@remoteoss/json-schema-form 0.1.0-dev.20230517211625 → 0.1.1-dev.20230613092121
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/CHANGELOG.md +3 -31
- package/README.md +11 -0
- package/dist/index.cjs +12 -4
- package/dist/index.js +12 -4
- package/dist/standalone.js +12 -4
- package/json-schema-form.schema.json +188 -0
- package/package.json +4 -1
- package/src/tests/createHeadlessForm.customValidations.test.jsx +799 -0
- package/src/tests/createHeadlessForm.test.js +3343 -0
- package/src/tests/helpers.custom.js +223 -0
- package/src/tests/helpers.js +1983 -0
- package/src/tests/internals.helpers.test.js +175 -0
- package/src/tests/utils.test.jsx +32 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,33 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
#### 0.1.0-beta.0 (2023-05-18)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
##### New Features
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
<!-- Type of changes:
|
|
11
|
-
- Added
|
|
12
|
-
- Changed
|
|
13
|
-
- Deprecated
|
|
14
|
-
- Removed
|
|
15
|
-
- Fixed
|
|
16
|
-
- Security
|
|
17
|
-
-->
|
|
18
|
-
|
|
19
|
-
<!-- eg:
|
|
20
|
-
### Added
|
|
21
|
-
- Short description about it. ([#pr-id](https://github.com/remoteoss/jsf/pull/<pr-id>))
|
|
22
|
-
|
|
23
|
-
### Deprecated
|
|
24
|
-
- Deprecated `xxx` in favor of `yyy`. ([#pr-id](https://github.com/remoteoss/jsf/pull/<pr-id>))
|
|
25
|
-
-->
|
|
26
|
-
|
|
27
|
-
## [1.0.0-beta.1] - 2023-XX-XX
|
|
28
|
-
|
|
29
|
-
### Added
|
|
30
|
-
|
|
31
|
-
- Initial public release. ([#1](https://github.com/remoteoss/jsf/pull/1))
|
|
32
|
-
|
|
33
|
-
---
|
|
5
|
+
- Initial release ([#1](https://github.com/remoteoss/json-schema-form/pull/1)) ([9a687351](https://github.com/remoteoss/json-schema-form/commit/9a6873513445a7a53e9f9222d457c5ce585cbbd8) and ([#5](https://github.com/remoteoss/json-schema-form/pull/5)) ([ceb6f47b](https://github.com/remoteoss/json-schema-form/commit/ceb6f47b3d1ff031e1789a504af32ecc36834d8e))
|
package/README.md
CHANGED
|
@@ -14,6 +14,17 @@
|
|
|
14
14
|
|
|
15
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.
|
|
16
16
|
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Available on [NPM](https://www.npmjs.com/package/@remoteoss/json-schema-form).
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @remoteoss/json-schema-form
|
|
23
|
+
# or
|
|
24
|
+
|
|
25
|
+
yarn install @remoteoss/json-schema-form
|
|
26
|
+
```
|
|
27
|
+
|
|
17
28
|
## Documentation
|
|
18
29
|
|
|
19
30
|
Check the 📚 **[JSF website](https://json-schema-form.vercel.app/)** for documentation and demos.
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.1.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.1.1-dev.20230613092121
|
|
5
|
+
Generated: Tue, 13 Jun 2023 09:21:43 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -58,7 +58,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
58
58
|
// src/index.js
|
|
59
59
|
var src_exports = {};
|
|
60
60
|
__export(src_exports, {
|
|
61
|
-
|
|
61
|
+
buildCompleteYupSchema: () => buildCompleteYupSchema,
|
|
62
|
+
createHeadlessForm: () => createHeadlessForm,
|
|
63
|
+
pickXKey: () => pickXKey
|
|
62
64
|
});
|
|
63
65
|
module.exports = __toCommonJS(src_exports);
|
|
64
66
|
|
|
@@ -369,8 +371,14 @@ var baseString = (0, import_yup.string)().trim();
|
|
|
369
371
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
370
372
|
var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
|
|
371
373
|
var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
|
|
374
|
+
var useOnlyStrings = (value, originalValue) => {
|
|
375
|
+
if (typeof originalValue === "string") {
|
|
376
|
+
return originalValue;
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
};
|
|
372
380
|
var yupSchemas = {
|
|
373
|
-
text: (0, import_yup.string)().trim().nullable(),
|
|
381
|
+
text: (0, import_yup.string)().transform(useOnlyStrings).trim().nullable(),
|
|
374
382
|
select: (0, import_yup.string)().trim().nullable(),
|
|
375
383
|
radio: (0, import_yup.string)().trim().nullable(),
|
|
376
384
|
date: (0, import_yup.string)().nullable().trim().matches(
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.1.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.1.1-dev.20230613092121
|
|
5
|
+
Generated: Tue, 13 Jun 2023 09:21:43 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -335,8 +335,14 @@ var baseString = string().trim();
|
|
|
335
335
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
336
336
|
var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
|
|
337
337
|
var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
|
|
338
|
+
var useOnlyStrings = (value, originalValue) => {
|
|
339
|
+
if (typeof originalValue === "string") {
|
|
340
|
+
return originalValue;
|
|
341
|
+
}
|
|
342
|
+
return null;
|
|
343
|
+
};
|
|
338
344
|
var yupSchemas = {
|
|
339
|
-
text: string().trim().nullable(),
|
|
345
|
+
text: string().transform(useOnlyStrings).trim().nullable(),
|
|
340
346
|
select: string().trim().nullable(),
|
|
341
347
|
radio: string().trim().nullable(),
|
|
342
348
|
date: string().nullable().trim().matches(
|
|
@@ -1170,5 +1176,7 @@ function createHeadlessForm(jsonSchema, customConfig = {}) {
|
|
|
1170
1176
|
}
|
|
1171
1177
|
}
|
|
1172
1178
|
export {
|
|
1173
|
-
|
|
1179
|
+
buildCompleteYupSchema,
|
|
1180
|
+
createHeadlessForm,
|
|
1181
|
+
pickXKey
|
|
1174
1182
|
};
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2023 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.1.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.1.1-dev.20230613092121
|
|
5
|
+
Generated: Tue, 13 Jun 2023 09:21:43 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11739,8 +11739,14 @@ var baseString = StringSchema().trim();
|
|
|
11739
11739
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
11740
11740
|
var convertBytesToKB = convertDiskSizeFromTo("Bytes", "KB");
|
|
11741
11741
|
var convertKbBytesToMB = convertDiskSizeFromTo("KB", "MB");
|
|
11742
|
+
var useOnlyStrings = (value, originalValue) => {
|
|
11743
|
+
if (typeof originalValue === "string") {
|
|
11744
|
+
return originalValue;
|
|
11745
|
+
}
|
|
11746
|
+
return null;
|
|
11747
|
+
};
|
|
11742
11748
|
var yupSchemas = {
|
|
11743
|
-
text: StringSchema().trim().nullable(),
|
|
11749
|
+
text: StringSchema().transform(useOnlyStrings).trim().nullable(),
|
|
11744
11750
|
select: StringSchema().trim().nullable(),
|
|
11745
11751
|
radio: StringSchema().trim().nullable(),
|
|
11746
11752
|
date: StringSchema().nullable().trim().matches(
|
|
@@ -12574,5 +12580,7 @@ function createHeadlessForm(jsonSchema, customConfig = {}) {
|
|
|
12574
12580
|
}
|
|
12575
12581
|
}
|
|
12576
12582
|
export {
|
|
12577
|
-
|
|
12583
|
+
buildCompleteYupSchema,
|
|
12584
|
+
createHeadlessForm,
|
|
12585
|
+
pickXKey
|
|
12578
12586
|
};
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "JSON json-schema-form-Schema",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"schemaArray": {
|
|
6
|
+
"allOf": [
|
|
7
|
+
{
|
|
8
|
+
"$ref": "http://json-schema.org/draft-07/schema#/definitions/schemaArray"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"items": { "$ref": "#" }
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"allOf": [{ "$ref": "http://json-schema.org/draft-07/schema#" }],
|
|
17
|
+
"properties": {
|
|
18
|
+
"additionalItems": { "$ref": "#" },
|
|
19
|
+
"additionalProperties": { "$ref": "#" },
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"additionalProperties": {
|
|
22
|
+
"anyOf": [{ "$ref": "#" }, { "type": "array" }]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"items": {
|
|
26
|
+
"anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/schemaArray" }]
|
|
27
|
+
},
|
|
28
|
+
"definitions": {
|
|
29
|
+
"additionalProperties": { "$ref": "#" }
|
|
30
|
+
},
|
|
31
|
+
"patternProperties": {
|
|
32
|
+
"additionalProperties": { "$ref": "#" }
|
|
33
|
+
},
|
|
34
|
+
"properties": {
|
|
35
|
+
"additionalProperties": { "$ref": "#" }
|
|
36
|
+
},
|
|
37
|
+
"if": { "$ref": "#" },
|
|
38
|
+
"then": { "$ref": "#" },
|
|
39
|
+
"else": { "$ref": "#" },
|
|
40
|
+
"allOf": { "$ref": "#/definitions/schemaArray" },
|
|
41
|
+
"anyOf": { "$ref": "#/definitions/schemaArray" },
|
|
42
|
+
"oneOf": { "$ref": "#/definitions/schemaArray" },
|
|
43
|
+
"not": { "$ref": "#" },
|
|
44
|
+
"contains": { "$ref": "#" },
|
|
45
|
+
"propertyNames": { "$ref": "#" },
|
|
46
|
+
"x-jsf-order": {
|
|
47
|
+
"description": "This keyword defines the order of fields for a given form or fieldset. It's placed at the schema root and inside of each fieldset.",
|
|
48
|
+
"$ref": "http://json-schema.org/draft-07/schema#/definitions/stringArray"
|
|
49
|
+
},
|
|
50
|
+
"x-jsf-errorMessage": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"additionalProperties": false,
|
|
53
|
+
"properties": {
|
|
54
|
+
"type": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"description": "Message shown when the value is not of the correct type."
|
|
57
|
+
},
|
|
58
|
+
"required": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"description": "Message shown when the value is required and not provided."
|
|
61
|
+
},
|
|
62
|
+
"minimum": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "Message shown when the value is less than the minimum value."
|
|
65
|
+
},
|
|
66
|
+
"minLength": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"description": "Message shown when the value is less than the minimum length."
|
|
69
|
+
},
|
|
70
|
+
"maximum": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "Message shown when the value is greater than the maximum value."
|
|
73
|
+
},
|
|
74
|
+
"maxLength": {
|
|
75
|
+
"type": "string",
|
|
76
|
+
"description": "Message shown when the value is greater than the maximum length."
|
|
77
|
+
},
|
|
78
|
+
"pattern": {
|
|
79
|
+
"type": "string",
|
|
80
|
+
"description": "Message shown when the value is not the correct format and does not match the pattern property."
|
|
81
|
+
},
|
|
82
|
+
"maxFileSize": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"description": "Message shown when the file size is greater than the maximum file size."
|
|
85
|
+
},
|
|
86
|
+
"accept": {
|
|
87
|
+
"type": "string",
|
|
88
|
+
"description": "Message shown when the file type is not accepted."
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
"x-jsf-presentation": {
|
|
93
|
+
"type": "object",
|
|
94
|
+
"description": "Presentation overrides for the schema",
|
|
95
|
+
"properties": {
|
|
96
|
+
"inputType": {
|
|
97
|
+
"description": "Input type for the generated UI field",
|
|
98
|
+
"type": "string",
|
|
99
|
+
"anyOf": [
|
|
100
|
+
{
|
|
101
|
+
"const": "text",
|
|
102
|
+
"description": "Similar to the native HTML input with text type."
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"const": "select",
|
|
106
|
+
"description": "Similar to the native HTML select element."
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"const": "radio",
|
|
110
|
+
"description": "Similar to a native HTML input with radio type."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"const": "number",
|
|
114
|
+
"description": "Similar to the native HTML input with number type."
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"const": "date",
|
|
118
|
+
"description": "Expects a value with format YYY-MM-DD."
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"const": "checkbox",
|
|
122
|
+
"description": "Similar to the native HTML input with checkbox type."
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"const": "email",
|
|
126
|
+
"description": "Similar to the native HTML input with email type."
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"const": "file",
|
|
130
|
+
"description": "Similar to the native HTML input with file type."
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"const": "fieldset",
|
|
134
|
+
"description": "Groups multiple Fields inside. Its expected value is a nested object."
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"const": "group-array",
|
|
138
|
+
"description": "A list of inputs that can be repeated. Its expected value is an array."
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "string",
|
|
142
|
+
"description": "Any arbitrary custom inputType you might want to represent your UI Field."
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
"accept": {
|
|
147
|
+
"description": "For `inputType: \"file\"`. The accepted file types, as a comma separated string.",
|
|
148
|
+
"type": "string"
|
|
149
|
+
},
|
|
150
|
+
"description": {
|
|
151
|
+
"description": "Field description with HTML. If you don't need HTML, please use the native description keyword.",
|
|
152
|
+
"type": "string"
|
|
153
|
+
},
|
|
154
|
+
"statement": {
|
|
155
|
+
"description": "Special message about the field. Useful in cases where this message is based on the field value.",
|
|
156
|
+
"type": "object",
|
|
157
|
+
"properties": {
|
|
158
|
+
"title": {
|
|
159
|
+
"type": "string"
|
|
160
|
+
},
|
|
161
|
+
"description": {
|
|
162
|
+
"description": "The sentence itself. Might include HTML.",
|
|
163
|
+
"type": "string"
|
|
164
|
+
},
|
|
165
|
+
"severity": {
|
|
166
|
+
"description": "Defines the type of message.",
|
|
167
|
+
"anyOf": [
|
|
168
|
+
{ "type": "string", "const": "info" },
|
|
169
|
+
{ "type": "string", "const": "warning" },
|
|
170
|
+
{ "type": "string", "const": "error" },
|
|
171
|
+
{ "type": "string", "const": "success" },
|
|
172
|
+
{}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"maxFileSize": {
|
|
178
|
+
"description": "For `inputType: \"file\"`. The maximum file size in KB. It's used to enhanced Yup validation.",
|
|
179
|
+
"type": "number"
|
|
180
|
+
},
|
|
181
|
+
"addFieldText": {
|
|
182
|
+
"description": "Used in `group-array` fields. The button text to add a new field.",
|
|
183
|
+
"type": "string"
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1-dev.20230613092121",
|
|
4
4
|
"description": "Headless UI form powered by JSON Schemas",
|
|
5
5
|
"author": "Remote.com <engineering@remote.com> (https://remote.com/)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"module": "dist/index.js",
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
+
"src/tests",
|
|
17
|
+
"json-schema-form.schema.json",
|
|
16
18
|
"README.md",
|
|
17
19
|
"CHANGELOG.md",
|
|
18
20
|
"LICENSE.md"
|
|
@@ -20,6 +22,7 @@
|
|
|
20
22
|
"scripts": {
|
|
21
23
|
"build": "node scripts/build.js",
|
|
22
24
|
"test": "jest",
|
|
25
|
+
"test:watch": "jest --watchAll",
|
|
23
26
|
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
24
27
|
"format": "npm run format:prettier && npm run format:eslint",
|
|
25
28
|
"prepare": "husky install",
|