@hybridcore/ui 1.5.12 → 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 fe } from "react/jsx-runtime";
2
- import f from "react";
3
- import he from "lodash";
4
- import { useForm as ve, Controller as m } from "react-hook-form";
5
- import { getNestedChildrenFromMap as ye } from "../../utils/ontology.js";
6
- import { i as be, d as Te } from "../../utils-Bq0ye5vf.js";
7
- import { ConditionalWrapper as ge } from "../conditional-wrapper/index.js";
8
- import { Container as Oe } from "../container/index.js";
9
- import { Box as s, TextField as y, FormGroup as Ie, FormControl as pe, InputLabel as xe, Select as Ce, MenuItem as Le, FormControlLabel as ee, Checkbox as te, Button as g } from "@mui/material";
10
- import { TreeSelect as Ve } from "../tree-select/index.js";
11
- import Se from "./components/policy-list/index.js";
12
- import Ee from "./components/variables/index.js";
13
- import { DisseminationList as Fe } from "../data-security-selectors/dissemination-list/index.js";
14
- import { SecurityLevel as ke } from "../data-security-selectors/security-level/index.js";
15
- const Re = {
1
+ import { jsx as i, jsxs as o, Fragment as me } from "react/jsx-runtime";
2
+ import u from "react";
3
+ import fe from "lodash";
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
+ import { Container as ge } from "../container/index.js";
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
- }, we = [
22
- "IMAGE",
23
- "VIDEO",
24
- "TEXT",
25
- "BINARY",
26
- "OTHER"
27
- ];
28
- function Be(e, ie) {
29
- var C, 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;
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: I,
32
- handleSubmit: ne,
25
+ register: O,
26
+ handleSubmit: te,
33
27
  control: c,
34
- formState: { errors: le, isDirty: ae },
28
+ formState: { errors: ie, isDirty: ne },
35
29
  getValues: p,
36
- setValue: b,
37
- reset: de
38
- } = ve({
30
+ setValue: y,
31
+ reset: ae
32
+ } = ue({
39
33
  defaultValues: e.defaultValues
40
- }), [re, oe] = f.useState([]), [T, x] = f.useState(), [_e, 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) {
@@ -52,57 +46,57 @@ function Be(e, ie) {
52
46
  );
53
47
  if (a.length > 0)
54
48
  for (let d = 0; d < a.length; d++) {
55
- const l = a[d], r = he.get(t, `variables.${l.propertyId}`);
49
+ const l = a[d], r = fe.get(t, `variables.${l.propertyId}`);
56
50
  if (r && e.keyAuth) {
57
- const u = await be(Re), h = await Te(u, String(r));
58
- h.data && (b(`variables.${l.propertyId}`, h.data), se((v) => v + 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 = () => {
58
+ const x = () => {
65
59
  const t = p("templateId");
66
- T && x(void 0);
67
- const n = ye(e.mappedTemplates);
68
- oe(n);
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
- x(a);
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
- b(t, n);
79
+ y(t, n);
86
80
  },
87
81
  getFormValue(t) {
88
82
  return p(t);
89
83
  }
90
- })), f.useEffect(() => (O(), () => {
91
- }), [e.mappedTemplates]), f.useEffect(() => {
92
- e.onSelectedTemplateChange && e.onSelectedTemplateChange(T);
93
- }, [T]);
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
- ge,
95
+ ye,
102
96
  {
103
97
  condition: e.variant === void 0 || e.variant === "inline",
104
98
  wrapper: (t) => /* @__PURE__ */ i(
105
- Oe,
99
+ ge,
106
100
  {
107
101
  disableHeader: !0,
108
102
  sx: { position: "relative", overflow: "visible" },
@@ -112,18 +106,18 @@ function Be(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
- !((L = (C = e.fieldOptions) == null ? void 0 : C.title) != null && L.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
- y,
114
+ b,
121
115
  {
122
116
  label: "Title *",
123
117
  variant: e.inputVariant,
124
118
  fullWidth: !0,
125
- ...I("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
  }
@@ -131,23 +125,23 @@ function Be(e, ie) {
131
125
  ),
132
126
  e.fieldOptions && ((V = e.fieldOptions.title) == null ? void 0 : V.helperText)
133
127
  ] }),
134
- !((E = (S = e.fieldOptions) == null ? void 0 : S.description) != null && E.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
- y,
130
+ b,
137
131
  {
138
132
  label: "Description",
139
133
  variant: e.inputVariant,
140
134
  fullWidth: !0,
141
135
  multiline: !0,
142
- minRows: (k = (F = e.fieldOptions) == null ? void 0 : F.description) == null ? void 0 : k.minRows,
143
- ...I("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
140
  e.fieldOptions && ((R = e.fieldOptions.description) == null ? void 0 : R.helperText)
147
141
  ] }),
148
- !((B = (w = e.fieldOptions) == null ? void 0 : w.templateId) != null && B.hidden) && /* @__PURE__ */ o(Ie, { 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
- m,
144
+ f,
151
145
  {
152
146
  name: "templateId",
153
147
  control: c,
@@ -156,7 +150,7 @@ function Be(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
- y,
153
+ b,
160
154
  {
161
155
  label: "Template",
162
156
  variant: e.inputVariant,
@@ -168,30 +162,30 @@ function Be(e, ie) {
168
162
  );
169
163
  }
170
164
  return /* @__PURE__ */ i(
171
- Ve,
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
- const u = {
173
+ const m = {
180
174
  target: {
181
175
  value: r ? Number(l) : 0
182
176
  }
183
177
  };
184
- n(u), O();
178
+ n(m), x();
185
179
  }
186
180
  }
187
181
  );
188
182
  }
189
183
  }
190
184
  ),
191
- e.fieldOptions && ((_ = e.fieldOptions.templateId) == null ? void 0 : _.helperText)
185
+ e.fieldOptions && ((D = e.fieldOptions.templateId) == null ? void 0 : D.helperText)
192
186
  ] }),
193
- "aliasList" in e.defaultValues && !((D = (A = e.fieldOptions) == null ? void 0 : A.aliasList) != null && D.hidden) && /* @__PURE__ */ i(
194
- m,
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,
@@ -200,14 +194,14 @@ function Be(e, ie) {
200
194
  const d = (r) => {
201
195
  const v = {
202
196
  target: {
203
- value: r.target.value.split(",").map((Z) => Z.trimStart())
197
+ value: r.target.value.split(",").map((z) => z.trimStart())
204
198
  }
205
199
  };
206
200
  n(v);
207
201
  };
208
202
  return /* @__PURE__ */ o(s, { mb: 2, children: [
209
203
  /* @__PURE__ */ i(
210
- y,
204
+ b,
211
205
  {
212
206
  label: "Alias List",
213
207
  variant: e.inputVariant,
@@ -223,8 +217,8 @@ function Be(e, ie) {
223
217
  }
224
218
  }
225
219
  ),
226
- "appliedPolicies" in e.defaultValues && !((W = (P = e.fieldOptions) == null ? void 0 : P.appliedPolicies) != null && W.hidden) && /* @__PURE__ */ i(
227
- m,
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 Be(e, ie) {
232
226
  var a;
233
227
  return /* @__PURE__ */ o(s, { mb: 2, children: [
234
228
  /* @__PURE__ */ i(
235
- Se,
229
+ Oe,
236
230
  {
237
231
  policyList: e.policyList,
238
232
  value: t || void 0,
@@ -245,14 +239,14 @@ function Be(e, ie) {
245
239
  }
246
240
  ),
247
241
  /* @__PURE__ */ i(
248
- m,
242
+ f,
249
243
  {
250
244
  name: "variables",
251
245
  control: c,
252
246
  render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ i(
253
- Ee,
247
+ pe,
254
248
  {
255
- template: T,
249
+ template: g,
256
250
  value: t,
257
251
  mapboxAccessToken: e.mapboxAccessToken,
258
252
  variant: e.inputVariant,
@@ -262,9 +256,9 @@ function Be(e, ie) {
262
256
  )
263
257
  }
264
258
  ),
265
- "fileInBase64" in e.defaultValues && !((N = (M = e.fieldOptions) == null ? void 0 : M.fileInBase64) != null && N.hidden) && /* @__PURE__ */ o(fe, { 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
- m,
261
+ f,
268
262
  {
269
263
  name: "fileInBase64",
270
264
  control: c,
@@ -272,18 +266,18 @@ function Be(e, ie) {
272
266
  var l;
273
267
  const d = (r) => {
274
268
  if (r.target.files) {
275
- const u = new FileReader();
276
- u.onload = async (v) => {
277
- const ue = v.target.result.split("base64,")[1];
278
- t(ue);
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
274
  const h = r.target.files[0];
281
- b("originalFileName", h.name), b("contentType", h.type), u.readAsDataURL(h);
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
- y,
280
+ b,
287
281
  {
288
282
  type: "file",
289
283
  label: "File to Upload",
@@ -300,46 +294,16 @@ function Be(e, ie) {
300
294
  }
301
295
  }
302
296
  ),
303
- !((K = (G = e.fieldOptions) == null ? void 0 : G.type) != null && K.hidden) && /* @__PURE__ */ i(
304
- m,
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(pe, { fullWidth: !0, variant: e.inputVariant, children: [
318
- /* @__PURE__ */ i(xe, { children: "Type" }),
319
- /* @__PURE__ */ i(
320
- Ce,
321
- {
322
- value: t ? [t] : "",
323
- onChange: a,
324
- children: we.map((l) => /* @__PURE__ */ i(Le, { value: l, children: l }, l))
325
- }
326
- )
327
- ] }),
328
- e.fieldOptions && ((d = e.fieldOptions.type) == null ? void 0 : d.helperText)
329
- ] });
330
- }
331
- }
332
- ),
333
- !((j = (U = e.fieldOptions) == null ? void 0 : U.redacted) != null && j.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
- m,
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"
@@ -347,26 +311,26 @@ function Be(e, ie) {
347
311
  ),
348
312
  e.fieldOptions && ((q = e.fieldOptions.redacted) == null ? void 0 : q.helperText)
349
313
  ] }),
350
- !((Y = (H = e.fieldOptions) == null ? void 0 : H.contentEncrypted) != null && Y.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
- m,
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 && ((J = e.fieldOptions.contentEncrypted) == null ? void 0 : J.helperText)
329
+ e.fieldOptions && ((H = e.fieldOptions.contentEncrypted) == null ? void 0 : H.helperText)
366
330
  ] })
367
331
  ] }),
368
- !((Q = ($ = e.fieldOptions) == null ? void 0 : $.disseminationList) != null && Q.hidden) && /* @__PURE__ */ i(
369
- m,
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 Be(e, ie) {
378
342
  n(r);
379
343
  };
380
344
  return /* @__PURE__ */ i(
381
- Fe,
345
+ Ce,
382
346
  {
383
347
  selectedIds: d,
384
348
  memberedGroups: e.memberedGroups,
@@ -390,8 +354,8 @@ function Be(e, ie) {
390
354
  }
391
355
  }
392
356
  ),
393
- !((z = (X = e.fieldOptions) == null ? void 0 : X.securityLevelId) != null && z.hidden) && /* @__PURE__ */ i(s, { mt: 2, children: /* @__PURE__ */ i(
394
- m,
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: {
@@ -400,11 +364,11 @@ function Be(e, ie) {
400
364
  control: c,
401
365
  render: ({ field: { value: t, onChange: n }, fieldState: a }) => {
402
366
  var l, r;
403
- const d = (u) => {
404
- n(u);
367
+ const d = (m) => {
368
+ n(m);
405
369
  };
406
370
  return /* @__PURE__ */ i(
407
- ke,
371
+ Ie,
408
372
  {
409
373
  value: t || 0,
410
374
  ontologyId: e.ontologyId,
@@ -423,19 +387,19 @@ function Be(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 Be(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 Be(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 Be(e, ie) {
478
442
  }
479
443
  );
480
444
  }
481
- const $e = f.forwardRef(Be);
445
+ const je = u.forwardRef(Ve);
482
446
  export {
483
- $e 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.12",
4
+ "version": "1.5.13",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",