@hybridcore/ui 1.5.5 → 1.5.8

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.
@@ -0,0 +1,349 @@
1
+ import { jsxs as h, Fragment as M, jsx as n } from "react/jsx-runtime";
2
+ import I from "lodash";
3
+ import q from "dayjs";
4
+ import { FormControl as B, FormLabel as N, FormGroup as W, FormControlLabel as j, Checkbox as Y, Typography as P, Button as F, Chip as $, Dialog as v, DialogTitle as _, DialogContent as E, DialogActions as G, InputAdornment as H, Tooltip as K } from "@mui/material";
5
+ import { Container as R, Values as U, MiniButton as J } from "./components/instance-form/components/composite-list/styled.js";
6
+ import { KeyboardArrowUp as Q, KeyboardArrowDown as X, Add as Z, LockOutlined as z } from "@mui/icons-material";
7
+ import O 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 ae } from "./components/date-time-picker/index.js";
11
+ import { T as p } from "./TextField-BjFXx91l.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-ush_fSWy.js";
16
+ import { M as re } from "./MenuItem-Lcjh1XlV.js";
17
+ import { B as L } from "./Box-SSMZuKnS.js";
18
+ import { useState as S } 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 d = O(!1), [m, T] = S(), [b, w] = S(!1), x = 10, A = (t) => {
29
+ T(I.get(t, i.propertyId));
30
+ }, y = () => {
31
+ g([...a || [], m]), T(""), d.action.close();
32
+ }, D = (t) => () => {
33
+ if (a) {
34
+ const o = [...a];
35
+ o.splice(t, 1), g(o);
36
+ }
37
+ }, k = (t) => {
38
+ const { value: o, checked: c } = t.target;
39
+ let s = I.isArray(a) ? a : [];
40
+ c ? s.push(o) : s = s.filter((f) => f !== o), 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(B, { fullWidth: !0, component: "fieldset", variant: u, children: [
46
+ /* @__PURE__ */ n(N, { component: "legend", sx: { mb: 1 }, children: i.name }),
47
+ /* @__PURE__ */ n(W, { children: t && t.length > 0 ? t.slice(0, b ? 9999 : x).map((o, c) => /* @__PURE__ */ n(
48
+ j,
49
+ {
50
+ label: o,
51
+ control: /* @__PURE__ */ n(
52
+ Y,
53
+ {
54
+ name: i.propertyId,
55
+ value: o,
56
+ size: "small",
57
+ checked: I.isArray(a) ? a.includes(o) : !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(Q, {}) : /* @__PURE__ */ n(X, {}),
76
+ onClick: () => w((o) => !o),
77
+ children: [
78
+ "Show ",
79
+ b ? "Less" : "More"
80
+ ]
81
+ }
82
+ )
83
+ ] });
84
+ }
85
+ return /* @__PURE__ */ h(M, { children: [
86
+ /* @__PURE__ */ h(R, { variant: u, children: [
87
+ /* @__PURE__ */ n(P, { children: i.name }),
88
+ /* @__PURE__ */ n(U, { children: I.isArray(a) && a.map((t, o) => {
89
+ var c, s;
90
+ return /* @__PURE__ */ n(
91
+ $,
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(o)
96
+ },
97
+ o
98
+ );
99
+ }) }),
100
+ /* @__PURE__ */ n(
101
+ J,
102
+ {
103
+ startIcon: /* @__PURE__ */ n(Z, {}),
104
+ variant: "text",
105
+ onClick: d.action.open,
106
+ children: "Add"
107
+ }
108
+ )
109
+ ] }),
110
+ /* @__PURE__ */ h(
111
+ v,
112
+ {
113
+ open: d.state.isOpen,
114
+ onClose: d.action.close,
115
+ maxWidth: "sm",
116
+ fullWidth: !0,
117
+ children: [
118
+ /* @__PURE__ */ n(_, { children: "Add List Value" }),
119
+ /* @__PURE__ */ n(E, { 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(G, { children: [
133
+ /* @__PURE__ */ n(
134
+ F,
135
+ {
136
+ variant: "contained",
137
+ color: "inherit",
138
+ onClick: d.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: d,
157
+ // keyAuth,
158
+ onChange: m
159
+ }) {
160
+ var k, C, V;
161
+ const T = (l) => {
162
+ const o = l.target.value.split(",").map((c) => c.trimStart());
163
+ m({
164
+ [e.propertyId]: o
165
+ });
166
+ }, b = (l) => {
167
+ const { name: t, type: o, 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]: o === "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 ([
194
+ "string",
195
+ "integer",
196
+ "double",
197
+ "text",
198
+ "long",
199
+ "byte",
200
+ "bank-account"
201
+ ].includes(e.type))
202
+ return /* @__PURE__ */ n(
203
+ p,
204
+ {
205
+ label: e.name,
206
+ name: e.propertyId,
207
+ required: e.required,
208
+ value: a ?? e.defaultValue ?? "",
209
+ defaultValue: a,
210
+ onChange: b,
211
+ variant: u,
212
+ type: "text",
213
+ multiline: e.type === "text",
214
+ disabled: !e.editable,
215
+ fullWidth: !0,
216
+ InputProps: {
217
+ size: r,
218
+ ...d && d[e.propertyId] && {
219
+ tabIndex: d[e.propertyId].order
220
+ },
221
+ ...e.privacyPreservationMethod === "ENCRYPTION" ? {
222
+ endAdornment: /* @__PURE__ */ n(H, { position: "end", children: /* @__PURE__ */ n(K, { title: "Encrypted Field", children: /* @__PURE__ */ n(z, {}) }) })
223
+ } : {}
224
+ }
225
+ }
226
+ );
227
+ if (e.type === "date") {
228
+ const l = a !== void 0 ? q(a).format() : a;
229
+ return /* @__PURE__ */ n(
230
+ ae,
231
+ {
232
+ label: e.name,
233
+ value: l,
234
+ variant: u,
235
+ size: r,
236
+ name: e.propertyId,
237
+ onChange: w,
238
+ ...d && d[e.propertyId] && {
239
+ minDate: d[e.propertyId].minDate
240
+ }
241
+ }
242
+ );
243
+ }
244
+ if (e.type === "list") {
245
+ let l = "";
246
+ return e.defaultValue && (l = I.isArray(e.defaultValue) ? a.join(", ") : e.defaultValue), a && (l = I.isArray(a) ? a.join(",") : a), /* @__PURE__ */ n(
247
+ p,
248
+ {
249
+ label: e.name,
250
+ name: e.propertyId,
251
+ value: l,
252
+ onChange: T,
253
+ variant: u,
254
+ disabled: !e.editable,
255
+ required: e.required,
256
+ fullWidth: !0,
257
+ helperText: r === "small" ? null : "Add list values with the comma (,) separated string",
258
+ InputProps: {
259
+ size: r,
260
+ placeholder: r === "small" ? "Add list values with the comma (,) separated string" : "",
261
+ ...d && d[e.propertyId] && {
262
+ tabIndex: d[e.propertyId].order
263
+ }
264
+ }
265
+ }
266
+ );
267
+ }
268
+ if (e.type === "boolean")
269
+ return /* @__PURE__ */ n(
270
+ le,
271
+ {
272
+ control: /* @__PURE__ */ n(
273
+ te,
274
+ {
275
+ name: e.propertyId,
276
+ checked: !!a,
277
+ onChange: b,
278
+ size: r
279
+ }
280
+ ),
281
+ label: e.name
282
+ }
283
+ );
284
+ if (e.type === "enum") {
285
+ let l = [];
286
+ 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(
287
+ oe,
288
+ {
289
+ fullWidth: !0,
290
+ variant: u,
291
+ size: r,
292
+ required: e.required,
293
+ children: [
294
+ /* @__PURE__ */ n(de, { id: `${e.propertyId}-label`, children: e.name }),
295
+ /* @__PURE__ */ n(
296
+ ie,
297
+ {
298
+ label: e.name,
299
+ name: e.name,
300
+ labelId: `${e.propertyId}-label`,
301
+ id: e.propertyId,
302
+ value: a ?? "",
303
+ onChange: x,
304
+ inputProps: {
305
+ ...d && d[e.propertyId] && {
306
+ tabIndex: d[e.propertyId].order
307
+ }
308
+ },
309
+ children: l.map((t, o) => /* @__PURE__ */ n(re, { value: t, children: t }, o))
310
+ }
311
+ )
312
+ ]
313
+ }
314
+ );
315
+ }
316
+ return e.type === "geometry" ? /* @__PURE__ */ n(L, { sx: { width: "100%" }, children: /* @__PURE__ */ n(
317
+ ee,
318
+ {
319
+ mapboxAccessToken: i,
320
+ label: e.name,
321
+ value: a ?? e.defaultValue ?? "",
322
+ defaultExtent: g,
323
+ variant: u,
324
+ onChange: A(e.propertyId)
325
+ }
326
+ ) }) : e.type === "phone-number" ? /* @__PURE__ */ n(L, { sx: { width: "100%" }, children: /* @__PURE__ */ n(
327
+ ne,
328
+ {
329
+ label: e.name,
330
+ placeholder: "Enter phone number",
331
+ value: a ?? e.defaultValue ?? "",
332
+ onChange: y(e.propertyId)
333
+ }
334
+ ) }) : e.type === "composite-list" ? /* @__PURE__ */ n(L, { sx: { width: "100%" }, children: /* @__PURE__ */ n(
335
+ me,
336
+ {
337
+ property: e,
338
+ value: a ?? e.defaultValue ?? "",
339
+ variant: u,
340
+ size: r,
341
+ mapboxAccessToken: i,
342
+ onChange: D(e.propertyId)
343
+ }
344
+ ) }) : /* @__PURE__ */ n(M, {});
345
+ }
346
+ export {
347
+ me as C,
348
+ ce as V
349
+ };
package/dist/main.d.ts CHANGED
@@ -228,6 +228,7 @@ declare interface FieldOptions {
228
228
  hidden?: boolean;
229
229
  disabled?: boolean;
230
230
  minDate?: Dayjs;
231
+ helperText?: React.ReactNode;
231
232
  [key: string]: string | number | object | boolean;
232
233
  }
233
234
 
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.5",
4
+ "version": "1.5.8",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",