@remoteoss/json-schema-form 0.9.1-dev.20240320153711 → 0.9.2-dev.20240518112325
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 +6 -0
- package/dist/index.cjs +13 -4
- package/dist/index.js +14 -5
- package/dist/standalone.js +13 -4
- package/package.json +1 -1
- package/src/tests/const.test.js +3 -2
- package/src/tests/createHeadlessForm.test.js +86 -51
- package/src/tests/helpers.js +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
#### 0.9.1-beta.0 (2024-03-26)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **select/radio:** Allow numbers in oneOf ([#49](https://github.com/remoteoss/json-schema-form/pull/49)) ([04c2598a](https://github.com/remoteoss/json-schema-form/commit/04c2598a3f4e31d8a9495e0d69c0427b6b8c9f56))
|
|
6
|
+
|
|
1
7
|
#### 0.9.0-beta.0 (2024-03-11)
|
|
2
8
|
|
|
3
9
|
##### Breaking changes
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.9.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.9.2-dev.20240518112325
|
|
5
|
+
Generated: Sat, 18 May 2024 11:23:50 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -509,12 +509,21 @@ var yupSchemas = {
|
|
|
509
509
|
}
|
|
510
510
|
return dateString;
|
|
511
511
|
},
|
|
512
|
-
radioOrSelectNumber: (options) => (0, import_yup.
|
|
512
|
+
radioOrSelectNumber: (options) => (0, import_yup.mixed)().typeError("The value must be a number").transform((value) => {
|
|
513
|
+
if (options?.some((option) => option.value === null)) {
|
|
514
|
+
return value;
|
|
515
|
+
}
|
|
516
|
+
return value === null ? void 0 : value;
|
|
517
|
+
}).test(
|
|
513
518
|
"matchesOptionOrPattern",
|
|
514
519
|
({ value }) => {
|
|
515
520
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
516
521
|
},
|
|
517
|
-
(value) =>
|
|
522
|
+
(value) => {
|
|
523
|
+
if (value !== void 0 && typeof value !== "number")
|
|
524
|
+
return false;
|
|
525
|
+
return validateRadioOrSelectOptions(value, options);
|
|
526
|
+
}
|
|
518
527
|
).nullable(),
|
|
519
528
|
number: (0, import_yup.number)().typeError("The value must be a number").nullable(),
|
|
520
529
|
file: (0, import_yup.array)().nullable(),
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.9.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.9.2-dev.20240518112325
|
|
5
|
+
Generated: Sat, 18 May 2024 11:23:50 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -386,7 +386,7 @@ import jsonLogic from "json-logic-js";
|
|
|
386
386
|
import flow from "lodash/flow";
|
|
387
387
|
import noop from "lodash/noop";
|
|
388
388
|
import { randexp } from "randexp";
|
|
389
|
-
import { string, number, boolean, object, array } from "yup";
|
|
389
|
+
import { string, number, boolean, object, array, mixed } from "yup";
|
|
390
390
|
var DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
|
|
391
391
|
var baseString = string().trim();
|
|
392
392
|
var todayDateHint = (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
|
|
@@ -473,12 +473,21 @@ var yupSchemas = {
|
|
|
473
473
|
}
|
|
474
474
|
return dateString;
|
|
475
475
|
},
|
|
476
|
-
radioOrSelectNumber: (options) =>
|
|
476
|
+
radioOrSelectNumber: (options) => mixed().typeError("The value must be a number").transform((value) => {
|
|
477
|
+
if (options?.some((option) => option.value === null)) {
|
|
478
|
+
return value;
|
|
479
|
+
}
|
|
480
|
+
return value === null ? void 0 : value;
|
|
481
|
+
}).test(
|
|
477
482
|
"matchesOptionOrPattern",
|
|
478
483
|
({ value }) => {
|
|
479
484
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
480
485
|
},
|
|
481
|
-
(value) =>
|
|
486
|
+
(value) => {
|
|
487
|
+
if (value !== void 0 && typeof value !== "number")
|
|
488
|
+
return false;
|
|
489
|
+
return validateRadioOrSelectOptions(value, options);
|
|
490
|
+
}
|
|
482
491
|
).nullable(),
|
|
483
492
|
number: number().typeError("The value must be a number").nullable(),
|
|
484
493
|
file: array().nullable(),
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.9.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.9.2-dev.20240518112325
|
|
5
|
+
Generated: Sat, 18 May 2024 11:23:50 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11827,12 +11827,21 @@ var yupSchemas = {
|
|
|
11827
11827
|
}
|
|
11828
11828
|
return dateString;
|
|
11829
11829
|
},
|
|
11830
|
-
radioOrSelectNumber: (options) =>
|
|
11830
|
+
radioOrSelectNumber: (options) => SchemaType().typeError("The value must be a number").transform((value) => {
|
|
11831
|
+
if (options?.some((option) => option.value === null)) {
|
|
11832
|
+
return value;
|
|
11833
|
+
}
|
|
11834
|
+
return value === null ? void 0 : value;
|
|
11835
|
+
}).test(
|
|
11831
11836
|
"matchesOptionOrPattern",
|
|
11832
11837
|
({ value }) => {
|
|
11833
11838
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
11834
11839
|
},
|
|
11835
|
-
(value) =>
|
|
11840
|
+
(value) => {
|
|
11841
|
+
if (value !== void 0 && typeof value !== "number")
|
|
11842
|
+
return false;
|
|
11843
|
+
return validateRadioOrSelectOptions(value, options);
|
|
11844
|
+
}
|
|
11836
11845
|
).nullable(),
|
|
11837
11846
|
number: NumberSchema().typeError("The value must be a number").nullable(),
|
|
11838
11847
|
file: array_default().nullable(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2-dev.20240518112325",
|
|
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",
|
package/src/tests/const.test.js
CHANGED
|
@@ -210,7 +210,7 @@ describe('OneOf const', () => {
|
|
|
210
210
|
});
|
|
211
211
|
expect(handleValidation({ number: 2 }).formErrors).toBeUndefined();
|
|
212
212
|
expect(handleValidation({ number: '2' }).formErrors).toEqual({
|
|
213
|
-
number: 'The
|
|
213
|
+
number: 'The option "2" is not valid.',
|
|
214
214
|
});
|
|
215
215
|
});
|
|
216
216
|
|
|
@@ -229,7 +229,8 @@ describe('OneOf const', () => {
|
|
|
229
229
|
});
|
|
230
230
|
expect(handleValidation({ number: 2 }).formErrors).toBeUndefined();
|
|
231
231
|
expect(handleValidation({ number: '2' }).formErrors).toEqual({
|
|
232
|
-
number: 'The
|
|
232
|
+
number: 'The option "2" is not valid.',
|
|
233
233
|
});
|
|
234
|
+
expect(handleValidation({ number: null }).formErrors).toEqual(undefined);
|
|
234
235
|
});
|
|
235
236
|
});
|
|
@@ -467,9 +467,9 @@ describe('createHeadlessForm', () => {
|
|
|
467
467
|
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeText);
|
|
468
468
|
|
|
469
469
|
expect(fields[0]).toMatchObject({
|
|
470
|
-
description: '
|
|
471
|
-
label: '
|
|
472
|
-
name: '
|
|
470
|
+
description: 'Your username (max 10 characters)',
|
|
471
|
+
label: 'Username',
|
|
472
|
+
name: 'username',
|
|
473
473
|
required: true,
|
|
474
474
|
schema: expect.any(Object),
|
|
475
475
|
inputType: 'text',
|
|
@@ -485,8 +485,8 @@ describe('createHeadlessForm', () => {
|
|
|
485
485
|
expect(fieldValidator.isValidSync(1)).toBe(false);
|
|
486
486
|
expect(fieldValidator.isValidSync(0)).toBe(false);
|
|
487
487
|
|
|
488
|
-
expect(handleValidation({
|
|
489
|
-
|
|
488
|
+
expect(handleValidation({ username: 1 }).formErrors).toEqual({
|
|
489
|
+
username: 'username must be a `string` type, but the final value was: `1`.',
|
|
490
490
|
});
|
|
491
491
|
|
|
492
492
|
expect(() => fieldValidator.validateSync('')).toThrowError('Required field');
|
|
@@ -496,20 +496,18 @@ describe('createHeadlessForm', () => {
|
|
|
496
496
|
const resultsWithRootDescription = createHeadlessForm(
|
|
497
497
|
JSONSchemaBuilder()
|
|
498
498
|
.addInput({
|
|
499
|
-
|
|
499
|
+
username: mockTextInput,
|
|
500
500
|
})
|
|
501
|
-
.setRequiredFields(['
|
|
501
|
+
.setRequiredFields(['username'])
|
|
502
502
|
.build()
|
|
503
503
|
);
|
|
504
504
|
|
|
505
|
-
expect(resultsWithRootDescription.fields[0].description).toMatch(
|
|
506
|
-
/the number of your national/i
|
|
507
|
-
);
|
|
505
|
+
expect(resultsWithRootDescription.fields[0].description).toMatch(/your username/i);
|
|
508
506
|
|
|
509
507
|
const resultsWithPresentationDescription = createHeadlessForm(
|
|
510
508
|
JSONSchemaBuilder()
|
|
511
509
|
.addInput({
|
|
512
|
-
|
|
510
|
+
username: {
|
|
513
511
|
...mockTextInput,
|
|
514
512
|
'x-jsf-presentation': {
|
|
515
513
|
inputType: 'text',
|
|
@@ -519,7 +517,7 @@ describe('createHeadlessForm', () => {
|
|
|
519
517
|
},
|
|
520
518
|
},
|
|
521
519
|
})
|
|
522
|
-
.setRequiredFields(['
|
|
520
|
+
.setRequiredFields(['username'])
|
|
523
521
|
.build()
|
|
524
522
|
);
|
|
525
523
|
|
|
@@ -532,20 +530,18 @@ describe('createHeadlessForm', () => {
|
|
|
532
530
|
const resultsWithRootDescription = createHeadlessForm(
|
|
533
531
|
JSONSchemaBuilder()
|
|
534
532
|
.addInput({
|
|
535
|
-
|
|
533
|
+
username: mockTextInputDeprecated,
|
|
536
534
|
})
|
|
537
|
-
.setRequiredFields(['
|
|
535
|
+
.setRequiredFields(['username'])
|
|
538
536
|
.build()
|
|
539
537
|
);
|
|
540
538
|
|
|
541
|
-
expect(resultsWithRootDescription.fields[0].description).toMatch(
|
|
542
|
-
/the number of your national/i
|
|
543
|
-
);
|
|
539
|
+
expect(resultsWithRootDescription.fields[0].description).toMatch(/your username/i);
|
|
544
540
|
|
|
545
541
|
const resultsWithPresentationDescription = createHeadlessForm(
|
|
546
542
|
JSONSchemaBuilder()
|
|
547
543
|
.addInput({
|
|
548
|
-
|
|
544
|
+
username: {
|
|
549
545
|
...mockTextInputDeprecated,
|
|
550
546
|
presentation: {
|
|
551
547
|
inputType: 'text',
|
|
@@ -555,7 +551,7 @@ describe('createHeadlessForm', () => {
|
|
|
555
551
|
},
|
|
556
552
|
},
|
|
557
553
|
})
|
|
558
|
-
.setRequiredFields(['
|
|
554
|
+
.setRequiredFields(['username'])
|
|
559
555
|
.build()
|
|
560
556
|
);
|
|
561
557
|
|
|
@@ -1561,9 +1557,9 @@ describe('createHeadlessForm', () => {
|
|
|
1561
1557
|
required: false,
|
|
1562
1558
|
fields: [
|
|
1563
1559
|
{
|
|
1564
|
-
description: '
|
|
1565
|
-
label: '
|
|
1566
|
-
name: '
|
|
1560
|
+
description: 'Your username (max 10 characters)',
|
|
1561
|
+
label: 'Username',
|
|
1562
|
+
name: 'username',
|
|
1567
1563
|
type: 'text',
|
|
1568
1564
|
required: true,
|
|
1569
1565
|
},
|
|
@@ -1608,9 +1604,9 @@ describe('createHeadlessForm', () => {
|
|
|
1608
1604
|
required: false,
|
|
1609
1605
|
fields: [
|
|
1610
1606
|
{
|
|
1611
|
-
description: '
|
|
1612
|
-
label: '
|
|
1613
|
-
name: '
|
|
1607
|
+
description: 'Your username (max 10 characters)',
|
|
1608
|
+
label: 'Username',
|
|
1609
|
+
name: 'username',
|
|
1614
1610
|
type: 'text',
|
|
1615
1611
|
required: true,
|
|
1616
1612
|
},
|
|
@@ -2018,16 +2014,55 @@ describe('createHeadlessForm', () => {
|
|
|
2018
2014
|
|
|
2019
2015
|
// Assert the yupError shape is really a YupError
|
|
2020
2016
|
expect(yupError).toEqual(expect.any(Error));
|
|
2021
|
-
expect(yupError.inner[0].path).toBe('
|
|
2017
|
+
expect(yupError.inner[0].path).toBe('username');
|
|
2022
2018
|
expect(yupError.inner[0].message).toBe('Required field');
|
|
2023
2019
|
|
|
2024
2020
|
// Assert the converted YupError to formErrors
|
|
2025
2021
|
expect(formErrors).toEqual({
|
|
2026
|
-
|
|
2022
|
+
username: 'Required field',
|
|
2027
2023
|
});
|
|
2028
2024
|
});
|
|
2029
2025
|
});
|
|
2030
2026
|
|
|
2027
|
+
it('supports oneOf number const', () => {
|
|
2028
|
+
const result = createHeadlessForm({
|
|
2029
|
+
type: 'object',
|
|
2030
|
+
additionalProperties: false,
|
|
2031
|
+
properties: {
|
|
2032
|
+
pets: {
|
|
2033
|
+
title: 'How many pets?',
|
|
2034
|
+
oneOf: [
|
|
2035
|
+
{
|
|
2036
|
+
title: 'One',
|
|
2037
|
+
const: 0,
|
|
2038
|
+
},
|
|
2039
|
+
{
|
|
2040
|
+
title: 'Two',
|
|
2041
|
+
const: 2,
|
|
2042
|
+
},
|
|
2043
|
+
{
|
|
2044
|
+
title: 'null',
|
|
2045
|
+
const: 1,
|
|
2046
|
+
},
|
|
2047
|
+
],
|
|
2048
|
+
'x-jsf-presentation': {
|
|
2049
|
+
inputType: 'select',
|
|
2050
|
+
},
|
|
2051
|
+
type: ['number', 'null'],
|
|
2052
|
+
},
|
|
2053
|
+
},
|
|
2054
|
+
required: [],
|
|
2055
|
+
'x-jsf-order': ['pets'],
|
|
2056
|
+
});
|
|
2057
|
+
|
|
2058
|
+
const fieldValidator = result.fields[0].schema;
|
|
2059
|
+
|
|
2060
|
+
expect(fieldValidator.isValidSync(0)).toBe(true);
|
|
2061
|
+
expect(fieldValidator.isValidSync(1)).toBe(true);
|
|
2062
|
+
expect(() => fieldValidator.validateSync('2')).toThrowError('The option "2" is not valid.');
|
|
2063
|
+
expect(fieldValidator.isValidSync(null)).toBe(true);
|
|
2064
|
+
});
|
|
2065
|
+
|
|
2031
2066
|
describe('x-jsf-presentation attribute', () => {
|
|
2032
2067
|
it('support field with "x-jsf-presentation.statement"', () => {
|
|
2033
2068
|
const result = createHeadlessForm(schemaInputWithStatement);
|
|
@@ -2773,7 +2808,7 @@ describe('createHeadlessForm', () => {
|
|
|
2773
2808
|
validateForm({
|
|
2774
2809
|
validate_tabs: 'no',
|
|
2775
2810
|
a_fieldset: {
|
|
2776
|
-
|
|
2811
|
+
username: 'abc',
|
|
2777
2812
|
},
|
|
2778
2813
|
mandatory_group_array: 'no',
|
|
2779
2814
|
})
|
|
@@ -2788,7 +2823,7 @@ describe('createHeadlessForm', () => {
|
|
|
2788
2823
|
validateForm({
|
|
2789
2824
|
validate_tabs: 'yes',
|
|
2790
2825
|
a_fieldset: {
|
|
2791
|
-
|
|
2826
|
+
username: 'abc',
|
|
2792
2827
|
},
|
|
2793
2828
|
mandatory_group_array: 'no',
|
|
2794
2829
|
})
|
|
@@ -2804,7 +2839,7 @@ describe('createHeadlessForm', () => {
|
|
|
2804
2839
|
validateForm({
|
|
2805
2840
|
validate_tabs: 'yes',
|
|
2806
2841
|
a_fieldset: {
|
|
2807
|
-
|
|
2842
|
+
username: 'abc',
|
|
2808
2843
|
},
|
|
2809
2844
|
mandatory_group_array: 'yes',
|
|
2810
2845
|
a_group_array: [{ full_name: 'adfs' }],
|
|
@@ -2815,7 +2850,7 @@ describe('createHeadlessForm', () => {
|
|
|
2815
2850
|
validateForm({
|
|
2816
2851
|
validate_tabs: 'yes',
|
|
2817
2852
|
a_fieldset: {
|
|
2818
|
-
|
|
2853
|
+
username: 'abc',
|
|
2819
2854
|
tabs: 2,
|
|
2820
2855
|
},
|
|
2821
2856
|
mandatory_group_array: 'no',
|
|
@@ -2904,18 +2939,18 @@ describe('createHeadlessForm', () => {
|
|
|
2904
2939
|
|
|
2905
2940
|
expect(
|
|
2906
2941
|
validateForm({
|
|
2907
|
-
validate_fieldset: ['
|
|
2942
|
+
validate_fieldset: ['username'],
|
|
2908
2943
|
a_fieldset: {
|
|
2909
|
-
|
|
2944
|
+
username: 'abc',
|
|
2910
2945
|
},
|
|
2911
2946
|
})
|
|
2912
2947
|
).toBeUndefined();
|
|
2913
2948
|
|
|
2914
2949
|
expect(
|
|
2915
2950
|
validateForm({
|
|
2916
|
-
validate_fieldset: ['
|
|
2951
|
+
validate_fieldset: ['username', 'all'],
|
|
2917
2952
|
a_fieldset: {
|
|
2918
|
-
|
|
2953
|
+
username: 'abc',
|
|
2919
2954
|
},
|
|
2920
2955
|
})
|
|
2921
2956
|
).toEqual({
|
|
@@ -2926,9 +2961,9 @@ describe('createHeadlessForm', () => {
|
|
|
2926
2961
|
|
|
2927
2962
|
expect(
|
|
2928
2963
|
validateForm({
|
|
2929
|
-
validate_fieldset: ['
|
|
2964
|
+
validate_fieldset: ['username', 'all'],
|
|
2930
2965
|
a_fieldset: {
|
|
2931
|
-
|
|
2966
|
+
username: 'abc',
|
|
2932
2967
|
tabs: 2,
|
|
2933
2968
|
},
|
|
2934
2969
|
})
|
|
@@ -2941,18 +2976,18 @@ describe('createHeadlessForm', () => {
|
|
|
2941
2976
|
|
|
2942
2977
|
expect(
|
|
2943
2978
|
validateForm({
|
|
2944
|
-
validate_fieldset: ['
|
|
2979
|
+
validate_fieldset: ['username'],
|
|
2945
2980
|
a_fieldset: {
|
|
2946
|
-
|
|
2981
|
+
username: 'abc',
|
|
2947
2982
|
},
|
|
2948
2983
|
})
|
|
2949
2984
|
).toBeUndefined();
|
|
2950
2985
|
|
|
2951
2986
|
expect(
|
|
2952
2987
|
validateForm({
|
|
2953
|
-
validate_fieldset: ['
|
|
2988
|
+
validate_fieldset: ['username', 'all'],
|
|
2954
2989
|
a_fieldset: {
|
|
2955
|
-
|
|
2990
|
+
username: 'abc',
|
|
2956
2991
|
},
|
|
2957
2992
|
})
|
|
2958
2993
|
).toEqual({
|
|
@@ -2963,9 +2998,9 @@ describe('createHeadlessForm', () => {
|
|
|
2963
2998
|
|
|
2964
2999
|
expect(
|
|
2965
3000
|
validateForm({
|
|
2966
|
-
validate_fieldset: ['
|
|
3001
|
+
validate_fieldset: ['username', 'all'],
|
|
2967
3002
|
a_fieldset: {
|
|
2968
|
-
|
|
3003
|
+
username: 'abc',
|
|
2969
3004
|
tabs: 2,
|
|
2970
3005
|
},
|
|
2971
3006
|
})
|
|
@@ -3545,7 +3580,7 @@ describe('createHeadlessForm', () => {
|
|
|
3545
3580
|
|
|
3546
3581
|
// It returns fields without errors
|
|
3547
3582
|
expect(result.fields).toBeDefined();
|
|
3548
|
-
expect(result.fields[0].fields[0].name).toBe('
|
|
3583
|
+
expect(result.fields[0].fields[0].name).toBe('username');
|
|
3549
3584
|
expect(result.fields[0].fields[1].name).toBe('tabs');
|
|
3550
3585
|
|
|
3551
3586
|
// Warn about those missmatched values
|
|
@@ -3688,14 +3723,14 @@ describe('createHeadlessForm', () => {
|
|
|
3688
3723
|
id_number: { 'data-field': 'field' },
|
|
3689
3724
|
fieldset: {
|
|
3690
3725
|
customProperties: {
|
|
3691
|
-
|
|
3726
|
+
username: { 'data-fieldset': 'fieldset' },
|
|
3692
3727
|
},
|
|
3693
3728
|
},
|
|
3694
3729
|
nestedFieldset: {
|
|
3695
3730
|
customProperties: {
|
|
3696
3731
|
innerFieldset: {
|
|
3697
3732
|
customProperties: {
|
|
3698
|
-
|
|
3733
|
+
username: { 'data-nested-fieldset': 'nested-fieldset' },
|
|
3699
3734
|
},
|
|
3700
3735
|
},
|
|
3701
3736
|
},
|
|
@@ -3714,7 +3749,7 @@ describe('createHeadlessForm', () => {
|
|
|
3714
3749
|
name: 'fieldset',
|
|
3715
3750
|
fields: [
|
|
3716
3751
|
{
|
|
3717
|
-
name: '
|
|
3752
|
+
name: 'username',
|
|
3718
3753
|
'data-fieldset': 'fieldset',
|
|
3719
3754
|
},
|
|
3720
3755
|
{
|
|
@@ -3729,7 +3764,7 @@ describe('createHeadlessForm', () => {
|
|
|
3729
3764
|
name: 'innerFieldset',
|
|
3730
3765
|
fields: [
|
|
3731
3766
|
{
|
|
3732
|
-
name: '
|
|
3767
|
+
name: 'username',
|
|
3733
3768
|
'data-nested-fieldset': 'nested-fieldset',
|
|
3734
3769
|
},
|
|
3735
3770
|
{
|
|
@@ -3751,8 +3786,8 @@ describe('createHeadlessForm', () => {
|
|
|
3751
3786
|
expect(fieldResult).not.toHaveProperty('data-fieldset');
|
|
3752
3787
|
expect(fieldResult).not.toHaveProperty('data-nested-fieldset');
|
|
3753
3788
|
|
|
3754
|
-
// $.fieldset.
|
|
3755
|
-
expect(fildsetResult.fields[0]).toHaveProperty('name', '
|
|
3789
|
+
// $.fieldset.username
|
|
3790
|
+
expect(fildsetResult.fields[0]).toHaveProperty('name', 'username');
|
|
3756
3791
|
expect(fildsetResult.fields[0]).toHaveProperty('data-fieldset', 'fieldset');
|
|
3757
3792
|
expect(fildsetResult.fields[0]).not.toHaveProperty('data-field');
|
|
3758
3793
|
expect(fildsetResult.fields[0]).not.toHaveProperty('data-nested-fieldset');
|
|
@@ -3760,7 +3795,7 @@ describe('createHeadlessForm', () => {
|
|
|
3760
3795
|
expect(fildsetResult.fields[1]).not.toHaveProperty('data-nested-fieldset');
|
|
3761
3796
|
|
|
3762
3797
|
// $.nestedFieldset.innerFieldset.id_number
|
|
3763
|
-
expect(nestedFieldsetResult.fields[0].fields[0]).toHaveProperty('name', '
|
|
3798
|
+
expect(nestedFieldsetResult.fields[0].fields[0]).toHaveProperty('name', 'username');
|
|
3764
3799
|
expect(nestedFieldsetResult.fields[0].fields[0]).toHaveProperty(
|
|
3765
3800
|
'data-nested-fieldset',
|
|
3766
3801
|
'nested-fieldset'
|
package/src/tests/helpers.js
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// -------------------------------------
|
|
4
4
|
|
|
5
5
|
export const mockTextInput = {
|
|
6
|
-
title: '
|
|
7
|
-
description: '
|
|
6
|
+
title: 'Username',
|
|
7
|
+
description: 'Your username (max 10 characters)',
|
|
8
8
|
maxLength: 10,
|
|
9
9
|
'x-jsf-presentation': {
|
|
10
10
|
inputType: 'text',
|
|
@@ -14,8 +14,8 @@ export const mockTextInput = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export const mockTextInputDeprecated = {
|
|
17
|
-
title: '
|
|
18
|
-
description: '
|
|
17
|
+
title: 'Username',
|
|
18
|
+
description: 'Your username (max 10 characters)',
|
|
19
19
|
maxLength: 10,
|
|
20
20
|
presentation: {
|
|
21
21
|
inputType: 'text',
|
|
@@ -313,10 +313,10 @@ export const mockFieldset = {
|
|
|
313
313
|
inputType: 'fieldset',
|
|
314
314
|
},
|
|
315
315
|
properties: {
|
|
316
|
-
|
|
316
|
+
username: mockTextInput,
|
|
317
317
|
tabs: mockNumberInput,
|
|
318
318
|
},
|
|
319
|
-
required: ['
|
|
319
|
+
required: ['username'],
|
|
320
320
|
type: 'object',
|
|
321
321
|
};
|
|
322
322
|
|
|
@@ -328,10 +328,10 @@ export const mockFocusedFieldset = {
|
|
|
328
328
|
variant: 'focused',
|
|
329
329
|
},
|
|
330
330
|
properties: {
|
|
331
|
-
|
|
331
|
+
username: mockTextInput,
|
|
332
332
|
tabs: mockNumberInput,
|
|
333
333
|
},
|
|
334
|
-
required: ['
|
|
334
|
+
required: ['username'],
|
|
335
335
|
type: 'object',
|
|
336
336
|
};
|
|
337
337
|
|
|
@@ -501,7 +501,7 @@ export const mockTelWithPattern = {
|
|
|
501
501
|
* @returns {Object} A JSON schema
|
|
502
502
|
* @example
|
|
503
503
|
* JSONSchemaBuilder().addInput({
|
|
504
|
-
|
|
504
|
+
username: mockTextInput,
|
|
505
505
|
})
|
|
506
506
|
.build();
|
|
507
507
|
*/
|
|
@@ -708,9 +708,9 @@ export const schemaWithoutTypes = {
|
|
|
708
708
|
|
|
709
709
|
export const schemaInputTypeText = {
|
|
710
710
|
properties: {
|
|
711
|
-
|
|
711
|
+
username: mockTextInput,
|
|
712
712
|
},
|
|
713
|
-
required: ['
|
|
713
|
+
required: ['username'],
|
|
714
714
|
};
|
|
715
715
|
|
|
716
716
|
export const schemaInputWithStatement = {
|
|
@@ -1292,7 +1292,7 @@ export const schemaDynamicValidationConst = {
|
|
|
1292
1292
|
then: {
|
|
1293
1293
|
properties: {
|
|
1294
1294
|
a_fieldset: {
|
|
1295
|
-
required: ['
|
|
1295
|
+
required: ['username', 'tabs'],
|
|
1296
1296
|
},
|
|
1297
1297
|
},
|
|
1298
1298
|
},
|
|
@@ -1369,7 +1369,7 @@ export const schemaDynamicValidationContains = JSONSchemaBuilder()
|
|
|
1369
1369
|
type: 'array',
|
|
1370
1370
|
description: 'Select what fieldset fields are required',
|
|
1371
1371
|
items: {
|
|
1372
|
-
enum: ['all', '
|
|
1372
|
+
enum: ['all', 'username'],
|
|
1373
1373
|
},
|
|
1374
1374
|
'x-jsf-presentation': {
|
|
1375
1375
|
inputType: 'select',
|
|
@@ -1379,8 +1379,8 @@ export const schemaDynamicValidationContains = JSONSchemaBuilder()
|
|
|
1379
1379
|
value: 'all',
|
|
1380
1380
|
},
|
|
1381
1381
|
{
|
|
1382
|
-
label: '
|
|
1383
|
-
value: '
|
|
1382
|
+
label: 'Username',
|
|
1383
|
+
value: 'username',
|
|
1384
1384
|
},
|
|
1385
1385
|
],
|
|
1386
1386
|
placeholder: 'Select...',
|
|
@@ -1401,7 +1401,7 @@ export const schemaDynamicValidationContains = JSONSchemaBuilder()
|
|
|
1401
1401
|
{
|
|
1402
1402
|
properties: {
|
|
1403
1403
|
a_fieldset: {
|
|
1404
|
-
required: ['
|
|
1404
|
+
required: ['username', 'tabs'],
|
|
1405
1405
|
},
|
|
1406
1406
|
},
|
|
1407
1407
|
}
|