react-crud-mobile 1.0.433 → 1.0.435

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 (34) hide show
  1. package/dist/elements/core/UIView.d.ts +3 -0
  2. package/dist/react-crud-mobile.cjs.development.js +59 -7
  3. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  4. package/dist/react-crud-mobile.cjs.production.min.js +1 -1
  5. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  6. package/dist/react-crud-mobile.esm.js +60 -8
  7. package/dist/react-crud-mobile.esm.js.map +1 -1
  8. package/package.json +72 -71
  9. package/src/elements/UI.tsx +65 -65
  10. package/src/elements/UIChildren.tsx +127 -127
  11. package/src/elements/UIComplete.tsx +14 -14
  12. package/src/elements/UIElement.tsx +523 -518
  13. package/src/elements/UITag.tsx +13 -13
  14. package/src/elements/charts/ElChart.tsx +10 -10
  15. package/src/elements/core/UIAutoComplete.tsx +17 -17
  16. package/src/elements/core/UIButton.tsx +73 -73
  17. package/src/elements/core/UIIcon.tsx +8 -8
  18. package/src/elements/core/UIInclude.tsx +40 -40
  19. package/src/elements/core/UIInput.tsx +69 -69
  20. package/src/elements/core/UILink.tsx +17 -17
  21. package/src/elements/core/UIList.tsx +135 -135
  22. package/src/elements/core/UIListItem.tsx +32 -32
  23. package/src/elements/core/UIListRow.tsx +32 -32
  24. package/src/elements/core/UIModal.tsx +139 -139
  25. package/src/elements/core/UIOption.tsx +17 -17
  26. package/src/elements/core/UIQuantity.tsx +97 -97
  27. package/src/elements/core/UIRadio.tsx +17 -17
  28. package/src/elements/core/UISelect.tsx +122 -122
  29. package/src/elements/core/UISwitch.tsx +26 -26
  30. package/src/elements/core/UIToggle.tsx +102 -102
  31. package/src/elements/core/UIView.tsx +62 -0
  32. package/src/elements/index.ts +1 -1
  33. package/src/elements/tabs/ElTabs.tsx +178 -178
  34. package/src/index.ts +1 -1
@@ -1,518 +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
-
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('value')}>
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
- });
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
+ });