@sphereon/ui-components.ssi-react 0.4.1-unstable.74 → 0.4.1-unstable.76
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.
|
@@ -9,15 +9,25 @@ const CustomArrayControl = (props) => {
|
|
|
9
9
|
const { data = [], handleChange, path, schema, uischema, label } = props;
|
|
10
10
|
const elements = uischema.options?.detail?.elements || [];
|
|
11
11
|
const itemSchema = schema.items && !Array.isArray(schema.items) ? schema.items : {};
|
|
12
|
-
const handleAdd = async () => {
|
|
13
|
-
|
|
12
|
+
const handleAdd = async (index) => {
|
|
13
|
+
if (index !== undefined) {
|
|
14
|
+
const targetItem = { ...data[index] };
|
|
15
|
+
targetItem.properties = targetItem.properties ?? [];
|
|
16
|
+
targetItem.properties.push({});
|
|
17
|
+
data[index] = targetItem;
|
|
18
|
+
handleChange(path, [...data]);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
handleChange(path, [...data, {}]);
|
|
22
|
+
}
|
|
14
23
|
};
|
|
15
24
|
const handleRemove = async (index) => {
|
|
16
25
|
const newData = data.filter((_, i) => i !== index);
|
|
17
26
|
handleChange(path, newData);
|
|
18
27
|
};
|
|
19
28
|
const getItemElements = () => {
|
|
20
|
-
return data.map((item, index) => _jsx("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: _jsx("div", { style: { display: 'flex', flexDirection: 'row', borderRadius: 8, overflow: 'hidden', width: '100%' }, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column',
|
|
29
|
+
return data.map((item, index) => _jsx("div", { style: { display: 'flex', flexDirection: 'row', gap: 12 }, children: _jsx("div", { style: { display: 'flex', flexDirection: 'row', borderRadius: 8, overflow: 'hidden', width: '100%' }, children: _jsxs("div", { style: { display: 'flex', flexDirection: 'column', width: '100%' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center', gap: 12 }, children: [_jsx("div", { style: { display: 'flex', flexDirection: 'row', gap: 24, padding: 24, border: '1px solid #C4C4C4', borderRadius: 8, flexGrow: 1, alignItems: 'center' }, children: getFieldElements(elements, `${path}.${index}`) }), _jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 24 }, children: [_jsx(IconButton, { icon: ButtonIcon.DELETE, onClick: () => handleRemove(index) }), item?.type === 'object' &&
|
|
30
|
+
_jsx(IconButton, { icon: ButtonIcon.ADD, onClick: () => handleAdd(index) })] })] }), item?.type === 'object' &&
|
|
21
31
|
_jsx("div", { style: { marginLeft: 24, display: 'flex', flexDirection: 'row' }, children: getChildFieldElements(elements, `${path}.${index}.properties`) })] }) }) }, index));
|
|
22
32
|
};
|
|
23
33
|
const getFieldElements = (elements, path) => {
|
|
@@ -40,6 +50,7 @@ const CustomArrayControl = (props) => {
|
|
|
40
50
|
scope: "#",
|
|
41
51
|
options: {
|
|
42
52
|
...uischema.options,
|
|
53
|
+
isChild: true,
|
|
43
54
|
type: JsonFormsCustomControlKey.ARRAY,
|
|
44
55
|
detail: {
|
|
45
56
|
elements
|
|
@@ -49,11 +60,12 @@ const CustomArrayControl = (props) => {
|
|
|
49
60
|
return (_jsx(JsonFormsDispatch, { uischema: childrenUiSchema, schema: resolvedChildrenSchema, path: path }, i));
|
|
50
61
|
});
|
|
51
62
|
};
|
|
52
|
-
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 28, width: '100%' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center' }, children: [_jsx("div", { style: { color: 'black', fontSize: 16, fontWeight: '400' }, children: label }),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
63
|
+
return (_jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 28, width: '100%' }, children: [_jsxs("div", { style: { display: 'flex', flexDirection: 'row', alignItems: 'center' }, children: [_jsx("div", { style: { color: 'black', fontSize: 16, fontWeight: '400' }, children: label }), !uischema.options?.isChild &&
|
|
64
|
+
_jsx(PrimaryButton, { caption: uischema.options?.addLabel || '+', onClick: handleAdd, style: {
|
|
65
|
+
marginLeft: 'auto',
|
|
66
|
+
height: 33,
|
|
67
|
+
width: 120
|
|
68
|
+
} })] }), getItemElements()] }));
|
|
57
69
|
};
|
|
58
70
|
export const customArrayControlTester = rankWith(5, and(isArrayObjectControl, optionIs('type', JsonFormsCustomControlKey.ARRAY)));
|
|
59
71
|
export default withJsonFormsControlProps(CustomArrayControl);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ui-components.ssi-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.1-unstable.
|
|
4
|
+
"version": "0.4.1-unstable.76+023c737",
|
|
5
5
|
"description": "SSI UI components for React",
|
|
6
6
|
"repository": "git@github.com:Sphereon-Opensource/UI-Components.git",
|
|
7
7
|
"author": "Sphereon <dev@sphereon.com>",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@mui/x-date-pickers": "^6.19.5",
|
|
51
51
|
"@sphereon/ssi-sdk.data-store": "0.34.1-feature.SSISDK.45.94",
|
|
52
52
|
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.45.94",
|
|
53
|
-
"@sphereon/ui-components.core": "0.4.1-unstable.
|
|
53
|
+
"@sphereon/ui-components.core": "0.4.1-unstable.76+023c737",
|
|
54
54
|
"@tanstack/react-table": "^8.9.3",
|
|
55
55
|
"ajv": "^8.17.1",
|
|
56
56
|
"ajv-formats": "^3.0.1",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"peerDependencies": {
|
|
72
72
|
"react": ">= 18"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "023c7379ca3d20a4e453d259e40c5ce7dff8fe81"
|
|
75
75
|
}
|