@remoteoss/json-schema-form 0.3.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 +19 -4
- package/dist/index.cjs +74 -22
- package/dist/index.js +74 -22
- package/dist/standalone.js +429 -805
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +537 -266
- package/src/tests/helpers.custom.js +1 -1
- package/src/tests/helpers.js +233 -65
|
@@ -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',
|
|
@@ -871,34 +849,106 @@ export const schemaInputDeprecated = JSONSchemaBuilder()
|
|
|
871
849
|
.build();
|
|
872
850
|
|
|
873
851
|
/** @deprecated */
|
|
874
|
-
export const schemaInputTypeRadioDeprecated =
|
|
875
|
-
|
|
852
|
+
export const schemaInputTypeRadioDeprecated = {
|
|
853
|
+
properties: {
|
|
876
854
|
has_siblings: mockRadioInputDeprecated,
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
855
|
+
},
|
|
856
|
+
required: ['has_siblings'],
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
export const schemaInputTypeRadio = {
|
|
860
|
+
properties: {
|
|
882
861
|
has_siblings: mockRadioInput,
|
|
883
|
-
}
|
|
884
|
-
|
|
885
|
-
|
|
862
|
+
},
|
|
863
|
+
required: ['has_siblings'],
|
|
864
|
+
};
|
|
886
865
|
|
|
887
|
-
export const
|
|
888
|
-
|
|
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
|
+
|
|
879
|
+
export const schemaInputTypeRadioRequiredAndOptional = {
|
|
880
|
+
properties: {
|
|
889
881
|
has_siblings: mockRadioInput,
|
|
890
|
-
has_car:
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
882
|
+
has_car: {
|
|
883
|
+
...mockRadioInputOptionalNull,
|
|
884
|
+
description: 'Do you have a car? (optional field, check oneOf)',
|
|
885
|
+
},
|
|
886
|
+
},
|
|
887
|
+
required: ['has_siblings'],
|
|
888
|
+
};
|
|
894
889
|
|
|
895
|
-
export const
|
|
896
|
-
|
|
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
|
+
|
|
910
|
+
export const schemaInputTypeRadioCard = {
|
|
911
|
+
properties: {
|
|
897
912
|
experience_level: mockRadioCardExpandableInput,
|
|
898
913
|
payment_method: mockRadioCardInput,
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
|
|
914
|
+
},
|
|
915
|
+
required: ['experience_level'],
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
export const schemaInputTypeRadioOptionsWithDetails = {
|
|
919
|
+
properties: {
|
|
920
|
+
health_perks: {
|
|
921
|
+
title: 'Health perks',
|
|
922
|
+
description:
|
|
923
|
+
'This example contains options with more custom details, under the x-jsf-presentation key',
|
|
924
|
+
oneOf: [
|
|
925
|
+
{
|
|
926
|
+
const: 'basic',
|
|
927
|
+
title: 'Basic',
|
|
928
|
+
'x-jsf-presentation': {
|
|
929
|
+
meta: {
|
|
930
|
+
displayCost: '$30.00/mo',
|
|
931
|
+
},
|
|
932
|
+
},
|
|
933
|
+
'x-another': 'extra-thing',
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
const: 'standard',
|
|
937
|
+
title: 'Standard',
|
|
938
|
+
'x-jsf-presentation': {
|
|
939
|
+
meta: {
|
|
940
|
+
displayCost: '$50.00/mo',
|
|
941
|
+
},
|
|
942
|
+
},
|
|
943
|
+
},
|
|
944
|
+
],
|
|
945
|
+
'x-jsf-presentation': {
|
|
946
|
+
inputType: 'radio',
|
|
947
|
+
},
|
|
948
|
+
type: 'string',
|
|
949
|
+
},
|
|
950
|
+
},
|
|
951
|
+
};
|
|
902
952
|
|
|
903
953
|
/** @deprecated */
|
|
904
954
|
export const schemaInputTypeSelectSoloDeprecated = JSONSchemaBuilder()
|
|
@@ -1178,8 +1228,8 @@ export const schemaWithOrderKeyword = JSONSchemaBuilder()
|
|
|
1178
1228
|
.setOrder(['username', 'age', 'street'])
|
|
1179
1229
|
.build();
|
|
1180
1230
|
|
|
1181
|
-
export const schemaDynamicValidationConst =
|
|
1182
|
-
|
|
1231
|
+
export const schemaDynamicValidationConst = {
|
|
1232
|
+
properties: {
|
|
1183
1233
|
a_fieldset: mockFieldset,
|
|
1184
1234
|
a_group_array: simpleGroupArrayInput,
|
|
1185
1235
|
validate_tabs: {
|
|
@@ -1216,8 +1266,8 @@ export const schemaDynamicValidationConst = JSONSchemaBuilder()
|
|
|
1216
1266
|
inputType: 'radio',
|
|
1217
1267
|
},
|
|
1218
1268
|
},
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1269
|
+
},
|
|
1270
|
+
allOf: [
|
|
1221
1271
|
{
|
|
1222
1272
|
if: {
|
|
1223
1273
|
properties: {
|
|
@@ -1236,27 +1286,25 @@ export const schemaDynamicValidationConst = JSONSchemaBuilder()
|
|
|
1236
1286
|
},
|
|
1237
1287
|
},
|
|
1238
1288
|
},
|
|
1239
|
-
]
|
|
1240
|
-
|
|
1241
|
-
{
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
const: 'yes',
|
|
1245
|
-
},
|
|
1289
|
+
],
|
|
1290
|
+
if: {
|
|
1291
|
+
properties: {
|
|
1292
|
+
validate_tabs: {
|
|
1293
|
+
const: 'yes',
|
|
1246
1294
|
},
|
|
1247
|
-
required: ['validate_tabs'],
|
|
1248
1295
|
},
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1296
|
+
required: ['validate_tabs'],
|
|
1297
|
+
},
|
|
1298
|
+
then: {
|
|
1299
|
+
properties: {
|
|
1300
|
+
a_fieldset: {
|
|
1301
|
+
required: ['id_number', 'tabs'],
|
|
1254
1302
|
},
|
|
1255
|
-
}
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
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
|
+
};
|
|
1260
1308
|
|
|
1261
1309
|
export const schemaDynamicValidationMinimumMaximum = JSONSchemaBuilder()
|
|
1262
1310
|
.addInput({
|
|
@@ -1642,6 +1690,126 @@ export const schemaFieldsetScopedCondition = {
|
|
|
1642
1690
|
type: 'object',
|
|
1643
1691
|
};
|
|
1644
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
|
+
|
|
1645
1813
|
export const schemaWorkSchedule = {
|
|
1646
1814
|
type: 'object',
|
|
1647
1815
|
properties: {
|