@remoteoss/json-schema-form 0.4.1-dev.20230703161935 → 0.4.1-dev.20230703203242
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/dist/index.cjs +27 -29
- package/dist/index.js +27 -29
- package/dist/standalone.js +27 -29
- package/package.json +1 -1
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.4.1-dev.
|
|
5
|
-
Generated: Mon, 03 Jul 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703203242
|
|
5
|
+
Generated: Mon, 03 Jul 2023 20:32:50 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -383,7 +383,15 @@ var validateOnlyStrings = (0, import_yup.string)().trim().nullable().test(
|
|
|
383
383
|
);
|
|
384
384
|
var yupSchemas = {
|
|
385
385
|
text: validateOnlyStrings,
|
|
386
|
-
radioOrSelect: (options) => (0, import_yup.string)().nullable().
|
|
386
|
+
radioOrSelect: (options) => (0, import_yup.string)().nullable().transform((value) => {
|
|
387
|
+
if (value === "") {
|
|
388
|
+
return void 0;
|
|
389
|
+
}
|
|
390
|
+
if (options?.includes(null)) {
|
|
391
|
+
return value;
|
|
392
|
+
}
|
|
393
|
+
return value === null ? void 0 : value;
|
|
394
|
+
}).oneOf(options, ({ value }) => {
|
|
387
395
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
388
396
|
}),
|
|
389
397
|
date: (0, import_yup.string)().nullable().trim().matches(
|
|
@@ -420,38 +428,19 @@ function getRequiredErrorMessage(inputType, { inlineError, configError }) {
|
|
|
420
428
|
return "Required field";
|
|
421
429
|
}
|
|
422
430
|
var getJsonTypeInArray = (jsonType) => Array.isArray(jsonType) ? jsonType.find((val) => val !== "null") : jsonType;
|
|
423
|
-
var
|
|
424
|
-
const
|
|
425
|
-
const optionsBroken = [
|
|
426
|
-
...onlyValues,
|
|
427
|
-
""
|
|
428
|
-
// [1]
|
|
429
|
-
];
|
|
430
|
-
if (field.required) {
|
|
431
|
-
return [
|
|
432
|
-
...optionsBroken,
|
|
433
|
-
null
|
|
434
|
-
// [2]
|
|
435
|
-
];
|
|
436
|
-
}
|
|
431
|
+
var getOptions = (field) => {
|
|
432
|
+
const allValues = field.options?.map((option) => option.value);
|
|
437
433
|
const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null"
|
|
438
434
|
// option but we don't have direct access at this point.
|
|
439
435
|
// Otherwise the JSON Schema validator will fail as explained in PR#18
|
|
440
436
|
field.jsonType.includes("null");
|
|
441
|
-
|
|
442
|
-
return [...optionsBroken, null];
|
|
443
|
-
}
|
|
444
|
-
return [
|
|
445
|
-
...optionsBroken,
|
|
446
|
-
null
|
|
447
|
-
// [3]
|
|
448
|
-
];
|
|
437
|
+
return isOptionalWithNull ? [...allValues, null] : allValues;
|
|
449
438
|
};
|
|
450
439
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
451
440
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
452
441
|
if (field.options?.length > 0) {
|
|
453
|
-
const
|
|
454
|
-
return yupSchemas.radioOrSelect(
|
|
442
|
+
const optionValues = getOptions(field);
|
|
443
|
+
return yupSchemas.radioOrSelect(optionValues);
|
|
455
444
|
}
|
|
456
445
|
return yupSchemas[inputType] || yupSchemasToJsonTypes[jsonType];
|
|
457
446
|
};
|
|
@@ -665,8 +654,17 @@ function checkIfConditionMatches(node, formValues, formFields) {
|
|
|
665
654
|
if (currentProperty.enum) {
|
|
666
655
|
return currentProperty.enum.includes(value);
|
|
667
656
|
}
|
|
668
|
-
const
|
|
669
|
-
return validateFieldSchema(
|
|
657
|
+
const field = getField(name, formFields);
|
|
658
|
+
return validateFieldSchema(
|
|
659
|
+
{
|
|
660
|
+
options: field.options,
|
|
661
|
+
// @TODO/CODE SMELL. We are passing the property (raw field), but buildYupSchema() expected the output field.
|
|
662
|
+
...currentProperty,
|
|
663
|
+
inputType: field.inputType,
|
|
664
|
+
required: true
|
|
665
|
+
},
|
|
666
|
+
value
|
|
667
|
+
);
|
|
670
668
|
});
|
|
671
669
|
}
|
|
672
670
|
function isFieldFilled(fieldValue) {
|
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.4.1-dev.
|
|
5
|
-
Generated: Mon, 03 Jul 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703203242
|
|
5
|
+
Generated: Mon, 03 Jul 2023 20:32:50 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -347,7 +347,15 @@ var validateOnlyStrings = string().trim().nullable().test(
|
|
|
347
347
|
);
|
|
348
348
|
var yupSchemas = {
|
|
349
349
|
text: validateOnlyStrings,
|
|
350
|
-
radioOrSelect: (options) => string().nullable().
|
|
350
|
+
radioOrSelect: (options) => string().nullable().transform((value) => {
|
|
351
|
+
if (value === "") {
|
|
352
|
+
return void 0;
|
|
353
|
+
}
|
|
354
|
+
if (options?.includes(null)) {
|
|
355
|
+
return value;
|
|
356
|
+
}
|
|
357
|
+
return value === null ? void 0 : value;
|
|
358
|
+
}).oneOf(options, ({ value }) => {
|
|
351
359
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
352
360
|
}),
|
|
353
361
|
date: string().nullable().trim().matches(
|
|
@@ -384,38 +392,19 @@ function getRequiredErrorMessage(inputType, { inlineError, configError }) {
|
|
|
384
392
|
return "Required field";
|
|
385
393
|
}
|
|
386
394
|
var getJsonTypeInArray = (jsonType) => Array.isArray(jsonType) ? jsonType.find((val) => val !== "null") : jsonType;
|
|
387
|
-
var
|
|
388
|
-
const
|
|
389
|
-
const optionsBroken = [
|
|
390
|
-
...onlyValues,
|
|
391
|
-
""
|
|
392
|
-
// [1]
|
|
393
|
-
];
|
|
394
|
-
if (field.required) {
|
|
395
|
-
return [
|
|
396
|
-
...optionsBroken,
|
|
397
|
-
null
|
|
398
|
-
// [2]
|
|
399
|
-
];
|
|
400
|
-
}
|
|
395
|
+
var getOptions = (field) => {
|
|
396
|
+
const allValues = field.options?.map((option) => option.value);
|
|
401
397
|
const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null"
|
|
402
398
|
// option but we don't have direct access at this point.
|
|
403
399
|
// Otherwise the JSON Schema validator will fail as explained in PR#18
|
|
404
400
|
field.jsonType.includes("null");
|
|
405
|
-
|
|
406
|
-
return [...optionsBroken, null];
|
|
407
|
-
}
|
|
408
|
-
return [
|
|
409
|
-
...optionsBroken,
|
|
410
|
-
null
|
|
411
|
-
// [3]
|
|
412
|
-
];
|
|
401
|
+
return isOptionalWithNull ? [...allValues, null] : allValues;
|
|
413
402
|
};
|
|
414
403
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
415
404
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
416
405
|
if (field.options?.length > 0) {
|
|
417
|
-
const
|
|
418
|
-
return yupSchemas.radioOrSelect(
|
|
406
|
+
const optionValues = getOptions(field);
|
|
407
|
+
return yupSchemas.radioOrSelect(optionValues);
|
|
419
408
|
}
|
|
420
409
|
return yupSchemas[inputType] || yupSchemasToJsonTypes[jsonType];
|
|
421
410
|
};
|
|
@@ -629,8 +618,17 @@ function checkIfConditionMatches(node, formValues, formFields) {
|
|
|
629
618
|
if (currentProperty.enum) {
|
|
630
619
|
return currentProperty.enum.includes(value);
|
|
631
620
|
}
|
|
632
|
-
const
|
|
633
|
-
return validateFieldSchema(
|
|
621
|
+
const field = getField(name, formFields);
|
|
622
|
+
return validateFieldSchema(
|
|
623
|
+
{
|
|
624
|
+
options: field.options,
|
|
625
|
+
// @TODO/CODE SMELL. We are passing the property (raw field), but buildYupSchema() expected the output field.
|
|
626
|
+
...currentProperty,
|
|
627
|
+
inputType: field.inputType,
|
|
628
|
+
required: true
|
|
629
|
+
},
|
|
630
|
+
value
|
|
631
|
+
);
|
|
634
632
|
});
|
|
635
633
|
}
|
|
636
634
|
function isFieldFilled(fieldValue) {
|
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.4.1-dev.
|
|
5
|
-
Generated: Mon, 03 Jul 2023
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703203242
|
|
5
|
+
Generated: Mon, 03 Jul 2023 20:32:50 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11323,7 +11323,15 @@ var validateOnlyStrings = StringSchema().trim().nullable().test(
|
|
|
11323
11323
|
);
|
|
11324
11324
|
var yupSchemas = {
|
|
11325
11325
|
text: validateOnlyStrings,
|
|
11326
|
-
radioOrSelect: (options) => StringSchema().nullable().
|
|
11326
|
+
radioOrSelect: (options) => StringSchema().nullable().transform((value) => {
|
|
11327
|
+
if (value === "") {
|
|
11328
|
+
return void 0;
|
|
11329
|
+
}
|
|
11330
|
+
if (options?.includes(null)) {
|
|
11331
|
+
return value;
|
|
11332
|
+
}
|
|
11333
|
+
return value === null ? void 0 : value;
|
|
11334
|
+
}).oneOf(options, ({ value }) => {
|
|
11327
11335
|
return `The option ${JSON.stringify(value)} is not valid.`;
|
|
11328
11336
|
}),
|
|
11329
11337
|
date: StringSchema().nullable().trim().matches(
|
|
@@ -11360,38 +11368,19 @@ function getRequiredErrorMessage(inputType, { inlineError, configError }) {
|
|
|
11360
11368
|
return "Required field";
|
|
11361
11369
|
}
|
|
11362
11370
|
var getJsonTypeInArray = (jsonType) => Array.isArray(jsonType) ? jsonType.find((val) => val !== "null") : jsonType;
|
|
11363
|
-
var
|
|
11364
|
-
const
|
|
11365
|
-
const optionsBroken = [
|
|
11366
|
-
...onlyValues,
|
|
11367
|
-
""
|
|
11368
|
-
// [1]
|
|
11369
|
-
];
|
|
11370
|
-
if (field.required) {
|
|
11371
|
-
return [
|
|
11372
|
-
...optionsBroken,
|
|
11373
|
-
null
|
|
11374
|
-
// [2]
|
|
11375
|
-
];
|
|
11376
|
-
}
|
|
11371
|
+
var getOptions = (field) => {
|
|
11372
|
+
const allValues = field.options?.map((option) => option.value);
|
|
11377
11373
|
const isOptionalWithNull = Array.isArray(field.jsonType) && // @TODO should also check the "oneOf" directly looking for "null"
|
|
11378
11374
|
// option but we don't have direct access at this point.
|
|
11379
11375
|
// Otherwise the JSON Schema validator will fail as explained in PR#18
|
|
11380
11376
|
field.jsonType.includes("null");
|
|
11381
|
-
|
|
11382
|
-
return [...optionsBroken, null];
|
|
11383
|
-
}
|
|
11384
|
-
return [
|
|
11385
|
-
...optionsBroken,
|
|
11386
|
-
null
|
|
11387
|
-
// [3]
|
|
11388
|
-
];
|
|
11377
|
+
return isOptionalWithNull ? [...allValues, null] : allValues;
|
|
11389
11378
|
};
|
|
11390
11379
|
var getYupSchema = ({ inputType, ...field }) => {
|
|
11391
11380
|
const jsonType = getJsonTypeInArray(field.jsonType);
|
|
11392
11381
|
if (field.options?.length > 0) {
|
|
11393
|
-
const
|
|
11394
|
-
return yupSchemas.radioOrSelect(
|
|
11382
|
+
const optionValues = getOptions(field);
|
|
11383
|
+
return yupSchemas.radioOrSelect(optionValues);
|
|
11395
11384
|
}
|
|
11396
11385
|
return yupSchemas[inputType] || yupSchemasToJsonTypes[jsonType];
|
|
11397
11386
|
};
|
|
@@ -11605,8 +11594,17 @@ function checkIfConditionMatches(node, formValues, formFields) {
|
|
|
11605
11594
|
if (currentProperty.enum) {
|
|
11606
11595
|
return currentProperty.enum.includes(value);
|
|
11607
11596
|
}
|
|
11608
|
-
const
|
|
11609
|
-
return validateFieldSchema(
|
|
11597
|
+
const field = getField(name, formFields);
|
|
11598
|
+
return validateFieldSchema(
|
|
11599
|
+
{
|
|
11600
|
+
options: field.options,
|
|
11601
|
+
// @TODO/CODE SMELL. We are passing the property (raw field), but buildYupSchema() expected the output field.
|
|
11602
|
+
...currentProperty,
|
|
11603
|
+
inputType: field.inputType,
|
|
11604
|
+
required: true
|
|
11605
|
+
},
|
|
11606
|
+
value
|
|
11607
|
+
);
|
|
11610
11608
|
});
|
|
11611
11609
|
}
|
|
11612
11610
|
function isFieldFilled(fieldValue) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.4.1-dev.
|
|
3
|
+
"version": "0.4.1-dev.20230703203242",
|
|
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",
|