react-crud-mobile 1.0.429 → 1.0.431

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 (32) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +2 -2
  2. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  3. package/dist/react-crud-mobile.cjs.production.min.js +1 -1
  4. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  5. package/dist/react-crud-mobile.esm.js +2 -2
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +71 -71
  8. package/src/elements/UI.tsx +65 -65
  9. package/src/elements/UIChildren.tsx +127 -127
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +518 -516
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/UIAutoComplete.tsx +17 -17
  15. package/src/elements/core/UIButton.tsx +73 -73
  16. package/src/elements/core/UIIcon.tsx +8 -8
  17. package/src/elements/core/UIInclude.tsx +40 -40
  18. package/src/elements/core/UIInput.tsx +69 -69
  19. package/src/elements/core/UILink.tsx +17 -17
  20. package/src/elements/core/UIList.tsx +135 -135
  21. package/src/elements/core/UIListItem.tsx +32 -32
  22. package/src/elements/core/UIListRow.tsx +32 -32
  23. package/src/elements/core/UIModal.tsx +139 -139
  24. package/src/elements/core/UIOption.tsx +17 -17
  25. package/src/elements/core/UIQuantity.tsx +97 -97
  26. package/src/elements/core/UIRadio.tsx +17 -17
  27. package/src/elements/core/UISelect.tsx +122 -122
  28. package/src/elements/core/UISwitch.tsx +26 -26
  29. package/src/elements/core/UIToggle.tsx +102 -102
  30. package/src/elements/index.ts +1 -1
  31. package/src/elements/tabs/ElTabs.tsx +178 -178
  32. package/src/index.ts +1 -1
@@ -1,516 +1,518 @@
1
- import React, {
2
- createContext,
3
- useContext,
4
- useEffect,
5
- useLayoutEffect,
6
- useRef,
7
- useState,
8
- } from 'react';
9
- import UIChildren from './UIChildren';
10
- import ElTabs from './tabs/ElTabs';
11
- import ElChart from './charts/ElChart';
12
- import UIComplete from './UIComplete';
13
- import {
14
- Crud,
15
- HtmlUtils,
16
- ScopeUtils,
17
- Utils,
18
- ElementType,
19
- ChildType,
20
- } from 'react-crud-utils';
21
- import UILink from './core/UILink';
22
- import UIIcon from './core/UIIcon';
23
- import UIButton from './core/UIButton';
24
- import UISelect from './core/UISelect';
25
- import UISwitch from './core/UISwitch';
26
- import UIOption from './core/UIOption';
27
- import UIRadio from './core/UIRadio';
28
- import UIInput from './core/UIInput';
29
- import { Image, Linking, StyleSheet, Text, View } from 'react-native';
30
- import UIList from './core/UIList';
31
- import UIToggle from './core/UIToggle';
32
- import UIQuantity from './core/UIQuantity';
33
- import UIModal from './core/UIModal';
34
- import { Ionicons } from '@expo/vector-icons';
35
-
36
- const CrudContext = createContext<any>({});
37
-
38
- export default function UIElement(props: ElementType) {
39
- const ctx = useContext(CrudContext);
40
- const theme = Utils.nvl(props.theme, ctx?.theme);
41
-
42
- let crud: Crud = Utils.nvl(props.crud, ctx?.crud);
43
- let [scope] = useState(ScopeUtils.create({ crud, ...props, theme }));
44
-
45
- crud = scope.crud;
46
-
47
- let [index, setIndex] = useState(0);
48
- let [error, setError]: string | any = useState(null);
49
-
50
- let options: any = scope.getOptions();
51
-
52
- let original = scope.original;
53
- let ref = useRef(null);
54
-
55
- scope.update = () => {
56
- setIndex(++index);
57
- };
58
-
59
- scope.updateElement = () => {
60
- setIndex(++index);
61
- };
62
-
63
- const Custom = () => {
64
- let c: any = original.custom;
65
-
66
- if (c) {
67
- if (typeof c === 'string') {
68
- return (
69
- <UIElement
70
- element={{ value: c, type: 'dummy' }}
71
- crud={crud}
72
- ></UIElement>
73
- );
74
- }
75
-
76
- return (
77
- <UIElement
78
- type={c.type}
79
- tag={c.type}
80
- {...c.props}
81
- crud={crud}
82
- ></UIElement>
83
- );
84
- }
85
-
86
- return <></>;
87
- };
88
-
89
- if (scope.is('type', 'dummy')) {
90
- return <>{scope.getDisplayValue()}</>;
91
- }
92
-
93
- let onCheck = () => {
94
- let v = scope.getValue();
95
- let check = !(v === true);
96
-
97
- onChange({ target: { value: check } });
98
- };
99
-
100
- let onChange = (e: any) => {
101
- let val = e.target.value;
102
-
103
- if (scope.isType('integer', 'int', 'number')) {
104
- val = parseInt(val);
105
- } else if (scope.isType('decimal')) {
106
- val = parseFloat(val);
107
- }
108
-
109
- if (scope.isType('select', 'complete')) {
110
- val = scope.getSelectedItem(val);
111
- }
112
-
113
- scope.changeValue(val);
114
- scope.update();
115
- };
116
-
117
- let onClick = (e: any) => {
118
- scope.call('click');
119
- };
120
-
121
- let defaultsInput: any = {
122
- scope,
123
- crud,
124
- onChange: onChange,
125
- };
126
-
127
- if (scope.isType('password')) {
128
- defaultsInput.type = 'password';
129
- }
130
-
131
- let isChecked = () => {
132
- let v = scope.getValue();
133
-
134
- return v === true;
135
- };
136
-
137
- let hasChildren = () => {
138
- if (scope.isInput()) {
139
- return false;
140
- }
141
-
142
- return !Utils.isEmpty(props.children) || !Utils.isEmpty(props.elements);
143
- };
144
-
145
- let isInput = scope.is(
146
- 'type',
147
- 'text',
148
- 'number',
149
- 'phone',
150
- 'postalCode',
151
- 'money',
152
- 'password',
153
- 'email'
154
- );
155
-
156
- const getStyle = (part?: string) => {
157
- let type = Utils.nvl(original.type, 'none');
158
- let key = Utils.nvl(part, 'root');
159
- let def = { ...styles[key], ...elementStyle?.[type]?.[key] };
160
- let hasChild = hasChildren();
161
-
162
- if (!part && !hasChild) {
163
- def = { ...def };
164
- }
165
-
166
- if (hasChild && part) {
167
- def = { ...def, ...withChildStyles[part] };
168
- }
169
-
170
- if (isInput) {
171
- def = { ...def, ...elementStyle.input[key] };
172
- }
173
-
174
- return { ...def, ...scope.getStyle(part, def) };
175
- };
176
-
177
- let elStyle = getStyle('element');
178
-
179
- let defaultsUI: any = {
180
- required: scope.isRequired(),
181
- size: 'small',
182
- scope,
183
- crud,
184
- style: elStyle,
185
- placeholder: scope.attr('placeholder', 'Digite aqui'),
186
- };
187
-
188
- scope.error = (msg: string) => {
189
- error = msg;
190
- setError(msg);
191
- };
192
-
193
- if (!original.list?.url && !original.load?.url) {
194
- scope.start();
195
- }
196
-
197
- useEffect(() => {
198
- scope.start();
199
- });
200
-
201
- const CustomIcon = () => {
202
- if (typeof original.icon === 'string') {
203
- return <Ionicons name={original.icon} style={scope.getStyle('icon')} />;
204
- }
205
- return <>{original.icon}</>;
206
- };
207
-
208
- scope.open = (args: any) => {
209
- Linking.openURL(args.url);
210
- };
211
-
212
- useLayoutEffect(() => {
213
- if (ref?.current && scope.is('type', 'card', 'list', 'tabs', 'stepper')) {
214
- let el: any = ref?.current;
215
-
216
- if (el?.classList) {
217
- let bg = HtmlUtils.getBGColor(el);
218
-
219
- if (bg === 'rgb(255, 255, 255)') {
220
- el.classList.add('ui-dark');
221
- } else {
222
- el.classList.add('ui-light');
223
- }
224
- }
225
- }
226
- });
227
-
228
- const isShowLabel = () => {
229
- if (
230
- typeof original.label !== 'undefined' &&
231
- original.label !== false &&
232
- !scope.isType('button', 'dialog', 'modal')
233
- ) {
234
- return true;
235
- }
236
-
237
- return false;
238
- };
239
-
240
- const isShowInner = () => {
241
- if (hasChildren()) {
242
- return false;
243
- }
244
- return true;
245
- };
246
-
247
- if (!scope.isRendered() || scope.is('type', 'define')) {
248
- return <></>;
249
- }
250
-
251
- const isShowChild = () => {
252
- if (
253
- scope.is(
254
- 'type',
255
- 'tabs',
256
- 'grid',
257
- 'list',
258
- 'define',
259
- 'repeat',
260
- 'modal',
261
- 'dialog',
262
- 'chart'
263
- )
264
- ) {
265
- return false;
266
- }
267
-
268
- return true;
269
- };
270
-
271
- return (
272
- <CrudContext.Provider value={{ crud, theme }}>
273
- <View ref={ref} style={getStyle()}>
274
- <>
275
- {isShowLabel() && (
276
- <Text style={getStyle('label')}>{scope.getLabel()}</Text>
277
- )}
278
- {isShowInner() && (
279
- <>
280
- <View style={getStyle('inner')}>
281
- {scope.is('type', 'button') && (
282
- <UIButton
283
- {...defaultsUI}
284
- onClick={onClick}
285
- variant={scope.attr('variant', 'outlined')}
286
- >
287
- {original.icon && <CustomIcon />}
288
- {original.label && (
289
- <Text style={scope.getPart('label', 'button')}>
290
- {scope.getLabel()}
291
- </Text>
292
- )}
293
- </UIButton>
294
- )}
295
- {scope.is('type', 'icon') && (
296
- <UIIcon
297
- {...defaultsUI}
298
- onClick={onClick}
299
- variant={scope.attr('variant', 'outlined')}
300
- >
301
- {scope.getDisplayValue()}
302
- </UIIcon>
303
- )}
304
- {scope.is('type', 'link') && (
305
- <UILink
306
- {...defaultsUI}
307
- onClick={onClick}
308
- variant={scope.attr('variant', 'outlined')}
309
- >
310
- {original.icon && <CustomIcon />}
311
- {original.label && (
312
- <Text style={scope.getPart('label', 'link')}>
313
- {scope.getLabel()}
314
- </Text>
315
- )}
316
- </UILink>
317
- )}
318
- {isInput && (
319
- <UIInput
320
- {...defaultsInput}
321
- {...defaultsUI}
322
- InputProps={{ ...original.inputProps }}
323
- />
324
- )}
325
- {scope.is('type', 'complete', 'autocomplete') && (
326
- <UIComplete
327
- scope={scope}
328
- defaultsInput={defaultsInput}
329
- defaultsUI={defaultsUI}
330
- />
331
- )}
332
- {scope.is('type', 'quantity') && (
333
- <UIQuantity
334
- scope={scope}
335
- defaultsInput={defaultsInput}
336
- defaultsUI={defaultsUI}
337
- />
338
- )}
339
- {scope.is('type', 'checkbox', 'boolean', 'switch') && (
340
- <UISwitch
341
- checked={isChecked()}
342
- {...defaultsInput}
343
- onChange={onCheck}
344
- />
345
- )}
346
- {scope.is('type', 'select') && (
347
- <UISelect
348
- {...defaultsInput}
349
- {...defaultsUI}
350
- value={scope.getSelectedValue()}
351
- />
352
- )}
353
- {scope.is('type', 'toggle') && (
354
- <UIToggle
355
- {...defaultsInput}
356
- {...defaultsUI}
357
- value={scope.getSelectedValue()}
358
- />
359
- )}
360
- {scope.is('type', 'radio') && (
361
- <UIRadio {...defaultsInput} {...defaultsUI} row>
362
- {options.map((row: any, i: number) => (
363
- <UIOption
364
- key={'i' + i}
365
- control={<UIRadio {...defaultsUI} />}
366
- label={row.label}
367
- value={row.value}
368
- />
369
- ))}
370
- </UIRadio>
371
- )}
372
- {scope.is('type', 'custom') && <Custom />}
373
- {scope.is('type', 'column') && (
374
- <>
375
- {scope.is('format', 'img') && (
376
- <Image source={scope.getDisplayValue()} />
377
- )}
378
- {scope.is('format', 'icon') && (
379
- <UIIcon scope={scope} crud={crud} />
380
- )}
381
- {!scope.is('format', 'icon', 'img') && (
382
- <Text>{scope.getDisplayValue()}</Text>
383
- )}
384
- </>
385
- )}
386
- {scope.is('type', 'output', 'value') && (
387
- <Text>{scope.getDisplayValue()}</Text>
388
- )}
389
- </View>
390
- {error && <View style={getStyle('error')}>{error}</View>}
391
- </>
392
- )}
393
- {scope.isType('type', 'list', 'repeat') && (
394
- <UIList {...props} scope={scope} crud={crud} />
395
- )}
396
- {scope.isType('type', 'dialog') && (
397
- <UIModal {...props} scope={scope} crud={crud} />
398
- )}
399
- {scope.isType('type', 'chart') && (
400
- <ElChart {...props} scope={scope} crud={crud} />
401
- )}
402
- {scope.isType('type', 'tabs') && (
403
- <ElTabs {...props} scope={scope} crud={crud} />
404
- )}
405
-
406
- {isShowChild() && (
407
- <UIChildren
408
- {...props}
409
- scope={scope}
410
- crud={crud}
411
- style={getStyle('inner')}
412
- />
413
- )}
414
- </>
415
- </View>
416
- </CrudContext.Provider>
417
- );
418
- }
419
-
420
- const box: any = {
421
- backgroundColor: 'white',
422
- padding: 16,
423
- borderRadius: 10,
424
- width: '100%',
425
- shadowColor: '#888', // iOS
426
- shadowOffset: { width: 0, height: 1 }, // iOS
427
- shadowOpacity: 0.25, // iOS
428
- shadowRadius: 3.84, // iOS
429
- elevation: 3, // Android
430
- };
431
-
432
- const elementStyle: any = {};
433
-
434
- elementStyle.card = StyleSheet.create({
435
- root: {
436
- ...box,
437
- },
438
- inner: {
439
- flex: 1,
440
- width: '100%',
441
- paddingBottom: 10,
442
- paddingTop: 5,
443
- alignSelf: 'flex-start',
444
- flexDirection: 'row',
445
- flexWrap: 'wrap',
446
- gap: 10,
447
- },
448
- });
449
-
450
- elementStyle.input = StyleSheet.create({
451
- inner: {
452
- flex: 1,
453
- width: '100%',
454
- paddingBottom: 0,
455
- paddingTop: 0,
456
- alignItems: 'center',
457
- borderWidth: 1,
458
- borderColor: 'borderColor',
459
- borderRadius: 20,
460
- paddingHorizontal: 15,
461
- alignSelf: 'flex-start',
462
- flexDirection: 'row',
463
- flexWrap: 'wrap',
464
- },
465
- });
466
-
467
- elementStyle.quantity = {
468
- inner: {
469
- ...box,
470
- padding: 5,
471
- borderRadius: 25,
472
- flexWrap: 'nowrap',
473
- flex: 1,
474
- flexDirection: 'row',
475
- justifyContent: 'center',
476
- alignItems: 'center',
477
- },
478
- };
479
-
480
- elementStyle.toggle = StyleSheet.create({
481
- inner: {
482
- ...box,
483
- flex: 1,
484
- width: '100%',
485
- gap: 10,
486
- justifyContent: 'center',
487
- flexDirection: 'row',
488
- paddingHorizontal: 10,
489
- paddingVertical: 0,
490
- alignSelf: 'flex-start',
491
- flexWrap: 'nowrap',
492
- },
493
- });
494
-
495
- const styles = StyleSheet.create({
496
- root: {
497
- gap: 5,
498
- flexDirection: 'column',
499
- flexWrap: 'wrap',
500
- width: '100%',
501
- alignItems: 'flex-start',
502
- },
503
- label: { width: '100%', fontWeight: 500, fontSize: 12 },
504
- inner: { width: '100%', marginBottom: 10 },
505
- });
506
-
507
- const withChildStyles = StyleSheet.create({
508
- root: {
509
- gap: 10,
510
- },
511
- label: {
512
- width: '100%',
513
- fontWeight: 500,
514
- fontSize: 24,
515
- },
516
- });
1
+ import React, {
2
+ createContext,
3
+ useContext,
4
+ useEffect,
5
+ useLayoutEffect,
6
+ useRef,
7
+ useState,
8
+ } from 'react';
9
+ import UIChildren from './UIChildren';
10
+ import ElTabs from './tabs/ElTabs';
11
+ import ElChart from './charts/ElChart';
12
+ import UIComplete from './UIComplete';
13
+ import {
14
+ Crud,
15
+ HtmlUtils,
16
+ ScopeUtils,
17
+ Utils,
18
+ ElementType,
19
+ ChildType,
20
+ } from 'react-crud-utils';
21
+ import UILink from './core/UILink';
22
+ import UIIcon from './core/UIIcon';
23
+ import UIButton from './core/UIButton';
24
+ import UISelect from './core/UISelect';
25
+ import UISwitch from './core/UISwitch';
26
+ import UIOption from './core/UIOption';
27
+ import UIRadio from './core/UIRadio';
28
+ import UIInput from './core/UIInput';
29
+ import { Image, Linking, StyleSheet, Text, View } from 'react-native';
30
+ import UIList from './core/UIList';
31
+ import UIToggle from './core/UIToggle';
32
+ import UIQuantity from './core/UIQuantity';
33
+ import UIModal from './core/UIModal';
34
+ import { Ionicons } from '@expo/vector-icons';
35
+
36
+ const CrudContext = createContext<any>({});
37
+
38
+ export default function UIElement(props: ElementType) {
39
+ const ctx = useContext(CrudContext);
40
+ const theme = Utils.nvl(props.theme, ctx?.theme);
41
+
42
+ let crud: Crud = Utils.nvl(props.crud, ctx?.crud);
43
+ let [scope] = useState(ScopeUtils.create({ crud, ...props, theme }));
44
+
45
+ crud = scope.crud;
46
+
47
+ let [index, setIndex] = useState(0);
48
+ let [error, setError]: string | any = useState(null);
49
+
50
+ let options: any = scope.getOptions();
51
+
52
+ let original = scope.original;
53
+ let ref = useRef(null);
54
+
55
+ scope.update = () => {
56
+ setIndex(++index);
57
+ };
58
+
59
+ scope.updateElement = () => {
60
+ setIndex(++index);
61
+ };
62
+
63
+ const Custom = () => {
64
+ let c: any = original.custom;
65
+
66
+ if (c) {
67
+ if (typeof c === 'string') {
68
+ return (
69
+ <UIElement
70
+ element={{ value: c, type: 'dummy' }}
71
+ crud={crud}
72
+ ></UIElement>
73
+ );
74
+ }
75
+
76
+ return (
77
+ <UIElement
78
+ type={c.type}
79
+ tag={c.type}
80
+ {...c.props}
81
+ crud={crud}
82
+ ></UIElement>
83
+ );
84
+ }
85
+
86
+ return <></>;
87
+ };
88
+
89
+ if (scope.is('type', 'dummy')) {
90
+ return <>{scope.getDisplayValue()}</>;
91
+ }
92
+
93
+ let onCheck = () => {
94
+ let v = scope.getValue();
95
+ let check = !(v === true);
96
+
97
+ onChange({ target: { value: check } });
98
+ };
99
+
100
+ let onChange = (e: any) => {
101
+ let val = e.target.value;
102
+
103
+ if (scope.isType('integer', 'int', 'number')) {
104
+ val = parseInt(val);
105
+ } else if (scope.isType('decimal')) {
106
+ val = parseFloat(val);
107
+ }
108
+
109
+ if (scope.isType('select', 'complete')) {
110
+ val = scope.getSelectedItem(val);
111
+ }
112
+
113
+ scope.changeValue(val);
114
+ scope.update();
115
+ };
116
+
117
+ let onClick = (e: any) => {
118
+ scope.call('click');
119
+ };
120
+
121
+ let defaultsInput: any = {
122
+ scope,
123
+ crud,
124
+ onChange: onChange,
125
+ };
126
+
127
+ if (scope.isType('password')) {
128
+ defaultsInput.type = 'password';
129
+ }
130
+
131
+ let isChecked = () => {
132
+ let v = scope.getValue();
133
+
134
+ return v === true;
135
+ };
136
+
137
+ let hasChildren = () => {
138
+ if (scope.isInput()) {
139
+ return false;
140
+ }
141
+
142
+ return !Utils.isEmpty(props.children) || !Utils.isEmpty(props.elements);
143
+ };
144
+
145
+ let isInput = scope.is(
146
+ 'type',
147
+ 'text',
148
+ 'number',
149
+ 'phone',
150
+ 'postalCode',
151
+ 'money',
152
+ 'password',
153
+ 'email'
154
+ );
155
+
156
+ const getStyle = (part?: string) => {
157
+ let type = Utils.nvl(original.type, 'none');
158
+ let key = Utils.nvl(part, 'root');
159
+ let def = { ...styles[key], ...elementStyle?.[type]?.[key] };
160
+ let hasChild = hasChildren();
161
+
162
+ if (!part && !hasChild) {
163
+ def = { ...def };
164
+ }
165
+
166
+ if (hasChild && part) {
167
+ def = { ...def, ...withChildStyles[part] };
168
+ }
169
+
170
+ if (isInput) {
171
+ def = { ...def, ...elementStyle.input[key] };
172
+ }
173
+
174
+ return { ...def, ...scope.getStyle(part, def) };
175
+ };
176
+
177
+ let elStyle = getStyle('element');
178
+
179
+ let defaultsUI: any = {
180
+ required: scope.isRequired(),
181
+ size: 'small',
182
+ scope,
183
+ crud,
184
+ style: elStyle,
185
+ placeholder: scope.attr('placeholder', 'Digite aqui'),
186
+ };
187
+
188
+ scope.error = (msg: string) => {
189
+ error = msg;
190
+ setError(msg);
191
+ };
192
+
193
+ if (!original.list?.url && !original.load?.url) {
194
+ scope.start();
195
+ }
196
+
197
+ useEffect(() => {
198
+ scope.start();
199
+ });
200
+
201
+ const CustomIcon = () => {
202
+ if (typeof original.icon === 'string') {
203
+ return <Ionicons name={original.icon} style={scope.getStyle('icon')} />;
204
+ }
205
+ return <>{original.icon}</>;
206
+ };
207
+
208
+ scope.open = (args: any) => {
209
+ Linking.openURL(args.url);
210
+ };
211
+
212
+ useLayoutEffect(() => {
213
+ if (ref?.current && scope.is('type', 'card', 'list', 'tabs', 'stepper')) {
214
+ let el: any = ref?.current;
215
+
216
+ if (el?.classList) {
217
+ let bg = HtmlUtils.getBGColor(el);
218
+
219
+ if (bg === 'rgb(255, 255, 255)') {
220
+ el.classList.add('ui-dark');
221
+ } else {
222
+ el.classList.add('ui-light');
223
+ }
224
+ }
225
+ }
226
+ });
227
+
228
+ const isShowLabel = () => {
229
+ if (
230
+ typeof original.label !== 'undefined' &&
231
+ original.label !== false &&
232
+ !scope.isType('button', 'dialog', 'modal')
233
+ ) {
234
+ return true;
235
+ }
236
+
237
+ return false;
238
+ };
239
+
240
+ const isShowInner = () => {
241
+ if (hasChildren()) {
242
+ return false;
243
+ }
244
+ return true;
245
+ };
246
+
247
+ if (!scope.isRendered() || scope.is('type', 'define')) {
248
+ return <></>;
249
+ }
250
+
251
+ const isShowChild = () => {
252
+ if (
253
+ scope.is(
254
+ 'type',
255
+ 'tabs',
256
+ 'grid',
257
+ 'list',
258
+ 'define',
259
+ 'repeat',
260
+ 'modal',
261
+ 'dialog',
262
+ 'chart'
263
+ )
264
+ ) {
265
+ return false;
266
+ }
267
+
268
+ return true;
269
+ };
270
+
271
+ return (
272
+ <CrudContext.Provider value={{ crud, theme }}>
273
+ <View ref={ref} style={getStyle()}>
274
+ <>
275
+ {isShowLabel() && (
276
+ <Text style={getStyle('label')}>{scope.getLabel()}</Text>
277
+ )}
278
+ {isShowInner() && (
279
+ <>
280
+ <View style={getStyle('inner')}>
281
+ {scope.is('type', 'button') && (
282
+ <UIButton
283
+ {...defaultsUI}
284
+ onClick={onClick}
285
+ variant={scope.attr('variant', 'outlined')}
286
+ >
287
+ {original.icon && <CustomIcon />}
288
+ {original.label && (
289
+ <Text style={scope.getPart('label', 'button')}>
290
+ {scope.getLabel()}
291
+ </Text>
292
+ )}
293
+ </UIButton>
294
+ )}
295
+ {scope.is('type', 'icon') && (
296
+ <UIIcon
297
+ {...defaultsUI}
298
+ onClick={onClick}
299
+ variant={scope.attr('variant', 'outlined')}
300
+ >
301
+ {scope.getDisplayValue()}
302
+ </UIIcon>
303
+ )}
304
+ {scope.is('type', 'link') && (
305
+ <UILink
306
+ {...defaultsUI}
307
+ onClick={onClick}
308
+ variant={scope.attr('variant', 'outlined')}
309
+ >
310
+ {original.icon && <CustomIcon />}
311
+ {original.label && (
312
+ <Text style={scope.getPart('label', 'link')}>
313
+ {scope.getLabel()}
314
+ </Text>
315
+ )}
316
+ </UILink>
317
+ )}
318
+ {isInput && (
319
+ <UIInput
320
+ {...defaultsInput}
321
+ {...defaultsUI}
322
+ InputProps={{ ...original.inputProps }}
323
+ />
324
+ )}
325
+ {scope.is('type', 'complete', 'autocomplete') && (
326
+ <UIComplete
327
+ scope={scope}
328
+ defaultsInput={defaultsInput}
329
+ defaultsUI={defaultsUI}
330
+ />
331
+ )}
332
+ {scope.is('type', 'quantity') && (
333
+ <UIQuantity
334
+ scope={scope}
335
+ defaultsInput={defaultsInput}
336
+ defaultsUI={defaultsUI}
337
+ />
338
+ )}
339
+ {scope.is('type', 'checkbox', 'boolean', 'switch') && (
340
+ <UISwitch
341
+ checked={isChecked()}
342
+ {...defaultsInput}
343
+ onChange={onCheck}
344
+ />
345
+ )}
346
+ {scope.is('type', 'select') && (
347
+ <UISelect
348
+ {...defaultsInput}
349
+ {...defaultsUI}
350
+ value={scope.getSelectedValue()}
351
+ />
352
+ )}
353
+ {scope.is('type', 'toggle') && (
354
+ <UIToggle
355
+ {...defaultsInput}
356
+ {...defaultsUI}
357
+ value={scope.getSelectedValue()}
358
+ />
359
+ )}
360
+ {scope.is('type', 'radio') && (
361
+ <UIRadio {...defaultsInput} {...defaultsUI} row>
362
+ {options.map((row: any, i: number) => (
363
+ <UIOption
364
+ key={'i' + i}
365
+ control={<UIRadio {...defaultsUI} />}
366
+ label={row.label}
367
+ value={row.value}
368
+ />
369
+ ))}
370
+ </UIRadio>
371
+ )}
372
+ {scope.is('type', 'custom') && <Custom />}
373
+ {scope.is('type', 'column') && (
374
+ <>
375
+ {scope.is('format', 'img') && (
376
+ <Image source={scope.getDisplayValue()} />
377
+ )}
378
+ {scope.is('format', 'icon') && (
379
+ <UIIcon scope={scope} crud={crud} />
380
+ )}
381
+ {!scope.is('format', 'icon', 'img') && (
382
+ <Text>{scope.getDisplayValue()}</Text>
383
+ )}
384
+ </>
385
+ )}
386
+ {scope.is('type', 'output', 'value') && (
387
+ <Text style={getStyle('element')}>
388
+ {scope.getDisplayValue()}
389
+ </Text>
390
+ )}
391
+ </View>
392
+ {error && <View style={getStyle('error')}>{error}</View>}
393
+ </>
394
+ )}
395
+ {scope.isType('type', 'list', 'repeat') && (
396
+ <UIList {...props} scope={scope} crud={crud} />
397
+ )}
398
+ {scope.isType('type', 'dialog') && (
399
+ <UIModal {...props} scope={scope} crud={crud} />
400
+ )}
401
+ {scope.isType('type', 'chart') && (
402
+ <ElChart {...props} scope={scope} crud={crud} />
403
+ )}
404
+ {scope.isType('type', 'tabs') && (
405
+ <ElTabs {...props} scope={scope} crud={crud} />
406
+ )}
407
+
408
+ {isShowChild() && (
409
+ <UIChildren
410
+ {...props}
411
+ scope={scope}
412
+ crud={crud}
413
+ style={getStyle('inner')}
414
+ />
415
+ )}
416
+ </>
417
+ </View>
418
+ </CrudContext.Provider>
419
+ );
420
+ }
421
+
422
+ const box: any = {
423
+ backgroundColor: 'white',
424
+ padding: 16,
425
+ borderRadius: 10,
426
+ width: '100%',
427
+ shadowColor: '#888', // iOS
428
+ shadowOffset: { width: 0, height: 1 }, // iOS
429
+ shadowOpacity: 0.25, // iOS
430
+ shadowRadius: 3.84, // iOS
431
+ elevation: 3, // Android
432
+ };
433
+
434
+ const elementStyle: any = {};
435
+
436
+ elementStyle.card = StyleSheet.create({
437
+ root: {
438
+ ...box,
439
+ },
440
+ inner: {
441
+ flex: 1,
442
+ width: '100%',
443
+ paddingBottom: 10,
444
+ paddingTop: 5,
445
+ alignSelf: 'flex-start',
446
+ flexDirection: 'row',
447
+ flexWrap: 'wrap',
448
+ gap: 10,
449
+ },
450
+ });
451
+
452
+ elementStyle.input = StyleSheet.create({
453
+ inner: {
454
+ flex: 1,
455
+ width: '100%',
456
+ paddingBottom: 0,
457
+ paddingTop: 0,
458
+ alignItems: 'center',
459
+ borderWidth: 1,
460
+ borderColor: 'borderColor',
461
+ borderRadius: 20,
462
+ paddingHorizontal: 15,
463
+ alignSelf: 'flex-start',
464
+ flexDirection: 'row',
465
+ flexWrap: 'wrap',
466
+ },
467
+ });
468
+
469
+ elementStyle.quantity = {
470
+ inner: {
471
+ ...box,
472
+ padding: 5,
473
+ borderRadius: 25,
474
+ flexWrap: 'nowrap',
475
+ flex: 1,
476
+ flexDirection: 'row',
477
+ justifyContent: 'center',
478
+ alignItems: 'center',
479
+ },
480
+ };
481
+
482
+ elementStyle.toggle = StyleSheet.create({
483
+ inner: {
484
+ ...box,
485
+ flex: 1,
486
+ width: '100%',
487
+ gap: 10,
488
+ justifyContent: 'center',
489
+ flexDirection: 'row',
490
+ paddingHorizontal: 10,
491
+ paddingVertical: 0,
492
+ alignSelf: 'flex-start',
493
+ flexWrap: 'nowrap',
494
+ },
495
+ });
496
+
497
+ const styles = StyleSheet.create({
498
+ root: {
499
+ gap: 5,
500
+ flexDirection: 'column',
501
+ flexWrap: 'wrap',
502
+ width: '100%',
503
+ alignItems: 'flex-start',
504
+ },
505
+ label: { width: '100%', fontWeight: 500, fontSize: 12 },
506
+ inner: { width: '100%' },
507
+ });
508
+
509
+ const withChildStyles = StyleSheet.create({
510
+ root: {
511
+ gap: 10,
512
+ },
513
+ label: {
514
+ width: '100%',
515
+ fontWeight: 500,
516
+ fontSize: 24,
517
+ },
518
+ });