react-crud-mobile 1.0.439 → 1.0.440

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