@abgov/jsonforms-components 1.42.7 → 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.
Files changed (2) hide show
  1. package/index.esm.js +12 -31
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -7600,12 +7600,12 @@ const AddressInputs = ({
7600
7600
  readonly: readOnly,
7601
7601
  value: (address === null || address === void 0 ? void 0 : address.municipality) || '',
7602
7602
  onChange: (name, value) => handleInputChange(name, value),
7603
- onBlur: (name, value) => handleOnBlur(name),
7603
+ onBlur: name => handleOnBlur(name),
7604
7604
  width: "100%"
7605
7605
  })
7606
7606
  }), jsx(GoAFormItem, {
7607
- label: "Postal Code",
7608
- 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 : '',
7609
7609
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('postalCode')) ? 'required' : 'optional',
7610
7610
  children: jsx(GoAInput, {
7611
7611
  name: "postalCode",
@@ -7616,7 +7616,7 @@ const AddressInputs = ({
7616
7616
  placeholder: "A0A 0A0",
7617
7617
  value: (address === null || address === void 0 ? void 0 : address.postalCode) || '',
7618
7618
  onChange: (name, value) => handleInputChange(name, value),
7619
- onBlur: (name, value) => handleOnBlur(name),
7619
+ onBlur: name => handleOnBlur(name),
7620
7620
  width: "100%",
7621
7621
  maxLength: 7
7622
7622
  })
@@ -7745,6 +7745,8 @@ const handlePostalCodeValidation = (validatePc, message, value, errors) => {
7745
7745
  const newErrors = Object.assign({}, errors);
7746
7746
  if (!validatePc && value.length >= 4) {
7747
7747
  newErrors['postalCode'] = message;
7748
+ } else if (value.length === 0) {
7749
+ newErrors['postalCode'] = 'Postal Code is required.';
7748
7750
  } else {
7749
7751
  delete newErrors['postalCode'];
7750
7752
  }
@@ -8024,7 +8026,7 @@ const AddressLookUpControl = props => {
8024
8026
  }
8025
8027
  });
8026
8028
  fetchSuggestions();
8027
- }, [searchTerm, formUrl, isAlbertaAddress]);
8029
+ }, [searchTerm]);
8028
8030
  const handleDropdownChange = value => {
8029
8031
  setSearchTerm(value);
8030
8032
  handleInputChange('addressLine1', value);
@@ -8039,47 +8041,26 @@ const AddressLookUpControl = props => {
8039
8041
  /* istanbul ignore next */
8040
8042
  const handleRequiredFieldBlur = name => {
8041
8043
  const err = Object.assign({}, errors);
8042
- if ((data === null || data === void 0 ? void 0 : data['city']) === undefined || (data === null || data === void 0 ? void 0 : data['city']) === '') {
8043
- err[name] = name === 'municipality' ? 'city is required' : '';
8044
- setErrors(err);
8045
- }
8046
8044
  if (!(data === null || data === void 0 ? void 0 : data[name]) || data[name] === '' || (data === null || data === void 0 ? void 0 : data[name]) === undefined) {
8047
8045
  err[name] = name === 'municipality' ? 'city is required' : `${name} is required`;
8048
8046
  setErrors(err);
8049
- }
8050
- if (!(data === null || data === void 0 ? void 0 : data[name])) {
8051
- err[name] = name === 'addressLine1' ? `${name} is required` : ``;
8052
- setErrors(err);
8053
8047
  } else {
8054
8048
  delete errors[name];
8055
8049
  }
8056
- setTimeout(() => {
8057
- setSuggestions([]);
8058
- setOpen(false);
8059
- }, 100);
8050
+ setSuggestions([]);
8051
+ setOpen(false);
8060
8052
  };
8061
- useEffect(() => {
8062
- if (dropdownRef.current) {
8063
- const selectedItem = dropdownRef.current.children[selectedIndex];
8064
- if (selectedItem) {
8065
- selectedItem.scrollIntoView({
8066
- block: 'nearest',
8067
- behavior: 'smooth'
8068
- });
8069
- }
8070
- }
8071
- }, [selectedIndex, open]);
8072
8053
  /* istanbul ignore next */
8073
8054
  const handleKeyDown = (e, value, key) => {
8074
8055
  var _a;
8075
8056
  if (key === 'ArrowDown') {
8076
8057
  setSelectedIndex(prevIndex => prevIndex < suggestions.length - 1 ? prevIndex + 1 : 0);
8077
- handleDropdownChange(value);
8058
+ handleInputChange('addressLine1', value);
8078
8059
  } else if (key === 'ArrowUp') {
8079
8060
  setSelectedIndex(prevIndex => prevIndex > 0 ? prevIndex - 1 : suggestions.length - 1);
8080
- handleDropdownChange(value);
8061
+ handleInputChange('addressLine1', value);
8081
8062
  } else if (key === 'Enter' || key === ' ' && value.length > 2) {
8082
- handleDropdownChange(value);
8063
+ handleInputChange('addressLine1', value);
8083
8064
  setLoading(false);
8084
8065
  if (selectedIndex >= 0) {
8085
8066
  (_a = document.getElementById('goaInput')) === null || _a === void 0 ? void 0 : _a.blur();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.42.7",
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",