react-crud-mobile 1.0.242 → 1.0.244

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