@remoteoss/json-schema-form 0.11.5-dev.20240821144620 → 0.11.6-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 +14 -0
- package/dist/index.cjs +3 -3
- package/dist/index.js +3 -3
- package/dist/standalone.js +3 -3
- package/package.json +1 -1
- package/src/tests/createHeadlessForm.test.js +20 -0
- package/src/tests/helpers.js +19 -0
- package/src/tests/modify.test.js +27 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
#### 0.11.6-beta.0 (2024-10-15)
|
|
2
|
+
|
|
3
|
+
##### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **modify:** Support json schemas without allOf ([#93](https://github.com/remoteoss/json-schema-form/pull/93)) ([03795d0a](https://github.com/remoteoss/json-schema-form/commit/03795d0ac1a7ae0d523cd8418b83342676f221cf))
|
|
6
|
+
|
|
7
|
+
#### 0.11.5-beta.0 (2024-08-22)
|
|
8
|
+
|
|
9
|
+
##### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **validation:** Validate null field type correctly ([#91](https://github.com/remoteoss/json-schema-form/pull/91)) ([1cb8b61f](https://github.com/remoteoss/json-schema-form/commit/1cb8b61fec06d851832f9e76b3156d6f574b5d41))
|
|
12
|
+
* **files:** accept object value with `name` property ([#91](https://github.com/remoteoss/json-schema-form/pull/91)) ([1cb8b61f](https://github.com/remoteoss/json-schema-form/commit/1cb8b61fec06d851832f9e76b3156d6f574b5d41))
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
#### 0.11.4-beta.0 (2024-08-20)
|
|
2
16
|
|
|
3
17
|
##### Bug Fixes
|
package/dist/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.6-beta.0
|
|
5
|
+
Generated: Tue, 15 Oct 2024 12:38:54 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -2044,7 +2044,7 @@ function pickFields(originalSchema, fieldsToPick) {
|
|
|
2044
2044
|
}
|
|
2045
2045
|
});
|
|
2046
2046
|
let missingFields = {};
|
|
2047
|
-
newSchema.allOf
|
|
2047
|
+
newSchema.allOf?.forEach((condition) => {
|
|
2048
2048
|
const { if: ifCondition, then: thenCondition, else: elseCondition } = condition;
|
|
2049
2049
|
const index = originalSchema.allOf.indexOf(condition);
|
|
2050
2050
|
missingFields = {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.6-beta.0
|
|
5
|
+
Generated: Tue, 15 Oct 2024 12:38:54 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -2007,7 +2007,7 @@ function pickFields(originalSchema, fieldsToPick) {
|
|
|
2007
2007
|
}
|
|
2008
2008
|
});
|
|
2009
2009
|
let missingFields = {};
|
|
2010
|
-
newSchema.allOf
|
|
2010
|
+
newSchema.allOf?.forEach((condition) => {
|
|
2011
2011
|
const { if: ifCondition, then: thenCondition, else: elseCondition } = condition;
|
|
2012
2012
|
const index = originalSchema.allOf.indexOf(condition);
|
|
2013
2013
|
missingFields = {
|
package/dist/standalone.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
/*!
|
|
3
3
|
Copyright (c) 2024 Remote Technology, Inc.
|
|
4
|
-
NPM Package: @remoteoss/json-schema-form@0.11.
|
|
5
|
-
Generated:
|
|
4
|
+
NPM Package: @remoteoss/json-schema-form@0.11.6-beta.0
|
|
5
|
+
Generated: Tue, 15 Oct 2024 12:38:54 GMT
|
|
6
6
|
|
|
7
7
|
MIT License
|
|
8
8
|
|
|
@@ -13523,7 +13523,7 @@ function pickFields(originalSchema, fieldsToPick) {
|
|
|
13523
13523
|
}
|
|
13524
13524
|
});
|
|
13525
13525
|
let missingFields = {};
|
|
13526
|
-
newSchema.allOf
|
|
13526
|
+
newSchema.allOf?.forEach((condition) => {
|
|
13527
13527
|
const { if: ifCondition, then: thenCondition, else: elseCondition } = condition;
|
|
13528
13528
|
const index = originalSchema.allOf.indexOf(condition);
|
|
13529
13529
|
missingFields = {
|
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.6-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",
|
|
@@ -2874,6 +2874,26 @@ describe('createHeadlessForm', () => {
|
|
|
2874
2874
|
).resolves.toEqual({ fileInput: [{ name: 'foo.pdf' }] });
|
|
2875
2875
|
});
|
|
2876
2876
|
|
|
2877
|
+
it('should validate format', async () =>
|
|
2878
|
+
expect(
|
|
2879
|
+
object()
|
|
2880
|
+
.shape({
|
|
2881
|
+
fileInput: fields[0].schema,
|
|
2882
|
+
})
|
|
2883
|
+
.validate({ fileInput: [{ name: 'foo.txt' }] })
|
|
2884
|
+
).rejects.toMatchObject({
|
|
2885
|
+
errors: ['Unsupported file format. The acceptable formats are .png,.jpg,.jpeg,.pdf.'],
|
|
2886
|
+
}));
|
|
2887
|
+
|
|
2888
|
+
it('should validate max size', async () =>
|
|
2889
|
+
expect(
|
|
2890
|
+
object()
|
|
2891
|
+
.shape({
|
|
2892
|
+
fileInput: fields[0].schema,
|
|
2893
|
+
})
|
|
2894
|
+
.validate({ fileInput: [{ name: 'foo.txt', size: 1024 * 1024 * 1024 }] })
|
|
2895
|
+
).rejects.toMatchObject({ errors: ['File size too large. The limit is 20 MB.'] }));
|
|
2896
|
+
|
|
2877
2897
|
it('throw an error if invalid file object', async () =>
|
|
2878
2898
|
expect(
|
|
2879
2899
|
object()
|
package/src/tests/helpers.js
CHANGED
|
@@ -782,6 +782,25 @@ export const schemaInputWithStatement = {
|
|
|
782
782
|
},
|
|
783
783
|
};
|
|
784
784
|
|
|
785
|
+
export const schemaHiddenInputWithStatement = {
|
|
786
|
+
properties: {
|
|
787
|
+
a_field_statement: {
|
|
788
|
+
type: 'null',
|
|
789
|
+
title: 'Company statement',
|
|
790
|
+
'x-jsf-presentation': {
|
|
791
|
+
inputType: 'hidden',
|
|
792
|
+
statement: {
|
|
793
|
+
title: 'Important statement',
|
|
794
|
+
description:
|
|
795
|
+
"This statement message will be shown at all times, irrespective of this field's visibility.",
|
|
796
|
+
inputType: 'statement',
|
|
797
|
+
severity: 'warning',
|
|
798
|
+
},
|
|
799
|
+
},
|
|
800
|
+
},
|
|
801
|
+
},
|
|
802
|
+
};
|
|
803
|
+
|
|
785
804
|
export const schemaInputWithExtra = {
|
|
786
805
|
properties: {
|
|
787
806
|
bonus: {
|
package/src/tests/modify.test.js
CHANGED
|
@@ -608,7 +608,7 @@ const schemaTickets = {
|
|
|
608
608
|
],
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
-
describe('modify() -
|
|
611
|
+
describe('modify() - reorder fields', () => {
|
|
612
612
|
it('reorder fields - basic usage', () => {
|
|
613
613
|
const baseExample = {
|
|
614
614
|
properties: {
|
|
@@ -821,6 +821,32 @@ describe('modify() - pick fields', () => {
|
|
|
821
821
|
expect(warnings).toHaveLength(0);
|
|
822
822
|
});
|
|
823
823
|
|
|
824
|
+
it('basic usage without conditionals', () => {
|
|
825
|
+
const schemaMinimal = {
|
|
826
|
+
properties: {
|
|
827
|
+
age: {
|
|
828
|
+
title: 'Age',
|
|
829
|
+
type: 'integer',
|
|
830
|
+
},
|
|
831
|
+
quantity: {
|
|
832
|
+
title: 'Quantity',
|
|
833
|
+
type: 'integer',
|
|
834
|
+
},
|
|
835
|
+
},
|
|
836
|
+
'x-jsf-order': ['age', 'quantity'],
|
|
837
|
+
};
|
|
838
|
+
const { schema, warnings } = modify(schemaMinimal, {
|
|
839
|
+
pick: ['quantity'],
|
|
840
|
+
});
|
|
841
|
+
|
|
842
|
+
expect(schema.properties.quantity).toBeDefined();
|
|
843
|
+
expect(schema.properties.age).toBeUndefined();
|
|
844
|
+
// `allOf` conditionals were not defined, and continue to be so.
|
|
845
|
+
// This test guards against a regression where lack of `allOf` caused a TypeError.
|
|
846
|
+
expect(schema.allOf).toBeUndefined();
|
|
847
|
+
expect(warnings).toHaveLength(0);
|
|
848
|
+
});
|
|
849
|
+
|
|
824
850
|
it('related conditionals are kept - (else)', () => {
|
|
825
851
|
const { schema, warnings } = modify(schemaTickets, {
|
|
826
852
|
pick: ['has_premium'],
|