@remoteoss/json-schema-form 0.4.1-dev.20230703082439 → 0.4.1-dev.20230703195833

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 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.20230703082439
5
- Generated: Mon, 03 Jul 2023 08:24:57 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703195833
5
+ Generated: Mon, 03 Jul 2023 19:58:43 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -441,7 +441,11 @@ var getOptionsAllowed = (field) => {
441
441
  if (isOptionalWithNull) {
442
442
  return [...optionsBroken, null];
443
443
  }
444
- return optionsBroken;
444
+ return [
445
+ ...optionsBroken,
446
+ null
447
+ // [3]
448
+ ];
445
449
  };
446
450
  var getYupSchema = ({ inputType, ...field }) => {
447
451
  const jsonType = getJsonTypeInArray(field.jsonType);
@@ -661,8 +665,17 @@ function checkIfConditionMatches(node, formValues, formFields) {
661
665
  if (currentProperty.enum) {
662
666
  return currentProperty.enum.includes(value);
663
667
  }
664
- const { inputType } = getField(name, formFields);
665
- return validateFieldSchema({ ...currentProperty, inputType, required: true }, value);
668
+ const field = getField(name, formFields);
669
+ return validateFieldSchema(
670
+ {
671
+ options: field.options,
672
+ // @TODO/CODE SMELL. We are passing the property (raw field), but buildYupSchema() expected the output field.
673
+ ...currentProperty,
674
+ inputType: field.inputType,
675
+ required: true
676
+ },
677
+ value
678
+ );
666
679
  });
667
680
  }
668
681
  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.20230703082439
5
- Generated: Mon, 03 Jul 2023 08:24:57 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703195833
5
+ Generated: Mon, 03 Jul 2023 19:58:43 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -405,7 +405,11 @@ var getOptionsAllowed = (field) => {
405
405
  if (isOptionalWithNull) {
406
406
  return [...optionsBroken, null];
407
407
  }
408
- return optionsBroken;
408
+ return [
409
+ ...optionsBroken,
410
+ null
411
+ // [3]
412
+ ];
409
413
  };
410
414
  var getYupSchema = ({ inputType, ...field }) => {
411
415
  const jsonType = getJsonTypeInArray(field.jsonType);
@@ -625,8 +629,17 @@ function checkIfConditionMatches(node, formValues, formFields) {
625
629
  if (currentProperty.enum) {
626
630
  return currentProperty.enum.includes(value);
627
631
  }
628
- const { inputType } = getField(name, formFields);
629
- return validateFieldSchema({ ...currentProperty, inputType, required: true }, value);
632
+ const field = getField(name, formFields);
633
+ return validateFieldSchema(
634
+ {
635
+ options: field.options,
636
+ // @TODO/CODE SMELL. We are passing the property (raw field), but buildYupSchema() expected the output field.
637
+ ...currentProperty,
638
+ inputType: field.inputType,
639
+ required: true
640
+ },
641
+ value
642
+ );
630
643
  });
631
644
  }
632
645
  function isFieldFilled(fieldValue) {
@@ -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.20230703082439
5
- Generated: Mon, 03 Jul 2023 08:24:57 GMT
4
+ NPM Package: @remoteoss/json-schema-form@0.4.1-dev.20230703195833
5
+ Generated: Mon, 03 Jul 2023 19:58:43 GMT
6
6
 
7
7
  MIT License
8
8
 
@@ -11381,7 +11381,11 @@ var getOptionsAllowed = (field) => {
11381
11381
  if (isOptionalWithNull) {
11382
11382
  return [...optionsBroken, null];
11383
11383
  }
11384
- return optionsBroken;
11384
+ return [
11385
+ ...optionsBroken,
11386
+ null
11387
+ // [3]
11388
+ ];
11385
11389
  };
11386
11390
  var getYupSchema = ({ inputType, ...field }) => {
11387
11391
  const jsonType = getJsonTypeInArray(field.jsonType);
@@ -11601,8 +11605,17 @@ function checkIfConditionMatches(node, formValues, formFields) {
11601
11605
  if (currentProperty.enum) {
11602
11606
  return currentProperty.enum.includes(value);
11603
11607
  }
11604
- const { inputType } = getField(name, formFields);
11605
- return validateFieldSchema({ ...currentProperty, inputType, required: true }, value);
11608
+ const field = getField(name, formFields);
11609
+ return validateFieldSchema(
11610
+ {
11611
+ options: field.options,
11612
+ // @TODO/CODE SMELL. We are passing the property (raw field), but buildYupSchema() expected the output field.
11613
+ ...currentProperty,
11614
+ inputType: field.inputType,
11615
+ required: true
11616
+ },
11617
+ value
11618
+ );
11606
11619
  });
11607
11620
  }
11608
11621
  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.20230703082439",
3
+ "version": "0.4.1-dev.20230703195833",
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",
@@ -852,26 +852,31 @@ describe('createHeadlessForm', () => {
852
852
  expect(validateForm({ has_car: '' })).toBeUndefined();
853
853
  }
854
854
 
855
- it('with null option (as Remote)', () => {
856
- const { handleValidation } = createHeadlessForm(schemaInputRadioOptionalNull);
855
+ it('normal optional (conventional way)', () => {
856
+ const { handleValidation } = createHeadlessForm(schemaInputRadioOptionalConventional);
857
857
  const validateForm = (vals) => friendlyError(handleValidation(vals));
858
858
 
859
859
  assertCommonBehavior(validateForm);
860
860
 
861
- // Accepts null value
861
+ // Accepts null, even though it shoudln't @BUG RMT-518
862
+ // This is for cases where we (Remote) still have incorrect
863
+ // JSON Schemas in our Platform.
862
864
  expect(validateForm({ has_car: null })).toBeUndefined();
865
+ // Expected:
866
+ // // Does NOT accept null value
867
+ // expect(validateForm({ has_car: null })).toEqual({
868
+ // has_car: 'The option null is not valid.',
869
+ // });
863
870
  });
864
871
 
865
- it('without null option (conventional way)', () => {
866
- const { handleValidation } = createHeadlessForm(schemaInputRadioOptionalConventional);
872
+ it('with null option (as Remote does)', () => {
873
+ const { handleValidation } = createHeadlessForm(schemaInputRadioOptionalNull);
867
874
  const validateForm = (vals) => friendlyError(handleValidation(vals));
868
875
 
869
876
  assertCommonBehavior(validateForm);
870
877
 
871
- // Does NOT accept null value
872
- expect(validateForm({ has_car: null })).toEqual({
873
- has_car: 'The option null is not valid.',
874
- });
878
+ // Accepts null value
879
+ expect(validateForm({ has_car: null })).toBeUndefined();
875
880
  });
876
881
  });
877
882
 
@@ -200,7 +200,7 @@ export const schemaInputTypeHidden = {
200
200
  ...mockSelectInputSolo,
201
201
  title: 'Select hidden',
202
202
  'x-jsf-presentation': { inputType: 'hidden' },
203
- default: 'Travel Bonus',
203
+ default: 'chr',
204
204
  },
205
205
  a_hidden_select_multiple: {
206
206
  ...schemaInputTypeCountriesMultiple.properties.nationality,
@@ -1696,7 +1696,7 @@ export const schemaWithConditionalToFieldset = {
1696
1696
  properties: {
1697
1697
  work_hours_per_week: {
1698
1698
  title: 'Hours per week',
1699
- type: 'string',
1699
+ type: 'number',
1700
1700
  description: 'Above 30 hours, the Perk>Food options change, and PTO is required.',
1701
1701
  'x-jsf-presentation': {
1702
1702
  inputType: 'number',
@@ -1704,7 +1704,7 @@ export const schemaWithConditionalToFieldset = {
1704
1704
  },
1705
1705
  pto: {
1706
1706
  title: 'Time-off (days)',
1707
- type: 'string',
1707
+ type: 'number',
1708
1708
  'x-jsf-presentation': {
1709
1709
  inputType: 'number',
1710
1710
  },