@remoteoss/json-schema-form 0.7.5-dev.20231115020835 → 0.7.7-dev.20240129180839
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 +15 -1
- package/dist/index.cjs +6 -10
- package/dist/index.js +6 -10
- package/dist/standalone.js +6 -10
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.customValidations.test.jsx +14 -8
- package/src/tests/createHeadlessForm.test.js +28 -65
- package/src/tests/helpers.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
#### 0.7.6-beta.0 (2024-01-23)
|
|
2
|
+
|
|
3
|
+
##### Chores
|
|
4
|
+
|
|
5
|
+
BREAKING CHANGES:
|
|
6
|
+
|
|
7
|
+
- **select:** Remove creatable logic ([#62](https://github.com/remoteoss/json-schema-form/pull/62)) ([0a6273c6](https://github.com/remoteoss/json-schema-form/commit/0a6273c63049a2f03bcf0b212dec6455ab48b5e5)) Added in 0.7.1
|
|
8
|
+
|
|
9
|
+
#### 0.7.5-beta.0 (2023-11-15)
|
|
10
|
+
|
|
11
|
+
##### Chores
|
|
12
|
+
|
|
13
|
+
- Follow-up of #57. Ignore internal attributes from conditional attributes removal (`visibilityCondition`) ([#59](https://github.com/remoteoss/json-schema-form/pull/59)) ([57fe4468](https://github.com/remoteoss/json-schema-form/commit/57fe446834636d727a5da5a91f7e5f3cc4eab8f8))
|
|
14
|
+
|
|
1
15
|
#### 0.7.4-beta.0 (2023-11-07)
|
|
2
16
|
|
|
3
17
|
##### Chores
|
|
4
18
|
|
|
5
|
-
- Follow-up of #57. Ignore internal attributes from conditional attributes removal ([#58](https://github.com/remoteoss/json-schema-form/pull/58)) ([ee762c2e](https://github.com/remoteoss/json-schema-form/commit/ee762c2e90834a9ec0d7b88af47cefe1e3a03dd1))
|
|
19
|
+
- Follow-up of #57. Ignore internal attributes from conditional attributes removal (`Component`, `calculateDynamicProperties`) ([#58](https://github.com/remoteoss/json-schema-form/pull/58)) ([ee762c2e](https://github.com/remoteoss/json-schema-form/commit/ee762c2e90834a9ec0d7b88af47cefe1e3a03dd1))
|
|
6
20
|
|
|
7
21
|
#### 0.7.3-beta.0 (2023-11-07)
|
|
8
22
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
Copyright (c)
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.7.
|
|
5
|
-
Generated:
|
|
3
|
+
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.7.7-dev.20240129180839
|
|
5
|
+
Generated: Mon, 29 Jan 2024 18:09:02 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -461,10 +461,7 @@ var validateMaxDate = (value, minDate) => {
|
|
|
461
461
|
};
|
|
462
462
|
var yupSchemas = {
|
|
463
463
|
text: validateOnlyStrings,
|
|
464
|
-
radioOrSelect: (options
|
|
465
|
-
if (isString) {
|
|
466
|
-
return (0, import_yup.string)().nullable();
|
|
467
|
-
}
|
|
464
|
+
radioOrSelect: (options) => {
|
|
468
465
|
return (0, import_yup.string)().nullable().transform((value) => {
|
|
469
466
|
if (value === "") {
|
|
470
467
|
return void 0;
|
|
@@ -568,9 +565,8 @@ var getOptions = (field) => {
|
|
|
568
565
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
569
566
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
570
567
|
if (field.options?.length > 0) {
|
|
571
|
-
const isString = field.options?.findIndex((option) => option.type === "string") > -1;
|
|
572
568
|
const optionValues = getOptions(field);
|
|
573
|
-
return yupSchemas.radioOrSelect(optionValues
|
|
569
|
+
return yupSchemas.radioOrSelect(optionValues);
|
|
574
570
|
}
|
|
575
571
|
if (field.format === "date") {
|
|
576
572
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
|
@@ -1671,7 +1667,7 @@ function buildFieldParameters(name, fieldProperties, required = [], config = {},
|
|
|
1671
1667
|
fields = getFieldsFromJSONSchema(
|
|
1672
1668
|
fieldProperties,
|
|
1673
1669
|
{
|
|
1674
|
-
customProperties: (0, import_get3.default)(config, `customProperties.${name}`, {}),
|
|
1670
|
+
customProperties: (0, import_get3.default)(config, `customProperties.${name}.customProperties`, {}),
|
|
1675
1671
|
parentID: name
|
|
1676
1672
|
},
|
|
1677
1673
|
logic
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
Copyright (c)
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.7.
|
|
5
|
-
Generated:
|
|
3
|
+
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.7.7-dev.20240129180839
|
|
5
|
+
Generated: Mon, 29 Jan 2024 18:09:02 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -425,10 +425,7 @@ var validateMaxDate = (value, minDate) => {
|
|
|
425
425
|
};
|
|
426
426
|
var yupSchemas = {
|
|
427
427
|
text: validateOnlyStrings,
|
|
428
|
-
radioOrSelect: (options
|
|
429
|
-
if (isString) {
|
|
430
|
-
return string().nullable();
|
|
431
|
-
}
|
|
428
|
+
radioOrSelect: (options) => {
|
|
432
429
|
return string().nullable().transform((value) => {
|
|
433
430
|
if (value === "") {
|
|
434
431
|
return void 0;
|
|
@@ -532,9 +529,8 @@ var getOptions = (field) => {
|
|
|
532
529
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
533
530
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
534
531
|
if (field.options?.length > 0) {
|
|
535
|
-
const isString = field.options?.findIndex((option) => option.type === "string") > -1;
|
|
536
532
|
const optionValues = getOptions(field);
|
|
537
|
-
return yupSchemas.radioOrSelect(optionValues
|
|
533
|
+
return yupSchemas.radioOrSelect(optionValues);
|
|
538
534
|
}
|
|
539
535
|
if (field.format === "date") {
|
|
540
536
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
|
@@ -1635,7 +1631,7 @@ function buildFieldParameters(name, fieldProperties, required = [], config = {},
|
|
|
1635
1631
|
fields = getFieldsFromJSONSchema(
|
|
1636
1632
|
fieldProperties,
|
|
1637
1633
|
{
|
|
1638
|
-
customProperties: get3(config, `customProperties.${name}`, {}),
|
|
1634
|
+
customProperties: get3(config, `customProperties.${name}.customProperties`, {}),
|
|
1639
1635
|
parentID: name
|
|
1640
1636
|
},
|
|
1641
1637
|
logic
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
|
-
Copyright (c)
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.7.
|
|
5
|
-
Generated:
|
|
3
|
+
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.7.7-dev.20240129180839
|
|
5
|
+
Generated: Mon, 29 Jan 2024 18:09:02 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11779,10 +11779,7 @@ var validateMaxDate = (value, minDate) => {
|
|
|
11779
11779
|
};
|
|
11780
11780
|
var yupSchemas = {
|
|
11781
11781
|
text: validateOnlyStrings,
|
|
11782
|
-
radioOrSelect: (options
|
|
11783
|
-
if (isString2) {
|
|
11784
|
-
return StringSchema().nullable();
|
|
11785
|
-
}
|
|
11782
|
+
radioOrSelect: (options) => {
|
|
11786
11783
|
return StringSchema().nullable().transform((value) => {
|
|
11787
11784
|
if (value === "") {
|
|
11788
11785
|
return void 0;
|
|
@@ -11886,9 +11883,8 @@ var getOptions = (field) => {
|
|
|
11886
11883
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
11887
11884
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
11888
11885
|
if (field.options?.length > 0) {
|
|
11889
|
-
const isString2 = field.options?.findIndex((option) => option.type === "string") > -1;
|
|
11890
11886
|
const optionValues = getOptions(field);
|
|
11891
|
-
return yupSchemas.radioOrSelect(optionValues
|
|
11887
|
+
return yupSchemas.radioOrSelect(optionValues);
|
|
11892
11888
|
}
|
|
11893
11889
|
if (field.format === "date") {
|
|
11894
11890
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
|
@@ -12989,7 +12985,7 @@ function buildFieldParameters(name, fieldProperties, required2 = [], config = {}
|
|
|
12989
12985
|
fields = getFieldsFromJSONSchema(
|
|
12990
12986
|
fieldProperties,
|
|
12991
12987
|
{
|
|
12992
|
-
customProperties: (0, import_get4.default)(config, `customProperties.${name}`, {}),
|
|
12988
|
+
customProperties: (0, import_get4.default)(config, `customProperties.${name}.customProperties`, {}),
|
|
12993
12989
|
parentID: name
|
|
12994
12990
|
},
|
|
12995
12991
|
logic
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.7-dev.20240129180839",
|
|
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",
|
|
@@ -357,17 +357,23 @@ describe('createHeadlessForm() - custom validations', () => {
|
|
|
357
357
|
minimum: 24,
|
|
358
358
|
maximum: 28,
|
|
359
359
|
},
|
|
360
|
-
second_gen: {
|
|
361
|
-
|
|
360
|
+
second_gen: {
|
|
361
|
+
customProperties: {
|
|
362
|
+
cub_age: {
|
|
362
363
|
minimum: 18,
|
|
363
|
-
maximum: 21
|
|
364
|
+
maximum: 21
|
|
365
|
+
},
|
|
366
|
+
third_gen: {
|
|
367
|
+
customProperties: {
|
|
368
|
+
grandcub_age: {
|
|
369
|
+
minimum: 10,
|
|
370
|
+
maximum: 15,
|
|
371
|
+
},
|
|
372
|
+
}
|
|
373
|
+
|
|
364
374
|
},
|
|
365
|
-
third_gen: {
|
|
366
|
-
grandcub_age: {
|
|
367
|
-
minimum: 10,
|
|
368
|
-
maximum: 15,
|
|
369
|
-
},
|
|
370
375
|
},
|
|
376
|
+
|
|
371
377
|
},
|
|
372
378
|
},
|
|
373
379
|
},
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
schemaInputTypeRadioOptionsWithDetails,
|
|
16
16
|
schemaInputTypeSelectSoloDeprecated,
|
|
17
17
|
schemaInputTypeSelectSolo,
|
|
18
|
-
schemaInputTypeSelectString,
|
|
19
18
|
schemaInputTypeSelectMultipleDeprecated,
|
|
20
19
|
schemaInputTypeSelectMultiple,
|
|
21
20
|
schemaInputTypeSelectMultipleOptional,
|
|
@@ -432,7 +431,7 @@ describe('createHeadlessForm', () => {
|
|
|
432
431
|
});
|
|
433
432
|
|
|
434
433
|
describe('field support', () => {
|
|
435
|
-
function assertOptionsAllowed({ handleValidation, fieldName, validOptions
|
|
434
|
+
function assertOptionsAllowed({ handleValidation, fieldName, validOptions }) {
|
|
436
435
|
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
437
436
|
|
|
438
437
|
// All allowed options are valid
|
|
@@ -440,34 +439,27 @@ describe('createHeadlessForm', () => {
|
|
|
440
439
|
expect(validateForm({ [fieldName]: value })).toBeUndefined();
|
|
441
440
|
});
|
|
442
441
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
// Given undefined, it says it's a required field.
|
|
450
|
-
expect(validateForm({})).toEqual({
|
|
451
|
-
[fieldName]: 'Required field',
|
|
452
|
-
});
|
|
442
|
+
// Any other arbitrary value is not valid.
|
|
443
|
+
expect(validateForm({ [fieldName]: 'blah-blah' })).toEqual({
|
|
444
|
+
[fieldName]: 'The option "blah-blah" is not valid.',
|
|
445
|
+
});
|
|
453
446
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
});
|
|
447
|
+
// Given undefined, it says it's a required field.
|
|
448
|
+
expect(validateForm({})).toEqual({
|
|
449
|
+
[fieldName]: 'Required field',
|
|
450
|
+
});
|
|
459
451
|
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
452
|
+
// As required field, empty string ("") is also considered empty. @BUG RMT-518
|
|
453
|
+
// Expectation: The error to be "The option '' is not valid."
|
|
454
|
+
expect(validateForm({ [fieldName]: '' })).toEqual({
|
|
455
|
+
[fieldName]: 'Required field',
|
|
456
|
+
});
|
|
466
457
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
458
|
+
// As required field, null is also considered empty @BUG RMT-518
|
|
459
|
+
// Expectation: The error to be "The option null is not valid."
|
|
460
|
+
expect(validateForm({ [fieldName]: null })).toEqual({
|
|
461
|
+
[fieldName]: 'Required field',
|
|
462
|
+
});
|
|
471
463
|
}
|
|
472
464
|
|
|
473
465
|
it('support "text" field type', () => {
|
|
@@ -639,41 +631,6 @@ describe('createHeadlessForm', () => {
|
|
|
639
631
|
});
|
|
640
632
|
});
|
|
641
633
|
|
|
642
|
-
it('supports "select" field type with string option', () => {
|
|
643
|
-
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeSelectString);
|
|
644
|
-
const fieldSelect = fields[0];
|
|
645
|
-
expect(fieldSelect).toMatchObject({
|
|
646
|
-
name: 'browsers',
|
|
647
|
-
label: 'Browsers (solo)',
|
|
648
|
-
description: 'This solo select also includes a disabled option.',
|
|
649
|
-
options: [
|
|
650
|
-
{
|
|
651
|
-
value: 'chr',
|
|
652
|
-
label: 'Chrome',
|
|
653
|
-
},
|
|
654
|
-
{
|
|
655
|
-
value: 'ff',
|
|
656
|
-
label: 'Firefox',
|
|
657
|
-
},
|
|
658
|
-
{
|
|
659
|
-
value: 'ie',
|
|
660
|
-
label: 'Internet Explorer',
|
|
661
|
-
disabled: true,
|
|
662
|
-
},
|
|
663
|
-
{ value: undefined, type: 'string', label: '{Create another}' },
|
|
664
|
-
],
|
|
665
|
-
});
|
|
666
|
-
|
|
667
|
-
expect(fieldSelect).not.toHaveProperty('multiple');
|
|
668
|
-
|
|
669
|
-
assertOptionsAllowed({
|
|
670
|
-
handleValidation,
|
|
671
|
-
fieldName: 'browsers',
|
|
672
|
-
validOptions: ['chr', 'ff', 'ie'],
|
|
673
|
-
isString: true,
|
|
674
|
-
});
|
|
675
|
-
});
|
|
676
|
-
|
|
677
634
|
it('supports "select" field type with multiple options @deprecated', () => {
|
|
678
635
|
const result = createHeadlessForm(schemaInputTypeSelectMultipleDeprecated);
|
|
679
636
|
expect(result).toMatchObject({
|
|
@@ -3720,11 +3677,17 @@ describe('createHeadlessForm', () => {
|
|
|
3720
3677
|
customProperties: {
|
|
3721
3678
|
id_number: { 'data-field': 'field' },
|
|
3722
3679
|
fieldset: {
|
|
3723
|
-
|
|
3680
|
+
customProperties: {
|
|
3681
|
+
id_number: { 'data-fieldset': 'fieldset' },
|
|
3682
|
+
},
|
|
3724
3683
|
},
|
|
3725
3684
|
nestedFieldset: {
|
|
3726
|
-
|
|
3727
|
-
|
|
3685
|
+
customProperties: {
|
|
3686
|
+
innerFieldset: {
|
|
3687
|
+
customProperties: {
|
|
3688
|
+
id_number: { 'data-nested-fieldset': 'nested-fieldset' },
|
|
3689
|
+
},
|
|
3690
|
+
},
|
|
3728
3691
|
},
|
|
3729
3692
|
},
|
|
3730
3693
|
},
|
package/src/tests/helpers.js
CHANGED
|
@@ -238,11 +238,6 @@ export const mockSelectInputSolo = {
|
|
|
238
238
|
},
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
-
export const mockSelectInputSoloCreatable = {
|
|
242
|
-
...mockSelectInputSolo,
|
|
243
|
-
oneOf: [...mockSelectInputSolo.oneOf, { type: 'string', title: '{Create another}' }],
|
|
244
|
-
};
|
|
245
|
-
|
|
246
241
|
export const mockSelectInputMultiple = {
|
|
247
242
|
title: 'Browsers (multiple)',
|
|
248
243
|
description: 'This multi-select also includes a disabled option.',
|
|
@@ -942,10 +937,6 @@ export const schemaInputTypeSelectSolo = JSONSchemaBuilder()
|
|
|
942
937
|
.setRequiredFields(['browsers'])
|
|
943
938
|
.build();
|
|
944
939
|
|
|
945
|
-
export const schemaInputTypeSelectString = JSONSchemaBuilder().addInput({
|
|
946
|
-
browsers: mockSelectInputSoloCreatable,
|
|
947
|
-
});
|
|
948
|
-
|
|
949
940
|
/** @deprecated */
|
|
950
941
|
export const schemaInputTypeSelectMultipleDeprecated = JSONSchemaBuilder()
|
|
951
942
|
.addInput({
|