@remoteoss/json-schema-form 0.11.11-dev.20250220174843 → 1.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nvmrc +1 -0
- package/.vscode/settings.json +51 -0
- package/README.md +29 -24
- package/babel.config.mjs +14 -0
- package/eslint.config.mjs +3 -0
- package/jest.config.mjs +52 -0
- package/package.json +27 -71
- package/src/form.ts +3 -0
- package/src/index.ts +1 -0
- package/src/utils.ts +24 -0
- package/test/form.test.ts +11 -0
- package/tsconfig.json +13 -0
- package/tsup.config.json +10 -0
- package/CHANGELOG.md +0 -320
- package/LICENSE +0 -21
- package/dist/index.cjs +0 -2171
- package/dist/index.js +0 -2140
- package/dist/standalone.js +0 -13656
- package/json-schema-form.d.ts +0 -175
- package/json-schema-form.schema.json +0 -188
- package/src/tests/checkIfConditionMatches.test.js +0 -65
- package/src/tests/conditions.test.js +0 -938
- package/src/tests/const.test.js +0 -236
- package/src/tests/createHeadlessForm.customValidations.test.js +0 -803
- package/src/tests/createHeadlessForm.test.js +0 -4324
- package/src/tests/helpers.custom.js +0 -222
- package/src/tests/helpers.js +0 -2385
- package/src/tests/internals.helpers.test.js +0 -175
- package/src/tests/jsonLogic.fixtures.js +0 -986
- package/src/tests/jsonLogic.test.js +0 -588
- package/src/tests/modify.test.js +0 -939
- package/src/tests/testUtils.js +0 -11
- package/src/tests/utils.test.jsx +0 -32
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
22.13.1
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Disable the default formatter, use eslint instead
|
|
3
|
+
"prettier.enable": false,
|
|
4
|
+
"editor.formatOnSave": false,
|
|
5
|
+
|
|
6
|
+
// Auto fix
|
|
7
|
+
"editor.codeActionsOnSave": {
|
|
8
|
+
"source.fixAll.eslint": "explicit",
|
|
9
|
+
"source.organizeImports": "never"
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
// Silent the stylistic rules in you IDE, but still auto fix them
|
|
13
|
+
"eslint.rules.customizations": [
|
|
14
|
+
{ "rule": "style/*", "severity": "off", "fixable": true },
|
|
15
|
+
{ "rule": "format/*", "severity": "off", "fixable": true },
|
|
16
|
+
{ "rule": "*-indent", "severity": "off", "fixable": true },
|
|
17
|
+
{ "rule": "*-spacing", "severity": "off", "fixable": true },
|
|
18
|
+
{ "rule": "*-spaces", "severity": "off", "fixable": true },
|
|
19
|
+
{ "rule": "*-order", "severity": "off", "fixable": true },
|
|
20
|
+
{ "rule": "*-dangle", "severity": "off", "fixable": true },
|
|
21
|
+
{ "rule": "*-newline", "severity": "off", "fixable": true },
|
|
22
|
+
{ "rule": "*quotes", "severity": "off", "fixable": true },
|
|
23
|
+
{ "rule": "*semi", "severity": "off", "fixable": true }
|
|
24
|
+
],
|
|
25
|
+
|
|
26
|
+
// Enable eslint for all supported languages
|
|
27
|
+
"eslint.validate": [
|
|
28
|
+
"javascript",
|
|
29
|
+
"javascriptreact",
|
|
30
|
+
"typescript",
|
|
31
|
+
"typescriptreact",
|
|
32
|
+
"vue",
|
|
33
|
+
"html",
|
|
34
|
+
"markdown",
|
|
35
|
+
"json",
|
|
36
|
+
"json5",
|
|
37
|
+
"jsonc",
|
|
38
|
+
"yaml",
|
|
39
|
+
"toml",
|
|
40
|
+
"xml",
|
|
41
|
+
"gql",
|
|
42
|
+
"graphql",
|
|
43
|
+
"astro",
|
|
44
|
+
"svelte",
|
|
45
|
+
"css",
|
|
46
|
+
"less",
|
|
47
|
+
"scss",
|
|
48
|
+
"pcss",
|
|
49
|
+
"postcss"
|
|
50
|
+
]
|
|
51
|
+
}
|
package/README.md
CHANGED
|
@@ -1,36 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
<img src=".github/media/jsf_logo_dark.png" width="600" alt="json-schema-form">
|
|
3
|
-
</p>
|
|
1
|
+
# Next
|
|
4
2
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
The current version (0.x) has some critical validation bugs
|
|
4
|
+
([examples](https://github.com/remoteoss/json-schema-form/pull/107)).
|
|
5
|
+
To fix them, we need to re-write the library internals.
|
|
6
|
+
This `next/` folder is where the rewriting is happening
|
|
7
|
+
(now in TypeScript, yey!).
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
We expect the main `createHeadlessForm()` API to remain the same,
|
|
10
|
+
avoiding any major breaking change.
|
|
11
|
+
This is under active development, more info soon!
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
## Development
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Ensure that you isolate your workspace to the "next" folder only.
|
|
16
|
+
This means:
|
|
16
17
|
|
|
17
|
-
|
|
18
|
+
1. In your editor, open only the "next" folder.
|
|
19
|
+
1. In your terminal, run commands when you are in the "next" folder only.
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
Otherwise, your editor may fail to set up linting and type checking,
|
|
22
|
+
while your terminal may fail to resolve paths.
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
yarn install @remoteoss/json-schema-form
|
|
26
|
-
```
|
|
24
|
+
The limitation of this approach is that
|
|
25
|
+
your editor will fail to recognise our git repository here.
|
|
26
|
+
This also means you should turn off the editor's suggestion
|
|
27
|
+
to open git repository at root.
|
|
27
28
|
|
|
28
|
-
##
|
|
29
|
+
## Node.js Version
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
This project requires Node.js LTS v22.13.1.
|
|
32
|
+
We recommend using the exact version specified in `.nvmrc`:
|
|
31
33
|
|
|
32
|
-
|
|
34
|
+
Navigate to the "next" folder and run:
|
|
33
35
|
|
|
34
|
-
|
|
36
|
+
```bash
|
|
37
|
+
nvm use
|
|
38
|
+
```
|
|
35
39
|
|
|
36
|
-
|
|
40
|
+
Without the correct Node.js version,
|
|
41
|
+
tests and other development tasks will likely fail.
|
package/babel.config.mjs
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @type {import('@babel/core').TransformOptions}
|
|
3
|
+
*/
|
|
4
|
+
const options = {
|
|
5
|
+
presets: [
|
|
6
|
+
['@babel/preset-env', { targets: { node: 'current' } }],
|
|
7
|
+
// Type checking is already done in our build,
|
|
8
|
+
// so we can use a lightweight preset.
|
|
9
|
+
// - https://jestjs.io/docs/getting-started#using-typescript
|
|
10
|
+
'@babel/preset-typescript',
|
|
11
|
+
],
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default options
|
package/jest.config.mjs
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This next version of JSON Schema Form ("V2")
|
|
3
|
+
* must be tested against 2 sets ("root") of tests.
|
|
4
|
+
* Note that "rootDir" is the path to this next version.
|
|
5
|
+
*
|
|
6
|
+
* @type {import('jest').Config['roots']}
|
|
7
|
+
*/
|
|
8
|
+
const roots = [
|
|
9
|
+
// 1. The existing tests from the previous version ("V1")
|
|
10
|
+
'<rootDir>/../src/tests',
|
|
11
|
+
// 2. The new tests for this version
|
|
12
|
+
'<rootDir>/test',
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Module aliases to use the same test with different source versions.
|
|
17
|
+
* To learn more, see "roots" above.
|
|
18
|
+
*
|
|
19
|
+
* This is only needed to use V1 tests for V2 source.
|
|
20
|
+
* as V2 tests are used to test V2 source only.
|
|
21
|
+
*
|
|
22
|
+
* @type {import('jest').Config['moduleNameMapper']}
|
|
23
|
+
*/
|
|
24
|
+
const moduleNameMapper = {
|
|
25
|
+
// We use kebab-case in V2
|
|
26
|
+
'^@/createHeadlessForm$': '<rootDir>/src/form',
|
|
27
|
+
'^@/utils$': '<rootDir>/src/utils',
|
|
28
|
+
// Avoid catch all aliases such as "^@/(.*)$".
|
|
29
|
+
// Aliases should be added as needed.
|
|
30
|
+
// If there are many, we will have a compat barrel file.
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Some tests are invalid for V2 testing.
|
|
35
|
+
* For example:
|
|
36
|
+
* - Buggy behaviours in V1 that are already fixed (and tested) in V2
|
|
37
|
+
* - Deprecated or removed APIs
|
|
38
|
+
*
|
|
39
|
+
* @type {import('jest').Config['testPathIgnorePatterns']}
|
|
40
|
+
*/
|
|
41
|
+
const testPathIgnorePatterns = [
|
|
42
|
+
// Nothing yet
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
/** @type {import('jest').Config} */
|
|
46
|
+
const config = {
|
|
47
|
+
roots,
|
|
48
|
+
moduleNameMapper,
|
|
49
|
+
testPathIgnorePatterns,
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export default config
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.0.0-beta.0",
|
|
4
|
+
"packageManager": "pnpm@9.15.2",
|
|
5
|
+
"description": "WIP V2 – Headless UI form powered by JSON Schemas",
|
|
5
6
|
"author": "Remote.com <engineering@remote.com> (https://remote.com/)",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"homepage": "https://json-schema-form.vercel.app/",
|
|
@@ -9,80 +10,35 @@
|
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "https://github.com/remoteoss/json-schema-form.git"
|
|
11
12
|
},
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"src/tests",
|
|
18
|
-
"json-schema-form.schema.json",
|
|
19
|
-
"json-schema-form.d.ts",
|
|
20
|
-
"README.md",
|
|
21
|
-
"CHANGELOG.md",
|
|
22
|
-
"LICENSE.md"
|
|
13
|
+
"keywords": [
|
|
14
|
+
"JSON",
|
|
15
|
+
"schema",
|
|
16
|
+
"json-schema",
|
|
17
|
+
"form"
|
|
23
18
|
],
|
|
19
|
+
"main": "index.js",
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.14.0"
|
|
22
|
+
},
|
|
24
23
|
"scripts": {
|
|
25
|
-
"build": "
|
|
24
|
+
"build": "tsup",
|
|
26
25
|
"test": "jest",
|
|
27
26
|
"test:watch": "jest --watchAll",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"format:prettier": "prettier --write \"src/**/*.{js,ts}\"",
|
|
33
|
-
"prettier:check": "prettier --check \"src/**/*.{js,ts}\"",
|
|
34
|
-
"check:pr-version": "node scripts/pr_dev_version",
|
|
35
|
-
"check:pr-next-version": "node scripts/pr_next_dev_version",
|
|
36
|
-
"release:local": "node scripts/release_local",
|
|
37
|
-
"release:dev:patch": "node scripts/release_dev patch",
|
|
38
|
-
"release:dev:minor": "node scripts/release_dev minor",
|
|
39
|
-
"release:main:patch": "node scripts/release_main patch",
|
|
40
|
-
"release:main:minor": "node scripts/release_main minor",
|
|
41
|
-
"release:v1:dev": "node scripts/release_v1 dev",
|
|
42
|
-
"release:v1:beta": "node scripts/release_v1 beta",
|
|
43
|
-
"version_as_main": "node scripts/version_as_main.js",
|
|
44
|
-
"psrepublishOnly": "if [[ ! $PWD =~ scripts$ ]]; then npm run publish:nopublish; fi",
|
|
45
|
-
"psublish:nopublish": "echo 'Use `npm release:*` script instead && exit 1"
|
|
46
|
-
},
|
|
47
|
-
"lint-staged": {
|
|
48
|
-
"*.{js,jsx}": [
|
|
49
|
-
"npm run format"
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"json-logic-js": "^2.0.2",
|
|
54
|
-
"lodash": "^4.17.21",
|
|
55
|
-
"randexp": "^0.5.3",
|
|
56
|
-
"yup": "^0.30.0"
|
|
27
|
+
"test:file": "jest --runTestsByPath",
|
|
28
|
+
"lint": "eslint --max-warnings 0 .",
|
|
29
|
+
"release:dev": "cd .. && npm run release:v1:dev",
|
|
30
|
+
"release:beta": "cd .. && npm run release:v1:beta"
|
|
57
31
|
},
|
|
58
32
|
"devDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@babel/
|
|
61
|
-
"@babel/preset-env": "^7.
|
|
62
|
-
"babel-
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"eslint-plugin-jest": "^27.2.1",
|
|
70
|
-
"eslint-plugin-prettier": "^4.2.1",
|
|
71
|
-
"eslint-plugin-sort-keys": "^2.3.5",
|
|
72
|
-
"eslint-plugin-unused-imports": "^1.1.5",
|
|
73
|
-
"fs-extra": "^11.1.1",
|
|
74
|
-
"generate-changelog": "^1.8.0",
|
|
75
|
-
"husky": "^8.0.3",
|
|
76
|
-
"jest": "^29.5.0",
|
|
77
|
-
"jest-environment-jsdom": "^29.5.0",
|
|
78
|
-
"lint-staged": "^13.2.2",
|
|
79
|
-
"semver": "^7.5.1"
|
|
80
|
-
},
|
|
81
|
-
"keywords": [
|
|
82
|
-
"json schemas",
|
|
83
|
-
"form"
|
|
84
|
-
],
|
|
85
|
-
"engines": {
|
|
86
|
-
"node": ">=18.14.0"
|
|
33
|
+
"@antfu/eslint-config": "^3.14.0",
|
|
34
|
+
"@babel/core": "^7.23.7",
|
|
35
|
+
"@babel/preset-env": "^7.23.7",
|
|
36
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
37
|
+
"@jest/globals": "^29.7.0",
|
|
38
|
+
"babel-jest": "^29.7.0",
|
|
39
|
+
"eslint": "^9.18.0",
|
|
40
|
+
"jest": "^29.7.0",
|
|
41
|
+
"tsup": "^8.3.5",
|
|
42
|
+
"typescript": "^5.7.3"
|
|
87
43
|
}
|
|
88
44
|
}
|
package/src/form.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createHeadlessForm } from './form'
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type DiskSizeUnit = 'Bytes' | 'KB' | 'MB'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @todo: Remove this.
|
|
5
|
+
*
|
|
6
|
+
* This utility only exists as an example of using V1 tests for V2 source.
|
|
7
|
+
* It should not be tested, or even part of JSON Schema Form.
|
|
8
|
+
*/
|
|
9
|
+
export function convertDiskSizeFromTo(
|
|
10
|
+
from: DiskSizeUnit,
|
|
11
|
+
to: DiskSizeUnit,
|
|
12
|
+
): (value: number) => number {
|
|
13
|
+
const multipliers: Record<DiskSizeUnit, number> = {
|
|
14
|
+
Bytes: 1,
|
|
15
|
+
KB: 1024,
|
|
16
|
+
MB: 1024 * 1024,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (value: number): number => {
|
|
20
|
+
const fromMultiplier = multipliers[from]
|
|
21
|
+
const toMultiplier = multipliers[to]
|
|
22
|
+
return (value * fromMultiplier) / toMultiplier
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, expect, it } from '@jest/globals'
|
|
2
|
+
import { createHeadlessForm } from '../src'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Example test suite for V2
|
|
6
|
+
*/
|
|
7
|
+
describe('createHeadlessForm', () => {
|
|
8
|
+
it('should be a function', () => {
|
|
9
|
+
expect(createHeadlessForm).toBeInstanceOf(Function)
|
|
10
|
+
})
|
|
11
|
+
})
|
package/tsconfig.json
ADDED