@hybridcore/ui 1.5.4 → 1.5.7

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,353 +0,0 @@
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 P, 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 z, LockOutlined as O } 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-BjFXx91l.js";
12
- import { B as x } from "./Box-SSMZuKnS.js";
13
- import { F as te } from "./FormControlLabel-BNT5EI0b.js";
14
- import { C as oe } from "./Checkbox-B0P8LhCl.js";
15
- import { F as de, I as ie } from "./InputLabel-ClDXuWBr.js";
16
- import { S as me } from "./Select-ush_fSWy.js";
17
- import { M as re } from "./MenuItem-Lcjh1XlV.js";
18
- import { useState as B } from "react";
19
- function ce({
20
- property: d,
21
- mapboxAccessToken: e,
22
- value: l,
23
- variant: s = "outlined",
24
- size: c = "medium",
25
- onChange: i
26
- }) {
27
- var C, g, V;
28
- const f = ee(!1), [o, u] = B(), [b, k] = B(!1), w = 10, A = (n) => {
29
- u(I.get(n, d.propertyId));
30
- }, y = () => {
31
- i([...l || [], o]), u(""), f.action.close();
32
- }, D = (n) => () => {
33
- if (l) {
34
- const t = [...l];
35
- t.splice(n, 1), i(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), i(r);
41
- };
42
- if (((g = (C = d.dataTypeInfo) == null ? void 0 : C.innerType) == null ? void 0 : g.type) === "enum") {
43
- const { enumValues: n } = d.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: d.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: d.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
- P,
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: d.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 = d.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: D(t)
96
- },
97
- t
98
- );
99
- }) }),
100
- /* @__PURE__ */ a(
101
- Q,
102
- {
103
- startIcon: /* @__PURE__ */ a(z, {}),
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 = d.dataTypeInfo) != null && V.innerType ? /* @__PURE__ */ a(
120
- ue,
121
- {
122
- mapboxAccessToken: e,
123
- property: {
124
- ...d,
125
- name: "Value",
126
- type: d.dataTypeInfo.innerType.type
127
- },
128
- value: o,
129
- onChange: A
130
- }
131
- ) : null }),
132
- /* @__PURE__ */ h(H, { children: [
133
- /* @__PURE__ */ a(
134
- P,
135
- {
136
- variant: "contained",
137
- color: "inherit",
138
- onClick: f.action.close,
139
- children: "Cancel"
140
- }
141
- ),
142
- /* @__PURE__ */ a(P, { variant: "contained", color: "primary", onClick: y, children: "Ok" })
143
- ] })
144
- ]
145
- }
146
- )
147
- ] });
148
- }
149
- function ue({
150
- mapboxAccessToken: d,
151
- property: e,
152
- value: l,
153
- variant: s = "standard",
154
- size: c = "medium",
155
- disableMargin: i = !1,
156
- defaultExtent: f,
157
- fieldOptions: o,
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
- }, D = (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: i ? 0 : 2 },
218
- InputProps: {
219
- size: c,
220
- ...o && o[e.propertyId] && {
221
- tabIndex: o[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(O, {}) }) })
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: i ? 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
- ...o && o[e.propertyId] && {
241
- minDate: o[e.propertyId].minDate
242
- }
243
- }
244
- ) });
245
- }
246
- if (e.type === "list") {
247
- let n = "";
248
- return e.defaultValue && (n = I.isArray(e.defaultValue) ? l.join(", ") : e.defaultValue), l && (n = I.isArray(l) ? l.join(",") : l), /* @__PURE__ */ a(
249
- q,
250
- {
251
- label: e.name,
252
- name: e.propertyId,
253
- value: n,
254
- onChange: b,
255
- variant: s,
256
- disabled: !e.editable,
257
- required: e.required,
258
- fullWidth: !0,
259
- helperText: c === "small" ? null : "Add list values with the comma (,) separated string",
260
- sx: { mb: i ? 0 : 2 },
261
- InputProps: {
262
- size: c,
263
- placeholder: c === "small" ? "Add list values with the comma (,) separated string" : "",
264
- ...o && o[e.propertyId] && {
265
- tabIndex: o[e.propertyId].order
266
- }
267
- }
268
- }
269
- );
270
- }
271
- if (e.type === "boolean")
272
- return /* @__PURE__ */ a(x, { mb: i ? 0 : 2, children: /* @__PURE__ */ a(
273
- te,
274
- {
275
- control: /* @__PURE__ */ a(
276
- oe,
277
- {
278
- name: e.propertyId,
279
- checked: !!l,
280
- onChange: k,
281
- size: c
282
- }
283
- ),
284
- label: e.name
285
- }
286
- ) });
287
- if (e.type === "enum") {
288
- let n = [];
289
- 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(
290
- de,
291
- {
292
- fullWidth: !0,
293
- variant: s,
294
- sx: { mb: i ? 0 : 2 },
295
- size: c,
296
- required: e.required,
297
- children: [
298
- /* @__PURE__ */ a(ie, { id: `${e.propertyId}-label`, children: e.name }),
299
- /* @__PURE__ */ a(
300
- me,
301
- {
302
- label: e.name,
303
- name: e.name,
304
- labelId: `${e.propertyId}-label`,
305
- id: e.propertyId,
306
- value: l ?? "",
307
- onChange: A,
308
- inputProps: {
309
- ...o && o[e.propertyId] && {
310
- tabIndex: o[e.propertyId].order
311
- }
312
- },
313
- children: n.map((t, m) => /* @__PURE__ */ a(re, { value: t, children: t }, m))
314
- }
315
- )
316
- ]
317
- }
318
- );
319
- }
320
- return e.type === "geometry" ? /* @__PURE__ */ a(x, { sx: { mb: i ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ a(
321
- ne,
322
- {
323
- mapboxAccessToken: d,
324
- label: e.name,
325
- value: l ?? e.defaultValue ?? "",
326
- defaultExtent: f,
327
- variant: s,
328
- onChange: y(e.propertyId)
329
- }
330
- ) }) : e.type === "phone-number" ? /* @__PURE__ */ a(x, { sx: { mb: i ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ a(
331
- ae,
332
- {
333
- label: e.name,
334
- placeholder: "Enter phone number",
335
- value: l ?? e.defaultValue ?? "",
336
- onChange: D(e.propertyId)
337
- }
338
- ) }) : e.type === "composite-list" ? /* @__PURE__ */ a(x, { sx: { mb: i ? 0 : 2, width: "100%" }, children: /* @__PURE__ */ a(
339
- ce,
340
- {
341
- property: e,
342
- value: l ?? e.defaultValue ?? "",
343
- variant: s,
344
- size: c,
345
- mapboxAccessToken: d,
346
- onChange: F(e.propertyId)
347
- }
348
- ) }) : /* @__PURE__ */ a(p, {});
349
- }
350
- export {
351
- ce as C,
352
- ue as V
353
- };