@abgov/jsonforms-components 1.42.5 → 1.42.7

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
@@ -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
  })
@@ -4435,7 +4435,7 @@ let _$7 = t => t,
4435
4435
  _t$7,
4436
4436
  _t2$4,
4437
4437
  _t3$4,
4438
- _t4$2;
4438
+ _t4$3;
4439
4439
  const GoADropdownTextbox = styled.div(_t$7 || (_t$7 = _$7`
4440
4440
  border-radius: var(--goa-space-2xs);
4441
4441
  box-shadow: ${0};
@@ -4475,7 +4475,7 @@ const GoADropdownListContainer = styled.div(_t3$4 || (_t3$4 = _$7`
4475
4475
  scrollbar-color: #a8a8a8 var(--goa-color-greyscale-100) !important;
4476
4476
  }
4477
4477
  `), p => p.optionListMaxHeight || '272px');
4478
- const GoADropdownListOption = styled.div(_t4$2 || (_t4$2 = _$7`
4478
+ const GoADropdownListOption = styled.div(_t4$3 || (_t4$3 = _$7`
4479
4479
  padding: var(--goa-space-2xs) var(--goa-space-s);
4480
4480
  text-overflow: ellipsis;
4481
4481
  color: ${0} !important;
@@ -5118,7 +5118,7 @@ let _$5 = t => t,
5118
5118
  _t$5,
5119
5119
  _t2$3,
5120
5120
  _t3$3,
5121
- _t4$1,
5121
+ _t4$2,
5122
5122
  _t5$1,
5123
5123
  _t6$1,
5124
5124
  _t7$1,
@@ -5149,7 +5149,7 @@ const ReviewItemHeader = styled.div(_t3$3 || (_t3$3 = _$5`
5149
5149
  justify-content: space-between;
5150
5150
  margin-bottom: 2rem;
5151
5151
  `));
5152
- const ReviewItemTitle = styled.div(_t4$1 || (_t4$1 = _$5`
5152
+ const ReviewItemTitle = styled.div(_t4$2 || (_t4$2 = _$5`
5153
5153
  font-size: var(--fs-xl);
5154
5154
  line-height: var(--lh-lg);
5155
5155
  font-weight: var(--fw-light);
@@ -5673,7 +5673,7 @@ const FormStepper = props => {
5673
5673
  const categoryLabels = [...allCategories.elements.map(category => category.label), summaryLabel];
5674
5674
  const visibleLabels = [...visibleCategoryLabels, summaryLabel];
5675
5675
  const newPage = mapToVisibleStep(page, categoryLabels, visibleLabels);
5676
- const pageStatus = getCompletionStatus(inputStatuses, page);
5676
+ const pageStatus = getCompletionStatus(inputStatuses, page, true);
5677
5677
  const statuses = [...stepStatuses];
5678
5678
  statuses[page - 1] = pageStatus ? pageStatus : 'incomplete';
5679
5679
  setStepStatuses(statuses);
@@ -6312,7 +6312,7 @@ let _$2 = t => t,
6312
6312
  _t$2,
6313
6313
  _t2$1,
6314
6314
  _t3$1,
6315
- _t4,
6315
+ _t4$1,
6316
6316
  _t5,
6317
6317
  _t6,
6318
6318
  _t7,
@@ -6333,7 +6333,7 @@ const NonEmptyCellStyle = styled.div(_t2$1 || (_t2$1 = _$2`
6333
6333
  const ToolBarHeader = styled.div(_t3$1 || (_t3$1 = _$2`
6334
6334
  margin-bottom: var(--goa-space-l);
6335
6335
  `));
6336
- const ObjectArrayTitle = styled.h2(_t4 || (_t4 = _$2`
6336
+ const ObjectArrayTitle = styled.h2(_t4$1 || (_t4$1 = _$2`
6337
6337
  margin-bottom: var(--goa-space-l);
6338
6338
  `));
6339
6339
  const TextCenter = styled.div(_t5 || (_t5 = _$2`
@@ -7466,7 +7466,8 @@ const GoAListWithDetailsTester = rankWith(3, and(uiTypeIs('ListWithDetail')));
7466
7466
  let _$1 = t => t,
7467
7467
  _t$1,
7468
7468
  _t2,
7469
- _t3;
7469
+ _t3,
7470
+ _t4;
7470
7471
  const SearchBox = styled.div(_t$1 || (_t$1 = _$1`
7471
7472
  position: relative;
7472
7473
 
@@ -7498,11 +7499,14 @@ const SearchBox = styled.div(_t$1 || (_t$1 = _$1`
7498
7499
  font-weight: var(--fw-bold);
7499
7500
  }
7500
7501
  `));
7501
- const LabelDiv = styled.div(_t2 || (_t2 = _$1`
7502
+ const AddressIndent = styled.div(_t2 || (_t2 = _$1`
7503
+ margin: 1em 1.5em 0 1.5em;
7504
+ `));
7505
+ const LabelDiv = styled.div(_t3 || (_t3 = _$1`
7502
7506
  font-size: var(--fs-sl);
7503
7507
  padding-bottom: 1.5rem;
7504
7508
  `));
7505
- const ListItem = styled.li(_t3 || (_t3 = _$1`
7509
+ const ListItem = styled.li(_t4 || (_t4 = _$1`
7506
7510
  background-color: ${0};
7507
7511
  color: ${0};
7508
7512
  font-weight: ${0};
@@ -8197,55 +8201,63 @@ const AddressViews = ({
8197
8201
  label: 'Yukon'
8198
8202
  }];
8199
8203
  return jsxs(Fragment, {
8200
- children: [jsxs(GoAGrid, {
8204
+ children: [jsx(GoAGrid, {
8201
8205
  minChildWidth: "0",
8202
8206
  gap: "s",
8203
- children: [jsx(GoAFormItem, {
8204
- error: ((_a = data === null || data === void 0 ? void 0 : data.addressLine1) === null || _a === void 0 ? void 0 : _a.length) === 0 ? 'addressLine1 is required' : '',
8205
- label: `${isAlbertaAddress ? 'Alberta p' : 'Canada p'}ostal address`,
8206
- children: jsx("p", {
8207
- children: data === null || data === void 0 ? void 0 : data.addressLine1
8208
- })
8209
- }), (data === null || data === void 0 ? void 0 : data.addressLine2) && jsx(GoAFormItem, {
8210
- label: "Address line 2",
8211
- children: jsx("p", {
8212
- children: data.addressLine2
8213
- })
8214
- })]
8215
- }), jsx("br", {}), jsxs(GoAGrid, {
8216
- minChildWidth: "0ch",
8217
- gap: "s",
8218
- children: [jsx(GoAFormItem, {
8219
- error: ((_b = data === null || data === void 0 ? void 0 : data.municipality) === null || _b === void 0 ? void 0 : _b.length) === 0 ? 'city is required' : '',
8220
- label: "City",
8221
- children: jsx("p", {
8222
- children: data === null || data === void 0 ? void 0 : data.municipality
8223
- })
8224
- }), jsx(GoAFormItem, {
8225
- error: ((_c = data === null || data === void 0 ? void 0 : data.postalCode) === null || _c === void 0 ? void 0 : _c.length) === 0 ? 'postalCode is required' : '',
8226
- label: "Postal Code",
8227
- children: jsx("p", {
8228
- children: data === null || data === void 0 ? void 0 : data.postalCode
8229
- })
8230
- })]
8231
- }), jsx("br", {}), jsxs(GoAGrid, {
8232
- minChildWidth: "0",
8233
- gap: "s",
8234
- children: [jsxs(GoAFormItem, {
8235
- label: "Province",
8236
- children: [isAlbertaAddress && jsx("div", {
8237
- "data-testid": "address-form-province-view",
8238
- children: "Alberta"
8239
- }), !isAlbertaAddress && jsx("div", {
8240
- "data-testid": "address-form-province-view",
8241
- children: (_d = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.subdivisionCode))) === null || _d === void 0 ? void 0 : _d.label
8207
+ children: jsx(GoAFormItem, {
8208
+ label: `${isAlbertaAddress ? 'Alberta' : 'Canada'} postal address`
8209
+ })
8210
+ }), jsxs(AddressIndent, {
8211
+ children: [jsxs(GoAGrid, {
8212
+ minChildWidth: "0",
8213
+ gap: "s",
8214
+ children: [jsx(GoAFormItem, {
8215
+ label: "Address line 1",
8216
+ error: ((_a = data === null || data === void 0 ? void 0 : data.addressLine1) === null || _a === void 0 ? void 0 : _a.length) === 0 ? 'addressLine1 is required' : '',
8217
+ children: jsx("p", {
8218
+ children: data === null || data === void 0 ? void 0 : data.addressLine1
8219
+ })
8220
+ }), (data === null || data === void 0 ? void 0 : data.addressLine2) && jsx(GoAFormItem, {
8221
+ label: "Address line 2",
8222
+ children: jsx("p", {
8223
+ children: data.addressLine2
8224
+ })
8225
+ })]
8226
+ }), jsx("br", {}), jsxs(GoAGrid, {
8227
+ minChildWidth: "0ch",
8228
+ gap: "s",
8229
+ children: [jsx(GoAFormItem, {
8230
+ error: ((_b = data === null || data === void 0 ? void 0 : data.municipality) === null || _b === void 0 ? void 0 : _b.length) === 0 ? 'city is required' : '',
8231
+ label: "City",
8232
+ children: jsx("p", {
8233
+ children: data === null || data === void 0 ? void 0 : data.municipality
8234
+ })
8235
+ }), jsx(GoAFormItem, {
8236
+ error: ((_c = data === null || data === void 0 ? void 0 : data.postalCode) === null || _c === void 0 ? void 0 : _c.length) === 0 ? 'postalCode is required' : '',
8237
+ label: "Postal Code",
8238
+ children: jsx("p", {
8239
+ children: data === null || data === void 0 ? void 0 : data.postalCode
8240
+ })
8241
+ })]
8242
+ }), jsx("br", {}), jsxs(GoAGrid, {
8243
+ minChildWidth: "0",
8244
+ gap: "s",
8245
+ children: [jsxs(GoAFormItem, {
8246
+ label: "Province",
8247
+ children: [isAlbertaAddress && jsx("div", {
8248
+ "data-testid": "address-form-province-view",
8249
+ children: "Alberta"
8250
+ }), !isAlbertaAddress && jsx("div", {
8251
+ "data-testid": "address-form-province-view",
8252
+ children: (_d = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.subdivisionCode))) === null || _d === void 0 ? void 0 : _d.label
8253
+ })]
8254
+ }), jsx(GoAFormItem, {
8255
+ label: "Country",
8256
+ children: jsx("div", {
8257
+ "data-testid": "address-form-country",
8258
+ children: "Canada"
8259
+ })
8242
8260
  })]
8243
- }), jsx(GoAFormItem, {
8244
- label: "Country",
8245
- children: jsx("div", {
8246
- "data-testid": "address-form-country",
8247
- children: "Canada"
8248
- })
8249
8261
  })]
8250
8262
  }), jsx("br", {}), jsx("br", {})]
8251
8263
  });
@@ -8258,11 +8270,9 @@ const AddressLookUpControlReview = props => {
8258
8270
  schema
8259
8271
  } = props;
8260
8272
  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';
8261
- return jsx("div", {
8262
- children: jsx(AddressViews, {
8263
- data: data,
8264
- isAlbertaAddress: isAlbertaAddress
8265
- })
8273
+ return jsx(AddressViews, {
8274
+ data: data,
8275
+ isAlbertaAddress: isAlbertaAddress
8266
8276
  });
8267
8277
  };
8268
8278
 
@@ -8378,30 +8388,44 @@ const NameInputs = ({
8378
8388
  };
8379
8389
 
8380
8390
  const FullNameReviewControl = props => {
8381
- var _a, _b, _c;
8391
+ var _a, _b, _c, _d, _e;
8382
8392
  const requiredFields = props.schema.required;
8393
+ const [errors, setErrors] = useState({});
8394
+ useEffect(() => {
8395
+ var _a, _b;
8396
+ const err = {};
8397
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) && !((_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName)) {
8398
+ err['firstName'] = `First name is required`;
8399
+ }
8400
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) && !((_b = props.data) === null || _b === void 0 ? void 0 : _b.lastName)) {
8401
+ err['lastName'] = `Last name is required`;
8402
+ }
8403
+ setErrors(err);
8404
+ }, [props.data, requiredFields]);
8383
8405
  return jsxs(GoAGrid, {
8384
8406
  minChildWidth: "0ch",
8385
8407
  gap: "s",
8386
8408
  children: [jsx(GoAFormItem, {
8387
8409
  label: "First Name",
8388
8410
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) ? 'required' : undefined,
8411
+ error: (_a = errors === null || errors === void 0 ? void 0 : errors['firstName']) !== null && _a !== void 0 ? _a : '',
8389
8412
  children: jsx("div", {
8390
8413
  "data-testid": `firstName-control-${props.id}`,
8391
- children: (_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName
8414
+ children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.firstName
8392
8415
  })
8393
8416
  }), jsx(GoAFormItem, {
8394
8417
  label: "Middle Name",
8395
8418
  children: jsx("div", {
8396
8419
  "data-testid": `middleName-control-${props.id}`,
8397
- children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.middleName
8420
+ children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.middleName
8398
8421
  })
8399
8422
  }), jsx(GoAFormItem, {
8400
8423
  label: "Last Name",
8401
8424
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) ? 'required' : undefined,
8425
+ error: (_d = errors === null || errors === void 0 ? void 0 : errors['lastName']) !== null && _d !== void 0 ? _d : '',
8402
8426
  children: jsx("div", {
8403
8427
  "data-testid": `lastName-control-${props.id}`,
8404
- children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.lastName
8428
+ children: (_e = props.data) === null || _e === void 0 ? void 0 : _e.lastName
8405
8429
  })
8406
8430
  })]
8407
8431
  });
@@ -8492,6 +8516,7 @@ const FullNameDobControl = props => {
8492
8516
  };
8493
8517
  const [formData, setFormData] = useState(data || defaultNameAndDob);
8494
8518
  const updateFormData = updatedData => {
8519
+ updatedData = Object.fromEntries(Object.entries(updatedData).filter(([_, value]) => value !== ''));
8495
8520
  handleChange(path, updatedData);
8496
8521
  };
8497
8522
  const handleInputChange = (field, value) => {
@@ -8500,7 +8525,6 @@ const FullNameDobControl = props => {
8500
8525
  });
8501
8526
  setFormData(updatedData);
8502
8527
  updateFormData(updatedData);
8503
- handleRequiredFieldBlur(field, updatedData);
8504
8528
  };
8505
8529
  const handleDobChange = (field, value) => {
8506
8530
  const updatedData = Object.assign(Object.assign({}, formData), {
@@ -8537,7 +8561,6 @@ const FullNameDobControl = props => {
8537
8561
  value: formData.firstName || '',
8538
8562
  onChange: (name, value) => {
8539
8563
  handleInputChange(name, value);
8540
- handleRequiredFieldBlur(name);
8541
8564
  },
8542
8565
  onBlur: name => {
8543
8566
  /* istanbul ignore next */
@@ -8604,8 +8627,23 @@ const FullNameDobControl = props => {
8604
8627
  };
8605
8628
 
8606
8629
  const FullNameDobReviewControl = props => {
8607
- var _a, _b, _c, _d;
8630
+ var _a, _b, _c, _d, _e, _f, _g;
8608
8631
  const requiredFields = props.schema.required;
8632
+ const [errors, setErrors] = useState({});
8633
+ useEffect(() => {
8634
+ var _a, _b, _c;
8635
+ const err = {};
8636
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) && !((_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName)) {
8637
+ err['firstName'] = `First name is required`;
8638
+ }
8639
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) && !((_b = props.data) === null || _b === void 0 ? void 0 : _b.lastName)) {
8640
+ err['lastName'] = `Last name is required`;
8641
+ }
8642
+ if ((requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('dateOfBirth')) && !((_c = props.data) === null || _c === void 0 ? void 0 : _c.dateOfBirth)) {
8643
+ err['dateOfBirth'] = `Date of birth is required`;
8644
+ }
8645
+ setErrors(err);
8646
+ }, [props.data, requiredFields]);
8609
8647
  return jsxs(Fragment, {
8610
8648
  children: [jsxs(GoAGrid, {
8611
8649
  minChildWidth: "0ch",
@@ -8613,22 +8651,24 @@ const FullNameDobReviewControl = props => {
8613
8651
  children: [jsx(GoAFormItem, {
8614
8652
  label: "First name",
8615
8653
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('firstName')) ? 'required' : undefined,
8654
+ error: (_a = errors === null || errors === void 0 ? void 0 : errors['firstName']) !== null && _a !== void 0 ? _a : '',
8616
8655
  children: jsx("div", {
8617
8656
  "data-testid": `firstName-control-${props.id}`,
8618
- children: (_a = props.data) === null || _a === void 0 ? void 0 : _a.firstName
8657
+ children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.firstName
8619
8658
  })
8620
8659
  }), jsx(GoAFormItem, {
8621
8660
  label: "Middle name",
8622
8661
  children: jsx("div", {
8623
8662
  "data-testid": `middleName-control-${props.id}`,
8624
- children: (_b = props.data) === null || _b === void 0 ? void 0 : _b.middleName
8663
+ children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.middleName
8625
8664
  })
8626
8665
  }), jsx(GoAFormItem, {
8627
8666
  label: "Last name",
8628
8667
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('lastName')) ? 'required' : undefined,
8668
+ error: (_d = errors === null || errors === void 0 ? void 0 : errors['lastName']) !== null && _d !== void 0 ? _d : '',
8629
8669
  children: jsx("div", {
8630
8670
  "data-testid": `lastName-control-${props.id}`,
8631
- children: (_c = props.data) === null || _c === void 0 ? void 0 : _c.lastName
8671
+ children: (_e = props.data) === null || _e === void 0 ? void 0 : _e.lastName
8632
8672
  })
8633
8673
  })]
8634
8674
  }), jsx(GoAGrid, {
@@ -8637,9 +8677,10 @@ const FullNameDobReviewControl = props => {
8637
8677
  children: jsx(GoAFormItem, {
8638
8678
  label: "Date of birth",
8639
8679
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('dateOfBirth')) ? 'required' : undefined,
8680
+ error: (_f = errors === null || errors === void 0 ? void 0 : errors['dateOfBirth']) !== null && _f !== void 0 ? _f : '',
8640
8681
  children: jsx("div", {
8641
8682
  "data-testid": `dob-control-${props.id}`,
8642
- children: (_d = props.data) === null || _d === void 0 ? void 0 : _d.dateOfBirth
8683
+ children: (_g = props.data) === null || _g === void 0 ? void 0 : _g.dateOfBirth
8643
8684
  })
8644
8685
  })
8645
8686
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.42.5",
3
+ "version": "1.42.7",
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,6 +4,7 @@ interface ListItemProps {
4
4
  index: number;
5
5
  }
6
6
  export declare const SearchBox: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
+ export declare const AddressIndent: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
7
8
  export declare const LabelDiv: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
8
9
  export declare const ListItem: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, ListItemProps>> & string;
9
10
  export {};