@hybridcore/ui 1.4.22 → 1.4.24

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.
@@ -3,7 +3,7 @@ import "@mui/material";
3
3
  import "./styled.js";
4
4
  import "@mui/icons-material";
5
5
  import "../../../../hooks/useToggle.js";
6
- import { C as l } from "../../../../index-BGS3q6sP.js";
6
+ import { C as l } from "../../../../index-oPY7k6mu.js";
7
7
  import "react";
8
8
  import "lodash";
9
9
  import "dayjs";
@@ -1,7 +1,7 @@
1
1
  import "react/jsx-runtime";
2
2
  import "lodash";
3
3
  import "dayjs";
4
- import { V as g } from "../../../../index-BGS3q6sP.js";
4
+ import { V as g } from "../../../../index-oPY7k6mu.js";
5
5
  import "@mui/material";
6
6
  import "@mui/icons-material";
7
7
  import "../../../geometry-picker/index.js";
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, Fragment as h } from "react/jsx-runtime";
2
2
  import p from "react";
3
- import { V as x } from "../../../../index-BGS3q6sP.js";
3
+ import { V as x } from "../../../../index-oPY7k6mu.js";
4
4
  import _ from "lodash";
5
5
  import { Box as d } from "@mui/material";
6
6
  function V({
@@ -5,7 +5,7 @@ import { DataGrid as fe } from "@mui/x-data-grid";
5
5
  import { useState as H, useEffect as ue } from "react";
6
6
  import h from "lodash";
7
7
  import { e as ye } from "../../ol-CHaVTXvL.js";
8
- import { V as he } from "../../index-BGS3q6sP.js";
8
+ import { V as he } from "../../index-oPY7k6mu.js";
9
9
  import { RangeSelector as me } from "../range-selector/index.js";
10
10
  const $e = ({
11
11
  open: F,
@@ -1,78 +1,85 @@
1
- import { jsx as s, Fragment as m } from "react/jsx-runtime";
2
- import a from "lodash";
3
- import { CollapsibleCard as y } from "../collapsible-card/index.js";
4
- import p from "./property.js";
1
+ import { jsx as a, Fragment as p } from "react/jsx-runtime";
2
+ import u from "lodash";
3
+ import { CollapsibleCard as v } from "../collapsible-card/index.js";
4
+ import h from "./property.js";
5
5
  const N = ({
6
6
  values: o,
7
7
  templates: d,
8
- inputVariant: u,
9
- onChange: h
8
+ inputVariant: c,
9
+ fieldOptions: s,
10
+ onChange: g
10
11
  }) => {
11
- const c = (f) => (r) => {
12
+ const m = (f) => (n) => {
12
13
  if (f) {
13
- let e = o.find((l) => l.templateKey === f);
14
+ let e = o.find((r) => r.templateKey === f);
14
15
  if (e) {
15
- const l = a.keys(r)[0];
16
+ const r = u.keys(n)[0];
16
17
  let t = e.filters.findIndex(
17
- (n) => n.fieldName === l
18
+ (l) => l.fieldName === r
18
19
  );
19
- const i = a.get(r, l);
20
- a.values(i).filter((n) => !(a.isArray(n) && n.length === 0 || n === "")).length === 0 && t !== -1 ? e.filters.splice(t, 1) : t !== -1 ? e.filters[t] = {
21
- fieldName: l,
20
+ const i = u.get(n, r);
21
+ u.values(i).filter((l) => !(u.isArray(l) && l.length === 0 || l === "")).length === 0 && t !== -1 ? e.filters.splice(t, 1) : t !== -1 ? e.filters[t] = {
22
+ fieldName: r,
22
23
  value: i
23
24
  } : e.filters.push({
24
- fieldName: l,
25
+ fieldName: r,
25
26
  value: i
26
27
  });
27
28
  }
28
- h(o);
29
+ g(o);
29
30
  } else console.warn("Template could not be found!");
30
31
  };
31
32
  if (o.length === 1) {
32
- const f = o[0], r = d.get(f.templateKey);
33
- return /* @__PURE__ */ s(m, { children: r == null ? void 0 : r.properties.map((e, l) => {
33
+ const f = o[0], n = d.get(f.templateKey);
34
+ return /* @__PURE__ */ a(p, { children: n == null ? void 0 : n.properties.filter((e) => {
35
+ var r;
36
+ return s ? !((r = s[e.propertyId]) != null && r.hidden) : !0;
37
+ }).map((e, r) => {
34
38
  let t = {};
35
39
  const i = f.filters.find(
36
- (n) => n.fieldName === e.propertyId
40
+ (l) => l.fieldName === e.propertyId
37
41
  );
38
- return i && (t = i.value), /* @__PURE__ */ s(
39
- p,
42
+ return i && (t = i.value), /* @__PURE__ */ a(
43
+ h,
40
44
  {
41
45
  property: e,
42
46
  value: t,
43
47
  size: "small",
44
- variant: u,
45
- onChange: c(r == null ? void 0 : r.templateKey)
48
+ variant: c,
49
+ onChange: m(n == null ? void 0 : n.templateKey)
46
50
  },
47
- l
51
+ r
48
52
  );
49
53
  }) });
50
54
  }
51
- return o.map((f, r) => {
55
+ return o.map((f, n) => {
52
56
  const e = d.get(f.templateKey);
53
- return /* @__PURE__ */ s(
54
- y,
57
+ return /* @__PURE__ */ a(
58
+ v,
55
59
  {
56
60
  header: e == null ? void 0 : e.name,
57
- content: /* @__PURE__ */ s(m, { children: e == null ? void 0 : e.properties.map((l, t) => {
61
+ content: /* @__PURE__ */ a(p, { children: e == null ? void 0 : e.properties.filter((r) => {
62
+ var t;
63
+ return s ? !((t = s[r.propertyId]) != null && t.hidden) : !0;
64
+ }).map((r, t) => {
58
65
  let i = {};
59
- const n = f.filters.find(
60
- (g) => g.fieldName === l.propertyId
66
+ const l = f.filters.find(
67
+ (y) => y.fieldName === r.propertyId
61
68
  );
62
- return n && (i = n.value), /* @__PURE__ */ s(
63
- p,
69
+ return l && (i = l.value), /* @__PURE__ */ a(
70
+ h,
64
71
  {
65
- property: l,
72
+ property: r,
66
73
  value: i,
67
74
  size: "small",
68
- variant: u,
69
- onChange: c(e == null ? void 0 : e.templateKey)
75
+ variant: c,
76
+ onChange: m(e == null ? void 0 : e.templateKey)
70
77
  },
71
78
  t
72
79
  );
73
80
  }) })
74
81
  },
75
- r
82
+ n
76
83
  );
77
84
  });
78
85
  };
@@ -0,0 +1,350 @@
1
+ import { jsxs as h, Fragment as P, jsx as a } from "react/jsx-runtime";
2
+ import I from "lodash";
3
+ import N from "dayjs";
4
+ import { FormControl as W, FormLabel as j, FormGroup as Y, FormControlLabel as $, Checkbox as v, Typography as S, Button as D, Chip as _, Dialog as E, DialogTitle as G, DialogContent as M, DialogActions as H, InputAdornment as K, Tooltip as R } from "@mui/material";
5
+ import { Container as U, Values as J, MiniButton as Q } from "./components/instance-form/components/composite-list/styled.js";
6
+ import { KeyboardArrowUp as X, KeyboardArrowDown as Z, Add as O, LockOutlined as z } from "@mui/icons-material";
7
+ import ee from "./hooks/useToggle.js";
8
+ import { GeometryPicker as ne } from "./components/geometry-picker/index.js";
9
+ import { PhoneInput as ae } from "./components/phone-input/index.js";
10
+ import { DateTimePicker as le } from "./components/date-time-picker/index.js";
11
+ import { T as q } from "./TextField-D87qTh1k.js";
12
+ import { B as x } from "./Box-BPyg-Ybm.js";
13
+ import { F as te } from "./FormControlLabel-D9KFjcIx.js";
14
+ import { C as oe } from "./Checkbox-qy3cjvnb.js";
15
+ import { F as de, I as ie } from "./InputLabel-CWkW8NtU.js";
16
+ import { S as me } from "./Select-ClaBvSqf.js";
17
+ import { M as re } from "./MenuItem-D-INSvZa.js";
18
+ import { useState as B } from "react";
19
+ function ce({
20
+ property: o,
21
+ mapboxAccessToken: e,
22
+ value: l,
23
+ variant: s = "outlined",
24
+ size: c = "medium",
25
+ onChange: d
26
+ }) {
27
+ var C, g, V;
28
+ const f = ee(!1), [i, u] = B(), [b, k] = B(!1), w = 10, A = (n) => {
29
+ u(I.get(n, o.propertyId));
30
+ }, y = () => {
31
+ d([...l || [], i]), u(""), f.action.close();
32
+ }, p = (n) => () => {
33
+ if (l) {
34
+ const t = [...l];
35
+ t.splice(n, 1), d(t);
36
+ }
37
+ }, F = (n) => {
38
+ const { value: t, checked: m } = n.target;
39
+ let r = I.isArray(l) ? l : [];
40
+ m ? r.push(t) : r = r.filter((L) => L !== t), d(r);
41
+ };
42
+ if (((g = (C = o.dataTypeInfo) == null ? void 0 : C.innerType) == null ? void 0 : g.type) === "enum") {
43
+ const { enumValues: n } = o.dataTypeInfo.innerType;
44
+ return /* @__PURE__ */ h(P, { children: [
45
+ /* @__PURE__ */ h(W, { fullWidth: !0, component: "fieldset", variant: s, children: [
46
+ /* @__PURE__ */ a(j, { component: "legend", sx: { mb: 1 }, children: o.name }),
47
+ /* @__PURE__ */ a(Y, { children: n && n.length > 0 ? n.slice(0, b ? 9999 : w).map((t, m) => /* @__PURE__ */ a(
48
+ $,
49
+ {
50
+ label: t,
51
+ control: /* @__PURE__ */ a(
52
+ v,
53
+ {
54
+ name: o.propertyId,
55
+ value: t,
56
+ size: "small",
57
+ checked: I.isArray(l) ? l.includes(t) : !1,
58
+ onChange: F
59
+ }
60
+ ),
61
+ componentsProps: {
62
+ typography: {
63
+ variant: "body2"
64
+ }
65
+ }
66
+ },
67
+ m
68
+ )) : /* @__PURE__ */ a(S, { variant: "caption", mb: 1, children: "No enum values!" }) })
69
+ ] }),
70
+ I.isArray(n) && n.length > w && /* @__PURE__ */ h(
71
+ D,
72
+ {
73
+ size: "small",
74
+ sx: { p: 0, textTransform: "none" },
75
+ endIcon: b ? /* @__PURE__ */ a(X, {}) : /* @__PURE__ */ a(Z, {}),
76
+ onClick: () => k((t) => !t),
77
+ children: [
78
+ "Show ",
79
+ b ? "Less" : "More"
80
+ ]
81
+ }
82
+ )
83
+ ] });
84
+ }
85
+ return /* @__PURE__ */ h(P, { children: [
86
+ /* @__PURE__ */ h(U, { variant: s, children: [
87
+ /* @__PURE__ */ a(S, { children: o.name }),
88
+ /* @__PURE__ */ a(J, { children: I.isArray(l) && l.map((n, t) => {
89
+ var m, r;
90
+ return /* @__PURE__ */ a(
91
+ _,
92
+ {
93
+ label: ((r = (m = o.dataTypeInfo) == null ? void 0 : m.innerType) == null ? void 0 : r.type) === "date" ? N(n).format("DD/MM/YYYY HH:mm:ss") : n,
94
+ size: c,
95
+ onDelete: p(t)
96
+ },
97
+ t
98
+ );
99
+ }) }),
100
+ /* @__PURE__ */ a(
101
+ Q,
102
+ {
103
+ startIcon: /* @__PURE__ */ a(O, {}),
104
+ variant: "text",
105
+ onClick: f.action.open,
106
+ children: "Add"
107
+ }
108
+ )
109
+ ] }),
110
+ /* @__PURE__ */ h(
111
+ E,
112
+ {
113
+ open: f.state.isOpen,
114
+ onClose: f.action.close,
115
+ maxWidth: "sm",
116
+ fullWidth: !0,
117
+ children: [
118
+ /* @__PURE__ */ a(G, { children: "Add List Value" }),
119
+ /* @__PURE__ */ a(M, { children: (V = o.dataTypeInfo) != null && V.innerType ? /* @__PURE__ */ a(
120
+ ue,
121
+ {
122
+ mapboxAccessToken: e,
123
+ property: {
124
+ ...o,
125
+ name: "Value",
126
+ type: o.dataTypeInfo.innerType.type
127
+ },
128
+ value: i,
129
+ onChange: A
130
+ }
131
+ ) : null }),
132
+ /* @__PURE__ */ h(H, { children: [
133
+ /* @__PURE__ */ a(
134
+ D,
135
+ {
136
+ variant: "contained",
137
+ color: "inherit",
138
+ onClick: f.action.close,
139
+ children: "Cancel"
140
+ }
141
+ ),
142
+ /* @__PURE__ */ a(D, { variant: "contained", color: "primary", onClick: y, children: "Ok" })
143
+ ] })
144
+ ]
145
+ }
146
+ )
147
+ ] });
148
+ }
149
+ function ue({
150
+ mapboxAccessToken: o,
151
+ property: e,
152
+ value: l,
153
+ variant: s = "standard",
154
+ size: c = "medium",
155
+ disableMargin: d = !1,
156
+ defaultExtent: f,
157
+ fieldOptions: i,
158
+ // keyAuth,
159
+ onChange: u
160
+ }) {
161
+ var C, g, V;
162
+ const b = (n) => {
163
+ const m = n.target.value.split(",").map((r) => r.trimStart());
164
+ u({
165
+ [e.propertyId]: m
166
+ });
167
+ }, k = (n) => {
168
+ const { name: t, type: m, checked: r, value: L } = n.target;
169
+ let T = L;
170
+ e.type === "double" && (T = T.replace(",", "."), T = T.replace(/[^\d.-]+/g, "")), u({
171
+ [t]: m === "checkbox" ? r : T
172
+ });
173
+ }, w = (n) => {
174
+ u({
175
+ [e.propertyId]: n
176
+ });
177
+ }, A = (n) => {
178
+ u({
179
+ [e.propertyId]: n.target.value
180
+ });
181
+ }, y = (n) => (t) => {
182
+ u({
183
+ [n]: t
184
+ });
185
+ }, p = (n) => (t) => {
186
+ u({
187
+ [n]: t
188
+ });
189
+ }, F = (n) => (t) => {
190
+ u({
191
+ [n]: t
192
+ });
193
+ };
194
+ if ([
195
+ "string",
196
+ "integer",
197
+ "double",
198
+ "text",
199
+ "long",
200
+ "byte",
201
+ "bank-account"
202
+ ].includes(e.type))
203
+ return /* @__PURE__ */ a(
204
+ q,
205
+ {
206
+ label: e.name,
207
+ name: e.propertyId,
208
+ required: e.required,
209
+ value: l ?? e.defaultValue ?? "",
210
+ defaultValue: l,
211
+ onChange: k,
212
+ variant: s,
213
+ type: "text",
214
+ multiline: e.type === "text",
215
+ disabled: !e.editable,
216
+ fullWidth: !0,
217
+ sx: { mb: d ? 0 : 2 },
218
+ InputProps: {
219
+ size: c,
220
+ ...i && i[e.propertyId] && {
221
+ tabIndex: i[e.propertyId].order
222
+ },
223
+ ...e.privacyPreservationMethod === "ENCRYPTION" ? {
224
+ endAdornment: /* @__PURE__ */ a(K, { position: "end", children: /* @__PURE__ */ a(R, { title: "Encrypted Field", children: /* @__PURE__ */ a(z, {}) }) })
225
+ } : {}
226
+ }
227
+ }
228
+ );
229
+ if (e.type === "date") {
230
+ const n = l !== void 0 ? N(l).format() : l;
231
+ return /* @__PURE__ */ a(x, { mb: d ? 0 : 2, children: /* @__PURE__ */ a(
232
+ le,
233
+ {
234
+ label: e.name,
235
+ value: n,
236
+ variant: s,
237
+ size: c,
238
+ name: e.propertyId,
239
+ onChange: w
240
+ }
241
+ ) });
242
+ }
243
+ if (e.type === "list") {
244
+ let n = "";
245
+ return e.defaultValue && (n = I.isArray(e.defaultValue) ? l.join(", ") : e.defaultValue), l && (n = I.isArray(l) ? l.join(",") : l), /* @__PURE__ */ a(
246
+ q,
247
+ {
248
+ label: e.name,
249
+ name: e.propertyId,
250
+ value: n,
251
+ onChange: b,
252
+ variant: s,
253
+ disabled: !e.editable,
254
+ required: e.required,
255
+ fullWidth: !0,
256
+ helperText: c === "small" ? null : "Add list values with the comma (,) separated string",
257
+ sx: { mb: d ? 0 : 2 },
258
+ InputProps: {
259
+ size: c,
260
+ placeholder: c === "small" ? "Add list values with the comma (,) separated string" : "",
261
+ ...i && i[e.propertyId] && {
262
+ tabIndex: i[e.propertyId].order
263
+ }
264
+ }
265
+ }
266
+ );
267
+ }
268
+ if (e.type === "boolean")
269
+ return /* @__PURE__ */ a(x, { mb: d ? 0 : 2, children: /* @__PURE__ */ a(
270
+ te,
271
+ {
272
+ control: /* @__PURE__ */ a(
273
+ oe,
274
+ {
275
+ name: e.propertyId,
276
+ checked: !!l,
277
+ onChange: k,
278
+ size: c
279
+ }
280
+ ),
281
+ label: e.name
282
+ }
283
+ ) });
284
+ if (e.type === "enum") {
285
+ let n = [];
286
+ return (C = e.dataTypeInfo) != null && C.enumValues && (n = e.dataTypeInfo.enumValues), (V = (g = e.dataTypeInfo) == null ? void 0 : g.innerType) != null && V.enumValues && (n = e.dataTypeInfo.innerType.enumValues), /* @__PURE__ */ h(
287
+ de,
288
+ {
289
+ fullWidth: !0,
290
+ variant: s,
291
+ sx: { mb: d ? 0 : 2 },
292
+ size: c,
293
+ required: e.required,
294
+ children: [
295
+ /* @__PURE__ */ a(ie, { id: `${e.propertyId}-label`, children: e.name }),
296
+ /* @__PURE__ */ a(
297
+ me,
298
+ {
299
+ label: e.name,
300
+ name: e.name,
301
+ labelId: `${e.propertyId}-label`,
302
+ id: e.propertyId,
303
+ value: l ?? "",
304
+ onChange: A,
305
+ inputProps: {
306
+ ...i && i[e.propertyId] && {
307
+ tabIndex: i[e.propertyId].order
308
+ }
309
+ },
310
+ children: n.map((t, m) => /* @__PURE__ */ a(re, { value: t, children: t }, m))
311
+ }
312
+ )
313
+ ]
314
+ }
315
+ );
316
+ }
317
+ return e.type === "geometry" ? /* @__PURE__ */ a(x, { sx: { mb: d ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ a(
318
+ ne,
319
+ {
320
+ mapboxAccessToken: o,
321
+ label: e.name,
322
+ value: l ?? e.defaultValue ?? "",
323
+ defaultExtent: f,
324
+ variant: s,
325
+ onChange: y(e.propertyId)
326
+ }
327
+ ) }) : e.type === "phone-number" ? /* @__PURE__ */ a(x, { sx: { mb: d ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ a(
328
+ ae,
329
+ {
330
+ label: e.name,
331
+ placeholder: "Enter phone number",
332
+ value: l ?? e.defaultValue ?? "",
333
+ onChange: p(e.propertyId)
334
+ }
335
+ ) }) : e.type === "composite-list" ? /* @__PURE__ */ a(x, { sx: { mb: d ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ a(
336
+ ce,
337
+ {
338
+ property: e,
339
+ value: l ?? e.defaultValue ?? "",
340
+ variant: s,
341
+ size: c,
342
+ mapboxAccessToken: o,
343
+ onChange: F(e.propertyId)
344
+ }
345
+ ) }) : /* @__PURE__ */ a(P, {});
346
+ }
347
+ export {
348
+ ce as C,
349
+ ue as V
350
+ };
package/dist/main.d.ts CHANGED
@@ -560,6 +560,9 @@ declare interface Props_10 {
560
560
  values: FV.TemplateFilter[];
561
561
  templates: Map<string | number, ONTOLOGY.TemplateType>;
562
562
  inputVariant?: "standard" | "outlined" | "filled";
563
+ fieldOptions?: {
564
+ [key: string]: FieldOptions;
565
+ };
563
566
  onChange(values: FV.TemplateFilter[]): void;
564
567
  }
565
568
 
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.22",
4
+ "version": "1.4.24",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",
@@ -1,338 +0,0 @@
1
- import { jsxs as h, Fragment as D, jsx as n } from "react/jsx-runtime";
2
- import I from "lodash";
3
- import B from "dayjs";
4
- import { FormControl as N, FormLabel as W, FormGroup as j, FormControlLabel as Y, Checkbox as $, Typography as P, Button as L, Chip as v, Dialog as O, DialogTitle as _, DialogContent as E, DialogActions as G, InputAdornment as M, Tooltip as H } from "@mui/material";
5
- import { Container as K, Values as R, MiniButton as U } from "./components/instance-form/components/composite-list/styled.js";
6
- import { KeyboardArrowUp as J, KeyboardArrowDown as Q, Add as X, LockOutlined as Z } from "@mui/icons-material";
7
- import z from "./hooks/useToggle.js";
8
- import { GeometryPicker as ee } from "./components/geometry-picker/index.js";
9
- import { PhoneInput as ne } from "./components/phone-input/index.js";
10
- import { DateTimePicker as le } from "./components/date-time-picker/index.js";
11
- import { T as S } from "./TextField-D87qTh1k.js";
12
- import { B as T } from "./Box-BPyg-Ybm.js";
13
- import { F as te } from "./FormControlLabel-D9KFjcIx.js";
14
- import { C as ae } from "./Checkbox-qy3cjvnb.js";
15
- import { F as oe, I as ie } from "./InputLabel-CWkW8NtU.js";
16
- import { S as de } from "./Select-ClaBvSqf.js";
17
- import { M as me } from "./MenuItem-D-INSvZa.js";
18
- import { useState as q } from "react";
19
- function ce({
20
- property: i,
21
- mapboxAccessToken: e,
22
- value: l,
23
- variant: s = "outlined",
24
- size: m = "medium",
25
- onChange: d
26
- }) {
27
- var g, V, t;
28
- const f = z(!1), [c, x] = q(), [C, w] = q(!1), k = 10, A = (a) => {
29
- x(I.get(a, i.propertyId));
30
- }, y = () => {
31
- d([...l || [], c]), x(""), f.action.close();
32
- }, F = (a) => () => {
33
- if (l) {
34
- const o = [...l];
35
- o.splice(a, 1), d(o);
36
- }
37
- }, p = (a) => {
38
- const { value: o, checked: r } = a.target;
39
- let u = I.isArray(l) ? l : [];
40
- r ? u.push(o) : u = u.filter((b) => b !== o), d(u);
41
- };
42
- if (((V = (g = i.dataTypeInfo) == null ? void 0 : g.innerType) == null ? void 0 : V.type) === "enum") {
43
- const { enumValues: a } = i.dataTypeInfo.innerType;
44
- return /* @__PURE__ */ h(D, { children: [
45
- /* @__PURE__ */ h(N, { fullWidth: !0, component: "fieldset", variant: s, children: [
46
- /* @__PURE__ */ n(W, { component: "legend", sx: { mb: 1 }, children: i.name }),
47
- /* @__PURE__ */ n(j, { children: a && a.length > 0 ? a.slice(0, C ? 9999 : k).map((o, r) => /* @__PURE__ */ n(
48
- Y,
49
- {
50
- label: o,
51
- control: /* @__PURE__ */ n(
52
- $,
53
- {
54
- name: i.propertyId,
55
- value: o,
56
- size: "small",
57
- checked: I.isArray(l) ? l.includes(o) : !1,
58
- onChange: p
59
- }
60
- ),
61
- componentsProps: {
62
- typography: {
63
- variant: "body2"
64
- }
65
- }
66
- },
67
- r
68
- )) : /* @__PURE__ */ n(P, { variant: "caption", mb: 1, children: "No enum values!" }) })
69
- ] }),
70
- I.isArray(a) && a.length > k && /* @__PURE__ */ h(
71
- L,
72
- {
73
- size: "small",
74
- sx: { p: 0, textTransform: "none" },
75
- endIcon: C ? /* @__PURE__ */ n(J, {}) : /* @__PURE__ */ n(Q, {}),
76
- onClick: () => w((o) => !o),
77
- children: [
78
- "Show ",
79
- C ? "Less" : "More"
80
- ]
81
- }
82
- )
83
- ] });
84
- }
85
- return /* @__PURE__ */ h(D, { children: [
86
- /* @__PURE__ */ h(K, { variant: s, children: [
87
- /* @__PURE__ */ n(P, { children: i.name }),
88
- /* @__PURE__ */ n(R, { children: I.isArray(l) && l.map((a, o) => {
89
- var r, u;
90
- return /* @__PURE__ */ n(
91
- v,
92
- {
93
- label: ((u = (r = i.dataTypeInfo) == null ? void 0 : r.innerType) == null ? void 0 : u.type) === "date" ? B(a).format("DD/MM/YYYY HH:mm:ss") : a,
94
- size: m,
95
- onDelete: F(o)
96
- },
97
- o
98
- );
99
- }) }),
100
- /* @__PURE__ */ n(
101
- U,
102
- {
103
- startIcon: /* @__PURE__ */ n(X, {}),
104
- variant: "text",
105
- onClick: f.action.open,
106
- children: "Add"
107
- }
108
- )
109
- ] }),
110
- /* @__PURE__ */ h(
111
- O,
112
- {
113
- open: f.state.isOpen,
114
- onClose: f.action.close,
115
- maxWidth: "sm",
116
- fullWidth: !0,
117
- children: [
118
- /* @__PURE__ */ n(_, { children: "Add List Value" }),
119
- /* @__PURE__ */ n(E, { children: (t = i.dataTypeInfo) != null && t.innerType ? /* @__PURE__ */ n(
120
- re,
121
- {
122
- mapboxAccessToken: e,
123
- property: {
124
- ...i,
125
- name: "Value",
126
- type: i.dataTypeInfo.innerType.type
127
- },
128
- value: c,
129
- onChange: A
130
- }
131
- ) : null }),
132
- /* @__PURE__ */ h(G, { children: [
133
- /* @__PURE__ */ n(
134
- L,
135
- {
136
- variant: "contained",
137
- color: "inherit",
138
- onClick: f.action.close,
139
- children: "Cancel"
140
- }
141
- ),
142
- /* @__PURE__ */ n(L, { variant: "contained", color: "primary", onClick: y, children: "Ok" })
143
- ] })
144
- ]
145
- }
146
- )
147
- ] });
148
- }
149
- function re({
150
- mapboxAccessToken: i,
151
- property: e,
152
- value: l,
153
- variant: s = "standard",
154
- size: m = "medium",
155
- disableMargin: d = !1,
156
- defaultExtent: f,
157
- // keyAuth,
158
- onChange: c
159
- }) {
160
- var p, g, V;
161
- const x = (t) => {
162
- const o = t.target.value.split(",").map((r) => r.trimStart());
163
- c({
164
- [e.propertyId]: o
165
- });
166
- }, C = (t) => {
167
- const { name: a, type: o, checked: r, value: u } = t.target;
168
- let b = u;
169
- e.type === "double" && (b = b.replace(",", "."), b = b.replace(/[^\d.-]+/g, "")), c({
170
- [a]: o === "checkbox" ? r : b
171
- });
172
- }, w = (t) => {
173
- c({
174
- [e.propertyId]: t
175
- });
176
- }, k = (t) => {
177
- c({
178
- [e.propertyId]: t.target.value
179
- });
180
- }, A = (t) => (a) => {
181
- c({
182
- [t]: a
183
- });
184
- }, y = (t) => (a) => {
185
- c({
186
- [t]: a
187
- });
188
- }, F = (t) => (a) => {
189
- c({
190
- [t]: a
191
- });
192
- };
193
- if ([
194
- "string",
195
- "integer",
196
- "double",
197
- "text",
198
- "long",
199
- "byte",
200
- "bank-account"
201
- ].includes(e.type))
202
- return /* @__PURE__ */ n(
203
- S,
204
- {
205
- label: e.name,
206
- name: e.propertyId,
207
- required: e.required,
208
- value: l ?? e.defaultValue ?? "",
209
- defaultValue: l,
210
- onChange: C,
211
- variant: s,
212
- type: "text",
213
- multiline: e.type === "text",
214
- disabled: !e.editable,
215
- fullWidth: !0,
216
- sx: { mb: d ? 0 : 2 },
217
- InputProps: {
218
- size: m,
219
- ...e.privacyPreservationMethod === "ENCRYPTION" ? {
220
- endAdornment: /* @__PURE__ */ n(M, { position: "end", children: /* @__PURE__ */ n(H, { title: "Encrypted Field", children: /* @__PURE__ */ n(Z, {}) }) })
221
- } : {}
222
- }
223
- }
224
- );
225
- if (e.type === "date") {
226
- const t = l !== void 0 ? B(l).format() : l;
227
- return /* @__PURE__ */ n(T, { mb: d ? 0 : 2, children: /* @__PURE__ */ n(
228
- le,
229
- {
230
- label: e.name,
231
- value: t,
232
- variant: s,
233
- size: m,
234
- name: e.propertyId,
235
- onChange: w
236
- }
237
- ) });
238
- }
239
- if (e.type === "list") {
240
- let t = "";
241
- return e.defaultValue && (t = I.isArray(e.defaultValue) ? l.join(", ") : e.defaultValue), l && (t = I.isArray(l) ? l.join(",") : l), /* @__PURE__ */ n(
242
- S,
243
- {
244
- label: e.name,
245
- name: e.propertyId,
246
- value: t,
247
- onChange: x,
248
- variant: s,
249
- disabled: !e.editable,
250
- required: e.required,
251
- fullWidth: !0,
252
- helperText: m === "small" ? null : "Add list values with the comma (,) separated string",
253
- sx: { mb: d ? 0 : 2 },
254
- InputProps: {
255
- size: m,
256
- placeholder: m === "small" ? "Add list values with the comma (,) separated string" : ""
257
- }
258
- }
259
- );
260
- }
261
- if (e.type === "boolean")
262
- return /* @__PURE__ */ n(T, { mb: d ? 0 : 2, children: /* @__PURE__ */ n(
263
- te,
264
- {
265
- control: /* @__PURE__ */ n(
266
- ae,
267
- {
268
- name: e.propertyId,
269
- checked: !!l,
270
- onChange: C,
271
- size: m
272
- }
273
- ),
274
- label: e.name
275
- }
276
- ) });
277
- if (e.type === "enum") {
278
- let t = [];
279
- return (p = e.dataTypeInfo) != null && p.enumValues && (t = e.dataTypeInfo.enumValues), (V = (g = e.dataTypeInfo) == null ? void 0 : g.innerType) != null && V.enumValues && (t = e.dataTypeInfo.innerType.enumValues), /* @__PURE__ */ h(
280
- oe,
281
- {
282
- fullWidth: !0,
283
- variant: s,
284
- sx: { mb: d ? 0 : 2 },
285
- size: m,
286
- required: e.required,
287
- children: [
288
- /* @__PURE__ */ n(ie, { id: `${e.propertyId}-label`, children: e.name }),
289
- /* @__PURE__ */ n(
290
- de,
291
- {
292
- label: e.name,
293
- name: e.name,
294
- labelId: `${e.propertyId}-label`,
295
- id: e.propertyId,
296
- value: l ?? "",
297
- onChange: k,
298
- children: t.map((a, o) => /* @__PURE__ */ n(me, { value: a, children: a }, o))
299
- }
300
- )
301
- ]
302
- }
303
- );
304
- }
305
- return e.type === "geometry" ? /* @__PURE__ */ n(T, { sx: { mb: d ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ n(
306
- ee,
307
- {
308
- mapboxAccessToken: i,
309
- label: e.name,
310
- value: l ?? e.defaultValue ?? "",
311
- defaultExtent: f,
312
- variant: s,
313
- onChange: A(e.propertyId)
314
- }
315
- ) }) : e.type === "phone-number" ? /* @__PURE__ */ n(T, { sx: { mb: d ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ n(
316
- ne,
317
- {
318
- label: e.name,
319
- placeholder: "Enter phone number",
320
- value: l ?? e.defaultValue ?? "",
321
- onChange: y(e.propertyId)
322
- }
323
- ) }) : e.type === "composite-list" ? /* @__PURE__ */ n(T, { sx: { mb: d ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ n(
324
- ce,
325
- {
326
- property: e,
327
- value: l ?? e.defaultValue ?? "",
328
- variant: s,
329
- size: m,
330
- mapboxAccessToken: i,
331
- onChange: F(e.propertyId)
332
- }
333
- ) }) : /* @__PURE__ */ n(D, {});
334
- }
335
- export {
336
- ce as C,
337
- re as V
338
- };