@remoteoss/json-schema-form 0.7.5-beta.0 → 0.7.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 CHANGED
@@ -1,3 +1,11 @@
1
+ #### 0.7.6-beta.0 (2024-01-23)
2
+
3
+ ##### Chores
4
+
5
+ BREAKING CHANGES:
6
+
7
+ - **select:** Remove creatable logic ([#62](https://github.com/remoteoss/json-schema-form/pull/62)) ([0a6273c6](https://github.com/remoteoss/json-schema-form/commit/0a6273c63049a2f03bcf0b212dec6455ab48b5e5)) Added in 0.7.1
8
+
1
9
  #### 0.7.5-beta.0 (2023-11-15)
2
10
 
3
11
  ##### Chores
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- Copyright (c) 2023 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.7.5-beta.0
5
- Generated: Wed, 15 Nov 2023 07:53:09 GMT
3
+ Copyright (c) 2024 Remote Technology, Inc.
4
+ NPM Package: @remoteoss/json-schema-form@0.7.6-beta.0
5
+ Generated: Tue, 23 Jan 2024 17:00:20 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -461,10 +461,7 @@ var validateMaxDate = (value, minDate) => {
461
461
  };
462
462
  var yupSchemas = {
463
463
  text: validateOnlyStrings,
464
- radioOrSelect: (options, isString) => {
465
- if (isString) {
466
- return (0, import_yup.string)().nullable();
467
- }
464
+ radioOrSelect: (options) => {
468
465
  return (0, import_yup.string)().nullable().transform((value) => {
469
466
  if (value === "") {
470
467
  return void 0;
@@ -568,9 +565,8 @@ var getOptions = (field) => {
568
565
  var getYupSchema = ({ inputType, ...field }) => {
569
566
  const jsonType = getJsonTypeInArray(field.jsonType);
570
567
  if (field.options?.length > 0) {
571
- const isString = field.options?.findIndex((option) => option.type === "string") > -1;
572
568
  const optionValues = getOptions(field);
573
- return yupSchemas.radioOrSelect(optionValues, isString);
569
+ return yupSchemas.radioOrSelect(optionValues);
574
570
  }
575
571
  if (field.format === "date") {
576
572
  return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- Copyright (c) 2023 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.7.5-beta.0
5
- Generated: Wed, 15 Nov 2023 07:53:09 GMT
3
+ Copyright (c) 2024 Remote Technology, Inc.
4
+ NPM Package: @remoteoss/json-schema-form@0.7.6-beta.0
5
+ Generated: Tue, 23 Jan 2024 17:00:20 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -425,10 +425,7 @@ var validateMaxDate = (value, minDate) => {
425
425
  };
426
426
  var yupSchemas = {
427
427
  text: validateOnlyStrings,
428
- radioOrSelect: (options, isString) => {
429
- if (isString) {
430
- return string().nullable();
431
- }
428
+ radioOrSelect: (options) => {
432
429
  return string().nullable().transform((value) => {
433
430
  if (value === "") {
434
431
  return void 0;
@@ -532,9 +529,8 @@ var getOptions = (field) => {
532
529
  var getYupSchema = ({ inputType, ...field }) => {
533
530
  const jsonType = getJsonTypeInArray(field.jsonType);
534
531
  if (field.options?.length > 0) {
535
- const isString = field.options?.findIndex((option) => option.type === "string") > -1;
536
532
  const optionValues = getOptions(field);
537
- return yupSchemas.radioOrSelect(optionValues, isString);
533
+ return yupSchemas.radioOrSelect(optionValues);
538
534
  }
539
535
  if (field.format === "date") {
540
536
  return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
@@ -1,8 +1,8 @@
1
1
 
2
2
  /*!
3
- Copyright (c) 2023 Remote Technology, Inc.
4
- NPM Package: @remoteoss/json-schema-form@0.7.5-beta.0
5
- Generated: Wed, 15 Nov 2023 07:53:09 GMT
3
+ Copyright (c) 2024 Remote Technology, Inc.
4
+ NPM Package: @remoteoss/json-schema-form@0.7.6-beta.0
5
+ Generated: Tue, 23 Jan 2024 17:00:20 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -11779,10 +11779,7 @@ var validateMaxDate = (value, minDate) => {
11779
11779
  };
11780
11780
  var yupSchemas = {
11781
11781
  text: validateOnlyStrings,
11782
- radioOrSelect: (options, isString2) => {
11783
- if (isString2) {
11784
- return StringSchema().nullable();
11785
- }
11782
+ radioOrSelect: (options) => {
11786
11783
  return StringSchema().nullable().transform((value) => {
11787
11784
  if (value === "") {
11788
11785
  return void 0;
@@ -11886,9 +11883,8 @@ var getOptions = (field) => {
11886
11883
  var getYupSchema = ({ inputType, ...field }) => {
11887
11884
  const jsonType = getJsonTypeInArray(field.jsonType);
11888
11885
  if (field.options?.length > 0) {
11889
- const isString2 = field.options?.findIndex((option) => option.type === "string") > -1;
11890
11886
  const optionValues = getOptions(field);
11891
- return yupSchemas.radioOrSelect(optionValues, isString2);
11887
+ return yupSchemas.radioOrSelect(optionValues);
11892
11888
  }
11893
11889
  if (field.format === "date") {
11894
11890
  return yupSchemas.date({ minDate: field.minDate, maxDate: field.maxDate });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remoteoss/json-schema-form",
3
- "version": "0.7.5-beta.0",
3
+ "version": "0.7.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",
@@ -15,7 +15,6 @@ import {
15
15
  schemaInputTypeRadioOptionsWithDetails,
16
16
  schemaInputTypeSelectSoloDeprecated,
17
17
  schemaInputTypeSelectSolo,
18
- schemaInputTypeSelectString,
19
18
  schemaInputTypeSelectMultipleDeprecated,
20
19
  schemaInputTypeSelectMultiple,
21
20
  schemaInputTypeSelectMultipleOptional,
@@ -432,7 +431,7 @@ describe('createHeadlessForm', () => {
432
431
  });
433
432
 
434
433
  describe('field support', () => {
435
- function assertOptionsAllowed({ handleValidation, fieldName, validOptions, isString = false }) {
434
+ function assertOptionsAllowed({ handleValidation, fieldName, validOptions }) {
436
435
  const validateForm = (vals) => friendlyError(handleValidation(vals));
437
436
 
438
437
  // All allowed options are valid
@@ -440,34 +439,27 @@ describe('createHeadlessForm', () => {
440
439
  expect(validateForm({ [fieldName]: value })).toBeUndefined();
441
440
  });
442
441
 
443
- if (!isString) {
444
- // Any other arbitrary value is not valid.
445
- expect(validateForm({ [fieldName]: 'blah-blah' })).toEqual({
446
- [fieldName]: 'The option "blah-blah" is not valid.',
447
- });
448
-
449
- // Given undefined, it says it's a required field.
450
- expect(validateForm({})).toEqual({
451
- [fieldName]: 'Required field',
452
- });
442
+ // Any other arbitrary value is not valid.
443
+ expect(validateForm({ [fieldName]: 'blah-blah' })).toEqual({
444
+ [fieldName]: 'The option "blah-blah" is not valid.',
445
+ });
453
446
 
454
- // As required field, empty string ("") is also considered empty. @BUG RMT-518
455
- // Expectation: The error to be "The option '' is not valid."
456
- expect(validateForm({ [fieldName]: '' })).toEqual({
457
- [fieldName]: 'Required field',
458
- });
447
+ // Given undefined, it says it's a required field.
448
+ expect(validateForm({})).toEqual({
449
+ [fieldName]: 'Required field',
450
+ });
459
451
 
460
- // As required field, null is also considered empty @BUG RMT-518
461
- // Expectation: The error to be "The option null is not valid."
462
- expect(validateForm({ [fieldName]: null })).toEqual({
463
- [fieldName]: 'Required field',
464
- });
465
- }
452
+ // As required field, empty string ("") is also considered empty. @BUG RMT-518
453
+ // Expectation: The error to be "The option '' is not valid."
454
+ expect(validateForm({ [fieldName]: '' })).toEqual({
455
+ [fieldName]: 'Required field',
456
+ });
466
457
 
467
- if (isString) {
468
- // Any other arbitrary value is valid.
469
- expect(validateForm({ [fieldName]: 'blah-blah' })).toBeUndefined();
470
- }
458
+ // As required field, null is also considered empty @BUG RMT-518
459
+ // Expectation: The error to be "The option null is not valid."
460
+ expect(validateForm({ [fieldName]: null })).toEqual({
461
+ [fieldName]: 'Required field',
462
+ });
471
463
  }
472
464
 
473
465
  it('support "text" field type', () => {
@@ -639,41 +631,6 @@ describe('createHeadlessForm', () => {
639
631
  });
640
632
  });
641
633
 
642
- it('supports "select" field type with string option', () => {
643
- const { fields, handleValidation } = createHeadlessForm(schemaInputTypeSelectString);
644
- const fieldSelect = fields[0];
645
- expect(fieldSelect).toMatchObject({
646
- name: 'browsers',
647
- label: 'Browsers (solo)',
648
- description: 'This solo select also includes a disabled option.',
649
- options: [
650
- {
651
- value: 'chr',
652
- label: 'Chrome',
653
- },
654
- {
655
- value: 'ff',
656
- label: 'Firefox',
657
- },
658
- {
659
- value: 'ie',
660
- label: 'Internet Explorer',
661
- disabled: true,
662
- },
663
- { value: undefined, type: 'string', label: '{Create another}' },
664
- ],
665
- });
666
-
667
- expect(fieldSelect).not.toHaveProperty('multiple');
668
-
669
- assertOptionsAllowed({
670
- handleValidation,
671
- fieldName: 'browsers',
672
- validOptions: ['chr', 'ff', 'ie'],
673
- isString: true,
674
- });
675
- });
676
-
677
634
  it('supports "select" field type with multiple options @deprecated', () => {
678
635
  const result = createHeadlessForm(schemaInputTypeSelectMultipleDeprecated);
679
636
  expect(result).toMatchObject({
@@ -238,11 +238,6 @@ export const mockSelectInputSolo = {
238
238
  },
239
239
  };
240
240
 
241
- export const mockSelectInputSoloCreatable = {
242
- ...mockSelectInputSolo,
243
- oneOf: [...mockSelectInputSolo.oneOf, { type: 'string', title: '{Create another}' }],
244
- };
245
-
246
241
  export const mockSelectInputMultiple = {
247
242
  title: 'Browsers (multiple)',
248
243
  description: 'This multi-select also includes a disabled option.',
@@ -942,10 +937,6 @@ export const schemaInputTypeSelectSolo = JSONSchemaBuilder()
942
937
  .setRequiredFields(['browsers'])
943
938
  .build();
944
939
 
945
- export const schemaInputTypeSelectString = JSONSchemaBuilder().addInput({
946
- browsers: mockSelectInputSoloCreatable,
947
- });
948
-
949
940
  /** @deprecated */
950
941
  export const schemaInputTypeSelectMultipleDeprecated = JSONSchemaBuilder()
951
942
  .addInput({