@abgov/jsonforms-components 1.54.2 → 1.54.3

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/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as runtime from 'react/jsx-runtime';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
+ import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
3
4
  import { GoAFormItem, GoAInput, GoATextArea, GoACallout, GoAInputDate, GoAInputDateTime, GoAInputTime, GoARadioGroup, GoARadioItem, GoACheckbox, GoAIcon, GoAGrid, GoAFormStepper, GoAFormStep, GoAPages, GoAButton, GoAModal, GoAButtonGroup, GoAIconButton, GoAFileUploadInput, GoACircularProgress, GoAContainer, GoATable, GoADropdown, GoADropdownItem, GoADetails, GoASpinner } from '@abgov/react-components';
4
5
  import styled from 'styled-components';
5
- import React, { createContext, useContext, useReducer, useMemo, useEffect, useState, useRef, useCallback } from 'react';
6
6
  import axios from 'axios';
7
7
  import get$1 from 'lodash/get';
8
8
  import { rankWith, isStringControl, and, optionIs, uiTypeIs, isDateControl, isNumberControl, isIntegerControl, isDateTimeControl, isTimeControl, isEnumControl, isBooleanControl, getAjv, isVisible, getControlPath, toDataPath, deriveLabelForUISchemaElement, isEnabled, schemaTypeIs, formatIs, createDefaultValue, or, isObjectArrayControl, isPrimitiveArrayControl, Paths, schemaMatches, hasType, isControl, isCategorization, isLayout } from '@jsonforms/core';
@@ -2719,7 +2719,6 @@ const checkFieldValidity = props => {
2719
2719
  }
2720
2720
  }
2721
2721
  if (required) {
2722
- if (data === undefined) return '';
2723
2722
  if (schema) {
2724
2723
  if (isEmptyBoolean(schema, data)) {
2725
2724
  return `${labelToUpdate} is required`;
@@ -2852,7 +2851,7 @@ const onKeyPressForTimeControl = props => {
2852
2851
  path
2853
2852
  } = controlProps;
2854
2853
  if (isNotKeyPressTabOrShift(key)) {
2855
- handleChange(path, value);
2854
+ handleChange(path, value === '' ? undefined : value);
2856
2855
  }
2857
2856
  };
2858
2857
  /**
@@ -2873,7 +2872,7 @@ const onKeyPressForDateControl = props => {
2873
2872
  } = controlProps;
2874
2873
  if (isNotKeyPressTabOrShift(key)) {
2875
2874
  value = standardizeDate(value) || '';
2876
- handleChange(path, value);
2875
+ handleChange(path, value === '' ? undefined : value);
2877
2876
  }
2878
2877
  };
2879
2878
  /**
@@ -2890,7 +2889,7 @@ const onBlurForTextControl = props => {
2890
2889
  path
2891
2890
  } = controlProps;
2892
2891
  if (isRequiredAndHasNoData(controlProps)) {
2893
- handleChange(path, value);
2892
+ handleChange(path, value === '' ? undefined : value);
2894
2893
  }
2895
2894
  };
2896
2895
  /**
@@ -2907,7 +2906,7 @@ const onBlurForNumericControl = props => {
2907
2906
  path
2908
2907
  } = controlProps;
2909
2908
  if (isRequiredAndHasNoData(controlProps)) {
2910
- let newValue = '';
2909
+ let newValue = undefined;
2911
2910
  if (value !== '') {
2912
2911
  newValue = +value;
2913
2912
  }
@@ -2931,25 +2930,6 @@ const onBlurForDateControl = props => {
2931
2930
  } = controlProps;
2932
2931
  if (isRequiredAndHasNoData(controlProps)) {
2933
2932
  value = standardizeDate(value) || '';
2934
- handleChange(path, value);
2935
- }
2936
- };
2937
- /**
2938
- * Helper function to process for onBlur event for time controls
2939
- * @param props - EventBlurControlProps
2940
- */
2941
- const onBlurForTimeControl = props => {
2942
- const {
2943
- controlProps
2944
- } = props;
2945
- const {
2946
- value
2947
- } = props;
2948
- const {
2949
- handleChange,
2950
- path
2951
- } = controlProps;
2952
- if (isRequiredAndHasNoData(controlProps)) {
2953
2933
  handleChange(path, value === '' ? undefined : value);
2954
2934
  }
2955
2935
  };
@@ -3848,11 +3828,13 @@ const GoAInputBaseControl = props => {
3848
3828
  input,
3849
3829
  required,
3850
3830
  path,
3851
- isStepperReview
3831
+ isStepperReview,
3832
+ skipOnBlurValidation
3852
3833
  } = props;
3853
3834
  const InnerComponent = input;
3854
3835
  const labelToUpdate = convertToSentenceCase(getLabelText(uischema.scope, label || ''));
3855
3836
  let modifiedErrors = checkFieldValidity(props);
3837
+ const [isVisited, setIsVisited] = useState(skipOnBlurValidation === true);
3856
3838
  if (modifiedErrors === 'must be equal to one of the allowed values') {
3857
3839
  modifiedErrors = '';
3858
3840
  }
@@ -3863,11 +3845,17 @@ const GoAInputBaseControl = props => {
3863
3845
  children: jsx(FormFieldWrapper, {
3864
3846
  children: jsx(GoAFormItem, {
3865
3847
  requirement: required ? 'required' : undefined,
3866
- error: modifiedErrors,
3848
+ error: isVisited === true ? modifiedErrors : undefined,
3867
3849
  testId: `${isStepperReview === true && 'review-base-'}${path}`,
3868
3850
  label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
3869
3851
  helpText: typeof ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.help) === 'string' && !isStepperReview ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help : '',
3870
- children: jsx(InnerComponent, Object.assign({}, props))
3852
+ children: jsx(InnerComponent, Object.assign({}, props, {
3853
+ isVisited,
3854
+ errors: modifiedErrors,
3855
+ setIsVisited: () => {
3856
+ setIsVisited(true);
3857
+ }
3858
+ }))
3871
3859
  })
3872
3860
  })
3873
3861
  })
@@ -4395,7 +4383,10 @@ const GoAInputText = props => {
4395
4383
  schema,
4396
4384
  label,
4397
4385
  path,
4398
- handleChange
4386
+ handleChange,
4387
+ errors,
4388
+ isVisited,
4389
+ setIsVisited
4399
4390
  } = props;
4400
4391
  const registerCtx = useContext(JsonFormsRegisterContext);
4401
4392
  const registerConfig = fetchRegisterConfigFromOptions$1((_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.register);
@@ -4435,7 +4426,6 @@ const GoAInputText = props => {
4435
4426
  }, [registerCtx, registerConfig]);
4436
4427
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4437
4428
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4438
- const errorsFormInput = checkFieldValidity(props);
4439
4429
  const isSinField = schema.title === sinTitle;
4440
4430
  const autoCapitalize = ((_f = (_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.componentProps) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true || ((_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.autoCapitalize) === true;
4441
4431
  const readOnly = (_k = (_j = (_h = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _h === void 0 ? void 0 : _h.componentProps) === null || _j === void 0 ? void 0 : _j.readOnly) !== null && _k !== void 0 ? _k : false;
@@ -4451,7 +4441,7 @@ const GoAInputText = props => {
4451
4441
  handleChange(path, value);
4452
4442
  }
4453
4443
  }, `jsonforms-${label}-dropdown`) : jsx(GoAInput, Object.assign({
4454
- error: errorsFormInput.length > 0,
4444
+ error: isVisited && errors.length > 0,
4455
4445
  type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text',
4456
4446
  disabled: !enabled,
4457
4447
  value: data,
@@ -4468,14 +4458,23 @@ const GoAInputText = props => {
4468
4458
  if (schema && schema.title === sinTitle && value !== '') {
4469
4459
  formattedValue = formatSin(value);
4470
4460
  }
4461
+ /* TODO: add the unit test, when the solution is used */
4462
+ /* istanbul ignore next */
4463
+ if (isVisited === false && setIsVisited) {
4464
+ setIsVisited();
4465
+ }
4471
4466
  onChangeForInputControl({
4472
4467
  name,
4473
4468
  value: formattedValue,
4474
4469
  controlProps: props
4475
4470
  });
4476
4471
  },
4477
- onKeyPress: (name, value, key) => {},
4478
4472
  onBlur: (name, value) => {
4473
+ /* istanbul ignore next */
4474
+ if (isVisited === false && setIsVisited) {
4475
+ setIsVisited();
4476
+ }
4477
+ /* istanbul ignore next */
4479
4478
  onBlurForTextControl({
4480
4479
  name,
4481
4480
  controlProps: props,
@@ -4492,7 +4491,7 @@ const GoATextControlTester = rankWith(1, isStringControl);
4492
4491
  const GoAInputTextControl = withJsonFormsControlProps(GoATextControl);
4493
4492
 
4494
4493
  const MultiLineText = props => {
4495
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4494
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4496
4495
  const {
4497
4496
  data,
4498
4497
  config,
@@ -4500,9 +4499,11 @@ const MultiLineText = props => {
4500
4499
  enabled,
4501
4500
  uischema,
4502
4501
  path,
4503
- handleChange,
4504
4502
  schema,
4505
- label
4503
+ label,
4504
+ isVisited,
4505
+ errors,
4506
+ setIsVisited
4506
4507
  } = props;
4507
4508
  const {
4508
4509
  required
@@ -4510,14 +4511,12 @@ const MultiLineText = props => {
4510
4511
  const [textAreaValue, _] = React.useState(data);
4511
4512
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4512
4513
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4513
- const errorsFormInput = checkFieldValidity(props);
4514
4514
  const width = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : '100%';
4515
4515
  const autoCapitalize = ((_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.autoCapitalize) === true || ((_f = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _f === void 0 ? void 0 : _f.autoCapitalize) === true;
4516
4516
  const readOnly = (_j = (_h = (_g = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _g === void 0 ? void 0 : _g.componentProps) === null || _h === void 0 ? void 0 : _h.readOnly) !== null && _j !== void 0 ? _j : false;
4517
4517
  const textAreaName = `${label || path}-text-area` || '';
4518
- (_k = document.getElementsByName(textAreaName)[0]) !== null && _k !== void 0 ? _k : null;
4519
4518
  const txtAreaComponent = jsx(GoATextArea, Object.assign({
4520
- error: errorsFormInput.length > 0,
4519
+ error: isVisited && errors.length > 0,
4521
4520
  value: textAreaValue,
4522
4521
  disabled: !enabled,
4523
4522
  readOnly: readOnly,
@@ -4529,7 +4528,12 @@ const MultiLineText = props => {
4529
4528
  // maxCount={schema.maxLength || 256}
4530
4529
  onKeyPress: (name, value, key) => {
4531
4530
  const newValue = autoCapitalize ? value.toUpperCase() : value;
4532
- if (value.length === 0 || required && errorsFormInput.length === 0 && value.length > 0) {
4531
+ /* TODO: add the unit test, when the solution is used */
4532
+ /* istanbul ignore next */
4533
+ if (isVisited === false && setIsVisited) {
4534
+ setIsVisited();
4535
+ }
4536
+ if (value.length === 0 || required && errors.length === 0 && value.length > 0) {
4533
4537
  onKeyPressForTextControl({
4534
4538
  name,
4535
4539
  value: newValue,
@@ -4544,9 +4548,13 @@ const MultiLineText = props => {
4544
4548
  });
4545
4549
  },
4546
4550
  onChange: (name, value) => {
4547
- // this is not triggered unless you tab out
4551
+ /* TODO: add the unit test, when the solution is used */
4552
+ /* istanbul ignore next */
4553
+ if (isVisited === false && setIsVisited) {
4554
+ setIsVisited();
4555
+ }
4548
4556
  }
4549
- }, (_l = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _l === void 0 ? void 0 : _l.componentProps));
4557
+ }, (_k = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _k === void 0 ? void 0 : _k.componentProps));
4550
4558
  return txtAreaComponent;
4551
4559
  };
4552
4560
  const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
@@ -4609,9 +4617,10 @@ const GoADateInput = props => {
4609
4617
  id,
4610
4618
  enabled,
4611
4619
  uischema,
4612
- path,
4613
- handleChange,
4614
- label
4620
+ errors,
4621
+ isVisited,
4622
+ label,
4623
+ setIsVisited
4615
4624
  } = props;
4616
4625
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4617
4626
  const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
@@ -4625,7 +4634,7 @@ const GoADateInput = props => {
4625
4634
  return invalidDateFormat(uischema.scope, 'Max');
4626
4635
  }
4627
4636
  return jsx(GoAInputDate, Object.assign({
4628
- error: checkFieldValidity(props).length > 0,
4637
+ error: isVisited && errors.length > 0,
4629
4638
  width: width,
4630
4639
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4631
4640
  value: standardizeDate(data) || '',
@@ -4633,6 +4642,11 @@ const GoADateInput = props => {
4633
4642
  disabled: !enabled,
4634
4643
  readonly: readOnly,
4635
4644
  onChange: (name, value) => {
4645
+ /* TODO: add the unit test, when the solution is used */
4646
+ /* istanbul ignore next */
4647
+ if (isVisited === false && setIsVisited) {
4648
+ setIsVisited();
4649
+ }
4636
4650
  onChangeForDateControl({
4637
4651
  name,
4638
4652
  value,
@@ -4648,6 +4662,11 @@ const GoADateInput = props => {
4648
4662
  });
4649
4663
  },
4650
4664
  onBlur: (name, value) => {
4665
+ /* istanbul ignore next */
4666
+ if (isVisited === false && setIsVisited) {
4667
+ setIsVisited();
4668
+ }
4669
+ /* istanbul ignore next */
4651
4670
  onBlurForDateControl({
4652
4671
  name,
4653
4672
  value,
@@ -4671,11 +4690,11 @@ const GoANumberInput = props => {
4671
4690
  id,
4672
4691
  enabled,
4673
4692
  uischema,
4674
- isValid,
4675
- path,
4676
- handleChange,
4677
4693
  schema,
4678
- label
4694
+ label,
4695
+ isVisited,
4696
+ errors,
4697
+ setIsVisited
4679
4698
  } = props;
4680
4699
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4681
4700
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
@@ -4686,10 +4705,9 @@ const GoANumberInput = props => {
4686
4705
  const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4687
4706
  const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4688
4707
  const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4689
- const errorsFormInput = checkFieldValidity(props);
4690
4708
  return jsx(GoAInput, Object.assign({
4691
4709
  type: "number",
4692
- error: errorsFormInput.length > 0,
4710
+ error: isVisited && errors.length > 0,
4693
4711
  disabled: !enabled,
4694
4712
  readonly: readOnly,
4695
4713
  value: InputValue,
@@ -4701,6 +4719,11 @@ const GoANumberInput = props => {
4701
4719
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4702
4720
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4703
4721
  onBlur: (name, value) => {
4722
+ /* istanbul ignore next */
4723
+ if (isVisited === false && setIsVisited) {
4724
+ setIsVisited();
4725
+ }
4726
+ /* istanbul ignore next */
4704
4727
  onBlurForNumericControl({
4705
4728
  name,
4706
4729
  value,
@@ -4708,6 +4731,11 @@ const GoANumberInput = props => {
4708
4731
  });
4709
4732
  },
4710
4733
  onChange: (name, value) => {
4734
+ /* TODO: add the unit test, when the solution is used */
4735
+ /* istanbul ignore next */
4736
+ if (isVisited === false && setIsVisited) {
4737
+ setIsVisited();
4738
+ }
4711
4739
  onChangeForNumericControl({
4712
4740
  name,
4713
4741
  value,
@@ -4731,11 +4759,11 @@ const GoAInputInteger = props => {
4731
4759
  id,
4732
4760
  enabled,
4733
4761
  uischema,
4734
- isValid,
4735
- path,
4736
- handleChange,
4737
4762
  schema,
4738
- label
4763
+ label,
4764
+ isVisited,
4765
+ errors,
4766
+ setIsVisited
4739
4767
  } = props;
4740
4768
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4741
4769
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
@@ -4746,10 +4774,9 @@ const GoAInputInteger = props => {
4746
4774
  const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4747
4775
  const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4748
4776
  const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4749
- const errorsFormInput = checkFieldValidity(props);
4750
4777
  return jsx(GoAInput, Object.assign({
4751
4778
  type: "number",
4752
- error: errorsFormInput.length > 0,
4779
+ error: isVisited && errors.length > 0,
4753
4780
  width: width,
4754
4781
  disabled: !enabled,
4755
4782
  readonly: readOnly,
@@ -4760,8 +4787,13 @@ const GoAInputInteger = props => {
4760
4787
  placeholder: placeholder,
4761
4788
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4762
4789
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4763
- onKeyPress: (name, value, key) => {},
4790
+ /* istanbul ignore next */
4764
4791
  onBlur: (name, value) => {
4792
+ /* TODO: add the unit test, when the solution is used */
4793
+ /* istanbul ignore next */
4794
+ if (isVisited === false && setIsVisited) {
4795
+ setIsVisited();
4796
+ }
4765
4797
  onBlurForNumericControl({
4766
4798
  name,
4767
4799
  value,
@@ -4769,6 +4801,11 @@ const GoAInputInteger = props => {
4769
4801
  });
4770
4802
  },
4771
4803
  onChange: (name, value) => {
4804
+ /* TODO: add the unit test, when the solution is used */
4805
+ /* istanbul ignore next */
4806
+ if (isVisited === false && setIsVisited) {
4807
+ setIsVisited();
4808
+ }
4772
4809
  onChangeForNumericControl({
4773
4810
  name,
4774
4811
  value,
@@ -4792,18 +4829,17 @@ const GoADateTimeInput = props => {
4792
4829
  id,
4793
4830
  enabled,
4794
4831
  uischema,
4795
- isValid,
4796
- path,
4832
+ isVisited,
4797
4833
  errors,
4798
- handleChange,
4799
4834
  schema,
4800
- label
4835
+ label,
4836
+ setIsVisited
4801
4837
  } = props;
4802
4838
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4803
4839
  const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4804
4840
  const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.width) !== null && _f !== void 0 ? _f : '100%';
4805
4841
  return jsx(GoAInputDateTime, Object.assign({
4806
- error: checkFieldValidity(props).length > 0,
4842
+ error: isVisited && errors.length > 0,
4807
4843
  width: width,
4808
4844
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4809
4845
  value: data ? new Date(data).toISOString() : '',
@@ -4811,6 +4847,9 @@ const GoADateTimeInput = props => {
4811
4847
  disabled: !enabled,
4812
4848
  readonly: readOnly,
4813
4849
  onChange: (name, value) => {
4850
+ if (isVisited === false && setIsVisited) {
4851
+ setIsVisited();
4852
+ }
4814
4853
  onChangeForDateTimeControl({
4815
4854
  name,
4816
4855
  value,
@@ -4826,6 +4865,11 @@ const GoADateTimeInput = props => {
4826
4865
  });
4827
4866
  },
4828
4867
  onBlur: (name, value) => {
4868
+ /* istanbul ignore next */
4869
+ if (isVisited === false && setIsVisited) {
4870
+ setIsVisited();
4871
+ }
4872
+ /* istanbul ignore next */
4829
4873
  onBlurForDateControl({
4830
4874
  name,
4831
4875
  value,
@@ -4849,19 +4893,20 @@ const GoATimeInput = props => {
4849
4893
  id,
4850
4894
  enabled,
4851
4895
  uischema,
4852
- isValid,
4853
4896
  path,
4854
4897
  handleChange,
4855
4898
  schema,
4856
- label
4899
+ label,
4900
+ isVisited,
4901
+ errors,
4902
+ setIsVisited
4857
4903
  } = props;
4858
4904
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4859
4905
  (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4860
4906
  const readOnly = (_c = (_b = (_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) === null || _b === void 0 ? void 0 : _b.readOnly) !== null && _c !== void 0 ? _c : false;
4861
- const errorsFormInput = checkFieldValidity(props);
4862
4907
  const width = (_f = (_e = (_d = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _d === void 0 ? void 0 : _d.componentProps) === null || _e === void 0 ? void 0 : _e.readOnly) !== null && _f !== void 0 ? _f : '100%';
4863
4908
  return jsx(GoAInputTime, Object.assign({
4864
- error: errorsFormInput.length > 0,
4909
+ error: isVisited && errors.length > 0,
4865
4910
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4866
4911
  value: data,
4867
4912
  step: 1,
@@ -4870,11 +4915,12 @@ const GoATimeInput = props => {
4870
4915
  readonly: readOnly,
4871
4916
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4872
4917
  onBlur: (name, value) => {
4873
- onBlurForTimeControl({
4874
- name,
4875
- value,
4876
- controlProps: props
4877
- });
4918
+ /* istanbul ignore next */
4919
+ if (isVisited === false && setIsVisited) {
4920
+ setIsVisited();
4921
+ }
4922
+ /* istanbul ignore next */
4923
+ handleChange(path, value === '' ? undefined : value);
4878
4924
  },
4879
4925
  // Dont use handleChange in the onChange event, use the keyPress or onBlur.
4880
4926
  // If you use it onChange along with keyPress event it will cause a
@@ -4912,7 +4958,9 @@ const EnumSelect = props => {
4912
4958
  config,
4913
4959
  label,
4914
4960
  uischema,
4915
- required
4961
+ required,
4962
+ setIsVisited,
4963
+ isVisited
4916
4964
  } = props;
4917
4965
  const registerCtx = useContext(JsonFormsRegisterContext);
4918
4966
  const registerConfig = fetchRegisterConfigFromOptions((_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.register);
@@ -4991,13 +5039,14 @@ const RadioGroup = props => {
4991
5039
  options,
4992
5040
  config,
4993
5041
  label,
4994
- t
5042
+ t,
5043
+ isVisited,
5044
+ errors
4995
5045
  } = props;
4996
5046
  const enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
4997
5047
  const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
4998
- const errorsFormInput = checkFieldValidity(props);
4999
5048
  return jsx(GoARadioGroup, Object.assign({
5000
- error: errorsFormInput.length > 0,
5049
+ error: isVisited && errors.length > 0,
5001
5050
  name: `${options || appliedUiSchemaOptions.label}`,
5002
5051
  testId: `${label || id}-jsonforms-radio`,
5003
5052
  value: data,
@@ -5032,20 +5081,13 @@ const BooleanComponent = ({
5032
5081
  label,
5033
5082
  required,
5034
5083
  errors,
5035
- schema
5084
+ schema,
5085
+ isVisited
5036
5086
  }) => {
5037
5087
  var _a, _b, _c;
5038
- const errorsFormInput = checkFieldValidity({
5039
- data,
5040
- uischema,
5041
- label,
5042
- required,
5043
- errors,
5044
- schema
5045
- });
5046
5088
  const text = `${((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.text) ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.text : (schema === null || schema === void 0 ? void 0 : schema.title) ? schema === null || schema === void 0 ? void 0 : schema.title : schema === null || schema === void 0 ? void 0 : schema.description}${required ? ' (required)' : ''}`;
5047
5089
  return jsx(GoACheckbox, Object.assign({
5048
- error: errorsFormInput.length > 0,
5090
+ error: isVisited && errors.length > 0,
5049
5091
  testId: `${path}-checkbox-test-id`,
5050
5092
  disabled: !enabled,
5051
5093
  text: text && text !== 'undefined' ? text : convertToReadableFormat(getLastSegmentFromPointer(uischema.scope)),
@@ -5073,7 +5115,7 @@ const BooleanRadioComponent = ({
5073
5115
  path,
5074
5116
  config,
5075
5117
  label,
5076
- required,
5118
+ isVisited,
5077
5119
  errors,
5078
5120
  description
5079
5121
  }) => {
@@ -5085,17 +5127,10 @@ const BooleanRadioComponent = ({
5085
5127
  const TrueDescription = description || (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.descriptionForTrue);
5086
5128
  const FalseDescription = description || (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.descriptionForFalse);
5087
5129
  const BaseTestId = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${path}-boolean-radio-jsonform`;
5088
- const errorsFormInput = checkFieldValidity({
5089
- data,
5090
- uischema,
5091
- label,
5092
- required,
5093
- errors
5094
- });
5095
5130
  return jsx(Visible, {
5096
5131
  visible: visible,
5097
5132
  children: jsxs(GoARadioGroup, Object.assign({
5098
- error: errorsFormInput.length > 0,
5133
+ error: isVisited && errors.length,
5099
5134
  name: `${label}`,
5100
5135
  value: data === true ? TrueValue : data === false ? FalseValue : null,
5101
5136
  disabled: !enabled,
@@ -5256,7 +5291,8 @@ const GoABaseInputReviewComponent = props => {
5256
5291
  };
5257
5292
  const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
5258
5293
  input: GoABaseInputReviewComponent,
5259
- isStepperReview: true
5294
+ isStepperReview: true,
5295
+ skipOnBlurValidation: true
5260
5296
  }));
5261
5297
  const GoInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
5262
5298
 
@@ -6073,32 +6109,24 @@ const JsonFormsStepperContextProvider = ({
6073
6109
  return stepperState.categories[id];
6074
6110
  },
6075
6111
  goToPage: (id, updateCategoryId) => {
6076
- var _a, _b, _c, _d;
6112
+ var _a, _b, _c;
6077
6113
  ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
6078
- if (updateCategoryId !== undefined && updateCategoryId < stepperState.categories.length) {
6079
- stepperDispatch({
6080
- type: 'update/category',
6081
- payload: {
6082
- errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
6083
- id: updateCategoryId,
6084
- ajv
6085
- }
6086
- });
6087
- }
6088
6114
  if (stepperState.isOnReview !== true) {
6089
- stepperDispatch({
6090
- type: 'update/category',
6091
- payload: {
6092
- errors: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _c === void 0 ? void 0 : _c.errors,
6093
- id: stepperState.activeId,
6094
- ajv
6095
- }
6096
- });
6115
+ for (let i = 0; i < id; i++) {
6116
+ stepperDispatch({
6117
+ type: 'update/category',
6118
+ payload: {
6119
+ errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
6120
+ id: i,
6121
+ ajv
6122
+ }
6123
+ });
6124
+ }
6097
6125
  }
6098
6126
  stepperDispatch({
6099
6127
  type: 'validate/form',
6100
6128
  payload: {
6101
- errors: (_d = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _d === void 0 ? void 0 : _d.errors
6129
+ errors: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _c === void 0 ? void 0 : _c.errors
6102
6130
  }
6103
6131
  });
6104
6132
  stepperDispatch({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.54.2",
3
+ "version": "1.54.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",
@@ -4,5 +4,7 @@ export interface WithInput {
4
4
  input: any;
5
5
  noLabel?: boolean;
6
6
  isStepperReview?: boolean;
7
+ setIsVisited?: () => void;
8
+ skipOnBlurValidation?: boolean;
7
9
  }
8
10
  export declare const GoAInputBaseControl: (props: ControlProps & WithInput) => JSX.Element;
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { RankedTester, ControlProps } from '@jsonforms/core';
3
- export declare const BooleanComponent: ({ data, enabled, uischema, handleChange, path, label, required, errors, schema, }: ControlProps) => import("react/jsx-runtime").JSX.Element;
3
+ import { WithInputProps } from './type';
4
+ export declare const BooleanComponent: ({ data, enabled, uischema, handleChange, path, label, required, errors, schema, isVisited, }: ControlProps & WithInputProps) => import("react/jsx-runtime").JSX.Element;
4
5
  export declare const BooleanControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
5
6
  export declare const GoABooleanControlTester: RankedTester;
6
7
  export declare const GoABooleanControl: import("react").ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { RankedTester, ControlProps } from '@jsonforms/core';
3
- export declare const BooleanRadioComponent: ({ data, visible, enabled, uischema, handleChange, path, config, label, required, errors, description, }: ControlProps) => import("react/jsx-runtime").JSX.Element;
3
+ import { WithInputProps } from './type';
4
+ export declare const BooleanRadioComponent: ({ data, visible, enabled, uischema, handleChange, path, config, label, isVisited, errors, description, }: ControlProps & WithInputProps) => import("react/jsx-runtime").JSX.Element;
4
5
  export declare const BooleanRadioControl: (props: ControlProps) => import("react/jsx-runtime").JSX.Element;
5
6
  export declare const GoABooleanRadioControlTester: RankedTester;
6
7
  export declare const GoABooleanRadioControl: React.ComponentType<import("@jsonforms/core").OwnPropsOfControl>;
@@ -1,6 +1,8 @@
1
1
  import { ControlProps } from '@jsonforms/core';
2
2
  export interface WithInputProps {
3
3
  label?: string;
4
+ isVisited?: boolean;
5
+ setIsVisited?: () => void;
4
6
  }
5
7
  /**
6
8
  * Base event control props to handle event controls