@remoteoss/json-schema-form 0.7.0-beta.0 → 0.7.1-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 +14 -22
- package/dist/index.cjs +19 -13
- package/dist/index.js +19 -13
- package/dist/standalone.js +26 -20
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +65 -22
- package/src/tests/helpers.js +34 -80
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
#### 0.7.1-beta.0 (2023-10-31)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **select:** support string type ([#54](https://github.com/remoteoss/json-schema-form/pull/54)) ([b00f8776](https://github.com/remoteoss/json-schema-form/commit/b00f8776aa244803375ba64fbdd52c8fff9b9bd8))
|
|
6
|
+
|
|
1
7
|
#### 0.7.0-beta.0 (2023-10-23)
|
|
2
8
|
|
|
3
9
|
##### Chores
|
|
@@ -27,10 +33,8 @@ BREAKING CHANGES:
|
|
|
27
33
|
|
|
28
34
|
- json-logic: Add conditional logic checking. ([#41](https://github.com/remoteoss/json-schema-form/pull/41)) ([6292b01e](https://github.com/remoteoss/json-schema-form/commit/6292b01e3f77a9038328d7375080ffc4cb30dbc8))
|
|
29
35
|
|
|
30
|
-
|
|
31
36
|
###### Full API additions now supported from 0.6.5 onwards.
|
|
32
37
|
|
|
33
|
-
|
|
34
38
|
- New custom JSON Schema keyword `x-jsf-logic` added to support cross-field validations. Built on top of [JsonLogic](https://jsonlogic.com/).
|
|
35
39
|
|
|
36
40
|
- `x-jsf-logic` can contain:
|
|
@@ -49,16 +53,11 @@ While docs are underway, you can read examples from all the [tests](https://gith
|
|
|
49
53
|
|
|
50
54
|
In short: `x-jsf-logic` is added to support complex conditional cross-field validations. Properties like `x-jsf-logic-validations` allow hooking those up to individual fields.
|
|
51
55
|
|
|
52
|
-
|
|
53
56
|
#### 0.6.4-beta.0 (2023-09-15)
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
58
|
##### Changes
|
|
58
|
-
- json-logic: computedAttrs - handle inline rules ([#40](https://github.com/remoteoss/json-schema-form/pull/40)) ([860ad91b](https://github.com/remoteoss/json-schema-form/commit/860ad91b034ab35d4d4bc51c0c04675f102bf278))
|
|
59
|
-
|
|
60
|
-
|
|
61
59
|
|
|
60
|
+
- json-logic: computedAttrs - handle inline rules ([#40](https://github.com/remoteoss/json-schema-form/pull/40)) ([860ad91b](https://github.com/remoteoss/json-schema-form/commit/860ad91b034ab35d4d4bc51c0c04675f102bf278))
|
|
62
61
|
|
|
63
62
|
#### 0.6.1-beta.0 (2023-09-13)
|
|
64
63
|
|
|
@@ -66,50 +65,43 @@ In short: `x-jsf-logic` is added to support complex conditional cross-field vali
|
|
|
66
65
|
|
|
67
66
|
- json-logic: Computed string based values ([#37](https://github.com/remoteoss/json-schema-form/pull/37)) ([6e042ea5](https://github.com/remoteoss/json-schema-form/commit/6e042ea579497ea573710c307a6ff7ee2f19b931))
|
|
68
67
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
68
|
#### 0.5.0-beta.0 (2023-09-12)
|
|
73
69
|
|
|
74
70
|
##### Changes
|
|
71
|
+
|
|
75
72
|
- json-logic: Computed Attributes ([#36](https://github.com/remoteoss/json-schema-form/pull/36)) ([80c29589](https://github.com/remoteoss/json-schema-form/commit/80c29589ac0972e0f33add70a59df15a46db1b43))
|
|
76
73
|
- json-logic: Initial skeleton implementation ([#35](https://github.com/remoteoss/json-schema-form/pull/35)) ([63149ae8](https://github.com/remoteoss/json-schema-form/commit/63149ae863cf1b5ad76a3b2a49c7f343e55ce07b))
|
|
77
74
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
75
|
#### 0.4.5-beta.0 (2023-08-31)
|
|
76
|
+
|
|
82
77
|
##### Bug fixes
|
|
83
78
|
|
|
84
79
|
- Validate values based on `const` key ([#34](https://github.com/remoteoss/json-schema-form/pull/34)) ([bf07870d](https://github.com/remoteoss/json-schema-form/commit/bf07870d407d9b9b078882a078b9e4c7928df868))
|
|
85
80
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
81
|
#### 0.4.4-beta.0 (2023-08-30)
|
|
90
82
|
|
|
91
83
|
##### Chores
|
|
92
84
|
|
|
93
|
-
|
|
85
|
+
- **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))
|
|
94
86
|
|
|
95
87
|
#### 0.4.3-beta.0 (2023-08-09)
|
|
96
88
|
|
|
97
89
|
##### Bug fixes
|
|
98
90
|
|
|
99
|
-
|
|
91
|
+
- **conditions:** Validate a deeply nested if (e.g. checking an object with a number property) in an if property now doesn't break the form. ([#33](https://github.com/remoteoss/json-schema-form/pull/33)) ([e34cfcc](https://github.com/remoteoss/json-schema-form/commit/e34cfccaf45f1460b346f3cff0c797b3d11259e3))
|
|
100
92
|
|
|
101
93
|
#### 0.4.2-beta.0 (2023-07-20)
|
|
102
94
|
|
|
103
95
|
##### Bug Fixes
|
|
104
96
|
|
|
105
|
-
|
|
97
|
+
- **date:** Validate based on minDate and maxDate ([#30](https://github.com/remoteoss/json-schema-form/pull/30)) ([01c0143e](https://github.com/remoteoss/json-schema-form/commit/01c0143ea4a3775f9489ae6cb8fd99a90b3f1394))
|
|
106
98
|
|
|
107
99
|
#### 0.4.1-beta.0 (2023-07-03)
|
|
108
100
|
|
|
109
101
|
##### Bug Fixes
|
|
110
102
|
|
|
111
|
-
|
|
112
|
-
|
|
103
|
+
- **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))
|
|
104
|
+
- **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))
|
|
113
105
|
|
|
114
106
|
#### 0.4.0-beta.0 (2023-06-22)
|
|
115
107
|
|
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.7.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.7.1-beta.0
|
|
5
|
+
Generated: Tue, 31 Oct 2023 14:25:25 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -461,17 +461,22 @@ var validateMaxDate = (value, minDate) => {
|
|
|
461
461
|
};
|
|
462
462
|
var yupSchemas = {
|
|
463
463
|
text: validateOnlyStrings,
|
|
464
|
-
radioOrSelect: (options
|
|
465
|
-
if (
|
|
466
|
-
return
|
|
464
|
+
radioOrSelect: (options, isString) => {
|
|
465
|
+
if (isString) {
|
|
466
|
+
return (0, import_yup.string)().nullable();
|
|
467
467
|
}
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
468
|
+
return (0, import_yup.string)().nullable().transform((value) => {
|
|
469
|
+
if (value === "") {
|
|
470
|
+
return void 0;
|
|
471
|
+
}
|
|
472
|
+
if (options?.includes(null)) {
|
|
473
|
+
return value;
|
|
474
|
+
}
|
|
475
|
+
return value === null ? void 0 : value;
|
|
476
|
+
}).oneOf(options, ({ value }) => {
|
|
477
|
+
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
478
|
+
});
|
|
479
|
+
},
|
|
475
480
|
date: ({ minDate, maxDate }) => {
|
|
476
481
|
let dateString = (0, import_yup.string)().nullable().transform((value) => {
|
|
477
482
|
if (value === "") {
|
|
@@ -539,8 +544,9 @@ var getOptions = (field) => {
|
|
|
539
544
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
540
545
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
541
546
|
if (field.options?.length > 0) {
|
|
547
|
+
const isString = field.options?.findIndex((option) => option.type === "string") > -1;
|
|
542
548
|
const optionValues = getOptions(field);
|
|
543
|
-
return yupSchemas.radioOrSelect(optionValues);
|
|
549
|
+
return yupSchemas.radioOrSelect(optionValues, isString);
|
|
544
550
|
}
|
|
545
551
|
if (field.format === "date") {
|
|
546
552
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
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.7.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.7.1-beta.0
|
|
5
|
+
Generated: Tue, 31 Oct 2023 14:25:25 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -425,17 +425,22 @@ var validateMaxDate = (value, minDate) => {
|
|
|
425
425
|
};
|
|
426
426
|
var yupSchemas = {
|
|
427
427
|
text: validateOnlyStrings,
|
|
428
|
-
radioOrSelect: (options
|
|
429
|
-
if (
|
|
430
|
-
return
|
|
428
|
+
radioOrSelect: (options, isString) => {
|
|
429
|
+
if (isString) {
|
|
430
|
+
return string().nullable();
|
|
431
431
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
432
|
+
return string().nullable().transform((value) => {
|
|
433
|
+
if (value === "") {
|
|
434
|
+
return void 0;
|
|
435
|
+
}
|
|
436
|
+
if (options?.includes(null)) {
|
|
437
|
+
return value;
|
|
438
|
+
}
|
|
439
|
+
return value === null ? void 0 : value;
|
|
440
|
+
}).oneOf(options, ({ value }) => {
|
|
441
|
+
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
442
|
+
});
|
|
443
|
+
},
|
|
439
444
|
date: ({ minDate, maxDate }) => {
|
|
440
445
|
let dateString = string().nullable().transform((value) => {
|
|
441
446
|
if (value === "") {
|
|
@@ -503,8 +508,9 @@ var getOptions = (field) => {
|
|
|
503
508
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
504
509
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
505
510
|
if (field.options?.length > 0) {
|
|
511
|
+
const isString = field.options?.findIndex((option) => option.type === "string") > -1;
|
|
506
512
|
const optionValues = getOptions(field);
|
|
507
|
-
return yupSchemas.radioOrSelect(optionValues);
|
|
513
|
+
return yupSchemas.radioOrSelect(optionValues, isString);
|
|
508
514
|
}
|
|
509
515
|
if (field.format === "date") {
|
|
510
516
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
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.7.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.7.1-beta.0
|
|
5
|
+
Generated: Tue, 31 Oct 2023 14:25:25 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -3577,7 +3577,7 @@ var require_property_expr = __commonJS({
|
|
|
3577
3577
|
);
|
|
3578
3578
|
}
|
|
3579
3579
|
function split2(path) {
|
|
3580
|
-
return path.match(SPLIT_REGEX)
|
|
3580
|
+
return path.match(SPLIT_REGEX);
|
|
3581
3581
|
}
|
|
3582
3582
|
function forEach2(parts, iter, thisArg) {
|
|
3583
3583
|
var len = parts.length, part, idx, isArray2, isBracket;
|
|
@@ -6898,13 +6898,13 @@ function _extends() {
|
|
|
6898
6898
|
}
|
|
6899
6899
|
|
|
6900
6900
|
// node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
6901
|
-
function _typeof(
|
|
6901
|
+
function _typeof(obj) {
|
|
6902
6902
|
"@babel/helpers - typeof";
|
|
6903
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(
|
|
6904
|
-
return typeof
|
|
6905
|
-
} : function(
|
|
6906
|
-
return
|
|
6907
|
-
}, _typeof(
|
|
6903
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
|
|
6904
|
+
return typeof obj2;
|
|
6905
|
+
} : function(obj2) {
|
|
6906
|
+
return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
|
|
6907
|
+
}, _typeof(obj);
|
|
6908
6908
|
}
|
|
6909
6909
|
|
|
6910
6910
|
// node_modules/@babel/runtime/helpers/esm/toPrimitive.js
|
|
@@ -11779,17 +11779,22 @@ var validateMaxDate = (value, minDate) => {
|
|
|
11779
11779
|
};
|
|
11780
11780
|
var yupSchemas = {
|
|
11781
11781
|
text: validateOnlyStrings,
|
|
11782
|
-
radioOrSelect: (options
|
|
11783
|
-
if (
|
|
11784
|
-
return
|
|
11782
|
+
radioOrSelect: (options, isString2) => {
|
|
11783
|
+
if (isString2) {
|
|
11784
|
+
return StringSchema().nullable();
|
|
11785
11785
|
}
|
|
11786
|
-
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
|
|
11790
|
-
|
|
11791
|
-
|
|
11792
|
-
|
|
11786
|
+
return StringSchema().nullable().transform((value) => {
|
|
11787
|
+
if (value === "") {
|
|
11788
|
+
return void 0;
|
|
11789
|
+
}
|
|
11790
|
+
if (options?.includes(null)) {
|
|
11791
|
+
return value;
|
|
11792
|
+
}
|
|
11793
|
+
return value === null ? void 0 : value;
|
|
11794
|
+
}).oneOf(options, ({ value }) => {
|
|
11795
|
+
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
11796
|
+
});
|
|
11797
|
+
},
|
|
11793
11798
|
date: ({ minDate, maxDate }) => {
|
|
11794
11799
|
let dateString = StringSchema().nullable().transform((value) => {
|
|
11795
11800
|
if (value === "") {
|
|
@@ -11857,8 +11862,9 @@ var getOptions = (field) => {
|
|
|
11857
11862
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
11858
11863
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
11859
11864
|
if (field.options?.length > 0) {
|
|
11865
|
+
const isString2 = field.options?.findIndex((option) => option.type === "string") > -1;
|
|
11860
11866
|
const optionValues = getOptions(field);
|
|
11861
|
-
return yupSchemas.radioOrSelect(optionValues);
|
|
11867
|
+
return yupSchemas.radioOrSelect(optionValues, isString2);
|
|
11862
11868
|
}
|
|
11863
11869
|
if (field.format === "date") {
|
|
11864
11870
|
return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
schemaInputTypeRadioOptionsWithDetails,
|
|
16
16
|
schemaInputTypeSelectSoloDeprecated,
|
|
17
17
|
schemaInputTypeSelectSolo,
|
|
18
|
+
schemaInputTypeSelectString,
|
|
18
19
|
schemaInputTypeSelectMultipleDeprecated,
|
|
19
20
|
schemaInputTypeSelectMultiple,
|
|
20
21
|
schemaInputTypeSelectMultipleOptional,
|
|
@@ -430,7 +431,7 @@ describe('createHeadlessForm', () => {
|
|
|
430
431
|
});
|
|
431
432
|
|
|
432
433
|
describe('field support', () => {
|
|
433
|
-
function assertOptionsAllowed({ handleValidation, fieldName, validOptions }) {
|
|
434
|
+
function assertOptionsAllowed({ handleValidation, fieldName, validOptions, isString = false }) {
|
|
434
435
|
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
435
436
|
|
|
436
437
|
// All allowed options are valid
|
|
@@ -438,27 +439,34 @@ describe('createHeadlessForm', () => {
|
|
|
438
439
|
expect(validateForm({ [fieldName]: value })).toBeUndefined();
|
|
439
440
|
});
|
|
440
441
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
[fieldName]: '
|
|
444
|
-
|
|
442
|
+
if (!isString) {
|
|
443
|
+
// Any other arbitrary value is not valid.
|
|
444
|
+
expect(validateForm({ [fieldName]: 'blah-blah' })).toEqual({
|
|
445
|
+
[fieldName]: 'The option "blah-blah" is not valid.',
|
|
446
|
+
});
|
|
445
447
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
448
|
+
// Given undefined, it says it's a required field.
|
|
449
|
+
expect(validateForm({})).toEqual({
|
|
450
|
+
[fieldName]: 'Required field',
|
|
451
|
+
});
|
|
450
452
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
453
|
+
// As required field, empty string ("") is also considered empty. @BUG RMT-518
|
|
454
|
+
// Expectation: The error to be "The option '' is not valid."
|
|
455
|
+
expect(validateForm({ [fieldName]: '' })).toEqual({
|
|
456
|
+
[fieldName]: 'Required field',
|
|
457
|
+
});
|
|
456
458
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
459
|
+
// As required field, null is also considered empty @BUG RMT-518
|
|
460
|
+
// Expectation: The error to be "The option null is not valid."
|
|
461
|
+
expect(validateForm({ [fieldName]: null })).toEqual({
|
|
462
|
+
[fieldName]: 'Required field',
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
if (isString) {
|
|
467
|
+
// Any other arbitrary value is valid.
|
|
468
|
+
expect(validateForm({ [fieldName]: 'blah-blah' })).toBeUndefined();
|
|
469
|
+
}
|
|
462
470
|
}
|
|
463
471
|
|
|
464
472
|
it('support "text" field type', () => {
|
|
@@ -630,6 +638,41 @@ describe('createHeadlessForm', () => {
|
|
|
630
638
|
});
|
|
631
639
|
});
|
|
632
640
|
|
|
641
|
+
it('supports "select" field type with string option', () => {
|
|
642
|
+
const { fields, handleValidation } = createHeadlessForm(schemaInputTypeSelectString);
|
|
643
|
+
const fieldSelect = fields[0];
|
|
644
|
+
expect(fieldSelect).toMatchObject({
|
|
645
|
+
name: 'browsers',
|
|
646
|
+
label: 'Browsers (solo)',
|
|
647
|
+
description: 'This solo select also includes a disabled option.',
|
|
648
|
+
options: [
|
|
649
|
+
{
|
|
650
|
+
value: 'chr',
|
|
651
|
+
label: 'Chrome',
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
value: 'ff',
|
|
655
|
+
label: 'Firefox',
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
value: 'ie',
|
|
659
|
+
label: 'Internet Explorer',
|
|
660
|
+
disabled: true,
|
|
661
|
+
},
|
|
662
|
+
{ value: undefined, type: 'string', label: '{Create another}' },
|
|
663
|
+
],
|
|
664
|
+
});
|
|
665
|
+
|
|
666
|
+
expect(fieldSelect).not.toHaveProperty('multiple');
|
|
667
|
+
|
|
668
|
+
assertOptionsAllowed({
|
|
669
|
+
handleValidation,
|
|
670
|
+
fieldName: 'browsers',
|
|
671
|
+
validOptions: ['chr', 'ff', 'ie'],
|
|
672
|
+
isString: true,
|
|
673
|
+
});
|
|
674
|
+
});
|
|
675
|
+
|
|
633
676
|
it('supports "select" field type with multiple options @deprecated', () => {
|
|
634
677
|
const result = createHeadlessForm(schemaInputTypeSelectMultipleDeprecated);
|
|
635
678
|
expect(result).toMatchObject({
|
|
@@ -1947,9 +1990,9 @@ describe('createHeadlessForm', () => {
|
|
|
1947
1990
|
},
|
|
1948
1991
|
},
|
|
1949
1992
|
{
|
|
1950
|
-
name: '
|
|
1951
|
-
label: '
|
|
1952
|
-
type: '
|
|
1993
|
+
name: 'role',
|
|
1994
|
+
label: 'Role',
|
|
1995
|
+
type: 'text',
|
|
1953
1996
|
statement: {
|
|
1954
1997
|
description: 'This is another statement message, but more severe.',
|
|
1955
1998
|
inputType: 'statement',
|
package/src/tests/helpers.js
CHANGED
|
@@ -238,6 +238,11 @@ 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
|
+
|
|
241
246
|
export const mockSelectInputMultiple = {
|
|
242
247
|
title: 'Browsers (multiple)',
|
|
243
248
|
description: 'This multi-select also includes a disabled option.',
|
|
@@ -463,6 +468,12 @@ export const mockCheckboxInput = {
|
|
|
463
468
|
})
|
|
464
469
|
.build();
|
|
465
470
|
*/
|
|
471
|
+
|
|
472
|
+
/**
|
|
473
|
+
* @deprecated in favor of normal JSON schema.
|
|
474
|
+
* Why? This adds extra complexity to read and to
|
|
475
|
+
* copy-paste into the Playground, validators, etc
|
|
476
|
+
* */
|
|
466
477
|
export function JSONSchemaBuilder() {
|
|
467
478
|
return {
|
|
468
479
|
addInput: function addInput(input) {
|
|
@@ -658,15 +669,15 @@ export const schemaWithoutTypes = {
|
|
|
658
669
|
},
|
|
659
670
|
};
|
|
660
671
|
|
|
661
|
-
export const schemaInputTypeText =
|
|
662
|
-
|
|
672
|
+
export const schemaInputTypeText = {
|
|
673
|
+
properties: {
|
|
663
674
|
id_number: mockTextInput,
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
|
|
675
|
+
},
|
|
676
|
+
required: ['id_number'],
|
|
677
|
+
};
|
|
667
678
|
|
|
668
|
-
export const schemaInputWithStatement =
|
|
669
|
-
|
|
679
|
+
export const schemaInputWithStatement = {
|
|
680
|
+
properties: {
|
|
670
681
|
bonus: {
|
|
671
682
|
title: 'Bonus',
|
|
672
683
|
'x-jsf-presentation': {
|
|
@@ -678,71 +689,10 @@ export const schemaInputWithStatement = JSONSchemaBuilder()
|
|
|
678
689
|
},
|
|
679
690
|
},
|
|
680
691
|
},
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
a_or_b: {
|
|
684
|
-
title: 'A dropdown',
|
|
685
|
-
description: 'Some options to chose from',
|
|
686
|
-
items: {
|
|
687
|
-
enum: ['A', 'B'],
|
|
688
|
-
},
|
|
692
|
+
role: {
|
|
693
|
+
title: 'Role',
|
|
689
694
|
'x-jsf-presentation': {
|
|
690
|
-
inputType: 'select',
|
|
691
|
-
options: [
|
|
692
|
-
{
|
|
693
|
-
label: 'A',
|
|
694
|
-
value: 'A',
|
|
695
|
-
},
|
|
696
|
-
{
|
|
697
|
-
label: 'B',
|
|
698
|
-
value: 'B',
|
|
699
|
-
},
|
|
700
|
-
],
|
|
701
|
-
placeholder: 'Select...',
|
|
702
|
-
statement: {
|
|
703
|
-
description: 'This is another statement message, but more severe.',
|
|
704
|
-
inputType: 'statement',
|
|
705
|
-
severity: 'warning',
|
|
706
|
-
},
|
|
707
|
-
},
|
|
708
|
-
},
|
|
709
|
-
})
|
|
710
|
-
.build();
|
|
711
|
-
|
|
712
|
-
export const schemaInputWithStatementDeprecated = JSONSchemaBuilder()
|
|
713
|
-
.addInput({
|
|
714
|
-
bonus: {
|
|
715
|
-
title: 'Bonus',
|
|
716
|
-
presentation: {
|
|
717
695
|
inputType: 'text',
|
|
718
|
-
statement: {
|
|
719
|
-
description: 'This is a custom statement message.',
|
|
720
|
-
inputType: 'statement',
|
|
721
|
-
severity: 'info',
|
|
722
|
-
},
|
|
723
|
-
},
|
|
724
|
-
},
|
|
725
|
-
})
|
|
726
|
-
.addInput({
|
|
727
|
-
a_or_b: {
|
|
728
|
-
title: 'A dropdown',
|
|
729
|
-
description: 'Some options to chose from',
|
|
730
|
-
items: {
|
|
731
|
-
enum: ['A', 'B'],
|
|
732
|
-
},
|
|
733
|
-
presentation: {
|
|
734
|
-
inputType: 'select',
|
|
735
|
-
options: [
|
|
736
|
-
{
|
|
737
|
-
label: 'A',
|
|
738
|
-
value: 'A',
|
|
739
|
-
},
|
|
740
|
-
{
|
|
741
|
-
label: 'B',
|
|
742
|
-
value: 'B',
|
|
743
|
-
},
|
|
744
|
-
],
|
|
745
|
-
placeholder: 'Select...',
|
|
746
696
|
statement: {
|
|
747
697
|
description: 'This is another statement message, but more severe.',
|
|
748
698
|
inputType: 'statement',
|
|
@@ -750,11 +700,11 @@ export const schemaInputWithStatementDeprecated = JSONSchemaBuilder()
|
|
|
750
700
|
},
|
|
751
701
|
},
|
|
752
702
|
},
|
|
753
|
-
}
|
|
754
|
-
|
|
703
|
+
},
|
|
704
|
+
};
|
|
755
705
|
|
|
756
|
-
export const schemaInputWithExtra =
|
|
757
|
-
|
|
706
|
+
export const schemaInputWithExtra = {
|
|
707
|
+
properties: {
|
|
758
708
|
bonus: {
|
|
759
709
|
title: 'Bonus',
|
|
760
710
|
'x-jsf-presentation': {
|
|
@@ -772,11 +722,11 @@ export const schemaInputWithExtra = JSONSchemaBuilder()
|
|
|
772
722
|
`,
|
|
773
723
|
},
|
|
774
724
|
},
|
|
775
|
-
}
|
|
776
|
-
|
|
725
|
+
},
|
|
726
|
+
};
|
|
777
727
|
|
|
778
|
-
export const schemaInputWithCustomDescription =
|
|
779
|
-
|
|
728
|
+
export const schemaInputWithCustomDescription = {
|
|
729
|
+
properties: {
|
|
780
730
|
other: {
|
|
781
731
|
title: 'Other',
|
|
782
732
|
'x-jsf-presentation': {
|
|
@@ -785,8 +735,8 @@ export const schemaInputWithCustomDescription = JSONSchemaBuilder()
|
|
|
785
735
|
},
|
|
786
736
|
type: 'string',
|
|
787
737
|
},
|
|
788
|
-
}
|
|
789
|
-
|
|
738
|
+
},
|
|
739
|
+
};
|
|
790
740
|
|
|
791
741
|
export const schemaInputDeprecated = JSONSchemaBuilder()
|
|
792
742
|
.addInput({
|
|
@@ -952,6 +902,10 @@ export const schemaInputTypeSelectSolo = JSONSchemaBuilder()
|
|
|
952
902
|
.setRequiredFields(['browsers'])
|
|
953
903
|
.build();
|
|
954
904
|
|
|
905
|
+
export const schemaInputTypeSelectString = JSONSchemaBuilder().addInput({
|
|
906
|
+
browsers: mockSelectInputSoloCreatable,
|
|
907
|
+
});
|
|
908
|
+
|
|
955
909
|
/** @deprecated */
|
|
956
910
|
export const schemaInputTypeSelectMultipleDeprecated = JSONSchemaBuilder()
|
|
957
911
|
.addInput({
|