@hybridcore/ui 1.5.4 → 1.5.5
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/dist/components/instance-form/index.js +88 -88
- package/dist/main.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { jsx as n, jsxs as h, Fragment as
|
|
1
|
+
import { jsx as n, jsxs as h, Fragment as ee } from "react/jsx-runtime";
|
|
2
2
|
import m from "react";
|
|
3
|
-
import
|
|
4
|
-
import { useForm as
|
|
5
|
-
import { getNestedChildrenFromMap as
|
|
6
|
-
import { i as ae, d as
|
|
7
|
-
import { ConditionalWrapper as
|
|
8
|
-
import { Container as
|
|
9
|
-
import { TextField as v, FormGroup as
|
|
10
|
-
import { TreeSelect as
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import { DisseminationList as
|
|
14
|
-
import { SecurityLevel as
|
|
15
|
-
const
|
|
3
|
+
import te from "lodash";
|
|
4
|
+
import { useForm as ne, Controller as s } from "react-hook-form";
|
|
5
|
+
import { getNestedChildrenFromMap as ie } from "../../utils/ontology.js";
|
|
6
|
+
import { i as ae, d as le } from "../../utils-Bq0ye5vf.js";
|
|
7
|
+
import { ConditionalWrapper as re } from "../conditional-wrapper/index.js";
|
|
8
|
+
import { Container as de } from "../container/index.js";
|
|
9
|
+
import { TextField as v, FormGroup as oe, FormControl as se, InputLabel as me, Select as ce, MenuItem as ue, FormControlLabel as K, Checkbox as U, Box as p, Button as g } from "@mui/material";
|
|
10
|
+
import { TreeSelect as fe } from "../tree-select/index.js";
|
|
11
|
+
import he from "./components/policy-list/index.js";
|
|
12
|
+
import ve from "./components/variables/index.js";
|
|
13
|
+
import { DisseminationList as be } from "../data-security-selectors/dissemination-list/index.js";
|
|
14
|
+
import { SecurityLevel as ye } from "../data-security-selectors/security-level/index.js";
|
|
15
|
+
const ge = {
|
|
16
16
|
alg: "A256GCM",
|
|
17
17
|
ext: !0,
|
|
18
18
|
k: "_El6rHQxC5E7NdO5DiMDITjF7f65wrlaJmFVagVE9Ic",
|
|
19
19
|
key_ops: ["encrypt", "decrypt"],
|
|
20
20
|
kty: "oct"
|
|
21
|
-
},
|
|
21
|
+
}, Te = [
|
|
22
22
|
"IMAGE",
|
|
23
23
|
"VIDEO",
|
|
24
24
|
"TEXT",
|
|
25
25
|
"BINARY",
|
|
26
26
|
"OTHER"
|
|
27
27
|
];
|
|
28
|
-
function
|
|
28
|
+
function pe(e, j) {
|
|
29
29
|
var L, V, S, E, F, k, O, R, w, B, _, A, D, P, W, M, N, G;
|
|
30
30
|
const {
|
|
31
31
|
register: C,
|
|
32
32
|
handleSubmit: q,
|
|
33
33
|
control: o,
|
|
34
|
-
formState: { errors: H },
|
|
34
|
+
formState: { errors: H, isDirty: Y },
|
|
35
35
|
getValues: I,
|
|
36
36
|
setValue: b,
|
|
37
|
-
reset:
|
|
38
|
-
} =
|
|
37
|
+
reset: J
|
|
38
|
+
} = ne({
|
|
39
39
|
defaultValues: e.defaultValues
|
|
40
|
-
}), [
|
|
40
|
+
}), [$, Q] = m.useState([]), [y, x] = m.useState(), [Ce, X] = m.useState(0), z = m.useMemo(() => {
|
|
41
41
|
const t = [];
|
|
42
|
-
return e.mappedTemplates.forEach((
|
|
43
|
-
|
|
42
|
+
return e.mappedTemplates.forEach((i) => {
|
|
43
|
+
i.creatable || t.push(String(i.id));
|
|
44
44
|
}), t;
|
|
45
45
|
}, [e.mappedTemplates]);
|
|
46
46
|
m.useEffect(() => {
|
|
47
47
|
(async () => {
|
|
48
|
-
const t = { ...e.defaultValues },
|
|
49
|
-
if (
|
|
50
|
-
const r =
|
|
51
|
-
(
|
|
48
|
+
const t = { ...e.defaultValues }, i = e.mappedTemplates.get(t.templateId);
|
|
49
|
+
if (i) {
|
|
50
|
+
const r = i.properties.filter(
|
|
51
|
+
(a) => a.privacyPreservationMethod === "ENCRYPTION"
|
|
52
52
|
);
|
|
53
53
|
if (r.length > 0)
|
|
54
|
-
for (let
|
|
55
|
-
const l = r[
|
|
54
|
+
for (let a = 0; a < r.length; a++) {
|
|
55
|
+
const l = r[a], d = te.get(t, `variables.${l.propertyId}`);
|
|
56
56
|
if (d && e.keyAuth) {
|
|
57
|
-
const c = await ae(
|
|
58
|
-
u.data && (b(`variables.${l.propertyId}`, u.data),
|
|
57
|
+
const c = await ae(ge), u = await le(c, String(d));
|
|
58
|
+
u.data && (b(`variables.${l.propertyId}`, u.data), X((f) => f + 1));
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -64,8 +64,8 @@ function Te(e, j) {
|
|
|
64
64
|
const T = () => {
|
|
65
65
|
const t = I("templateId");
|
|
66
66
|
y && x(void 0);
|
|
67
|
-
const
|
|
68
|
-
|
|
67
|
+
const i = ie(e.mappedTemplates);
|
|
68
|
+
Q(i);
|
|
69
69
|
for (const r of e.mappedTemplates.values())
|
|
70
70
|
if (r.id === t) {
|
|
71
71
|
x(r);
|
|
@@ -74,15 +74,15 @@ function Te(e, j) {
|
|
|
74
74
|
};
|
|
75
75
|
m.useImperativeHandle(j, () => ({
|
|
76
76
|
resetForm() {
|
|
77
|
-
|
|
77
|
+
J({
|
|
78
78
|
title: "",
|
|
79
79
|
description: "",
|
|
80
80
|
templateId: 0,
|
|
81
81
|
variables: {}
|
|
82
82
|
}), T();
|
|
83
83
|
},
|
|
84
|
-
setFormValue(t,
|
|
85
|
-
b(t,
|
|
84
|
+
setFormValue(t, i) {
|
|
85
|
+
b(t, i);
|
|
86
86
|
},
|
|
87
87
|
getFormValue(t) {
|
|
88
88
|
return I(t);
|
|
@@ -91,18 +91,18 @@ function Te(e, j) {
|
|
|
91
91
|
}), [e.mappedTemplates]), m.useEffect(() => {
|
|
92
92
|
e.onSelectedTemplateChange && e.onSelectedTemplateChange(y);
|
|
93
93
|
}, [y]);
|
|
94
|
-
const
|
|
94
|
+
const Z = () => {
|
|
95
95
|
if (e.onCancel) {
|
|
96
|
-
e.onCancel();
|
|
96
|
+
e.onCancel(Y);
|
|
97
97
|
return;
|
|
98
98
|
}
|
|
99
99
|
};
|
|
100
100
|
return /* @__PURE__ */ n(
|
|
101
|
-
|
|
101
|
+
re,
|
|
102
102
|
{
|
|
103
103
|
condition: e.variant === void 0 || e.variant === "inline",
|
|
104
104
|
wrapper: (t) => /* @__PURE__ */ n(
|
|
105
|
-
|
|
105
|
+
de,
|
|
106
106
|
{
|
|
107
107
|
disableHeader: !0,
|
|
108
108
|
sx: { position: "relative", overflow: "visible" },
|
|
@@ -141,14 +141,14 @@ function Te(e, j) {
|
|
|
141
141
|
...C("description")
|
|
142
142
|
}
|
|
143
143
|
),
|
|
144
|
-
!((R = (O = e.fieldOptions) == null ? void 0 : O.templateId) != null && R.hidden) && /* @__PURE__ */ n(
|
|
144
|
+
!((R = (O = e.fieldOptions) == null ? void 0 : O.templateId) != null && R.hidden) && /* @__PURE__ */ n(oe, { sx: { mb: 2 }, children: /* @__PURE__ */ n(
|
|
145
145
|
s,
|
|
146
146
|
{
|
|
147
147
|
name: "templateId",
|
|
148
148
|
control: o,
|
|
149
|
-
render: ({ field: { value: t, onChange:
|
|
150
|
-
var r,
|
|
151
|
-
if ((
|
|
149
|
+
render: ({ field: { value: t, onChange: i } }) => {
|
|
150
|
+
var r, a;
|
|
151
|
+
if ((a = (r = e.fieldOptions) == null ? void 0 : r.templateId) != null && a.disabled) {
|
|
152
152
|
const l = t ? e.mappedTemplates.get(t) : void 0;
|
|
153
153
|
return /* @__PURE__ */ n(
|
|
154
154
|
v,
|
|
@@ -163,12 +163,12 @@ function Te(e, j) {
|
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
return /* @__PURE__ */ n(
|
|
166
|
-
|
|
166
|
+
fe,
|
|
167
167
|
{
|
|
168
168
|
label: "Template",
|
|
169
|
-
data:
|
|
169
|
+
data: $,
|
|
170
170
|
selected: t === 0 ? "" : [String(t)],
|
|
171
|
-
disabled:
|
|
171
|
+
disabled: z,
|
|
172
172
|
variant: e.inputVariant,
|
|
173
173
|
onChange: (l, d) => {
|
|
174
174
|
const c = {
|
|
@@ -176,7 +176,7 @@ function Te(e, j) {
|
|
|
176
176
|
value: d ? Number(l) : 0
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
|
-
|
|
179
|
+
i(c), T();
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
);
|
|
@@ -188,14 +188,14 @@ function Te(e, j) {
|
|
|
188
188
|
{
|
|
189
189
|
name: "aliasList",
|
|
190
190
|
control: o,
|
|
191
|
-
render: ({ field: { value: t, onChange:
|
|
192
|
-
const
|
|
191
|
+
render: ({ field: { value: t, onChange: i, ...r } }) => {
|
|
192
|
+
const a = (l) => {
|
|
193
193
|
const u = {
|
|
194
194
|
target: {
|
|
195
195
|
value: l.target.value.split(",").map((f) => f.trimStart())
|
|
196
196
|
}
|
|
197
197
|
};
|
|
198
|
-
|
|
198
|
+
i(u);
|
|
199
199
|
};
|
|
200
200
|
return /* @__PURE__ */ n(
|
|
201
201
|
v,
|
|
@@ -206,7 +206,7 @@ function Te(e, j) {
|
|
|
206
206
|
value: t,
|
|
207
207
|
sx: { mb: 2 },
|
|
208
208
|
helperText: "Add list values with the comma (,) separated string",
|
|
209
|
-
onChange:
|
|
209
|
+
onChange: a,
|
|
210
210
|
...r
|
|
211
211
|
}
|
|
212
212
|
);
|
|
@@ -218,12 +218,12 @@ function Te(e, j) {
|
|
|
218
218
|
{
|
|
219
219
|
name: "appliedPolicies",
|
|
220
220
|
control: o,
|
|
221
|
-
render: ({ field: { value: t, onChange:
|
|
222
|
-
|
|
221
|
+
render: ({ field: { value: t, onChange: i } }) => /* @__PURE__ */ n(
|
|
222
|
+
he,
|
|
223
223
|
{
|
|
224
224
|
policyList: e.policyList,
|
|
225
225
|
value: t || void 0,
|
|
226
|
-
onChange:
|
|
226
|
+
onChange: i
|
|
227
227
|
}
|
|
228
228
|
)
|
|
229
229
|
}
|
|
@@ -233,34 +233,34 @@ function Te(e, j) {
|
|
|
233
233
|
{
|
|
234
234
|
name: "variables",
|
|
235
235
|
control: o,
|
|
236
|
-
render: ({ field: { value: t, onChange:
|
|
237
|
-
|
|
236
|
+
render: ({ field: { value: t, onChange: i } }) => /* @__PURE__ */ n(
|
|
237
|
+
ve,
|
|
238
238
|
{
|
|
239
239
|
template: y,
|
|
240
240
|
value: t,
|
|
241
241
|
mapboxAccessToken: e.mapboxAccessToken,
|
|
242
242
|
variant: e.inputVariant,
|
|
243
243
|
fieldOptions: e.fieldOptions,
|
|
244
|
-
onChange:
|
|
244
|
+
onChange: i
|
|
245
245
|
}
|
|
246
246
|
)
|
|
247
247
|
}
|
|
248
248
|
),
|
|
249
|
-
"fileInBase64" in e.defaultValues && !((P = (D = e.fieldOptions) == null ? void 0 : D.fileInBase64) != null && P.hidden) && /* @__PURE__ */ h(
|
|
249
|
+
"fileInBase64" in e.defaultValues && !((P = (D = e.fieldOptions) == null ? void 0 : D.fileInBase64) != null && P.hidden) && /* @__PURE__ */ h(ee, { children: [
|
|
250
250
|
/* @__PURE__ */ n(
|
|
251
251
|
s,
|
|
252
252
|
{
|
|
253
253
|
name: "fileInBase64",
|
|
254
254
|
control: o,
|
|
255
|
-
render: ({ field: { onChange: t, ...
|
|
256
|
-
const r = (
|
|
257
|
-
if (
|
|
255
|
+
render: ({ field: { onChange: t, ...i } }) => {
|
|
256
|
+
const r = (a) => {
|
|
257
|
+
if (a.target.files) {
|
|
258
258
|
const l = new FileReader();
|
|
259
259
|
l.onload = async (c) => {
|
|
260
260
|
const f = c.target.result.split("base64,")[1];
|
|
261
261
|
t(f);
|
|
262
262
|
};
|
|
263
|
-
const d =
|
|
263
|
+
const d = a.target.files[0];
|
|
264
264
|
b("originalFileName", d.name), b("contentType", d.type), l.readAsDataURL(d);
|
|
265
265
|
}
|
|
266
266
|
};
|
|
@@ -275,7 +275,7 @@ function Te(e, j) {
|
|
|
275
275
|
helperText: "Select a file to upload",
|
|
276
276
|
InputLabelProps: { shrink: !0 },
|
|
277
277
|
onChange: r,
|
|
278
|
-
...
|
|
278
|
+
...i
|
|
279
279
|
}
|
|
280
280
|
);
|
|
281
281
|
}
|
|
@@ -286,15 +286,15 @@ function Te(e, j) {
|
|
|
286
286
|
{
|
|
287
287
|
name: "type",
|
|
288
288
|
control: o,
|
|
289
|
-
render: ({ field: { value: t, onChange:
|
|
290
|
-
const r = (
|
|
289
|
+
render: ({ field: { value: t, onChange: i } }) => {
|
|
290
|
+
const r = (a) => {
|
|
291
291
|
const {
|
|
292
292
|
target: { value: l }
|
|
293
|
-
} =
|
|
294
|
-
|
|
293
|
+
} = a;
|
|
294
|
+
i(l);
|
|
295
295
|
};
|
|
296
296
|
return /* @__PURE__ */ h(
|
|
297
|
-
|
|
297
|
+
se,
|
|
298
298
|
{
|
|
299
299
|
fullWidth: !0,
|
|
300
300
|
sx: {
|
|
@@ -302,13 +302,13 @@ function Te(e, j) {
|
|
|
302
302
|
},
|
|
303
303
|
variant: e.inputVariant,
|
|
304
304
|
children: [
|
|
305
|
-
/* @__PURE__ */ n(
|
|
305
|
+
/* @__PURE__ */ n(me, { children: "Type" }),
|
|
306
306
|
/* @__PURE__ */ n(
|
|
307
|
-
|
|
307
|
+
ce,
|
|
308
308
|
{
|
|
309
309
|
value: t ? [t] : "",
|
|
310
310
|
onChange: r,
|
|
311
|
-
children:
|
|
311
|
+
children: Te.map((a) => /* @__PURE__ */ n(ue, { value: a, children: a }, a))
|
|
312
312
|
}
|
|
313
313
|
)
|
|
314
314
|
]
|
|
@@ -325,7 +325,7 @@ function Te(e, j) {
|
|
|
325
325
|
{
|
|
326
326
|
name: "redacted",
|
|
327
327
|
control: o,
|
|
328
|
-
render: ({ field: { value: t, ...
|
|
328
|
+
render: ({ field: { value: t, ...i } }) => /* @__PURE__ */ n(U, { checked: !!t, ...i })
|
|
329
329
|
}
|
|
330
330
|
),
|
|
331
331
|
label: "Redacted",
|
|
@@ -340,7 +340,7 @@ function Te(e, j) {
|
|
|
340
340
|
{
|
|
341
341
|
name: "contentEncrypted",
|
|
342
342
|
control: o,
|
|
343
|
-
render: ({ field: { value: t, ...
|
|
343
|
+
render: ({ field: { value: t, ...i } }) => /* @__PURE__ */ n(U, { checked: !!t, ...i })
|
|
344
344
|
}
|
|
345
345
|
),
|
|
346
346
|
label: "Content Encrypted",
|
|
@@ -356,14 +356,14 @@ function Te(e, j) {
|
|
|
356
356
|
required: !0
|
|
357
357
|
},
|
|
358
358
|
control: o,
|
|
359
|
-
render: ({ field: { value: t, onChange:
|
|
360
|
-
const
|
|
361
|
-
|
|
359
|
+
render: ({ field: { value: t, onChange: i }, fieldState: r }) => {
|
|
360
|
+
const a = t || [], l = (d) => {
|
|
361
|
+
i(d);
|
|
362
362
|
};
|
|
363
363
|
return /* @__PURE__ */ n(
|
|
364
|
-
|
|
364
|
+
be,
|
|
365
365
|
{
|
|
366
|
-
selectedIds:
|
|
366
|
+
selectedIds: a,
|
|
367
367
|
memberedGroups: e.memberedGroups,
|
|
368
368
|
showError: !!r.error,
|
|
369
369
|
variant: e.inputVariant,
|
|
@@ -381,13 +381,13 @@ function Te(e, j) {
|
|
|
381
381
|
required: !0
|
|
382
382
|
},
|
|
383
383
|
control: o,
|
|
384
|
-
render: ({ field: { value: t, onChange:
|
|
384
|
+
render: ({ field: { value: t, onChange: i }, fieldState: r }) => {
|
|
385
385
|
var l, d;
|
|
386
|
-
const
|
|
387
|
-
|
|
386
|
+
const a = (c) => {
|
|
387
|
+
i(c);
|
|
388
388
|
};
|
|
389
389
|
return /* @__PURE__ */ n(
|
|
390
|
-
|
|
390
|
+
ye,
|
|
391
391
|
{
|
|
392
392
|
value: t || 0,
|
|
393
393
|
ontologyId: e.ontologyId,
|
|
@@ -398,7 +398,7 @@ function Te(e, j) {
|
|
|
398
398
|
templateType: (d = e.securityLevelConfig) == null ? void 0 : d.templateType,
|
|
399
399
|
showError: !!r.error,
|
|
400
400
|
variant: e.inputVariant,
|
|
401
|
-
onChange:
|
|
401
|
+
onChange: a
|
|
402
402
|
}
|
|
403
403
|
);
|
|
404
404
|
}
|
|
@@ -412,7 +412,7 @@ function Te(e, j) {
|
|
|
412
412
|
variant: "text",
|
|
413
413
|
disabled: e.loading,
|
|
414
414
|
sx: { textTransform: "none" },
|
|
415
|
-
onClick:
|
|
415
|
+
onClick: Z,
|
|
416
416
|
children: "Cancel"
|
|
417
417
|
}
|
|
418
418
|
),
|
|
@@ -429,7 +429,7 @@ function Te(e, j) {
|
|
|
429
429
|
children: e.removeLoading ? "Deleting..." : "Delete"
|
|
430
430
|
}
|
|
431
431
|
),
|
|
432
|
-
e.saveButtons ? e.saveButtons.map((t,
|
|
432
|
+
e.saveButtons ? e.saveButtons.map((t, i) => /* @__PURE__ */ n(
|
|
433
433
|
g,
|
|
434
434
|
{
|
|
435
435
|
type: "submit",
|
|
@@ -441,7 +441,7 @@ function Te(e, j) {
|
|
|
441
441
|
onClick: t.onClick,
|
|
442
442
|
children: t.label
|
|
443
443
|
},
|
|
444
|
-
|
|
444
|
+
i
|
|
445
445
|
)) : /* @__PURE__ */ n(
|
|
446
446
|
g,
|
|
447
447
|
{
|
|
@@ -461,7 +461,7 @@ function Te(e, j) {
|
|
|
461
461
|
}
|
|
462
462
|
);
|
|
463
463
|
}
|
|
464
|
-
const
|
|
464
|
+
const De = m.forwardRef(pe);
|
|
465
465
|
export {
|
|
466
|
-
|
|
466
|
+
De as InstanceForm
|
|
467
467
|
};
|
package/dist/main.d.ts
CHANGED