@hybridcore/ui 1.4.14 → 1.4.16

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.
@@ -2,8 +2,8 @@ import { jsxs as l, Fragment as p, jsx as o } from "react/jsx-runtime";
2
2
  import { Button as a, Box as f } from "@mui/material";
3
3
  import u from "../map/index.js";
4
4
  import C from "../parser/index.js";
5
- import { g as y, c as g } from "../../../ol-CHaVTXvL.js";
6
- import { useState as h } from "react";
5
+ import { g as y, c as h } from "../../../ol-CHaVTXvL.js";
6
+ import { useState as g } from "react";
7
7
  import { Add as P } from "@mui/icons-material";
8
8
  import { parse as v, convert as x } from "../../map/helpers/wkt.js";
9
9
  import T from "lodash";
@@ -14,7 +14,7 @@ function M({
14
14
  onCancel: m,
15
15
  onSubmit: s
16
16
  }) {
17
- const [t, n] = h(
17
+ const [t, n] = g(
18
18
  r ? y(r) : c
19
19
  );
20
20
  return /* @__PURE__ */ l(p, { children: [
@@ -27,7 +27,7 @@ function M({
27
27
  disableContextMenu: !0,
28
28
  defaultExtent: r,
29
29
  onDrawEnd: (e) => {
30
- const i = g({ features: e });
30
+ const i = h({ features: e });
31
31
  n(i);
32
32
  }
33
33
  }
@@ -54,7 +54,7 @@ function M({
54
54
  }
55
55
  ]
56
56
  };
57
- else if (e.type === "Point")
57
+ else if ((e == null ? void 0 : e.type) === "Point")
58
58
  e = {
59
59
  type: "GeometryCollection",
60
60
  geometries: [
@@ -65,7 +65,7 @@ function M({
65
65
  }
66
66
  ]
67
67
  };
68
- else if (e.type === "GeometryCollection")
68
+ else if ((e == null ? void 0 : e.type) === "GeometryCollection")
69
69
  e.geometries.push({
70
70
  type: "Point",
71
71
  coordinates: [0, 0]
@@ -75,7 +75,7 @@ function M({
75
75
  return;
76
76
  }
77
77
  const i = x(e);
78
- n(i);
78
+ n(i ?? "");
79
79
  },
80
80
  children: "Add Coordinate"
81
81
  }
@@ -1,4 +1,4 @@
1
- import { jsxs as a, jsx as e, Fragment as x } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as r, Fragment as x } from "react/jsx-runtime";
2
2
  import E, { useState as F, useEffect as T } from "react";
3
3
  import { Dialog as w, DialogContent as K, DialogActions as j, Button as c, Box as O } from "@mui/material";
4
4
  import g from "../map/index.js";
@@ -16,53 +16,53 @@ function z({
16
16
  onSubmit: u,
17
17
  onChange: d
18
18
  }) {
19
- const r = E.useRef(null), [t, k] = F(y), m = () => {
20
- u && u(t);
21
- }, p = (n) => {
22
- const o = P({ features: n });
19
+ const t = E.useRef(null), [n, k] = F(y), m = () => {
20
+ u && u(n);
21
+ }, p = (e) => {
22
+ const o = P({ features: e });
23
23
  k(o), d && d(o);
24
24
  }, h = () => {
25
25
  var o, v, C;
26
- const n = S(t);
27
- if (!_.isArray(n))
28
- if (n.type === "Point") {
29
- const i = B(n.coordinates, "EPSG:4326", "EPSG:3857");
30
- (o = r.current) == null || o.setCenter(i), (v = r.current) == null || v.setZoomLevel(10);
26
+ const e = S(n);
27
+ if (!_.isArray(e))
28
+ if ((e == null ? void 0 : e.type) === "Point") {
29
+ const i = B(e.coordinates, "EPSG:4326", "EPSG:3857");
30
+ (o = t.current) == null || o.setCenter(i), (v = t.current) == null || v.setZoomLevel(10);
31
31
  } else {
32
- const i = R(t);
33
- i && ((C = r.current) == null || C.centerToFeature(i[0], [100, 100, 100, 100]));
32
+ const i = R(n);
33
+ i && ((C = t.current) == null || C.centerToFeature(i[0], [100, 100, 100, 100]));
34
34
  }
35
35
  };
36
36
  return T(() => (h(), () => {
37
37
  }), [h]), W === "dialog" ? /* @__PURE__ */ a(w, { open: !0, maxWidth: "sm", fullWidth: !0, onClose: l, children: [
38
- /* @__PURE__ */ e(K, { children: /* @__PURE__ */ e(
38
+ /* @__PURE__ */ r(K, { children: /* @__PURE__ */ r(
39
39
  g,
40
40
  {
41
41
  id: f,
42
- ref: r,
43
- drawingWKTData: t,
42
+ ref: t,
43
+ drawingWKTData: n,
44
44
  mapboxAccessToken: s,
45
45
  onDrawEnd: p
46
46
  }
47
47
  ) }),
48
48
  /* @__PURE__ */ a(j, { children: [
49
- /* @__PURE__ */ e(c, { color: "inherit", variant: "contained", onClick: l, children: "Cancel" }),
50
- /* @__PURE__ */ e(c, { variant: "contained", onClick: m, children: "Ok" })
49
+ /* @__PURE__ */ r(c, { color: "inherit", variant: "contained", onClick: l, children: "Cancel" }),
50
+ /* @__PURE__ */ r(c, { variant: "contained", onClick: m, children: "Ok" })
51
51
  ] })
52
52
  ] }) : /* @__PURE__ */ a(x, { children: [
53
- /* @__PURE__ */ e(
53
+ /* @__PURE__ */ r(
54
54
  g,
55
55
  {
56
56
  id: f,
57
- ref: r,
58
- drawingWKTData: t,
57
+ ref: t,
58
+ drawingWKTData: n,
59
59
  mapboxAccessToken: s,
60
60
  onDrawEnd: p
61
61
  }
62
62
  ),
63
63
  !D && /* @__PURE__ */ a(O, { display: "flex", justifyContent: "space-between", mt: 3, children: [
64
- /* @__PURE__ */ e(c, { color: "primary", onClick: l, children: "Cancel" }),
65
- /* @__PURE__ */ e(c, { color: "primary", variant: "contained", onClick: m, children: "Ok" })
64
+ /* @__PURE__ */ r(c, { color: "primary", onClick: l, children: "Cancel" }),
65
+ /* @__PURE__ */ r(c, { color: "primary", variant: "contained", onClick: m, children: "Ok" })
66
66
  ] })
67
67
  ] });
68
68
  }
@@ -1,17 +1,18 @@
1
- import { jsx as e, Fragment as y, jsxs as o } from "react/jsx-runtime";
1
+ import { jsx as e, Fragment as w, jsxs as o } from "react/jsx-runtime";
2
2
  import { AccordionSummary as c, Box as a, Typography as s, Tooltip as d, IconButton as h, AccordionDetails as p } from "@mui/material";
3
3
  import m from "./coordinate-input/index.js";
4
- import w from "./logic.js";
4
+ import P from "./logic.js";
5
5
  import { GridExpandMoreIcon as f } from "@mui/x-data-grid";
6
6
  import { Accordion as u } from "./styled.js";
7
7
  import { Close as g } from "@mui/icons-material";
8
- import { ConditionalWrapper as P } from "../../conditional-wrapper/index.js";
9
- function M(C) {
10
- const { state: I, action: t } = w(C);
11
- return /* @__PURE__ */ e(y, { children: I.parsed.map((r, n) => {
8
+ import { ConditionalWrapper as z } from "../../conditional-wrapper/index.js";
9
+ function R(C) {
10
+ var I;
11
+ const { state: y, action: t } = P(C);
12
+ return /* @__PURE__ */ e(w, { children: (I = y.parsed) == null ? void 0 : I.map((r, n) => {
12
13
  if (r.type === "Point")
13
14
  return /* @__PURE__ */ e(
14
- P,
15
+ z,
15
16
  {
16
17
  condition: !C.disableGrouping,
17
18
  wrapper: (i) => /* @__PURE__ */ o(u, { defaultExpanded: !0, children: [
@@ -175,5 +176,5 @@ function M(C) {
175
176
  }) });
176
177
  }
177
178
  export {
178
- M as default
179
+ R as default
179
180
  };
@@ -1,80 +1,80 @@
1
1
  import u from "react";
2
2
  import { parse as a, convert as l } from "../../map/helpers/wkt.js";
3
3
  import m from "lodash";
4
- function M({ value: p, onChange: i }) {
5
- const r = u.useMemo(() => {
4
+ function M({ value: p, onChange: s }) {
5
+ const n = u.useMemo(() => {
6
6
  let o = a(p);
7
- return m.isArray(o) || (o = [o]), o;
7
+ return o && !m.isArray(o) && (o = [o]), o;
8
8
  }, [p]);
9
9
  return {
10
10
  state: {
11
- parsed: r
11
+ parsed: n
12
12
  },
13
13
  action: {
14
- onCoordinateInputChange: (o) => (s) => {
15
- if (i) {
14
+ onCoordinateInputChange: (o) => (c) => {
15
+ if (s) {
16
16
  let e;
17
- const t = [...r];
17
+ const t = [...n || []];
18
18
  t[o] = {
19
19
  type: "Point",
20
- coordinates: [s.longitude, s.latitude]
20
+ coordinates: [c.longitude, c.latitude]
21
21
  }, t.length > 1 ? e = l({
22
22
  type: "GeometryCollection",
23
23
  geometries: t
24
- }) : e = l(t[0]), i(e);
24
+ }) : e = l(t[0]), s(e ?? "");
25
25
  }
26
26
  },
27
- onPolygonInputChange: (o, s, e) => (t) => {
28
- if (i) {
29
- const n = [...r], c = [...o[0]];
30
- c[e] = [t.longitude, t.latitude], n[s] = {
27
+ onPolygonInputChange: (o, c, e) => (t) => {
28
+ if (s) {
29
+ const i = [...n || []], r = [...o[0]];
30
+ r[e] = [t.longitude, t.latitude], i[c] = {
31
31
  type: "Polygon",
32
- coordinates: [c]
32
+ coordinates: [r]
33
33
  };
34
34
  const g = l({
35
35
  type: "GeometryCollection",
36
- geometries: n
36
+ geometries: i
37
37
  });
38
- i(g);
38
+ s(g ?? "");
39
39
  }
40
40
  },
41
- onMultiPointInputChange: (o, s, e) => (t) => {
42
- if (i) {
43
- const n = [...r], c = [...o];
44
- c[e] = [t.longitude, t.latitude], n[s] = {
41
+ onMultiPointInputChange: (o, c, e) => (t) => {
42
+ if (s) {
43
+ const i = [...n || []], r = [...o];
44
+ r[e] = [t.longitude, t.latitude], i[c] = {
45
45
  type: "MultiPoint",
46
- coordinates: c
46
+ coordinates: r
47
47
  };
48
48
  const g = l({
49
49
  type: "GeometryCollection",
50
- geometries: n
50
+ geometries: i
51
51
  });
52
- i(g);
52
+ s(g ?? "");
53
53
  }
54
54
  },
55
- onLineStringInputChange: (o, s, e) => (t) => {
56
- if (i) {
57
- const n = [...r], c = [...o];
58
- c[e] = [t.longitude, t.latitude], n[s] = {
55
+ onLineStringInputChange: (o, c, e) => (t) => {
56
+ if (s) {
57
+ const i = [...n || []], r = [...o];
58
+ r[e] = [t.longitude, t.latitude], i[c] = {
59
59
  type: "LineString",
60
- coordinates: c
60
+ coordinates: r
61
61
  };
62
62
  const g = l({
63
63
  type: "GeometryCollection",
64
- geometries: n
64
+ geometries: i
65
65
  });
66
- i(g);
66
+ s(g ?? "");
67
67
  }
68
68
  },
69
- onRemoveItem: (o) => (s) => {
70
- if (s.stopPropagation(), i) {
71
- const e = [...r];
69
+ onRemoveItem: (o) => (c) => {
70
+ if (c.stopPropagation(), s) {
71
+ const e = [...n || []];
72
72
  e.splice(o, 1);
73
- const n = l({
73
+ const i = l({
74
74
  type: "GeometryCollection",
75
75
  geometries: e
76
76
  });
77
- i(n);
77
+ s(i ?? "");
78
78
  }
79
79
  }
80
80
  }
@@ -1,40 +1,54 @@
1
- import { jsx as i, Fragment as t } from "react/jsx-runtime";
1
+ import { jsx as t, Fragment as h } from "react/jsx-runtime";
2
2
  import p from "react";
3
- import { V as l } from "../../../../index-V39OBeR0.js";
4
- import m from "lodash";
5
- function b({
3
+ import { V as x } from "../../../../index-V39OBeR0.js";
4
+ import _ from "lodash";
5
+ import { Box as d } from "@mui/material";
6
+ function V({
6
7
  template: o,
7
- value: e,
8
- mapboxAccessToken: s,
9
- variant: a = "outlined",
10
- onChange: u
8
+ value: i,
9
+ mapboxAccessToken: a,
10
+ variant: f = "outlined",
11
+ fieldOptions: n,
12
+ onChange: s
11
13
  }) {
12
- const d = p.useMemo(() => {
13
- let r = o == null ? void 0 : o.properties.filter((n) => n.visible);
14
- return r = m.orderBy(r, "id"), r;
15
- }, [o]), f = (r) => {
16
- const n = {
14
+ const c = p.useMemo(() => {
15
+ let r = o == null ? void 0 : o.properties.filter((e) => e.visible);
16
+ return r = _.orderBy(r, "id"), r;
17
+ }, [o]), l = (r) => {
18
+ const e = {
17
19
  target: {
18
- value: { ...e, ...r }
20
+ value: { ...i, ...r }
19
21
  }
20
22
  };
21
- u(n);
23
+ s(e);
22
24
  };
23
- return o === void 0 ? /* @__PURE__ */ i(t, {}) : /* @__PURE__ */ i(t, { children: d.map((r, n) => {
24
- const c = e ? e[r.propertyId] : "";
25
- return /* @__PURE__ */ i(
26
- l,
25
+ return o === void 0 ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(d, { display: "flex", flexDirection: "column", children: c.filter((r) => {
26
+ var e;
27
+ return n ? !((e = n[r.propertyId]) != null && e.hidden) : !0;
28
+ }).map((r, e) => {
29
+ var u;
30
+ const m = i ? i[r.propertyId] : "";
31
+ return /* @__PURE__ */ t(
32
+ d,
27
33
  {
28
- property: r,
29
- value: c,
30
- mapboxAccessToken: s,
31
- variant: a,
32
- onChange: f
33
- },
34
- n
34
+ ...n && ((u = n[r.propertyId]) == null ? void 0 : u.order) && {
35
+ order: n[r.propertyId].order
36
+ },
37
+ children: /* @__PURE__ */ t(
38
+ x,
39
+ {
40
+ property: r,
41
+ value: m,
42
+ mapboxAccessToken: a,
43
+ variant: f,
44
+ onChange: l
45
+ },
46
+ e
47
+ )
48
+ }
35
49
  );
36
50
  }) });
37
51
  }
38
52
  export {
39
- b as default
53
+ V as default
40
54
  };
@@ -1,42 +1,43 @@
1
- import { jsx as a, jsxs as h, Fragment as D } from "react/jsx-runtime";
1
+ import { jsx as a, jsxs as h, Fragment as $ } from "react/jsx-runtime";
2
2
  import m from "react";
3
- import P from "lodash";
4
- import { useForm as W, Controller as s } from "react-hook-form";
5
- import { getNestedChildrenFromMap as M } from "../../utils/ontology.js";
6
- import { i as N, d as G } from "../../utils-Bq0ye5vf.js";
7
- import { ConditionalWrapper as K } from "../conditional-wrapper/index.js";
8
- import { Container as O } from "../container/index.js";
9
- import { TextField as v, FormGroup as U, FormControl as j, InputLabel as q, Select as H, MenuItem as Y, FormControlLabel as L, Checkbox as V, Box as p, Button as y } from "@mui/material";
10
- import { TreeSelect as J } from "../tree-select/index.js";
11
- import $ from "./components/policy-list/index.js";
12
- import Q from "./components/variables/index.js";
13
- import { DisseminationList as X } from "../data-security-selectors/dissemination-list/index.js";
14
- import { SecurityLevel as z } from "../data-security-selectors/security-level/index.js";
15
- const Z = {
3
+ import Q from "lodash";
4
+ import { useForm as X, Controller as s } from "react-hook-form";
5
+ import { getNestedChildrenFromMap as z } from "../../utils/ontology.js";
6
+ import { i as Z, d as ee } from "../../utils-Bq0ye5vf.js";
7
+ import { ConditionalWrapper as te } from "../conditional-wrapper/index.js";
8
+ import { Container as ae } from "../container/index.js";
9
+ import { TextField as v, FormGroup as ne, FormControl as ie, InputLabel as le, Select as re, MenuItem as de, FormControlLabel as W, Checkbox as M, Box as p, Button as g } from "@mui/material";
10
+ import { TreeSelect as oe } from "../tree-select/index.js";
11
+ import se from "./components/policy-list/index.js";
12
+ import me from "./components/variables/index.js";
13
+ import { DisseminationList as ce } from "../data-security-selectors/dissemination-list/index.js";
14
+ import { SecurityLevel as ue } from "../data-security-selectors/security-level/index.js";
15
+ const fe = {
16
16
  alg: "A256GCM",
17
17
  ext: !0,
18
18
  k: "_El6rHQxC5E7NdO5DiMDITjF7f65wrlaJmFVagVE9Ic",
19
19
  key_ops: ["encrypt", "decrypt"],
20
20
  kty: "oct"
21
- }, ee = [
21
+ }, he = [
22
22
  "IMAGE",
23
23
  "VIDEO",
24
24
  "TEXT",
25
25
  "BINARY",
26
26
  "OTHER"
27
27
  ];
28
- function te(e, S) {
28
+ function ve(e, N) {
29
+ var L, V, S, E, F, k, R, O, w, B, _, A, D, P;
29
30
  const {
30
31
  register: C,
31
- handleSubmit: E,
32
- control: d,
33
- formState: { errors: F },
34
- getValues: x,
32
+ handleSubmit: G,
33
+ control: o,
34
+ formState: { errors: K },
35
+ getValues: I,
35
36
  setValue: b,
36
- reset: k
37
- } = W({
37
+ reset: U
38
+ } = X({
38
39
  defaultValues: e.defaultValues
39
- }), [R, _] = m.useState([]), [g, I] = m.useState(), [ae, w] = m.useState(0), A = m.useMemo(() => {
40
+ }), [j, q] = m.useState([]), [y, x] = m.useState(), [be, H] = m.useState(0), Y = m.useMemo(() => {
40
41
  const t = [];
41
42
  return e.mappedTemplates.forEach((n) => {
42
43
  n.creatable || t.push(String(n.id));
@@ -46,34 +47,34 @@ function te(e, S) {
46
47
  (async () => {
47
48
  const t = { ...e.defaultValues }, n = e.mappedTemplates.get(t.templateId);
48
49
  if (n) {
49
- const i = n.properties.filter(
50
- (l) => l.privacyPreservationMethod === "ENCRYPTION"
50
+ const r = n.properties.filter(
51
+ (i) => i.privacyPreservationMethod === "ENCRYPTION"
51
52
  );
52
- if (i.length > 0)
53
- for (let l = 0; l < i.length; l++) {
54
- const r = i[l], o = P.get(t, `variables.${r.propertyId}`);
55
- if (o && e.keyAuth) {
56
- const c = await N(Z), u = await G(c, o);
57
- u.data && (b(`variables.${r.propertyId}`, u.data), w((f) => f + 1));
53
+ if (r.length > 0)
54
+ for (let i = 0; i < r.length; i++) {
55
+ const l = r[i], d = Q.get(t, `variables.${l.propertyId}`);
56
+ if (d && e.keyAuth) {
57
+ const c = await Z(fe), u = await ee(c, d);
58
+ u.data && (b(`variables.${l.propertyId}`, u.data), H((f) => f + 1));
58
59
  }
59
60
  }
60
61
  }
61
62
  })();
62
63
  }, [e.defaultValues, e.mappedTemplates, e.keyAuth]);
63
64
  const T = () => {
64
- const t = x("templateId");
65
- g && I(void 0);
66
- const n = M(e.mappedTemplates);
67
- _(n);
68
- for (const i of e.mappedTemplates.values())
69
- if (i.id === t) {
70
- I(i);
65
+ const t = I("templateId");
66
+ y && x(void 0);
67
+ const n = z(e.mappedTemplates);
68
+ q(n);
69
+ for (const r of e.mappedTemplates.values())
70
+ if (r.id === t) {
71
+ x(r);
71
72
  break;
72
73
  }
73
74
  };
74
- m.useImperativeHandle(S, () => ({
75
+ m.useImperativeHandle(N, () => ({
75
76
  resetForm() {
76
- k({
77
+ U({
77
78
  title: "",
78
79
  description: "",
79
80
  templateId: 0,
@@ -84,373 +85,383 @@ function te(e, S) {
84
85
  b(t, n);
85
86
  },
86
87
  getFormValue(t) {
87
- return x(t);
88
+ return I(t);
88
89
  }
89
90
  })), m.useEffect(() => (T(), () => {
90
91
  }), [e.mappedTemplates]), m.useEffect(() => {
91
- e.onSelectedTemplateChange && e.onSelectedTemplateChange(g);
92
- }, [g]);
93
- const B = () => {
92
+ e.onSelectedTemplateChange && e.onSelectedTemplateChange(y);
93
+ }, [y]);
94
+ const J = () => {
94
95
  if (e.onCancel) {
95
96
  e.onCancel();
96
97
  return;
97
98
  }
98
99
  };
99
100
  return /* @__PURE__ */ a(
100
- K,
101
+ te,
101
102
  {
102
103
  condition: e.variant === void 0 || e.variant === "inline",
103
104
  wrapper: (t) => /* @__PURE__ */ a(
104
- O,
105
+ ae,
105
106
  {
106
107
  disableHeader: !0,
107
108
  sx: { position: "relative", overflow: "visible" },
108
109
  children: t
109
110
  }
110
111
  ),
111
- children: /* @__PURE__ */ h("form", { onSubmit: E(e.onSubmit), children: [
112
- /* @__PURE__ */ a(
113
- v,
114
- {
115
- label: "Title *",
116
- variant: e.inputVariant,
117
- fullWidth: !0,
118
- sx: { mb: 2 },
119
- ...C("title", { required: !0 }),
120
- ...F.title && {
121
- helperText: "This field is required!",
122
- error: !0
123
- }
124
- }
125
- ),
126
- /* @__PURE__ */ a(
127
- v,
128
- {
129
- label: "Description",
130
- variant: e.inputVariant,
131
- fullWidth: !0,
132
- multiline: !0,
133
- sx: { mb: 2 },
134
- ...C("description")
135
- }
136
- ),
137
- /* @__PURE__ */ a(U, { sx: { mb: 2 }, children: /* @__PURE__ */ a(
138
- s,
139
- {
140
- name: "templateId",
141
- control: d,
142
- render: ({ field: { value: t, onChange: n } }) => {
143
- if (e.disableTemplateChange) {
144
- const i = t ? e.mappedTemplates.get(t) : void 0;
145
- return /* @__PURE__ */ a(
146
- v,
147
- {
148
- label: "Template",
149
- variant: e.inputVariant,
150
- fullWidth: !0,
151
- disabled: !0,
152
- value: i == null ? void 0 : i.name,
153
- InputLabelProps: { shrink: !0 }
112
+ children: /* @__PURE__ */ h(
113
+ "form",
114
+ {
115
+ onSubmit: G(e.onSubmit),
116
+ style: { display: "flex", flexDirection: "column" },
117
+ children: [
118
+ /* @__PURE__ */ a(
119
+ v,
120
+ {
121
+ label: "Title *",
122
+ variant: e.inputVariant,
123
+ fullWidth: !0,
124
+ sx: { mb: 2 },
125
+ ...C("title", { required: !0 }),
126
+ ...K.title && {
127
+ helperText: "This field is required!",
128
+ error: !0
129
+ }
130
+ }
131
+ ),
132
+ /* @__PURE__ */ a(
133
+ v,
134
+ {
135
+ label: "Description",
136
+ variant: e.inputVariant,
137
+ fullWidth: !0,
138
+ multiline: !0,
139
+ sx: { mb: 2 },
140
+ minRows: (V = (L = e.fieldOptions) == null ? void 0 : L.description) == null ? void 0 : V.minRows,
141
+ ...C("description")
142
+ }
143
+ ),
144
+ !((E = (S = e.fieldOptions) == null ? void 0 : S.templateId) != null && E.hidden) && /* @__PURE__ */ a(ne, { sx: { mb: 2 }, children: /* @__PURE__ */ a(
145
+ s,
146
+ {
147
+ name: "templateId",
148
+ control: o,
149
+ render: ({ field: { value: t, onChange: n } }) => {
150
+ var r, i;
151
+ if ((i = (r = e.fieldOptions) == null ? void 0 : r.templateId) != null && i.disabled) {
152
+ const l = t ? e.mappedTemplates.get(t) : void 0;
153
+ return /* @__PURE__ */ a(
154
+ v,
155
+ {
156
+ label: "Template",
157
+ variant: e.inputVariant,
158
+ fullWidth: !0,
159
+ disabled: !0,
160
+ value: l == null ? void 0 : l.name,
161
+ InputLabelProps: { shrink: !0 }
162
+ }
163
+ );
154
164
  }
155
- );
165
+ return /* @__PURE__ */ a(
166
+ oe,
167
+ {
168
+ label: "Template",
169
+ data: j,
170
+ selected: t === 0 ? "" : [String(t)],
171
+ disabled: Y,
172
+ variant: e.inputVariant,
173
+ onChange: (l, d) => {
174
+ const c = {
175
+ target: {
176
+ value: d ? Number(l) : 0
177
+ }
178
+ };
179
+ n(c), T();
180
+ }
181
+ }
182
+ );
183
+ }
156
184
  }
157
- return /* @__PURE__ */ a(
158
- J,
159
- {
160
- label: "Template",
161
- data: R,
162
- selected: t === 0 ? "" : [String(t)],
163
- disabled: A,
164
- variant: e.inputVariant,
165
- onChange: (i, l) => {
166
- const r = {
185
+ ) }),
186
+ "aliasList" in e.defaultValues && !((k = (F = e.fieldOptions) == null ? void 0 : F.aliasList) != null && k.hidden) && /* @__PURE__ */ a(
187
+ s,
188
+ {
189
+ name: "aliasList",
190
+ control: o,
191
+ render: ({ field: { value: t, onChange: n, ...r } }) => {
192
+ const i = (l) => {
193
+ const u = {
167
194
  target: {
168
- value: l ? Number(i) : 0
195
+ value: l.target.value.split(",").map((f) => f.trimStart())
169
196
  }
170
197
  };
171
- n(r), T();
172
- }
173
- }
174
- );
175
- }
176
- }
177
- ) }),
178
- "aliasList" in e.defaultValues && /* @__PURE__ */ a(
179
- s,
180
- {
181
- name: "aliasList",
182
- control: d,
183
- render: ({ field: { value: t, onChange: n, ...i } }) => {
184
- const l = (r) => {
185
- const u = {
186
- target: {
187
- value: r.target.value.split(",").map((f) => f.trimStart())
188
- }
189
- };
190
- n(u);
191
- };
192
- return /* @__PURE__ */ a(
193
- v,
194
- {
195
- label: "Alias List",
196
- variant: e.inputVariant,
197
- fullWidth: !0,
198
- value: t,
199
- sx: { mb: 2 },
200
- helperText: "Add list values with the comma (,) separated string",
201
- onChange: l,
202
- ...i
198
+ n(u);
199
+ };
200
+ return /* @__PURE__ */ a(
201
+ v,
202
+ {
203
+ label: "Alias List",
204
+ variant: e.inputVariant,
205
+ fullWidth: !0,
206
+ value: t,
207
+ sx: { mb: 2 },
208
+ helperText: "Add list values with the comma (,) separated string",
209
+ onChange: i,
210
+ ...r
211
+ }
212
+ );
203
213
  }
204
- );
205
- }
206
- }
207
- ),
208
- "appliedPolicies" in e.defaultValues && /* @__PURE__ */ a(
209
- s,
210
- {
211
- name: "appliedPolicies",
212
- control: d,
213
- render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ a(
214
- $,
215
- {
216
- policyList: e.policyList,
217
- value: t || void 0,
218
- onChange: n
219
214
  }
220
- )
221
- }
222
- ),
223
- /* @__PURE__ */ a(
224
- s,
225
- {
226
- name: "variables",
227
- control: d,
228
- render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ a(
229
- Q,
215
+ ),
216
+ "appliedPolicies" in e.defaultValues && !((O = (R = e.fieldOptions) == null ? void 0 : R.appliedPolicies) != null && O.hidden) && /* @__PURE__ */ a(
217
+ s,
230
218
  {
231
- template: g,
232
- value: t,
233
- mapboxAccessToken: e.mapboxAccessToken,
234
- variant: e.inputVariant,
235
- onChange: n
236
- }
237
- )
238
- }
239
- ),
240
- "fileInBase64" in e.defaultValues && /* @__PURE__ */ h(D, { children: [
241
- /* @__PURE__ */ a(
242
- s,
243
- {
244
- name: "fileInBase64",
245
- control: d,
246
- render: ({ field: { onChange: t, ...n } }) => {
247
- const i = (l) => {
248
- if (l.target.files) {
249
- const r = new FileReader();
250
- r.onload = async (c) => {
251
- const f = c.target.result.split("base64,")[1];
252
- t(f);
253
- };
254
- const o = l.target.files[0];
255
- b("originalFileName", o.name), b("contentType", o.type), r.readAsDataURL(o);
256
- }
257
- };
258
- return /* @__PURE__ */ a(
259
- v,
219
+ name: "appliedPolicies",
220
+ control: o,
221
+ render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ a(
222
+ se,
260
223
  {
261
- type: "file",
262
- label: "File to Upload",
263
- variant: e.inputVariant,
264
- fullWidth: !0,
265
- sx: { mb: 2 },
266
- helperText: "Select a file to upload",
267
- InputLabelProps: { shrink: !0 },
268
- onChange: i,
269
- ...n
224
+ policyList: e.policyList,
225
+ value: t || void 0,
226
+ onChange: n
270
227
  }
271
- );
228
+ )
272
229
  }
273
- }
274
- ),
275
- /* @__PURE__ */ a(
276
- s,
277
- {
278
- name: "type",
279
- control: d,
280
- render: ({ field: { value: t, onChange: n } }) => {
281
- const i = (l) => {
282
- const {
283
- target: { value: r }
284
- } = l;
285
- n(r);
286
- };
287
- return /* @__PURE__ */ h(
288
- j,
230
+ ),
231
+ /* @__PURE__ */ a(
232
+ s,
233
+ {
234
+ name: "variables",
235
+ control: o,
236
+ render: ({ field: { value: t, onChange: n } }) => /* @__PURE__ */ a(
237
+ me,
289
238
  {
290
- fullWidth: !0,
291
- sx: {
292
- mb: 2
293
- },
239
+ template: y,
240
+ value: t,
241
+ mapboxAccessToken: e.mapboxAccessToken,
294
242
  variant: e.inputVariant,
295
- children: [
296
- /* @__PURE__ */ a(q, { children: "Type" }),
297
- /* @__PURE__ */ a(
298
- H,
299
- {
300
- value: t ? [t] : "",
301
- onChange: i,
302
- children: ee.map((l) => /* @__PURE__ */ a(Y, { value: l, children: l }, l))
303
- }
304
- )
305
- ]
243
+ fieldOptions: e.fieldOptions,
244
+ onChange: n
306
245
  }
307
- );
246
+ )
308
247
  }
309
- }
310
- ),
311
- /* @__PURE__ */ a(
312
- L,
313
- {
314
- control: /* @__PURE__ */ a(
248
+ ),
249
+ "fileInBase64" in e.defaultValues && !((B = (w = e.fieldOptions) == null ? void 0 : w.fileInBase64) != null && B.hidden) && /* @__PURE__ */ h($, { children: [
250
+ /* @__PURE__ */ a(
315
251
  s,
316
252
  {
317
- name: "redacted",
318
- control: d,
319
- render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ a(V, { checked: !!t, ...n })
253
+ name: "fileInBase64",
254
+ control: o,
255
+ render: ({ field: { onChange: t, ...n } }) => {
256
+ const r = (i) => {
257
+ if (i.target.files) {
258
+ const l = new FileReader();
259
+ l.onload = async (c) => {
260
+ const f = c.target.result.split("base64,")[1];
261
+ t(f);
262
+ };
263
+ const d = i.target.files[0];
264
+ b("originalFileName", d.name), b("contentType", d.type), l.readAsDataURL(d);
265
+ }
266
+ };
267
+ return /* @__PURE__ */ a(
268
+ v,
269
+ {
270
+ type: "file",
271
+ label: "File to Upload",
272
+ variant: e.inputVariant,
273
+ fullWidth: !0,
274
+ sx: { mb: 2 },
275
+ helperText: "Select a file to upload",
276
+ InputLabelProps: { shrink: !0 },
277
+ onChange: r,
278
+ ...n
279
+ }
280
+ );
281
+ }
320
282
  }
321
283
  ),
322
- label: "Redacted",
323
- sx: { mb: 2 }
324
- }
325
- ),
326
- /* @__PURE__ */ a(
327
- L,
328
- {
329
- control: /* @__PURE__ */ a(
284
+ /* @__PURE__ */ a(
330
285
  s,
331
286
  {
332
- name: "contentEncrypted",
333
- control: d,
334
- render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ a(V, { checked: !!t, ...n })
287
+ name: "type",
288
+ control: o,
289
+ render: ({ field: { value: t, onChange: n } }) => {
290
+ const r = (i) => {
291
+ const {
292
+ target: { value: l }
293
+ } = i;
294
+ n(l);
295
+ };
296
+ return /* @__PURE__ */ h(
297
+ ie,
298
+ {
299
+ fullWidth: !0,
300
+ sx: {
301
+ mb: 2
302
+ },
303
+ variant: e.inputVariant,
304
+ children: [
305
+ /* @__PURE__ */ a(le, { children: "Type" }),
306
+ /* @__PURE__ */ a(
307
+ re,
308
+ {
309
+ value: t ? [t] : "",
310
+ onChange: r,
311
+ children: he.map((i) => /* @__PURE__ */ a(de, { value: i, children: i }, i))
312
+ }
313
+ )
314
+ ]
315
+ }
316
+ );
317
+ }
335
318
  }
336
319
  ),
337
- label: "Content Encrypted",
338
- sx: { mb: 2 }
339
- }
340
- )
341
- ] }),
342
- /* @__PURE__ */ a(
343
- s,
344
- {
345
- name: "disseminationList",
346
- rules: {
347
- required: !0
348
- },
349
- control: d,
350
- render: ({ field: { value: t, onChange: n }, fieldState: i }) => {
351
- const l = t || [], r = (o) => {
352
- n(o);
353
- };
354
- return /* @__PURE__ */ a(
355
- X,
320
+ /* @__PURE__ */ a(
321
+ W,
356
322
  {
357
- selectedIds: l,
358
- memberedGroups: e.memberedGroups,
359
- showError: !!i.error,
360
- variant: e.inputVariant,
361
- onChange: r
323
+ control: /* @__PURE__ */ a(
324
+ s,
325
+ {
326
+ name: "redacted",
327
+ control: o,
328
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ a(M, { checked: !!t, ...n })
329
+ }
330
+ ),
331
+ label: "Redacted",
332
+ sx: { mb: 2 }
362
333
  }
363
- );
364
- }
365
- }
366
- ),
367
- /* @__PURE__ */ a(p, { mt: 2, children: /* @__PURE__ */ a(
368
- s,
369
- {
370
- name: "securityLevelId",
371
- rules: {
372
- required: !0
373
- },
374
- control: d,
375
- render: ({ field: { value: t, onChange: n }, fieldState: i }) => {
376
- var r, o;
377
- const l = (c) => {
378
- n(c);
379
- };
380
- return /* @__PURE__ */ a(
381
- z,
334
+ ),
335
+ /* @__PURE__ */ a(
336
+ W,
382
337
  {
383
- value: t || 0,
384
- ontologyId: e.ontologyId,
385
- appRoles: e.appRoles,
386
- securityLevels: e.securityLevels,
387
- minLevelId: e.minSecurityLevel,
388
- templateKeys: (r = e.securityLevelConfig) == null ? void 0 : r.templateKeys,
389
- templateType: (o = e.securityLevelConfig) == null ? void 0 : o.templateType,
390
- showError: !!i.error,
391
- variant: e.inputVariant,
392
- onChange: l
338
+ control: /* @__PURE__ */ a(
339
+ s,
340
+ {
341
+ name: "contentEncrypted",
342
+ control: o,
343
+ render: ({ field: { value: t, ...n } }) => /* @__PURE__ */ a(M, { checked: !!t, ...n })
344
+ }
345
+ ),
346
+ label: "Content Encrypted",
347
+ sx: { mb: 2 }
393
348
  }
394
- );
395
- }
396
- }
397
- ) }),
398
- /* @__PURE__ */ h(p, { display: "flex", justifyContent: "space-between", mt: 3, children: [
399
- /* @__PURE__ */ a(
400
- y,
401
- {
402
- color: "primary",
403
- variant: "text",
404
- disabled: e.loading,
405
- sx: { textTransform: "none" },
406
- onClick: B,
407
- children: "Cancel"
408
- }
409
- ),
410
- /* @__PURE__ */ h(p, { children: [
411
- e.onRemove !== void 0 && /* @__PURE__ */ a(
412
- y,
349
+ )
350
+ ] }),
351
+ !((A = (_ = e.fieldOptions) == null ? void 0 : _.disseminationList) != null && A.hidden) && /* @__PURE__ */ a(
352
+ s,
413
353
  {
414
- type: "button",
415
- color: "error",
416
- variant: "contained",
417
- disabled: e.removeLoading || e.loading,
418
- sx: { mr: 2, textTransform: "none" },
419
- onClick: e.onRemove,
420
- children: e.removeLoading ? "Deleting..." : "Delete"
354
+ name: "disseminationList",
355
+ rules: {
356
+ required: !0
357
+ },
358
+ control: o,
359
+ render: ({ field: { value: t, onChange: n }, fieldState: r }) => {
360
+ const i = t || [], l = (d) => {
361
+ n(d);
362
+ };
363
+ return /* @__PURE__ */ a(
364
+ ce,
365
+ {
366
+ selectedIds: i,
367
+ memberedGroups: e.memberedGroups,
368
+ showError: !!r.error,
369
+ variant: e.inputVariant,
370
+ onChange: l
371
+ }
372
+ );
373
+ }
421
374
  }
422
375
  ),
423
- e.saveButtons ? e.saveButtons.map((t, n) => /* @__PURE__ */ a(
424
- y,
425
- {
426
- type: "submit",
427
- color: "primary",
428
- variant: "contained",
429
- disabled: e.loading,
430
- startIcon: t.icon,
431
- sx: { ml: 1, textTransform: "none" },
432
- onClick: t.onClick,
433
- children: t.label
434
- },
435
- n
436
- )) : /* @__PURE__ */ a(
437
- y,
376
+ !((P = (D = e.fieldOptions) == null ? void 0 : D.securityLevelId) != null && P.hidden) && /* @__PURE__ */ a(p, { mt: 2, children: /* @__PURE__ */ a(
377
+ s,
438
378
  {
439
- type: "submit",
440
- color: "primary",
441
- variant: "contained",
442
- disabled: e.loading,
443
- sx: { textTransform: "none" },
444
- children: e.loading ? "Saving..." : "Save"
379
+ name: "securityLevelId",
380
+ rules: {
381
+ required: !0
382
+ },
383
+ control: o,
384
+ render: ({ field: { value: t, onChange: n }, fieldState: r }) => {
385
+ var l, d;
386
+ const i = (c) => {
387
+ n(c);
388
+ };
389
+ return /* @__PURE__ */ a(
390
+ ue,
391
+ {
392
+ value: t || 0,
393
+ ontologyId: e.ontologyId,
394
+ appRoles: e.appRoles,
395
+ securityLevels: e.securityLevels,
396
+ minLevelId: e.minSecurityLevel,
397
+ templateKeys: (l = e.securityLevelConfig) == null ? void 0 : l.templateKeys,
398
+ templateType: (d = e.securityLevelConfig) == null ? void 0 : d.templateType,
399
+ showError: !!r.error,
400
+ variant: e.inputVariant,
401
+ onChange: i
402
+ }
403
+ );
404
+ }
445
405
  }
446
- )
447
- ] })
448
- ] })
449
- ] })
406
+ ) }),
407
+ /* @__PURE__ */ h(p, { display: "flex", justifyContent: "space-between", mt: 3, children: [
408
+ /* @__PURE__ */ a(
409
+ g,
410
+ {
411
+ color: "primary",
412
+ variant: "text",
413
+ disabled: e.loading,
414
+ sx: { textTransform: "none" },
415
+ onClick: J,
416
+ children: "Cancel"
417
+ }
418
+ ),
419
+ /* @__PURE__ */ h(p, { children: [
420
+ e.onRemove !== void 0 && /* @__PURE__ */ a(
421
+ g,
422
+ {
423
+ type: "button",
424
+ color: "error",
425
+ variant: "contained",
426
+ disabled: e.removeLoading || e.loading,
427
+ sx: { mr: 2, textTransform: "none" },
428
+ onClick: e.onRemove,
429
+ children: e.removeLoading ? "Deleting..." : "Delete"
430
+ }
431
+ ),
432
+ e.saveButtons ? e.saveButtons.map((t, n) => /* @__PURE__ */ a(
433
+ g,
434
+ {
435
+ type: "submit",
436
+ color: "primary",
437
+ variant: "contained",
438
+ disabled: e.loading,
439
+ startIcon: t.icon,
440
+ sx: { ml: 1, textTransform: "none" },
441
+ onClick: t.onClick,
442
+ children: t.label
443
+ },
444
+ n
445
+ )) : /* @__PURE__ */ a(
446
+ g,
447
+ {
448
+ type: "submit",
449
+ color: "primary",
450
+ variant: "contained",
451
+ disabled: e.loading,
452
+ sx: { textTransform: "none" },
453
+ children: e.loading ? "Saving..." : "Save"
454
+ }
455
+ )
456
+ ] })
457
+ ] })
458
+ ]
459
+ }
460
+ )
450
461
  }
451
462
  );
452
463
  }
453
- const ge = m.forwardRef(te);
464
+ const Oe = m.forwardRef(ve);
454
465
  export {
455
- ge as InstanceForm
466
+ Oe as InstanceForm
456
467
  };
@@ -1,24 +1,32 @@
1
1
  import i from "terraformer-wkt-parser";
2
2
  import * as o from "@turf/turf";
3
3
  const l = (e) => {
4
- if (e.includes("GEOMETRYCOLLECTION")) {
5
- let t = e.replace("GEOMETRYCOLLECTION(", "");
6
- t = t.slice(0, -1);
7
- let n = t.split("),");
8
- return n = n.filter((r) => r !== "").map((r, s) => (s < n.length - 1 && (r += ")"), r)), n.map((r) => i.parse(r));
4
+ try {
5
+ if (e.includes("GEOMETRYCOLLECTION")) {
6
+ let t = e.replace("GEOMETRYCOLLECTION(", "");
7
+ t = t.slice(0, -1);
8
+ let r = t.split("),");
9
+ return r = r.filter((n) => n !== "").map((n, c) => (c < r.length - 1 && (n += ")"), n)), r.map((n) => i.parse(n));
10
+ }
11
+ return i.parse(e);
12
+ } catch {
9
13
  }
10
- return i.parse(e);
11
- }, p = (e) => i.convert(e), u = (e) => {
14
+ }, p = (e) => {
15
+ try {
16
+ return i.convert(e);
17
+ } catch {
18
+ }
19
+ }, u = (e) => {
12
20
  let t = [0, 0];
13
21
  if (e.type === "Point")
14
22
  return t = e.coordinates, t;
15
23
  if (e.type === "Polygon") {
16
- const n = o.polygon(e.coordinates);
17
- return t = o.centerOfMass(n).geometry.coordinates, t;
24
+ const r = o.polygon(e.coordinates);
25
+ return t = o.centerOfMass(r).geometry.coordinates, t;
18
26
  }
19
27
  if (e.type === "LineString") {
20
- const n = o.lineString(e.coordinates);
21
- return t = o.centerOfMass(n).geometry.coordinates, t;
28
+ const r = o.lineString(e.coordinates);
29
+ return t = o.centerOfMass(r).geometry.coordinates, t;
22
30
  }
23
31
  return e.type === "MultiPoint" ? (t = o.multiPoint(e.coordinates).geometry.coordinates[0], t) : (console.log("Undefined geometry type!", e.type), t);
24
32
  };
package/dist/main.d.ts CHANGED
@@ -203,6 +203,13 @@ declare function exportKey(key: any): Promise<JsonWebKey>;
203
203
 
204
204
  declare type FeatureType = AUTH.ModuleType;
205
205
 
206
+ declare interface FieldOptions {
207
+ order?: number;
208
+ hidden?: boolean;
209
+ disabled?: boolean;
210
+ [key: string]: string | number | object | boolean;
211
+ }
212
+
206
213
  declare function generateKey(): Promise<CryptoKey>;
207
214
 
208
215
  export declare const GeometryPicker: React.FC<Props_5>;
@@ -283,6 +290,9 @@ K extends
283
290
  INSTANCE.CreateFileDTO &
284
291
  INSTANCE.UpdateFileDTO
285
292
  >;
293
+ fieldOptions?: {
294
+ [key: string]: FieldOptions;
295
+ };
286
296
  /**
287
297
  *
288
298
  */
@@ -294,7 +304,6 @@ K extends
294
304
  /**
295
305
  *
296
306
  */
297
- disableTemplateChange?: boolean;
298
307
  /**
299
308
  *
300
309
  */
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.4.14",
4
+ "version": "1.4.16",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",