@abgov/jsonforms-components 2.60.15 → 2.60.17
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
|
@@ -11758,6 +11758,16 @@ const DeleteDialog = /*#__PURE__*/React.memo(function DeleteDialog({
|
|
|
11758
11758
|
}, 1);
|
|
11759
11759
|
});
|
|
11760
11760
|
|
|
11761
|
+
const jsonPreviewStyle = {
|
|
11762
|
+
display: 'block',
|
|
11763
|
+
width: '100%',
|
|
11764
|
+
boxSizing: 'border-box',
|
|
11765
|
+
margin: 0,
|
|
11766
|
+
padding: 0,
|
|
11767
|
+
whiteSpace: 'pre-wrap',
|
|
11768
|
+
textAlign: 'left',
|
|
11769
|
+
overflowX: 'auto'
|
|
11770
|
+
};
|
|
11761
11771
|
function prettify(prop) {
|
|
11762
11772
|
return prop.replace(/([A-Z])/g, ' $1').replace(/[_-]/g, ' ').replace(/^./, c => c.toUpperCase());
|
|
11763
11773
|
}
|
|
@@ -11874,18 +11884,21 @@ const renderCellColumn = ({
|
|
|
11874
11884
|
return `${dateObj.year}-${dateObj.month}-${dayValue}`;
|
|
11875
11885
|
}
|
|
11876
11886
|
return jsx("pre", {
|
|
11887
|
+
style: jsonPreviewStyle,
|
|
11877
11888
|
children: JSON.stringify(data, null, 2)
|
|
11878
11889
|
});
|
|
11879
11890
|
} else if (result.length === 0) {
|
|
11880
11891
|
return renderWarningCell();
|
|
11881
11892
|
} else if (result.length > 0 && (isObjectArrayEmpty(data) || nestedErrors.length > 0)) {
|
|
11882
11893
|
return jsx("pre", {
|
|
11894
|
+
style: jsonPreviewStyle,
|
|
11883
11895
|
children: renderWarningCell(JSON.stringify(data, null, 2))
|
|
11884
11896
|
});
|
|
11885
11897
|
} else if (data !== undefined && result.length > 0 && error !== '' && error !== undefined) {
|
|
11886
11898
|
const values = Object.values(data);
|
|
11887
11899
|
if (values && values.length > 0) {
|
|
11888
11900
|
return jsx("pre", {
|
|
11901
|
+
style: jsonPreviewStyle,
|
|
11889
11902
|
children: renderWarningCell(JSON.stringify(values.at(0), null, 2))
|
|
11890
11903
|
});
|
|
11891
11904
|
}
|
|
@@ -12637,6 +12650,7 @@ const ArrayControlReview = props => {
|
|
|
12637
12650
|
const GoAArrayControlRenderer = withJsonFormsControlProps(ArrayControlBase);
|
|
12638
12651
|
const GoAArrayControlReviewRenderer = withJsonFormsControlProps(ArrayControlReview);
|
|
12639
12652
|
const PrimitiveArrayControl = props => {
|
|
12653
|
+
var _enumerators$function;
|
|
12640
12654
|
const {
|
|
12641
12655
|
data,
|
|
12642
12656
|
path,
|
|
@@ -12648,8 +12662,13 @@ const PrimitiveArrayControl = props => {
|
|
|
12648
12662
|
renderers,
|
|
12649
12663
|
cells
|
|
12650
12664
|
} = props;
|
|
12665
|
+
const enumerators = useContext(JsonFormContext);
|
|
12651
12666
|
const rawItems = Array.isArray(data) ? data : [];
|
|
12652
12667
|
const items = rawItems.filter(item => item !== undefined && item !== null);
|
|
12668
|
+
const deleteTriggerFunction = enumerators == null || (_enumerators$function = enumerators.functions) == null ? void 0 : _enumerators$function.get('delete-file');
|
|
12669
|
+
const deleteTrigger = deleteTriggerFunction && deleteTriggerFunction();
|
|
12670
|
+
const fileListValue = enumerators == null ? void 0 : enumerators.data.get('file-list');
|
|
12671
|
+
const fileList = fileListValue && fileListValue();
|
|
12653
12672
|
useEffect(() => {
|
|
12654
12673
|
if (rawItems.length !== items.length) {
|
|
12655
12674
|
handleChange(path, items.length > 0 ? items : undefined);
|
|
@@ -12662,9 +12681,20 @@ const PrimitiveArrayControl = props => {
|
|
|
12662
12681
|
const getOptionLabel = option => typeof option === 'string' ? option : option.title || option.const;
|
|
12663
12682
|
const getOptionDescription = option => typeof option === 'string' ? undefined : option.description;
|
|
12664
12683
|
const removeItem = index => {
|
|
12684
|
+
const itemSchema = schema == null ? void 0 : schema.items;
|
|
12685
|
+
const removedItem = items[index];
|
|
12686
|
+
const itemPath = composePaths(path, `${index}`);
|
|
12687
|
+
if ((itemSchema == null ? void 0 : itemSchema.format) === 'file-urn' && deleteTrigger && removedItem) {
|
|
12688
|
+
var _fileList$itemPath;
|
|
12689
|
+
const allUploadedFiles = Object.values(fileList || {}).flat() || [];
|
|
12690
|
+
const rowFile = (fileList == null || (_fileList$itemPath = fileList[itemPath]) == null ? void 0 : _fileList$itemPath.find(file => (file == null ? void 0 : file.urn) === removedItem)) || allUploadedFiles.find(file => (file == null ? void 0 : file.urn) === removedItem);
|
|
12691
|
+
if (rowFile != null && rowFile.urn) {
|
|
12692
|
+
deleteTrigger(rowFile, itemPath);
|
|
12693
|
+
}
|
|
12694
|
+
}
|
|
12665
12695
|
const copy = [...items];
|
|
12666
12696
|
copy.splice(index, 1);
|
|
12667
|
-
handleChange(path, copy);
|
|
12697
|
+
handleChange(path, copy.length > 0 ? copy : undefined);
|
|
12668
12698
|
};
|
|
12669
12699
|
const getPrimitiveArrayOptions = schema => {
|
|
12670
12700
|
const itemSchema = schema == null ? void 0 : schema.items;
|
|
@@ -17579,20 +17609,66 @@ const NameInputs = ({
|
|
|
17579
17609
|
handleInputChange,
|
|
17580
17610
|
data,
|
|
17581
17611
|
requiredFields,
|
|
17582
|
-
disabled
|
|
17612
|
+
disabled,
|
|
17613
|
+
errors,
|
|
17614
|
+
onFieldBlur
|
|
17583
17615
|
}) => {
|
|
17584
|
-
var
|
|
17585
|
-
const [
|
|
17616
|
+
var _displayedErrors$firs, _displayedErrors$last;
|
|
17617
|
+
const [internalErrors, setInternalErrors] = useState({});
|
|
17618
|
+
const currentValues = {
|
|
17619
|
+
firstName,
|
|
17620
|
+
middleName: middleName || '',
|
|
17621
|
+
lastName
|
|
17622
|
+
};
|
|
17623
|
+
useEffect(() => {
|
|
17624
|
+
const timeout = window.setTimeout(() => {
|
|
17625
|
+
['firstName', 'middleName', 'lastName'].forEach(field => {
|
|
17626
|
+
var _input$value;
|
|
17627
|
+
const input = document.querySelector(`goa-input[name="${field}"]`);
|
|
17628
|
+
const liveValue = (input == null || (_input$value = input.value) == null ? void 0 : _input$value.trim()) || '';
|
|
17629
|
+
if (liveValue && !currentValues[field]) {
|
|
17630
|
+
handleInputChange(field, liveValue);
|
|
17631
|
+
}
|
|
17632
|
+
});
|
|
17633
|
+
}, 50);
|
|
17634
|
+
return () => window.clearTimeout(timeout);
|
|
17635
|
+
}, [firstName, middleName, lastName, handleInputChange]);
|
|
17636
|
+
useEffect(() => {
|
|
17637
|
+
if (errors) {
|
|
17638
|
+
return;
|
|
17639
|
+
}
|
|
17640
|
+
setInternalErrors(currentErrors => {
|
|
17641
|
+
const nextErrors = Object.assign({}, currentErrors);
|
|
17642
|
+
let hasChanges = false;
|
|
17643
|
+
Object.keys(currentErrors).forEach(name => {
|
|
17644
|
+
const currentValue = (currentValues[name] || '').trim();
|
|
17645
|
+
if (requiredFields != null && requiredFields.includes(name) && currentValue === '') {
|
|
17646
|
+
return;
|
|
17647
|
+
}
|
|
17648
|
+
delete nextErrors[name];
|
|
17649
|
+
hasChanges = true;
|
|
17650
|
+
});
|
|
17651
|
+
return hasChanges ? nextErrors : currentErrors;
|
|
17652
|
+
});
|
|
17653
|
+
}, [errors, firstName, middleName, lastName, requiredFields]);
|
|
17586
17654
|
// eslint-disable-next-line
|
|
17587
17655
|
const handleRequiredFieldBlur = (name, updatedData) => {
|
|
17588
|
-
const err = Object.assign({},
|
|
17589
|
-
if ((!(data != null && data[name]) || (data == null ? void 0 : data[name]) === '') && requiredFields.includes(name) && (true)) {
|
|
17656
|
+
const err = Object.assign({}, internalErrors);
|
|
17657
|
+
if ((!(data != null && data[name]) || (data == null ? void 0 : data[name]) === '') && requiredFields != null && requiredFields.includes(name) && (true)) {
|
|
17590
17658
|
const modifiedName = name === 'firstName' ? 'First name' : name === 'lastName' ? 'Last name' : '';
|
|
17591
17659
|
err[name] = `${modifiedName} is required`;
|
|
17592
17660
|
} else {
|
|
17593
17661
|
err[name] = '';
|
|
17594
17662
|
}
|
|
17595
|
-
|
|
17663
|
+
setInternalErrors(err);
|
|
17664
|
+
};
|
|
17665
|
+
const displayedErrors = errors != null ? errors : internalErrors;
|
|
17666
|
+
const handleBlur = name => {
|
|
17667
|
+
if (onFieldBlur) {
|
|
17668
|
+
onFieldBlur(name);
|
|
17669
|
+
} else {
|
|
17670
|
+
handleRequiredFieldBlur(name);
|
|
17671
|
+
}
|
|
17596
17672
|
};
|
|
17597
17673
|
return jsxs(GoabGrid, {
|
|
17598
17674
|
minChildWidth: "0ch",
|
|
@@ -17603,7 +17679,7 @@ const NameInputs = ({
|
|
|
17603
17679
|
testId: "form-item-first-name",
|
|
17604
17680
|
label: "First name",
|
|
17605
17681
|
requirement: requiredFields != null && requiredFields.includes('firstName') ? 'required' : undefined,
|
|
17606
|
-
error: (
|
|
17682
|
+
error: (_displayedErrors$firs = displayedErrors == null ? void 0 : displayedErrors['firstName']) != null ? _displayedErrors$firs : '',
|
|
17607
17683
|
children: jsx(GoabInput, {
|
|
17608
17684
|
type: "text",
|
|
17609
17685
|
name: "firstName",
|
|
@@ -17613,7 +17689,7 @@ const NameInputs = ({
|
|
|
17613
17689
|
value: firstName || '',
|
|
17614
17690
|
onChange: detail => handleInputChange(detail.name, detail.value),
|
|
17615
17691
|
onBlur: detail => {
|
|
17616
|
-
|
|
17692
|
+
handleBlur(detail.name);
|
|
17617
17693
|
},
|
|
17618
17694
|
width: "100%"
|
|
17619
17695
|
})
|
|
@@ -17635,7 +17711,7 @@ const NameInputs = ({
|
|
|
17635
17711
|
testId: "form-item-last-name",
|
|
17636
17712
|
label: "Last name",
|
|
17637
17713
|
requirement: requiredFields != null && requiredFields.includes('lastName') ? 'required' : undefined,
|
|
17638
|
-
error: (
|
|
17714
|
+
error: (_displayedErrors$last = displayedErrors == null ? void 0 : displayedErrors['lastName']) != null ? _displayedErrors$last : '',
|
|
17639
17715
|
children: jsx(GoabInput, {
|
|
17640
17716
|
type: "text",
|
|
17641
17717
|
name: "lastName",
|
|
@@ -17645,7 +17721,7 @@ const NameInputs = ({
|
|
|
17645
17721
|
value: lastName || '',
|
|
17646
17722
|
onChange: detail => handleInputChange(detail.name, detail.value),
|
|
17647
17723
|
onBlur: detail => {
|
|
17648
|
-
|
|
17724
|
+
handleBlur(detail.name);
|
|
17649
17725
|
},
|
|
17650
17726
|
width: "100%"
|
|
17651
17727
|
})
|
|
@@ -17817,6 +17893,8 @@ handleRequiredFieldBlur) {
|
|
|
17817
17893
|
}, [formData]);
|
|
17818
17894
|
}
|
|
17819
17895
|
|
|
17896
|
+
const AUTOFILL_FIELDS = ['firstName', 'middleName', 'lastName', 'dateOfBirth'];
|
|
17897
|
+
const getRequiredLabel = name => name === 'firstName' ? 'First name' : name === 'lastName' ? 'Last name' : name === 'dateOfBirth' ? 'Date of birth' : name;
|
|
17820
17898
|
const normalizeNameDobData = value => ({
|
|
17821
17899
|
firstName: (value == null ? void 0 : value.firstName) || '',
|
|
17822
17900
|
middleName: (value == null ? void 0 : value.middleName) || '',
|
|
@@ -17824,7 +17902,7 @@ const normalizeNameDobData = value => ({
|
|
|
17824
17902
|
dateOfBirth: (value == null ? void 0 : value.dateOfBirth) || ''
|
|
17825
17903
|
});
|
|
17826
17904
|
const FullNameDobControl = props => {
|
|
17827
|
-
var
|
|
17905
|
+
var _errors$dateOfBirth;
|
|
17828
17906
|
const {
|
|
17829
17907
|
data,
|
|
17830
17908
|
path,
|
|
@@ -17834,7 +17912,7 @@ const FullNameDobControl = props => {
|
|
|
17834
17912
|
visible,
|
|
17835
17913
|
uischema
|
|
17836
17914
|
} = props;
|
|
17837
|
-
const requiredFields = schema.required;
|
|
17915
|
+
const requiredFields = schema.required || [];
|
|
17838
17916
|
const [errors, setErrors] = useState({});
|
|
17839
17917
|
const controlRef = useRef(null);
|
|
17840
17918
|
const formStepperCtx = useContext(JsonFormsStepperContext);
|
|
@@ -17849,9 +17927,9 @@ const FullNameDobControl = props => {
|
|
|
17849
17927
|
};
|
|
17850
17928
|
const [formData, setFormData] = useState(normalizeNameDobData(data));
|
|
17851
17929
|
const updateFormData = updatedData => {
|
|
17852
|
-
|
|
17853
|
-
setFormData(
|
|
17854
|
-
handleChange(path,
|
|
17930
|
+
const nextData = Object.fromEntries(Object.entries(updatedData).filter(([_, value]) => value !== ''));
|
|
17931
|
+
setFormData(nextData);
|
|
17932
|
+
handleChange(path, nextData);
|
|
17855
17933
|
};
|
|
17856
17934
|
useEffect(() => {
|
|
17857
17935
|
const nextData = normalizeNameDobData(data);
|
|
@@ -17869,14 +17947,13 @@ const FullNameDobControl = props => {
|
|
|
17869
17947
|
const err = Object.assign({}, errors);
|
|
17870
17948
|
const liveInputValue = (_ref = (_ref2 = (_updatedData$name = updatedData == null ? void 0 : updatedData[name]) != null ? _updatedData$name : data == null ? void 0 : data[name]) != null ? _ref2 : (_document$querySelect = document.querySelector(`goa-input[name="${name}"]`)) == null ? void 0 : _document$querySelect.value) != null ? _ref : '';
|
|
17871
17949
|
if (requiredFields.includes(name) && liveInputValue.trim() === '') {
|
|
17872
|
-
|
|
17873
|
-
err[name] = `${modifiedName} is required`;
|
|
17950
|
+
err[name] = `${getRequiredLabel(name)} is required`;
|
|
17874
17951
|
} else {
|
|
17875
17952
|
delete err[name];
|
|
17876
17953
|
}
|
|
17877
17954
|
setErrors(err);
|
|
17878
17955
|
};
|
|
17879
|
-
useSyncAutofillFields(
|
|
17956
|
+
useSyncAutofillFields(AUTOFILL_FIELDS, formData, updateFormData, handleRequiredFieldBlur);
|
|
17880
17957
|
useEffect(() => {
|
|
17881
17958
|
var _controlRef$current$q, _controlRef$current, _host$shadowRoot;
|
|
17882
17959
|
const host = (_controlRef$current$q = (_controlRef$current = controlRef.current) == null ? void 0 : _controlRef$current.querySelector('goa-input[type="date"]')) != null ? _controlRef$current$q : null;
|
|
@@ -17917,64 +17994,16 @@ const FullNameDobControl = props => {
|
|
|
17917
17994
|
visible: visible,
|
|
17918
17995
|
children: jsxs("div", {
|
|
17919
17996
|
ref: controlRef,
|
|
17920
|
-
children: [
|
|
17921
|
-
|
|
17922
|
-
|
|
17923
|
-
|
|
17924
|
-
|
|
17925
|
-
|
|
17926
|
-
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
17930
|
-
disabled: !enabled,
|
|
17931
|
-
type: "text",
|
|
17932
|
-
name: "firstName",
|
|
17933
|
-
testId: "name-form-first-name",
|
|
17934
|
-
ariaLabel: 'name-form-first-name',
|
|
17935
|
-
value: formData.firstName,
|
|
17936
|
-
onChange: detail => {
|
|
17937
|
-
handleInputChange(detail.name, detail.value);
|
|
17938
|
-
},
|
|
17939
|
-
onBlur: detail => {
|
|
17940
|
-
handleRequiredFieldBlur(detail.name);
|
|
17941
|
-
},
|
|
17942
|
-
width: "100%"
|
|
17943
|
-
})
|
|
17944
|
-
}), jsx(GoabFormItem, {
|
|
17945
|
-
label: "Middle name",
|
|
17946
|
-
requirement: schema != null && (_schema$required2 = schema.required) != null && _schema$required2.includes('middleName') ? 'required' : undefined,
|
|
17947
|
-
children: jsx(GoabInput, {
|
|
17948
|
-
type: "text",
|
|
17949
|
-
name: "middleName",
|
|
17950
|
-
disabled: !enabled,
|
|
17951
|
-
testId: "name-form-middle-name",
|
|
17952
|
-
ariaLabel: 'name-form-middle-name',
|
|
17953
|
-
value: formData.middleName || '',
|
|
17954
|
-
onChange: detail => handleInputChange(detail.name, detail.value),
|
|
17955
|
-
width: "100%"
|
|
17956
|
-
})
|
|
17957
|
-
}), jsx(GoabFormItem, {
|
|
17958
|
-
label: "Last name",
|
|
17959
|
-
requirement: schema != null && (_schema$required3 = schema.required) != null && _schema$required3.includes('lastName') ? 'required' : undefined,
|
|
17960
|
-
error: (_errors$lastName = errors == null ? void 0 : errors['lastName']) != null ? _errors$lastName : '',
|
|
17961
|
-
testId: "form-item-last-name",
|
|
17962
|
-
children: jsx(GoabInput, {
|
|
17963
|
-
type: "text",
|
|
17964
|
-
name: "lastName",
|
|
17965
|
-
disabled: !enabled,
|
|
17966
|
-
testId: "name-form-last-name",
|
|
17967
|
-
ariaLabel: 'name-form-last-name',
|
|
17968
|
-
value: formData.lastName || '',
|
|
17969
|
-
onChange: detail => {
|
|
17970
|
-
handleInputChange(detail.name, detail.value);
|
|
17971
|
-
},
|
|
17972
|
-
onBlur: detail => {
|
|
17973
|
-
handleRequiredFieldBlur(detail.name);
|
|
17974
|
-
},
|
|
17975
|
-
width: "100%"
|
|
17976
|
-
})
|
|
17977
|
-
})]
|
|
17997
|
+
children: [jsx(NameInputs, {
|
|
17998
|
+
firstName: formData.firstName,
|
|
17999
|
+
middleName: formData.middleName,
|
|
18000
|
+
lastName: formData.lastName,
|
|
18001
|
+
handleInputChange: handleInputChange,
|
|
18002
|
+
data: formData,
|
|
18003
|
+
disabled: !enabled,
|
|
18004
|
+
requiredFields: requiredFields,
|
|
18005
|
+
errors: errors,
|
|
18006
|
+
onFieldBlur: handleRequiredFieldBlur
|
|
17978
18007
|
}), jsx(GoabGrid, {
|
|
17979
18008
|
minChildWidth: "0ch",
|
|
17980
18009
|
gap: "s",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.60.
|
|
3
|
+
"version": "2.60.17",
|
|
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",
|
package/renderer-catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"generatedAt": "2026-04-
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"generatedAt": "2026-04-29T21:25:28.694Z",
|
|
4
|
+
"sourceCommit": "4a8e24eeb967cbbf32d54077d2a3aa489e565b67",
|
|
5
5
|
"sourcePath": "libs/jsonforms-components/src/index.ts",
|
|
6
6
|
"rendererCount": 33,
|
|
7
7
|
"renderers": [
|
|
@@ -5,8 +5,10 @@ interface NameInputsProps {
|
|
|
5
5
|
lastName: string;
|
|
6
6
|
isStepperReview?: boolean;
|
|
7
7
|
disabled?: boolean;
|
|
8
|
-
data
|
|
9
|
-
requiredFields
|
|
8
|
+
data?: any;
|
|
9
|
+
requiredFields?: string[];
|
|
10
|
+
errors?: Record<string, string>;
|
|
11
|
+
onFieldBlur?: (name: string) => void;
|
|
10
12
|
handleInputChange: (field: string, value: string) => void;
|
|
11
13
|
}
|
|
12
14
|
export declare const NameInputs: React.FC<NameInputsProps>;
|