@hybridcore/ui 1.5.11 → 1.5.13

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,49 +1,43 @@
1
- import { jsx as i, jsxs as o, Fragment as ue } from "react/jsx-runtime";
2
- import f from "react";
1
+ import { jsx as i, jsxs as o, Fragment as me } from "react/jsx-runtime";
2
+ import u from "react";
3
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";
4
+ import { useForm as ue, Controller as f } from "react-hook-form";
5
+ import { getNestedChildrenFromMap as he } from "../../utils/ontology.js";
6
+ import { i as ve, d as be } from "../../utils-Bq0ye5vf.js";
7
+ import { ConditionalWrapper as ye } from "../conditional-wrapper/index.js";
8
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 = {
9
+ import { Box as s, TextField as b, FormGroup as Te, FormControlLabel as X, Checkbox as Z, Button as T } from "@mui/material";
10
+ import { TreeSelect as xe } from "../tree-select/index.js";
11
+ import Oe from "./components/policy-list/index.js";
12
+ import pe from "./components/variables/index.js";
13
+ import { DisseminationList as Ce } from "../data-security-selectors/dissemination-list/index.js";
14
+ import { SecurityLevel as Ie } from "../data-security-selectors/security-level/index.js";
15
+ const Le = {
16
16
  alg: "A256GCM",
17
17
  ext: !0,
18
18
  k: "_El6rHQxC5E7NdO5DiMDITjF7f65wrlaJmFVagVE9Ic",
19
19
  key_ops: ["encrypt", "decrypt"],
20
20
  kty: "oct"
21
- }, Re = [
22
- "IMAGE",
23
- "VIDEO",
24
- "TEXT",
25
- "BINARY",
26
- "OTHER"
27
- ];
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;
21
+ };
22
+ function Ve(e, ee) {
23
+ var I, L, V, S, k, F, E, R, w, B, D, P, _, A, W, N, K, M, j, q, G, U, H, J, $, Q, Y;
30
24
  const {
31
- register: p,
32
- handleSubmit: ne,
25
+ register: O,
26
+ handleSubmit: te,
33
27
  control: c,
34
- formState: { errors: le, isDirty: ae },
35
- getValues: x,
28
+ formState: { errors: ie, isDirty: ne },
29
+ getValues: p,
36
30
  setValue: y,
37
- reset: de
38
- } = he({
31
+ reset: ae
32
+ } = ue({
39
33
  defaultValues: e.defaultValues
40
- }), [re, oe] = f.useState([]), [b, C] = f.useState(), [Be, se] = f.useState(0), ce = f.useMemo(() => {
34
+ }), [le, de] = u.useState([]), [g, C] = u.useState(), [Se, re] = u.useState(0), oe = u.useMemo(() => {
41
35
  const t = [];
42
36
  return e.mappedTemplates.forEach((n) => {
43
37
  n.creatable || t.push(String(n.id));
44
38
  }), t;
45
39
  }, [e.mappedTemplates]);
46
- f.useEffect(() => {
40
+ u.useEffect(() => {
47
41
  (async () => {
48
42
  const t = { ...e.defaultValues }, n = e.mappedTemplates.get(t.templateId);
49
43
  if (n) {
@@ -54,51 +48,51 @@ function we(e, ie) {
54
48
  for (let d = 0; d < a.length; d++) {
55
49
  const l = a[d], r = fe.get(t, `variables.${l.propertyId}`);
56
50
  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));
51
+ const m = await ve(Le), h = await be(m, String(r));
52
+ h.data && (y(`variables.${l.propertyId}`, h.data), re((v) => v + 1));
59
53
  }
60
54
  }
61
55
  }
62
56
  })();
63
57
  }, [e.defaultValues, e.mappedTemplates, e.keyAuth]);
64
- const O = () => {
65
- const t = x("templateId");
66
- b && C(void 0);
67
- const n = ve(e.mappedTemplates);
68
- oe(n);
58
+ const x = () => {
59
+ const t = p("templateId");
60
+ g && C(void 0);
61
+ const n = he(e.mappedTemplates);
62
+ de(n);
69
63
  for (const a of e.mappedTemplates.values())
70
64
  if (a.id === t) {
71
65
  C(a);
72
66
  break;
73
67
  }
74
68
  };
75
- f.useImperativeHandle(ie, () => ({
69
+ u.useImperativeHandle(ee, () => ({
76
70
  resetForm() {
77
- de({
71
+ ae({
78
72
  title: "",
79
73
  description: "",
80
74
  templateId: 0,
81
75
  variables: {}
82
- }), O();
76
+ }), x();
83
77
  },
84
78
  setFormValue(t, n) {
85
79
  y(t, n);
86
80
  },
87
81
  getFormValue(t) {
88
- return x(t);
82
+ return p(t);
89
83
  }
90
- })), f.useEffect(() => (O(), () => {
91
- }), [e.mappedTemplates]), f.useEffect(() => {
92
- e.onSelectedTemplateChange && e.onSelectedTemplateChange(b);
93
- }, [b]);
94
- const me = () => {
84
+ })), u.useEffect(() => (x(), () => {
85
+ }), [e.mappedTemplates]), u.useEffect(() => {
86
+ e.onSelectedTemplateChange && e.onSelectedTemplateChange(g);
87
+ }, [g]);
88
+ const se = () => {
95
89
  if (e.onCancel) {
96
- e.onCancel(ae);
90
+ e.onCancel(ne);
97
91
  return;
98
92
  }
99
93
  };
100
94
  return /* @__PURE__ */ i(
101
- Te,
95
+ ye,
102
96
  {
103
97
  condition: e.variant === void 0 || e.variant === "inline",
104
98
  wrapper: (t) => /* @__PURE__ */ i(
@@ -112,42 +106,42 @@ function we(e, ie) {
112
106
  children: /* @__PURE__ */ o(
113
107
  "form",
114
108
  {
115
- onSubmit: ne(e.onSubmit),
109
+ onSubmit: te(e.onSubmit),
116
110
  style: { display: "flex", flexDirection: "column" },
117
111
  children: [
118
- !((V = (L = e.fieldOptions) == null ? void 0 : L.title) != null && V.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
112
+ !((L = (I = e.fieldOptions) == null ? void 0 : I.title) != null && L.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
119
113
  /* @__PURE__ */ i(
120
- v,
114
+ b,
121
115
  {
122
116
  label: "Title *",
123
117
  variant: e.inputVariant,
124
118
  fullWidth: !0,
125
- ...p("title", { required: !0 }),
126
- ...le.title && {
119
+ ...O("title", { required: !0 }),
120
+ ...ie.title && {
127
121
  helperText: "This field is required!",
128
122
  error: !0
129
123
  }
130
124
  }
131
125
  ),
132
- e.fieldOptions && ((S = e.fieldOptions.title) == null ? void 0 : S.helperText)
126
+ e.fieldOptions && ((V = e.fieldOptions.title) == null ? void 0 : V.helperText)
133
127
  ] }),
134
- !((F = (E = e.fieldOptions) == null ? void 0 : E.description) != null && F.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
128
+ !((k = (S = e.fieldOptions) == null ? void 0 : S.description) != null && k.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
135
129
  /* @__PURE__ */ i(
136
- v,
130
+ b,
137
131
  {
138
132
  label: "Description",
139
133
  variant: e.inputVariant,
140
134
  fullWidth: !0,
141
135
  multiline: !0,
142
- minRows: (R = (k = e.fieldOptions) == null ? void 0 : k.description) == null ? void 0 : R.minRows,
143
- ...p("description")
136
+ minRows: (E = (F = e.fieldOptions) == null ? void 0 : F.description) == null ? void 0 : E.minRows,
137
+ ...O("description")
144
138
  }
145
139
  ),
146
- e.fieldOptions && ((w = e.fieldOptions.description) == null ? void 0 : w.helperText)
140
+ e.fieldOptions && ((R = e.fieldOptions.description) == null ? void 0 : R.helperText)
147
141
  ] }),
148
- !((_ = (B = e.fieldOptions) == null ? void 0 : B.templateId) != null && _.hidden) && /* @__PURE__ */ o(Oe, { sx: { mb: 2 }, children: [
142
+ !((B = (w = e.fieldOptions) == null ? void 0 : w.templateId) != null && B.hidden) && /* @__PURE__ */ o(Te, { sx: { mb: 2 }, children: [
149
143
  /* @__PURE__ */ i(
150
- u,
144
+ f,
151
145
  {
152
146
  name: "templateId",
153
147
  control: c,
@@ -156,7 +150,7 @@ function we(e, ie) {
156
150
  if ((d = (a = e.fieldOptions) == null ? void 0 : a.templateId) != null && d.disabled) {
157
151
  const l = t ? e.mappedTemplates.get(t) : void 0;
158
152
  return /* @__PURE__ */ i(
159
- v,
153
+ b,
160
154
  {
161
155
  label: "Template",
162
156
  variant: e.inputVariant,
@@ -168,12 +162,12 @@ function we(e, ie) {
168
162
  );
169
163
  }
170
164
  return /* @__PURE__ */ i(
171
- Le,
165
+ xe,
172
166
  {
173
167
  label: "Template",
174
- data: re,
168
+ data: le,
175
169
  selected: t === 0 ? "" : [String(t)],
176
- disabled: ce,
170
+ disabled: oe,
177
171
  variant: e.inputVariant,
178
172
  onChange: (l, r) => {
179
173
  const m = {
@@ -181,33 +175,33 @@ function we(e, ie) {
181
175
  value: r ? Number(l) : 0
182
176
  }
183
177
  };
184
- n(m), O();
178
+ n(m), x();
185
179
  }
186
180
  }
187
181
  );
188
182
  }
189
183
  }
190
184
  ),
191
- e.fieldOptions && ((A = e.fieldOptions.templateId) == null ? void 0 : A.helperText)
185
+ e.fieldOptions && ((D = e.fieldOptions.templateId) == null ? void 0 : D.helperText)
192
186
  ] }),
193
- "aliasList" in e.defaultValues && !((P = (D = e.fieldOptions) == null ? void 0 : D.aliasList) != null && P.hidden) && /* @__PURE__ */ i(
194
- u,
187
+ "aliasList" in e.defaultValues && !((_ = (P = e.fieldOptions) == null ? void 0 : P.aliasList) != null && _.hidden) && /* @__PURE__ */ i(
188
+ f,
195
189
  {
196
190
  name: "aliasList",
197
191
  control: c,
198
192
  render: ({ field: { value: t, onChange: n, ...a } }) => {
199
193
  var l;
200
194
  const d = (r) => {
201
- const T = {
195
+ const v = {
202
196
  target: {
203
- value: r.target.value.split(",").map((I) => I.trimStart())
197
+ value: r.target.value.split(",").map((z) => z.trimStart())
204
198
  }
205
199
  };
206
- n(T);
200
+ n(v);
207
201
  };
208
202
  return /* @__PURE__ */ o(s, { mb: 2, children: [
209
203
  /* @__PURE__ */ i(
210
- v,
204
+ b,
211
205
  {
212
206
  label: "Alias List",
213
207
  variant: e.inputVariant,
@@ -223,8 +217,8 @@ function we(e, ie) {
223
217
  }
224
218
  }
225
219
  ),
226
- "appliedPolicies" in e.defaultValues && !((M = (W = e.fieldOptions) == null ? void 0 : W.appliedPolicies) != null && M.hidden) && /* @__PURE__ */ i(
227
- u,
220
+ "appliedPolicies" in e.defaultValues && !((W = (A = e.fieldOptions) == null ? void 0 : A.appliedPolicies) != null && W.hidden) && /* @__PURE__ */ i(
221
+ f,
228
222
  {
229
223
  name: "appliedPolicies",
230
224
  control: c,
@@ -232,7 +226,7 @@ function we(e, ie) {
232
226
  var a;
233
227
  return /* @__PURE__ */ o(s, { mb: 2, children: [
234
228
  /* @__PURE__ */ i(
235
- Ve,
229
+ Oe,
236
230
  {
237
231
  policyList: e.policyList,
238
232
  value: t || void 0,
@@ -245,14 +239,14 @@ function we(e, ie) {
245
239
  }
246
240
  ),
247
241
  /* @__PURE__ */ i(
248
- u,
242
+ f,
249
243
  {
250
244
  name: "variables",
251
245
  control: c,
252
246
  render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ i(
253
- Se,
247
+ pe,
254
248
  {
255
- template: b,
249
+ template: g,
256
250
  value: t,
257
251
  mapboxAccessToken: e.mapboxAccessToken,
258
252
  variant: e.inputVariant,
@@ -262,28 +256,28 @@ function we(e, ie) {
262
256
  )
263
257
  }
264
258
  ),
265
- "fileInBase64" in e.defaultValues && !((G = (N = e.fieldOptions) == null ? void 0 : N.fileInBase64) != null && G.hidden) && /* @__PURE__ */ o(ue, { children: [
259
+ "fileInBase64" in e.defaultValues && !((K = (N = e.fieldOptions) == null ? void 0 : N.fileInBase64) != null && K.hidden) && /* @__PURE__ */ o(me, { children: [
266
260
  /* @__PURE__ */ i(
267
- u,
261
+ f,
268
262
  {
269
263
  name: "fileInBase64",
270
264
  control: c,
271
- render: ({ field: { onChange: t, ...n } }) => {
272
- var d;
273
- const a = (l) => {
274
- if (l.target.files) {
275
- const r = new FileReader();
276
- r.onload = async (h) => {
277
- const I = h.target.result.split("base64,")[1];
278
- t(I);
265
+ render: ({ field: { onChange: t, value: n, ...a } }) => {
266
+ var l;
267
+ const d = (r) => {
268
+ if (r.target.files) {
269
+ const m = new FileReader();
270
+ m.onload = async (v) => {
271
+ const ce = v.target.result.split("base64,")[1];
272
+ t(ce);
279
273
  };
280
- const m = l.target.files[0];
281
- y("originalFileName", m.name), y("contentType", m.type), r.readAsDataURL(m);
274
+ const h = r.target.files[0];
275
+ y("originalFileName", h.name), y("contentType", h.type), m.readAsDataURL(h);
282
276
  }
283
277
  };
284
278
  return /* @__PURE__ */ o(s, { mb: 2, children: [
285
279
  /* @__PURE__ */ i(
286
- v,
280
+ b,
287
281
  {
288
282
  type: "file",
289
283
  label: "File to Upload",
@@ -291,82 +285,52 @@ function we(e, ie) {
291
285
  fullWidth: !0,
292
286
  helperText: "Select a file to upload",
293
287
  InputLabelProps: { shrink: !0 },
294
- onChange: a,
295
- ...n
288
+ onChange: d,
289
+ ...a
296
290
  }
297
291
  ),
298
- e.fieldOptions && ((d = e.fieldOptions.fileInBase64) == null ? void 0 : d.helperText)
299
- ] });
300
- }
301
- }
302
- ),
303
- !((U = (K = e.fieldOptions) == null ? void 0 : K.type) != null && U.hidden) && /* @__PURE__ */ i(
304
- u,
305
- {
306
- name: "type",
307
- control: c,
308
- render: ({ field: { value: t, onChange: n } }) => {
309
- var d;
310
- const a = (l) => {
311
- const {
312
- target: { value: r }
313
- } = l;
314
- n(r);
315
- };
316
- return /* @__PURE__ */ o(s, { mb: 2, children: [
317
- /* @__PURE__ */ o(Ie, { fullWidth: !0, variant: e.inputVariant, children: [
318
- /* @__PURE__ */ i(pe, { children: "Type" }),
319
- /* @__PURE__ */ i(
320
- xe,
321
- {
322
- value: t ? [t] : "",
323
- onChange: a,
324
- children: Re.map((l) => /* @__PURE__ */ i(Ce, { value: l, children: l }, l))
325
- }
326
- )
327
- ] }),
328
- e.fieldOptions && ((d = e.fieldOptions.type) == null ? void 0 : d.helperText)
292
+ e.fieldOptions && ((l = e.fieldOptions.fileInBase64) == null ? void 0 : l.helperText)
329
293
  ] });
330
294
  }
331
295
  }
332
296
  ),
333
- !((q = (j = e.fieldOptions) == null ? void 0 : j.redacted) != null && q.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
297
+ !((j = (M = e.fieldOptions) == null ? void 0 : M.redacted) != null && j.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
334
298
  /* @__PURE__ */ i(
335
- ee,
299
+ X,
336
300
  {
337
301
  control: /* @__PURE__ */ i(
338
- u,
302
+ f,
339
303
  {
340
304
  name: "redacted",
341
305
  control: c,
342
- render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(te, { checked: !!t, ...n })
306
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(Z, { checked: !!t, ...n })
343
307
  }
344
308
  ),
345
309
  label: "Redacted"
346
310
  }
347
311
  ),
348
- e.fieldOptions && ((H = e.fieldOptions.redacted) == null ? void 0 : H.helperText)
312
+ e.fieldOptions && ((q = e.fieldOptions.redacted) == null ? void 0 : q.helperText)
349
313
  ] }),
350
- !((J = (Y = e.fieldOptions) == null ? void 0 : Y.contentEncrypted) != null && J.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
314
+ !((U = (G = e.fieldOptions) == null ? void 0 : G.contentEncrypted) != null && U.hidden) && /* @__PURE__ */ o(s, { mb: 2, children: [
351
315
  /* @__PURE__ */ i(
352
- ee,
316
+ X,
353
317
  {
354
318
  control: /* @__PURE__ */ i(
355
- u,
319
+ f,
356
320
  {
357
321
  name: "contentEncrypted",
358
322
  control: c,
359
- render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(te, { checked: !!t, ...n })
323
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(Z, { checked: !!t, ...n })
360
324
  }
361
325
  ),
362
326
  label: "Content Encrypted"
363
327
  }
364
328
  ),
365
- e.fieldOptions && (($ = e.fieldOptions.contentEncrypted) == null ? void 0 : $.helperText)
329
+ e.fieldOptions && ((H = e.fieldOptions.contentEncrypted) == null ? void 0 : H.helperText)
366
330
  ] })
367
331
  ] }),
368
- !((X = (Q = e.fieldOptions) == null ? void 0 : Q.disseminationList) != null && X.hidden) && /* @__PURE__ */ i(
369
- u,
332
+ !(($ = (J = e.fieldOptions) == null ? void 0 : J.disseminationList) != null && $.hidden) && /* @__PURE__ */ i(
333
+ f,
370
334
  {
371
335
  name: "disseminationList",
372
336
  rules: {
@@ -378,7 +342,7 @@ function we(e, ie) {
378
342
  n(r);
379
343
  };
380
344
  return /* @__PURE__ */ i(
381
- Ee,
345
+ Ce,
382
346
  {
383
347
  selectedIds: d,
384
348
  memberedGroups: e.memberedGroups,
@@ -390,8 +354,8 @@ function we(e, ie) {
390
354
  }
391
355
  }
392
356
  ),
393
- !((Z = (z = e.fieldOptions) == null ? void 0 : z.securityLevelId) != null && Z.hidden) && /* @__PURE__ */ i(s, { mt: 2, children: /* @__PURE__ */ i(
394
- u,
357
+ !((Y = (Q = e.fieldOptions) == null ? void 0 : Q.securityLevelId) != null && Y.hidden) && /* @__PURE__ */ i(s, { mt: 2, children: /* @__PURE__ */ i(
358
+ f,
395
359
  {
396
360
  name: "securityLevelId",
397
361
  rules: {
@@ -404,7 +368,7 @@ function we(e, ie) {
404
368
  n(m);
405
369
  };
406
370
  return /* @__PURE__ */ i(
407
- Fe,
371
+ Ie,
408
372
  {
409
373
  value: t || 0,
410
374
  ontologyId: e.ontologyId,
@@ -423,19 +387,19 @@ function we(e, ie) {
423
387
  ) }),
424
388
  /* @__PURE__ */ o(s, { display: "flex", justifyContent: "space-between", mt: 3, children: [
425
389
  /* @__PURE__ */ i(
426
- g,
390
+ T,
427
391
  {
428
392
  color: "primary",
429
393
  variant: "text",
430
394
  disabled: e.loading,
431
395
  sx: { textTransform: "none" },
432
- onClick: me,
396
+ onClick: se,
433
397
  children: "Cancel"
434
398
  }
435
399
  ),
436
400
  /* @__PURE__ */ o(s, { children: [
437
401
  e.onRemove !== void 0 && /* @__PURE__ */ i(
438
- g,
402
+ T,
439
403
  {
440
404
  type: "button",
441
405
  color: "error",
@@ -447,7 +411,7 @@ function we(e, ie) {
447
411
  }
448
412
  ),
449
413
  e.saveButtons ? e.saveButtons.map((t, n) => /* @__PURE__ */ i(
450
- g,
414
+ T,
451
415
  {
452
416
  type: "submit",
453
417
  color: "primary",
@@ -460,7 +424,7 @@ function we(e, ie) {
460
424
  },
461
425
  n
462
426
  )) : /* @__PURE__ */ i(
463
- g,
427
+ T,
464
428
  {
465
429
  type: "submit",
466
430
  color: "primary",
@@ -478,7 +442,7 @@ function we(e, ie) {
478
442
  }
479
443
  );
480
444
  }
481
- const Je = f.forwardRef(we);
445
+ const je = u.forwardRef(Ve);
482
446
  export {
483
- Je as InstanceForm
447
+ je as InstanceForm
484
448
  };
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.11",
4
+ "version": "1.5.13",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",