@abgov/jsonforms-components 1.38.0 → 1.38.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.
package/index.esm.js CHANGED
@@ -4511,6 +4511,7 @@ const Dropdown = props => {
4511
4511
  onChange,
4512
4512
  optionListMaxHeight,
4513
4513
  isAutoCompletion,
4514
+ enabled,
4514
4515
  id
4515
4516
  } = props;
4516
4517
  const [isOpen, setIsOpen] = useState(false);
@@ -4674,6 +4675,7 @@ const Dropdown = props => {
4674
4675
  onTrailingIconClick: () => {
4675
4676
  setIsOpen(!isOpen);
4676
4677
  },
4678
+ disabled: !enabled,
4677
4679
  name: `dropdown-${label}`,
4678
4680
  width: "100%",
4679
4681
  value: inputText,
@@ -4729,10 +4731,7 @@ const EnumSelect = props => {
4729
4731
  var _a, _b, _c, _d;
4730
4732
  const {
4731
4733
  data,
4732
- id,
4733
4734
  enabled,
4734
- errors,
4735
- schema,
4736
4735
  path,
4737
4736
  handleChange,
4738
4737
  options,
@@ -4784,6 +4783,7 @@ const EnumSelect = props => {
4784
4783
  message: error
4785
4784
  }) : jsx(Dropdown, {
4786
4785
  items: mergedOptions,
4786
+ enabled: !enabled,
4787
4787
  selected: data,
4788
4788
  id: `jsonforms-${label}-dropdown`,
4789
4789
  label: label,
@@ -8141,6 +8141,18 @@ const NameInputs = ({
8141
8141
  }) => {
8142
8142
  var _a, _b;
8143
8143
  const [errors, setErrors] = useState({});
8144
+ /* istanbul ignore next */
8145
+ // eslint-disable-next-line
8146
+ const handleRequiredFieldBlur = (name, updatedData) => {
8147
+ const err = Object.assign({}, errors);
8148
+ if ((!(data === null || data === void 0 ? void 0 : data[name]) || (data === null || data === void 0 ? void 0 : data[name]) === '') && requiredFields.includes(name) && (!updatedData || (updatedData === null || updatedData === void 0 ? void 0 : updatedData[name]) === '')) {
8149
+ const modifiedName = name === 'firstName' ? 'First name' : name === 'lastName' ? 'Last name' : '';
8150
+ err[name] = `${modifiedName} is required`;
8151
+ } else {
8152
+ err[name] = '';
8153
+ }
8154
+ setErrors(err);
8155
+ };
8144
8156
  return jsxs(GoAGrid, {
8145
8157
  minChildWidth: "0ch",
8146
8158
  gap: "s",
@@ -8157,6 +8169,10 @@ const NameInputs = ({
8157
8169
  ariaLabel: 'name-form-first-name',
8158
8170
  value: firstName || '',
8159
8171
  onChange: (name, value) => handleInputChange(name, value),
8172
+ onBlur: name => {
8173
+ /* istanbul ignore next */
8174
+ handleRequiredFieldBlur(name);
8175
+ },
8160
8176
  width: "100%"
8161
8177
  })
8162
8178
  }), jsx(GoAFormItem, {
@@ -8184,6 +8200,10 @@ const NameInputs = ({
8184
8200
  ariaLabel: 'name-form-last-name',
8185
8201
  value: lastName || '',
8186
8202
  onChange: (name, value) => handleInputChange(name, value),
8203
+ onBlur: name => {
8204
+ /* istanbul ignore next */
8205
+ handleRequiredFieldBlur(name);
8206
+ },
8187
8207
  width: "100%"
8188
8208
  })
8189
8209
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.38.0",
3
+ "version": "1.38.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",
@@ -6,6 +6,7 @@ export interface DropdownProps {
6
6
  items: Array<Item>;
7
7
  label: string;
8
8
  selected: string;
9
+ enabled: boolean;
9
10
  optionListMaxHeight?: string;
10
11
  onChange: (value: string) => void;
11
12
  isAutoCompletion?: boolean;
@@ -1,15 +1,10 @@
1
1
  import React from 'react';
2
- interface Data {
3
- firstName: string;
4
- middleName: string;
5
- lastName: string;
6
- }
7
2
  interface NameInputsProps {
8
3
  firstName: string;
9
4
  middleName?: string;
10
5
  lastName: string;
11
6
  isStepperReview?: boolean;
12
- data: Data;
7
+ data: any;
13
8
  requiredFields: string[];
14
9
  handleInputChange: (field: string, value: string) => void;
15
10
  }