react-crud-mobile 1.1.2 → 1.3.1

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