@hybridcore/ui 1.5.38 → 1.5.41

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,293 +1,308 @@
1
- import { jsx as i, jsxs as d, Fragment as he } from "react/jsx-runtime";
2
- import h, { useRef as be } from "react";
3
- import ve from "lodash";
4
- import { useForm as ye, Controller as f } from "react-hook-form";
5
- import { getNestedChildrenFromMap as ge } from "../../utils/ontology.js";
6
- import { i as Te, d as xe } from "../../utils-Bq0ye5vf.js";
7
- import { ConditionalWrapper as u } from "../conditional-wrapper/index.js";
8
- import { Container as Ie } from "../container/index.js";
9
- import { Box as n, Typography as b, TextField as g, FormGroup as we, FormControlLabel as te, Checkbox as ie, Button as I } from "@mui/material";
10
- import { TreeSelect as Pe } from "../tree-select/index.js";
11
- import Ce from "./components/policy-list/index.js";
12
- import Le from "./components/variables/index.js";
13
- import { DisseminationList as Oe } from "../data-security-selectors/dissemination-list/index.js";
14
- import { SecurityLevel as pe } from "../data-security-selectors/security-level/index.js";
15
- const Ve = {
1
+ import { jsx as i, jsxs as o, Fragment as xe } from "react/jsx-runtime";
2
+ import v, { useRef as Te } from "react";
3
+ import Ie from "lodash";
4
+ import { useForm as we, Controller as u } from "react-hook-form";
5
+ import { getNestedChildrenFromMap as Ce } from "../../utils/ontology.js";
6
+ import { i as Le, d as Oe } from "../../utils-Bq0ye5vf.js";
7
+ import { ConditionalWrapper as h } from "../conditional-wrapper/index.js";
8
+ import { Container as Ve } from "../container/index.js";
9
+ import { Box as l, Typography as y, TextField as x, FormHelperText as re, FormGroup as Se, FormControlLabel as oe, Checkbox as ce, Button as w } from "@mui/material";
10
+ import { TreeSelect as Fe } from "../tree-select/index.js";
11
+ import ke from "./components/policy-list/index.js";
12
+ import Re from "./components/variables/index.js";
13
+ import { DisseminationList as Ee } from "../data-security-selectors/dissemination-list/index.js";
14
+ import { SecurityLevel as Pe } from "../data-security-selectors/security-level/index.js";
15
+ const Be = {
16
16
  alg: "A256GCM",
17
17
  ext: !0,
18
18
  k: "_El6rHQxC5E7NdO5DiMDITjF7f65wrlaJmFVagVE9Ic",
19
19
  key_ops: ["encrypt", "decrypt"],
20
20
  kty: "oct"
21
21
  };
22
- function Se(e, le) {
23
- var p, V, S, F, k, R, E, B, D, _, A, W, q, N, K, M, U, j, G, H, J, $, Q, Y, z, X, Z;
24
- const P = be(null), {
25
- register: C,
26
- handleSubmit: ne,
27
- control: s,
28
- formState: { errors: ae, isDirty: de },
29
- getValues: L,
22
+ function De(e, se) {
23
+ var R, E, P, B, D, A, N, _, W, q, $, K, M, U, j, G, H, J, Q, Y, z, X, Z, ee, te, ie, ne, le, ae;
24
+ const L = Te(null), {
25
+ register: O,
26
+ handleSubmit: me,
27
+ control: m,
28
+ formState: { errors: fe, isDirty: V },
29
+ getValues: S,
30
30
  setValue: T,
31
- reset: re
32
- } = ye({
31
+ reset: ue,
32
+ watch: F
33
+ } = we({
33
34
  defaultValues: e.defaultValues
34
- }), [oe, ce] = h.useState([]), [x, O] = h.useState(), [Fe, se] = h.useState(0), me = h.useMemo(() => {
35
+ }), c = (e == null ? void 0 : e.labelPosition) ?? "default", [he, ve] = v.useState([]), [I, k] = v.useState(), [Ae, ge] = v.useState(0), ye = v.useMemo(() => {
35
36
  const t = [];
36
- return e.mappedTemplates.forEach((l) => {
37
- l.creatable || t.push(String(l.id));
37
+ return e.mappedTemplates.forEach((n) => {
38
+ n.creatable || t.push(String(n.id));
38
39
  }), t;
39
40
  }, [e.mappedTemplates]);
40
- h.useEffect(() => {
41
+ v.useEffect(() => {
41
42
  (async () => {
42
- const t = { ...e.defaultValues }, l = e.mappedTemplates.get(t.templateId);
43
- if (l) {
44
- const a = l.properties.filter(
45
- (o) => o.privacyPreservationMethod === "ENCRYPTION"
43
+ const t = { ...e.defaultValues }, n = e.mappedTemplates.get(t.templateId);
44
+ if (n) {
45
+ const d = n.properties.filter(
46
+ (r) => r.privacyPreservationMethod === "ENCRYPTION"
46
47
  );
47
- if (a.length > 0)
48
- for (let o = 0; o < a.length; o++) {
49
- const r = a[o], c = ve.get(t, `variables.${r.propertyId}`);
50
- if (c && e.keyAuth) {
51
- const m = await Te(Ve), v = await xe(m, String(c));
52
- v.data && (T(`variables.${r.propertyId}`, v.data), se((y) => y + 1));
48
+ if (d.length > 0)
49
+ for (let r = 0; r < d.length; r++) {
50
+ const a = d[r], s = Ie.get(t, `variables.${a.propertyId}`);
51
+ if (s && e.keyAuth) {
52
+ const f = await Le(Be), b = await Oe(f, String(s));
53
+ b.data && (T(`variables.${a.propertyId}`, b.data), ge((p) => p + 1));
53
54
  }
54
55
  }
55
56
  }
56
57
  })();
57
58
  }, [e.defaultValues, e.mappedTemplates, e.keyAuth]);
58
- const w = () => {
59
- const t = L("templateId");
60
- x && O(void 0);
61
- const l = ge(e.mappedTemplates);
62
- ce(l);
63
- for (const a of e.mappedTemplates.values())
64
- if (a.id === t) {
65
- O(a);
59
+ const C = () => {
60
+ const t = S("templateId");
61
+ I && k(void 0);
62
+ const n = Ce(e.mappedTemplates);
63
+ ve(n);
64
+ for (const d of e.mappedTemplates.values())
65
+ if (d.id === t) {
66
+ k(d);
66
67
  break;
67
68
  }
68
69
  };
69
- h.useImperativeHandle(le, () => ({
70
+ v.useImperativeHandle(se, () => ({
70
71
  requestSubmit() {
71
72
  var t;
72
- (t = P.current) == null || t.requestSubmit();
73
+ (t = L.current) == null || t.requestSubmit();
73
74
  },
74
75
  resetForm() {
75
- re({
76
+ ue({
76
77
  title: "",
77
78
  description: "",
78
79
  templateId: 0,
79
80
  variables: {}
80
- }), w();
81
+ }), C();
81
82
  },
82
- setFormValue(t, l) {
83
- T(t, l);
83
+ setFormValue(t, n) {
84
+ T(t, n);
84
85
  },
85
86
  getFormValue(t) {
86
- return L(t);
87
+ return S(t);
88
+ },
89
+ isDirty() {
90
+ return V;
87
91
  }
88
- })), h.useEffect(() => (w(), () => {
89
- }), [e.mappedTemplates]), h.useEffect(() => {
90
- e.onSelectedTemplateChange && e.onSelectedTemplateChange(x);
91
- }, [x]);
92
- const fe = () => {
92
+ })), v.useEffect(() => (C(), () => {
93
+ }), [e.mappedTemplates]), v.useEffect(() => {
94
+ e.onSelectedTemplateChange && e.onSelectedTemplateChange(I);
95
+ }, [I]);
96
+ const be = () => {
93
97
  if (e.onCancel) {
94
- e.onCancel(de);
98
+ e.onCancel(V);
95
99
  return;
96
100
  }
101
+ }, g = (t) => {
102
+ var r, a;
103
+ if (!t) return;
104
+ const n = (a = (r = e == null ? void 0 : e.fieldOptions) == null ? void 0 : r[t]) == null ? void 0 : a.maxChar;
105
+ return n != null && !Number.isNaN(Number(n)) ? Number(n) : void 0;
97
106
  };
98
107
  return /* @__PURE__ */ i(
99
- u,
108
+ h,
100
109
  {
101
110
  condition: e.variant === void 0 || e.variant === "inline",
102
111
  wrapper: (t) => /* @__PURE__ */ i(
103
- Ie,
112
+ Ve,
104
113
  {
105
114
  disableHeader: !0,
106
115
  sx: { position: "relative", overflow: "visible" },
107
116
  children: t
108
117
  }
109
118
  ),
110
- children: /* @__PURE__ */ d(
119
+ children: /* @__PURE__ */ o(
111
120
  "form",
112
121
  {
113
- ref: P,
114
- onSubmit: ne(e.onSubmit),
122
+ ref: L,
123
+ onSubmit: me(e.onSubmit),
115
124
  style: { display: "flex", flexDirection: "column" },
116
125
  children: [
117
- !((V = (p = e.fieldOptions) == null ? void 0 : p.title) != null && V.hidden) && /* @__PURE__ */ i(
118
- u,
126
+ !((E = (R = e.fieldOptions) == null ? void 0 : R.title) != null && E.hidden) && /* @__PURE__ */ i(
127
+ h,
119
128
  {
120
- condition: e.labelPosition === "left",
121
- wrapper: (t) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
122
- /* @__PURE__ */ i(b, { width: "32%", children: "Title *" }),
123
- /* @__PURE__ */ i(n, { width: "68%", children: t })
129
+ condition: c === "left",
130
+ wrapper: (t) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
131
+ /* @__PURE__ */ i(y, { width: "32%", children: "Title *" }),
132
+ /* @__PURE__ */ i(l, { width: "68%", children: t })
124
133
  ] }),
125
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
134
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
126
135
  /* @__PURE__ */ i(
127
- g,
136
+ x,
128
137
  {
129
- label: e.labelPosition === "default" ? "Title *" : void 0,
138
+ label: c === "default" ? "Title *" : void 0,
130
139
  variant: e.inputVariant,
140
+ inputProps: g("title") ? { maxLength: g("title") } : void 0,
131
141
  fullWidth: !0,
132
- ...C("title", { required: !0 }),
133
- ...ae.title && {
142
+ ...O("title", { required: !0 }),
143
+ ...fe.title && {
134
144
  helperText: "This field is required!",
135
145
  error: !0
136
146
  }
137
147
  }
138
148
  ),
139
- e.fieldOptions && ((S = e.fieldOptions.title) == null ? void 0 : S.helperText)
149
+ g("title") && /* @__PURE__ */ i(re, { sx: { textAlign: "right", mt: 0.5 }, children: `${(P = F("title")) == null ? void 0 : P.length}/${g("title")}` }),
150
+ e.fieldOptions && ((B = e.fieldOptions.title) == null ? void 0 : B.helperText)
140
151
  ] })
141
152
  }
142
153
  ),
143
- !((k = (F = e.fieldOptions) == null ? void 0 : F.description) != null && k.hidden) && /* @__PURE__ */ i(
144
- u,
154
+ !((A = (D = e.fieldOptions) == null ? void 0 : D.description) != null && A.hidden) && /* @__PURE__ */ i(
155
+ h,
145
156
  {
146
- condition: e.labelPosition === "left",
147
- wrapper: (t) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
148
- /* @__PURE__ */ i(b, { width: "32%", children: "Description" }),
149
- /* @__PURE__ */ i(n, { width: "68%", children: t })
157
+ condition: c === "left",
158
+ wrapper: (t) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
159
+ /* @__PURE__ */ i(y, { width: "32%", children: "Description" }),
160
+ /* @__PURE__ */ i(l, { width: "68%", children: t })
150
161
  ] }),
151
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
162
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
152
163
  /* @__PURE__ */ i(
153
- g,
164
+ x,
154
165
  {
155
- label: e.labelPosition === "default" ? "Description" : void 0,
166
+ label: c === "default" ? "Description" : void 0,
167
+ inputProps: g("description") ? { maxLength: g("description") } : void 0,
156
168
  variant: e.inputVariant,
157
169
  fullWidth: !0,
158
170
  multiline: !0,
159
- minRows: (E = (R = e.fieldOptions) == null ? void 0 : R.description) == null ? void 0 : E.minRows,
160
- ...C("description")
171
+ minRows: (_ = (N = e.fieldOptions) == null ? void 0 : N.description) == null ? void 0 : _.minRows,
172
+ ...O("description")
161
173
  }
162
174
  ),
163
- e.fieldOptions && ((B = e.fieldOptions.description) == null ? void 0 : B.helperText)
175
+ g("description") && /* @__PURE__ */ i(re, { sx: { textAlign: "right", mt: 0.5 }, children: `${(W = F("description")) == null ? void 0 : W.length}/${g(
176
+ "description"
177
+ )}` }),
178
+ e.fieldOptions && ((q = e.fieldOptions.description) == null ? void 0 : q.helperText)
164
179
  ] })
165
180
  }
166
181
  ),
167
- !((_ = (D = e.fieldOptions) == null ? void 0 : D.templateId) != null && _.hidden) && /* @__PURE__ */ i(
168
- u,
182
+ !((K = ($ = e.fieldOptions) == null ? void 0 : $.templateId) != null && K.hidden) && /* @__PURE__ */ i(
183
+ h,
169
184
  {
170
- condition: e.labelPosition === "left",
171
- wrapper: (t) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
172
- /* @__PURE__ */ i(b, { width: "32%", children: "Template" }),
173
- /* @__PURE__ */ i(n, { width: "68%", children: t })
185
+ condition: c === "left",
186
+ wrapper: (t) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
187
+ /* @__PURE__ */ i(y, { width: "32%", children: "Template" }),
188
+ /* @__PURE__ */ i(l, { width: "68%", children: t })
174
189
  ] }),
175
- children: /* @__PURE__ */ d(we, { sx: { mb: 2 }, children: [
190
+ children: /* @__PURE__ */ o(Se, { sx: { mb: 2 }, children: [
176
191
  /* @__PURE__ */ i(
177
- f,
192
+ u,
178
193
  {
179
194
  name: "templateId",
180
- control: s,
181
- render: ({ field: { value: t, onChange: l } }) => {
182
- var a, o;
183
- if ((o = (a = e.fieldOptions) == null ? void 0 : a.templateId) != null && o.disabled) {
184
- const r = t ? e.mappedTemplates.get(t) : void 0;
195
+ control: m,
196
+ render: ({ field: { value: t, onChange: n } }) => {
197
+ var d, r;
198
+ if ((r = (d = e.fieldOptions) == null ? void 0 : d.templateId) != null && r.disabled) {
199
+ const a = t ? e.mappedTemplates.get(t) : void 0;
185
200
  return /* @__PURE__ */ i(
186
- g,
201
+ x,
187
202
  {
188
203
  label: "Template",
189
204
  variant: e.inputVariant,
190
205
  fullWidth: !0,
191
206
  disabled: !0,
192
- value: r == null ? void 0 : r.name,
207
+ value: a == null ? void 0 : a.name,
193
208
  InputLabelProps: { shrink: !0 }
194
209
  }
195
210
  );
196
211
  }
197
212
  return /* @__PURE__ */ i(
198
- Pe,
213
+ Fe,
199
214
  {
200
- label: e.labelPosition === "default" ? "Template" : void 0,
201
- data: oe,
215
+ label: c === "default" ? "Template" : void 0,
216
+ data: he,
202
217
  selected: t === 0 ? "" : [String(t)],
203
- disabled: me,
218
+ disabled: ye,
204
219
  variant: e.inputVariant,
205
- onChange: (r, c) => {
206
- const m = {
220
+ onChange: (a, s) => {
221
+ const f = {
207
222
  target: {
208
- value: c ? Number(r) : 0
223
+ value: s ? Number(a) : 0
209
224
  }
210
225
  };
211
- l(m), w();
226
+ n(f), C();
212
227
  }
213
228
  }
214
229
  );
215
230
  }
216
231
  }
217
232
  ),
218
- e.fieldOptions && ((A = e.fieldOptions.templateId) == null ? void 0 : A.helperText)
233
+ e.fieldOptions && ((M = e.fieldOptions.templateId) == null ? void 0 : M.helperText)
219
234
  ] })
220
235
  }
221
236
  ),
222
- "aliasList" in e.defaultValues && !((q = (W = e.fieldOptions) == null ? void 0 : W.aliasList) != null && q.hidden) && /* @__PURE__ */ i(
223
- f,
237
+ "aliasList" in e.defaultValues && !((j = (U = e.fieldOptions) == null ? void 0 : U.aliasList) != null && j.hidden) && /* @__PURE__ */ i(
238
+ u,
224
239
  {
225
240
  name: "aliasList",
226
- control: s,
227
- render: ({ field: { value: t, onChange: l, ...a } }) => {
228
- var r;
229
- const o = (c) => {
230
- const y = {
241
+ control: m,
242
+ render: ({ field: { value: t, onChange: n, ...d } }) => {
243
+ var a;
244
+ const r = (s) => {
245
+ const p = {
231
246
  target: {
232
- value: c.target.value.split(",").map((ee) => ee.trimStart())
247
+ value: s.target.value.split(",").map((de) => de.trimStart())
233
248
  }
234
249
  };
235
- l(y);
250
+ n(p);
236
251
  };
237
252
  return /* @__PURE__ */ i(
238
- u,
253
+ h,
239
254
  {
240
- condition: e.labelPosition === "left",
241
- wrapper: (c) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
242
- /* @__PURE__ */ i(b, { width: "32%", children: "Alias List" }),
243
- /* @__PURE__ */ i(n, { width: "68%", children: c })
255
+ condition: c === "left",
256
+ wrapper: (s) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
257
+ /* @__PURE__ */ i(y, { width: "32%", children: "Alias List" }),
258
+ /* @__PURE__ */ i(l, { width: "68%", children: s })
244
259
  ] }),
245
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
260
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
246
261
  /* @__PURE__ */ i(
247
- g,
262
+ x,
248
263
  {
249
- label: e.labelPosition === "default" ? "Alias List" : void 0,
264
+ label: c === "default" ? "Alias List" : void 0,
250
265
  variant: e.inputVariant,
251
266
  fullWidth: !0,
252
267
  value: t,
253
268
  helperText: "Add list values with the comma (,) separated string",
254
- onChange: o,
255
- ...a
269
+ onChange: r,
270
+ ...d
256
271
  }
257
272
  ),
258
- e.fieldOptions && ((r = e.fieldOptions.aliasList) == null ? void 0 : r.helperText)
273
+ e.fieldOptions && ((a = e.fieldOptions.aliasList) == null ? void 0 : a.helperText)
259
274
  ] })
260
275
  }
261
276
  );
262
277
  }
263
278
  }
264
279
  ),
265
- "appliedPolicies" in e.defaultValues && !((K = (N = e.fieldOptions) == null ? void 0 : N.appliedPolicies) != null && K.hidden) && /* @__PURE__ */ i(
266
- f,
280
+ "appliedPolicies" in e.defaultValues && !((H = (G = e.fieldOptions) == null ? void 0 : G.appliedPolicies) != null && H.hidden) && /* @__PURE__ */ i(
281
+ u,
267
282
  {
268
283
  name: "appliedPolicies",
269
- control: s,
270
- render: ({ field: { value: t, onChange: l } }) => {
271
- var a;
284
+ control: m,
285
+ render: ({ field: { value: t, onChange: n } }) => {
286
+ var d;
272
287
  return /* @__PURE__ */ i(
273
- u,
288
+ h,
274
289
  {
275
- condition: e.labelPosition === "left",
276
- wrapper: (o) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
277
- /* @__PURE__ */ i(b, { width: "32%", children: "Policy List" }),
278
- /* @__PURE__ */ i(n, { width: "68%", children: o })
290
+ condition: c === "left",
291
+ wrapper: (r) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
292
+ /* @__PURE__ */ i(y, { width: "32%", children: "Policy List" }),
293
+ /* @__PURE__ */ i(l, { width: "68%", children: r })
279
294
  ] }),
280
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
295
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
281
296
  /* @__PURE__ */ i(
282
- Ce,
297
+ ke,
283
298
  {
284
299
  policyList: e.policyList,
285
- labelPosition: e.labelPosition,
300
+ labelPosition: c,
286
301
  value: t || void 0,
287
- onChange: l
302
+ onChange: n
288
303
  }
289
304
  ),
290
- e.fieldOptions && ((a = e.fieldOptions.appliedPolicies) == null ? void 0 : a.helperText)
305
+ e.fieldOptions && ((d = e.fieldOptions.appliedPolicies) == null ? void 0 : d.helperText)
291
306
  ] })
292
307
  }
293
308
  );
@@ -295,200 +310,200 @@ function Se(e, le) {
295
310
  }
296
311
  ),
297
312
  /* @__PURE__ */ i(
298
- f,
313
+ u,
299
314
  {
300
315
  name: "variables",
301
- control: s,
302
- render: ({ field: { value: t, onChange: l } }) => /* @__PURE__ */ i(
303
- Le,
316
+ control: m,
317
+ render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ i(
318
+ Re,
304
319
  {
305
- template: x,
320
+ template: I,
306
321
  value: t,
307
322
  mapboxAccessToken: e.mapboxAccessToken,
308
323
  variant: e.inputVariant,
309
- labelPosition: e.labelPosition,
324
+ labelPosition: c,
310
325
  fieldOptions: e.fieldOptions,
311
- onChange: l
326
+ onChange: n
312
327
  }
313
328
  )
314
329
  }
315
330
  ),
316
- "fileInBase64" in e.defaultValues && !((U = (M = e.fieldOptions) == null ? void 0 : M.fileInBase64) != null && U.hidden) && /* @__PURE__ */ d(he, { children: [
331
+ "fileInBase64" in e.defaultValues && !((Q = (J = e.fieldOptions) == null ? void 0 : J.fileInBase64) != null && Q.hidden) && /* @__PURE__ */ o(xe, { children: [
317
332
  /* @__PURE__ */ i(
318
- f,
333
+ u,
319
334
  {
320
335
  name: "fileInBase64",
321
- control: s,
322
- render: ({ field: { onChange: t, value: l, ...a } }) => {
323
- var r;
324
- const o = (c) => {
325
- if (c.target.files) {
326
- const m = new FileReader();
327
- m.onload = async (y) => {
328
- const ue = y.target.result.split("base64,")[1];
329
- t(ue);
336
+ control: m,
337
+ render: ({ field: { onChange: t, value: n, ...d } }) => {
338
+ var a;
339
+ const r = (s) => {
340
+ if (s.target.files) {
341
+ const f = new FileReader();
342
+ f.onload = async (p) => {
343
+ const pe = p.target.result.split("base64,")[1];
344
+ t(pe);
330
345
  };
331
- const v = c.target.files[0];
332
- T("originalFileName", v.name), T("contentType", v.type), m.readAsDataURL(v);
346
+ const b = s.target.files[0];
347
+ T("originalFileName", b.name), T("contentType", b.type), f.readAsDataURL(b);
333
348
  }
334
349
  };
335
350
  return /* @__PURE__ */ i(
336
- u,
351
+ h,
337
352
  {
338
- condition: e.labelPosition === "left",
339
- wrapper: (c) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
340
- /* @__PURE__ */ i(b, { width: "32%", children: "File to Upload" }),
341
- /* @__PURE__ */ i(n, { width: "68%", children: c })
353
+ condition: c === "left",
354
+ wrapper: (s) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
355
+ /* @__PURE__ */ i(y, { width: "32%", children: "File to Upload" }),
356
+ /* @__PURE__ */ i(l, { width: "68%", children: s })
342
357
  ] }),
343
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
358
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
344
359
  /* @__PURE__ */ i(
345
- g,
360
+ x,
346
361
  {
347
362
  type: "file",
348
- label: e.labelPosition === "default" ? "File to Upload" : void 0,
363
+ label: c === "default" ? "File to Upload" : void 0,
349
364
  variant: e.inputVariant,
350
365
  fullWidth: !0,
351
366
  helperText: "Select a file to upload",
352
367
  InputLabelProps: { shrink: !0 },
353
- onChange: o,
354
- ...a
368
+ onChange: r,
369
+ ...d
355
370
  }
356
371
  ),
357
- e.fieldOptions && ((r = e.fieldOptions.fileInBase64) == null ? void 0 : r.helperText)
372
+ e.fieldOptions && ((a = e.fieldOptions.fileInBase64) == null ? void 0 : a.helperText)
358
373
  ] })
359
374
  }
360
375
  );
361
376
  }
362
377
  }
363
378
  ),
364
- !((G = (j = e.fieldOptions) == null ? void 0 : j.redacted) != null && G.hidden) && /* @__PURE__ */ i(
365
- u,
379
+ !((z = (Y = e.fieldOptions) == null ? void 0 : Y.redacted) != null && z.hidden) && /* @__PURE__ */ i(
380
+ h,
366
381
  {
367
- condition: e.labelPosition === "left",
368
- wrapper: (t) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
369
- /* @__PURE__ */ i(b, { width: "32%", children: "Redacted" }),
370
- /* @__PURE__ */ i(n, { width: "68%", children: t })
382
+ condition: c === "left",
383
+ wrapper: (t) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
384
+ /* @__PURE__ */ i(y, { width: "32%", children: "Redacted" }),
385
+ /* @__PURE__ */ i(l, { width: "68%", children: t })
371
386
  ] }),
372
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
387
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
373
388
  /* @__PURE__ */ i(
374
- te,
389
+ oe,
375
390
  {
376
391
  control: /* @__PURE__ */ i(
377
- f,
392
+ u,
378
393
  {
379
394
  name: "redacted",
380
- control: s,
381
- render: ({ field: { value: t, ...l } }) => /* @__PURE__ */ i(ie, { checked: !!t, ...l })
395
+ control: m,
396
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(ce, { checked: !!t, ...n })
382
397
  }
383
398
  ),
384
- label: e.labelPosition === "default" ? "Redacted" : void 0
399
+ label: c === "default" ? "Redacted" : void 0
385
400
  }
386
401
  ),
387
- e.fieldOptions && ((H = e.fieldOptions.redacted) == null ? void 0 : H.helperText)
402
+ e.fieldOptions && ((X = e.fieldOptions.redacted) == null ? void 0 : X.helperText)
388
403
  ] })
389
404
  }
390
405
  ),
391
- !(($ = (J = e.fieldOptions) == null ? void 0 : J.contentEncrypted) != null && $.hidden) && /* @__PURE__ */ i(
392
- u,
406
+ !((ee = (Z = e.fieldOptions) == null ? void 0 : Z.contentEncrypted) != null && ee.hidden) && /* @__PURE__ */ i(
407
+ h,
393
408
  {
394
- condition: e.labelPosition === "left",
395
- wrapper: (t) => /* @__PURE__ */ d(n, { display: "flex", alignItems: "center", children: [
396
- /* @__PURE__ */ i(b, { width: "32%", children: "Content Encrypted" }),
397
- /* @__PURE__ */ i(n, { width: "68%", children: t })
409
+ condition: c === "left",
410
+ wrapper: (t) => /* @__PURE__ */ o(l, { display: "flex", alignItems: "center", children: [
411
+ /* @__PURE__ */ i(y, { width: "32%", children: "Content Encrypted" }),
412
+ /* @__PURE__ */ i(l, { width: "68%", children: t })
398
413
  ] }),
399
- children: /* @__PURE__ */ d(n, { mb: 2, children: [
414
+ children: /* @__PURE__ */ o(l, { mb: 2, children: [
400
415
  /* @__PURE__ */ i(
401
- te,
416
+ oe,
402
417
  {
403
418
  control: /* @__PURE__ */ i(
404
- f,
419
+ u,
405
420
  {
406
421
  name: "contentEncrypted",
407
- control: s,
408
- render: ({ field: { value: t, ...l } }) => /* @__PURE__ */ i(ie, { checked: !!t, ...l })
422
+ control: m,
423
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ i(ce, { checked: !!t, ...n })
409
424
  }
410
425
  ),
411
- label: e.labelPosition === "default" ? "Content Encrypted" : void 0
426
+ label: c === "default" ? "Content Encrypted" : void 0
412
427
  }
413
428
  ),
414
- e.fieldOptions && ((Q = e.fieldOptions.contentEncrypted) == null ? void 0 : Q.helperText)
429
+ e.fieldOptions && ((te = e.fieldOptions.contentEncrypted) == null ? void 0 : te.helperText)
415
430
  ] })
416
431
  }
417
432
  )
418
433
  ] }),
419
- !((z = (Y = e.fieldOptions) == null ? void 0 : Y.disseminationList) != null && z.hidden) && /* @__PURE__ */ i(
420
- f,
434
+ !((ne = (ie = e.fieldOptions) == null ? void 0 : ie.disseminationList) != null && ne.hidden) && /* @__PURE__ */ i(
435
+ u,
421
436
  {
422
437
  name: "disseminationList",
423
438
  rules: {
424
439
  required: !0
425
440
  },
426
- control: s,
427
- render: ({ field: { value: t, onChange: l }, fieldState: a }) => {
428
- const o = t || [], r = (c) => {
429
- l(c);
441
+ control: m,
442
+ render: ({ field: { value: t, onChange: n }, fieldState: d }) => {
443
+ const r = t || [], a = (s) => {
444
+ n(s);
430
445
  };
431
446
  return /* @__PURE__ */ i(
432
- Oe,
447
+ Ee,
433
448
  {
434
- selectedIds: o,
449
+ selectedIds: r,
435
450
  memberedGroups: e.memberedGroups,
436
- showError: !!a.error,
451
+ showError: !!d.error,
437
452
  variant: e.inputVariant,
438
- labelPosition: e.labelPosition,
439
- onChange: r
453
+ labelPosition: c,
454
+ onChange: a
440
455
  }
441
456
  );
442
457
  }
443
458
  }
444
459
  ),
445
- !((Z = (X = e.fieldOptions) == null ? void 0 : X.securityLevelId) != null && Z.hidden) && /* @__PURE__ */ i(n, { mt: 2, children: /* @__PURE__ */ i(
446
- f,
460
+ !((ae = (le = e.fieldOptions) == null ? void 0 : le.securityLevelId) != null && ae.hidden) && /* @__PURE__ */ i(l, { mt: 2, children: /* @__PURE__ */ i(
461
+ u,
447
462
  {
448
463
  name: "securityLevelId",
449
464
  rules: {
450
465
  required: !0
451
466
  },
452
- control: s,
453
- render: ({ field: { value: t, onChange: l }, fieldState: a }) => {
454
- var r, c;
455
- const o = (m) => {
456
- l(m);
467
+ control: m,
468
+ render: ({ field: { value: t, onChange: n }, fieldState: d }) => {
469
+ var a, s;
470
+ const r = (f) => {
471
+ n(f);
457
472
  };
458
473
  return /* @__PURE__ */ i(
459
- pe,
474
+ Pe,
460
475
  {
461
476
  value: t || 0,
462
477
  ontologyId: e.ontologyId,
463
478
  appRoles: e.appRoles,
464
479
  securityLevels: e.securityLevels,
465
480
  minLevelId: e.minSecurityLevel,
466
- templateKeys: (r = e.securityLevelConfig) == null ? void 0 : r.templateKeys,
467
- templateType: (c = e.securityLevelConfig) == null ? void 0 : c.templateType,
468
- showError: !!a.error,
481
+ templateKeys: (a = e.securityLevelConfig) == null ? void 0 : a.templateKeys,
482
+ templateType: (s = e.securityLevelConfig) == null ? void 0 : s.templateType,
483
+ showError: !!d.error,
469
484
  variant: e.inputVariant,
470
- labelPosition: e.labelPosition,
471
- onChange: o
485
+ labelPosition: c,
486
+ onChange: r
472
487
  }
473
488
  );
474
489
  }
475
490
  }
476
491
  ) }),
477
- /* @__PURE__ */ d(n, { display: "flex", justifyContent: "space-between", mt: 3, children: [
492
+ /* @__PURE__ */ o(l, { display: "flex", justifyContent: "space-between", mt: 3, children: [
478
493
  /* @__PURE__ */ i(
479
- I,
494
+ w,
480
495
  {
481
496
  color: "primary",
482
497
  variant: "text",
483
498
  disabled: e.loading,
484
499
  sx: { textTransform: "none" },
485
- onClick: fe,
500
+ onClick: be,
486
501
  children: "Cancel"
487
502
  }
488
503
  ),
489
- /* @__PURE__ */ d(n, { children: [
504
+ /* @__PURE__ */ o(l, { children: [
490
505
  e.onRemove !== void 0 && /* @__PURE__ */ i(
491
- I,
506
+ w,
492
507
  {
493
508
  type: "button",
494
509
  color: "error",
@@ -499,8 +514,8 @@ function Se(e, le) {
499
514
  children: e.removeLoading ? "Deleting..." : "Delete"
500
515
  }
501
516
  ),
502
- e.saveButtons ? e.saveButtons.map((t, l) => /* @__PURE__ */ i(
503
- I,
517
+ e.saveButtons ? e.saveButtons.map((t, n) => /* @__PURE__ */ i(
518
+ w,
504
519
  {
505
520
  type: "submit",
506
521
  color: "primary",
@@ -511,9 +526,9 @@ function Se(e, le) {
511
526
  onClick: t.onClick,
512
527
  children: t.label
513
528
  },
514
- l
529
+ n
515
530
  )) : /* @__PURE__ */ i(
516
- I,
531
+ w,
517
532
  {
518
533
  type: "submit",
519
534
  color: "primary",
@@ -531,7 +546,7 @@ function Se(e, le) {
531
546
  }
532
547
  );
533
548
  }
534
- const Ge = h.forwardRef(Se);
549
+ const ze = v.forwardRef(De);
535
550
  export {
536
- Ge as InstanceForm
551
+ ze as InstanceForm
537
552
  };
package/dist/main.d.ts CHANGED
@@ -244,6 +244,7 @@ declare interface FieldOptions {
244
244
  minDate?: Dayjs;
245
245
  helperText?: React.ReactNode;
246
246
  component?: React.ReactNode;
247
+ maxChar?: number;
247
248
  [key: string]: string | number | object | boolean;
248
249
  }
249
250
 
@@ -270,7 +271,7 @@ declare function importKey(jwk: any): Promise<CryptoKey>;
270
271
 
271
272
  export declare const InstanceForm: <T extends ONTOLOGY.Object | ONTOLOGY.Event | ONTOLOGY.Agent | ONTOLOGY.File, K extends INSTANCE.CreateObjectDTO | INSTANCE.UpdateObjectDTO | INSTANCE.CreateEventDTO | INSTANCE.UpdateEventDTO | INSTANCE.CreateAgentDTO | INSTANCE.CreateFileDTO | INSTANCE.UpdateFileDTO>(props: InstanceFormProps<T, K> & default_2.RefAttributes<InstanceFormHandle>) => default_2.ReactNode | null;
272
273
 
273
- declare interface InstanceFormHandle {
274
+ export declare interface InstanceFormHandle {
274
275
  /**
275
276
  *
276
277
  * @returns
@@ -290,6 +291,10 @@ declare interface InstanceFormHandle {
290
291
  * @returns
291
292
  */
292
293
  getFormValue: (name: any) => any;
294
+ /**
295
+ * @returns whether any form field has been modified
296
+ */
297
+ isDirty(): boolean;
293
298
  }
294
299
 
295
300
  declare interface InstanceFormProps<
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.38",
4
+ "version": "1.5.41",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",