@abgov/jsonforms-components 1.38.0 → 1.38.1
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
|
@@ -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.
|
|
3
|
+
"version": "1.38.1",
|
|
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",
|
|
@@ -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:
|
|
7
|
+
data: any;
|
|
13
8
|
requiredFields: string[];
|
|
14
9
|
handleInputChange: (field: string, value: string) => void;
|
|
15
10
|
}
|