@remoteoss/json-schema-form 0.1.1-dev.20230614173637 → 0.1.1-dev.20230615153439
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 +4 -5
- package/dist/index.js +4 -5
- package/dist/standalone.js +359 -788
- package/json-schema-form.d.ts +1 -0
- package/package.json +3 -2
- package/src/tests/createHeadlessForm.test.js +18 -20
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function pickXKey(node: Object, key: 'presentation' | 'error-message'): Object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@remoteoss/json-schema-form",
|
|
3
|
-
"version": "0.1.1-dev.
|
|
3
|
+
"version": "0.1.1-dev.20230615153439",
|
|
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",
|
|
@@ -11,10 +11,12 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "dist/index.cjs",
|
|
13
13
|
"module": "dist/index.js",
|
|
14
|
+
"typings": "./json-schema-form.d.ts",
|
|
14
15
|
"files": [
|
|
15
16
|
"dist",
|
|
16
17
|
"src/tests",
|
|
17
18
|
"json-schema-form.schema.json",
|
|
19
|
+
"json-schema-form.d.ts",
|
|
18
20
|
"README.md",
|
|
19
21
|
"CHANGELOG.md",
|
|
20
22
|
"LICENSE.md"
|
|
@@ -22,7 +24,6 @@
|
|
|
22
24
|
"scripts": {
|
|
23
25
|
"build": "node scripts/build.js",
|
|
24
26
|
"test": "jest",
|
|
25
|
-
"test:watch": "jest --watchAll",
|
|
26
27
|
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
27
28
|
"format": "npm run format:prettier && npm run format:eslint",
|
|
28
29
|
"prepare": "husky install",
|
|
@@ -419,7 +419,7 @@ describe('createHeadlessForm', () => {
|
|
|
419
419
|
|
|
420
420
|
describe('field support', () => {
|
|
421
421
|
it('support "text" field type', () => {
|
|
422
|
-
const { fields
|
|
422
|
+
const { fields } = createHeadlessForm(schemaInputTypeText);
|
|
423
423
|
|
|
424
424
|
expect(fields[0]).toMatchObject({
|
|
425
425
|
description: 'The number of your national identification (max 10 digits)',
|
|
@@ -435,14 +435,10 @@ describe('createHeadlessForm', () => {
|
|
|
435
435
|
});
|
|
436
436
|
|
|
437
437
|
const fieldValidator = fields[0].schema;
|
|
438
|
-
expect(fieldValidator.isValidSync('CI007'
|
|
439
|
-
expect(fieldValidator.isValidSync(true
|
|
440
|
-
expect(fieldValidator.isValidSync(1
|
|
441
|
-
expect(fieldValidator.isValidSync(0
|
|
442
|
-
|
|
443
|
-
expect(handleValidation({ id_number: 1 }).formErrors).toEqual({
|
|
444
|
-
id_number: 'id_number must be a `string` type, but the final value was: `1`.',
|
|
445
|
-
});
|
|
438
|
+
expect(fieldValidator.isValidSync('CI007')).toBe(true);
|
|
439
|
+
expect(fieldValidator.isValidSync(true)).toBe(true); // @BUG RMT-446 - cannot be a bool
|
|
440
|
+
expect(fieldValidator.isValidSync(1)).toBe(true); // @BUG RMT-446 - cannot be a number
|
|
441
|
+
expect(fieldValidator.isValidSync(0)).toBe(true); // @BUG RMT-446 - cannot be a number
|
|
446
442
|
|
|
447
443
|
expect(() => fieldValidator.validateSync('')).toThrowError('Required field');
|
|
448
444
|
});
|
|
@@ -1311,7 +1307,9 @@ describe('createHeadlessForm', () => {
|
|
|
1311
1307
|
|
|
1312
1308
|
// The "child.has_child" is required
|
|
1313
1309
|
expect(validateForm({})).toEqual({
|
|
1314
|
-
child:
|
|
1310
|
+
child: {
|
|
1311
|
+
has_child: 'Required field',
|
|
1312
|
+
},
|
|
1315
1313
|
});
|
|
1316
1314
|
|
|
1317
1315
|
// The "child.no" is valid
|
|
@@ -2315,7 +2313,7 @@ describe('createHeadlessForm', () => {
|
|
|
2315
2313
|
validateForm({
|
|
2316
2314
|
validate_tabs: 'no',
|
|
2317
2315
|
a_fieldset: {
|
|
2318
|
-
id_number:
|
|
2316
|
+
id_number: 123,
|
|
2319
2317
|
},
|
|
2320
2318
|
mandatory_group_array: 'no',
|
|
2321
2319
|
})
|
|
@@ -2330,7 +2328,7 @@ describe('createHeadlessForm', () => {
|
|
|
2330
2328
|
validateForm({
|
|
2331
2329
|
validate_tabs: 'yes',
|
|
2332
2330
|
a_fieldset: {
|
|
2333
|
-
id_number:
|
|
2331
|
+
id_number: 123,
|
|
2334
2332
|
},
|
|
2335
2333
|
mandatory_group_array: 'no',
|
|
2336
2334
|
})
|
|
@@ -2346,7 +2344,7 @@ describe('createHeadlessForm', () => {
|
|
|
2346
2344
|
validateForm({
|
|
2347
2345
|
validate_tabs: 'yes',
|
|
2348
2346
|
a_fieldset: {
|
|
2349
|
-
id_number:
|
|
2347
|
+
id_number: 123,
|
|
2350
2348
|
},
|
|
2351
2349
|
mandatory_group_array: 'yes',
|
|
2352
2350
|
a_group_array: [{ full_name: 'adfs' }],
|
|
@@ -2357,7 +2355,7 @@ describe('createHeadlessForm', () => {
|
|
|
2357
2355
|
validateForm({
|
|
2358
2356
|
validate_tabs: 'yes',
|
|
2359
2357
|
a_fieldset: {
|
|
2360
|
-
id_number:
|
|
2358
|
+
id_number: 123,
|
|
2361
2359
|
tabs: 2,
|
|
2362
2360
|
},
|
|
2363
2361
|
mandatory_group_array: 'no',
|
|
@@ -2448,7 +2446,7 @@ describe('createHeadlessForm', () => {
|
|
|
2448
2446
|
validateForm({
|
|
2449
2447
|
validate_fieldset: ['id_number'],
|
|
2450
2448
|
a_fieldset: {
|
|
2451
|
-
id_number:
|
|
2449
|
+
id_number: 123,
|
|
2452
2450
|
},
|
|
2453
2451
|
})
|
|
2454
2452
|
).toBeUndefined();
|
|
@@ -2457,7 +2455,7 @@ describe('createHeadlessForm', () => {
|
|
|
2457
2455
|
validateForm({
|
|
2458
2456
|
validate_fieldset: ['id_number', 'all'],
|
|
2459
2457
|
a_fieldset: {
|
|
2460
|
-
id_number:
|
|
2458
|
+
id_number: 123,
|
|
2461
2459
|
},
|
|
2462
2460
|
})
|
|
2463
2461
|
).toEqual({
|
|
@@ -2470,7 +2468,7 @@ describe('createHeadlessForm', () => {
|
|
|
2470
2468
|
validateForm({
|
|
2471
2469
|
validate_fieldset: ['id_number', 'all'],
|
|
2472
2470
|
a_fieldset: {
|
|
2473
|
-
id_number:
|
|
2471
|
+
id_number: 123,
|
|
2474
2472
|
tabs: 2,
|
|
2475
2473
|
},
|
|
2476
2474
|
})
|
|
@@ -2485,7 +2483,7 @@ describe('createHeadlessForm', () => {
|
|
|
2485
2483
|
validateForm({
|
|
2486
2484
|
validate_fieldset: ['id_number'],
|
|
2487
2485
|
a_fieldset: {
|
|
2488
|
-
id_number:
|
|
2486
|
+
id_number: 123,
|
|
2489
2487
|
},
|
|
2490
2488
|
})
|
|
2491
2489
|
).toBeUndefined();
|
|
@@ -2494,7 +2492,7 @@ describe('createHeadlessForm', () => {
|
|
|
2494
2492
|
validateForm({
|
|
2495
2493
|
validate_fieldset: ['id_number', 'all'],
|
|
2496
2494
|
a_fieldset: {
|
|
2497
|
-
id_number:
|
|
2495
|
+
id_number: 123,
|
|
2498
2496
|
},
|
|
2499
2497
|
})
|
|
2500
2498
|
).toEqual({
|
|
@@ -2507,7 +2505,7 @@ describe('createHeadlessForm', () => {
|
|
|
2507
2505
|
validateForm({
|
|
2508
2506
|
validate_fieldset: ['id_number', 'all'],
|
|
2509
2507
|
a_fieldset: {
|
|
2510
|
-
id_number:
|
|
2508
|
+
id_number: 123,
|
|
2511
2509
|
tabs: 2,
|
|
2512
2510
|
},
|
|
2513
2511
|
})
|