@abgov/jsonforms-components 1.42.6 → 1.42.8

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
@@ -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);
@@ -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};
@@ -7596,12 +7600,12 @@ const AddressInputs = ({
7596
7600
  readonly: readOnly,
7597
7601
  value: (address === null || address === void 0 ? void 0 : address.municipality) || '',
7598
7602
  onChange: (name, value) => handleInputChange(name, value),
7599
- onBlur: (name, value) => handleOnBlur(name),
7603
+ onBlur: name => handleOnBlur(name),
7600
7604
  width: "100%"
7601
7605
  })
7602
7606
  }), jsx(GoAFormItem, {
7603
- label: "Postal Code",
7604
- error: (_b = errors === null || errors === void 0 ? void 0 : errors['postalCode']) !== null && _b !== void 0 ? _b : '',
7607
+ label: "Postal code",
7608
+ error: (_b = errors === null || errors === void 0 ? void 0 : errors.postalCode) !== null && _b !== void 0 ? _b : '',
7605
7609
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('postalCode')) ? 'required' : 'optional',
7606
7610
  children: jsx(GoAInput, {
7607
7611
  name: "postalCode",
@@ -7612,7 +7616,7 @@ const AddressInputs = ({
7612
7616
  placeholder: "A0A 0A0",
7613
7617
  value: (address === null || address === void 0 ? void 0 : address.postalCode) || '',
7614
7618
  onChange: (name, value) => handleInputChange(name, value),
7615
- onBlur: (name, value) => handleOnBlur(name),
7619
+ onBlur: name => handleOnBlur(name),
7616
7620
  width: "100%",
7617
7621
  maxLength: 7
7618
7622
  })
@@ -7741,6 +7745,8 @@ const handlePostalCodeValidation = (validatePc, message, value, errors) => {
7741
7745
  const newErrors = Object.assign({}, errors);
7742
7746
  if (!validatePc && value.length >= 4) {
7743
7747
  newErrors['postalCode'] = message;
7748
+ } else if (value.length === 0) {
7749
+ newErrors['postalCode'] = 'Postal Code is required.';
7744
7750
  } else {
7745
7751
  delete newErrors['postalCode'];
7746
7752
  }
@@ -8020,7 +8026,7 @@ const AddressLookUpControl = props => {
8020
8026
  }
8021
8027
  });
8022
8028
  fetchSuggestions();
8023
- }, [searchTerm, formUrl, isAlbertaAddress]);
8029
+ }, [searchTerm]);
8024
8030
  const handleDropdownChange = value => {
8025
8031
  setSearchTerm(value);
8026
8032
  handleInputChange('addressLine1', value);
@@ -8035,47 +8041,26 @@ const AddressLookUpControl = props => {
8035
8041
  /* istanbul ignore next */
8036
8042
  const handleRequiredFieldBlur = name => {
8037
8043
  const err = Object.assign({}, errors);
8038
- if ((data === null || data === void 0 ? void 0 : data['city']) === undefined || (data === null || data === void 0 ? void 0 : data['city']) === '') {
8039
- err[name] = name === 'municipality' ? 'city is required' : '';
8040
- setErrors(err);
8041
- }
8042
8044
  if (!(data === null || data === void 0 ? void 0 : data[name]) || data[name] === '' || (data === null || data === void 0 ? void 0 : data[name]) === undefined) {
8043
8045
  err[name] = name === 'municipality' ? 'city is required' : `${name} is required`;
8044
8046
  setErrors(err);
8045
- }
8046
- if (!(data === null || data === void 0 ? void 0 : data[name])) {
8047
- err[name] = name === 'addressLine1' ? `${name} is required` : ``;
8048
- setErrors(err);
8049
8047
  } else {
8050
8048
  delete errors[name];
8051
8049
  }
8052
- setTimeout(() => {
8053
- setSuggestions([]);
8054
- setOpen(false);
8055
- }, 100);
8050
+ setSuggestions([]);
8051
+ setOpen(false);
8056
8052
  };
8057
- useEffect(() => {
8058
- if (dropdownRef.current) {
8059
- const selectedItem = dropdownRef.current.children[selectedIndex];
8060
- if (selectedItem) {
8061
- selectedItem.scrollIntoView({
8062
- block: 'nearest',
8063
- behavior: 'smooth'
8064
- });
8065
- }
8066
- }
8067
- }, [selectedIndex, open]);
8068
8053
  /* istanbul ignore next */
8069
8054
  const handleKeyDown = (e, value, key) => {
8070
8055
  var _a;
8071
8056
  if (key === 'ArrowDown') {
8072
8057
  setSelectedIndex(prevIndex => prevIndex < suggestions.length - 1 ? prevIndex + 1 : 0);
8073
- handleDropdownChange(value);
8058
+ handleInputChange('addressLine1', value);
8074
8059
  } else if (key === 'ArrowUp') {
8075
8060
  setSelectedIndex(prevIndex => prevIndex > 0 ? prevIndex - 1 : suggestions.length - 1);
8076
- handleDropdownChange(value);
8061
+ handleInputChange('addressLine1', value);
8077
8062
  } else if (key === 'Enter' || key === ' ' && value.length > 2) {
8078
- handleDropdownChange(value);
8063
+ handleInputChange('addressLine1', value);
8079
8064
  setLoading(false);
8080
8065
  if (selectedIndex >= 0) {
8081
8066
  (_a = document.getElementById('goaInput')) === null || _a === void 0 ? void 0 : _a.blur();
@@ -8197,55 +8182,63 @@ const AddressViews = ({
8197
8182
  label: 'Yukon'
8198
8183
  }];
8199
8184
  return jsxs(Fragment, {
8200
- children: [jsxs(GoAGrid, {
8185
+ children: [jsx(GoAGrid, {
8201
8186
  minChildWidth: "0",
8202
8187
  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' : 'Canada'} postal 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
8188
+ children: jsx(GoAFormItem, {
8189
+ label: `${isAlbertaAddress ? 'Alberta' : 'Canada'} postal address`
8190
+ })
8191
+ }), jsxs(AddressIndent, {
8192
+ children: [jsxs(GoAGrid, {
8193
+ minChildWidth: "0",
8194
+ gap: "s",
8195
+ children: [jsx(GoAFormItem, {
8196
+ label: "Address line 1",
8197
+ error: ((_a = data === null || data === void 0 ? void 0 : data.addressLine1) === null || _a === void 0 ? void 0 : _a.length) === 0 ? 'addressLine1 is required' : '',
8198
+ children: jsx("p", {
8199
+ children: data === null || data === void 0 ? void 0 : data.addressLine1
8200
+ })
8201
+ }), (data === null || data === void 0 ? void 0 : data.addressLine2) && jsx(GoAFormItem, {
8202
+ label: "Address line 2",
8203
+ children: jsx("p", {
8204
+ children: data.addressLine2
8205
+ })
8206
+ })]
8207
+ }), jsx("br", {}), jsxs(GoAGrid, {
8208
+ minChildWidth: "0ch",
8209
+ gap: "s",
8210
+ children: [jsx(GoAFormItem, {
8211
+ error: ((_b = data === null || data === void 0 ? void 0 : data.municipality) === null || _b === void 0 ? void 0 : _b.length) === 0 ? 'city is required' : '',
8212
+ label: "City",
8213
+ children: jsx("p", {
8214
+ children: data === null || data === void 0 ? void 0 : data.municipality
8215
+ })
8216
+ }), jsx(GoAFormItem, {
8217
+ error: ((_c = data === null || data === void 0 ? void 0 : data.postalCode) === null || _c === void 0 ? void 0 : _c.length) === 0 ? 'postalCode is required' : '',
8218
+ label: "Postal Code",
8219
+ children: jsx("p", {
8220
+ children: data === null || data === void 0 ? void 0 : data.postalCode
8221
+ })
8222
+ })]
8223
+ }), jsx("br", {}), jsxs(GoAGrid, {
8224
+ minChildWidth: "0",
8225
+ gap: "s",
8226
+ children: [jsxs(GoAFormItem, {
8227
+ label: "Province",
8228
+ children: [isAlbertaAddress && jsx("div", {
8229
+ "data-testid": "address-form-province-view",
8230
+ children: "Alberta"
8231
+ }), !isAlbertaAddress && jsx("div", {
8232
+ "data-testid": "address-form-province-view",
8233
+ children: (_d = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.subdivisionCode))) === null || _d === void 0 ? void 0 : _d.label
8234
+ })]
8235
+ }), jsx(GoAFormItem, {
8236
+ label: "Country",
8237
+ children: jsx("div", {
8238
+ "data-testid": "address-form-country",
8239
+ children: "Canada"
8240
+ })
8242
8241
  })]
8243
- }), jsx(GoAFormItem, {
8244
- label: "Country",
8245
- children: jsx("div", {
8246
- "data-testid": "address-form-country",
8247
- children: "Canada"
8248
- })
8249
8242
  })]
8250
8243
  }), jsx("br", {}), jsx("br", {})]
8251
8244
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.42.6",
3
+ "version": "1.42.8",
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 {};