@remoteoss/json-schema-form 0.4.0-beta.0 → 0.4.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 +7 -0
- package/dist/index.cjs +59 -21
- package/dist/index.js +59 -21
- package/dist/standalone.js +414 -804
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +507 -266
- package/src/tests/helpers.custom.js +1 -1
- package/src/tests/helpers.js +177 -45
|
@@ -200,7 +200,7 @@ export const schemaInputTypeHidden = {
|
|
|
200
200
|
...mockSelectInputSolo,
|
|
201
201
|
title: 'Select hidden',
|
|
202
202
|
'x-jsf-presentation': { inputType: 'hidden' },
|
|
203
|
-
default: '
|
|
203
|
+
default: 'chr',
|
|
204
204
|
},
|
|
205
205
|
a_hidden_select_multiple: {
|
|
206
206
|
...schemaInputTypeCountriesMultiple.properties.nationality,
|
package/src/tests/helpers.js
CHANGED
|
@@ -127,28 +127,6 @@ export const mockRadioInput = {
|
|
|
127
127
|
},
|
|
128
128
|
type: 'string',
|
|
129
129
|
};
|
|
130
|
-
export const mockRadioInputOptional = {
|
|
131
|
-
title: 'Has car',
|
|
132
|
-
description: 'Do you have a car? (optional field, check oneOf)',
|
|
133
|
-
oneOf: [
|
|
134
|
-
{
|
|
135
|
-
const: null, // The option is excluded from the jsf options.
|
|
136
|
-
title: 'N/A',
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
const: 'yes',
|
|
140
|
-
title: 'Yes',
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
const: 'no',
|
|
144
|
-
title: 'No',
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
'x-jsf-presentation': {
|
|
148
|
-
inputType: 'radio',
|
|
149
|
-
},
|
|
150
|
-
type: ['string', 'null'],
|
|
151
|
-
};
|
|
152
130
|
|
|
153
131
|
export const mockRadioCardExpandableInput = {
|
|
154
132
|
title: 'Experience level',
|
|
@@ -885,14 +863,50 @@ export const schemaInputTypeRadio = {
|
|
|
885
863
|
required: ['has_siblings'],
|
|
886
864
|
};
|
|
887
865
|
|
|
866
|
+
export const mockRadioInputOptionalNull = {
|
|
867
|
+
title: 'Has car',
|
|
868
|
+
oneOf: [
|
|
869
|
+
{ const: 'yes', title: 'Yes' },
|
|
870
|
+
{ const: 'no', title: 'No' },
|
|
871
|
+
// JSF excludes the null option from the field output
|
|
872
|
+
// But keepts null as an accepted value
|
|
873
|
+
{ const: null, title: 'N/A' },
|
|
874
|
+
],
|
|
875
|
+
'x-jsf-presentation': { inputType: 'radio' },
|
|
876
|
+
type: ['string', 'null'], // Yes, the JSON Schema spec is 'null', not null.
|
|
877
|
+
};
|
|
878
|
+
|
|
888
879
|
export const schemaInputTypeRadioRequiredAndOptional = {
|
|
889
880
|
properties: {
|
|
890
881
|
has_siblings: mockRadioInput,
|
|
891
|
-
has_car:
|
|
882
|
+
has_car: {
|
|
883
|
+
...mockRadioInputOptionalNull,
|
|
884
|
+
description: 'Do you have a car? (optional field, check oneOf)',
|
|
885
|
+
},
|
|
892
886
|
},
|
|
893
887
|
required: ['has_siblings'],
|
|
894
888
|
};
|
|
895
889
|
|
|
890
|
+
export const schemaInputRadioOptionalNull = {
|
|
891
|
+
properties: {
|
|
892
|
+
has_car: mockRadioInputOptionalNull,
|
|
893
|
+
},
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
export const schemaInputRadioOptionalConventional = {
|
|
897
|
+
properties: {
|
|
898
|
+
has_car: {
|
|
899
|
+
title: 'Has car',
|
|
900
|
+
oneOf: [
|
|
901
|
+
{ const: 'yes', title: 'Yes' },
|
|
902
|
+
{ const: 'no', title: 'No' },
|
|
903
|
+
],
|
|
904
|
+
'x-jsf-presentation': { inputType: 'radio' },
|
|
905
|
+
type: 'string',
|
|
906
|
+
},
|
|
907
|
+
},
|
|
908
|
+
};
|
|
909
|
+
|
|
896
910
|
export const schemaInputTypeRadioCard = {
|
|
897
911
|
properties: {
|
|
898
912
|
experience_level: mockRadioCardExpandableInput,
|
|
@@ -1214,8 +1228,8 @@ export const schemaWithOrderKeyword = JSONSchemaBuilder()
|
|
|
1214
1228
|
.setOrder(['username', 'age', 'street'])
|
|
1215
1229
|
.build();
|
|
1216
1230
|
|
|
1217
|
-
export const schemaDynamicValidationConst =
|
|
1218
|
-
|
|
1231
|
+
export const schemaDynamicValidationConst = {
|
|
1232
|
+
properties: {
|
|
1219
1233
|
a_fieldset: mockFieldset,
|
|
1220
1234
|
a_group_array: simpleGroupArrayInput,
|
|
1221
1235
|
validate_tabs: {
|
|
@@ -1252,8 +1266,8 @@ export const schemaDynamicValidationConst = JSONSchemaBuilder()
|
|
|
1252
1266
|
inputType: 'radio',
|
|
1253
1267
|
},
|
|
1254
1268
|
},
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1269
|
+
},
|
|
1270
|
+
allOf: [
|
|
1257
1271
|
{
|
|
1258
1272
|
if: {
|
|
1259
1273
|
properties: {
|
|
@@ -1272,27 +1286,25 @@ export const schemaDynamicValidationConst = JSONSchemaBuilder()
|
|
|
1272
1286
|
},
|
|
1273
1287
|
},
|
|
1274
1288
|
},
|
|
1275
|
-
]
|
|
1276
|
-
|
|
1277
|
-
{
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
const: 'yes',
|
|
1281
|
-
},
|
|
1289
|
+
],
|
|
1290
|
+
if: {
|
|
1291
|
+
properties: {
|
|
1292
|
+
validate_tabs: {
|
|
1293
|
+
const: 'yes',
|
|
1282
1294
|
},
|
|
1283
|
-
required: ['validate_tabs'],
|
|
1284
1295
|
},
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1296
|
+
required: ['validate_tabs'],
|
|
1297
|
+
},
|
|
1298
|
+
then: {
|
|
1299
|
+
properties: {
|
|
1300
|
+
a_fieldset: {
|
|
1301
|
+
required: ['id_number', 'tabs'],
|
|
1290
1302
|
},
|
|
1291
|
-
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1303
|
+
},
|
|
1304
|
+
},
|
|
1305
|
+
required: ['a_fieldset', 'validate_tabs', 'mandatory_group_array'],
|
|
1306
|
+
'x-jsf-order': ['validate_tabs', 'a_fieldset', 'mandatory_group_array', 'a_group_array'],
|
|
1307
|
+
};
|
|
1296
1308
|
|
|
1297
1309
|
export const schemaDynamicValidationMinimumMaximum = JSONSchemaBuilder()
|
|
1298
1310
|
.addInput({
|
|
@@ -1678,6 +1690,126 @@ export const schemaFieldsetScopedCondition = {
|
|
|
1678
1690
|
type: 'object',
|
|
1679
1691
|
};
|
|
1680
1692
|
|
|
1693
|
+
export const schemaWithConditionalToFieldset = {
|
|
1694
|
+
additionalProperties: false,
|
|
1695
|
+
type: 'object',
|
|
1696
|
+
properties: {
|
|
1697
|
+
work_hours_per_week: {
|
|
1698
|
+
title: 'Hours per week',
|
|
1699
|
+
type: 'number',
|
|
1700
|
+
description: 'Above 30 hours, the Perk>Food options change, and PTO is required.',
|
|
1701
|
+
'x-jsf-presentation': {
|
|
1702
|
+
inputType: 'number',
|
|
1703
|
+
},
|
|
1704
|
+
},
|
|
1705
|
+
pto: {
|
|
1706
|
+
title: 'Time-off (days)',
|
|
1707
|
+
type: 'number',
|
|
1708
|
+
'x-jsf-presentation': {
|
|
1709
|
+
inputType: 'number',
|
|
1710
|
+
},
|
|
1711
|
+
},
|
|
1712
|
+
perks: {
|
|
1713
|
+
additionalProperties: false,
|
|
1714
|
+
properties: {
|
|
1715
|
+
food: {
|
|
1716
|
+
oneOf: [
|
|
1717
|
+
{
|
|
1718
|
+
const: 'lunch',
|
|
1719
|
+
title: 'Lunch',
|
|
1720
|
+
},
|
|
1721
|
+
{
|
|
1722
|
+
const: 'dinner',
|
|
1723
|
+
title: 'Dinner',
|
|
1724
|
+
},
|
|
1725
|
+
{
|
|
1726
|
+
const: 'all',
|
|
1727
|
+
title: 'All',
|
|
1728
|
+
description: 'Every meal',
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
const: 'no',
|
|
1732
|
+
title: 'No food',
|
|
1733
|
+
},
|
|
1734
|
+
],
|
|
1735
|
+
title: 'Food',
|
|
1736
|
+
type: 'string',
|
|
1737
|
+
'x-jsf-presentation': {
|
|
1738
|
+
inputType: 'radio',
|
|
1739
|
+
},
|
|
1740
|
+
},
|
|
1741
|
+
retirement: {
|
|
1742
|
+
oneOf: [
|
|
1743
|
+
{
|
|
1744
|
+
const: 'basic',
|
|
1745
|
+
title: 'Basic',
|
|
1746
|
+
},
|
|
1747
|
+
{
|
|
1748
|
+
const: 'plus',
|
|
1749
|
+
title: 'Plus',
|
|
1750
|
+
},
|
|
1751
|
+
],
|
|
1752
|
+
title: 'Retirement',
|
|
1753
|
+
type: 'string',
|
|
1754
|
+
'x-jsf-presentation': {
|
|
1755
|
+
inputType: 'radio',
|
|
1756
|
+
},
|
|
1757
|
+
},
|
|
1758
|
+
},
|
|
1759
|
+
required: ['food', 'retirement'],
|
|
1760
|
+
title: 'Perks',
|
|
1761
|
+
type: 'object',
|
|
1762
|
+
'x-jsf-presentation': {
|
|
1763
|
+
inputType: 'fieldset',
|
|
1764
|
+
},
|
|
1765
|
+
},
|
|
1766
|
+
},
|
|
1767
|
+
allOf: [
|
|
1768
|
+
{
|
|
1769
|
+
if: {
|
|
1770
|
+
properties: {
|
|
1771
|
+
work_hours_per_week: {
|
|
1772
|
+
minimum: 30,
|
|
1773
|
+
},
|
|
1774
|
+
},
|
|
1775
|
+
required: ['work_hours_per_week'],
|
|
1776
|
+
},
|
|
1777
|
+
then: {
|
|
1778
|
+
properties: {
|
|
1779
|
+
pto: {
|
|
1780
|
+
$comment: '@BUG: This description does not disappear once activated.',
|
|
1781
|
+
description: 'Above 30 hours, the PTO needs to be at least 20 days.',
|
|
1782
|
+
minimum: 20,
|
|
1783
|
+
},
|
|
1784
|
+
perks: {
|
|
1785
|
+
properties: {
|
|
1786
|
+
food: {
|
|
1787
|
+
description: "Above 30 hours, the 'no' option disappears.",
|
|
1788
|
+
oneOf: [
|
|
1789
|
+
{
|
|
1790
|
+
const: 'lunch',
|
|
1791
|
+
title: 'Lunch',
|
|
1792
|
+
},
|
|
1793
|
+
{
|
|
1794
|
+
const: 'dinner',
|
|
1795
|
+
title: 'Dinner',
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
const: 'all',
|
|
1799
|
+
title: 'all',
|
|
1800
|
+
},
|
|
1801
|
+
],
|
|
1802
|
+
},
|
|
1803
|
+
},
|
|
1804
|
+
},
|
|
1805
|
+
},
|
|
1806
|
+
required: ['pto'],
|
|
1807
|
+
},
|
|
1808
|
+
},
|
|
1809
|
+
],
|
|
1810
|
+
required: ['perks', 'work_hours_per_week'],
|
|
1811
|
+
};
|
|
1812
|
+
|
|
1681
1813
|
export const schemaWorkSchedule = {
|
|
1682
1814
|
type: 'object',
|
|
1683
1815
|
properties: {
|