@abgov/jsonforms-components 2.62.0 → 2.63.0
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 +56 -1
- package/package.json +2 -2
- package/renderer-catalog.json +2 -2
package/index.esm.js
CHANGED
|
@@ -12827,7 +12827,27 @@ const PrimitiveArrayControl = props => {
|
|
|
12827
12827
|
};
|
|
12828
12828
|
const GoAPrimitiveArrayRenderer = withJsonFormsControlProps(PrimitiveArrayControl);
|
|
12829
12829
|
|
|
12830
|
+
const getDataAtPath = (data, path) => path.replace(/\[(\d+)\]/g, '.$1').split('.').reduce((acc, key) => acc && typeof acc === 'object' ? acc[key] : undefined, data);
|
|
12831
|
+
const collectFileFields = (schema, value, currentPath) => {
|
|
12832
|
+
if (!schema || value === undefined || value === null) {
|
|
12833
|
+
return [];
|
|
12834
|
+
}
|
|
12835
|
+
if (schema.type === 'string' && schema.format === 'file-urn' && typeof value === 'string' && value !== '') {
|
|
12836
|
+
return [{
|
|
12837
|
+
path: currentPath,
|
|
12838
|
+
urn: value
|
|
12839
|
+
}];
|
|
12840
|
+
}
|
|
12841
|
+
if (schema.type === 'object' && !Array.isArray(schema.properties) && schema.properties && typeof value === 'object') {
|
|
12842
|
+
return Object.entries(schema.properties).flatMap(([key, propertySchema]) => collectFileFields(propertySchema, value[key], composePaths(currentPath, key)));
|
|
12843
|
+
}
|
|
12844
|
+
if (schema.type === 'array' && Array.isArray(value) && schema.items && !Array.isArray(schema.items)) {
|
|
12845
|
+
return value.flatMap((item, index) => collectFileFields(schema.items, item, composePaths(currentPath, `${index}`)));
|
|
12846
|
+
}
|
|
12847
|
+
return [];
|
|
12848
|
+
};
|
|
12830
12849
|
const ListWithDetailsControl = props => {
|
|
12850
|
+
var _enumerators$function;
|
|
12831
12851
|
const [open, setOpen] = useState(false);
|
|
12832
12852
|
const [path, setPath] = useState();
|
|
12833
12853
|
const [name, setName] = useState();
|
|
@@ -12838,6 +12858,14 @@ const ListWithDetailsControl = props => {
|
|
|
12838
12858
|
handleChange
|
|
12839
12859
|
} = props;
|
|
12840
12860
|
const [currentTab, setCurrentTab] = useState(0);
|
|
12861
|
+
const enumerators = useContext(JsonFormContext);
|
|
12862
|
+
const {
|
|
12863
|
+
core
|
|
12864
|
+
} = useJsonForms();
|
|
12865
|
+
const deleteTriggerFunction = enumerators == null || (_enumerators$function = enumerators.functions) == null ? void 0 : _enumerators$function.get('delete-file');
|
|
12866
|
+
const deleteTrigger = deleteTriggerFunction && deleteTriggerFunction();
|
|
12867
|
+
const fileListValue = enumerators == null ? void 0 : enumerators.data.get('file-list');
|
|
12868
|
+
const fileList = fileListValue && fileListValue();
|
|
12841
12869
|
const openDeleteDialog = useCallback((p, rowIndex, name) => {
|
|
12842
12870
|
setOpen(true);
|
|
12843
12871
|
setPath(p);
|
|
@@ -12849,6 +12877,33 @@ const ListWithDetailsControl = props => {
|
|
|
12849
12877
|
const deleteConfirm = useCallback(() => {
|
|
12850
12878
|
const p = path == null ? void 0 : path.substring(0, path.lastIndexOf('.'));
|
|
12851
12879
|
if (removeItems && p) {
|
|
12880
|
+
var _props$schema;
|
|
12881
|
+
const rowValue = path ? getDataAtPath(core == null ? void 0 : core.data, path) : undefined;
|
|
12882
|
+
const itemSchema = (_props$schema = props.schema) == null ? void 0 : _props$schema.items;
|
|
12883
|
+
const fileFields = collectFileFields(itemSchema, rowValue, path != null ? path : '');
|
|
12884
|
+
if (deleteTrigger) {
|
|
12885
|
+
const allUploadedFiles = Object.values(fileList || {}).flat() || [];
|
|
12886
|
+
const fileListFields = Object.entries(fileList || {}).reduce((fields, [filePath, files]) => {
|
|
12887
|
+
if (!filePath.startsWith(`${path}.`) || !Array.isArray(files)) {
|
|
12888
|
+
return fields;
|
|
12889
|
+
}
|
|
12890
|
+
return fields.concat(files.filter(file => Boolean(file == null ? void 0 : file.urn)).map(file => ({
|
|
12891
|
+
path: filePath,
|
|
12892
|
+
urn: file.urn
|
|
12893
|
+
})));
|
|
12894
|
+
}, []);
|
|
12895
|
+
const allFileFields = [...fileFields, ...fileListFields].filter((field, index, fields) => fields.findIndex(candidate => candidate.path === field.path && candidate.urn === field.urn) === index);
|
|
12896
|
+
allFileFields.forEach(({
|
|
12897
|
+
path: fieldPath,
|
|
12898
|
+
urn
|
|
12899
|
+
}) => {
|
|
12900
|
+
var _fileList$fieldPath;
|
|
12901
|
+
const rowFile = (fileList == null || (_fileList$fieldPath = fileList[fieldPath]) == null ? void 0 : _fileList$fieldPath.find(file => (file == null ? void 0 : file.urn) === urn)) || allUploadedFiles.find(file => (file == null ? void 0 : file.urn) === urn);
|
|
12902
|
+
if (rowFile != null && rowFile.urn) {
|
|
12903
|
+
deleteTrigger(rowFile, fieldPath);
|
|
12904
|
+
}
|
|
12905
|
+
});
|
|
12906
|
+
}
|
|
12852
12907
|
if (props.data === 1) {
|
|
12853
12908
|
handleChange(p, null);
|
|
12854
12909
|
setCurrentTab(0);
|
|
@@ -12859,7 +12914,7 @@ const ListWithDetailsControl = props => {
|
|
|
12859
12914
|
}
|
|
12860
12915
|
setOpen(false);
|
|
12861
12916
|
// eslint-disable-next-line
|
|
12862
|
-
}, [
|
|
12917
|
+
}, [core == null ? void 0 : core.data, deleteTrigger, fileList, handleChange, path, props.data, props.schema, removeItems, rowData]);
|
|
12863
12918
|
return jsxs(Visible, {
|
|
12864
12919
|
visible: visible,
|
|
12865
12920
|
children: [jsx(ListWithDetailControl, Object.assign({}, props, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abgov/jsonforms-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.63.0",
|
|
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",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"pluralize": "^8.0.0"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"axios": "1.15.
|
|
23
|
+
"axios": "^1.15.2",
|
|
24
24
|
"lodash": "^4.17.23",
|
|
25
25
|
"styled-components": "^6.0.0"
|
|
26
26
|
},
|
package/renderer-catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
|
-
"generatedAt": "2026-05-
|
|
4
|
-
"sourceCommit": "
|
|
3
|
+
"generatedAt": "2026-05-06T18:14:28.530Z",
|
|
4
|
+
"sourceCommit": "7bb09ca8bb456426bf4c753390a28f8d0697e925",
|
|
5
5
|
"sourcePath": "libs/jsonforms-components/src/index.ts",
|
|
6
6
|
"rendererCount": 33,
|
|
7
7
|
"renderers": [
|