@abgov/jsonforms-components 1.42.4 → 1.42.6

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.
Files changed (2) hide show
  1. package/index.esm.js +49 -19
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -3684,7 +3684,7 @@ const GoAInputBaseControl = props => {
3684
3684
  error: modifiedErrors,
3685
3685
  testId: `${isStepperReview === true && 'review-base-'}${path}`,
3686
3686
  label: (props === null || props === void 0 ? void 0 : props.noLabel) === true ? '' : labelToUpdate,
3687
- helpText: typeof ((_a = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _a === void 0 ? void 0 : _a.help) === 'string' ? (_b = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _b === void 0 ? void 0 : _b.help : '',
3687
+ 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 : '',
3688
3688
  children: jsx(InnerComponent, Object.assign({}, modifiedProps))
3689
3689
  })
3690
3690
  })
@@ -4712,6 +4712,7 @@ const Dropdown = props => {
4712
4712
  setItems(selectedItems);
4713
4713
  }
4714
4714
  },
4715
+ onTrailingIconClick: () => {},
4715
4716
  trailingIcon: trailingIcon
4716
4717
  })
4717
4718
  }), jsx(GoADropdownListContainerWrapper, {
@@ -5672,7 +5673,7 @@ const FormStepper = props => {
5672
5673
  const categoryLabels = [...allCategories.elements.map(category => category.label), summaryLabel];
5673
5674
  const visibleLabels = [...visibleCategoryLabels, summaryLabel];
5674
5675
  const newPage = mapToVisibleStep(page, categoryLabels, visibleLabels);
5675
- const pageStatus = getCompletionStatus(inputStatuses, page);
5676
+ const pageStatus = getCompletionStatus(inputStatuses, page, true);
5676
5677
  const statuses = [...stepStatuses];
5677
5678
  statuses[page - 1] = pageStatus ? pageStatus : 'incomplete';
5678
5679
  setStepStatuses(statuses);
@@ -8201,7 +8202,7 @@ const AddressViews = ({
8201
8202
  gap: "s",
8202
8203
  children: [jsx(GoAFormItem, {
8203
8204
  error: ((_a = data === null || data === void 0 ? void 0 : data.addressLine1) === null || _a === void 0 ? void 0 : _a.length) === 0 ? 'addressLine1 is required' : '',
8204
- label: `${isAlbertaAddress ? 'Alberta p' : 'Canada p'}ostal address`,
8205
+ label: `${isAlbertaAddress ? 'Alberta' : 'Canada'} postal address`,
8205
8206
  children: jsx("p", {
8206
8207
  children: data === null || data === void 0 ? void 0 : data.addressLine1
8207
8208
  })
@@ -8257,11 +8258,9 @@ const AddressLookUpControlReview = props => {
8257
8258
  schema
8258
8259
  } = props;
8259
8260
  const isAlbertaAddress = ((_b = (_a = schema === null || schema === void 0 ? void 0 : schema.properties) === null || _a === void 0 ? void 0 : _a.subdivisionCode) === null || _b === void 0 ? void 0 : _b.const) === 'AB';
8260
- return jsx("div", {
8261
- children: jsx(AddressViews, {
8262
- data: data,
8263
- isAlbertaAddress: isAlbertaAddress
8264
- })
8261
+ return jsx(AddressViews, {
8262
+ data: data,
8263
+ isAlbertaAddress: isAlbertaAddress
8265
8264
  });
8266
8265
  };
8267
8266
 
@@ -8377,30 +8376,44 @@ const NameInputs = ({
8377
8376
  };
8378
8377
 
8379
8378
  const FullNameReviewControl = props => {
8380
- var _a, _b, _c;
8379
+ var _a, _b, _c, _d, _e;
8381
8380
  const requiredFields = props.schema.required;
8381
+ const [errors, setErrors] = useState({});
8382
+ useEffect(() => {
8383
+ var _a, _b;
8384
+ const err = {};
8385
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) && !((_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName)) {
8386
+ err['firstName'] = `First name is required`;
8387
+ }
8388
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) && !((_b = props.data) === null || _b === void 0 ? void 0 : _b.lastName)) {
8389
+ err['lastName'] = `Last name is required`;
8390
+ }
8391
+ setErrors(err);
8392
+ }, [props.data, requiredFields]);
8382
8393
  return jsxs(GoAGrid, {
8383
8394
  minChildWidth: "0ch",
8384
8395
  gap: "s",
8385
8396
  children: [jsx(GoAFormItem, {
8386
8397
  label: "First Name",
8387
8398
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) ? 'required' : undefined,
8399
+ error: (_a = errors === null || errors === void 0 ? void 0 : errors['firstName']) !== null && _a !== void 0 ? _a : '',
8388
8400
  children: jsx("div", {
8389
8401
  "data-testid": `firstName-control-${props.id}`,
8390
- children: (_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName
8402
+ children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.firstName
8391
8403
  })
8392
8404
  }), jsx(GoAFormItem, {
8393
8405
  label: "Middle Name",
8394
8406
  children: jsx("div", {
8395
8407
  "data-testid": `middleName-control-${props.id}`,
8396
- children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.middleName
8408
+ children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.middleName
8397
8409
  })
8398
8410
  }), jsx(GoAFormItem, {
8399
8411
  label: "Last Name",
8400
8412
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) ? 'required' : undefined,
8413
+ error: (_d = errors === null || errors === void 0 ? void 0 : errors['lastName']) !== null && _d !== void 0 ? _d : '',
8401
8414
  children: jsx("div", {
8402
8415
  "data-testid": `lastName-control-${props.id}`,
8403
- children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.lastName
8416
+ children: (_e = props.data) === null || _e === void 0 ? void 0 : _e.lastName
8404
8417
  })
8405
8418
  })]
8406
8419
  });
@@ -8491,6 +8504,7 @@ const FullNameDobControl = props => {
8491
8504
  };
8492
8505
  const [formData, setFormData] = useState(data || defaultNameAndDob);
8493
8506
  const updateFormData = updatedData => {
8507
+ updatedData = Object.fromEntries(Object.entries(updatedData).filter(([_, value]) => value !== ''));
8494
8508
  handleChange(path, updatedData);
8495
8509
  };
8496
8510
  const handleInputChange = (field, value) => {
@@ -8499,7 +8513,6 @@ const FullNameDobControl = props => {
8499
8513
  });
8500
8514
  setFormData(updatedData);
8501
8515
  updateFormData(updatedData);
8502
- handleRequiredFieldBlur(field, updatedData);
8503
8516
  };
8504
8517
  const handleDobChange = (field, value) => {
8505
8518
  const updatedData = Object.assign(Object.assign({}, formData), {
@@ -8536,7 +8549,6 @@ const FullNameDobControl = props => {
8536
8549
  value: formData.firstName || '',
8537
8550
  onChange: (name, value) => {
8538
8551
  handleInputChange(name, value);
8539
- handleRequiredFieldBlur(name);
8540
8552
  },
8541
8553
  onBlur: name => {
8542
8554
  /* istanbul ignore next */
@@ -8603,8 +8615,23 @@ const FullNameDobControl = props => {
8603
8615
  };
8604
8616
 
8605
8617
  const FullNameDobReviewControl = props => {
8606
- var _a, _b, _c, _d;
8618
+ var _a, _b, _c, _d, _e, _f, _g;
8607
8619
  const requiredFields = props.schema.required;
8620
+ const [errors, setErrors] = useState({});
8621
+ useEffect(() => {
8622
+ var _a, _b, _c;
8623
+ const err = {};
8624
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) && !((_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName)) {
8625
+ err['firstName'] = `First name is required`;
8626
+ }
8627
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) && !((_b = props.data) === null || _b === void 0 ? void 0 : _b.lastName)) {
8628
+ err['lastName'] = `Last name is required`;
8629
+ }
8630
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('dateOfBirth')) && !((_c = props.data) === null || _c === void 0 ? void 0 : _c.dateOfBirth)) {
8631
+ err['dateOfBirth'] = `Date of birth is required`;
8632
+ }
8633
+ setErrors(err);
8634
+ }, [props.data, requiredFields]);
8608
8635
  return jsxs(Fragment, {
8609
8636
  children: [jsxs(GoAGrid, {
8610
8637
  minChildWidth: "0ch",
@@ -8612,22 +8639,24 @@ const FullNameDobReviewControl = props => {
8612
8639
  children: [jsx(GoAFormItem, {
8613
8640
  label: "First name",
8614
8641
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) ? 'required' : undefined,
8642
+ error: (_a = errors === null || errors === void 0 ? void 0 : errors['firstName']) !== null && _a !== void 0 ? _a : '',
8615
8643
  children: jsx("div", {
8616
8644
  "data-testid": `firstName-control-${props.id}`,
8617
- children: (_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName
8645
+ children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.firstName
8618
8646
  })
8619
8647
  }), jsx(GoAFormItem, {
8620
8648
  label: "Middle name",
8621
8649
  children: jsx("div", {
8622
8650
  "data-testid": `middleName-control-${props.id}`,
8623
- children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.middleName
8651
+ children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.middleName
8624
8652
  })
8625
8653
  }), jsx(GoAFormItem, {
8626
8654
  label: "Last name",
8627
8655
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) ? 'required' : undefined,
8656
+ error: (_d = errors === null || errors === void 0 ? void 0 : errors['lastName']) !== null && _d !== void 0 ? _d : '',
8628
8657
  children: jsx("div", {
8629
8658
  "data-testid": `lastName-control-${props.id}`,
8630
- children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.lastName
8659
+ children: (_e = props.data) === null || _e === void 0 ? void 0 : _e.lastName
8631
8660
  })
8632
8661
  })]
8633
8662
  }), jsx(GoAGrid, {
@@ -8636,9 +8665,10 @@ const FullNameDobReviewControl = props => {
8636
8665
  children: jsx(GoAFormItem, {
8637
8666
  label: "Date of birth",
8638
8667
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('dateOfBirth')) ? 'required' : undefined,
8668
+ error: (_f = errors === null || errors === void 0 ? void 0 : errors['dateOfBirth']) !== null && _f !== void 0 ? _f : '',
8639
8669
  children: jsx("div", {
8640
8670
  "data-testid": `dob-control-${props.id}`,
8641
- children: (_d = props.data) === null || _d === void 0 ? void 0 : _d.dateOfBirth
8671
+ children: (_g = props.data) === null || _g === void 0 ? void 0 : _g.dateOfBirth
8642
8672
  })
8643
8673
  })
8644
8674
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.42.4",
3
+ "version": "1.42.6",
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",