@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 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
- <p align="center">
2
- <img src=".github/media/jsf_logo_dark.png" width="600" alt="json-schema-form">
3
- </p>
1
+ # Next
4
2
 
5
- <p align="center">
6
- <code>json-schema-form</code> is a headless UI form library powered by <a href="https://json-schema.org/">JSON Schemas</a>.
7
- <br/>
8
- It transforms JSON schemas into Javascript to be consumed by your UI libraries.
9
- </p>
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
- ### Why JSON Schemas for forms?
13
+ ## Development
14
14
 
15
- JSON Schemas are the SSoT (Single Source of Truth) that allows you to share form's _structure_ and _validations_ between frontend and backend, regardless of the language used.
15
+ Ensure that you isolate your workspace to the "next" folder only.
16
+ This means:
16
17
 
17
- ## Installation
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
- Available on [NPM](https://www.npmjs.com/package/@remoteoss/json-schema-form).
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
- ```bash
22
- npm install @remoteoss/json-schema-form
23
- # or
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
- ## Documentation
29
+ ## Node.js Version
29
30
 
30
- Check the 📚 **[JSF website](https://json-schema-form.vercel.app/)** for documentation and demos.
31
+ This project requires Node.js LTS v22.13.1.
32
+ We recommend using the exact version specified in `.nvmrc`:
31
33
 
32
- ## Contributing
34
+ Navigate to the "next" folder and run:
33
35
 
34
- Read [CONTRIBUTING](CONTRIBUTING.md) to get started.
36
+ ```bash
37
+ nvm use
38
+ ```
35
39
 
36
- _Backed by [Remote.com](https://remote.com/)_
40
+ Without the correct Node.js version,
41
+ tests and other development tasks will likely fail.
@@ -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
@@ -0,0 +1,3 @@
1
+ import antfu from '@antfu/eslint-config'
2
+
3
+ export default antfu({})
@@ -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.11.11-dev.20250220174843",
4
- "description": "Headless UI form powered by JSON Schemas",
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
- "main": "dist/index.cjs",
13
- "module": "dist/index.js",
14
- "typings": "./json-schema-form.d.ts",
15
- "files": [
16
- "dist",
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": "node scripts/build.js",
24
+ "build": "tsup",
26
25
  "test": "jest",
27
26
  "test:watch": "jest --watchAll",
28
- "lint": "eslint \"src/**/*.{js,ts}\"",
29
- "format": "npm run format:prettier && npm run format:eslint",
30
- "prepare": "husky install",
31
- "format:eslint": "eslint --fix \"src/**/*.{js,ts}\"",
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
- "@babel/core": "^7.21.5",
60
- "@babel/eslint-parser": "^7.25.9",
61
- "@babel/preset-env": "^7.21.5",
62
- "babel-jest": "^29.5.0",
63
- "babel-plugin-module-resolver": "^5.0.2",
64
- "child-process-promise": "^2.2.1",
65
- "esbuild": "^0.17.15",
66
- "eslint": "^7.32.0",
67
- "eslint-config-prettier": "^8.6.0",
68
- "eslint-plugin-import": "^2.27.5",
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
@@ -0,0 +1,3 @@
1
+ export function createHeadlessForm(): never {
2
+ throw new Error('Not implemented')
3
+ }
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
@@ -0,0 +1,13 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "strict": true,
6
+ "esModuleInterop": true,
7
+ "forceConsistentCasingInFileNames": true,
8
+ "skipLibCheck": true
9
+ },
10
+ "include": [
11
+ "src"
12
+ ]
13
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "clean": true,
3
+ "dts": true,
4
+ "entry": ["src/index.ts"],
5
+ "format": ["esm"],
6
+ "sourcemap": true,
7
+ "minify": true,
8
+ "target": "es2020",
9
+ "outDir": "dist"
10
+ }