@remoteoss/json-schema-form 0.4.1-dev.20230703203242 → 0.5.0-dev.20230705114115
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 +7 -0
- package/dist/index.cjs +5 -14
- package/dist/index.js +5 -14
- package/dist/standalone.js +5 -14
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +6 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
#### 0.4.1-beta.0 (2023-07-03)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **fieldset:** support root conditionals for fieldsets ([#23](https://github.com/remoteoss/json-schema-form/pull/23)) ([65d87b3a](https://github.com/remoteoss/json-schema-form/commit/65d87b3a93018f0729aed565000eb2a2ce1f2ce7))
|
|
6
|
+
* **select/radio:** Accept just the values in options (plus `''` and `null` for backward-compatibility) ([#18](https://github.com/remoteoss/json-schema-form/pull/18)) ([37501d2d](https://github.com/remoteoss/json-schema-form/commit/37501d2ddafdd5e207b34d2ca3f6b7b7a1006e9d))
|
|
7
|
+
|
|
1
8
|
#### 0.4.0-beta.0 (2023-06-22)
|
|
2
9
|
|
|
3
10
|
##### New Features
|
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.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230705114115
|
|
5
|
+
Generated: Wed, 05 Jul 2023 11:41:29 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -350,13 +350,6 @@ function convertDiskSizeFromTo(from, to) {
|
|
|
350
350
|
return value * Math.pow(1024, units.indexOf(from.toLowerCase())) / Math.pow(1024, units.indexOf(to.toLowerCase()));
|
|
351
351
|
};
|
|
352
352
|
}
|
|
353
|
-
function containsHTML(str = "") {
|
|
354
|
-
return /<[a-z][\s\S]*>/i.test(str);
|
|
355
|
-
}
|
|
356
|
-
function wrapWithSpan(html, properties = {}) {
|
|
357
|
-
const attributes = Object.entries(properties).reduce((acc, [key, value]) => `${acc}${key}="${value}" `, "").trim();
|
|
358
|
-
return `<span ${attributes}>${html}</span>`;
|
|
359
|
-
}
|
|
360
353
|
function hasProperty(object2, propertyName) {
|
|
361
354
|
return Object.prototype.hasOwnProperty.call(object2, propertyName);
|
|
362
355
|
}
|
|
@@ -878,7 +871,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
878
871
|
const errorMessage = pickXKey(schemaNode, "errorMessage") ?? {};
|
|
879
872
|
const node = (0, import_omit.default)(schemaNode, ["x-jsf-presentation", "presentation"]);
|
|
880
873
|
const description = presentation?.description || node.description;
|
|
881
|
-
const statementDescription =
|
|
874
|
+
const statementDescription = presentation.statement?.description;
|
|
882
875
|
return (0, import_omitBy.default)(
|
|
883
876
|
{
|
|
884
877
|
label: node.title,
|
|
@@ -914,10 +907,8 @@ function extractParametersFromNode(schemaNode) {
|
|
|
914
907
|
},
|
|
915
908
|
// Handle [name].presentation
|
|
916
909
|
...presentation,
|
|
917
|
-
description
|
|
918
|
-
|
|
919
|
-
}) : description,
|
|
920
|
-
extra: containsHTML(presentation.extra) ? wrapWithSpan(presentation.extra, { class: "jsf-extra" }) : presentation.extra,
|
|
910
|
+
description,
|
|
911
|
+
extra: presentation.extra,
|
|
921
912
|
statement: presentation.statement && {
|
|
922
913
|
...presentation.statement,
|
|
923
914
|
description: statementDescription
|
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.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230705114115
|
|
5
|
+
Generated: Wed, 05 Jul 2023 11:41:29 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -314,13 +314,6 @@ function convertDiskSizeFromTo(from, to) {
|
|
|
314
314
|
return value * Math.pow(1024, units.indexOf(from.toLowerCase())) / Math.pow(1024, units.indexOf(to.toLowerCase()));
|
|
315
315
|
};
|
|
316
316
|
}
|
|
317
|
-
function containsHTML(str = "") {
|
|
318
|
-
return /<[a-z][\s\S]*>/i.test(str);
|
|
319
|
-
}
|
|
320
|
-
function wrapWithSpan(html, properties = {}) {
|
|
321
|
-
const attributes = Object.entries(properties).reduce((acc, [key, value]) => `${acc}${key}="${value}" `, "").trim();
|
|
322
|
-
return `<span ${attributes}>${html}</span>`;
|
|
323
|
-
}
|
|
324
317
|
function hasProperty(object2, propertyName) {
|
|
325
318
|
return Object.prototype.hasOwnProperty.call(object2, propertyName);
|
|
326
319
|
}
|
|
@@ -842,7 +835,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
842
835
|
const errorMessage = pickXKey(schemaNode, "errorMessage") ?? {};
|
|
843
836
|
const node = omit(schemaNode, ["x-jsf-presentation", "presentation"]);
|
|
844
837
|
const description = presentation?.description || node.description;
|
|
845
|
-
const statementDescription =
|
|
838
|
+
const statementDescription = presentation.statement?.description;
|
|
846
839
|
return omitBy(
|
|
847
840
|
{
|
|
848
841
|
label: node.title,
|
|
@@ -878,10 +871,8 @@ function extractParametersFromNode(schemaNode) {
|
|
|
878
871
|
},
|
|
879
872
|
// Handle [name].presentation
|
|
880
873
|
...presentation,
|
|
881
|
-
description
|
|
882
|
-
|
|
883
|
-
}) : description,
|
|
884
|
-
extra: containsHTML(presentation.extra) ? wrapWithSpan(presentation.extra, { class: "jsf-extra" }) : presentation.extra,
|
|
874
|
+
description,
|
|
875
|
+
extra: presentation.extra,
|
|
885
876
|
statement: presentation.statement && {
|
|
886
877
|
...presentation.statement,
|
|
887
878
|
description: statementDescription
|
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.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230705114115
|
|
5
|
+
Generated: Wed, 05 Jul 2023 11:41:29 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11291,13 +11291,6 @@ function convertDiskSizeFromTo(from2, to) {
|
|
|
11291
11291
|
return value * Math.pow(1024, units.indexOf(from2.toLowerCase())) / Math.pow(1024, units.indexOf(to.toLowerCase()));
|
|
11292
11292
|
};
|
|
11293
11293
|
}
|
|
11294
|
-
function containsHTML(str = "") {
|
|
11295
|
-
return /<[a-z][\s\S]*>/i.test(str);
|
|
11296
|
-
}
|
|
11297
|
-
function wrapWithSpan(html, properties = {}) {
|
|
11298
|
-
const attributes = Object.entries(properties).reduce((acc, [key, value]) => `${acc}${key}="${value}" `, "").trim();
|
|
11299
|
-
return `<span ${attributes}>${html}</span>`;
|
|
11300
|
-
}
|
|
11301
11294
|
function hasProperty(object2, propertyName) {
|
|
11302
11295
|
return Object.prototype.hasOwnProperty.call(object2, propertyName);
|
|
11303
11296
|
}
|
|
@@ -11818,7 +11811,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
11818
11811
|
const errorMessage = pickXKey(schemaNode, "errorMessage") ?? {};
|
|
11819
11812
|
const node = (0, import_omit.default)(schemaNode, ["x-jsf-presentation", "presentation"]);
|
|
11820
11813
|
const description = presentation?.description || node.description;
|
|
11821
|
-
const statementDescription =
|
|
11814
|
+
const statementDescription = presentation.statement?.description;
|
|
11822
11815
|
return (0, import_omitBy.default)(
|
|
11823
11816
|
{
|
|
11824
11817
|
label: node.title,
|
|
@@ -11854,10 +11847,8 @@ function extractParametersFromNode(schemaNode) {
|
|
|
11854
11847
|
},
|
|
11855
11848
|
// Handle [name].presentation
|
|
11856
11849
|
...presentation,
|
|
11857
|
-
description
|
|
11858
|
-
|
|
11859
|
-
}) : description,
|
|
11860
|
-
extra: containsHTML(presentation.extra) ? wrapWithSpan(presentation.extra, { class: "jsf-extra" }) : presentation.extra,
|
|
11850
|
+
description,
|
|
11851
|
+
extra: presentation.extra,
|
|
11861
11852
|
statement: presentation.statement && {
|
|
11862
11853
|
...presentation.statement,
|
|
11863
11854
|
description: statementDescription
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-dev.20230705114115",
|
|
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",
|
|
@@ -439,23 +439,15 @@ describe('createHeadlessForm', () => {
|
|
|
439
439
|
|
|
440
440
|
// All allowed options are valid
|
|
441
441
|
validOptions.forEach((value) => {
|
|
442
|
-
expect(
|
|
443
|
-
validateForm({
|
|
444
|
-
[fieldName]: value,
|
|
445
|
-
})
|
|
446
|
-
).toBeUndefined();
|
|
442
|
+
expect(validateForm({ [fieldName]: value })).toBeUndefined();
|
|
447
443
|
});
|
|
448
444
|
|
|
449
445
|
// Any other arbitrary value is not valid.
|
|
450
|
-
expect(
|
|
451
|
-
validateForm({
|
|
452
|
-
[fieldName]: 'blah-blah',
|
|
453
|
-
})
|
|
454
|
-
).toEqual({
|
|
446
|
+
expect(validateForm({ [fieldName]: 'blah-blah' })).toEqual({
|
|
455
447
|
[fieldName]: 'The option "blah-blah" is not valid.',
|
|
456
448
|
});
|
|
457
449
|
|
|
458
|
-
//
|
|
450
|
+
// Given undefined, it says it's a required field.
|
|
459
451
|
expect(validateForm({})).toEqual({
|
|
460
452
|
[fieldName]: 'Required field',
|
|
461
453
|
});
|
|
@@ -831,6 +823,9 @@ describe('createHeadlessForm', () => {
|
|
|
831
823
|
|
|
832
824
|
describe('support "radio" optional field - more examples @BUG RMT-518', () => {
|
|
833
825
|
function assertCommonBehavior(validateForm) {
|
|
826
|
+
// Note: Very similar to assertOptionsAllowed()
|
|
827
|
+
// We could reuse it in a next iteration.
|
|
828
|
+
|
|
834
829
|
// Happy path
|
|
835
830
|
expect(validateForm({ has_car: 'yes' })).toBeUndefined();
|
|
836
831
|
|