react-crud-mobile 1.0.583 → 1.0.585

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