@remoteoss/json-schema-form 0.11.10-beta.0 → 0.11.11-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 +6 -0
- package/dist/index.cjs +7 -2
- package/dist/index.js +7 -2
- package/dist/standalone.js +7 -2
- package/package.json +5 -1
- package/src/tests/checkIfConditionMatches.test.js +1 -1
- package/src/tests/conditions.test.js +49 -1
- package/src/tests/const.test.js +1 -1
- package/src/tests/createHeadlessForm.customValidations.test.js +1 -2
- package/src/tests/createHeadlessForm.test.js +1 -2
- package/src/tests/internals.helpers.test.js +2 -2
- package/src/tests/jsonLogic.test.js +1 -2
- package/src/tests/modify.test.js +1 -1
- package/src/tests/utils.test.jsx +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
#### 0.11.11-beta.0 (2025-02-20)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **conditionals:** Add support to `oneOf` ([#136](https://github.com/remoteoss/json-schema-form/pull/136)) ([966cec59](https://github.com/remoteoss/json-schema-form/commit/966cec595ed2a1ff35f9d15e22acaea16cdd5113))
|
|
6
|
+
|
|
1
7
|
#### 0.11.10-beta.0 (2025-01-22)
|
|
2
8
|
|
|
3
9
|
##### 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.11-beta.0
|
|
5
|
+
Generated: Thu, 20 Feb 2025 18:25:18 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -101,6 +101,11 @@ function checkIfConditionMatchesProperties(node, formValues, formFields, logic)
|
|
|
101
101
|
if (typeof node.if === "boolean") {
|
|
102
102
|
return node.if;
|
|
103
103
|
}
|
|
104
|
+
if (node.if.anyOf) {
|
|
105
|
+
return node.if.anyOf.some(
|
|
106
|
+
(property) => checkIfConditionMatchesProperties({ if: property }, formValues, formFields, logic)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
104
109
|
return Object.keys(node.if.properties ?? {}).every((name) => {
|
|
105
110
|
const currentProperty = node.if.properties[name];
|
|
106
111
|
const value = formValues[name];
|
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.11-beta.0
|
|
5
|
+
Generated: Thu, 20 Feb 2025 18:25:18 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -64,6 +64,11 @@ function checkIfConditionMatchesProperties(node, formValues, formFields, logic)
|
|
|
64
64
|
if (typeof node.if === "boolean") {
|
|
65
65
|
return node.if;
|
|
66
66
|
}
|
|
67
|
+
if (node.if.anyOf) {
|
|
68
|
+
return node.if.anyOf.some(
|
|
69
|
+
(property) => checkIfConditionMatchesProperties({ if: property }, formValues, formFields, logic)
|
|
70
|
+
);
|
|
71
|
+
}
|
|
67
72
|
return Object.keys(node.if.properties ?? {}).every((name) => {
|
|
68
73
|
const currentProperty = node.if.properties[name];
|
|
69
74
|
const value = formValues[name];
|
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.11-beta.0
|
|
5
|
+
Generated: Thu, 20 Feb 2025 18:25:18 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -11581,6 +11581,11 @@ function checkIfConditionMatchesProperties(node, formValues, formFields, logic)
|
|
|
11581
11581
|
if (typeof node.if === "boolean") {
|
|
11582
11582
|
return node.if;
|
|
11583
11583
|
}
|
|
11584
|
+
if (node.if.anyOf) {
|
|
11585
|
+
return node.if.anyOf.some(
|
|
11586
|
+
(property2) => checkIfConditionMatchesProperties({ if: property2 }, formValues, formFields, logic)
|
|
11587
|
+
);
|
|
11588
|
+
}
|
|
11584
11589
|
return Object.keys(node.if.properties ?? {}).every((name) => {
|
|
11585
11590
|
const currentProperty = node.if.properties[name];
|
|
11586
11591
|
const value = formValues[name];
|
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.11-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",
|
|
@@ -32,11 +32,14 @@
|
|
|
32
32
|
"format:prettier": "prettier --write \"src/**/*.{js,ts}\"",
|
|
33
33
|
"prettier:check": "prettier --check \"src/**/*.{js,ts}\"",
|
|
34
34
|
"check:pr-version": "node scripts/pr_dev_version",
|
|
35
|
+
"check:pr-next-version": "node scripts/pr_next_dev_version",
|
|
35
36
|
"release:local": "node scripts/release_local",
|
|
36
37
|
"release:dev:patch": "node scripts/release_dev patch",
|
|
37
38
|
"release:dev:minor": "node scripts/release_dev minor",
|
|
38
39
|
"release:main:patch": "node scripts/release_main patch",
|
|
39
40
|
"release:main:minor": "node scripts/release_main minor",
|
|
41
|
+
"release:v1:dev": "node scripts/release_v1 dev",
|
|
42
|
+
"release:v1:beta": "node scripts/release_v1 beta",
|
|
40
43
|
"version_as_main": "node scripts/version_as_main.js",
|
|
41
44
|
"psrepublishOnly": "if [[ ! $PWD =~ scripts$ ]]; then npm run publish:nopublish; fi",
|
|
42
45
|
"psublish:nopublish": "echo 'Use `npm release:*` script instead && exit 1"
|
|
@@ -57,6 +60,7 @@
|
|
|
57
60
|
"@babel/eslint-parser": "^7.25.9",
|
|
58
61
|
"@babel/preset-env": "^7.21.5",
|
|
59
62
|
"babel-jest": "^29.5.0",
|
|
63
|
+
"babel-plugin-module-resolver": "^5.0.2",
|
|
60
64
|
"child-process-promise": "^2.2.1",
|
|
61
65
|
"esbuild": "^0.17.15",
|
|
62
66
|
"eslint": "^7.32.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkIfConditionMatchesProperties } from '
|
|
1
|
+
import { checkIfConditionMatchesProperties } from '@/internals/checkIfConditionMatches';
|
|
2
2
|
|
|
3
3
|
describe('checkIfConditionMatchesProperties()', () => {
|
|
4
4
|
it('True if is always going to be true', () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHeadlessForm } from '
|
|
1
|
+
import { createHeadlessForm } from '@/createHeadlessForm';
|
|
2
2
|
|
|
3
3
|
describe('Conditional attributes updated', () => {
|
|
4
4
|
it('Should allow check of a nested property in a conditional', () => {
|
|
@@ -548,6 +548,54 @@ describe('Conditional with literal booleans', () => {
|
|
|
548
548
|
});
|
|
549
549
|
});
|
|
550
550
|
|
|
551
|
+
describe('Conditional with anyOf', () => {
|
|
552
|
+
const schema = {
|
|
553
|
+
additionalProperties: false,
|
|
554
|
+
type: 'object',
|
|
555
|
+
properties: {
|
|
556
|
+
field_a: { type: 'string' },
|
|
557
|
+
field_b: { type: 'string' },
|
|
558
|
+
field_c: { type: 'string' },
|
|
559
|
+
},
|
|
560
|
+
allOf: [
|
|
561
|
+
{
|
|
562
|
+
if: {
|
|
563
|
+
anyOf: [
|
|
564
|
+
{ properties: { field_a: { const: '1' } }, required: ['field_a'] },
|
|
565
|
+
{ properties: { field_b: { const: '2' } }, required: ['field_b'] },
|
|
566
|
+
],
|
|
567
|
+
},
|
|
568
|
+
then: {
|
|
569
|
+
required: ['field_c'],
|
|
570
|
+
},
|
|
571
|
+
else: {
|
|
572
|
+
properties: {
|
|
573
|
+
field_c: false,
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
],
|
|
578
|
+
};
|
|
579
|
+
|
|
580
|
+
it('handles true case', () => {
|
|
581
|
+
const { fields, handleValidation } = createHeadlessForm(schema, { strictInputType: false });
|
|
582
|
+
|
|
583
|
+
expect(fields[2].isVisible).toBe(false);
|
|
584
|
+
expect(handleValidation({ field_a: 'x', field_b: '2' }).formErrors).toEqual({
|
|
585
|
+
field_c: 'Required field',
|
|
586
|
+
});
|
|
587
|
+
expect(fields[2].isVisible).toBe(true);
|
|
588
|
+
});
|
|
589
|
+
|
|
590
|
+
it('handles false case', () => {
|
|
591
|
+
const { fields, handleValidation } = createHeadlessForm(schema, { strictInputType: false });
|
|
592
|
+
|
|
593
|
+
expect(fields[2].isVisible).toBe(false);
|
|
594
|
+
expect(handleValidation({ field_a: 'x', field_b: 'x' }).formErrors).toBeUndefined();
|
|
595
|
+
expect(fields[2].isVisible).toBe(false);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
|
|
551
599
|
describe('Conditionals - bugs and code-smells', () => {
|
|
552
600
|
// Why do we have these bugs?
|
|
553
601
|
// To be honest we never realized it much later later.
|
package/src/tests/const.test.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import merge from 'lodash/fp/merge';
|
|
2
2
|
|
|
3
|
-
import { createHeadlessForm } from '../createHeadlessForm';
|
|
4
|
-
|
|
5
3
|
import { JSONSchemaBuilder, mockFieldset, mockRadioInputString } from './helpers';
|
|
6
4
|
import { mockMoneyInput } from './helpers.custom';
|
|
5
|
+
import { createHeadlessForm } from '@/createHeadlessForm';
|
|
7
6
|
|
|
8
7
|
function friendlyError({ formErrors }) {
|
|
9
8
|
// destruct the formErrors directly
|
|
@@ -2,8 +2,6 @@ import isNil from 'lodash/isNil';
|
|
|
2
2
|
import omitBy from 'lodash/omitBy';
|
|
3
3
|
import { object } from 'yup';
|
|
4
4
|
|
|
5
|
-
import { createHeadlessForm } from '../createHeadlessForm';
|
|
6
|
-
|
|
7
5
|
import {
|
|
8
6
|
JSONSchemaBuilder,
|
|
9
7
|
schemaInputTypeText,
|
|
@@ -67,6 +65,7 @@ import {
|
|
|
67
65
|
schemaInputTypeFile,
|
|
68
66
|
} from './helpers';
|
|
69
67
|
import { mockConsole, restoreConsoleAndEnsureItWasNotCalled } from './testUtils';
|
|
68
|
+
import { createHeadlessForm } from '@/createHeadlessForm';
|
|
70
69
|
|
|
71
70
|
function buildJSONSchemaInput({ presentationFields, inputFields = {}, required }) {
|
|
72
71
|
return {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as Yup from 'yup';
|
|
2
2
|
|
|
3
|
-
import { yupToFormErrors } from '
|
|
4
|
-
import { getFieldDescription, pickXKey } from '
|
|
3
|
+
import { yupToFormErrors } from '@/helpers';
|
|
4
|
+
import { getFieldDescription, pickXKey } from '@/internals/helpers';
|
|
5
5
|
|
|
6
6
|
describe('getFieldDescription()', () => {
|
|
7
7
|
it('returns no description', () => {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { createHeadlessForm } from '../createHeadlessForm';
|
|
2
|
-
|
|
3
1
|
import {
|
|
4
2
|
createSchemaWithRulesOnFieldA,
|
|
5
3
|
createSchemaWithThreePropertiesWithRuleOnFieldA,
|
|
@@ -38,6 +36,7 @@ import {
|
|
|
38
36
|
badSchemaThatWillNotSetAForcedValue,
|
|
39
37
|
} from './jsonLogic.fixtures';
|
|
40
38
|
import { mockConsole, restoreConsoleAndEnsureItWasNotCalled } from './testUtils';
|
|
39
|
+
import { createHeadlessForm } from '@/createHeadlessForm';
|
|
41
40
|
|
|
42
41
|
beforeEach(mockConsole);
|
|
43
42
|
afterEach(restoreConsoleAndEnsureItWasNotCalled);
|
package/src/tests/modify.test.js
CHANGED
package/src/tests/utils.test.jsx
CHANGED