@abgov/jsonforms-components 1.42.7 → 1.42.9

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 +19 -34
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -5597,6 +5597,7 @@ const FormStepper = props => {
5597
5597
  const componentProps = (_b = (_a = uischema.options) === null || _a === void 0 ? void 0 : _a.componentProps) !== null && _b !== void 0 ? _b : {};
5598
5598
  const optionProps = uischema.options || {};
5599
5599
  const [step, setStep] = React.useState(0);
5600
+ const [staleCategories, setStaleCategories] = React.useState(categorization.elements);
5600
5601
  const [isFormValid, setIsFormValid] = React.useState(false);
5601
5602
  const [showNextBtn, setShowNextBtn] = React.useState(true);
5602
5603
  const [isOpen, setIsOpen] = React.useState(false);
@@ -5639,6 +5640,9 @@ const FormStepper = props => {
5639
5640
  setStep((componentProps === null || componentProps === void 0 ? void 0 : componentProps.controlledNav) ? 1 : 0);
5640
5641
  // eslint-disable-next-line react-hooks/exhaustive-deps
5641
5642
  }, []);
5643
+ useEffect(() => {
5644
+ setStaleCategories(categories);
5645
+ }, [categories]);
5642
5646
  /* istanbul ignore next */
5643
5647
  if ((categories === null || categories === void 0 ? void 0 : categories.length) < 1) {
5644
5648
  // eslint-disable-next-line
@@ -5700,7 +5704,7 @@ const FormStepper = props => {
5700
5704
  children: jsxs("div", {
5701
5705
  id: `${path || `goa`}-form-stepper`,
5702
5706
  className: "formStepper",
5703
- children: [jsxs(GoAFormStepper, {
5707
+ children: [categories.length === staleCategories.length && jsxs(GoAFormStepper, {
5704
5708
  testId: ((_e = uischema === null || uischema === void 0 ? void 0 : uischema.options) === null || _e === void 0 ? void 0 : _e.testId) || 'form-stepper-test',
5705
5709
  step: step,
5706
5710
  onChange: step => {
@@ -7600,12 +7604,12 @@ const AddressInputs = ({
7600
7604
  readonly: readOnly,
7601
7605
  value: (address === null || address === void 0 ? void 0 : address.municipality) || '',
7602
7606
  onChange: (name, value) => handleInputChange(name, value),
7603
- onBlur: (name, value) => handleOnBlur(name),
7607
+ onBlur: name => handleOnBlur(name),
7604
7608
  width: "100%"
7605
7609
  })
7606
7610
  }), jsx(GoAFormItem, {
7607
- label: "Postal Code",
7608
- error: (_b = errors === null || errors === void 0 ? void 0 : errors['postalCode']) !== null && _b !== void 0 ? _b : '',
7611
+ label: "Postal code",
7612
+ error: (_b = errors === null || errors === void 0 ? void 0 : errors.postalCode) !== null && _b !== void 0 ? _b : '',
7609
7613
  requirement: (requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.includes('postalCode')) ? 'required' : 'optional',
7610
7614
  children: jsx(GoAInput, {
7611
7615
  name: "postalCode",
@@ -7616,7 +7620,7 @@ const AddressInputs = ({
7616
7620
  placeholder: "A0A 0A0",
7617
7621
  value: (address === null || address === void 0 ? void 0 : address.postalCode) || '',
7618
7622
  onChange: (name, value) => handleInputChange(name, value),
7619
- onBlur: (name, value) => handleOnBlur(name),
7623
+ onBlur: name => handleOnBlur(name),
7620
7624
  width: "100%",
7621
7625
  maxLength: 7
7622
7626
  })
@@ -7745,6 +7749,8 @@ const handlePostalCodeValidation = (validatePc, message, value, errors) => {
7745
7749
  const newErrors = Object.assign({}, errors);
7746
7750
  if (!validatePc && value.length >= 4) {
7747
7751
  newErrors['postalCode'] = message;
7752
+ } else if (value.length === 0) {
7753
+ newErrors['postalCode'] = 'Postal Code is required.';
7748
7754
  } else {
7749
7755
  delete newErrors['postalCode'];
7750
7756
  }
@@ -8006,7 +8012,7 @@ const AddressLookUpControl = props => {
8006
8012
  };
8007
8013
  useEffect(() => {
8008
8014
  const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
8009
- if (searchTerm.length > 2 && searchTerm.charAt(searchTerm.length - 1) !== ' ') {
8015
+ if (searchTerm.length > 2) {
8010
8016
  setLoading(true);
8011
8017
  setOpen(true);
8012
8018
  yield fetchAddressSuggestions(formUrl, searchTerm, isAlbertaAddress).then(response => {
@@ -8024,7 +8030,7 @@ const AddressLookUpControl = props => {
8024
8030
  }
8025
8031
  });
8026
8032
  fetchSuggestions();
8027
- }, [searchTerm, formUrl, isAlbertaAddress]);
8033
+ }, [searchTerm]);
8028
8034
  const handleDropdownChange = value => {
8029
8035
  setSearchTerm(value);
8030
8036
  handleInputChange('addressLine1', value);
@@ -8039,47 +8045,26 @@ const AddressLookUpControl = props => {
8039
8045
  /* istanbul ignore next */
8040
8046
  const handleRequiredFieldBlur = name => {
8041
8047
  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
8048
  if (!(data === null || data === void 0 ? void 0 : data[name]) || data[name] === '' || (data === null || data === void 0 ? void 0 : data[name]) === undefined) {
8047
8049
  err[name] = name === 'municipality' ? 'city is required' : `${name} is required`;
8048
8050
  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
8051
  } else {
8054
8052
  delete errors[name];
8055
8053
  }
8056
- setTimeout(() => {
8057
- setSuggestions([]);
8058
- setOpen(false);
8059
- }, 100);
8054
+ setSuggestions([]);
8055
+ setOpen(false);
8060
8056
  };
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
8057
  /* istanbul ignore next */
8073
8058
  const handleKeyDown = (e, value, key) => {
8074
8059
  var _a;
8075
8060
  if (key === 'ArrowDown') {
8076
8061
  setSelectedIndex(prevIndex => prevIndex < suggestions.length - 1 ? prevIndex + 1 : 0);
8077
- handleDropdownChange(value);
8062
+ handleInputChange('addressLine1', value);
8078
8063
  } else if (key === 'ArrowUp') {
8079
8064
  setSelectedIndex(prevIndex => prevIndex > 0 ? prevIndex - 1 : suggestions.length - 1);
8080
- handleDropdownChange(value);
8081
- } else if (key === 'Enter' || key === ' ' && value.length > 2) {
8082
- handleDropdownChange(value);
8065
+ handleInputChange('addressLine1', value);
8066
+ } else if (key === 'Enter') {
8067
+ handleInputChange('addressLine1', value);
8083
8068
  setLoading(false);
8084
8069
  if (selectedIndex >= 0) {
8085
8070
  (_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.9",
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",