@hybridcore/ui 1.5.9 → 1.5.11

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.
@@ -1,43 +1,43 @@
1
- import { jsx as i, jsxs as o, Fragment as re } from "react/jsx-runtime";
1
+ import { jsx as i, jsxs as o, Fragment as ue } from "react/jsx-runtime";
2
2
  import f from "react";
3
- import de from "lodash";
4
- import { useForm as oe, Controller as u } from "react-hook-form";
5
- import { getNestedChildrenFromMap as se } from "../../utils/ontology.js";
6
- import { i as ce, d as me } from "../../utils-Bq0ye5vf.js";
7
- import { ConditionalWrapper as ue } from "../conditional-wrapper/index.js";
8
- import { Container as fe } from "../container/index.js";
9
- import { Box as s, TextField as v, FormGroup as he, FormControl as ve, InputLabel as be, Select as ye, MenuItem as Te, FormControlLabel as J, Checkbox as $, Button as g } from "@mui/material";
10
- import { TreeSelect as ge } from "../tree-select/index.js";
11
- import pe from "./components/policy-list/index.js";
12
- import Ie from "./components/variables/index.js";
13
- import { DisseminationList as xe } from "../data-security-selectors/dissemination-list/index.js";
14
- import { SecurityLevel as Ce } from "../data-security-selectors/security-level/index.js";
15
- const Oe = {
3
+ import fe from "lodash";
4
+ import { useForm as he, Controller as u } from "react-hook-form";
5
+ import { getNestedChildrenFromMap as ve } from "../../utils/ontology.js";
6
+ import { i as ye, d as be } from "../../utils-Bq0ye5vf.js";
7
+ import { ConditionalWrapper as Te } from "../conditional-wrapper/index.js";
8
+ import { Container as ge } from "../container/index.js";
9
+ import { Box as s, TextField as v, FormGroup as Oe, FormControl as Ie, InputLabel as pe, Select as xe, MenuItem as Ce, FormControlLabel as ee, Checkbox as te, Button as g } from "@mui/material";
10
+ import { TreeSelect as Le } from "../tree-select/index.js";
11
+ import Ve from "./components/policy-list/index.js";
12
+ import Se from "./components/variables/index.js";
13
+ import { DisseminationList as Ee } from "../data-security-selectors/dissemination-list/index.js";
14
+ import { SecurityLevel as Fe } from "../data-security-selectors/security-level/index.js";
15
+ const ke = {
16
16
  alg: "A256GCM",
17
17
  ext: !0,
18
18
  k: "_El6rHQxC5E7NdO5DiMDITjF7f65wrlaJmFVagVE9Ic",
19
19
  key_ops: ["encrypt", "decrypt"],
20
20
  kty: "oct"
21
- }, Le = [
21
+ }, Re = [
22
22
  "IMAGE",
23
23
  "VIDEO",
24
24
  "TEXT",
25
25
  "BINARY",
26
26
  "OTHER"
27
27
  ];
28
- function Ve(e, Q) {
29
- var L, V, S, E, F, k, R, w, B, _, A, D, P, W, M, N, G, K, U, j, q, H, Y;
28
+ function we(e, ie) {
29
+ var L, V, S, E, F, k, R, w, B, _, A, D, P, W, M, N, G, K, U, j, q, H, Y, J, $, Q, X, z, Z;
30
30
  const {
31
- register: x,
32
- handleSubmit: X,
31
+ register: p,
32
+ handleSubmit: ne,
33
33
  control: c,
34
- formState: { errors: z, isDirty: Z },
35
- getValues: C,
36
- setValue: b,
37
- reset: ee
38
- } = oe({
34
+ formState: { errors: le, isDirty: ae },
35
+ getValues: x,
36
+ setValue: y,
37
+ reset: de
38
+ } = he({
39
39
  defaultValues: e.defaultValues
40
- }), [te, ie] = f.useState([]), [y, O] = f.useState(), [Se, ne] = f.useState(0), le = f.useMemo(() => {
40
+ }), [re, oe] = f.useState([]), [b, C] = f.useState(), [Be, se] = f.useState(0), ce = f.useMemo(() => {
41
41
  const t = [];
42
42
  return e.mappedTemplates.forEach((n) => {
43
43
  n.creatable || t.push(String(n.id));
@@ -48,61 +48,61 @@ function Ve(e, Q) {
48
48
  const t = { ...e.defaultValues }, n = e.mappedTemplates.get(t.templateId);
49
49
  if (n) {
50
50
  const a = n.properties.filter(
51
- (r) => r.privacyPreservationMethod === "ENCRYPTION"
51
+ (d) => d.privacyPreservationMethod === "ENCRYPTION"
52
52
  );
53
53
  if (a.length > 0)
54
- for (let r = 0; r < a.length; r++) {
55
- const l = a[r], d = de.get(t, `variables.${l.propertyId}`);
56
- if (d && e.keyAuth) {
57
- const m = await ce(Oe), h = await me(m, String(d));
58
- h.data && (b(`variables.${l.propertyId}`, h.data), ne((T) => T + 1));
54
+ for (let d = 0; d < a.length; d++) {
55
+ const l = a[d], r = fe.get(t, `variables.${l.propertyId}`);
56
+ if (r && e.keyAuth) {
57
+ const m = await ye(ke), h = await be(m, String(r));
58
+ h.data && (y(`variables.${l.propertyId}`, h.data), se((T) => T + 1));
59
59
  }
60
60
  }
61
61
  }
62
62
  })();
63
63
  }, [e.defaultValues, e.mappedTemplates, e.keyAuth]);
64
- const p = () => {
65
- const t = C("templateId");
66
- y && O(void 0);
67
- const n = se(e.mappedTemplates);
68
- ie(n);
64
+ const O = () => {
65
+ const t = x("templateId");
66
+ b && C(void 0);
67
+ const n = ve(e.mappedTemplates);
68
+ oe(n);
69
69
  for (const a of e.mappedTemplates.values())
70
70
  if (a.id === t) {
71
- O(a);
71
+ C(a);
72
72
  break;
73
73
  }
74
74
  };
75
- f.useImperativeHandle(Q, () => ({
75
+ f.useImperativeHandle(ie, () => ({
76
76
  resetForm() {
77
- ee({
77
+ de({
78
78
  title: "",
79
79
  description: "",
80
80
  templateId: 0,
81
81
  variables: {}
82
- }), p();
82
+ }), O();
83
83
  },
84
84
  setFormValue(t, n) {
85
- b(t, n);
85
+ y(t, n);
86
86
  },
87
87
  getFormValue(t) {
88
- return C(t);
88
+ return x(t);
89
89
  }
90
- })), f.useEffect(() => (p(), () => {
90
+ })), f.useEffect(() => (O(), () => {
91
91
  }), [e.mappedTemplates]), f.useEffect(() => {
92
- e.onSelectedTemplateChange && e.onSelectedTemplateChange(y);
93
- }, [y]);
94
- const ae = () => {
92
+ e.onSelectedTemplateChange && e.onSelectedTemplateChange(b);
93
+ }, [b]);
94
+ const me = () => {
95
95
  if (e.onCancel) {
96
- e.onCancel(Z);
96
+ e.onCancel(ae);
97
97
  return;
98
98
  }
99
99
  };
100
100
  return /* @__PURE__ */ i(
101
- ue,
101
+ Te,
102
102
  {
103
103
  condition: e.variant === void 0 || e.variant === "inline",
104
104
  wrapper: (t) => /* @__PURE__ */ i(
105
- fe,
105
+ ge,
106
106
  {
107
107
  disableHeader: !0,
108
108
  sx: { position: "relative", overflow: "visible" },
@@ -112,7 +112,7 @@ function Ve(e, Q) {
112
112
  children: /* @__PURE__ */ o(
113
113
  "form",
114
114
  {
115
- onSubmit: X(e.onSubmit),
115
+ onSubmit: ne(e.onSubmit),
116
116
  style: { display: "flex", flexDirection: "column" },
117
117
  children: [
118
118
  !((V = (L = e.fieldOptions) == null ? void 0 : L.title) != null && V.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
@@ -122,8 +122,8 @@ function Ve(e, Q) {
122
122
  label: "Title *",
123
123
  variant: e.inputVariant,
124
124
  fullWidth: !0,
125
- ...x("title", { required: !0 }),
126
- ...z.title && {
125
+ ...p("title", { required: !0 }),
126
+ ...le.title && {
127
127
  helperText: "This field is required!",
128
128
  error: !0
129
129
  }
@@ -140,20 +140,20 @@ function Ve(e, Q) {
140
140
  fullWidth: !0,
141
141
  multiline: !0,
142
142
  minRows: (R = (k = e.fieldOptions) == null ? void 0 : k.description) == null ? void 0 : R.minRows,
143
- ...x("description")
143
+ ...p("description")
144
144
  }
145
145
  ),
146
146
  e.fieldOptions && ((w = e.fieldOptions.description) == null ? void 0 : w.helperText)
147
147
  ] }),
148
- !((_ = (B = e.fieldOptions) == null ? void 0 : B.templateId) != null && _.hidden) && /* @__PURE__ */ o(he, { sx: { mb: 2 }, children: [
148
+ !((_ = (B = e.fieldOptions) == null ? void 0 : B.templateId) != null && _.hidden) && /* @__PURE__ */ o(Oe, { sx: { mb: 2 }, children: [
149
149
  /* @__PURE__ */ i(
150
150
  u,
151
151
  {
152
152
  name: "templateId",
153
153
  control: c,
154
154
  render: ({ field: { value: t, onChange: n } }) => {
155
- var a, r;
156
- if ((r = (a = e.fieldOptions) == null ? void 0 : a.templateId) != null && r.disabled) {
155
+ var a, d;
156
+ if ((d = (a = e.fieldOptions) == null ? void 0 : a.templateId) != null && d.disabled) {
157
157
  const l = t ? e.mappedTemplates.get(t) : void 0;
158
158
  return /* @__PURE__ */ i(
159
159
  v,
@@ -168,20 +168,20 @@ function Ve(e, Q) {
168
168
  );
169
169
  }
170
170
  return /* @__PURE__ */ i(
171
- ge,
171
+ Le,
172
172
  {
173
173
  label: "Template",
174
- data: te,
174
+ data: re,
175
175
  selected: t === 0 ? "" : [String(t)],
176
- disabled: le,
176
+ disabled: ce,
177
177
  variant: e.inputVariant,
178
- onChange: (l, d) => {
178
+ onChange: (l, r) => {
179
179
  const m = {
180
180
  target: {
181
- value: d ? Number(l) : 0
181
+ value: r ? Number(l) : 0
182
182
  }
183
183
  };
184
- n(m), p();
184
+ n(m), O();
185
185
  }
186
186
  }
187
187
  );
@@ -197,10 +197,10 @@ function Ve(e, Q) {
197
197
  control: c,
198
198
  render: ({ field: { value: t, onChange: n, ...a } }) => {
199
199
  var l;
200
- const r = (d) => {
200
+ const d = (r) => {
201
201
  const T = {
202
202
  target: {
203
- value: d.target.value.split(",").map((I) => I.trimStart())
203
+ value: r.target.value.split(",").map((I) => I.trimStart())
204
204
  }
205
205
  };
206
206
  n(T);
@@ -214,7 +214,7 @@ function Ve(e, Q) {
214
214
  fullWidth: !0,
215
215
  value: t,
216
216
  helperText: "Add list values with the comma (,) separated string",
217
- onChange: r,
217
+ onChange: d,
218
218
  ...a
219
219
  }
220
220
  ),
@@ -232,7 +232,7 @@ function Ve(e, Q) {
232
232
  var a;
233
233
  return /* @__PURE__ */ o(s, { mb: 2, children: [
234
234
  /* @__PURE__ */ i(
235
- pe,
235
+ Ve,
236
236
  {
237
237
  policyList: e.policyList,
238
238
  value: t || void 0,
@@ -250,9 +250,9 @@ function Ve(e, Q) {
250
250
  name: "variables",
251
251
  control: c,
252
252
  render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ i(
253
- Ie,
253
+ Se,
254
254
  {
255
- template: y,
255
+ template: b,
256
256
  value: t,
257
257
  mapboxAccessToken: e.mapboxAccessToken,
258
258
  variant: e.inputVariant,
@@ -262,23 +262,23 @@ function Ve(e, Q) {
262
262
  )
263
263
  }
264
264
  ),
265
- "fileInBase64" in e.defaultValues && !((G = (N = e.fieldOptions) == null ? void 0 : N.fileInBase64) != null && G.hidden) && /* @__PURE__ */ o(re, { children: [
265
+ "fileInBase64" in e.defaultValues && !((G = (N = e.fieldOptions) == null ? void 0 : N.fileInBase64) != null && G.hidden) && /* @__PURE__ */ o(ue, { children: [
266
266
  /* @__PURE__ */ i(
267
267
  u,
268
268
  {
269
269
  name: "fileInBase64",
270
270
  control: c,
271
271
  render: ({ field: { onChange: t, ...n } }) => {
272
- var r;
272
+ var d;
273
273
  const a = (l) => {
274
274
  if (l.target.files) {
275
- const d = new FileReader();
276
- d.onload = async (h) => {
275
+ const r = new FileReader();
276
+ r.onload = async (h) => {
277
277
  const I = h.target.result.split("base64,")[1];
278
278
  t(I);
279
279
  };
280
280
  const m = l.target.files[0];
281
- b("originalFileName", m.name), b("contentType", m.type), d.readAsDataURL(m);
281
+ y("originalFileName", m.name), y("contentType", m.type), r.readAsDataURL(m);
282
282
  }
283
283
  };
284
284
  return /* @__PURE__ */ o(s, { mb: 2, children: [
@@ -295,77 +295,77 @@ function Ve(e, Q) {
295
295
  ...n
296
296
  }
297
297
  ),
298
- e.fieldOptions && ((r = e.fieldOptions.fileInBase64) == null ? void 0 : r.helperText)
298
+ e.fieldOptions && ((d = e.fieldOptions.fileInBase64) == null ? void 0 : d.helperText)
299
299
  ] });
300
300
  }
301
301
  }
302
302
  ),
303
- /* @__PURE__ */ i(
303
+ !((U = (K = e.fieldOptions) == null ? void 0 : K.type) != null && U.hidden) && /* @__PURE__ */ i(
304
304
  u,
305
305
  {
306
306
  name: "type",
307
307
  control: c,
308
308
  render: ({ field: { value: t, onChange: n } }) => {
309
- var r;
309
+ var d;
310
310
  const a = (l) => {
311
311
  const {
312
- target: { value: d }
312
+ target: { value: r }
313
313
  } = l;
314
- n(d);
314
+ n(r);
315
315
  };
316
316
  return /* @__PURE__ */ o(s, { mb: 2, children: [
317
- /* @__PURE__ */ o(ve, { fullWidth: !0, variant: e.inputVariant, children: [
318
- /* @__PURE__ */ i(be, { children: "Type" }),
317
+ /* @__PURE__ */ o(Ie, { fullWidth: !0, variant: e.inputVariant, children: [
318
+ /* @__PURE__ */ i(pe, { children: "Type" }),
319
319
  /* @__PURE__ */ i(
320
- ye,
320
+ xe,
321
321
  {
322
322
  value: t ? [t] : "",
323
323
  onChange: a,
324
- children: Le.map((l) => /* @__PURE__ */ i(Te, { value: l, children: l }, l))
324
+ children: Re.map((l) => /* @__PURE__ */ i(Ce, { value: l, children: l }, l))
325
325
  }
326
326
  )
327
327
  ] }),
328
- e.fieldOptions && ((r = e.fieldOptions.type) == null ? void 0 : r.helperText)
328
+ e.fieldOptions && ((d = e.fieldOptions.type) == null ? void 0 : d.helperText)
329
329
  ] });
330
330
  }
331
331
  }
332
332
  ),
333
- /* @__PURE__ */ o(s, { mb: 2, children: [
333
+ !((q = (j = e.fieldOptions) == null ? void 0 : j.redacted) != null && q.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
334
334
  /* @__PURE__ */ i(
335
- J,
335
+ ee,
336
336
  {
337
337
  control: /* @__PURE__ */ i(
338
338
  u,
339
339
  {
340
340
  name: "redacted",
341
341
  control: c,
342
- render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i($, { checked: !!t, ...n })
342
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(te, { checked: !!t, ...n })
343
343
  }
344
344
  ),
345
345
  label: "Redacted"
346
346
  }
347
347
  ),
348
- e.fieldOptions && ((K = e.fieldOptions.redacted) == null ? void 0 : K.helperText)
348
+ e.fieldOptions && ((H = e.fieldOptions.redacted) == null ? void 0 : H.helperText)
349
349
  ] }),
350
- /* @__PURE__ */ o(s, { mb: 2, children: [
350
+ !((J = (Y = e.fieldOptions) == null ? void 0 : Y.contentEncrypted) != null && J.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
351
351
  /* @__PURE__ */ i(
352
- J,
352
+ ee,
353
353
  {
354
354
  control: /* @__PURE__ */ i(
355
355
  u,
356
356
  {
357
357
  name: "contentEncrypted",
358
358
  control: c,
359
- render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i($, { checked: !!t, ...n })
359
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(te, { checked: !!t, ...n })
360
360
  }
361
361
  ),
362
362
  label: "Content Encrypted"
363
363
  }
364
364
  ),
365
- e.fieldOptions && ((U = e.fieldOptions.contentEncrypted) == null ? void 0 : U.helperText)
365
+ e.fieldOptions && (($ = e.fieldOptions.contentEncrypted) == null ? void 0 : $.helperText)
366
366
  ] })
367
367
  ] }),
368
- !((q = (j = e.fieldOptions) == null ? void 0 : j.disseminationList) != null && q.hidden) && /* @__PURE__ */ i(
368
+ !((X = (Q = e.fieldOptions) == null ? void 0 : Q.disseminationList) != null && X.hidden) && /* @__PURE__ */ i(
369
369
  u,
370
370
  {
371
371
  name: "disseminationList",
@@ -374,13 +374,13 @@ function Ve(e, Q) {
374
374
  },
375
375
  control: c,
376
376
  render: ({ field: { value: t, onChange: n }, fieldState: a }) => {
377
- const r = t || [], l = (d) => {
378
- n(d);
377
+ const d = t || [], l = (r) => {
378
+ n(r);
379
379
  };
380
380
  return /* @__PURE__ */ i(
381
- xe,
381
+ Ee,
382
382
  {
383
- selectedIds: r,
383
+ selectedIds: d,
384
384
  memberedGroups: e.memberedGroups,
385
385
  showError: !!a.error,
386
386
  variant: e.inputVariant,
@@ -390,7 +390,7 @@ function Ve(e, Q) {
390
390
  }
391
391
  }
392
392
  ),
393
- !((Y = (H = e.fieldOptions) == null ? void 0 : H.securityLevelId) != null && Y.hidden) && /* @__PURE__ */ i(s, { mt: 2, children: /* @__PURE__ */ i(
393
+ !((Z = (z = e.fieldOptions) == null ? void 0 : z.securityLevelId) != null && Z.hidden) && /* @__PURE__ */ i(s, { mt: 2, children: /* @__PURE__ */ i(
394
394
  u,
395
395
  {
396
396
  name: "securityLevelId",
@@ -399,12 +399,12 @@ function Ve(e, Q) {
399
399
  },
400
400
  control: c,
401
401
  render: ({ field: { value: t, onChange: n }, fieldState: a }) => {
402
- var l, d;
403
- const r = (m) => {
402
+ var l, r;
403
+ const d = (m) => {
404
404
  n(m);
405
405
  };
406
406
  return /* @__PURE__ */ i(
407
- Ce,
407
+ Fe,
408
408
  {
409
409
  value: t || 0,
410
410
  ontologyId: e.ontologyId,
@@ -412,10 +412,10 @@ function Ve(e, Q) {
412
412
  securityLevels: e.securityLevels,
413
413
  minLevelId: e.minSecurityLevel,
414
414
  templateKeys: (l = e.securityLevelConfig) == null ? void 0 : l.templateKeys,
415
- templateType: (d = e.securityLevelConfig) == null ? void 0 : d.templateType,
415
+ templateType: (r = e.securityLevelConfig) == null ? void 0 : r.templateType,
416
416
  showError: !!a.error,
417
417
  variant: e.inputVariant,
418
- onChange: r
418
+ onChange: d
419
419
  }
420
420
  );
421
421
  }
@@ -429,7 +429,7 @@ function Ve(e, Q) {
429
429
  variant: "text",
430
430
  disabled: e.loading,
431
431
  sx: { textTransform: "none" },
432
- onClick: ae,
432
+ onClick: me,
433
433
  children: "Cancel"
434
434
  }
435
435
  ),
@@ -478,7 +478,7 @@ function Ve(e, Q) {
478
478
  }
479
479
  );
480
480
  }
481
- const Ke = f.forwardRef(Ve);
481
+ const Je = f.forwardRef(we);
482
482
  export {
483
- Ke as InstanceForm
483
+ Je as InstanceForm
484
484
  };
@@ -183,7 +183,7 @@ const R = ({
183
183
  if (e.type === "enum" || e.type === "composite-list" && ((S = (I = e.dataTypeInfo) == null ? void 0 : I.innerType) == null ? void 0 : S.type) === "enum") {
184
184
  const [l, n] = Y(!1), o = 10;
185
185
  let i = [];
186
- return (y = e.dataTypeInfo) != null && y.enumValues && (i = e.dataTypeInfo.enumValues), (M = (V = e.dataTypeInfo) == null ? void 0 : V.innerType) != null && M.enumValues && (i = e.dataTypeInfo.innerType.enumValues), /* @__PURE__ */ m(d, { children: [
186
+ return (y = e.dataTypeInfo) != null && y.enumValues && (i = e.dataTypeInfo.enumValues), (M = (V = e.dataTypeInfo) == null ? void 0 : V.innerType) != null && M.enumValues && (i = e.dataTypeInfo.innerType.enumValues), /* @__PURE__ */ m(d, { mb: 1, children: [
187
187
  /* @__PURE__ */ m(B, { fullWidth: !0, component: "fieldset", variant: c, children: [
188
188
  /* @__PURE__ */ t(P, { component: "legend", sx: { mb: 1, fontSize: 12 }, children: e.name }),
189
189
  /* @__PURE__ */ t(D, { children: i.slice(0, l ? 9999 : o).map((s, x) => /* @__PURE__ */ t(
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridcore/ui",
3
3
  "description": "Hybrid Core UI Library",
4
- "version": "1.5.9",
4
+ "version": "1.5.11",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",