Installations
npm install @luomus/laji-form
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
16.20.2
NPM Version
8.19.4
Score
49.9
Supply Chain
63.6
Quality
91.8
Maintenance
100
Vulnerability
84.7
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (59.56%)
TypeScript (35.66%)
CSS (4.5%)
Shell (0.22%)
HTML (0.04%)
Dockerfile (0.02%)
validate.email 🚀
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Developer
luomus
Download Statistics
Total Downloads
4,017
Last Day
2
Last Week
40
Last Month
299
Last Year
2,518
GitHub Statistics
MIT License
4,246 Commits
5 Watchers
8 Branches
7 Contributors
Updated on Feb 14, 2025
Package Meta Information
Latest Version
15.1.33
Package Id
@luomus/laji-form@15.1.33
Unpacked Size
3.59 MB
Size
904.23 kB
File Count
251
NPM Version
8.19.4
Node Version
16.20.2
Published on
Feb 14, 2025
Total Downloads
Cumulative downloads
Total Downloads
4,017
Last Day
-33.3%
2
Compared to previous day
Last Week
-73.2%
40
Compared to previous week
Last Month
64.3%
299
Compared to previous month
Last Year
68%
2,518
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
32
Dev Dependencies
22
README
LajiForm is a dynamic form built on React. It can be used as a standalone library or as a React component. LajiForm is a wrapper for react-jsonschema-form.
Installing
npm install @luomus/laji-form --save
If you are going to use the bootstrap 3 theme, you need to install also react-bootstrap
:
npm install react-bootstrap@0.33.1 --save
Usage as a library
LajiForm passes all its properties to react-jsonschema-form. Read the documentation for react-jsonschema-form.
Usage as a standalone library
import LajiForm from "laji-form";
new LajiForm({
schema: schema,
uiSchema: uiSchema, formData: formData,
rootElem: document.getElementById("app")
});
You can update the properties with setState(props)
. You need to pass only the properties that you are changing, since it just calls the React component's setState(props)
.
You can unmount the component with unmount()
.
Usage as a React component
import React from "react";
import { render } from "react-dom";
import LajiForm from "laji-form/lib/components/LajiForm";
render(<LajiForm
schema={...}
uiSchema={...}
formData={...} />,
document.getElementById("app"));
API Client
In addition to properties you would pass to <Form />, you must pass an api client implementation, if you need to use fields that use lajitest.api.fi. The api client implementation must have fetch()
-method, which returns a Promise.
fetch(path, query, options)
parameters are as follows:
- path: URL path for GET.
- query: Object, where keys are param names and values are param values.
- options: Object containing options for request.
See the example implementation in src/playground/ApiClientImplementation.js.
Pass the implementation to LajiForm like so:
<LajiForm apiClient={new ApiClientImplementation()} ... />
Themes
Bootstrap 3
LajiForm provides bootstrap 3 theme. To use it, you need to install react-bootstrap@0.33.1
and provide the built-in bootstrap 3 theme it as a prop:
import bs3 from "laji-form/lib/themes/bs3";
<LajiForm theme={bs3} ... />
Bootstrap 5
To use bootstrap 5 theme, you need to install following packages:
npm install --save react-bootstrap-5@npm:react-bootstrap@2.5.0
mpn install --save @fortawesome/fontawesome-svg-core@6.2.0
npm install --save @fortawesome/free-solid-svg-icons@6.2.0
npm install --save @fortawesome/react-fontawesome@0.2.0
Then it can be used by providing the theme to the form:
import bs5 from "laji-form/lib/themes/bs5";
<LajiForm theme={bs5} ... />
You can also use a custom theme and provide it the same way. There is a theme interface themes/theme.ts
which the theme must implement.
Notifications
LajiForm expects a notification implementation as a paratemer notifier
. The notifier
object must implement the interface below:
{
success: message => (),
warning: message => (),
info: message => (),
error: message => (),
}
Styles
Styles can be found at dist/styles.css
.
Development
Run npm ci
to install the dependencies and npm start
to start the app.
Before running, you'll need to configure your personal apitest.laji.fi access token. Get the key to your email:
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" -d "{\
\"email\": \"<YOUR EMAIL ADDRESS>\"\
}" "http://apitest.laji.fi/v0/api-token"
Copy settings template file:
cp properties.json.example properties.json
Then put the API access token you got in your email to properties.json
. Put also your user access token & user ID there. Google API key is needed only for using the reverse geo location for foreign locations.
Try to keep the code style consistent - npm run lint
should pass without errors.
Developing different forms
Start the server and navigate to the local playground http://localhost:8083?id={form_id}
Playground query parameters
Option | Default | Description |
---|---|---|
id | - | Form id to use. If empty, playground/schemas.json will be used for form schemas. |
local | false | Use local schemas under forms/ instead of fetching from apitest.laji.fi. |
localFormData | false | Use local formData under forms/${id}.formData.json instead of form's prepopulatedDocument . |
settings | true | Use local settings defined in playground/schemas . |
lang | fi | Language of the form. Doesn't affect local forms. |
readonly | false | Sets the form readonly. |
Examples
http://localhost:8083?id=JX.519 Trip report form with empty formData
.
http://localhost:8083?id=MHL.1&localFormData=true Line transect form with local formData
.
Tests
You might need to install playwright dependencies to run the tests:
npx playwright install
The playground server can be running or or not. If it's not running, it will be automatically started.
Run the tests:
npm test
If you run into issues with browser dependencies etc, there's also a dockerized runner:
# Run all tests (builds docker image & runs it)
npm run test:docker
# Or if you want to give playwright params, run certain tests etc:
npm run test:docker -- test/mobile-form.spec.ts --project chromium

No vulnerabilities found.
Reason
30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
- Warn: containerImage not pinned by hash: test.Dockerfile:1: pin your Docker image by updating mcr.microsoft.com/playwright:v1.40.1 to mcr.microsoft.com/playwright:v1.40.1@sha256:1aba528f5db4f4c130653ed1de737ddc1d276197cc4503d3bb7903a93b7fb32e
- Info: 1 out of 1 npmCommand dependencies pinned
- Info: 0 out of 1 containerImage dependencies pinned
Reason
Found 2/23 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Reason
33 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-4gmj-3p3h-gm8h
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq
- Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488
- Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4
- Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
3.2
/10
Last Scanned on 2025-02-17
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More