@remoteoss/json-schema-form 0.4.4-dev.20230829191632 → 0.4.5-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/CHANGELOG.md +12 -0
- package/dist/index.cjs +12 -3
- package/dist/index.js +12 -3
- package/dist/standalone.js +12 -3
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +25 -0
- package/src/tests/helpers.js +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
#### 0.4.5-beta.0 (2023-08-31)
|
|
2
|
+
|
|
3
|
+
##### Changes
|
|
4
|
+
|
|
5
|
+
* Allow validation of consts to support single values ([#34](https://github.com/remoteoss/json-schema-form/pull/34)) ([bf07870d](https://github.com/remoteoss/json-schema-form/commit/bf07870d407d9b9b078882a078b9e4c7928df868))
|
|
6
|
+
|
|
7
|
+
#### 0.4.4-beta.0 (2023-08-30)
|
|
8
|
+
|
|
9
|
+
##### Chores
|
|
10
|
+
|
|
11
|
+
* **fieldset:** ignore values not matching the field type ([#44](https://github.com/remoteoss/json-schema-form/pull/44)) ([f0af54e5](https://github.com/remoteoss/json-schema-form/commit/f0af54e5d425fb78524ab150bb31629d00369a61))
|
|
12
|
+
|
|
1
13
|
#### 0.4.3-beta.0 (2023-08-09)
|
|
2
14
|
|
|
3
15
|
##### Bug fixes
|
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.4.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.5-beta.0
|
|
5
|
+
Generated: Thu, 31 Aug 2023 07:23:05 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -759,7 +759,16 @@ function getPrefillSubFieldValues(field, defaultValues, parentFieldKeyPath) {
|
|
|
759
759
|
initialValue[field.name] = subFieldValues;
|
|
760
760
|
}
|
|
761
761
|
} else {
|
|
762
|
-
|
|
762
|
+
if (typeof initialValue !== "object") {
|
|
763
|
+
console.warn(
|
|
764
|
+
`Field "${parentFieldKeyPath}"'s value is "${initialValue}", but should be type object.`
|
|
765
|
+
);
|
|
766
|
+
initialValue = getPrefillValues([field], {
|
|
767
|
+
// TODO nested fieldsets are not handled
|
|
768
|
+
});
|
|
769
|
+
} else {
|
|
770
|
+
initialValue = getPrefillValues([field], initialValue);
|
|
771
|
+
}
|
|
763
772
|
}
|
|
764
773
|
return initialValue;
|
|
765
774
|
}
|
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.4.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.5-beta.0
|
|
5
|
+
Generated: Thu, 31 Aug 2023 07:23:05 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -723,7 +723,16 @@ function getPrefillSubFieldValues(field, defaultValues, parentFieldKeyPath) {
|
|
|
723
723
|
initialValue[field.name] = subFieldValues;
|
|
724
724
|
}
|
|
725
725
|
} else {
|
|
726
|
-
|
|
726
|
+
if (typeof initialValue !== "object") {
|
|
727
|
+
console.warn(
|
|
728
|
+
`Field "${parentFieldKeyPath}"'s value is "${initialValue}", but should be type object.`
|
|
729
|
+
);
|
|
730
|
+
initialValue = getPrefillValues([field], {
|
|
731
|
+
// TODO nested fieldsets are not handled
|
|
732
|
+
});
|
|
733
|
+
} else {
|
|
734
|
+
initialValue = getPrefillValues([field], initialValue);
|
|
735
|
+
}
|
|
727
736
|
}
|
|
728
737
|
return initialValue;
|
|
729
738
|
}
|
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.4.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.5-beta.0
|
|
5
|
+
Generated: Thu, 31 Aug 2023 07:23:05 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11699,7 +11699,16 @@ function getPrefillSubFieldValues(field, defaultValues, parentFieldKeyPath) {
|
|
|
11699
11699
|
initialValue[field.name] = subFieldValues;
|
|
11700
11700
|
}
|
|
11701
11701
|
} else {
|
|
11702
|
-
|
|
11702
|
+
if (typeof initialValue !== "object") {
|
|
11703
|
+
console.warn(
|
|
11704
|
+
`Field "${parentFieldKeyPath}"'s value is "${initialValue}", but should be type object.`
|
|
11705
|
+
);
|
|
11706
|
+
initialValue = getPrefillValues([field], {
|
|
11707
|
+
// TODO nested fieldsets are not handled
|
|
11708
|
+
});
|
|
11709
|
+
} else {
|
|
11710
|
+
initialValue = getPrefillValues([field], initialValue);
|
|
11711
|
+
}
|
|
11703
11712
|
}
|
|
11704
11713
|
return initialValue;
|
|
11705
11714
|
}
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
schemaInputTypeSelectMultipleDeprecated,
|
|
19
19
|
schemaInputTypeSelectMultiple,
|
|
20
20
|
schemaInputTypeSelectMultipleOptional,
|
|
21
|
+
schemaInputTypeFieldset,
|
|
21
22
|
schemaInputTypeNumber,
|
|
22
23
|
schemaInputTypeNumberZeroMaximum,
|
|
23
24
|
schemaInputTypeDate,
|
|
@@ -92,12 +93,15 @@ const getField = (fields, name, ...subNames) => {
|
|
|
92
93
|
};
|
|
93
94
|
|
|
94
95
|
beforeEach(() => {
|
|
96
|
+
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
95
97
|
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
96
98
|
});
|
|
97
99
|
|
|
98
100
|
afterEach(() => {
|
|
99
101
|
expect(console.error).not.toHaveBeenCalled();
|
|
100
102
|
console.error.mockRestore();
|
|
103
|
+
expect(console.warn).not.toHaveBeenCalled();
|
|
104
|
+
console.warn.mockRestore();
|
|
101
105
|
});
|
|
102
106
|
|
|
103
107
|
describe('createHeadlessForm', () => {
|
|
@@ -3446,6 +3450,27 @@ describe('createHeadlessForm', () => {
|
|
|
3446
3450
|
],
|
|
3447
3451
|
});
|
|
3448
3452
|
});
|
|
3453
|
+
|
|
3454
|
+
it('should ignore initial values that do not match the field type (eg string vs object)', () => {
|
|
3455
|
+
const result = createHeadlessForm(schemaInputTypeFieldset, {
|
|
3456
|
+
initialValues: {
|
|
3457
|
+
a_fieldset: 'foo', // should be an object instead of string
|
|
3458
|
+
},
|
|
3459
|
+
});
|
|
3460
|
+
|
|
3461
|
+
// It returns fields without errors
|
|
3462
|
+
expect(result.fields).toBeDefined();
|
|
3463
|
+
expect(result.fields[0].fields[0].name).toBe('id_number');
|
|
3464
|
+
expect(result.fields[0].fields[1].name).toBe('tabs');
|
|
3465
|
+
|
|
3466
|
+
// Warn about those missmatched values
|
|
3467
|
+
expect(console.warn).toHaveBeenCalledWith(
|
|
3468
|
+
`Field "a_fieldset"'s value is "foo", but should be type object.`
|
|
3469
|
+
);
|
|
3470
|
+
console.warn.mockClear();
|
|
3471
|
+
|
|
3472
|
+
expect(console.error).not.toHaveBeenCalled();
|
|
3473
|
+
});
|
|
3449
3474
|
});
|
|
3450
3475
|
});
|
|
3451
3476
|
|
package/src/tests/helpers.js
CHANGED
|
@@ -1020,12 +1020,12 @@ export const schemaInputTypeFileWithSkippable = JSONSchemaBuilder()
|
|
|
1020
1020
|
})
|
|
1021
1021
|
.build();
|
|
1022
1022
|
|
|
1023
|
-
export const schemaInputTypeFieldset =
|
|
1024
|
-
|
|
1023
|
+
export const schemaInputTypeFieldset = {
|
|
1024
|
+
properties: {
|
|
1025
1025
|
a_fieldset: mockFieldset,
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1026
|
+
},
|
|
1027
|
+
required: ['a_fieldset'],
|
|
1028
|
+
};
|
|
1029
1029
|
|
|
1030
1030
|
export const schemaInputTypeFocusedFieldset = JSONSchemaBuilder()
|
|
1031
1031
|
.addInput({
|