react-crud-mobile 1.3.413 → 1.3.503

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.
Files changed (57) hide show
  1. package/dist/index.d.mts +58 -0
  2. package/dist/index.d.ts +58 -1
  3. package/dist/index.js +2531 -5
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +2556 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +75 -75
  8. package/src/elements/core/UIAutoComplete.tsx +17 -17
  9. package/src/elements/core/UILink.tsx +17 -17
  10. package/src/elements/core/UIListItem.tsx +32 -32
  11. package/src/elements/core/UIListRow.tsx +2 -1
  12. package/src/elements/core/UIOption.tsx +17 -17
  13. package/src/elements/core/UIRadio.tsx +17 -17
  14. package/src/elements/core/UISlider.tsx +61 -61
  15. package/src/elements/core/UIStatusBar.tsx +5 -5
  16. package/src/elements/core/UISwitch.tsx +27 -27
  17. package/src/hooks/useIsVisible.ts +39 -39
  18. package/src/utils/MobileUtils.ts +13 -13
  19. package/dist/elements/UI.d.ts +0 -49
  20. package/dist/elements/UIChildren.d.ts +0 -15
  21. package/dist/elements/UIComplete.d.ts +0 -3
  22. package/dist/elements/UIElement.d.ts +0 -3
  23. package/dist/elements/UITag.d.ts +0 -7
  24. package/dist/elements/charts/ElChart.d.ts +0 -3
  25. package/dist/elements/core/SafeView.d.ts +0 -9
  26. package/dist/elements/core/UIAutoComplete.d.ts +0 -2
  27. package/dist/elements/core/UIButton.d.ts +0 -3
  28. package/dist/elements/core/UIHeader.d.ts +0 -3
  29. package/dist/elements/core/UIIcon.d.ts +0 -3
  30. package/dist/elements/core/UIInclude.d.ts +0 -3
  31. package/dist/elements/core/UIInput.d.ts +0 -3
  32. package/dist/elements/core/UILink.d.ts +0 -2
  33. package/dist/elements/core/UIList.d.ts +0 -3
  34. package/dist/elements/core/UIListItem.d.ts +0 -7
  35. package/dist/elements/core/UIListRow.d.ts +0 -8
  36. package/dist/elements/core/UIModal.d.ts +0 -8
  37. package/dist/elements/core/UIOption.d.ts +0 -2
  38. package/dist/elements/core/UIOrder.d.ts +0 -3
  39. package/dist/elements/core/UIQuantity.d.ts +0 -3
  40. package/dist/elements/core/UIRadio.d.ts +0 -2
  41. package/dist/elements/core/UISelect.d.ts +0 -3
  42. package/dist/elements/core/UISlider.d.ts +0 -3
  43. package/dist/elements/core/UIStatusBar.d.ts +0 -2
  44. package/dist/elements/core/UISwitch.d.ts +0 -3
  45. package/dist/elements/core/UIToast.d.ts +0 -2
  46. package/dist/elements/core/UIToggle.d.ts +0 -3
  47. package/dist/elements/core/UIView.d.ts +0 -3
  48. package/dist/elements/index.d.ts +0 -1
  49. package/dist/elements/tabs/ElTabs.d.ts +0 -3
  50. package/dist/hooks/useIsVisible.d.ts +0 -2
  51. package/dist/react-crud-mobile.cjs.development.js +0 -2906
  52. package/dist/react-crud-mobile.cjs.development.js.map +0 -1
  53. package/dist/react-crud-mobile.cjs.production.min.js +0 -2
  54. package/dist/react-crud-mobile.cjs.production.min.js.map +0 -1
  55. package/dist/react-crud-mobile.esm.js +0 -2898
  56. package/dist/react-crud-mobile.esm.js.map +0 -1
  57. package/dist/utils/MobileUtils.d.ts +0 -3
package/dist/index.mjs ADDED
@@ -0,0 +1,2556 @@
1
+ // src/elements/UIElement.tsx
2
+ import React9, {
3
+ createContext,
4
+ useContext,
5
+ useEffect as useEffect4,
6
+ useLayoutEffect,
7
+ useRef as useRef6,
8
+ useState as useState14
9
+ } from "react";
10
+
11
+ // src/elements/UIChildren.tsx
12
+ import React2, { useState } from "react";
13
+ import { ScopeUtils, Utils } from "react-crud-utils";
14
+ import { StyleSheet, View } from "react-native";
15
+ function UIChildren(props) {
16
+ let [scope] = useState(Utils.nvl(props.scope, ScopeUtils.create(props)));
17
+ let crud = Utils.nvl(props.crud, scope.crud);
18
+ let validateScope = Utils.nvl(props.validateScope, "global");
19
+ let name = Utils.nvl(props.part, "child");
20
+ if (scope.isInput()) {
21
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null);
22
+ }
23
+ let Paint = ({ child }) => {
24
+ if (!child) {
25
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null);
26
+ }
27
+ if (typeof child === "string") {
28
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, child);
29
+ }
30
+ let Custom = child.type;
31
+ let pps = { ...child.props };
32
+ delete pps.children;
33
+ if (typeof Custom === "string") {
34
+ if (Utils.isEmpty(child.props.children)) {
35
+ return /* @__PURE__ */ React2.createElement(Custom, { ...pps });
36
+ }
37
+ return /* @__PURE__ */ React2.createElement(Custom, { ...pps }, /* @__PURE__ */ React2.createElement(
38
+ UIChildren,
39
+ {
40
+ transient: true,
41
+ validateScope,
42
+ ...child.props,
43
+ scope,
44
+ crud
45
+ }
46
+ ));
47
+ } else if (typeof Custom === "function") {
48
+ return /* @__PURE__ */ React2.createElement(
49
+ Custom,
50
+ {
51
+ validateScope,
52
+ ...child.props,
53
+ parent: scope,
54
+ crud
55
+ }
56
+ );
57
+ }
58
+ if (!Utils.isEmpty(child.props?.children)) {
59
+ return /* @__PURE__ */ React2.createElement(
60
+ UIChildren,
61
+ {
62
+ validateScope,
63
+ ...child.props,
64
+ scope,
65
+ crud,
66
+ transient: true
67
+ }
68
+ );
69
+ }
70
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null);
71
+ };
72
+ const Draw = () => {
73
+ if (props.elements) {
74
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, Object.entries(props.elements).map((t, k) => {
75
+ return /* @__PURE__ */ React2.createElement(UIElement, { crud, ...t[1] });
76
+ }));
77
+ }
78
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, React2.Children.map(props.children, (child) => {
79
+ return /* @__PURE__ */ React2.createElement(Paint, { child });
80
+ }));
81
+ };
82
+ if (props.transient) {
83
+ return /* @__PURE__ */ React2.createElement(Draw, null);
84
+ }
85
+ if (Utils.isEmpty(props.children) && Utils.isEmpty(props.elements)) {
86
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null);
87
+ }
88
+ const getStyle = (part) => {
89
+ let key = Utils.nvl(part, "root");
90
+ let def = styles[key];
91
+ let css = {};
92
+ if (!Utils.isEmpty(props.style)) {
93
+ if (props.style?.push) {
94
+ Utils.each(props.style, (s) => {
95
+ if (s) {
96
+ css = { ...css, ...s };
97
+ }
98
+ });
99
+ } else {
100
+ css = { ...props.style };
101
+ }
102
+ }
103
+ return { ...def, ...css, ...scope.getStyle(part) };
104
+ };
105
+ if (props.transient) {
106
+ return /* @__PURE__ */ React2.createElement(Draw, null);
107
+ }
108
+ return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(View, { style: getStyle(name) }, /* @__PURE__ */ React2.createElement(Draw, null)));
109
+ }
110
+ var styles = StyleSheet.create({
111
+ child: { width: "100%" },
112
+ inner: { width: "100%" }
113
+ });
114
+
115
+ // src/elements/tabs/ElTabs.tsx
116
+ import React3, { useState as useState2 } from "react";
117
+ import Ionicons from "@expo/vector-icons/Ionicons";
118
+ import { CrudUtils, Utils as Utils2 } from "react-crud-utils";
119
+ function ElTabs(props) {
120
+ let scope = props.scope;
121
+ let [selectedIndex, setSelectedIndex] = useState2(0);
122
+ let element = scope.original;
123
+ let items = scope.getItems();
124
+ let counter = 0;
125
+ let tabs = [];
126
+ let [selected, setSelected] = useState2(null);
127
+ const onChangeTab = (tab, validate = true) => {
128
+ if (tab) {
129
+ scope.execute({
130
+ event: {
131
+ validate,
132
+ validateScope: element.validateScope,
133
+ action: () => {
134
+ scope.changeValue(tab.data);
135
+ selected = tab;
136
+ selectedIndex = tab.index;
137
+ setSelectedIndex(selectedIndex);
138
+ setSelected(tab);
139
+ }
140
+ }
141
+ });
142
+ }
143
+ };
144
+ const getStyleClass = (t) => {
145
+ let s = "ui-tabs-item ui-click";
146
+ if (selected?.index === t.index) {
147
+ s = s + " ui-tab-selected";
148
+ }
149
+ return s;
150
+ };
151
+ const addTab = (child, item) => {
152
+ let original = { ...child.props };
153
+ if (!item) {
154
+ item = scope.crud.data;
155
+ }
156
+ let crudTab = CrudUtils.create("tabs", {
157
+ data: item,
158
+ changed: item,
159
+ parent: scope.crud
160
+ });
161
+ let element2 = Utils2.resolve(original, crudTab);
162
+ if (element2.rendered === false) {
163
+ return;
164
+ }
165
+ tabs.push({
166
+ ...element2,
167
+ child,
168
+ element: element2,
169
+ original,
170
+ index: counter++,
171
+ data: item
172
+ });
173
+ };
174
+ React3.Children.map(props.children, (child, index) => {
175
+ if (Utils2.isEmpty(items)) {
176
+ addTab(child, {});
177
+ } else {
178
+ for (const i in items) {
179
+ let o = items[i];
180
+ addTab(child, o);
181
+ }
182
+ }
183
+ });
184
+ if (!selected) {
185
+ onChangeTab(tabs[selectedIndex], false);
186
+ }
187
+ const nav = (i) => {
188
+ let t = tabs[selectedIndex + i];
189
+ onChangeTab(t);
190
+ };
191
+ const previous = () => {
192
+ nav(-1);
193
+ };
194
+ const next = () => {
195
+ nav(1);
196
+ };
197
+ let isStepper = element.layout === "stepper";
198
+ return /* @__PURE__ */ React3.createElement(
199
+ "div",
200
+ {
201
+ className: scope.getStyleClass("inner"),
202
+ style: scope.getStyle("inner")
203
+ },
204
+ /* @__PURE__ */ React3.createElement("div", { className: "ui-tabs-content" }, /* @__PURE__ */ React3.createElement("div", { className: "ui-tabs-items" }, tabs.map((t, i) => /* @__PURE__ */ React3.createElement(
205
+ "div",
206
+ {
207
+ key: Utils2.key(element.id, "tab", i),
208
+ className: getStyleClass(t),
209
+ onClick: () => {
210
+ onChangeTab(t);
211
+ }
212
+ },
213
+ isStepper && /* @__PURE__ */ React3.createElement("div", { className: "ui-tab-item-divisor" }),
214
+ /* @__PURE__ */ React3.createElement("div", { className: "ui-tab-item-inner" }, isStepper && /* @__PURE__ */ React3.createElement("div", { className: "ui-step-line" }), /* @__PURE__ */ React3.createElement("div", { className: "ui-tab-item-label" }, isStepper ? t.index + 1 : t.label))
215
+ ))), selected && /* @__PURE__ */ React3.createElement(React3.Fragment, null, isStepper && /* @__PURE__ */ React3.createElement("div", { className: "ui-tabs-label" }, selected.label), /* @__PURE__ */ React3.createElement("div", { className: "ui-tabs-area" }, /* @__PURE__ */ React3.createElement(UIChildren, { ...props, scope }, selected.child)), element.layout === "stepper" && /* @__PURE__ */ React3.createElement("div", { className: "ui-tabs-actions" }, /* @__PURE__ */ React3.createElement(UI_default.Output, { space: 6, layout: "left" }, /* @__PURE__ */ React3.createElement(
216
+ UI_default.Include,
217
+ {
218
+ ...props,
219
+ transient: true,
220
+ name: "left",
221
+ default: /* @__PURE__ */ React3.createElement(
222
+ UI_default.Button,
223
+ {
224
+ rendered: selectedIndex > 0,
225
+ icon: /* @__PURE__ */ React3.createElement(Ionicons, null),
226
+ click: previous
227
+ }
228
+ )
229
+ }
230
+ )), /* @__PURE__ */ React3.createElement(UI_default.Output, { space: 6, layout: "right" }, /* @__PURE__ */ React3.createElement(
231
+ UI_default.Include,
232
+ {
233
+ ...props,
234
+ transient: true,
235
+ name: "right",
236
+ default: /* @__PURE__ */ React3.createElement(
237
+ UI_default.Button,
238
+ {
239
+ rendered: selectedIndex < tabs.length - 1,
240
+ icon: /* @__PURE__ */ React3.createElement(Ionicons, null),
241
+ click: next
242
+ }
243
+ )
244
+ }
245
+ )))))
246
+ );
247
+ }
248
+
249
+ // src/elements/charts/ElChart.tsx
250
+ import React4 from "react";
251
+ import { Utils as Utils3 } from "react-crud-utils";
252
+ function ElChart(props) {
253
+ let scope = props.scope;
254
+ let items = scope.getItems();
255
+ let columns = Utils3.asList(scope.original.columns);
256
+ return /* @__PURE__ */ React4.createElement("div", { className: "ui-chart-data" });
257
+ }
258
+
259
+ // src/elements/core/UIAutoComplete.tsx
260
+ import { Text, TouchableOpacity, Linking } from "react-native";
261
+ function UIAutoComplete(props) {
262
+ const handlePress = () => {
263
+ Linking.openURL("https://reactnative.dev/");
264
+ };
265
+ return /* @__PURE__ */ React.createElement(TouchableOpacity, { onPress: handlePress }, /* @__PURE__ */ React.createElement(Text, { style: styles2.link }, "Clique aqui para acessar o React Native"));
266
+ }
267
+ var styles2 = {
268
+ link: {}
269
+ };
270
+
271
+ // src/elements/UIComplete.tsx
272
+ function UIComplete({
273
+ defaultsInput,
274
+ defaultsUI,
275
+ scope
276
+ }) {
277
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(UIAutoComplete, { ...defaultsInput, ...defaultsUI }));
278
+ }
279
+
280
+ // src/elements/UIElement.tsx
281
+ import {
282
+ HtmlUtils as HtmlUtils2,
283
+ ScopeUtils as ScopeUtils3,
284
+ Utils as Utils18,
285
+ ComponentUtils as ComponentUtils5,
286
+ CrudUtils as CrudUtils2,
287
+ ViewUtils as ViewUtils3
288
+ } from "react-crud-utils";
289
+
290
+ // src/elements/core/UILink.tsx
291
+ import { Text as Text2, TouchableOpacity as TouchableOpacity2, Linking as Linking2 } from "react-native";
292
+ function UILink(props) {
293
+ const handlePress = () => {
294
+ Linking2.openURL("https://reactnative.dev/");
295
+ };
296
+ return /* @__PURE__ */ React.createElement(TouchableOpacity2, { onPress: handlePress }, /* @__PURE__ */ React.createElement(Text2, { style: styles3.link }, "Clique aqui para acessar o React Native"));
297
+ }
298
+ var styles3 = {
299
+ link: {}
300
+ };
301
+
302
+ // src/elements/core/UIIcon.tsx
303
+ import {
304
+ Ionicons as Ionicons2,
305
+ MaterialCommunityIcons,
306
+ AntDesign,
307
+ Entypo,
308
+ EvilIcons
309
+ } from "@expo/vector-icons";
310
+ import { Utils as Utils4 } from "react-crud-utils";
311
+ function UIIcon({ scope }) {
312
+ let name = scope.getValue();
313
+ let libs = {
314
+ ion: Ionicons2,
315
+ ant: AntDesign,
316
+ entypo: Entypo,
317
+ evil: EvilIcons,
318
+ material: MaterialCommunityIcons
319
+ };
320
+ let library = Utils4.nvl(scope.original.library, "ion");
321
+ let Aux = libs[library];
322
+ let css = scope.getStyle("icon");
323
+ let fontSize = scope.part("size", 20);
324
+ let size = scope.part("iconSize", fontSize);
325
+ if (scope.original?.transient) {
326
+ css = { ...css, ...scope.getStyle() };
327
+ }
328
+ return /* @__PURE__ */ React.createElement(Aux, { size, name, style: css });
329
+ }
330
+
331
+ // src/elements/core/UIButton.tsx
332
+ import { Utils as Utils5 } from "react-crud-utils";
333
+ import { Text as Text3, TouchableHighlight } from "react-native";
334
+ var BUTTONS_SIZE = { small: { minWidth: 30, height: 30 } };
335
+ function UIButton(props) {
336
+ let scope = props.scope;
337
+ let element = scope.original;
338
+ let size = Utils5.nvl(element.size, "default");
339
+ let align = Utils5.nvl(element.align, "center");
340
+ let variant = Utils5.nvl(element.variant, "default");
341
+ let color = element.color;
342
+ let label = scope.getLabel();
343
+ let icon = scope.getPart("icon");
344
+ if (!color) color = "primaryLight";
345
+ const styles13 = {
346
+ buttonLabel: {
347
+ color: "#ffffff",
348
+ fontWeight: 400,
349
+ fontSize: 15
350
+ },
351
+ buttonInner: {
352
+ flexDirection: "row",
353
+ alignItems: "center",
354
+ justifyContent: "center",
355
+ height: 44,
356
+ minWidth: 44
357
+ },
358
+ buttonIcon: {
359
+ color: "#fff",
360
+ fontSize: 16
361
+ },
362
+ button: {
363
+ backgroundColor: color,
364
+ borderRadius: 20,
365
+ gap: 10,
366
+ justifyContent: "center",
367
+ alignItems: "center",
368
+ flexDirection: "row"
369
+ }
370
+ };
371
+ const onClick = (e) => {
372
+ scope.call("click", {});
373
+ };
374
+ const style = (part, extra2) => {
375
+ let css = { ...styles13[part], ...extra2 };
376
+ if (variant === "text" || variant === "outlined") {
377
+ css.backgroundColor = "transparent";
378
+ css.color = Utils5.nvl(color, "text");
379
+ }
380
+ if (size === "small") {
381
+ css.fontSize = 12;
382
+ css.fontWeight = 500;
383
+ }
384
+ if (size === "medium") {
385
+ css.fontSize = 14;
386
+ css.fontWeight = 500;
387
+ }
388
+ if (align === "left") {
389
+ css.justifyContent = "flex-start";
390
+ }
391
+ return scope.getStyle(part, css);
392
+ };
393
+ let extra = {};
394
+ if (icon) {
395
+ extra.button = { height: 40, padding: 0 };
396
+ } else {
397
+ extra.button = { height: 50 };
398
+ }
399
+ const buttonStyle = Utils5.call(() => {
400
+ let def = { ...extra?.button };
401
+ if (variant === "outlined") {
402
+ def.borderWidth = 1;
403
+ def.borderColor = Utils5.nvl(color, "text");
404
+ }
405
+ if (size) {
406
+ def = { ...def, ...BUTTONS_SIZE[size] };
407
+ }
408
+ if (!label) {
409
+ def = { ...def, borderRadius: 20 };
410
+ }
411
+ let css = style("button", def);
412
+ if (!css.width) {
413
+ let h = css.height;
414
+ if (typeof h === "number") {
415
+ css.minWidth = h;
416
+ }
417
+ }
418
+ return css;
419
+ });
420
+ const buttonLabel = style("buttonLabel");
421
+ const iconStyle = Utils5.call(() => {
422
+ let css = style("buttonIcon", extra.icon);
423
+ css.fontSize = Utils5.nvl(buttonLabel.fontSize, css.fontSize);
424
+ return css;
425
+ });
426
+ return /* @__PURE__ */ React.createElement(
427
+ TouchableHighlight,
428
+ {
429
+ underlayColor: "transparent",
430
+ onPress: onClick,
431
+ style: buttonStyle
432
+ },
433
+ /* @__PURE__ */ React.createElement(React.Fragment, null, icon && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
434
+ UI_default.Icon,
435
+ {
436
+ size: Utils5.nvl(element.iconSize, 30),
437
+ style: iconStyle,
438
+ value: icon
439
+ }
440
+ )), label && /* @__PURE__ */ React.createElement(Text3, { style: buttonLabel }, label))
441
+ );
442
+ }
443
+
444
+ // src/elements/core/UISelect.tsx
445
+ import { useRef, useState as useState3 } from "react";
446
+ import { Utils as Utils6 } from "react-crud-utils";
447
+ import {
448
+ Text as Text4,
449
+ TouchableOpacity as TouchableOpacity3,
450
+ StyleSheet as StyleSheet4,
451
+ Modal,
452
+ View as View3,
453
+ ScrollView
454
+ } from "react-native";
455
+ import { Ionicons as Ionicons3 } from "@expo/vector-icons";
456
+ import { SafeAreaView } from "react-native-safe-area-context";
457
+ function UISelect(props) {
458
+ const [modalVisible, setModalVisible] = useState3(false);
459
+ const scope = props.scope;
460
+ const original = scope.original;
461
+ const items = Utils6.nvl(scope.getOptions(), []);
462
+ const placeholder = scope.attr("placeholder", "Selecione...");
463
+ const value = scope.getDisplayValue();
464
+ const theme = scope.getTheme();
465
+ const headerStyle = Utils6.nvl(theme.styles?.defaults?.header, {});
466
+ const handlePress = () => {
467
+ setModalVisible(!modalVisible);
468
+ };
469
+ const scrollRef = useRef(null);
470
+ const iconColor = Utils6.nvl(theme.colors?.text, "#100e0e");
471
+ const modalColor = Utils6.nvl(headerStyle.color, "white");
472
+ const defaults = { color: modalColor };
473
+ const onClick = ({ crud, value: value2 }) => {
474
+ let val = value2;
475
+ if (original.isObject && val?.object) {
476
+ scope.changeValue(val?.object);
477
+ } else if (val?.value) {
478
+ scope.changeValue(val?.value);
479
+ } else {
480
+ scope.changeValue(value2);
481
+ }
482
+ setModalVisible(false);
483
+ };
484
+ const style = (part, extra) => {
485
+ let all = { ...styles4[part], ...extra };
486
+ return scope.getStyle(part, all);
487
+ };
488
+ const isModalVisible = () => {
489
+ return modalVisible;
490
+ };
491
+ const getLabelStyle = () => {
492
+ const css = style("selectLabel");
493
+ let fs = parseInt(css.fontSize);
494
+ if (!fs) {
495
+ fs = 14;
496
+ }
497
+ let lh = Utils6.nvl(css.lineHeight, fs + 2);
498
+ css.fontSize = fs;
499
+ css.lineHeight = lh;
500
+ return css;
501
+ };
502
+ const labelStyle = getLabelStyle();
503
+ const defIconSize = Utils6.nvl(labelStyle.fontSize, 14) + 2;
504
+ const iconSize = scope.getPart("iconSize", null, defIconSize);
505
+ return /* @__PURE__ */ React.createElement(
506
+ View3,
507
+ {
508
+ key: scope.getName(`${scope.getPart("modal")}_${modalVisible}`),
509
+ style: style("selectRoot")
510
+ },
511
+ /* @__PURE__ */ React.createElement(TouchableOpacity3, { onPress: handlePress, style: style("selectInput") }, /* @__PURE__ */ React.createElement(Text4, { style: labelStyle }, Utils6.nvl(value, placeholder)), /* @__PURE__ */ React.createElement(
512
+ Ionicons3,
513
+ {
514
+ name: "chevron-down-outline",
515
+ size: iconSize,
516
+ color: scope.getPart("iconColor", null, iconColor),
517
+ style: style("iconStyle", {})
518
+ }
519
+ )),
520
+ /* @__PURE__ */ React.createElement(
521
+ Modal,
522
+ {
523
+ animationType: "slide",
524
+ transparent: true,
525
+ visible: isModalVisible(),
526
+ onRequestClose: () => setModalVisible(false)
527
+ },
528
+ /* @__PURE__ */ React.createElement(SafeAreaView, { style: style("modalTop") }),
529
+ /* @__PURE__ */ React.createElement(SafeAreaView, { style: style("modalSafe") }, /* @__PURE__ */ React.createElement(View3, { style: scope.getStyle("header", headerStyle) }, /* @__PURE__ */ React.createElement(
530
+ TouchableOpacity3,
531
+ {
532
+ onPress: handlePress,
533
+ style: style("modalCloseButton")
534
+ },
535
+ /* @__PURE__ */ React.createElement(
536
+ Ionicons3,
537
+ {
538
+ name: "close",
539
+ size: 24,
540
+ color: modalColor,
541
+ style: style("modalCloseText", defaults)
542
+ }
543
+ )
544
+ ), /* @__PURE__ */ React.createElement(Text4, { style: style("modalTitle", defaults) }, placeholder)), /* @__PURE__ */ React.createElement(
545
+ ScrollView,
546
+ {
547
+ contentContainerStyle: { flexGrow: 1, paddingBottom: 50 },
548
+ style: style("modalContent"),
549
+ nestedScrollEnabled: true,
550
+ ref: scrollRef
551
+ },
552
+ /* @__PURE__ */ React.createElement(
553
+ View3,
554
+ {
555
+ style: {
556
+ flex: 1,
557
+ paddingLeft: 15,
558
+ paddingRight: 15,
559
+ paddingTop: 10,
560
+ paddingBottom: 10
561
+ }
562
+ },
563
+ /* @__PURE__ */ React.createElement(
564
+ UI_default.List,
565
+ {
566
+ data: items,
567
+ name: scope.getName("list"),
568
+ layout: "card",
569
+ search: original.search === true,
570
+ click: onClick,
571
+ rowStyle: {
572
+ paddingLeft: 15,
573
+ paddinRight: 15,
574
+ ...original?.rowStyle
575
+ },
576
+ ...original?.listProps
577
+ },
578
+ /* @__PURE__ */ React.createElement(UI_default.Value, { value: "#{@this.label}" })
579
+ )
580
+ )
581
+ ))
582
+ )
583
+ );
584
+ }
585
+ var styles4 = StyleSheet4.create({
586
+ selectRoot: {
587
+ justifyContent: "flex-start",
588
+ alignItems: "flex-start",
589
+ flex: 1
590
+ },
591
+ selectInput: {
592
+ width: "100%",
593
+ flexDirection: "row",
594
+ borderRadius: 5,
595
+ paddingHorizontal: 15,
596
+ borderWidth: 1,
597
+ borderStyle: "solid",
598
+ borderColor: "#dedede",
599
+ paddingVertical: 10
600
+ },
601
+ selectLabel: { flex: 1, fontSize: 14 },
602
+ modalTop: {
603
+ backgroundColor: "primary",
604
+ width: "100%"
605
+ },
606
+ modalSafe: {
607
+ flex: 1,
608
+ width: "100%",
609
+ backgroundColor: "background"
610
+ },
611
+ modalCloseButton: {
612
+ padding: 10
613
+ },
614
+ modalCloseText: {
615
+ fontSize: 18,
616
+ color: "white"
617
+ },
618
+ modalTitle: {
619
+ fontSize: 18,
620
+ fontWeight: "bold",
621
+ marginLeft: 10
622
+ },
623
+ modalContent: {
624
+ flex: 1,
625
+ backgroundColor: "background"
626
+ }
627
+ });
628
+
629
+ // src/elements/core/UISwitch.tsx
630
+ import { useState as useState4 } from "react";
631
+ import { Utils as Utils7 } from "react-crud-utils";
632
+ import { Switch } from "react-native";
633
+ function UISwitch(props) {
634
+ const scope = props.scope;
635
+ const initial = Utils7.nvl(scope.getValue(), false);
636
+ const [value, setValue] = useState4(initial);
637
+ let onChange = (v) => {
638
+ scope.changeValue(v);
639
+ setValue(v);
640
+ };
641
+ return /* @__PURE__ */ React.createElement(
642
+ Switch,
643
+ {
644
+ value,
645
+ style: scope.getStyle("element"),
646
+ onValueChange: onChange
647
+ }
648
+ );
649
+ }
650
+
651
+ // src/elements/core/UISlider.tsx
652
+ import { useState as useState5 } from "react";
653
+ import { ComponentUtils, Utils as Utils8 } from "react-crud-utils";
654
+ import Slider from "@react-native-community/slider";
655
+ function UISlider(props) {
656
+ const scope = props.scope;
657
+ const initial = Utils8.nvl(scope.getValue(), 0);
658
+ const [value, setValue] = useState5(initial);
659
+ let onChange = (v) => {
660
+ v = Utils8.nvl(v, 0);
661
+ console.log(v);
662
+ scope.changeValue(v);
663
+ setValue(v);
664
+ };
665
+ let step = scope.attr("step", 1);
666
+ let min = scope.attr("min", 0);
667
+ let max = scope.attr("min", 100);
668
+ let onSlideScroll = (scrollEnabled) => {
669
+ let viewScope = ComponentUtils.getViewScope();
670
+ if (scope.original.debug) {
671
+ console.log(viewScope);
672
+ }
673
+ if (viewScope) {
674
+ let scrollRef = viewScope.get("scrollRef");
675
+ if (scrollRef) scrollRef.current?.setNativeProps?.({ scrollEnabled });
676
+ }
677
+ };
678
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
679
+ Slider,
680
+ {
681
+ minimumValue: min,
682
+ maximumValue: max,
683
+ step,
684
+ minimumTrackTintColor: "#1EB1FC",
685
+ maximumTrackTintColor: "#d3d3d3",
686
+ thumbTintColor: "#1EB1FC",
687
+ value,
688
+ onSlidingStart: () => onSlideScroll(false),
689
+ onSlidingComplete: () => onSlideScroll(true),
690
+ style: { width: "100%", height: 40, ...scope.getStyle("element") },
691
+ onValueChange: onChange
692
+ }
693
+ ));
694
+ }
695
+
696
+ // src/elements/core/UIOption.tsx
697
+ import { Text as Text5, TouchableOpacity as TouchableOpacity4, Linking as Linking3 } from "react-native";
698
+ function UIOption(props) {
699
+ const handlePress = () => {
700
+ Linking3.openURL("https://reactnative.dev/");
701
+ };
702
+ return /* @__PURE__ */ React.createElement(TouchableOpacity4, { onPress: handlePress }, /* @__PURE__ */ React.createElement(Text5, { style: styles5.link }, "Clique aqui para acessar o React Native"));
703
+ }
704
+ var styles5 = {
705
+ link: {}
706
+ };
707
+
708
+ // src/elements/core/UIRadio.tsx
709
+ import { Text as Text6, TouchableOpacity as TouchableOpacity5, Linking as Linking4 } from "react-native";
710
+ function UIRadio(props) {
711
+ const handlePress = () => {
712
+ Linking4.openURL("https://reactnative.dev/");
713
+ };
714
+ return /* @__PURE__ */ React.createElement(TouchableOpacity5, { onPress: handlePress }, /* @__PURE__ */ React.createElement(Text6, { style: styles6.link }, "Clique aqui para acessar o React Native"));
715
+ }
716
+ var styles6 = {
717
+ link: {}
718
+ };
719
+
720
+ // src/elements/core/UIInput.tsx
721
+ import { useState as useState6 } from "react";
722
+ import { Utils as Utils9 } from "react-crud-utils";
723
+ import { StyleSheet as StyleSheet7, TextInput, View as View4 } from "react-native";
724
+ import { Ionicons as Ionicons4 } from "@expo/vector-icons";
725
+ function UIInput(props) {
726
+ let scope = props.scope;
727
+ let initial = Utils9.call(() => {
728
+ let val = Utils9.nvl(scope.getValue(), "");
729
+ if (val && val?.push) {
730
+ return val.join(", ").trim();
731
+ }
732
+ return val;
733
+ });
734
+ let label = scope.getLabel();
735
+ let placeholder = scope.getPart("placeholder", null, label);
736
+ let el = scope.original;
737
+ const element = scope.original;
738
+ const [height, setHeight] = useState6(80);
739
+ const [value, setValue] = useState6(initial);
740
+ let onChange = (v) => {
741
+ v = scope.changeValue(v);
742
+ setValue(v);
743
+ };
744
+ const style = (part, extra) => {
745
+ return { ...scope.getStyle(part, { ...styles7[part], ...extra }) };
746
+ };
747
+ const CustomIcon = () => {
748
+ let icon = el.icon;
749
+ if (icon) {
750
+ if (typeof icon === "string") {
751
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, el.icon && /* @__PURE__ */ React.createElement(
752
+ Ionicons4,
753
+ {
754
+ name: el.icon,
755
+ size: scope.attr("iconSize", 20),
756
+ color: scope.attr("iconColor", "#888")
757
+ }
758
+ ));
759
+ }
760
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, icon);
761
+ }
762
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
763
+ };
764
+ let type = scope.getPart("type", null, "text");
765
+ let decode = {
766
+ textarea: {
767
+ multiline: true,
768
+ autoHeight: element.autoHeight !== false,
769
+ textAlignVertical: "top",
770
+ numberOfLines: 5,
771
+ style: { height: Math.max(80, height) },
772
+ baseStyle: { paddingVertical: 10 }
773
+ }
774
+ };
775
+ let defs = { ...Utils9.nvl(decode[type], {}), ...element.inputProps };
776
+ let inputStyle = Utils9.call(() => {
777
+ let size = element.size;
778
+ let css = {};
779
+ if (size === "small") {
780
+ css.height = 30;
781
+ css.fontSize = 12;
782
+ }
783
+ css.fontSize = Utils9.nvl(element.fontSize, css.fontSize);
784
+ css = { ...style("input"), ...style(type, css) };
785
+ css.lineHeight = parseInt(css.fontSize) + 2;
786
+ return css;
787
+ });
788
+ if (defs.autoHeight) {
789
+ defs.onContentSizeChange = (event) => {
790
+ setHeight(event.nativeEvent.contentSize.height);
791
+ };
792
+ inputStyle = { ...inputStyle, ...defs.style };
793
+ }
794
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(View4, { style: style("base", defs?.baseStyle) }, scope.getPart("left"), /* @__PURE__ */ React.createElement(
795
+ TextInput,
796
+ {
797
+ onChangeText: onChange,
798
+ value,
799
+ placeholder,
800
+ ...defs,
801
+ style: inputStyle
802
+ }
803
+ ), /* @__PURE__ */ React.createElement(CustomIcon, null)), scope.getPart("right"));
804
+ }
805
+ var styles7 = StyleSheet7.create({
806
+ base: {
807
+ flex: 1,
808
+ width: "100%",
809
+ paddingBottom: 0,
810
+ paddingTop: 0,
811
+ alignItems: "center",
812
+ borderWidth: 1,
813
+ borderColor: "borderColor",
814
+ borderRadius: 5,
815
+ paddingHorizontal: 10,
816
+ alignSelf: "flex-start",
817
+ flexDirection: "row",
818
+ flexWrap: "wrap",
819
+ gap: 10
820
+ },
821
+ icon: {
822
+ marginRight: 10
823
+ // Espaço entre ícone e input
824
+ },
825
+ input: {
826
+ marginHorizontal: 0,
827
+ marginVertical: 0,
828
+ paddingVertical: 0,
829
+ height: 40,
830
+ width: "100%",
831
+ flex: 1
832
+ // Para o input ocupar o espaço restante
833
+ },
834
+ textarea: {
835
+ marginHorizontal: 0,
836
+ marginVertical: 0,
837
+ paddingVertical: 10,
838
+ width: "100%",
839
+ height: "auto",
840
+ alignSelf: "stretch",
841
+ flex: 1
842
+ // Para o input ocupar o espaço restante
843
+ }
844
+ });
845
+
846
+ // src/elements/UIElement.tsx
847
+ import {
848
+ Alert,
849
+ Image,
850
+ Linking as Linking5,
851
+ StyleSheet as StyleSheet15,
852
+ Text as Text14,
853
+ TouchableHighlight as TouchableHighlight5,
854
+ View as View13
855
+ } from "react-native";
856
+
857
+ // src/elements/core/UIList.tsx
858
+ import React6, { useState as useState9 } from "react";
859
+ import { ComponentUtils as ComponentUtils2, Utils as Utils11 } from "react-crud-utils";
860
+ import { StyleSheet as StyleSheet9, Text as Text7, View as View6 } from "react-native";
861
+
862
+ // src/elements/core/UIListRow.tsx
863
+ import React5, { useRef as useRef2, useState as useState8 } from "react";
864
+ import { ScopeUtils as ScopeUtils2 } from "react-crud-utils";
865
+ import { StyleSheet as StyleSheet8, TouchableHighlight as TouchableHighlight2, View as View5 } from "react-native";
866
+
867
+ // src/hooks/useIsVisible.ts
868
+ import { useEffect as useEffect2, useState as useState7 } from "react";
869
+ import { Dimensions, Platform } from "react-native";
870
+ function useIsVisible(ref, scope) {
871
+ const [isVisible, setIsVisible] = useState7(scope.visible === true);
872
+ useEffect2(() => {
873
+ const checkVisibility = () => {
874
+ if (!ref.current || isVisible || !scope.original?.useIsInView) return;
875
+ if (Platform.OS === "web") {
876
+ const rect = ref.current.getBoundingClientRect?.();
877
+ if (rect && typeof window !== "undefined") {
878
+ const windowHeight = window.innerHeight;
879
+ const visible = rect.top < windowHeight && rect.bottom > 0;
880
+ if (visible) scope.visible = visible;
881
+ setIsVisible(visible);
882
+ }
883
+ } else {
884
+ ref.current.measureInWindow?.((x, y, width, height) => {
885
+ const windowHeight = Dimensions.get("window").height;
886
+ const visible = y < windowHeight && y + height > 0;
887
+ if (visible) scope.visible = visible;
888
+ setIsVisible(visible);
889
+ });
890
+ }
891
+ };
892
+ const interval = setInterval(checkVisibility, 300);
893
+ return () => clearInterval(interval);
894
+ }, [ref]);
895
+ return isVisible;
896
+ }
897
+
898
+ // src/elements/core/UIListRow.tsx
899
+ function UIListRow(props) {
900
+ const scope = props.scope;
901
+ const index = props.index;
902
+ const original = scope.original;
903
+ const item = props.item;
904
+ const cols = scope.getPart("cols", void 0, -1);
905
+ const rowWidth = Math.floor(100 / cols) + "%";
906
+ const styles13 = { repeat: stylesRepeat, list: stylesList }?.[original.type];
907
+ const name = `${scope.key("row", index, "")}`;
908
+ const [row] = useState8(
909
+ ScopeUtils2.create({
910
+ ...original,
911
+ parent: scope,
912
+ name,
913
+ crud: scope.crud,
914
+ index,
915
+ type: "row",
916
+ data: item
917
+ })
918
+ );
919
+ const targetRef = useRef2(null);
920
+ const isVisible = useIsVisible(targetRef, row);
921
+ const onClick = (item2) => {
922
+ row.call("click", { value: item2, item: item2, edit: true, index });
923
+ };
924
+ const Child = () => {
925
+ if (!isVisible && original.useIsInView && !row.visible && index > 20) {
926
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null);
927
+ }
928
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(UIChildren, { transient: true, scope: row, crud: row.crud }, props.children));
929
+ };
930
+ const ListItem = () => {
931
+ let [updateIndex, setUpdateIndex] = useState8(0);
932
+ let key = scope.key("item");
933
+ row.selected = row.getPart("isSelectedRow", void 0, false);
934
+ const getRowStyle = () => {
935
+ let css = row.getStyle("row", { ...styles13.row, minHeight: 30 });
936
+ if (row.selected) {
937
+ css = { ...css, ...row.getStyle("rowSelected", {}) };
938
+ } else {
939
+ css = { ...css, ...row.getStyle("rowUnSelected", {}) };
940
+ }
941
+ if (cols > 0) {
942
+ css.width = rowWidth;
943
+ }
944
+ return css;
945
+ };
946
+ row.update = () => {
947
+ scope.updateIndex = scope.updateIndex + 1;
948
+ setUpdateIndex(++updateIndex);
949
+ };
950
+ let renderedRow = row.getPart("renderedItem", void 0, true);
951
+ if (renderedRow === false) {
952
+ return /* @__PURE__ */ React5.createElement(React5.Fragment, null);
953
+ }
954
+ if (!original.click) {
955
+ return /* @__PURE__ */ React5.createElement(View5, { key, style: getRowStyle(), ref: targetRef }, /* @__PURE__ */ React5.createElement(Child, null));
956
+ }
957
+ return /* @__PURE__ */ React5.createElement(
958
+ TouchableHighlight2,
959
+ {
960
+ key,
961
+ style: getRowStyle(),
962
+ underlayColor: "transparent",
963
+ ref: targetRef,
964
+ onPress: (e) => {
965
+ e.stopPropagation();
966
+ onClick(item);
967
+ }
968
+ },
969
+ /* @__PURE__ */ React5.createElement(Child, null)
970
+ );
971
+ };
972
+ return /* @__PURE__ */ React5.createElement(ListItem, null);
973
+ }
974
+ var stylesList = StyleSheet8.create({
975
+ row: {
976
+ padding: 5,
977
+ margin: 0,
978
+ width: "100%",
979
+ backgroundColor: "background",
980
+ gap: 10,
981
+ borderRadius: 8,
982
+ justifyContent: "center"
983
+ }
984
+ });
985
+ var stylesRepeat = StyleSheet8.create({
986
+ row: {
987
+ padding: 0,
988
+ width: "100%",
989
+ justifyContent: "center"
990
+ }
991
+ });
992
+
993
+ // src/elements/core/UIList.tsx
994
+ import { Ionicons as Ionicons5 } from "@expo/vector-icons";
995
+ function UIList(props) {
996
+ const scope = props.scope;
997
+ const crud = scope.crud;
998
+ const original = scope.original;
999
+ const cols = Utils11.nvl(scope.getPart("cols", void 0, 1));
1000
+ const styles13 = { repeat: stylesRepeat2, list: stylesList2 }?.[original.type];
1001
+ const add = ComponentUtils2.getDefine(props, "add");
1002
+ const hideAddWhenEmpty = original.hideAddWhenEmpty;
1003
+ const hideEmpty = original.hideEmpty;
1004
+ const getStyle = (key, extra) => {
1005
+ return scope.getStyle(key, { ...extra, ...styles13[key] });
1006
+ };
1007
+ const getContainerStyle = (extra) => {
1008
+ let row = getStyle("container", {});
1009
+ if (cols > 1) {
1010
+ row = { ...row, flexDirection: "row", flexWrap: "wrap" };
1011
+ }
1012
+ return row;
1013
+ };
1014
+ const LocalData = () => {
1015
+ let [index, setIndex] = useState9(scope.updateIndex);
1016
+ let empty = scope.attr("empty", "Sem registro");
1017
+ scope.update = () => {
1018
+ scope.updateIndex = ++index;
1019
+ setIndex(index);
1020
+ };
1021
+ const items2 = Utils11.call(() => {
1022
+ let list = Utils11.nvl(scope.getItems(), []);
1023
+ if (original.search !== false && !original.list?.url) {
1024
+ let query = crud.get("query", "").toLowerCase().trim();
1025
+ if (query.length > 1) {
1026
+ let filters = [];
1027
+ let filterBy = Utils11.nvl(original.filterBy, "label");
1028
+ Utils11.each(list, (o) => {
1029
+ let label = Utils11.getValue(filterBy, "none", o).toLowerCase();
1030
+ if (label) {
1031
+ if (label.includes(query)) {
1032
+ filters.push(o);
1033
+ }
1034
+ }
1035
+ });
1036
+ return filters;
1037
+ }
1038
+ }
1039
+ return list;
1040
+ });
1041
+ let isEmpty = Utils11.isEmpty(items2);
1042
+ const isShowAdd = () => {
1043
+ if (!isEmpty) {
1044
+ return true;
1045
+ }
1046
+ return hideAddWhenEmpty !== true;
1047
+ };
1048
+ let Empty = () => {
1049
+ if (!isEmpty) {
1050
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null);
1051
+ }
1052
+ if (!empty) {
1053
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null);
1054
+ }
1055
+ if (typeof empty === "string") {
1056
+ return /* @__PURE__ */ React6.createElement(
1057
+ Text7,
1058
+ {
1059
+ style: scope.getStyle("empty", {
1060
+ flex: 1,
1061
+ fontWeight: 400,
1062
+ fontSize: 18,
1063
+ padding: 10,
1064
+ textAlign: "center",
1065
+ width: "100%",
1066
+ justifyContent: "center",
1067
+ alignItems: "center"
1068
+ })
1069
+ },
1070
+ empty
1071
+ );
1072
+ }
1073
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, empty);
1074
+ };
1075
+ if (empty === false && isEmpty) {
1076
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null);
1077
+ }
1078
+ return /* @__PURE__ */ React6.createElement(View6, { style: getContainerStyle() }, /* @__PURE__ */ React6.createElement(Empty, null), items2.map((item, i) => /* @__PURE__ */ React6.createElement(UIListRow, { index: i, item, scope }, props.children)), isShowAdd() && /* @__PURE__ */ React6.createElement(React6.Fragment, null, add));
1079
+ };
1080
+ let items = Utils11.nvl(scope.getItems(), []);
1081
+ if (hideEmpty && Utils11.isEmpty(items)) {
1082
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null);
1083
+ }
1084
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, original.search !== false && /* @__PURE__ */ React6.createElement(
1085
+ UI_default.Text,
1086
+ {
1087
+ placeholder: "Pesquisar...",
1088
+ field: "query",
1089
+ crud,
1090
+ style: { marginBottom: 10 },
1091
+ change: {
1092
+ action: () => {
1093
+ scope.search();
1094
+ }
1095
+ },
1096
+ icon: /* @__PURE__ */ React6.createElement(Ionicons5, { name: "search", size: 20, color: "#888" })
1097
+ }
1098
+ ), /* @__PURE__ */ React6.createElement(LocalData, null));
1099
+ }
1100
+ var stylesList2 = StyleSheet9.create({
1101
+ container: {
1102
+ display: "flex",
1103
+ flexWrap: "wrap",
1104
+ gap: 10,
1105
+ width: "100%"
1106
+ },
1107
+ text: {
1108
+ fontSize: 18,
1109
+ fontWeight: "bold"
1110
+ }
1111
+ });
1112
+ var stylesRepeat2 = StyleSheet9.create({
1113
+ container: {
1114
+ display: "flex",
1115
+ flexWrap: "wrap",
1116
+ gap: 10,
1117
+ width: "100%"
1118
+ },
1119
+ text: {
1120
+ fontSize: 18,
1121
+ fontWeight: "bold"
1122
+ }
1123
+ });
1124
+
1125
+ // src/elements/core/UIToggle.tsx
1126
+ import React7, { useState as useState10 } from "react";
1127
+ import { Utils as Utils12 } from "react-crud-utils";
1128
+ import { StyleSheet as StyleSheet10, Text as Text8, TouchableHighlight as TouchableHighlight3, View as View7 } from "react-native";
1129
+ function UIToggle(props) {
1130
+ const scope = props.scope;
1131
+ const options = Utils12.nvl(scope.getOptions(), []);
1132
+ const value = scope.getInputValue();
1133
+ let [index, setIndex] = useState10(0);
1134
+ const isSelected = (item) => {
1135
+ return item?.value === value;
1136
+ };
1137
+ const onClick = (item) => {
1138
+ scope.changeValue(item.object);
1139
+ setIndex(++index);
1140
+ };
1141
+ const Item = ({ item, index: index2 }) => {
1142
+ let selected = isSelected(item);
1143
+ let style = { ...styles8.text, ...scope.getStyle("text") };
1144
+ if (selected) style.color = "#ffffff";
1145
+ if (Utils12.isEmpty(props.children)) {
1146
+ return /* @__PURE__ */ React7.createElement(Text8, { style }, item.label);
1147
+ }
1148
+ return /* @__PURE__ */ React7.createElement(UIListRow, { scope, item: item.object, index: index2 }, props.children);
1149
+ };
1150
+ const getItemStyle = (item) => {
1151
+ let style = { ...styles8.item, ...scope.getStyle("item") };
1152
+ let wPart = 100 / options.length;
1153
+ let width = Math.floor(wPart) + "%";
1154
+ if (isSelected(item)) {
1155
+ let selectedColor = scope.getPart("selectedColor", void 0, "primary");
1156
+ let st = scope.getStyle("selected", {
1157
+ backgroundColor: selectedColor,
1158
+ color: "#ffffff"
1159
+ });
1160
+ style = { ...style, ...st };
1161
+ if (!style.color) {
1162
+ style.color = "#ffffff";
1163
+ }
1164
+ const backgroundColor = item.backgroundColor;
1165
+ const color = item.color;
1166
+ if (item.backgroundColor) style = { ...style, backgroundColor };
1167
+ if (item.color) style = { ...style, color };
1168
+ } else {
1169
+ style.backgroundColor = "#fff";
1170
+ style.color = "#000";
1171
+ }
1172
+ style.width = width;
1173
+ return style;
1174
+ };
1175
+ return /* @__PURE__ */ React7.createElement(View7, { style: { ...styles8.container, ...scope.getStyle("items") } }, options.map((item, i) => /* @__PURE__ */ React7.createElement(
1176
+ TouchableHighlight3,
1177
+ {
1178
+ key: `k-${i}`,
1179
+ style: getItemStyle(item),
1180
+ onPress: (e) => {
1181
+ onClick(item);
1182
+ }
1183
+ },
1184
+ /* @__PURE__ */ React7.createElement(Item, { item, index: i })
1185
+ )));
1186
+ }
1187
+ var styles8 = StyleSheet10.create({
1188
+ container: {
1189
+ flex: 1,
1190
+ width: "100%",
1191
+ justifyContent: "center",
1192
+ flexDirection: "row",
1193
+ alignItems: "center",
1194
+ margin: 3,
1195
+ gap: 5
1196
+ },
1197
+ item: {
1198
+ backgroundColor: "background",
1199
+ justifyContent: "center",
1200
+ alignItems: "center",
1201
+ width: "auto",
1202
+ flexDirection: "row",
1203
+ flex: 1,
1204
+ padding: 5,
1205
+ borderRadius: 2
1206
+ },
1207
+ text: {
1208
+ fontSize: 13,
1209
+ fontWeight: "400"
1210
+ }
1211
+ });
1212
+
1213
+ // src/elements/core/UIQuantity.tsx
1214
+ import { Ionicons as Ionicons6 } from "@expo/vector-icons";
1215
+ import { useState as useState11 } from "react";
1216
+ import { Utils as Utils13 } from "react-crud-utils";
1217
+ import { Text as Text9, TouchableHighlight as TouchableHighlight4 } from "react-native";
1218
+ function UIQuantity(props) {
1219
+ const scope = props.scope;
1220
+ const element = scope.original;
1221
+ let [index, setIndex] = useState11(0);
1222
+ const value = scope.getValue(0);
1223
+ let color = element.color;
1224
+ if (!color) color = "primary";
1225
+ const btn = {
1226
+ padding: 0,
1227
+ alignItems: "center",
1228
+ height: 30,
1229
+ width: 30,
1230
+ textAlign: "center",
1231
+ verticalAling: "middle",
1232
+ borderRadius: 24,
1233
+ backgroundColor: color,
1234
+ color: "#ffffff",
1235
+ justifyContent: "center"
1236
+ };
1237
+ const styles13 = {
1238
+ buttonLabel: {
1239
+ color: "#ffffff",
1240
+ fontWeight: "500",
1241
+ fontSize: 16
1242
+ },
1243
+ value: {
1244
+ flex: 1,
1245
+ flexDirection: "row",
1246
+ textAlign: "center",
1247
+ fontWeight: "500"
1248
+ },
1249
+ buttonInner: {
1250
+ flexDirection: "row",
1251
+ alignItems: "center",
1252
+ justifyContent: "center"
1253
+ },
1254
+ buttonIcon: {
1255
+ color: "#fff",
1256
+ fontSize: 18
1257
+ },
1258
+ button: btn,
1259
+ addButton: {
1260
+ ...btn
1261
+ },
1262
+ delButton: {
1263
+ ...btn
1264
+ }
1265
+ };
1266
+ const change = (val) => {
1267
+ scope.changeValue(value + val);
1268
+ setIndex(++index);
1269
+ };
1270
+ const onClickAdd = () => {
1271
+ change(1);
1272
+ };
1273
+ const onClickDel = () => {
1274
+ change(-1);
1275
+ };
1276
+ const style = (part, extra) => {
1277
+ let s = { ...styles13[part], ...extra };
1278
+ return scope.getStyle(part, s);
1279
+ };
1280
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
1281
+ TouchableHighlight4,
1282
+ {
1283
+ underlayColor: "transparent",
1284
+ onPress: onClickDel,
1285
+ style: style("delButton")
1286
+ },
1287
+ /* @__PURE__ */ React.createElement(Ionicons6, { size: 30, style: style("buttonIcon"), name: "remove" })
1288
+ ), /* @__PURE__ */ React.createElement(Text9, { style: style("value") }, Utils13.nvl(value, 0)), /* @__PURE__ */ React.createElement(
1289
+ TouchableHighlight4,
1290
+ {
1291
+ underlayColor: "transparent",
1292
+ onPress: onClickAdd,
1293
+ style: style("addButton")
1294
+ },
1295
+ /* @__PURE__ */ React.createElement(Ionicons6, { size: 30, style: style("buttonIcon"), name: "add" })
1296
+ ));
1297
+ }
1298
+
1299
+ // src/elements/core/UIModal.tsx
1300
+ import { useRef as useRef3, useState as useState12 } from "react";
1301
+ import { ComponentUtils as ComponentUtils3, Utils as Utils14 } from "react-crud-utils";
1302
+ import {
1303
+ Text as Text10,
1304
+ TouchableOpacity as TouchableOpacity6,
1305
+ StyleSheet as StyleSheet12,
1306
+ Modal as Modal2,
1307
+ View as View9,
1308
+ ScrollView as ScrollView2
1309
+ } from "react-native";
1310
+ import Ionicons7 from "@expo/vector-icons/Ionicons";
1311
+
1312
+ // src/elements/core/UIToast.tsx
1313
+ import { StyleSheet as StyleSheet11 } from "react-native";
1314
+ import Toast, { BaseToast, ErrorToast } from "react-native-toast-message";
1315
+ function UIToast() {
1316
+ const toastConfig = {
1317
+ success: (props) => /* @__PURE__ */ React.createElement(
1318
+ BaseToast,
1319
+ {
1320
+ ...props,
1321
+ style: styles13.darkToast,
1322
+ contentContainerStyle: { paddingHorizontal: 15 },
1323
+ text1Style: styles13.text,
1324
+ text2Style: styles13.text
1325
+ }
1326
+ ),
1327
+ error: (props) => /* @__PURE__ */ React.createElement(
1328
+ ErrorToast,
1329
+ {
1330
+ ...props,
1331
+ style: styles13.darkToast,
1332
+ text1Style: styles13.text,
1333
+ text2Style: styles13.text
1334
+ }
1335
+ ),
1336
+ info: (props) => /* @__PURE__ */ React.createElement(
1337
+ BaseToast,
1338
+ {
1339
+ ...props,
1340
+ style: styles13.darkToast,
1341
+ text1Style: styles13.text,
1342
+ text2Style: styles13.text
1343
+ }
1344
+ )
1345
+ };
1346
+ const styles13 = StyleSheet11.create({
1347
+ darkToast: {
1348
+ backgroundColor: "rgba(34, 34, 34, 0.85)",
1349
+ borderLeftColor: "#222"
1350
+ // borda mais escura
1351
+ },
1352
+ text: {
1353
+ color: "#fff",
1354
+ // letras brancas
1355
+ textAlign: "center"
1356
+ }
1357
+ });
1358
+ return /* @__PURE__ */ React.createElement(Toast, { config: toastConfig });
1359
+ }
1360
+
1361
+ // src/elements/core/UIModal.tsx
1362
+ import { SafeAreaView as SafeAreaView2 } from "react-native-safe-area-context";
1363
+ function UIModal(props) {
1364
+ const scrollRef = useRef3(null);
1365
+ let owner = props.scope;
1366
+ let [index, setIndex] = useState12(0);
1367
+ let dialog = owner.currentDialog;
1368
+ let curr = dialog?.crud;
1369
+ if (!dialog) {
1370
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
1371
+ }
1372
+ dialog.update = () => {
1373
+ setIndex(++index);
1374
+ };
1375
+ if (dialog.debug) console.log(dialog);
1376
+ const scope = dialog.scope;
1377
+ const label = scope.getLabel();
1378
+ const theme = scope.getTheme();
1379
+ const headerStyle = Utils14.nvl(theme.styles?.defaults?.header, {});
1380
+ const headerRight = ComponentUtils3.getDefine(props, "header", "right");
1381
+ const bottom = ComponentUtils3.getDefine(props, "bottom");
1382
+ const style = (part, extra) => {
1383
+ let st = { ...styles9[part], ...extra };
1384
+ return { ...scope.getStyle(part, st) };
1385
+ };
1386
+ const onClose = () => {
1387
+ scope.close({ scope, crud: dialog?.crud, event: {} });
1388
+ };
1389
+ scope.put("scrollRef", scrollRef);
1390
+ const original = owner.original;
1391
+ ComponentUtils3.setViewScope(scope);
1392
+ let color = Utils14.nvl(headerStyle.color, "white");
1393
+ let defaults = { color };
1394
+ let key = `${curr.name}-${index}`;
1395
+ let ModalContent = ({ children }) => {
1396
+ let disableScroll = scope.part("disableScroll", false);
1397
+ let disableContent = scope.part("disableContent", false);
1398
+ if (disableContent) {
1399
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, children);
1400
+ }
1401
+ if (disableScroll) {
1402
+ return /* @__PURE__ */ React.createElement(View9, { style: style("modalContent") }, children);
1403
+ }
1404
+ return /* @__PURE__ */ React.createElement(
1405
+ ScrollView2,
1406
+ {
1407
+ contentContainerStyle: { flexGrow: 1, paddingBottom: 50 },
1408
+ style: style("modalContent"),
1409
+ nestedScrollEnabled: true,
1410
+ ref: scrollRef
1411
+ },
1412
+ children
1413
+ );
1414
+ };
1415
+ const ModalInner = () => {
1416
+ let Content = () => {
1417
+ if (dialog?.component) {
1418
+ let cprops = dialog.props;
1419
+ let Aux = dialog.component;
1420
+ return /* @__PURE__ */ React.createElement(Aux, { key: curr.uuid, crud: curr, ...cprops });
1421
+ }
1422
+ return /* @__PURE__ */ React.createElement(UIChildren, { scope, crud: curr }, props.children);
1423
+ };
1424
+ let content = /* @__PURE__ */ React.createElement(Content, null);
1425
+ let area = {};
1426
+ if (original.transient) {
1427
+ return /* @__PURE__ */ React.createElement(SafeAreaView2, { style: style("modalSafe", area) }, content);
1428
+ }
1429
+ return /* @__PURE__ */ React.createElement(SafeAreaView2, { style: style("modalSafe", area) }, /* @__PURE__ */ React.createElement(View9, { style: scope.getStyle("header", headerStyle) }, /* @__PURE__ */ React.createElement(TouchableOpacity6, { onPress: onClose, style: style("modalCloseButton") }, /* @__PURE__ */ React.createElement(
1430
+ Ionicons7,
1431
+ {
1432
+ name: "chevron-back-outline",
1433
+ size: 24,
1434
+ color,
1435
+ style: style("modalCloseText", defaults)
1436
+ }
1437
+ )), /* @__PURE__ */ React.createElement(Text10, { style: style("modalTitle", defaults) }, label), !Utils14.isEmpty(headerRight) && /* @__PURE__ */ React.createElement(UIChildren, { scope, crud: curr, transient: true }, headerRight)), /* @__PURE__ */ React.createElement(ModalContent, null, content), bottom, /* @__PURE__ */ React.createElement(UIToast, null));
1438
+ };
1439
+ return /* @__PURE__ */ React.createElement(
1440
+ Modal2,
1441
+ {
1442
+ key,
1443
+ animationType: "slide",
1444
+ transparent: true,
1445
+ visible: true,
1446
+ onRequestClose: onClose
1447
+ },
1448
+ /* @__PURE__ */ React.createElement(ModalInner, null)
1449
+ );
1450
+ }
1451
+ var styles9 = StyleSheet12.create({
1452
+ modalTop: {
1453
+ backgroundColor: "background",
1454
+ width: "100%"
1455
+ },
1456
+ modalSafe: {
1457
+ flex: 1,
1458
+ width: "100%",
1459
+ backgroundColor: "background"
1460
+ },
1461
+ modalCloseButton: {
1462
+ padding: 10
1463
+ },
1464
+ modalCloseText: {
1465
+ fontSize: 18,
1466
+ color: "white"
1467
+ },
1468
+ modalTitle: {
1469
+ fontSize: 22,
1470
+ fontWeight: 600,
1471
+ marginLeft: 10
1472
+ },
1473
+ modalContent: {
1474
+ flex: 1,
1475
+ backgroundColor: "background",
1476
+ paddingLeft: 15,
1477
+ paddingRight: 15,
1478
+ paddingTop: 10,
1479
+ paddingBottom: 10
1480
+ }
1481
+ });
1482
+
1483
+ // src/elements/UIElement.tsx
1484
+ import { Ionicons as Ionicons8 } from "@expo/vector-icons";
1485
+
1486
+ // src/elements/core/UIView.tsx
1487
+ import { ScrollView as ScrollView3, StyleSheet as StyleSheet13, View as View11 } from "react-native";
1488
+ import { ComponentUtils as ComponentUtils4, Utils as Utils16, ViewUtils as ViewUtils2 } from "react-crud-utils";
1489
+ import { useRef as useRef4 } from "react";
1490
+
1491
+ // src/elements/core/UIHeader.tsx
1492
+ import { Text as Text11, View as View10 } from "react-native";
1493
+ import { HtmlUtils, Utils as Utils15 } from "react-crud-utils";
1494
+ function UIHeader({ scope }) {
1495
+ const theme = scope.getTheme();
1496
+ const header = scope.getPart("header", null, []);
1497
+ const headerStyle = Utils15.nvl(theme.styles?.defaults?.header, {});
1498
+ const headerTextStyle = Utils15.nvl(theme.styles?.defaults?.headerText, {});
1499
+ let headerStyleFull = Utils15.call(() => {
1500
+ let css = scope.getStyle("header", headerStyle);
1501
+ let bg = css.backgroundColor;
1502
+ if (bg) {
1503
+ css.color = HtmlUtils.getTextColor(bg);
1504
+ }
1505
+ return css;
1506
+ });
1507
+ let hasHeader = !Utils15.isEmpty(header);
1508
+ let AuxHeader = () => {
1509
+ if (typeof header === "string") {
1510
+ return /* @__PURE__ */ React.createElement(Text11, { style: headerTextStyle }, header);
1511
+ }
1512
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, header);
1513
+ };
1514
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, hasHeader && /* @__PURE__ */ React.createElement(View10, { style: headerStyleFull }, /* @__PURE__ */ React.createElement(AuxHeader, null)));
1515
+ }
1516
+
1517
+ // src/elements/core/UIView.tsx
1518
+ function UIView({ scope, children }) {
1519
+ const scrollRef = useRef4(null);
1520
+ const original = scope.original;
1521
+ const onScroll = () => {
1522
+ const crud = ViewUtils2.getCrud();
1523
+ Utils16.each(crud.scroll, (s) => {
1524
+ if (s.onScroll) {
1525
+ s.onScroll.call(s);
1526
+ }
1527
+ });
1528
+ };
1529
+ scope.put("scrollRef", scrollRef);
1530
+ ComponentUtils4.setViewScope(scope);
1531
+ let Container = () => {
1532
+ if (original.scroll === false) {
1533
+ return /* @__PURE__ */ React.createElement(UIChildren, { scope }, children);
1534
+ }
1535
+ return /* @__PURE__ */ React.createElement(View11, { style: scope.getStyle("container", styles10.container) }, /* @__PURE__ */ React.createElement(
1536
+ ScrollView3,
1537
+ {
1538
+ onScroll,
1539
+ scrollEventThrottle: 16,
1540
+ ref: scrollRef,
1541
+ nestedScrollEnabled: true,
1542
+ keyboardShouldPersistTaps: "handled",
1543
+ contentContainerStyle: scope.getStyle("contentContainer", {
1544
+ paddingBottom: 50
1545
+ }),
1546
+ style: scope.getStyle("scroll", styles10.scroll)
1547
+ },
1548
+ /* @__PURE__ */ React.createElement(UIChildren, { scope }, children)
1549
+ ));
1550
+ };
1551
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(UIHeader, { scope }), /* @__PURE__ */ React.createElement(Container, null), /* @__PURE__ */ React.createElement(UIToast, null), " ");
1552
+ }
1553
+ var styles10 = StyleSheet13.create({
1554
+ scroll: {
1555
+ paddingTop: 10,
1556
+ paddingBottom: 10,
1557
+ paddingLeft: 15,
1558
+ paddingRight: 15
1559
+ },
1560
+ container: {},
1561
+ view: {}
1562
+ });
1563
+
1564
+ // src/elements/UIElement.tsx
1565
+ import Toast2 from "react-native-toast-message";
1566
+
1567
+ // src/elements/core/UIOrder.tsx
1568
+ import React8, { useRef as useRef5, useState as useState13, useEffect as useEffect3 } from "react";
1569
+ import { Utils as Utils17 } from "react-crud-utils";
1570
+ import {
1571
+ View as View12,
1572
+ Text as Text13,
1573
+ StyleSheet as StyleSheet14,
1574
+ Animated,
1575
+ PanResponder,
1576
+ TouchableOpacity as TouchableOpacity7
1577
+ } from "react-native";
1578
+ var ITEM_HEIGHT = 70;
1579
+ function UIOrder(props) {
1580
+ const scope = props.scope;
1581
+ const element = scope.original;
1582
+ const initial = scope.getOptions();
1583
+ const [items, setItems] = useState13(initial);
1584
+ const [draggingId, setDraggingId] = useState13(null);
1585
+ const positions = useRef5(
1586
+ Object.fromEntries(
1587
+ initial.map((it, i) => [it.value, new Animated.Value(i * ITEM_HEIGHT)])
1588
+ )
1589
+ ).current;
1590
+ const panRespondersRef = useRef5({});
1591
+ const activeItem = useRef5(null);
1592
+ const activeIndex = useRef5(-1);
1593
+ const offsetY = useRef5(0);
1594
+ const itemsRef = useRef5(items);
1595
+ useEffect3(() => {
1596
+ itemsRef.current = items;
1597
+ }, [items]);
1598
+ useEffect3(() => {
1599
+ items.forEach((it, idx) => {
1600
+ if (!positions[it.value])
1601
+ positions[it.value] = new Animated.Value(idx * ITEM_HEIGHT);
1602
+ Animated.spring(positions[it.value], {
1603
+ toValue: idx * ITEM_HEIGHT,
1604
+ useNativeDriver: false
1605
+ }).start();
1606
+ });
1607
+ }, [items]);
1608
+ const onChange = (updated) => {
1609
+ const array = [];
1610
+ const items2 = scope.getItems();
1611
+ items2.splice(0);
1612
+ Utils17.each(updated, (o) => {
1613
+ const v = o.object;
1614
+ array.push(v);
1615
+ items2.push(v);
1616
+ });
1617
+ scope.changeValue(array);
1618
+ };
1619
+ const createPanResponder = (item) => PanResponder.create({
1620
+ onStartShouldSetPanResponder: () => true,
1621
+ onPanResponderGrant: () => {
1622
+ const currentItems = itemsRef.current;
1623
+ if (!positions[item.value] || !currentItems.find((it) => it.value === item.value))
1624
+ return;
1625
+ activeItem.current = item;
1626
+ activeIndex.current = currentItems.findIndex(
1627
+ (it) => it.value === item.value
1628
+ );
1629
+ offsetY.current = positions[item.value]._value;
1630
+ setDraggingId(item.value);
1631
+ },
1632
+ onPanResponderMove: (_, gesture) => {
1633
+ const currentItems = itemsRef.current;
1634
+ if (!positions[item.value] || !currentItems.find((it) => it.value === item.value))
1635
+ return;
1636
+ const y = offsetY.current + gesture.dy;
1637
+ positions[item.value].setValue(y);
1638
+ const targetIndex = Math.max(
1639
+ 0,
1640
+ Math.min(
1641
+ currentItems.length - 1,
1642
+ Math.floor((y + ITEM_HEIGHT / 2) / ITEM_HEIGHT)
1643
+ )
1644
+ );
1645
+ currentItems.forEach((other, idx) => {
1646
+ if (other.value === item.value || !positions[other.value]) return;
1647
+ let targetY = idx * ITEM_HEIGHT;
1648
+ if (idx > activeIndex.current && idx <= targetIndex)
1649
+ targetY = (idx - 1) * ITEM_HEIGHT;
1650
+ else if (idx < activeIndex.current && idx >= targetIndex)
1651
+ targetY = (idx + 1) * ITEM_HEIGHT;
1652
+ Animated.timing(positions[other.value], {
1653
+ toValue: targetY,
1654
+ duration: 120,
1655
+ useNativeDriver: false
1656
+ }).start();
1657
+ });
1658
+ },
1659
+ onPanResponderRelease: () => {
1660
+ const moved = activeItem.current;
1661
+ const currentItems = itemsRef.current;
1662
+ if (!moved || !positions[moved.value] || !currentItems.find((it) => it.value === moved.value))
1663
+ return;
1664
+ const finalY = positions[moved.value]._value;
1665
+ const newIndex = Math.max(
1666
+ 0,
1667
+ Math.min(
1668
+ currentItems.length - 1,
1669
+ Math.floor((finalY + ITEM_HEIGHT / 2) / ITEM_HEIGHT)
1670
+ )
1671
+ );
1672
+ const oldIndex = activeIndex.current;
1673
+ const updated = [...currentItems];
1674
+ const [removed] = updated.splice(oldIndex, 1);
1675
+ updated.splice(newIndex, 0, removed);
1676
+ setItems(updated);
1677
+ onChange(updated);
1678
+ setDraggingId(null);
1679
+ activeItem.current = null;
1680
+ activeIndex.current = -1;
1681
+ }
1682
+ });
1683
+ items.forEach((it) => {
1684
+ if (!panRespondersRef.current[it.value]) {
1685
+ panRespondersRef.current[it.value] = createPanResponder(it);
1686
+ }
1687
+ });
1688
+ const removeItem = (id) => {
1689
+ if (draggingId === id) {
1690
+ setDraggingId(null);
1691
+ activeItem.current = null;
1692
+ activeIndex.current = -1;
1693
+ }
1694
+ if (positions[id]) {
1695
+ delete positions[id];
1696
+ }
1697
+ if (panRespondersRef.current[id]) {
1698
+ delete panRespondersRef.current[id];
1699
+ }
1700
+ setItems((prev) => {
1701
+ const updated = prev.filter((it) => it.value !== id);
1702
+ updated.forEach((it, idx) => {
1703
+ if (positions[it.value])
1704
+ Animated.spring(positions[it.value], {
1705
+ toValue: idx * ITEM_HEIGHT,
1706
+ useNativeDriver: false
1707
+ }).start();
1708
+ });
1709
+ onChange(updated);
1710
+ return updated;
1711
+ });
1712
+ };
1713
+ const Empty = () => {
1714
+ if (Utils17.isEmpty(items)) {
1715
+ let empty = scope.part("empty", "Sem registro");
1716
+ if (empty !== false) return /* @__PURE__ */ React8.createElement(React8.Fragment, null, empty);
1717
+ }
1718
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null);
1719
+ };
1720
+ return /* @__PURE__ */ React8.createElement(View12, { style: styles11.container }, /* @__PURE__ */ React8.createElement(Empty, null), /* @__PURE__ */ React8.createElement(View12, { style: { height: items.length * ITEM_HEIGHT, width: "100%" } }, items.map((item) => {
1721
+ const y = positions[item.value];
1722
+ if (!y) return null;
1723
+ const isDragging = draggingId === item.value;
1724
+ const itemStyle = scope.getStyle("row", { ...styles11.item });
1725
+ return /* @__PURE__ */ React8.createElement(
1726
+ Animated.View,
1727
+ {
1728
+ key: item.value,
1729
+ ...panRespondersRef.current[item.value]?.panHandlers ?? {},
1730
+ style: [
1731
+ itemStyle,
1732
+ {
1733
+ position: "absolute",
1734
+ left: 0,
1735
+ right: 0,
1736
+ height: ITEM_HEIGHT - 8,
1737
+ transform: [{ translateY: y }],
1738
+ zIndex: isDragging ? 999 : 0,
1739
+ elevation: isDragging ? 999 : 0
1740
+ }
1741
+ ]
1742
+ },
1743
+ /* @__PURE__ */ React8.createElement(View12, { style: styles11.handle }, /* @__PURE__ */ React8.createElement(Text13, { style: styles11.handleText }, "\u2261")),
1744
+ /* @__PURE__ */ React8.createElement(Text13, { style: styles11.itemText }, item.label),
1745
+ element.remove && /* @__PURE__ */ React8.createElement(
1746
+ TouchableOpacity7,
1747
+ {
1748
+ onPress: () => removeItem(item.value),
1749
+ style: styles11.del
1750
+ },
1751
+ /* @__PURE__ */ React8.createElement(Text13, { style: { color: "#fff" } }, "X")
1752
+ )
1753
+ );
1754
+ })));
1755
+ }
1756
+ var styles11 = StyleSheet14.create({
1757
+ container: { flex: 1 },
1758
+ title: { fontSize: 18, fontWeight: "600", marginBottom: 12 },
1759
+ item: {
1760
+ backgroundColor: "#fff",
1761
+ borderRadius: 10,
1762
+ marginVertical: 4,
1763
+ paddingHorizontal: 12,
1764
+ alignItems: "center",
1765
+ flexDirection: "row",
1766
+ elevation: 3,
1767
+ shadowColor: "#000",
1768
+ shadowOpacity: 0.05,
1769
+ shadowRadius: 6
1770
+ },
1771
+ handle: { width: 40, alignItems: "center", justifyContent: "center" },
1772
+ handleText: { fontSize: 22, color: "#666" },
1773
+ itemText: { fontSize: 16, flex: 1 },
1774
+ del: {
1775
+ backgroundColor: "#e74c3c",
1776
+ height: 34,
1777
+ width: 34,
1778
+ borderRadius: 6,
1779
+ alignItems: "center",
1780
+ justifyContent: "center"
1781
+ }
1782
+ });
1783
+
1784
+ // src/elements/UIElement.tsx
1785
+ var CrudContext = createContext({});
1786
+ function UIElement(props) {
1787
+ const ctx = useContext(CrudContext);
1788
+ const theme = Utils18.nvl(props.theme, ctx?.theme);
1789
+ let crud = Utils18.nvl(props.crud, ctx?.crud);
1790
+ let [scope] = useState14(ScopeUtils3.create({ crud, ...props, theme }));
1791
+ let [index, setIndex] = useState14(0);
1792
+ let [error, setError] = useState14(null);
1793
+ scope.compile(props);
1794
+ crud = scope.crud;
1795
+ let options = scope.getOptions();
1796
+ let original = scope.original;
1797
+ let ref = useRef6(null);
1798
+ scope.update = () => {
1799
+ setIndex(++index);
1800
+ };
1801
+ scope.updateElement = () => {
1802
+ setIndex(++index);
1803
+ };
1804
+ scope.toast = (message, type = "info", args) => {
1805
+ Toast2.show({
1806
+ type,
1807
+ // 'success' | 'error' | 'info'
1808
+ text1: message,
1809
+ position: "bottom",
1810
+ // 'top' é outra opção
1811
+ visibilityTime: 3e3,
1812
+ // tempo que fica visível em ms
1813
+ ...args
1814
+ });
1815
+ };
1816
+ scope.prompt = (args) => {
1817
+ let event = args.event;
1818
+ if (event) {
1819
+ let message = "Voc\xEA tem certeza que deseja continuar?";
1820
+ let title = "Aten\xE7\xE3o";
1821
+ let prompt = event.prompt;
1822
+ if (typeof prompt === "string") {
1823
+ message = prompt;
1824
+ }
1825
+ if (typeof prompt === "object") {
1826
+ message = Utils18.nvl(prompt.message, message);
1827
+ title = Utils18.nvl(prompt.title, title);
1828
+ }
1829
+ Alert.alert(
1830
+ title,
1831
+ message,
1832
+ [
1833
+ {
1834
+ text: "Cancelar",
1835
+ style: "cancel"
1836
+ },
1837
+ {
1838
+ text: "Confirmar",
1839
+ onPress: () => scope.execute(args)
1840
+ }
1841
+ ],
1842
+ { cancelable: false }
1843
+ );
1844
+ }
1845
+ };
1846
+ const Custom = () => {
1847
+ let c = original.custom;
1848
+ if (c) {
1849
+ if (typeof c === "string") {
1850
+ return /* @__PURE__ */ React9.createElement(
1851
+ UIElement,
1852
+ {
1853
+ element: { value: c, type: "dummy" },
1854
+ crud
1855
+ }
1856
+ );
1857
+ }
1858
+ return /* @__PURE__ */ React9.createElement(
1859
+ UIElement,
1860
+ {
1861
+ type: c.type,
1862
+ tag: c.type,
1863
+ ...c.props,
1864
+ crud
1865
+ }
1866
+ );
1867
+ }
1868
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null);
1869
+ };
1870
+ if (scope.is("type", "dummy")) {
1871
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, scope.getDisplayValue());
1872
+ }
1873
+ let onCheck = () => {
1874
+ let v = scope.getValue();
1875
+ let check = !(v === true);
1876
+ onChange({ target: { value: check } });
1877
+ };
1878
+ let onChange = (e) => {
1879
+ let val = e.target.value;
1880
+ if (scope.isType("integer", "int", "number")) {
1881
+ val = parseInt(val);
1882
+ } else if (scope.isType("decimal")) {
1883
+ val = parseFloat(val);
1884
+ }
1885
+ if (scope.isType("select", "complete")) {
1886
+ val = scope.getSelectedItem(val);
1887
+ }
1888
+ scope.changeValue(val);
1889
+ scope.update();
1890
+ };
1891
+ let onClick = (e) => {
1892
+ if (scope.currentDialog?.component) return;
1893
+ scope.call("click");
1894
+ };
1895
+ let defaultsInput = {
1896
+ scope,
1897
+ crud,
1898
+ onChange
1899
+ };
1900
+ if (scope.isType("password")) {
1901
+ defaultsInput.type = "password";
1902
+ }
1903
+ let isChecked = () => {
1904
+ let v = scope.getValue();
1905
+ return v === true;
1906
+ };
1907
+ let hasChildren = () => {
1908
+ if (scope.isInput()) {
1909
+ return false;
1910
+ }
1911
+ return !Utils18.isEmpty(props.children) || !Utils18.isEmpty(props.elements);
1912
+ };
1913
+ let isInput = scope.is(
1914
+ "type",
1915
+ "text",
1916
+ "textarea",
1917
+ "number",
1918
+ "integer",
1919
+ "int",
1920
+ "phone",
1921
+ "postalCode",
1922
+ "money",
1923
+ "password",
1924
+ "email"
1925
+ );
1926
+ const getStyle = (part, extra) => {
1927
+ let type = Utils18.nvl(original.type, "none");
1928
+ let key = Utils18.nvl(part, "root");
1929
+ let def = { ...styles12[key] };
1930
+ let hasChild = hasChildren();
1931
+ type = Utils18.nvl(original.layout, type);
1932
+ if (!part && !hasChild) {
1933
+ def = { ...def };
1934
+ }
1935
+ if (scope.isInput()) {
1936
+ def = { ...def, ...elementStyle.input[key] };
1937
+ }
1938
+ def = { ...def, ...elementStyle?.[type]?.[key] };
1939
+ if (hasChild && part) {
1940
+ def = { ...def, ...withChildStyles[part] };
1941
+ }
1942
+ return { ...def, ...scope.getStyle(part, { ...def, ...extra }) };
1943
+ };
1944
+ let elStyle = getStyle("element");
1945
+ let defaultsUI = {
1946
+ required: scope.isRequired(),
1947
+ size: "small",
1948
+ scope,
1949
+ crud,
1950
+ style: elStyle,
1951
+ placeholder: scope.attr("placeholder", "Digite aqui")
1952
+ };
1953
+ scope.error = (msg) => {
1954
+ error = msg;
1955
+ setError(msg);
1956
+ };
1957
+ if (!original.list?.url && !original.load?.url) {
1958
+ scope.start();
1959
+ }
1960
+ useEffect4(() => {
1961
+ scope.start();
1962
+ });
1963
+ const CustomIcon = () => {
1964
+ if (typeof original.icon === "string") {
1965
+ return /* @__PURE__ */ React9.createElement(Ionicons8, { name: original.icon, style: scope.getStyle("icon") });
1966
+ }
1967
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, original.icon);
1968
+ };
1969
+ scope.open = (args) => {
1970
+ Linking5.openURL(args.url);
1971
+ };
1972
+ useLayoutEffect(() => {
1973
+ if (ref?.current && scope.is("type", "card", "list", "tabs", "stepper")) {
1974
+ let el = ref?.current;
1975
+ if (el?.classList) {
1976
+ let bg = HtmlUtils2.getBGColor(el);
1977
+ if (bg === "rgb(255, 255, 255)") {
1978
+ el.classList.add("ui-dark");
1979
+ } else {
1980
+ el.classList.add("ui-light");
1981
+ }
1982
+ }
1983
+ }
1984
+ });
1985
+ const isShowLabel = () => {
1986
+ if (typeof original.label !== "undefined" && original.label !== false && !scope.isType("button", "dialog", "modal")) {
1987
+ return true;
1988
+ }
1989
+ return false;
1990
+ };
1991
+ const isShowInner = () => {
1992
+ if (scope.isType("icon")) return false;
1993
+ if (hasChildren()) {
1994
+ return false;
1995
+ }
1996
+ return true;
1997
+ };
1998
+ if (!scope.isRendered() || scope.is("type", "define")) {
1999
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null);
2000
+ }
2001
+ const isShowChild = () => {
2002
+ if (scope.isType(
2003
+ "tabs",
2004
+ "view",
2005
+ "grid",
2006
+ "list",
2007
+ "define",
2008
+ "repeat",
2009
+ "modal",
2010
+ "dialog",
2011
+ "chart"
2012
+ )) {
2013
+ return false;
2014
+ }
2015
+ return true;
2016
+ };
2017
+ let isTouch = !scope.isType("input", "grid", "list", "order", "repeat") && original.click;
2018
+ let custom = {};
2019
+ if (isTouch) {
2020
+ custom.underlayColor = "transparent";
2021
+ custom.onPress = onClick;
2022
+ }
2023
+ let Tag = (props2) => {
2024
+ let Aux = View13;
2025
+ if (isTouch) {
2026
+ Aux = TouchableHighlight5;
2027
+ }
2028
+ if (scope.isType("dialog", "order") || original.transient) {
2029
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, props2.children);
2030
+ }
2031
+ return /* @__PURE__ */ React9.createElement(Aux, { ...props2 });
2032
+ };
2033
+ let Inner = () => {
2034
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, scope.getPart("render", null, /* @__PURE__ */ React9.createElement(React9.Fragment, null)), scope.is("type", "button") && /* @__PURE__ */ React9.createElement(
2035
+ UIButton,
2036
+ {
2037
+ ...defaultsUI,
2038
+ onClick,
2039
+ variant: scope.attr("variant", "outlined")
2040
+ },
2041
+ original.icon && /* @__PURE__ */ React9.createElement(CustomIcon, null),
2042
+ original.label && /* @__PURE__ */ React9.createElement(Text14, { style: scope.getPart("label", "button") }, scope.getLabel())
2043
+ ), scope.is("type", "link") && /* @__PURE__ */ React9.createElement(
2044
+ UILink,
2045
+ {
2046
+ ...defaultsUI,
2047
+ onClick,
2048
+ variant: scope.attr("variant", "outlined")
2049
+ },
2050
+ original.icon && /* @__PURE__ */ React9.createElement(CustomIcon, null),
2051
+ original.label && /* @__PURE__ */ React9.createElement(Text14, { style: scope.getPart("label", "link") }, scope.getLabel())
2052
+ ), isInput && /* @__PURE__ */ React9.createElement(
2053
+ UIInput,
2054
+ {
2055
+ ...defaultsInput,
2056
+ ...defaultsUI,
2057
+ InputProps: { ...original.inputProps }
2058
+ }
2059
+ ), scope.is("type", "complete", "autocomplete") && /* @__PURE__ */ React9.createElement(
2060
+ UIComplete,
2061
+ {
2062
+ scope,
2063
+ defaultsInput,
2064
+ defaultsUI
2065
+ }
2066
+ ), scope.is("type", "quantity") && /* @__PURE__ */ React9.createElement(
2067
+ UIQuantity,
2068
+ {
2069
+ scope,
2070
+ defaultsInput,
2071
+ defaultsUI
2072
+ }
2073
+ ), scope.is("type", "checkbox", "boolean", "switch") && /* @__PURE__ */ React9.createElement(
2074
+ UISwitch,
2075
+ {
2076
+ checked: isChecked(),
2077
+ ...defaultsInput,
2078
+ onChange: onCheck
2079
+ }
2080
+ ), scope.isType("slider") && /* @__PURE__ */ React9.createElement(UISlider, { ...defaultsInput, onChange: onCheck }), scope.is("type", "select") && /* @__PURE__ */ React9.createElement(
2081
+ UISelect,
2082
+ {
2083
+ ...defaultsInput,
2084
+ ...defaultsUI,
2085
+ value: scope.getSelectedValue()
2086
+ }
2087
+ ), scope.is("type", "toggle") && /* @__PURE__ */ React9.createElement(
2088
+ UIToggle,
2089
+ {
2090
+ ...defaultsInput,
2091
+ ...defaultsUI,
2092
+ value: scope.getSelectedValue()
2093
+ }
2094
+ ), scope.is("type", "radio") && /* @__PURE__ */ React9.createElement(UIRadio, { ...defaultsInput, ...defaultsUI, row: true }, options.map((row, i) => /* @__PURE__ */ React9.createElement(
2095
+ UIOption,
2096
+ {
2097
+ key: "i" + i,
2098
+ control: /* @__PURE__ */ React9.createElement(UIRadio, { ...defaultsUI }),
2099
+ label: row.label,
2100
+ value: row.value
2101
+ }
2102
+ ))), scope.is("type", "custom") && /* @__PURE__ */ React9.createElement(Custom, null), scope.is("type", "column") && /* @__PURE__ */ React9.createElement(React9.Fragment, null, scope.is("format", "img") && /* @__PURE__ */ React9.createElement(Image, { source: scope.getDisplayValue() }), scope.is("format", "icon") && /* @__PURE__ */ React9.createElement(UIIcon, { scope, crud }), !scope.is("format", "icon", "img") && /* @__PURE__ */ React9.createElement(Text14, null, scope.getDisplayValue())), scope.is("type", "output", "value") && /* @__PURE__ */ React9.createElement(Text14, { style: getStyle("value") }, scope.getDisplayValue()));
2103
+ };
2104
+ let Include = ({ name, style }) => {
2105
+ if (props[name]) {
2106
+ let define = ComponentUtils5.getDefine(props, name);
2107
+ if (!Utils18.isEmpty(define)) {
2108
+ return /* @__PURE__ */ React9.createElement(
2109
+ UIChildren,
2110
+ {
2111
+ ...props,
2112
+ scope,
2113
+ crud,
2114
+ style: getStyle(name, style)
2115
+ },
2116
+ define
2117
+ );
2118
+ }
2119
+ }
2120
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null);
2121
+ };
2122
+ let Container = () => {
2123
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, isShowLabel() && /* @__PURE__ */ React9.createElement(
2124
+ View13,
2125
+ {
2126
+ style: getStyle("outerLabel", {
2127
+ alignSelf: "flex-start",
2128
+ flexDirection: "row",
2129
+ display: "flex",
2130
+ justifyContent: "space-between",
2131
+ alignItems: "center",
2132
+ width: "100%"
2133
+ })
2134
+ },
2135
+ /* @__PURE__ */ React9.createElement(Text14, { style: getStyle("label") }, scope.getLabel()),
2136
+ /* @__PURE__ */ React9.createElement(Include, { name: "actions", style: { width: "auto" } })
2137
+ ), isShowInner() && /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(View13, { style: getStyle("inner") }, /* @__PURE__ */ React9.createElement(Inner, null)), error && /* @__PURE__ */ React9.createElement(
2138
+ View13,
2139
+ {
2140
+ style: getStyle("error", {
2141
+ fontSize: 12,
2142
+ paddingTop: 4,
2143
+ color: "#e55b5b"
2144
+ })
2145
+ },
2146
+ error
2147
+ )), scope.isType("list", "repeat") && /* @__PURE__ */ React9.createElement(UIList, { ...props, scope, crud }), scope.isType("order") && /* @__PURE__ */ React9.createElement(UIOrder, { ...props, scope, crud }), scope.isType("chart") && /* @__PURE__ */ React9.createElement(ElChart, { ...props, scope, crud }), scope.isType("tabs") && /* @__PURE__ */ React9.createElement(ElTabs, { ...props, scope, crud }), scope.isType("view") && /* @__PURE__ */ React9.createElement(UIView, { ...props, scope, crud }), scope.is("type", "icon") && /* @__PURE__ */ React9.createElement(
2148
+ UIIcon,
2149
+ {
2150
+ ...defaultsUI,
2151
+ onClick,
2152
+ variant: scope.attr("variant", "outlined")
2153
+ },
2154
+ scope.getDisplayValue()
2155
+ ), isShowChild() && /* @__PURE__ */ React9.createElement(
2156
+ UIChildren,
2157
+ {
2158
+ ...props,
2159
+ scope,
2160
+ crud,
2161
+ style: getStyle("inner")
2162
+ }
2163
+ ), /* @__PURE__ */ React9.createElement(UIModal, { ...props, scope, crud }));
2164
+ };
2165
+ let Card = (props2) => {
2166
+ let isCard = scope.is("type|layout", "card");
2167
+ if (scope.isType("list")) {
2168
+ let empty = scope.getPart("empty", null, void 0);
2169
+ let items = scope.getItems();
2170
+ if (empty === false && Utils18.isEmpty(items)) {
2171
+ isCard = false;
2172
+ }
2173
+ }
2174
+ if (isCard) {
2175
+ let box2 = {
2176
+ ...getStyle("box", { ...boxStyle.box, alignSelf: "stretch" })
2177
+ };
2178
+ let borderWidth = original.boxBorder;
2179
+ if (borderWidth || borderWidth === 0) {
2180
+ if (borderWidth === true) {
2181
+ borderWidth = 1;
2182
+ }
2183
+ box2 = { ...box2, borderWidth };
2184
+ }
2185
+ return /* @__PURE__ */ React9.createElement(View13, { style: getStyle("card", { ...box2 }) }, /* @__PURE__ */ React9.createElement(
2186
+ View13,
2187
+ {
2188
+ style: getStyle("boxInner", {
2189
+ paddingHorizontal: 15,
2190
+ paddingVertical: 10
2191
+ })
2192
+ },
2193
+ props2.children
2194
+ ));
2195
+ }
2196
+ if (scope.isInput() || original.container) {
2197
+ return /* @__PURE__ */ React9.createElement(
2198
+ View13,
2199
+ {
2200
+ style: getStyle("container", { paddingVertical: 5, width: "100%" })
2201
+ },
2202
+ props2.children
2203
+ );
2204
+ }
2205
+ return /* @__PURE__ */ React9.createElement(React9.Fragment, null, props2.children);
2206
+ };
2207
+ scope.dialogShow = (args) => {
2208
+ let event = Utils18.nvl(args?.event, {});
2209
+ if (event?.debug) console.log(args);
2210
+ let caller = args.caller;
2211
+ let main = ViewUtils3.getCrud("view");
2212
+ let parent = main.dialog;
2213
+ let { crud: crud2 } = args;
2214
+ let name = scope.getName("modal");
2215
+ let edit = args.edit === true;
2216
+ let def = {};
2217
+ let rowItem = null;
2218
+ let component = event?.component;
2219
+ let elo = Utils18.nvl(caller?.original, original);
2220
+ if (crud2.is("row")) {
2221
+ def.parent = crud2.parent.parent;
2222
+ def.search = crud2.parent;
2223
+ rowItem = crud2.data;
2224
+ } else if (crud2.is("search")) {
2225
+ def.parent = crud2.parent;
2226
+ def.search = crud2;
2227
+ }
2228
+ let crudData = crud2.data;
2229
+ let eventData = Utils18.nvl(event.data, event.send);
2230
+ if (typeof eventData === "function") {
2231
+ eventData = eventData.call(this, args);
2232
+ }
2233
+ if (event.send === false || event.data === false) {
2234
+ crudData = {};
2235
+ }
2236
+ let data = Utils18.nvl(eventData, args.item, rowItem, crudData, {});
2237
+ let d = CrudUtils2.create("dialog", {
2238
+ parent: crud2,
2239
+ root: crud2,
2240
+ name,
2241
+ data,
2242
+ edit,
2243
+ scope,
2244
+ ...def
2245
+ });
2246
+ let el = {
2247
+ label: elo.label,
2248
+ icon: elo.icon,
2249
+ type: "dialog"
2250
+ };
2251
+ let close = event.dialog?.close;
2252
+ if (typeof event.dialog === "object") {
2253
+ el = { ...el, ...event.dialog };
2254
+ }
2255
+ if (event.header) el.header = event.header;
2256
+ if (event.label) el.label = event.label;
2257
+ if (event.title) el.title = event.title;
2258
+ let label = Utils18.nvl(el.title, el.label);
2259
+ el.label = label;
2260
+ let dialogScope = ScopeUtils3.create({
2261
+ parent: scope,
2262
+ crud: d,
2263
+ ...el,
2264
+ owner: scope
2265
+ });
2266
+ let dialog = {
2267
+ crud: d,
2268
+ label,
2269
+ parent,
2270
+ component,
2271
+ scope: dialogScope,
2272
+ close,
2273
+ props: event.props,
2274
+ debug: event.debug
2275
+ };
2276
+ main.dialog = dialog;
2277
+ scope.currentDialog = dialog;
2278
+ if (parent) parent.update?.();
2279
+ scope.update();
2280
+ };
2281
+ scope.dialogHide = (args) => {
2282
+ let main = ViewUtils3.getCrud("view");
2283
+ let current = main.dialog;
2284
+ let next = Utils18.nvl(current.parent, null);
2285
+ main.dialog = next;
2286
+ scope.currentDialog = next;
2287
+ let nextScope = next?.scope?.parent;
2288
+ let currScope = current?.scope?.parent;
2289
+ if (currScope) {
2290
+ const close = current.close;
2291
+ currScope.update();
2292
+ if (close) {
2293
+ if (close?.debug) console.log("Fechando");
2294
+ current.scope.call("close", { close });
2295
+ }
2296
+ }
2297
+ if (nextScope) {
2298
+ nextScope.update();
2299
+ }
2300
+ };
2301
+ if (original.hideEmpty && !scope.isType("list", "select", "complete")) {
2302
+ let value = scope.getValue();
2303
+ if (Utils18.isEmpty(value)) return /* @__PURE__ */ React9.createElement(React9.Fragment, null);
2304
+ }
2305
+ return /* @__PURE__ */ React9.createElement(CrudContext.Provider, { value: { crud, theme } }, /* @__PURE__ */ React9.createElement(Tag, { ref, style: getStyle(), ...custom }, /* @__PURE__ */ React9.createElement(Card, null, /* @__PURE__ */ React9.createElement(Container, null))));
2306
+ }
2307
+ var boxStyle = StyleSheet15.create({
2308
+ box: {
2309
+ borderWidth: 1,
2310
+ borderColor: "#dedede",
2311
+ borderStyle: "solid",
2312
+ backgroundColor: "white",
2313
+ borderRadius: 10,
2314
+ width: "100%",
2315
+ shadowColor: "#000",
2316
+ shadowOpacity: 0.1,
2317
+ shadowRadius: 4,
2318
+ elevation: 3
2319
+ }
2320
+ });
2321
+ var box = {
2322
+ ...boxStyle.box
2323
+ };
2324
+ var elementStyle = {};
2325
+ elementStyle.view = {
2326
+ inner: {
2327
+ width: "100%",
2328
+ alignItems: "normal",
2329
+ flex: 1
2330
+ },
2331
+ container: {
2332
+ width: "100%",
2333
+ backgroundColor: "background",
2334
+ flex: 1,
2335
+ gap: 10
2336
+ },
2337
+ root: {
2338
+ width: "100%",
2339
+ flex: 1,
2340
+ alignItems: "normal",
2341
+ padding: 0
2342
+ }
2343
+ };
2344
+ elementStyle.input = StyleSheet15.create({
2345
+ label: {
2346
+ paddingLeft: 0
2347
+ },
2348
+ inner: {
2349
+ flex: 1,
2350
+ width: "100%",
2351
+ padding: 0,
2352
+ gap: 10,
2353
+ alignSelf: "flex-start",
2354
+ flexDirection: "row",
2355
+ flexWrap: "wrap"
2356
+ }
2357
+ });
2358
+ elementStyle.quantity = {
2359
+ inner: {
2360
+ ...box,
2361
+ backgroundColor: "primarySoft",
2362
+ fontWeight: 600,
2363
+ fontSize: 16,
2364
+ borderRadius: 25,
2365
+ borderWidth: 0,
2366
+ paddingHorizontal: 5,
2367
+ paddingVertical: 5,
2368
+ flexWrap: "nowrap",
2369
+ flex: 1,
2370
+ flexDirection: "row",
2371
+ justifyContent: "center",
2372
+ alignItems: "center"
2373
+ }
2374
+ };
2375
+ elementStyle.toggle = StyleSheet15.create({
2376
+ root: {
2377
+ height: "auto"
2378
+ },
2379
+ inner: {
2380
+ ...box,
2381
+ flex: 1,
2382
+ width: "100%",
2383
+ gap: 10,
2384
+ borderRadius: 2,
2385
+ justifyContent: "center",
2386
+ flexDirection: "row",
2387
+ alignSelf: "flex-start",
2388
+ flexWrap: "nowrap"
2389
+ }
2390
+ });
2391
+ var styles12 = StyleSheet15.create({
2392
+ root: {
2393
+ gap: 5,
2394
+ flexDirection: "column",
2395
+ flexWrap: "wrap",
2396
+ width: "100%",
2397
+ alignItems: "flex-start"
2398
+ },
2399
+ label: {
2400
+ fontWeight: 600,
2401
+ fontSize: 12,
2402
+ paddingVertical: 3,
2403
+ color: "labelColor"
2404
+ },
2405
+ inner: { width: "100%", justifyContent: "space-between" }
2406
+ });
2407
+ var withChildStyles = StyleSheet15.create({
2408
+ root: {
2409
+ gap: 10
2410
+ },
2411
+ label: {
2412
+ width: "100%",
2413
+ fontWeight: 500,
2414
+ fontSize: 24
2415
+ }
2416
+ });
2417
+
2418
+ // src/elements/core/UIInclude.tsx
2419
+ import { ComponentUtils as ComponentUtils6, Utils as Utils19 } from "react-crud-utils";
2420
+ function UIInclude(props) {
2421
+ if (props.rendered === false) {
2422
+ return /* @__PURE__ */ React.createElement(React.Fragment, null);
2423
+ }
2424
+ let includes = ComponentUtils6.getDefine(props, props.name, props.position);
2425
+ if (Utils19.isEmpty(includes)) {
2426
+ includes = props.default;
2427
+ }
2428
+ if (!Utils19.isEmpty(includes)) {
2429
+ let Aux = (tagProp) => {
2430
+ let Tag = props.tag;
2431
+ if (!Utils19.isEmpty(Tag)) {
2432
+ return /* @__PURE__ */ React.createElement(Tag, { ...tagProp }, tagProp.children);
2433
+ }
2434
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, tagProp.children);
2435
+ };
2436
+ return /* @__PURE__ */ React.createElement(Aux, { ...props.tagProps }, /* @__PURE__ */ React.createElement(
2437
+ UIChildren,
2438
+ {
2439
+ transient: true,
2440
+ ...props,
2441
+ scope: props.scope,
2442
+ crud: props.crud,
2443
+ part: props.name
2444
+ },
2445
+ includes
2446
+ ));
2447
+ }
2448
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, includes);
2449
+ }
2450
+
2451
+ // src/elements/core/SafeView.tsx
2452
+ import {
2453
+ Keyboard,
2454
+ KeyboardAvoidingView,
2455
+ Platform as Platform2,
2456
+ StatusBar,
2457
+ TouchableWithoutFeedback
2458
+ } from "react-native";
2459
+ import {
2460
+ SafeAreaProvider,
2461
+ SafeAreaView as SafeAreaContextView
2462
+ } from "react-native-safe-area-context";
2463
+ import { ThemeUtils, useTheme, Utils as Utils20 } from "react-crud-utils";
2464
+ function SafeView(props) {
2465
+ let theme = ThemeUtils.getCurrentTheme();
2466
+ if (Utils20.isEmpty(theme)) {
2467
+ theme = useTheme();
2468
+ }
2469
+ const dismissKeyboard = () => {
2470
+ if (Platform2.OS !== "web") {
2471
+ Keyboard.dismiss();
2472
+ }
2473
+ };
2474
+ return /* @__PURE__ */ React.createElement(SafeAreaProvider, null, /* @__PURE__ */ React.createElement(
2475
+ SafeAreaContextView,
2476
+ {
2477
+ style: {
2478
+ backgroundColor: theme.colors?.theme,
2479
+ ...props.viewStyle,
2480
+ flex: 1
2481
+ }
2482
+ },
2483
+ /* @__PURE__ */ React.createElement(StatusBar, { barStyle: "dark-content", backgroundColor: "#f5f5f5" }),
2484
+ /* @__PURE__ */ React.createElement(
2485
+ KeyboardAvoidingView,
2486
+ {
2487
+ behavior: Platform2.OS === "ios" ? "padding" : "height",
2488
+ style: {
2489
+ flex: 1,
2490
+ // 🔹 Ocupa 100% da tela
2491
+ justifyContent: "flex-start"
2492
+ }
2493
+ },
2494
+ /* @__PURE__ */ React.createElement(
2495
+ TouchableWithoutFeedback,
2496
+ {
2497
+ onPress: dismissKeyboard,
2498
+ accessible: false
2499
+ },
2500
+ /* @__PURE__ */ React.createElement(React.Fragment, null, props.children)
2501
+ )
2502
+ )
2503
+ ));
2504
+ }
2505
+
2506
+ // src/elements/UI.tsx
2507
+ var UI = {
2508
+ Order: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "order" }),
2509
+ List: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "list" }),
2510
+ Row: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "row" }),
2511
+ Value: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "value" }),
2512
+ Label: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "label" }),
2513
+ Repeat: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "repeat", props: { search: false } }),
2514
+ Define: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "define" }),
2515
+ Include: (props) => /* @__PURE__ */ React.createElement(UIInclude, { ...props }),
2516
+ Column: ({ type = "column", ...props }) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "column" }),
2517
+ Input: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props }),
2518
+ Text: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "text" }),
2519
+ Textarea: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "textarea" }),
2520
+ Email: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "email" }),
2521
+ Button: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "button" }),
2522
+ Link: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "link" }),
2523
+ Icon: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "icon", transient: true }),
2524
+ Output: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "output" }),
2525
+ Form: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "form" }),
2526
+ Crud: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "crud" }),
2527
+ View: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "view", transient: true }),
2528
+ Bottom: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "bottom" }),
2529
+ Dialog: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "dialog" }),
2530
+ Content: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "content" }),
2531
+ Top: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "top" }),
2532
+ Card: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "card" }),
2533
+ Tab: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "tab" }),
2534
+ Tabs: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "tabs" }),
2535
+ Step: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "tab", layout: "step" }),
2536
+ Stepper: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "tabs", layout: "stepper" }),
2537
+ Money: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "money" }),
2538
+ Chart: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "chart" }),
2539
+ Password: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "password" }),
2540
+ Complete: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "complete" }),
2541
+ Checkbox: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "switch" }),
2542
+ Switch: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "switch" }),
2543
+ Radio: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "radio" }),
2544
+ Select: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "select" }),
2545
+ Toggle: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "toggle" }),
2546
+ Entity: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "entity" }),
2547
+ Element: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "element" }),
2548
+ Quantity: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "quantity" }),
2549
+ Slider: (props) => /* @__PURE__ */ React.createElement(UIElement, { ...props, type: "slider" }),
2550
+ SafeView
2551
+ };
2552
+ var UI_default = UI;
2553
+ export {
2554
+ UI_default as UI
2555
+ };
2556
+ //# sourceMappingURL=index.mjs.map