@remoteoss/json-schema-form 0.11.12-dev.20250411165200 → 0.11.13-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 +12 -0
- package/dist/index.cjs +24 -35
- package/dist/index.js +24 -35
- package/dist/standalone.js +28 -39
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +38 -43
- package/src/tests/helpers.custom.js +7 -7
- package/src/tests/helpers.js +5 -89
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
#### 0.11.13-beta.0 (2025-05-05)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* Fields accept any key starting with x-* ([#180](https://github.com/remoteoss/json-schema-form/pull/180)) ([c22aee0a](https://github.com/remoteoss/json-schema-form/commit/c22aee0a211afb0109257bd9e7265a0e91aef118))
|
|
6
|
+
|
|
7
|
+
#### 0.11.12-beta.0 (2025-04-15)
|
|
8
|
+
|
|
9
|
+
##### Chores
|
|
10
|
+
|
|
11
|
+
* change deprecated 'presentation' to 'x-jsf-presentation' in test helpers ([#159](https://github.com/remoteoss/json-schema-form/pull/159)) ([3f03b16d](https://github.com/remoteoss/json-schema-form/commit/3f03b16dce6acd801ff497a9c547cceb1b6347c5))
|
|
12
|
+
|
|
1
13
|
#### 0.11.11-beta.0 (2025-02-20)
|
|
2
14
|
|
|
3
15
|
##### Bug Fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2025 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.13-beta.0
|
|
5
|
+
Generated: Mon, 05 May 2025 11:12:08 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -82,6 +82,7 @@ var import_get2 = __toESM(require("lodash/get"));
|
|
|
82
82
|
var import_isNil = __toESM(require("lodash/isNil"));
|
|
83
83
|
var import_omit = __toESM(require("lodash/omit"));
|
|
84
84
|
var import_omitBy = __toESM(require("lodash/omitBy"));
|
|
85
|
+
var import_pickBy = __toESM(require("lodash/pickBy"));
|
|
85
86
|
var import_set = __toESM(require("lodash/set"));
|
|
86
87
|
var import_yup2 = require("yup");
|
|
87
88
|
|
|
@@ -1308,24 +1309,12 @@ function processNode({
|
|
|
1308
1309
|
formFields,
|
|
1309
1310
|
accRequired = /* @__PURE__ */ new Set(),
|
|
1310
1311
|
parentID = "root",
|
|
1311
|
-
logic
|
|
1312
|
-
processingConditional = false
|
|
1312
|
+
logic
|
|
1313
1313
|
}) {
|
|
1314
1314
|
const requiredFields = new Set(accRequired);
|
|
1315
1315
|
Object.keys(node.properties ?? []).forEach((fieldName) => {
|
|
1316
1316
|
const field = getField(fieldName, formFields);
|
|
1317
1317
|
updateField(field, requiredFields, node, formValues, logic, { parentID });
|
|
1318
|
-
const nestedNode = node.properties[fieldName];
|
|
1319
|
-
const isFieldset = field.inputType === supportedTypes.FIELDSET;
|
|
1320
|
-
if (isFieldset && processingConditional) {
|
|
1321
|
-
processNode({
|
|
1322
|
-
node: nestedNode,
|
|
1323
|
-
formValues: formValues[fieldName] || {},
|
|
1324
|
-
formFields: field.fields,
|
|
1325
|
-
parentID,
|
|
1326
|
-
logic
|
|
1327
|
-
});
|
|
1328
|
-
}
|
|
1329
1318
|
});
|
|
1330
1319
|
node.required?.forEach((fieldName) => {
|
|
1331
1320
|
requiredFields.add(fieldName);
|
|
@@ -1342,8 +1331,7 @@ function processNode({
|
|
|
1342
1331
|
formFields,
|
|
1343
1332
|
accRequired: requiredFields,
|
|
1344
1333
|
parentID,
|
|
1345
|
-
logic
|
|
1346
|
-
processingConditional: true
|
|
1334
|
+
logic
|
|
1347
1335
|
});
|
|
1348
1336
|
branchRequired.forEach((field) => requiredFields.add(field));
|
|
1349
1337
|
} else if (node.else) {
|
|
@@ -1353,8 +1341,7 @@ function processNode({
|
|
|
1353
1341
|
formFields,
|
|
1354
1342
|
accRequired: requiredFields,
|
|
1355
1343
|
parentID,
|
|
1356
|
-
logic
|
|
1357
|
-
processingConditional: true
|
|
1344
|
+
logic
|
|
1358
1345
|
});
|
|
1359
1346
|
branchRequired.forEach((field) => requiredFields.add(field));
|
|
1360
1347
|
}
|
|
@@ -1371,20 +1358,6 @@ function processNode({
|
|
|
1371
1358
|
});
|
|
1372
1359
|
});
|
|
1373
1360
|
}
|
|
1374
|
-
if (node.properties) {
|
|
1375
|
-
Object.entries(node.properties).forEach(([name, nestedNode]) => {
|
|
1376
|
-
const inputType = getInputType(nestedNode);
|
|
1377
|
-
if (inputType === supportedTypes.FIELDSET) {
|
|
1378
|
-
processNode({
|
|
1379
|
-
node: nestedNode,
|
|
1380
|
-
formValues: formValues[name] || {},
|
|
1381
|
-
formFields: getField(name, formFields).fields,
|
|
1382
|
-
parentID: name,
|
|
1383
|
-
logic
|
|
1384
|
-
});
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1387
|
-
}
|
|
1388
1361
|
if (node.allOf) {
|
|
1389
1362
|
node.allOf.map(
|
|
1390
1363
|
(allOfNode) => processNode({
|
|
@@ -1399,6 +1372,20 @@ function processNode({
|
|
|
1399
1372
|
allOfItemRequired.forEach(requiredFields.add, requiredFields);
|
|
1400
1373
|
});
|
|
1401
1374
|
}
|
|
1375
|
+
if (node.properties) {
|
|
1376
|
+
Object.entries(node.properties).forEach(([name, nestedNode]) => {
|
|
1377
|
+
const inputType = getInputType(nestedNode);
|
|
1378
|
+
if (inputType === supportedTypes.FIELDSET) {
|
|
1379
|
+
processNode({
|
|
1380
|
+
node: nestedNode,
|
|
1381
|
+
formValues: formValues[name] || {},
|
|
1382
|
+
formFields: getField(name, formFields).fields,
|
|
1383
|
+
parentID: name,
|
|
1384
|
+
logic
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
}
|
|
1402
1389
|
if (node["x-jsf-logic"]) {
|
|
1403
1390
|
const { required: requiredFromLogic } = processJSONLogicNode({
|
|
1404
1391
|
node: node["x-jsf-logic"],
|
|
@@ -1474,7 +1461,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
1474
1461
|
const jsonLogicValidations = schemaNode["x-jsf-logic-validations"];
|
|
1475
1462
|
const computedAttributes = schemaNode["x-jsf-logic-computedAttrs"];
|
|
1476
1463
|
const decoratedComputedAttributes = getDecoratedComputedAttributes(computedAttributes);
|
|
1477
|
-
const node = (0, import_omit.default)(schemaNode, ["x-jsf-presentation", "presentation"]);
|
|
1464
|
+
const node = (0, import_omit.default)(schemaNode, ["x-jsf-presentation", "presentation", "x-jsf-errorMessage"]);
|
|
1478
1465
|
const description = presentation?.description || node.description;
|
|
1479
1466
|
const statementDescription = presentation.statement?.description;
|
|
1480
1467
|
const value = typeof node.const !== "undefined" && typeof node.default !== "undefined" && node.const === node.default ? { forcedValue: node.const } : {};
|
|
@@ -1530,7 +1517,9 @@ function extractParametersFromNode(schemaNode) {
|
|
|
1530
1517
|
else: node.else,
|
|
1531
1518
|
anyOf: node.anyOf,
|
|
1532
1519
|
allOf: node.allOf,
|
|
1533
|
-
errorMessage
|
|
1520
|
+
errorMessage,
|
|
1521
|
+
// Pass down all x-* keys except x-jsf-*, as those are handled above.
|
|
1522
|
+
...(0, import_pickBy.default)(node, (_, key) => key.startsWith("x-") && !key.startsWith("x-jsf-"))
|
|
1534
1523
|
},
|
|
1535
1524
|
import_isNil.default
|
|
1536
1525
|
);
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2025 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.13-beta.0
|
|
5
|
+
Generated: Mon, 05 May 2025 11:12:08 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -45,6 +45,7 @@ import get2 from "lodash/get";
|
|
|
45
45
|
import isNil from "lodash/isNil";
|
|
46
46
|
import omit from "lodash/omit";
|
|
47
47
|
import omitBy from "lodash/omitBy";
|
|
48
|
+
import pickBy from "lodash/pickBy";
|
|
48
49
|
import set from "lodash/set";
|
|
49
50
|
import { lazy } from "yup";
|
|
50
51
|
|
|
@@ -1271,24 +1272,12 @@ function processNode({
|
|
|
1271
1272
|
formFields,
|
|
1272
1273
|
accRequired = /* @__PURE__ */ new Set(),
|
|
1273
1274
|
parentID = "root",
|
|
1274
|
-
logic
|
|
1275
|
-
processingConditional = false
|
|
1275
|
+
logic
|
|
1276
1276
|
}) {
|
|
1277
1277
|
const requiredFields = new Set(accRequired);
|
|
1278
1278
|
Object.keys(node.properties ?? []).forEach((fieldName) => {
|
|
1279
1279
|
const field = getField(fieldName, formFields);
|
|
1280
1280
|
updateField(field, requiredFields, node, formValues, logic, { parentID });
|
|
1281
|
-
const nestedNode = node.properties[fieldName];
|
|
1282
|
-
const isFieldset = field.inputType === supportedTypes.FIELDSET;
|
|
1283
|
-
if (isFieldset && processingConditional) {
|
|
1284
|
-
processNode({
|
|
1285
|
-
node: nestedNode,
|
|
1286
|
-
formValues: formValues[fieldName] || {},
|
|
1287
|
-
formFields: field.fields,
|
|
1288
|
-
parentID,
|
|
1289
|
-
logic
|
|
1290
|
-
});
|
|
1291
|
-
}
|
|
1292
1281
|
});
|
|
1293
1282
|
node.required?.forEach((fieldName) => {
|
|
1294
1283
|
requiredFields.add(fieldName);
|
|
@@ -1305,8 +1294,7 @@ function processNode({
|
|
|
1305
1294
|
formFields,
|
|
1306
1295
|
accRequired: requiredFields,
|
|
1307
1296
|
parentID,
|
|
1308
|
-
logic
|
|
1309
|
-
processingConditional: true
|
|
1297
|
+
logic
|
|
1310
1298
|
});
|
|
1311
1299
|
branchRequired.forEach((field) => requiredFields.add(field));
|
|
1312
1300
|
} else if (node.else) {
|
|
@@ -1316,8 +1304,7 @@ function processNode({
|
|
|
1316
1304
|
formFields,
|
|
1317
1305
|
accRequired: requiredFields,
|
|
1318
1306
|
parentID,
|
|
1319
|
-
logic
|
|
1320
|
-
processingConditional: true
|
|
1307
|
+
logic
|
|
1321
1308
|
});
|
|
1322
1309
|
branchRequired.forEach((field) => requiredFields.add(field));
|
|
1323
1310
|
}
|
|
@@ -1334,20 +1321,6 @@ function processNode({
|
|
|
1334
1321
|
});
|
|
1335
1322
|
});
|
|
1336
1323
|
}
|
|
1337
|
-
if (node.properties) {
|
|
1338
|
-
Object.entries(node.properties).forEach(([name, nestedNode]) => {
|
|
1339
|
-
const inputType = getInputType(nestedNode);
|
|
1340
|
-
if (inputType === supportedTypes.FIELDSET) {
|
|
1341
|
-
processNode({
|
|
1342
|
-
node: nestedNode,
|
|
1343
|
-
formValues: formValues[name] || {},
|
|
1344
|
-
formFields: getField(name, formFields).fields,
|
|
1345
|
-
parentID: name,
|
|
1346
|
-
logic
|
|
1347
|
-
});
|
|
1348
|
-
}
|
|
1349
|
-
});
|
|
1350
|
-
}
|
|
1351
1324
|
if (node.allOf) {
|
|
1352
1325
|
node.allOf.map(
|
|
1353
1326
|
(allOfNode) => processNode({
|
|
@@ -1362,6 +1335,20 @@ function processNode({
|
|
|
1362
1335
|
allOfItemRequired.forEach(requiredFields.add, requiredFields);
|
|
1363
1336
|
});
|
|
1364
1337
|
}
|
|
1338
|
+
if (node.properties) {
|
|
1339
|
+
Object.entries(node.properties).forEach(([name, nestedNode]) => {
|
|
1340
|
+
const inputType = getInputType(nestedNode);
|
|
1341
|
+
if (inputType === supportedTypes.FIELDSET) {
|
|
1342
|
+
processNode({
|
|
1343
|
+
node: nestedNode,
|
|
1344
|
+
formValues: formValues[name] || {},
|
|
1345
|
+
formFields: getField(name, formFields).fields,
|
|
1346
|
+
parentID: name,
|
|
1347
|
+
logic
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
});
|
|
1351
|
+
}
|
|
1365
1352
|
if (node["x-jsf-logic"]) {
|
|
1366
1353
|
const { required: requiredFromLogic } = processJSONLogicNode({
|
|
1367
1354
|
node: node["x-jsf-logic"],
|
|
@@ -1437,7 +1424,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
1437
1424
|
const jsonLogicValidations = schemaNode["x-jsf-logic-validations"];
|
|
1438
1425
|
const computedAttributes = schemaNode["x-jsf-logic-computedAttrs"];
|
|
1439
1426
|
const decoratedComputedAttributes = getDecoratedComputedAttributes(computedAttributes);
|
|
1440
|
-
const node = omit(schemaNode, ["x-jsf-presentation", "presentation"]);
|
|
1427
|
+
const node = omit(schemaNode, ["x-jsf-presentation", "presentation", "x-jsf-errorMessage"]);
|
|
1441
1428
|
const description = presentation?.description || node.description;
|
|
1442
1429
|
const statementDescription = presentation.statement?.description;
|
|
1443
1430
|
const value = typeof node.const !== "undefined" && typeof node.default !== "undefined" && node.const === node.default ? { forcedValue: node.const } : {};
|
|
@@ -1493,7 +1480,9 @@ function extractParametersFromNode(schemaNode) {
|
|
|
1493
1480
|
else: node.else,
|
|
1494
1481
|
anyOf: node.anyOf,
|
|
1495
1482
|
allOf: node.allOf,
|
|
1496
|
-
errorMessage
|
|
1483
|
+
errorMessage,
|
|
1484
|
+
// Pass down all x-* keys except x-jsf-*, as those are handled above.
|
|
1485
|
+
...pickBy(node, (_, key) => key.startsWith("x-") && !key.startsWith("x-jsf-"))
|
|
1497
1486
|
},
|
|
1498
1487
|
isNil
|
|
1499
1488
|
);
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2025 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.13-beta.0
|
|
5
|
+
Generated: Mon, 05 May 2025 11:12:08 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -3064,7 +3064,7 @@ var require_pickBy = __commonJS({
|
|
|
3064
3064
|
var baseIteratee2 = require_baseIteratee();
|
|
3065
3065
|
var basePickBy = require_basePickBy();
|
|
3066
3066
|
var getAllKeysIn2 = require_getAllKeysIn();
|
|
3067
|
-
function
|
|
3067
|
+
function pickBy2(object2, predicate) {
|
|
3068
3068
|
if (object2 == null) {
|
|
3069
3069
|
return {};
|
|
3070
3070
|
}
|
|
@@ -3076,7 +3076,7 @@ var require_pickBy = __commonJS({
|
|
|
3076
3076
|
return predicate(value, path[0]);
|
|
3077
3077
|
});
|
|
3078
3078
|
}
|
|
3079
|
-
module2.exports =
|
|
3079
|
+
module2.exports = pickBy2;
|
|
3080
3080
|
}
|
|
3081
3081
|
});
|
|
3082
3082
|
|
|
@@ -3085,9 +3085,9 @@ var require_omitBy = __commonJS({
|
|
|
3085
3085
|
"node_modules/lodash/omitBy.js"(exports2, module2) {
|
|
3086
3086
|
var baseIteratee2 = require_baseIteratee();
|
|
3087
3087
|
var negate = require_negate();
|
|
3088
|
-
var
|
|
3088
|
+
var pickBy2 = require_pickBy();
|
|
3089
3089
|
function omitBy3(object2, predicate) {
|
|
3090
|
-
return
|
|
3090
|
+
return pickBy2(object2, negate(baseIteratee2(predicate)));
|
|
3091
3091
|
}
|
|
3092
3092
|
module2.exports = omitBy3;
|
|
3093
3093
|
}
|
|
@@ -7041,6 +7041,7 @@ var import_get3 = __toESM(require_get());
|
|
|
7041
7041
|
var import_isNil = __toESM(require_isNil());
|
|
7042
7042
|
var import_omit = __toESM(require_omit());
|
|
7043
7043
|
var import_omitBy = __toESM(require_omitBy());
|
|
7044
|
+
var import_pickBy = __toESM(require_pickBy());
|
|
7044
7045
|
var import_set = __toESM(require_set());
|
|
7045
7046
|
|
|
7046
7047
|
// node_modules/@babel/runtime/helpers/esm/extends.js
|
|
@@ -12787,24 +12788,12 @@ function processNode({
|
|
|
12787
12788
|
formFields,
|
|
12788
12789
|
accRequired = /* @__PURE__ */ new Set(),
|
|
12789
12790
|
parentID = "root",
|
|
12790
|
-
logic
|
|
12791
|
-
processingConditional = false
|
|
12791
|
+
logic
|
|
12792
12792
|
}) {
|
|
12793
12793
|
const requiredFields = new Set(accRequired);
|
|
12794
12794
|
Object.keys(node.properties ?? []).forEach((fieldName) => {
|
|
12795
12795
|
const field = getField(fieldName, formFields);
|
|
12796
12796
|
updateField(field, requiredFields, node, formValues, logic, { parentID });
|
|
12797
|
-
const nestedNode = node.properties[fieldName];
|
|
12798
|
-
const isFieldset = field.inputType === supportedTypes.FIELDSET;
|
|
12799
|
-
if (isFieldset && processingConditional) {
|
|
12800
|
-
processNode({
|
|
12801
|
-
node: nestedNode,
|
|
12802
|
-
formValues: formValues[fieldName] || {},
|
|
12803
|
-
formFields: field.fields,
|
|
12804
|
-
parentID,
|
|
12805
|
-
logic
|
|
12806
|
-
});
|
|
12807
|
-
}
|
|
12808
12797
|
});
|
|
12809
12798
|
node.required?.forEach((fieldName) => {
|
|
12810
12799
|
requiredFields.add(fieldName);
|
|
@@ -12821,8 +12810,7 @@ function processNode({
|
|
|
12821
12810
|
formFields,
|
|
12822
12811
|
accRequired: requiredFields,
|
|
12823
12812
|
parentID,
|
|
12824
|
-
logic
|
|
12825
|
-
processingConditional: true
|
|
12813
|
+
logic
|
|
12826
12814
|
});
|
|
12827
12815
|
branchRequired.forEach((field) => requiredFields.add(field));
|
|
12828
12816
|
} else if (node.else) {
|
|
@@ -12832,8 +12820,7 @@ function processNode({
|
|
|
12832
12820
|
formFields,
|
|
12833
12821
|
accRequired: requiredFields,
|
|
12834
12822
|
parentID,
|
|
12835
|
-
logic
|
|
12836
|
-
processingConditional: true
|
|
12823
|
+
logic
|
|
12837
12824
|
});
|
|
12838
12825
|
branchRequired.forEach((field) => requiredFields.add(field));
|
|
12839
12826
|
}
|
|
@@ -12850,20 +12837,6 @@ function processNode({
|
|
|
12850
12837
|
});
|
|
12851
12838
|
});
|
|
12852
12839
|
}
|
|
12853
|
-
if (node.properties) {
|
|
12854
|
-
Object.entries(node.properties).forEach(([name, nestedNode]) => {
|
|
12855
|
-
const inputType = getInputType(nestedNode);
|
|
12856
|
-
if (inputType === supportedTypes.FIELDSET) {
|
|
12857
|
-
processNode({
|
|
12858
|
-
node: nestedNode,
|
|
12859
|
-
formValues: formValues[name] || {},
|
|
12860
|
-
formFields: getField(name, formFields).fields,
|
|
12861
|
-
parentID: name,
|
|
12862
|
-
logic
|
|
12863
|
-
});
|
|
12864
|
-
}
|
|
12865
|
-
});
|
|
12866
|
-
}
|
|
12867
12840
|
if (node.allOf) {
|
|
12868
12841
|
node.allOf.map(
|
|
12869
12842
|
(allOfNode) => processNode({
|
|
@@ -12878,6 +12851,20 @@ function processNode({
|
|
|
12878
12851
|
allOfItemRequired.forEach(requiredFields.add, requiredFields);
|
|
12879
12852
|
});
|
|
12880
12853
|
}
|
|
12854
|
+
if (node.properties) {
|
|
12855
|
+
Object.entries(node.properties).forEach(([name, nestedNode]) => {
|
|
12856
|
+
const inputType = getInputType(nestedNode);
|
|
12857
|
+
if (inputType === supportedTypes.FIELDSET) {
|
|
12858
|
+
processNode({
|
|
12859
|
+
node: nestedNode,
|
|
12860
|
+
formValues: formValues[name] || {},
|
|
12861
|
+
formFields: getField(name, formFields).fields,
|
|
12862
|
+
parentID: name,
|
|
12863
|
+
logic
|
|
12864
|
+
});
|
|
12865
|
+
}
|
|
12866
|
+
});
|
|
12867
|
+
}
|
|
12881
12868
|
if (node["x-jsf-logic"]) {
|
|
12882
12869
|
const { required: requiredFromLogic } = processJSONLogicNode({
|
|
12883
12870
|
node: node["x-jsf-logic"],
|
|
@@ -12953,7 +12940,7 @@ function extractParametersFromNode(schemaNode) {
|
|
|
12953
12940
|
const jsonLogicValidations = schemaNode["x-jsf-logic-validations"];
|
|
12954
12941
|
const computedAttributes = schemaNode["x-jsf-logic-computedAttrs"];
|
|
12955
12942
|
const decoratedComputedAttributes = getDecoratedComputedAttributes(computedAttributes);
|
|
12956
|
-
const node = (0, import_omit.default)(schemaNode, ["x-jsf-presentation", "presentation"]);
|
|
12943
|
+
const node = (0, import_omit.default)(schemaNode, ["x-jsf-presentation", "presentation", "x-jsf-errorMessage"]);
|
|
12957
12944
|
const description = presentation?.description || node.description;
|
|
12958
12945
|
const statementDescription = presentation.statement?.description;
|
|
12959
12946
|
const value = typeof node.const !== "undefined" && typeof node.default !== "undefined" && node.const === node.default ? { forcedValue: node.const } : {};
|
|
@@ -13009,7 +12996,9 @@ function extractParametersFromNode(schemaNode) {
|
|
|
13009
12996
|
else: node.else,
|
|
13010
12997
|
anyOf: node.anyOf,
|
|
13011
12998
|
allOf: node.allOf,
|
|
13012
|
-
errorMessage
|
|
12999
|
+
errorMessage,
|
|
13000
|
+
// Pass down all x-* keys except x-jsf-*, as those are handled above.
|
|
13001
|
+
...(0, import_pickBy.default)(node, (_, key) => key.startsWith("x-") && !key.startsWith("x-jsf-"))
|
|
13013
13002
|
},
|
|
13014
13003
|
import_isNil.default
|
|
13015
13004
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.13-beta.0",
|
|
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",
|
|
@@ -63,7 +63,6 @@ import {
|
|
|
63
63
|
schemaForErrorMessageSpecificity,
|
|
64
64
|
jsfConfigForErrorMessageSpecificity,
|
|
65
65
|
schemaInputTypeFile,
|
|
66
|
-
schemaWithRootFieldsetsConditionals,
|
|
67
66
|
} from './helpers';
|
|
68
67
|
import { mockConsole, restoreConsoleAndEnsureItWasNotCalled } from './testUtils';
|
|
69
68
|
import { createHeadlessForm } from '@/createHeadlessForm';
|
|
@@ -2163,47 +2162,6 @@ describe('createHeadlessForm', () => {
|
|
|
2163
2162
|
).toBeUndefined();
|
|
2164
2163
|
});
|
|
2165
2164
|
});
|
|
2166
|
-
|
|
2167
|
-
describe('supports root fieldsets conditionals', () => {
|
|
2168
|
-
it('Given a basic retirement, the perks.has_pension is hidden', async () => {
|
|
2169
|
-
const { fields, handleValidation } = createHeadlessForm(
|
|
2170
|
-
schemaWithRootFieldsetsConditionals,
|
|
2171
|
-
{}
|
|
2172
|
-
);
|
|
2173
|
-
const validateForm = (vals) => friendlyError(handleValidation(vals));
|
|
2174
|
-
|
|
2175
|
-
expect(validateForm({})).toEqual({
|
|
2176
|
-
perks: {
|
|
2177
|
-
retirement: 'Required field',
|
|
2178
|
-
},
|
|
2179
|
-
});
|
|
2180
|
-
|
|
2181
|
-
// has_pension is not visible
|
|
2182
|
-
expect(getField(fields, 'perks', 'has_pension').isVisible).toBe(false);
|
|
2183
|
-
|
|
2184
|
-
expect(
|
|
2185
|
-
validateForm({
|
|
2186
|
-
perks: { retirement: 'plus' },
|
|
2187
|
-
})
|
|
2188
|
-
).toEqual({
|
|
2189
|
-
perks: {
|
|
2190
|
-
has_pension: 'Required field',
|
|
2191
|
-
},
|
|
2192
|
-
});
|
|
2193
|
-
|
|
2194
|
-
// field becomes visible
|
|
2195
|
-
expect(getField(fields, 'perks', 'has_pension').isVisible).toBe(true);
|
|
2196
|
-
|
|
2197
|
-
expect(
|
|
2198
|
-
validateForm({
|
|
2199
|
-
perks: { retirement: 'basic' },
|
|
2200
|
-
})
|
|
2201
|
-
).toBeUndefined();
|
|
2202
|
-
|
|
2203
|
-
// field becomes invisible
|
|
2204
|
-
expect(getField(fields, 'perks', 'has_pension').isVisible).toBe(false);
|
|
2205
|
-
});
|
|
2206
|
-
});
|
|
2207
2165
|
});
|
|
2208
2166
|
|
|
2209
2167
|
it('support "email" field type', () => {
|
|
@@ -2563,7 +2521,7 @@ describe('createHeadlessForm', () => {
|
|
|
2563
2521
|
.addInput({
|
|
2564
2522
|
username: {
|
|
2565
2523
|
...mockTextInputDeprecated,
|
|
2566
|
-
presentation: {
|
|
2524
|
+
'x-jsf-presentation': {
|
|
2567
2525
|
inputType: 'text',
|
|
2568
2526
|
maskSecret: 2,
|
|
2569
2527
|
// should override the root level description
|
|
@@ -2609,6 +2567,43 @@ describe('createHeadlessForm', () => {
|
|
|
2609
2567
|
});
|
|
2610
2568
|
});
|
|
2611
2569
|
|
|
2570
|
+
it('pass any "x-" attribute, expect for x-jsf-* keys', () => {
|
|
2571
|
+
const result = createHeadlessForm({
|
|
2572
|
+
properties: {
|
|
2573
|
+
country: {
|
|
2574
|
+
title: 'Country',
|
|
2575
|
+
type: 'string',
|
|
2576
|
+
'x-foo': 123,
|
|
2577
|
+
'x-bar': { something: true },
|
|
2578
|
+
'x-jsf-presentation': {
|
|
2579
|
+
inputType: 'select',
|
|
2580
|
+
direction: 'row',
|
|
2581
|
+
},
|
|
2582
|
+
'x-jsf-errorMessage': {
|
|
2583
|
+
type: 'some error message',
|
|
2584
|
+
},
|
|
2585
|
+
'x-jsf-foo': 'bar',
|
|
2586
|
+
},
|
|
2587
|
+
},
|
|
2588
|
+
});
|
|
2589
|
+
|
|
2590
|
+
expect(result.fields[0]).toMatchObject({
|
|
2591
|
+
name: 'country',
|
|
2592
|
+
label: 'Country',
|
|
2593
|
+
type: 'select',
|
|
2594
|
+
inputType: 'select',
|
|
2595
|
+
direction: 'row',
|
|
2596
|
+
errorMessage: { type: 'some error message' },
|
|
2597
|
+
'x-foo': 123,
|
|
2598
|
+
'x-bar': { something: true },
|
|
2599
|
+
});
|
|
2600
|
+
|
|
2601
|
+
// These ones are excluded:
|
|
2602
|
+
expect(result.fields[0]['x-jsf-presentation']).toBeUndefined();
|
|
2603
|
+
expect(result.fields[0]['x-jsf-errorMessage']).toBeUndefined();
|
|
2604
|
+
expect(result.fields[0]['x-jsf-foo']).toBeUndefined();
|
|
2605
|
+
});
|
|
2606
|
+
|
|
2612
2607
|
it('pass custom attributes as function', () => {
|
|
2613
2608
|
function FakeComponent(props) {
|
|
2614
2609
|
const { label, description } = props;
|
|
@@ -11,7 +11,7 @@ export const schemaInputTypeTextarea = {
|
|
|
11
11
|
properties: {
|
|
12
12
|
comment: {
|
|
13
13
|
title: 'Your comment',
|
|
14
|
-
presentation: {
|
|
14
|
+
'x-jsf-presentation': {
|
|
15
15
|
inputType: 'textarea',
|
|
16
16
|
},
|
|
17
17
|
maxLength: 250,
|
|
@@ -29,7 +29,7 @@ export const inputTypeCountriesSolo = {
|
|
|
29
29
|
{ title: 'Algeria', const: 'Algeria' },
|
|
30
30
|
],
|
|
31
31
|
type: 'string',
|
|
32
|
-
presentation: {
|
|
32
|
+
'x-jsf-presentation': {
|
|
33
33
|
inputType: 'countries',
|
|
34
34
|
},
|
|
35
35
|
};
|
|
@@ -58,7 +58,7 @@ export const schemaInputTypeCountriesMultiple = {
|
|
|
58
58
|
],
|
|
59
59
|
},
|
|
60
60
|
type: 'array',
|
|
61
|
-
presentation: {
|
|
61
|
+
'x-jsf-presentation': {
|
|
62
62
|
inputType: 'countries',
|
|
63
63
|
},
|
|
64
64
|
},
|
|
@@ -90,7 +90,7 @@ export const schemaInputTypeTel = {
|
|
|
90
90
|
type: 'string',
|
|
91
91
|
pattern: '^(\\+|00)[0-9]{6,}$',
|
|
92
92
|
maxLength: 30,
|
|
93
|
-
presentation: {
|
|
93
|
+
'x-jsf-presentation': {
|
|
94
94
|
inputType: 'tel',
|
|
95
95
|
},
|
|
96
96
|
errorMessage: {
|
|
@@ -106,7 +106,7 @@ const mockTelInput = {
|
|
|
106
106
|
title: 'Phone number',
|
|
107
107
|
description: 'Enter your telephone number',
|
|
108
108
|
maxLength: 30,
|
|
109
|
-
presentation: {
|
|
109
|
+
'x-jsf-presentation': {
|
|
110
110
|
inputType: 'tel',
|
|
111
111
|
},
|
|
112
112
|
pattern: '^(\\+|00)\\d*$',
|
|
@@ -116,7 +116,7 @@ const mockTelInput = {
|
|
|
116
116
|
export const mockMoneyInput = {
|
|
117
117
|
title: 'Weekly salary',
|
|
118
118
|
description: 'This field has a min and max values. Max has a custom error message.',
|
|
119
|
-
presentation: {
|
|
119
|
+
'x-jsf-presentation': {
|
|
120
120
|
inputType: 'money',
|
|
121
121
|
currency: 'EUR',
|
|
122
122
|
},
|
|
@@ -150,7 +150,7 @@ export const schemaCustomComponent = {
|
|
|
150
150
|
salary: {
|
|
151
151
|
title: 'Monthly gross salary',
|
|
152
152
|
description: 'This field gets represented by a custom UI Component.',
|
|
153
|
-
presentation: {
|
|
153
|
+
'x-jsf-presentation': {
|
|
154
154
|
inputType: 'money',
|
|
155
155
|
currency: 'EUR',
|
|
156
156
|
},
|
package/src/tests/helpers.js
CHANGED
|
@@ -17,7 +17,7 @@ export const mockTextInputDeprecated = {
|
|
|
17
17
|
title: 'Username',
|
|
18
18
|
description: 'Your username (max 10 characters)',
|
|
19
19
|
maxLength: 10,
|
|
20
|
-
presentation: {
|
|
20
|
+
'x-jsf-presentation': {
|
|
21
21
|
inputType: 'text',
|
|
22
22
|
maskSecret: 2,
|
|
23
23
|
},
|
|
@@ -1284,7 +1284,7 @@ export const schemaForErrorMessageSpecificity = {
|
|
|
1284
1284
|
title: 'Weekday',
|
|
1285
1285
|
description: "This text field has the traditional error message. 'Required field'",
|
|
1286
1286
|
type: 'string',
|
|
1287
|
-
presentation: { inputType: 'text' },
|
|
1287
|
+
'x-jsf-presentation': { inputType: 'text' },
|
|
1288
1288
|
},
|
|
1289
1289
|
day: {
|
|
1290
1290
|
title: 'Day',
|
|
@@ -1293,21 +1293,21 @@ export const schemaForErrorMessageSpecificity = {
|
|
|
1293
1293
|
'The remaining fields are numbers and were customized to say "This cannot be empty." instead of "Required field".',
|
|
1294
1294
|
|
|
1295
1295
|
maximum: 31,
|
|
1296
|
-
presentation: { inputType: 'number' },
|
|
1296
|
+
'x-jsf-presentation': { inputType: 'number' },
|
|
1297
1297
|
},
|
|
1298
1298
|
month: {
|
|
1299
1299
|
title: 'Month',
|
|
1300
1300
|
type: 'number',
|
|
1301
1301
|
minimum: 1,
|
|
1302
1302
|
maximum: 12,
|
|
1303
|
-
presentation: { inputType: 'number' },
|
|
1303
|
+
'x-jsf-presentation': { inputType: 'number' },
|
|
1304
1304
|
},
|
|
1305
1305
|
year: {
|
|
1306
1306
|
title: 'Year',
|
|
1307
1307
|
description:
|
|
1308
1308
|
"This number field has a custom error message declared in the json schema, which has a higher specificity than the one declared in createHeadlessForm's configuration.",
|
|
1309
1309
|
type: 'number',
|
|
1310
|
-
presentation: { inputType: 'number' },
|
|
1310
|
+
'x-jsf-presentation': { inputType: 'number' },
|
|
1311
1311
|
'x-jsf-errorMessage': {
|
|
1312
1312
|
required: 'The year is mandatory.',
|
|
1313
1313
|
},
|
|
@@ -1973,90 +1973,6 @@ export const schemaWithConditionalToFieldset = {
|
|
|
1973
1973
|
required: ['perks', 'work_hours_per_week'],
|
|
1974
1974
|
};
|
|
1975
1975
|
|
|
1976
|
-
export const schemaWithRootFieldsetsConditionals = {
|
|
1977
|
-
additionalProperties: false,
|
|
1978
|
-
type: 'object',
|
|
1979
|
-
properties: {
|
|
1980
|
-
perks: {
|
|
1981
|
-
additionalProperties: false,
|
|
1982
|
-
properties: {
|
|
1983
|
-
retirement: {
|
|
1984
|
-
oneOf: [
|
|
1985
|
-
{
|
|
1986
|
-
const: 'basic',
|
|
1987
|
-
title: 'Basic',
|
|
1988
|
-
},
|
|
1989
|
-
{
|
|
1990
|
-
const: 'plus',
|
|
1991
|
-
title: 'Plus',
|
|
1992
|
-
},
|
|
1993
|
-
],
|
|
1994
|
-
title: 'Retirement',
|
|
1995
|
-
type: 'string',
|
|
1996
|
-
'x-jsf-presentation': {
|
|
1997
|
-
inputType: 'radio',
|
|
1998
|
-
},
|
|
1999
|
-
},
|
|
2000
|
-
has_pension: {
|
|
2001
|
-
oneOf: [
|
|
2002
|
-
{
|
|
2003
|
-
const: 'yes',
|
|
2004
|
-
title: 'Yes',
|
|
2005
|
-
},
|
|
2006
|
-
{
|
|
2007
|
-
const: 'no',
|
|
2008
|
-
title: 'No',
|
|
2009
|
-
},
|
|
2010
|
-
],
|
|
2011
|
-
title: 'Has pension',
|
|
2012
|
-
type: 'string',
|
|
2013
|
-
'x-jsf-presentation': {
|
|
2014
|
-
inputType: 'radio',
|
|
2015
|
-
},
|
|
2016
|
-
},
|
|
2017
|
-
},
|
|
2018
|
-
required: ['retirement'],
|
|
2019
|
-
title: 'Perks',
|
|
2020
|
-
type: 'object',
|
|
2021
|
-
'x-jsf-presentation': {
|
|
2022
|
-
inputType: 'fieldset',
|
|
2023
|
-
},
|
|
2024
|
-
},
|
|
2025
|
-
},
|
|
2026
|
-
required: ['perks'],
|
|
2027
|
-
allOf: [
|
|
2028
|
-
{
|
|
2029
|
-
if: {
|
|
2030
|
-
properties: {
|
|
2031
|
-
perks: {
|
|
2032
|
-
properties: {
|
|
2033
|
-
retirement: {
|
|
2034
|
-
const: 'basic',
|
|
2035
|
-
},
|
|
2036
|
-
},
|
|
2037
|
-
},
|
|
2038
|
-
},
|
|
2039
|
-
},
|
|
2040
|
-
then: {
|
|
2041
|
-
properties: {
|
|
2042
|
-
perks: {
|
|
2043
|
-
properties: {
|
|
2044
|
-
has_pension: false,
|
|
2045
|
-
},
|
|
2046
|
-
},
|
|
2047
|
-
},
|
|
2048
|
-
},
|
|
2049
|
-
else: {
|
|
2050
|
-
properties: {
|
|
2051
|
-
perks: {
|
|
2052
|
-
required: ['has_pension'],
|
|
2053
|
-
},
|
|
2054
|
-
},
|
|
2055
|
-
},
|
|
2056
|
-
},
|
|
2057
|
-
],
|
|
2058
|
-
};
|
|
2059
|
-
|
|
2060
1976
|
export const schemaWorkSchedule = {
|
|
2061
1977
|
type: 'object',
|
|
2062
1978
|
properties: {
|