@abgov/jsonforms-components 1.54.1 → 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
  };
@@ -3037,10 +3017,14 @@ const onChangeForNumericControl = props => {
3037
3017
  //Prevents handleChange from executing if the data has not changed
3038
3018
  //so the component will not re render.
3039
3019
  if (data !== +value) {
3040
- handleChange(path, value === '' ? undefined : value);
3020
+ let newValue = undefined;
3021
+ if (value !== '') {
3022
+ newValue = +value;
3023
+ }
3024
+ handleChange(path, newValue);
3041
3025
  }
3042
3026
  } else {
3043
- handleChange(path, value);
3027
+ handleChange(path, value === '' ? undefined : value);
3044
3028
  }
3045
3029
  };
3046
3030
 
@@ -3844,11 +3828,13 @@ const GoAInputBaseControl = props => {
3844
3828
  input,
3845
3829
  required,
3846
3830
  path,
3847
- isStepperReview
3831
+ isStepperReview,
3832
+ skipOnBlurValidation
3848
3833
  } = props;
3849
3834
  const InnerComponent = input;
3850
3835
  const labelToUpdate = convertToSentenceCase(getLabelText(uischema.scope, label || ''));
3851
3836
  let modifiedErrors = checkFieldValidity(props);
3837
+ const [isVisited, setIsVisited] = useState(skipOnBlurValidation === true);
3852
3838
  if (modifiedErrors === 'must be equal to one of the allowed values') {
3853
3839
  modifiedErrors = '';
3854
3840
  }
@@ -3859,11 +3845,17 @@ const GoAInputBaseControl = props => {
3859
3845
  children: jsx(FormFieldWrapper, {
3860
3846
  children: jsx(GoAFormItem, {
3861
3847
  requirement: required ? 'required' : undefined,
3862
- error: modifiedErrors,
3848
+ error: isVisited === true ? modifiedErrors : undefined,
3863
3849
  testId: `${isStepperReview === true && 'review-base-'}${path}`,
3864
3850
  label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
3865
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 : '',
3866
- 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
+ }))
3867
3859
  })
3868
3860
  })
3869
3861
  })
@@ -4391,7 +4383,10 @@ const GoAInputText = props => {
4391
4383
  schema,
4392
4384
  label,
4393
4385
  path,
4394
- handleChange
4386
+ handleChange,
4387
+ errors,
4388
+ isVisited,
4389
+ setIsVisited
4395
4390
  } = props;
4396
4391
  const registerCtx = useContext(JsonFormsRegisterContext);
4397
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);
@@ -4431,7 +4426,6 @@ const GoAInputText = props => {
4431
4426
  }, [registerCtx, registerConfig]);
4432
4427
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4433
4428
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4434
- const errorsFormInput = checkFieldValidity(props);
4435
4429
  const isSinField = schema.title === sinTitle;
4436
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;
4437
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;
@@ -4447,7 +4441,7 @@ const GoAInputText = props => {
4447
4441
  handleChange(path, value);
4448
4442
  }
4449
4443
  }, `jsonforms-${label}-dropdown`) : jsx(GoAInput, Object.assign({
4450
- error: errorsFormInput.length > 0,
4444
+ error: isVisited && errors.length > 0,
4451
4445
  type: appliedUiSchemaOptions.format === 'password' ? 'password' : 'text',
4452
4446
  disabled: !enabled,
4453
4447
  value: data,
@@ -4464,14 +4458,23 @@ const GoAInputText = props => {
4464
4458
  if (schema && schema.title === sinTitle && value !== '') {
4465
4459
  formattedValue = formatSin(value);
4466
4460
  }
4461
+ /* TODO: add the unit test, when the solution is used */
4462
+ /* istanbul ignore next */
4463
+ if (isVisited === false && setIsVisited) {
4464
+ setIsVisited();
4465
+ }
4467
4466
  onChangeForInputControl({
4468
4467
  name,
4469
4468
  value: formattedValue,
4470
4469
  controlProps: props
4471
4470
  });
4472
4471
  },
4473
- onKeyPress: (name, value, key) => {},
4474
4472
  onBlur: (name, value) => {
4473
+ /* istanbul ignore next */
4474
+ if (isVisited === false && setIsVisited) {
4475
+ setIsVisited();
4476
+ }
4477
+ /* istanbul ignore next */
4475
4478
  onBlurForTextControl({
4476
4479
  name,
4477
4480
  controlProps: props,
@@ -4488,7 +4491,7 @@ const GoATextControlTester = rankWith(1, isStringControl);
4488
4491
  const GoAInputTextControl = withJsonFormsControlProps(GoATextControl);
4489
4492
 
4490
4493
  const MultiLineText = props => {
4491
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
4494
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
4492
4495
  const {
4493
4496
  data,
4494
4497
  config,
@@ -4496,9 +4499,11 @@ const MultiLineText = props => {
4496
4499
  enabled,
4497
4500
  uischema,
4498
4501
  path,
4499
- handleChange,
4500
4502
  schema,
4501
- label
4503
+ label,
4504
+ isVisited,
4505
+ errors,
4506
+ setIsVisited
4502
4507
  } = props;
4503
4508
  const {
4504
4509
  required
@@ -4506,14 +4511,12 @@ const MultiLineText = props => {
4506
4511
  const [textAreaValue, _] = React.useState(data);
4507
4512
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4508
4513
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4509
- const errorsFormInput = checkFieldValidity(props);
4510
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%';
4511
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;
4512
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;
4513
4517
  const textAreaName = `${label || path}-text-area` || '';
4514
- (_k = document.getElementsByName(textAreaName)[0]) !== null && _k !== void 0 ? _k : null;
4515
4518
  const txtAreaComponent = jsx(GoATextArea, Object.assign({
4516
- error: errorsFormInput.length > 0,
4519
+ error: isVisited && errors.length > 0,
4517
4520
  value: textAreaValue,
4518
4521
  disabled: !enabled,
4519
4522
  readOnly: readOnly,
@@ -4525,7 +4528,12 @@ const MultiLineText = props => {
4525
4528
  // maxCount={schema.maxLength || 256}
4526
4529
  onKeyPress: (name, value, key) => {
4527
4530
  const newValue = autoCapitalize ? value.toUpperCase() : value;
4528
- 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) {
4529
4537
  onKeyPressForTextControl({
4530
4538
  name,
4531
4539
  value: newValue,
@@ -4540,9 +4548,13 @@ const MultiLineText = props => {
4540
4548
  });
4541
4549
  },
4542
4550
  onChange: (name, value) => {
4543
- // 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
+ }
4544
4556
  }
4545
- }, (_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));
4546
4558
  return txtAreaComponent;
4547
4559
  };
4548
4560
  const MultiLineTextControlInput = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
@@ -4605,9 +4617,10 @@ const GoADateInput = props => {
4605
4617
  id,
4606
4618
  enabled,
4607
4619
  uischema,
4608
- path,
4609
- handleChange,
4610
- label
4620
+ errors,
4621
+ isVisited,
4622
+ label,
4623
+ setIsVisited
4611
4624
  } = props;
4612
4625
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4613
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;
@@ -4621,7 +4634,7 @@ const GoADateInput = props => {
4621
4634
  return invalidDateFormat(uischema.scope, 'Max');
4622
4635
  }
4623
4636
  return jsx(GoAInputDate, Object.assign({
4624
- error: checkFieldValidity(props).length > 0,
4637
+ error: isVisited && errors.length > 0,
4625
4638
  width: width,
4626
4639
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4627
4640
  value: standardizeDate(data) || '',
@@ -4629,6 +4642,11 @@ const GoADateInput = props => {
4629
4642
  disabled: !enabled,
4630
4643
  readonly: readOnly,
4631
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
+ }
4632
4650
  onChangeForDateControl({
4633
4651
  name,
4634
4652
  value,
@@ -4644,6 +4662,11 @@ const GoADateInput = props => {
4644
4662
  });
4645
4663
  },
4646
4664
  onBlur: (name, value) => {
4665
+ /* istanbul ignore next */
4666
+ if (isVisited === false && setIsVisited) {
4667
+ setIsVisited();
4668
+ }
4669
+ /* istanbul ignore next */
4647
4670
  onBlurForDateControl({
4648
4671
  name,
4649
4672
  value,
@@ -4667,11 +4690,11 @@ const GoANumberInput = props => {
4667
4690
  id,
4668
4691
  enabled,
4669
4692
  uischema,
4670
- isValid,
4671
- path,
4672
- handleChange,
4673
4693
  schema,
4674
- label
4694
+ label,
4695
+ isVisited,
4696
+ errors,
4697
+ setIsVisited
4675
4698
  } = props;
4676
4699
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4677
4700
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
@@ -4682,10 +4705,9 @@ const GoANumberInput = props => {
4682
4705
  const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4683
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;
4684
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%';
4685
- const errorsFormInput = checkFieldValidity(props);
4686
4708
  return jsx(GoAInput, Object.assign({
4687
4709
  type: "number",
4688
- error: errorsFormInput.length > 0,
4710
+ error: isVisited && errors.length > 0,
4689
4711
  disabled: !enabled,
4690
4712
  readonly: readOnly,
4691
4713
  value: InputValue,
@@ -4696,8 +4718,12 @@ const GoANumberInput = props => {
4696
4718
  width: width,
4697
4719
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4698
4720
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4699
- onKeyPress: (name, value, key) => {},
4700
4721
  onBlur: (name, value) => {
4722
+ /* istanbul ignore next */
4723
+ if (isVisited === false && setIsVisited) {
4724
+ setIsVisited();
4725
+ }
4726
+ /* istanbul ignore next */
4701
4727
  onBlurForNumericControl({
4702
4728
  name,
4703
4729
  value,
@@ -4705,6 +4731,11 @@ const GoANumberInput = props => {
4705
4731
  });
4706
4732
  },
4707
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
+ }
4708
4739
  onChangeForNumericControl({
4709
4740
  name,
4710
4741
  value,
@@ -4728,11 +4759,11 @@ const GoAInputInteger = props => {
4728
4759
  id,
4729
4760
  enabled,
4730
4761
  uischema,
4731
- isValid,
4732
- path,
4733
- handleChange,
4734
4762
  schema,
4735
- label
4763
+ label,
4764
+ isVisited,
4765
+ errors,
4766
+ setIsVisited
4736
4767
  } = props;
4737
4768
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4738
4769
  const placeholder = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
@@ -4743,10 +4774,9 @@ const GoAInputInteger = props => {
4743
4774
  const MaxValue = clonedSchema.exclusiveMaximum ? clonedSchema.exclusiveMaximum : '';
4744
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;
4745
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%';
4746
- const errorsFormInput = checkFieldValidity(props);
4747
4777
  return jsx(GoAInput, Object.assign({
4748
4778
  type: "number",
4749
- error: errorsFormInput.length > 0,
4779
+ error: isVisited && errors.length > 0,
4750
4780
  width: width,
4751
4781
  disabled: !enabled,
4752
4782
  readonly: readOnly,
@@ -4757,8 +4787,13 @@ const GoAInputInteger = props => {
4757
4787
  placeholder: placeholder,
4758
4788
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4759
4789
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4760
- onKeyPress: (name, value, key) => {},
4790
+ /* istanbul ignore next */
4761
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
+ }
4762
4797
  onBlurForNumericControl({
4763
4798
  name,
4764
4799
  value,
@@ -4766,6 +4801,11 @@ const GoAInputInteger = props => {
4766
4801
  });
4767
4802
  },
4768
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
+ }
4769
4809
  onChangeForNumericControl({
4770
4810
  name,
4771
4811
  value,
@@ -4789,18 +4829,17 @@ const GoADateTimeInput = props => {
4789
4829
  id,
4790
4830
  enabled,
4791
4831
  uischema,
4792
- isValid,
4793
- path,
4832
+ isVisited,
4794
4833
  errors,
4795
- handleChange,
4796
4834
  schema,
4797
- label
4835
+ label,
4836
+ setIsVisited
4798
4837
  } = props;
4799
4838
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4800
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;
4801
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%';
4802
4841
  return jsx(GoAInputDateTime, Object.assign({
4803
- error: checkFieldValidity(props).length > 0,
4842
+ error: isVisited && errors.length > 0,
4804
4843
  width: width,
4805
4844
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4806
4845
  value: data ? new Date(data).toISOString() : '',
@@ -4808,6 +4847,9 @@ const GoADateTimeInput = props => {
4808
4847
  disabled: !enabled,
4809
4848
  readonly: readOnly,
4810
4849
  onChange: (name, value) => {
4850
+ if (isVisited === false && setIsVisited) {
4851
+ setIsVisited();
4852
+ }
4811
4853
  onChangeForDateTimeControl({
4812
4854
  name,
4813
4855
  value,
@@ -4823,6 +4865,11 @@ const GoADateTimeInput = props => {
4823
4865
  });
4824
4866
  },
4825
4867
  onBlur: (name, value) => {
4868
+ /* istanbul ignore next */
4869
+ if (isVisited === false && setIsVisited) {
4870
+ setIsVisited();
4871
+ }
4872
+ /* istanbul ignore next */
4826
4873
  onBlurForDateControl({
4827
4874
  name,
4828
4875
  value,
@@ -4846,19 +4893,20 @@ const GoATimeInput = props => {
4846
4893
  id,
4847
4894
  enabled,
4848
4895
  uischema,
4849
- isValid,
4850
4896
  path,
4851
4897
  handleChange,
4852
4898
  schema,
4853
- label
4899
+ label,
4900
+ isVisited,
4901
+ errors,
4902
+ setIsVisited
4854
4903
  } = props;
4855
4904
  const appliedUiSchemaOptions = Object.assign(Object.assign({}, config), uischema === null || uischema === void 0 ? void 0 : uischema.options);
4856
4905
  (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.placeholder) || (schema === null || schema === void 0 ? void 0 : schema.description) || '';
4857
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;
4858
- const errorsFormInput = checkFieldValidity(props);
4859
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%';
4860
4908
  return jsx(GoAInputTime, Object.assign({
4861
- error: errorsFormInput.length > 0,
4909
+ error: isVisited && errors.length > 0,
4862
4910
  name: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.name) || `${id || label}-input`,
4863
4911
  value: data,
4864
4912
  step: 1,
@@ -4867,11 +4915,12 @@ const GoATimeInput = props => {
4867
4915
  readonly: readOnly,
4868
4916
  testId: (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${id}-input`,
4869
4917
  onBlur: (name, value) => {
4870
- onBlurForTimeControl({
4871
- name,
4872
- value,
4873
- controlProps: props
4874
- });
4918
+ /* istanbul ignore next */
4919
+ if (isVisited === false && setIsVisited) {
4920
+ setIsVisited();
4921
+ }
4922
+ /* istanbul ignore next */
4923
+ handleChange(path, value === '' ? undefined : value);
4875
4924
  },
4876
4925
  // Dont use handleChange in the onChange event, use the keyPress or onBlur.
4877
4926
  // If you use it onChange along with keyPress event it will cause a
@@ -4909,7 +4958,9 @@ const EnumSelect = props => {
4909
4958
  config,
4910
4959
  label,
4911
4960
  uischema,
4912
- required
4961
+ required,
4962
+ setIsVisited,
4963
+ isVisited
4913
4964
  } = props;
4914
4965
  const registerCtx = useContext(JsonFormsRegisterContext);
4915
4966
  const registerConfig = fetchRegisterConfigFromOptions((_b = (_a = props.uischema) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.register);
@@ -4988,13 +5039,14 @@ const RadioGroup = props => {
4988
5039
  options,
4989
5040
  config,
4990
5041
  label,
4991
- t
5042
+ t,
5043
+ isVisited,
5044
+ errors
4992
5045
  } = props;
4993
5046
  const enumData = (schema === null || schema === void 0 ? void 0 : schema.enum) || [];
4994
5047
  const appliedUiSchemaOptions = merge({}, config, props.uischema.options, options);
4995
- const errorsFormInput = checkFieldValidity(props);
4996
5048
  return jsx(GoARadioGroup, Object.assign({
4997
- error: errorsFormInput.length > 0,
5049
+ error: isVisited && errors.length > 0,
4998
5050
  name: `${options || appliedUiSchemaOptions.label}`,
4999
5051
  testId: `${label || id}-jsonforms-radio`,
5000
5052
  value: data,
@@ -5029,20 +5081,13 @@ const BooleanComponent = ({
5029
5081
  label,
5030
5082
  required,
5031
5083
  errors,
5032
- schema
5084
+ schema,
5085
+ isVisited
5033
5086
  }) => {
5034
5087
  var _a, _b, _c;
5035
- const errorsFormInput = checkFieldValidity({
5036
- data,
5037
- uischema,
5038
- label,
5039
- required,
5040
- errors,
5041
- schema
5042
- });
5043
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)' : ''}`;
5044
5089
  return jsx(GoACheckbox, Object.assign({
5045
- error: errorsFormInput.length > 0,
5090
+ error: isVisited && errors.length > 0,
5046
5091
  testId: `${path}-checkbox-test-id`,
5047
5092
  disabled: !enabled,
5048
5093
  text: text && text !== 'undefined' ? text : convertToReadableFormat(getLastSegmentFromPointer(uischema.scope)),
@@ -5070,7 +5115,7 @@ const BooleanRadioComponent = ({
5070
5115
  path,
5071
5116
  config,
5072
5117
  label,
5073
- required,
5118
+ isVisited,
5074
5119
  errors,
5075
5120
  description
5076
5121
  }) => {
@@ -5082,17 +5127,10 @@ const BooleanRadioComponent = ({
5082
5127
  const TrueDescription = description || (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.descriptionForTrue);
5083
5128
  const FalseDescription = description || (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.descriptionForFalse);
5084
5129
  const BaseTestId = (appliedUiSchemaOptions === null || appliedUiSchemaOptions === void 0 ? void 0 : appliedUiSchemaOptions.testId) || `${path}-boolean-radio-jsonform`;
5085
- const errorsFormInput = checkFieldValidity({
5086
- data,
5087
- uischema,
5088
- label,
5089
- required,
5090
- errors
5091
- });
5092
5130
  return jsx(Visible, {
5093
5131
  visible: visible,
5094
5132
  children: jsxs(GoARadioGroup, Object.assign({
5095
- error: errorsFormInput.length > 0,
5133
+ error: isVisited && errors.length,
5096
5134
  name: `${label}`,
5097
5135
  value: data === true ? TrueValue : data === false ? FalseValue : null,
5098
5136
  disabled: !enabled,
@@ -5253,7 +5291,8 @@ const GoABaseInputReviewComponent = props => {
5253
5291
  };
5254
5292
  const GoInputBaseReview = props => jsx(GoAInputBaseControl, Object.assign({}, props, {
5255
5293
  input: GoABaseInputReviewComponent,
5256
- isStepperReview: true
5294
+ isStepperReview: true,
5295
+ skipOnBlurValidation: true
5257
5296
  }));
5258
5297
  const GoInputBaseReviewControl = withJsonFormsControlProps(GoInputBaseReview);
5259
5298
 
@@ -6070,32 +6109,24 @@ const JsonFormsStepperContextProvider = ({
6070
6109
  return stepperState.categories[id];
6071
6110
  },
6072
6111
  goToPage: (id, updateCategoryId) => {
6073
- var _a, _b, _c, _d;
6112
+ var _a, _b, _c;
6074
6113
  ajv.validate(schema, ((_a = ctx.core) === null || _a === void 0 ? void 0 : _a.data) || {});
6075
- if (updateCategoryId !== undefined && updateCategoryId < stepperState.categories.length) {
6076
- stepperDispatch({
6077
- type: 'update/category',
6078
- payload: {
6079
- errors: (_b = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _b === void 0 ? void 0 : _b.errors,
6080
- id: updateCategoryId,
6081
- ajv
6082
- }
6083
- });
6084
- }
6085
6114
  if (stepperState.isOnReview !== true) {
6086
- stepperDispatch({
6087
- type: 'update/category',
6088
- payload: {
6089
- errors: (_c = ctx === null || ctx === void 0 ? void 0 : ctx.core) === null || _c === void 0 ? void 0 : _c.errors,
6090
- id: stepperState.activeId,
6091
- ajv
6092
- }
6093
- });
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
+ }
6094
6125
  }
6095
6126
  stepperDispatch({
6096
6127
  type: 'validate/form',
6097
6128
  payload: {
6098
- 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
6099
6130
  }
6100
6131
  });
6101
6132
  stepperDispatch({
@@ -7174,7 +7205,9 @@ const NonEmptyCellComponent$1 = /*#__PURE__*/React.memo(function NonEmptyCellCom
7174
7205
  return jsx("td", {
7175
7206
  children: isInReview ? jsx("div", {
7176
7207
  "data-testid": `#/properties/${schemaName}-input-${i}-review`,
7177
- children: currentData
7208
+ children: typeof currentData === 'string' ? currentData : jsx("pre", {
7209
+ children: JSON.stringify(currentData, null, 2)
7210
+ })
7178
7211
  }) : jsx(GoAFormItem, {
7179
7212
  error: (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '',
7180
7213
  mb: errorRow && !error && '2xl' || 'xs',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.54.1",
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