@abgov/jsonforms-components 1.56.0 → 1.56.2

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 +10 -20
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -8743,11 +8743,7 @@ const AddressLookUpControl = props => {
8743
8743
  const [open, setOpen] = useState(false);
8744
8744
  const label = typeof (uischema === null || uischema === void 0 ? void 0 : uischema.label) === 'string' && uischema.label ? uischema.label : '';
8745
8745
  const defaultAddress = {
8746
- addressLine1: '',
8747
- addressLine2: '',
8748
- municipality: '',
8749
8746
  subdivisionCode: isAlbertaAddress ? 'AB' : '',
8750
- postalCode: '',
8751
8747
  country: 'CA'
8752
8748
  };
8753
8749
  const [address, setAddress] = useState(data || defaultAddress);
@@ -8784,6 +8780,9 @@ const AddressLookUpControl = props => {
8784
8780
  });
8785
8781
  delete errors[field];
8786
8782
  }
8783
+ if (value === '' && field in newAddress) {
8784
+ delete newAddress[field];
8785
+ }
8787
8786
  setAddress(newAddress);
8788
8787
  updateFormData(newAddress);
8789
8788
  };
@@ -8950,7 +8949,7 @@ const AddressViews = ({
8950
8949
  data,
8951
8950
  isAlbertaAddress
8952
8951
  }) => {
8953
- var _a, _b, _c, _d;
8952
+ var _a;
8954
8953
  const provinces = [{
8955
8954
  value: 'AB',
8956
8955
  label: 'Alberta'
@@ -9004,7 +9003,7 @@ const AddressViews = ({
9004
9003
  gap: "s",
9005
9004
  children: [jsx(GoAFormItem, {
9006
9005
  label: "Address line 1",
9007
- error: ((_a = data === null || data === void 0 ? void 0 : data.addressLine1) === null || _a === void 0 ? void 0 : _a.length) === 0 ? 'addressLine1 is required' : '',
9006
+ error: (data === null || data === void 0 ? void 0 : data.addressLine1) === undefined ? 'addressLine1 is required' : '',
9008
9007
  children: jsx(TextWrap, {
9009
9008
  children: data === null || data === void 0 ? void 0 : data.addressLine1
9010
9009
  })
@@ -9018,13 +9017,13 @@ const AddressViews = ({
9018
9017
  minChildWidth: "0ch",
9019
9018
  gap: "s",
9020
9019
  children: [jsx(GoAFormItem, {
9021
- error: ((_b = data === null || data === void 0 ? void 0 : data.municipality) === null || _b === void 0 ? void 0 : _b.length) === 0 ? 'city is required' : '',
9020
+ error: (data === null || data === void 0 ? void 0 : data.municipality) === undefined ? 'city is required' : '',
9022
9021
  label: "City",
9023
9022
  children: jsx(TextWrap, {
9024
9023
  children: data === null || data === void 0 ? void 0 : data.municipality
9025
9024
  })
9026
9025
  }), jsx(GoAFormItem, {
9027
- error: ((_c = data === null || data === void 0 ? void 0 : data.postalCode) === null || _c === void 0 ? void 0 : _c.length) === 0 ? 'postalCode is required' : '',
9026
+ error: (data === null || data === void 0 ? void 0 : data.postalCode) === undefined ? 'postalCode is required' : '',
9028
9027
  label: "Postal Code",
9029
9028
  children: jsx(TextWrap, {
9030
9029
  children: data === null || data === void 0 ? void 0 : data.postalCode
@@ -9040,7 +9039,7 @@ const AddressViews = ({
9040
9039
  children: "Alberta"
9041
9040
  }), !isAlbertaAddress && jsx("div", {
9042
9041
  "data-testid": "address-form-province-view",
9043
- children: (_d = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.subdivisionCode))) === null || _d === void 0 ? void 0 : _d.label
9042
+ children: (_a = provinces.find(p => p.value === (data === null || data === void 0 ? void 0 : data.subdivisionCode))) === null || _a === void 0 ? void 0 : _a.label
9044
9043
  })]
9045
9044
  }), jsx(GoAFormItem, {
9046
9045
  label: "Country",
@@ -9226,11 +9225,7 @@ const FullNameControl = props => {
9226
9225
  enabled
9227
9226
  } = props;
9228
9227
  const requiredFields = schema.required;
9229
- const defaultName = {
9230
- firstName: '',
9231
- middleName: '',
9232
- lastName: ''
9233
- };
9228
+ const defaultName = {};
9234
9229
  const [nameData, setNameData] = useState(data || defaultName);
9235
9230
  const updateFormData = updatedData => {
9236
9231
  updatedData = Object.fromEntries(Object.entries(updatedData).filter(([_, value]) => value !== ''));
@@ -9268,12 +9263,7 @@ const FullNameDobControl = props => {
9268
9263
  } = props;
9269
9264
  const requiredFields = schema.required;
9270
9265
  const [errors, setErrors] = useState({});
9271
- const defaultNameAndDob = {
9272
- firstName: '',
9273
- middleName: '',
9274
- lastName: '',
9275
- dateOfBirth: undefined
9276
- };
9266
+ const defaultNameAndDob = {};
9277
9267
  const validDates = () => {
9278
9268
  const currentDate = new Date();
9279
9269
  const minDate = new Date(currentDate.getFullYear() - 150, currentDate.getMonth(), currentDate.getDate()).toISOString().substring(0, 10);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.56.0",
3
+ "version": "1.56.2",
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",