@hybridcore/ui 1.5.32 → 1.5.34

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