@remoteoss/json-schema-form 0.5.0-dev.20230719114157 → 0.5.0-dev.20230719145458
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/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/standalone.js +2 -2
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +24 -26
- package/src/tests/helpers.js +13 -18
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.0-dev.
|
|
5
|
-
Generated: Wed, 19 Jul 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230719145458
|
|
5
|
+
Generated: Wed, 19 Jul 2023 14:55:12 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
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.0-dev.
|
|
5
|
-
Generated: Wed, 19 Jul 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230719145458
|
|
5
|
+
Generated: Wed, 19 Jul 2023 14:55:12 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
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.0-dev.
|
|
5
|
-
Generated: Wed, 19 Jul 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.5.0-dev.20230719145458
|
|
5
|
+
Generated: Wed, 19 Jul 2023 14:55:12 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.20230719145458",
|
|
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",
|
|
@@ -1009,30 +1009,30 @@ describe('createHeadlessForm', () => {
|
|
|
1009
1009
|
});
|
|
1010
1010
|
|
|
1011
1011
|
it('support "date" field type', () => {
|
|
1012
|
-
const
|
|
1012
|
+
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeDate);
|
|
1013
1013
|
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
maxDate: '2022-03-01',
|
|
1025
|
-
},
|
|
1026
|
-
],
|
|
1014
|
+
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
1015
|
+
|
|
1016
|
+
expect(fields[0]).toMatchObject({
|
|
1017
|
+
label: 'Birthdate',
|
|
1018
|
+
name: 'birthdate',
|
|
1019
|
+
required: true,
|
|
1020
|
+
schema: expect.any(Object),
|
|
1021
|
+
type: 'date',
|
|
1022
|
+
minDate: '1922-03-01',
|
|
1023
|
+
maxDate: '2022-03-01',
|
|
1027
1024
|
});
|
|
1028
1025
|
|
|
1029
|
-
const fieldValidator = result.fields[0].schema;
|
|
1030
1026
|
const todayDateHint = new Date().toISOString().substring(0, 10);
|
|
1031
|
-
|
|
1032
|
-
expect(
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1027
|
+
|
|
1028
|
+
expect(validateForm({})).toEqual({
|
|
1029
|
+
birthdate: 'Required field',
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
expect(validateForm({ birthdate: '2020-10-10' })).toBeUndefined();
|
|
1033
|
+
expect(validateForm({ birthdate: '2020-13-10' })).toEqual({
|
|
1034
|
+
birthdate: `Must be a valid date in yyyy-mm-dd format. e.g. ${todayDateHint}`,
|
|
1035
|
+
});
|
|
1036
1036
|
});
|
|
1037
1037
|
|
|
1038
1038
|
it('support "date" field type with a minDate', () => {
|
|
@@ -1046,7 +1046,6 @@ describe('createHeadlessForm', () => {
|
|
|
1046
1046
|
required: true,
|
|
1047
1047
|
schema: expect.any(Object),
|
|
1048
1048
|
type: 'date',
|
|
1049
|
-
maxLength: 10,
|
|
1050
1049
|
minDate: '1922-03-01',
|
|
1051
1050
|
maxDate: '2022-03-01',
|
|
1052
1051
|
});
|
|
@@ -1065,9 +1064,9 @@ describe('createHeadlessForm', () => {
|
|
|
1065
1064
|
birthdate: 'The date must be 1922-03-01 or after.',
|
|
1066
1065
|
});
|
|
1067
1066
|
|
|
1068
|
-
expect(validateForm({ birthdate: '1922-03-01' })).
|
|
1067
|
+
expect(validateForm({ birthdate: '1922-03-01' })).toBeUndefined();
|
|
1069
1068
|
|
|
1070
|
-
expect(validateForm({ birthdate: '2021-03-01' })).
|
|
1069
|
+
expect(validateForm({ birthdate: '2021-03-01' })).toBeUndefined();
|
|
1071
1070
|
});
|
|
1072
1071
|
|
|
1073
1072
|
it('support "date" field type with a maxDate', () => {
|
|
@@ -1081,7 +1080,6 @@ describe('createHeadlessForm', () => {
|
|
|
1081
1080
|
required: true,
|
|
1082
1081
|
schema: expect.any(Object),
|
|
1083
1082
|
type: 'date',
|
|
1084
|
-
maxLength: 10,
|
|
1085
1083
|
minDate: '1922-03-01',
|
|
1086
1084
|
maxDate: '2022-03-01',
|
|
1087
1085
|
});
|
|
@@ -1092,8 +1090,8 @@ describe('createHeadlessForm', () => {
|
|
|
1092
1090
|
birthdate: `Must be a valid date in yyyy-mm-dd format. e.g. ${todayDateHint}`,
|
|
1093
1091
|
});
|
|
1094
1092
|
|
|
1095
|
-
expect(validateForm({ birthdate: '2022-02-01' })).
|
|
1096
|
-
expect(validateForm({ birthdate: '2022-03-01' })).
|
|
1093
|
+
expect(validateForm({ birthdate: '2022-02-01' })).toBeUndefined();
|
|
1094
|
+
expect(validateForm({ birthdate: '2022-03-01' })).toBeUndefined();
|
|
1097
1095
|
expect(validateForm({ birthdate: '2022-04-01' })).toEqual({
|
|
1098
1096
|
birthdate: 'The date must be 2022-03-01 or before.',
|
|
1099
1097
|
});
|
package/src/tests/helpers.js
CHANGED
|
@@ -272,18 +272,6 @@ export const mockSelectInputMultipleOptional = {
|
|
|
272
272
|
type: ['array', 'null'],
|
|
273
273
|
};
|
|
274
274
|
|
|
275
|
-
export const mockDateInput = {
|
|
276
|
-
'x-jsf-presentation': {
|
|
277
|
-
inputType: 'date',
|
|
278
|
-
maxDate: '2022-03-01',
|
|
279
|
-
minDate: '1922-03-01',
|
|
280
|
-
},
|
|
281
|
-
title: 'Birthdate',
|
|
282
|
-
type: 'string',
|
|
283
|
-
format: 'date',
|
|
284
|
-
maxLength: 10,
|
|
285
|
-
};
|
|
286
|
-
|
|
287
275
|
export const mockFileInput = {
|
|
288
276
|
description: 'File Input Description',
|
|
289
277
|
'x-jsf-presentation': {
|
|
@@ -998,12 +986,19 @@ export const schemaInputTypeNumberWithPercentage = JSONSchemaBuilder()
|
|
|
998
986
|
.setRequiredFields(['shares'])
|
|
999
987
|
.build();
|
|
1000
988
|
|
|
1001
|
-
export const schemaInputTypeDate =
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
989
|
+
export const schemaInputTypeDate = {
|
|
990
|
+
type: 'object',
|
|
991
|
+
additionalProperties: false,
|
|
992
|
+
properties: {
|
|
993
|
+
birthdate: {
|
|
994
|
+
'x-jsf-presentation': { inputType: 'date', maxDate: '2022-03-01', minDate: '1922-03-01' },
|
|
995
|
+
title: 'Birthdate',
|
|
996
|
+
type: 'string',
|
|
997
|
+
format: 'date',
|
|
998
|
+
},
|
|
999
|
+
},
|
|
1000
|
+
required: ['birthdate'],
|
|
1001
|
+
};
|
|
1007
1002
|
|
|
1008
1003
|
export const schemaInputTypeEmail = JSONSchemaBuilder()
|
|
1009
1004
|
.addInput({
|