react-crud-mobile 1.3.303 → 1.3.305

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 (42) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +4 -1
  2. package/dist/react-crud-mobile.cjs.development.js.map +1 -1
  3. package/dist/react-crud-mobile.cjs.production.min.js +1 -1
  4. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
  5. package/dist/react-crud-mobile.esm.js +4 -1
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +77 -77
  8. package/src/elements/UI.tsx +77 -77
  9. package/src/elements/UIChildren.tsx +142 -142
  10. package/src/elements/UIComplete.tsx +14 -14
  11. package/src/elements/UIElement.tsx +858 -858
  12. package/src/elements/UITag.tsx +13 -13
  13. package/src/elements/charts/ElChart.tsx +10 -10
  14. package/src/elements/core/GestureView.tsx +16 -16
  15. package/src/elements/core/SafeView.tsx +63 -63
  16. package/src/elements/core/UIAutoComplete.tsx +17 -17
  17. package/src/elements/core/UIButton.tsx +143 -143
  18. package/src/elements/core/UIHeader.tsx +38 -38
  19. package/src/elements/core/UIIcon.tsx +25 -25
  20. package/src/elements/core/UIInclude.tsx +40 -40
  21. package/src/elements/core/UIInput.tsx +133 -132
  22. package/src/elements/core/UILink.tsx +17 -17
  23. package/src/elements/core/UIList.tsx +180 -180
  24. package/src/elements/core/UIListItem.tsx +32 -32
  25. package/src/elements/core/UIListRow.tsx +132 -132
  26. package/src/elements/core/UIModal.tsx +212 -212
  27. package/src/elements/core/UIOption.tsx +17 -17
  28. package/src/elements/core/UIOrder.tsx +194 -194
  29. package/src/elements/core/UIQuantity.tsx +98 -98
  30. package/src/elements/core/UIRadio.tsx +17 -17
  31. package/src/elements/core/UISelect.tsx +175 -175
  32. package/src/elements/core/UISlider.tsx +61 -61
  33. package/src/elements/core/UIStatusBar.tsx +5 -5
  34. package/src/elements/core/UISwitch.tsx +27 -27
  35. package/src/elements/core/UIToast.tsx +44 -44
  36. package/src/elements/core/UIToggle.tsx +102 -102
  37. package/src/elements/core/UIView.tsx +69 -69
  38. package/src/elements/index.ts +1 -1
  39. package/src/elements/tabs/ElTabs.tsx +178 -178
  40. package/src/hooks/useIsVisible.ts +39 -39
  41. package/src/index.ts +1 -1
  42. package/src/utils/MobileUtils.ts +12 -12
@@ -1,858 +1,858 @@
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
- MethodType,
20
- ActionType,
21
- ComponentUtils,
22
- CrudUtils,
23
- ViewUtils,
24
- Scope,
25
- } from 'react-crud-utils';
26
- import UILink from './core/UILink';
27
- import UIIcon from './core/UIIcon';
28
- import UIButton from './core/UIButton';
29
- import UISelect from './core/UISelect';
30
- import UISwitch from './core/UISwitch';
31
- import UISlider from './core/UISlider';
32
- import UIOption from './core/UIOption';
33
- import UIRadio from './core/UIRadio';
34
- import UIInput from './core/UIInput';
35
- import {
36
- Alert,
37
- Image,
38
- Linking,
39
- StyleSheet,
40
- Text,
41
- TouchableHighlight,
42
- View,
43
- } from 'react-native';
44
- import UIList from './core/UIList';
45
- import UIToggle from './core/UIToggle';
46
- import UIQuantity from './core/UIQuantity';
47
- import UIModal from './core/UIModal';
48
- import { Ionicons } from '@expo/vector-icons';
49
- import UIView from './core/UIView';
50
- import Toast from 'react-native-toast-message';
51
- import UIOrder from './core/UIOrder';
52
-
53
- const CrudContext = createContext<any>({});
54
-
55
- export default function UIElement(props: ElementType) {
56
- const ctx = useContext(CrudContext);
57
- const theme = Utils.nvl(props.theme, ctx?.theme);
58
-
59
- let crud: Crud = Utils.nvl(props.crud, ctx?.crud);
60
- let [scope] = useState<Scope>(ScopeUtils.create({ crud, ...props, theme }));
61
- let [index, setIndex] = useState(0);
62
- let [error, setError]: string | any = useState(null);
63
-
64
- scope.compile(props);
65
-
66
- crud = scope.crud;
67
-
68
- let options: any = scope.getOptions();
69
-
70
- let original = scope.original;
71
- let ref = useRef(null);
72
-
73
- scope.update = () => {
74
- setIndex(++index);
75
- };
76
-
77
- scope.updateElement = () => {
78
- setIndex(++index);
79
- };
80
-
81
- scope.toast = (message: string, type = 'info', args?: any) => {
82
- Toast.show({
83
- type, // 'success' | 'error' | 'info'
84
- text1: message,
85
- position: 'bottom', // 'top' é outra opção
86
- visibilityTime: 3000, // tempo que fica visível em ms
87
- ...args,
88
- });
89
- };
90
-
91
- scope.prompt = (args: MethodType) => {
92
- let event = args.event as ActionType;
93
-
94
- if (event) {
95
- let message = 'Você tem certeza que deseja continuar?';
96
- let title = 'Atenção';
97
- let prompt = event.prompt;
98
-
99
- if (typeof prompt === 'string') {
100
- message = prompt;
101
- }
102
-
103
- if (typeof prompt === 'object') {
104
- message = Utils.nvl(prompt.message, message);
105
- title = Utils.nvl(prompt.title, title);
106
- }
107
-
108
- Alert.alert(
109
- title,
110
- message,
111
- [
112
- {
113
- text: 'Cancelar',
114
- style: 'cancel',
115
- },
116
- {
117
- text: 'Confirmar',
118
- onPress: () => scope.execute(args),
119
- },
120
- ],
121
- { cancelable: false }
122
- );
123
- }
124
- };
125
- const Custom = () => {
126
- let c: any = original.custom;
127
-
128
- if (c) {
129
- if (typeof c === 'string') {
130
- return (
131
- <UIElement
132
- element={{ value: c, type: 'dummy' }}
133
- crud={crud}
134
- ></UIElement>
135
- );
136
- }
137
-
138
- return (
139
- <UIElement
140
- type={c.type}
141
- tag={c.type}
142
- {...c.props}
143
- crud={crud}
144
- ></UIElement>
145
- );
146
- }
147
-
148
- return <></>;
149
- };
150
-
151
- if (scope.is('type', 'dummy')) {
152
- return <>{scope.getDisplayValue()}</>;
153
- }
154
-
155
- let onCheck = () => {
156
- let v = scope.getValue();
157
- let check = !(v === true);
158
-
159
- onChange({ target: { value: check } });
160
- };
161
-
162
- let onChange = (e: any) => {
163
- let val = e.target.value;
164
-
165
- if (scope.isType('integer', 'int', 'number')) {
166
- val = parseInt(val);
167
- } else if (scope.isType('decimal')) {
168
- val = parseFloat(val);
169
- }
170
-
171
- if (scope.isType('select', 'complete')) {
172
- val = scope.getSelectedItem(val);
173
- }
174
-
175
- scope.changeValue(val);
176
- scope.update();
177
- };
178
-
179
- let onClick = (e: any) => {
180
- if (scope.currentDialog?.component) return;
181
-
182
- scope.call('click');
183
- };
184
-
185
- let defaultsInput: any = {
186
- scope,
187
- crud,
188
- onChange: onChange,
189
- };
190
-
191
- if (scope.isType('password')) {
192
- defaultsInput.type = 'password';
193
- }
194
-
195
- let isChecked = () => {
196
- let v = scope.getValue();
197
-
198
- return v === true;
199
- };
200
-
201
- let hasChildren = () => {
202
- if (scope.isInput()) {
203
- return false;
204
- }
205
-
206
- return !Utils.isEmpty(props.children) || !Utils.isEmpty(props.elements);
207
- };
208
-
209
- let isInput = scope.is(
210
- 'type',
211
- 'text',
212
- 'textarea',
213
- 'number',
214
- 'integer',
215
- 'int',
216
- 'phone',
217
- 'postalCode',
218
- 'money',
219
- 'password',
220
- 'email'
221
- );
222
-
223
- const getStyle = (part?: string, extra?: any) => {
224
- let type = Utils.nvl(original.type, 'none');
225
- let key = Utils.nvl(part, 'root');
226
- let def = { ...styles[key] };
227
- let hasChild = hasChildren();
228
-
229
- type = Utils.nvl(original.layout, type);
230
-
231
- if (!part && !hasChild) {
232
- def = { ...def };
233
- }
234
-
235
- if (scope.isInput()) {
236
- def = { ...def, ...elementStyle.input[key] };
237
- }
238
-
239
- def = { ...def, ...elementStyle?.[type]?.[key] };
240
-
241
- if (hasChild && part) {
242
- def = { ...def, ...withChildStyles[part] };
243
- }
244
-
245
- return { ...def, ...scope.getStyle(part, { ...def, ...extra }) };
246
- };
247
-
248
- let elStyle = getStyle('element');
249
-
250
- let defaultsUI: any = {
251
- required: scope.isRequired(),
252
- size: 'small',
253
- scope,
254
- crud,
255
- style: elStyle,
256
- placeholder: scope.attr('placeholder', 'Digite aqui'),
257
- };
258
-
259
- scope.error = (msg: string) => {
260
- error = msg;
261
- setError(msg);
262
- };
263
-
264
- if (!original.list?.url && !original.load?.url) {
265
- scope.start();
266
- }
267
-
268
- useEffect(() => {
269
- scope.start();
270
- });
271
-
272
- const CustomIcon = () => {
273
- if (typeof original.icon === 'string') {
274
- return <Ionicons name={original.icon} style={scope.getStyle('icon')} />;
275
- }
276
- return <>{original.icon}</>;
277
- };
278
-
279
- scope.open = (args: any) => {
280
- Linking.openURL(args.url);
281
- };
282
-
283
- useLayoutEffect(() => {
284
- if (ref?.current && scope.is('type', 'card', 'list', 'tabs', 'stepper')) {
285
- let el: any = ref?.current;
286
-
287
- if (el?.classList) {
288
- let bg = HtmlUtils.getBGColor(el);
289
-
290
- if (bg === 'rgb(255, 255, 255)') {
291
- el.classList.add('ui-dark');
292
- } else {
293
- el.classList.add('ui-light');
294
- }
295
- }
296
- }
297
- });
298
-
299
- const isShowLabel = () => {
300
- if (
301
- typeof original.label !== 'undefined' &&
302
- original.label !== false &&
303
- !scope.isType('button', 'dialog', 'modal')
304
- ) {
305
- return true;
306
- }
307
-
308
- return false;
309
- };
310
-
311
- const isShowInner = () => {
312
- if (hasChildren()) {
313
- return false;
314
- }
315
- return true;
316
- };
317
-
318
- if (!scope.isRendered() || scope.is('type', 'define')) {
319
- return <></>;
320
- }
321
-
322
- const isShowChild = () => {
323
- if (
324
- scope.isType(
325
- 'tabs',
326
- 'view',
327
- 'grid',
328
- 'list',
329
- 'define',
330
- 'repeat',
331
- 'modal',
332
- 'dialog',
333
- 'chart'
334
- )
335
- ) {
336
- return false;
337
- }
338
-
339
- return true;
340
- };
341
-
342
- let isTouch =
343
- !scope.isType('input', 'grid', 'list', 'order', 'repeat') && original.click;
344
- let custom: any = {};
345
-
346
- if (isTouch) {
347
- custom.underlayColor = 'transparent';
348
- custom.onPress = onClick;
349
- }
350
-
351
- let Tag = (props: any) => {
352
- let Aux: any = View;
353
-
354
- if (isTouch) {
355
- Aux = TouchableHighlight;
356
- }
357
-
358
- if (scope.isType('dialog', 'order') || original.transient) {
359
- return <>{props.children}</>;
360
- }
361
-
362
- return <Aux {...props} />;
363
- };
364
-
365
- let Inner = () => {
366
- return (
367
- <>
368
- {scope.getPart('render', null, <></>)}
369
- {scope.is('type', 'button') && (
370
- <UIButton
371
- {...defaultsUI}
372
- onClick={onClick}
373
- variant={scope.attr('variant', 'outlined')}
374
- >
375
- {original.icon && <CustomIcon />}
376
- {original.label && (
377
- <Text style={scope.getPart('label', 'button')}>
378
- {scope.getLabel()}
379
- </Text>
380
- )}
381
- </UIButton>
382
- )}
383
- {scope.is('type', 'icon') && (
384
- <UIIcon
385
- {...defaultsUI}
386
- onClick={onClick}
387
- variant={scope.attr('variant', 'outlined')}
388
- >
389
- {scope.getDisplayValue()}
390
- </UIIcon>
391
- )}
392
- {scope.is('type', 'link') && (
393
- <UILink
394
- {...defaultsUI}
395
- onClick={onClick}
396
- variant={scope.attr('variant', 'outlined')}
397
- >
398
- {original.icon && <CustomIcon />}
399
- {original.label && (
400
- <Text style={scope.getPart('label', 'link')}>
401
- {scope.getLabel()}
402
- </Text>
403
- )}
404
- </UILink>
405
- )}
406
- {isInput && (
407
- <UIInput
408
- {...defaultsInput}
409
- {...defaultsUI}
410
- InputProps={{ ...original.inputProps }}
411
- />
412
- )}
413
- {scope.is('type', 'complete', 'autocomplete') && (
414
- <UIComplete
415
- scope={scope}
416
- defaultsInput={defaultsInput}
417
- defaultsUI={defaultsUI}
418
- />
419
- )}
420
- {scope.is('type', 'quantity') && (
421
- <UIQuantity
422
- scope={scope}
423
- defaultsInput={defaultsInput}
424
- defaultsUI={defaultsUI}
425
- />
426
- )}
427
- {scope.is('type', 'checkbox', 'boolean', 'switch') && (
428
- <UISwitch
429
- checked={isChecked()}
430
- {...defaultsInput}
431
- onChange={onCheck}
432
- />
433
- )}
434
- {scope.isType('slider') && (
435
- <UISlider {...defaultsInput} onChange={onCheck} />
436
- )}
437
- {scope.is('type', 'select') && (
438
- <UISelect
439
- {...defaultsInput}
440
- {...defaultsUI}
441
- value={scope.getSelectedValue()}
442
- />
443
- )}
444
- {scope.is('type', 'toggle') && (
445
- <UIToggle
446
- {...defaultsInput}
447
- {...defaultsUI}
448
- value={scope.getSelectedValue()}
449
- />
450
- )}
451
- {scope.is('type', 'radio') && (
452
- <UIRadio {...defaultsInput} {...defaultsUI} row>
453
- {options.map((row: any, i: number) => (
454
- <UIOption
455
- key={'i' + i}
456
- control={<UIRadio {...defaultsUI} />}
457
- label={row.label}
458
- value={row.value}
459
- />
460
- ))}
461
- </UIRadio>
462
- )}
463
- {scope.is('type', 'custom') && <Custom />}
464
- {scope.is('type', 'column') && (
465
- <>
466
- {scope.is('format', 'img') && (
467
- <Image source={scope.getDisplayValue()} />
468
- )}
469
- {scope.is('format', 'icon') && <UIIcon scope={scope} crud={crud} />}
470
- {!scope.is('format', 'icon', 'img') && (
471
- <Text>{scope.getDisplayValue()}</Text>
472
- )}
473
- </>
474
- )}
475
- {scope.is('type', 'output', 'value') && (
476
- <Text style={getStyle('value')}>{scope.getDisplayValue()}</Text>
477
- )}
478
- </>
479
- );
480
- };
481
-
482
- let Include = ({ name, style }: any) => {
483
- if (props[name]) {
484
- let define = ComponentUtils.getDefine(props, name);
485
-
486
- if (!Utils.isEmpty(define)) {
487
- return (
488
- <UIChildren
489
- {...props}
490
- scope={scope}
491
- crud={crud}
492
- style={getStyle(name, style)}
493
- >
494
- {define}
495
- </UIChildren>
496
- );
497
- }
498
- }
499
- return <></>;
500
- };
501
-
502
- let Container = () => {
503
- return (
504
- <>
505
- {isShowLabel() && (
506
- <View
507
- style={getStyle('outerLabel', {
508
- alignSelf: 'flex-start',
509
- flexDirection: 'row',
510
- display: 'flex',
511
- justifyContent: 'space-between',
512
- alignItems: 'center',
513
- width: '100%',
514
- })}
515
- >
516
- <Text style={getStyle('label')}>{scope.getLabel()}</Text>
517
- <Include name="actions" style={{ width: 'auto' }} />
518
- </View>
519
- )}
520
- {isShowInner() && (
521
- <>
522
- <View style={getStyle('inner')}>
523
- <Inner />
524
- </View>
525
- {error && (
526
- <View
527
- style={getStyle('error', {
528
- fontSize: 12,
529
- paddingTop: 4,
530
- color: '#e55b5b',
531
- })}
532
- >
533
- {error}
534
- </View>
535
- )}
536
- </>
537
- )}
538
- {scope.isType('list', 'repeat') && (
539
- <UIList {...props} scope={scope} crud={crud} />
540
- )}
541
- {scope.isType('order') && (
542
- <UIOrder {...props} scope={scope} crud={crud} />
543
- )}
544
-
545
- {scope.isType('chart') && (
546
- <ElChart {...props} scope={scope} crud={crud} />
547
- )}
548
- {scope.isType('tabs') && (
549
- <ElTabs {...props} scope={scope} crud={crud} />
550
- )}
551
-
552
- {scope.isType('view') && (
553
- <UIView {...props} scope={scope} crud={crud} />
554
- )}
555
-
556
- {isShowChild() && (
557
- <UIChildren
558
- {...props}
559
- scope={scope}
560
- crud={crud}
561
- style={getStyle('inner')}
562
- />
563
- )}
564
- <UIModal {...props} scope={scope} crud={crud} />
565
- </>
566
- );
567
- };
568
-
569
- let Card = (props: any) => {
570
- let isCard = scope.is('type|layout', 'card');
571
-
572
- if (scope.isType('list')) {
573
- let empty = scope.getPart('empty', null, undefined);
574
- let items = scope.getItems();
575
-
576
- if (empty === false && Utils.isEmpty(items)) {
577
- isCard = false;
578
- }
579
- }
580
-
581
- if (isCard) {
582
- let box = {
583
- ...getStyle('box', { ...boxStyle.box, alignSelf: 'stretch' }),
584
- };
585
-
586
- return (
587
- <View style={getStyle('card', { ...box })}>
588
- <View
589
- style={getStyle('boxInner', {
590
- paddingHorizontal: 15,
591
- paddingVertical: 10,
592
- })}
593
- >
594
- {props.children}
595
- </View>
596
- </View>
597
- );
598
- }
599
-
600
- if (scope.isInput() || original.container) {
601
- return (
602
- <View
603
- style={getStyle('container', { paddingVertical: 5, width: '100%' })}
604
- >
605
- {props.children}
606
- </View>
607
- );
608
- }
609
- return <>{props.children}</>;
610
- };
611
-
612
- scope.dialogShow = (args?: MethodType) => {
613
- let event = Utils.nvl(args?.event, {});
614
-
615
- if (event?.debug) console.log(args);
616
-
617
- let caller = args.caller;
618
- let main = ViewUtils.getCrud('view');
619
- let parent = main.dialog;
620
- let { crud } = args;
621
- let name = scope.getName('modal');
622
- let edit = args.edit === true;
623
- let def: any = {};
624
- let rowItem = null;
625
- let component = event?.component;
626
- let elo = Utils.nvl(caller?.original, original);
627
-
628
- if (crud.is('row')) {
629
- def.parent = crud.parent.parent;
630
- def.search = crud.parent;
631
-
632
- rowItem = crud.data;
633
- } else if (crud.is('search')) {
634
- def.parent = crud.parent;
635
- def.search = crud;
636
- }
637
-
638
- let crudData = crud.data;
639
- let eventData = Utils.nvl(event.data, event.send);
640
-
641
- if (typeof eventData === 'function') {
642
- eventData = eventData.call(this, args);
643
- }
644
-
645
- if (event.send === false || event.data === false) {
646
- crudData = {};
647
- }
648
-
649
- let data = Utils.nvl(eventData, args.item, rowItem, crudData, {});
650
-
651
- let d = CrudUtils.create('dialog', {
652
- parent: crud,
653
- root: crud,
654
- name,
655
- data,
656
- edit,
657
- scope,
658
- ...def,
659
- });
660
-
661
- let el: any = {
662
- label: elo.label,
663
- icon: elo.icon,
664
- type: 'dialog',
665
- };
666
-
667
- let close = event.dialog?.close;
668
-
669
- if (typeof event.dialog === 'object') {
670
- el = { ...el, ...event.dialog };
671
- }
672
-
673
- if (event.header) el.header = event.header;
674
- if (event.label) el.label = event.label;
675
- if (event.title) el.title = event.title;
676
-
677
- let label = Utils.nvl(el.title, el.label);
678
-
679
- el.label = label;
680
-
681
- let dialogScope = ScopeUtils.create({
682
- parent: scope,
683
- crud: d,
684
- ...el,
685
- owner: scope,
686
- });
687
-
688
- let dialog = {
689
- crud: d,
690
- label,
691
- parent,
692
- component,
693
- scope: dialogScope,
694
- close,
695
- props: event.props,
696
- debug: event.debug,
697
- };
698
-
699
- main.dialog = dialog;
700
- scope.currentDialog = dialog;
701
-
702
- if (parent) parent.update?.();
703
- scope.update();
704
- };
705
-
706
- scope.dialogHide = (args?: MethodType) => {
707
- let main = ViewUtils.getCrud('view');
708
- let current = main.dialog;
709
- let next = Utils.nvl(current.parent, null);
710
-
711
- main.dialog = next;
712
- scope.currentDialog = next;
713
-
714
- let nextScope = next?.scope?.parent;
715
- let currScope = current?.scope?.parent;
716
-
717
- if (currScope) {
718
- const close = current.close;
719
-
720
- currScope.update();
721
-
722
- if (close) {
723
- if (close?.debug) console.log('Fechando');
724
- current.scope.call('close', { close });
725
- }
726
- }
727
-
728
- if (nextScope) {
729
- nextScope.update();
730
- }
731
- };
732
-
733
- return (
734
- <CrudContext.Provider value={{ crud, theme }}>
735
- <Tag ref={ref} style={getStyle()} {...custom}>
736
- <Card>
737
- <Container />
738
- </Card>
739
- </Tag>
740
- </CrudContext.Provider>
741
- );
742
- }
743
-
744
- let boxStyle = StyleSheet.create({
745
- box: {
746
- borderWidth: 0,
747
- borderColor: '#dedede',
748
- borderStyle: 'solid',
749
- backgroundColor: 'white',
750
- borderRadius: 12,
751
- width: '100%',
752
- shadowColor: '#000',
753
- shadowOpacity: 0.1,
754
- shadowRadius: 4,
755
- },
756
- });
757
-
758
- const box: any = {
759
- ...boxStyle.box,
760
- };
761
- //v4
762
- const elementStyle: any = {};
763
-
764
- elementStyle.view = {
765
- inner: {
766
- width: '100%',
767
- alignItems: 'normal',
768
- flex: 1,
769
- },
770
- container: {
771
- width: '100%',
772
- backgroundColor: 'background',
773
- flex: 1,
774
- gap: 10,
775
- },
776
- root: {
777
- width: '100%',
778
- flex: 1,
779
- alignItems: 'normal',
780
- padding: 0,
781
- },
782
- };
783
-
784
- elementStyle.input = StyleSheet.create({
785
- label: {
786
- paddingLeft: 0,
787
- },
788
- inner: {
789
- flex: 1,
790
- width: '100%',
791
- padding: 0,
792
- gap: 10,
793
- alignSelf: 'flex-start',
794
- flexDirection: 'row',
795
- flexWrap: 'wrap',
796
- },
797
- });
798
-
799
- elementStyle.quantity = {
800
- inner: {
801
- ...box,
802
- backgroundColor: 'primarySoft',
803
- fontWeight: 600,
804
- fontSize: 16,
805
- borderRadius: 25,
806
- borderWidth: 0,
807
- paddingHorizontal: 5,
808
- paddingVertical: 5,
809
- flexWrap: 'nowrap',
810
- flex: 1,
811
- flexDirection: 'row',
812
- justifyContent: 'center',
813
- alignItems: 'center',
814
- },
815
- };
816
-
817
- elementStyle.toggle = StyleSheet.create({
818
- inner: {
819
- ...box,
820
- flex: 1,
821
- width: '100%',
822
- gap: 10,
823
- justifyContent: 'center',
824
- flexDirection: 'row',
825
- paddingHorizontal: 10,
826
- paddingVertical: 0,
827
- alignSelf: 'flex-start',
828
- flexWrap: 'nowrap',
829
- },
830
- });
831
-
832
- const styles = StyleSheet.create({
833
- root: {
834
- gap: 5,
835
- flexDirection: 'column',
836
- flexWrap: 'wrap',
837
- width: '100%',
838
- alignItems: 'flex-start',
839
- },
840
- label: {
841
- fontWeight: 400,
842
- fontSize: 12,
843
- paddingVertical: 3,
844
- color: 'labelColor',
845
- },
846
- inner: { width: '100%' },
847
- });
848
-
849
- const withChildStyles = StyleSheet.create({
850
- root: {
851
- gap: 10,
852
- },
853
- label: {
854
- width: '100%',
855
- fontWeight: 500,
856
- fontSize: 24,
857
- },
858
- });
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
+ MethodType,
20
+ ActionType,
21
+ ComponentUtils,
22
+ CrudUtils,
23
+ ViewUtils,
24
+ Scope,
25
+ } from 'react-crud-utils';
26
+ import UILink from './core/UILink';
27
+ import UIIcon from './core/UIIcon';
28
+ import UIButton from './core/UIButton';
29
+ import UISelect from './core/UISelect';
30
+ import UISwitch from './core/UISwitch';
31
+ import UISlider from './core/UISlider';
32
+ import UIOption from './core/UIOption';
33
+ import UIRadio from './core/UIRadio';
34
+ import UIInput from './core/UIInput';
35
+ import {
36
+ Alert,
37
+ Image,
38
+ Linking,
39
+ StyleSheet,
40
+ Text,
41
+ TouchableHighlight,
42
+ View,
43
+ } from 'react-native';
44
+ import UIList from './core/UIList';
45
+ import UIToggle from './core/UIToggle';
46
+ import UIQuantity from './core/UIQuantity';
47
+ import UIModal from './core/UIModal';
48
+ import { Ionicons } from '@expo/vector-icons';
49
+ import UIView from './core/UIView';
50
+ import Toast from 'react-native-toast-message';
51
+ import UIOrder from './core/UIOrder';
52
+
53
+ const CrudContext = createContext<any>({});
54
+
55
+ export default function UIElement(props: ElementType) {
56
+ const ctx = useContext(CrudContext);
57
+ const theme = Utils.nvl(props.theme, ctx?.theme);
58
+
59
+ let crud: Crud = Utils.nvl(props.crud, ctx?.crud);
60
+ let [scope] = useState<Scope>(ScopeUtils.create({ crud, ...props, theme }));
61
+ let [index, setIndex] = useState(0);
62
+ let [error, setError]: string | any = useState(null);
63
+
64
+ scope.compile(props);
65
+
66
+ crud = scope.crud;
67
+
68
+ let options: any = scope.getOptions();
69
+
70
+ let original = scope.original;
71
+ let ref = useRef(null);
72
+
73
+ scope.update = () => {
74
+ setIndex(++index);
75
+ };
76
+
77
+ scope.updateElement = () => {
78
+ setIndex(++index);
79
+ };
80
+
81
+ scope.toast = (message: string, type = 'info', args?: any) => {
82
+ Toast.show({
83
+ type, // 'success' | 'error' | 'info'
84
+ text1: message,
85
+ position: 'bottom', // 'top' é outra opção
86
+ visibilityTime: 3000, // tempo que fica visível em ms
87
+ ...args,
88
+ });
89
+ };
90
+
91
+ scope.prompt = (args: MethodType) => {
92
+ let event = args.event as ActionType;
93
+
94
+ if (event) {
95
+ let message = 'Você tem certeza que deseja continuar?';
96
+ let title = 'Atenção';
97
+ let prompt = event.prompt;
98
+
99
+ if (typeof prompt === 'string') {
100
+ message = prompt;
101
+ }
102
+
103
+ if (typeof prompt === 'object') {
104
+ message = Utils.nvl(prompt.message, message);
105
+ title = Utils.nvl(prompt.title, title);
106
+ }
107
+
108
+ Alert.alert(
109
+ title,
110
+ message,
111
+ [
112
+ {
113
+ text: 'Cancelar',
114
+ style: 'cancel',
115
+ },
116
+ {
117
+ text: 'Confirmar',
118
+ onPress: () => scope.execute(args),
119
+ },
120
+ ],
121
+ { cancelable: false }
122
+ );
123
+ }
124
+ };
125
+ const Custom = () => {
126
+ let c: any = original.custom;
127
+
128
+ if (c) {
129
+ if (typeof c === 'string') {
130
+ return (
131
+ <UIElement
132
+ element={{ value: c, type: 'dummy' }}
133
+ crud={crud}
134
+ ></UIElement>
135
+ );
136
+ }
137
+
138
+ return (
139
+ <UIElement
140
+ type={c.type}
141
+ tag={c.type}
142
+ {...c.props}
143
+ crud={crud}
144
+ ></UIElement>
145
+ );
146
+ }
147
+
148
+ return <></>;
149
+ };
150
+
151
+ if (scope.is('type', 'dummy')) {
152
+ return <>{scope.getDisplayValue()}</>;
153
+ }
154
+
155
+ let onCheck = () => {
156
+ let v = scope.getValue();
157
+ let check = !(v === true);
158
+
159
+ onChange({ target: { value: check } });
160
+ };
161
+
162
+ let onChange = (e: any) => {
163
+ let val = e.target.value;
164
+
165
+ if (scope.isType('integer', 'int', 'number')) {
166
+ val = parseInt(val);
167
+ } else if (scope.isType('decimal')) {
168
+ val = parseFloat(val);
169
+ }
170
+
171
+ if (scope.isType('select', 'complete')) {
172
+ val = scope.getSelectedItem(val);
173
+ }
174
+
175
+ scope.changeValue(val);
176
+ scope.update();
177
+ };
178
+
179
+ let onClick = (e: any) => {
180
+ if (scope.currentDialog?.component) return;
181
+
182
+ scope.call('click');
183
+ };
184
+
185
+ let defaultsInput: any = {
186
+ scope,
187
+ crud,
188
+ onChange: onChange,
189
+ };
190
+
191
+ if (scope.isType('password')) {
192
+ defaultsInput.type = 'password';
193
+ }
194
+
195
+ let isChecked = () => {
196
+ let v = scope.getValue();
197
+
198
+ return v === true;
199
+ };
200
+
201
+ let hasChildren = () => {
202
+ if (scope.isInput()) {
203
+ return false;
204
+ }
205
+
206
+ return !Utils.isEmpty(props.children) || !Utils.isEmpty(props.elements);
207
+ };
208
+
209
+ let isInput = scope.is(
210
+ 'type',
211
+ 'text',
212
+ 'textarea',
213
+ 'number',
214
+ 'integer',
215
+ 'int',
216
+ 'phone',
217
+ 'postalCode',
218
+ 'money',
219
+ 'password',
220
+ 'email'
221
+ );
222
+
223
+ const getStyle = (part?: string, extra?: any) => {
224
+ let type = Utils.nvl(original.type, 'none');
225
+ let key = Utils.nvl(part, 'root');
226
+ let def = { ...styles[key] };
227
+ let hasChild = hasChildren();
228
+
229
+ type = Utils.nvl(original.layout, type);
230
+
231
+ if (!part && !hasChild) {
232
+ def = { ...def };
233
+ }
234
+
235
+ if (scope.isInput()) {
236
+ def = { ...def, ...elementStyle.input[key] };
237
+ }
238
+
239
+ def = { ...def, ...elementStyle?.[type]?.[key] };
240
+
241
+ if (hasChild && part) {
242
+ def = { ...def, ...withChildStyles[part] };
243
+ }
244
+
245
+ return { ...def, ...scope.getStyle(part, { ...def, ...extra }) };
246
+ };
247
+
248
+ let elStyle = getStyle('element');
249
+
250
+ let defaultsUI: any = {
251
+ required: scope.isRequired(),
252
+ size: 'small',
253
+ scope,
254
+ crud,
255
+ style: elStyle,
256
+ placeholder: scope.attr('placeholder', 'Digite aqui'),
257
+ };
258
+
259
+ scope.error = (msg: string) => {
260
+ error = msg;
261
+ setError(msg);
262
+ };
263
+
264
+ if (!original.list?.url && !original.load?.url) {
265
+ scope.start();
266
+ }
267
+
268
+ useEffect(() => {
269
+ scope.start();
270
+ });
271
+
272
+ const CustomIcon = () => {
273
+ if (typeof original.icon === 'string') {
274
+ return <Ionicons name={original.icon} style={scope.getStyle('icon')} />;
275
+ }
276
+ return <>{original.icon}</>;
277
+ };
278
+
279
+ scope.open = (args: any) => {
280
+ Linking.openURL(args.url);
281
+ };
282
+
283
+ useLayoutEffect(() => {
284
+ if (ref?.current && scope.is('type', 'card', 'list', 'tabs', 'stepper')) {
285
+ let el: any = ref?.current;
286
+
287
+ if (el?.classList) {
288
+ let bg = HtmlUtils.getBGColor(el);
289
+
290
+ if (bg === 'rgb(255, 255, 255)') {
291
+ el.classList.add('ui-dark');
292
+ } else {
293
+ el.classList.add('ui-light');
294
+ }
295
+ }
296
+ }
297
+ });
298
+
299
+ const isShowLabel = () => {
300
+ if (
301
+ typeof original.label !== 'undefined' &&
302
+ original.label !== false &&
303
+ !scope.isType('button', 'dialog', 'modal')
304
+ ) {
305
+ return true;
306
+ }
307
+
308
+ return false;
309
+ };
310
+
311
+ const isShowInner = () => {
312
+ if (hasChildren()) {
313
+ return false;
314
+ }
315
+ return true;
316
+ };
317
+
318
+ if (!scope.isRendered() || scope.is('type', 'define')) {
319
+ return <></>;
320
+ }
321
+
322
+ const isShowChild = () => {
323
+ if (
324
+ scope.isType(
325
+ 'tabs',
326
+ 'view',
327
+ 'grid',
328
+ 'list',
329
+ 'define',
330
+ 'repeat',
331
+ 'modal',
332
+ 'dialog',
333
+ 'chart'
334
+ )
335
+ ) {
336
+ return false;
337
+ }
338
+
339
+ return true;
340
+ };
341
+
342
+ let isTouch =
343
+ !scope.isType('input', 'grid', 'list', 'order', 'repeat') && original.click;
344
+ let custom: any = {};
345
+
346
+ if (isTouch) {
347
+ custom.underlayColor = 'transparent';
348
+ custom.onPress = onClick;
349
+ }
350
+
351
+ let Tag = (props: any) => {
352
+ let Aux: any = View;
353
+
354
+ if (isTouch) {
355
+ Aux = TouchableHighlight;
356
+ }
357
+
358
+ if (scope.isType('dialog', 'order') || original.transient) {
359
+ return <>{props.children}</>;
360
+ }
361
+
362
+ return <Aux {...props} />;
363
+ };
364
+
365
+ let Inner = () => {
366
+ return (
367
+ <>
368
+ {scope.getPart('render', null, <></>)}
369
+ {scope.is('type', 'button') && (
370
+ <UIButton
371
+ {...defaultsUI}
372
+ onClick={onClick}
373
+ variant={scope.attr('variant', 'outlined')}
374
+ >
375
+ {original.icon && <CustomIcon />}
376
+ {original.label && (
377
+ <Text style={scope.getPart('label', 'button')}>
378
+ {scope.getLabel()}
379
+ </Text>
380
+ )}
381
+ </UIButton>
382
+ )}
383
+ {scope.is('type', 'icon') && (
384
+ <UIIcon
385
+ {...defaultsUI}
386
+ onClick={onClick}
387
+ variant={scope.attr('variant', 'outlined')}
388
+ >
389
+ {scope.getDisplayValue()}
390
+ </UIIcon>
391
+ )}
392
+ {scope.is('type', 'link') && (
393
+ <UILink
394
+ {...defaultsUI}
395
+ onClick={onClick}
396
+ variant={scope.attr('variant', 'outlined')}
397
+ >
398
+ {original.icon && <CustomIcon />}
399
+ {original.label && (
400
+ <Text style={scope.getPart('label', 'link')}>
401
+ {scope.getLabel()}
402
+ </Text>
403
+ )}
404
+ </UILink>
405
+ )}
406
+ {isInput && (
407
+ <UIInput
408
+ {...defaultsInput}
409
+ {...defaultsUI}
410
+ InputProps={{ ...original.inputProps }}
411
+ />
412
+ )}
413
+ {scope.is('type', 'complete', 'autocomplete') && (
414
+ <UIComplete
415
+ scope={scope}
416
+ defaultsInput={defaultsInput}
417
+ defaultsUI={defaultsUI}
418
+ />
419
+ )}
420
+ {scope.is('type', 'quantity') && (
421
+ <UIQuantity
422
+ scope={scope}
423
+ defaultsInput={defaultsInput}
424
+ defaultsUI={defaultsUI}
425
+ />
426
+ )}
427
+ {scope.is('type', 'checkbox', 'boolean', 'switch') && (
428
+ <UISwitch
429
+ checked={isChecked()}
430
+ {...defaultsInput}
431
+ onChange={onCheck}
432
+ />
433
+ )}
434
+ {scope.isType('slider') && (
435
+ <UISlider {...defaultsInput} onChange={onCheck} />
436
+ )}
437
+ {scope.is('type', 'select') && (
438
+ <UISelect
439
+ {...defaultsInput}
440
+ {...defaultsUI}
441
+ value={scope.getSelectedValue()}
442
+ />
443
+ )}
444
+ {scope.is('type', 'toggle') && (
445
+ <UIToggle
446
+ {...defaultsInput}
447
+ {...defaultsUI}
448
+ value={scope.getSelectedValue()}
449
+ />
450
+ )}
451
+ {scope.is('type', 'radio') && (
452
+ <UIRadio {...defaultsInput} {...defaultsUI} row>
453
+ {options.map((row: any, i: number) => (
454
+ <UIOption
455
+ key={'i' + i}
456
+ control={<UIRadio {...defaultsUI} />}
457
+ label={row.label}
458
+ value={row.value}
459
+ />
460
+ ))}
461
+ </UIRadio>
462
+ )}
463
+ {scope.is('type', 'custom') && <Custom />}
464
+ {scope.is('type', 'column') && (
465
+ <>
466
+ {scope.is('format', 'img') && (
467
+ <Image source={scope.getDisplayValue()} />
468
+ )}
469
+ {scope.is('format', 'icon') && <UIIcon scope={scope} crud={crud} />}
470
+ {!scope.is('format', 'icon', 'img') && (
471
+ <Text>{scope.getDisplayValue()}</Text>
472
+ )}
473
+ </>
474
+ )}
475
+ {scope.is('type', 'output', 'value') && (
476
+ <Text style={getStyle('value')}>{scope.getDisplayValue()}</Text>
477
+ )}
478
+ </>
479
+ );
480
+ };
481
+
482
+ let Include = ({ name, style }: any) => {
483
+ if (props[name]) {
484
+ let define = ComponentUtils.getDefine(props, name);
485
+
486
+ if (!Utils.isEmpty(define)) {
487
+ return (
488
+ <UIChildren
489
+ {...props}
490
+ scope={scope}
491
+ crud={crud}
492
+ style={getStyle(name, style)}
493
+ >
494
+ {define}
495
+ </UIChildren>
496
+ );
497
+ }
498
+ }
499
+ return <></>;
500
+ };
501
+
502
+ let Container = () => {
503
+ return (
504
+ <>
505
+ {isShowLabel() && (
506
+ <View
507
+ style={getStyle('outerLabel', {
508
+ alignSelf: 'flex-start',
509
+ flexDirection: 'row',
510
+ display: 'flex',
511
+ justifyContent: 'space-between',
512
+ alignItems: 'center',
513
+ width: '100%',
514
+ })}
515
+ >
516
+ <Text style={getStyle('label')}>{scope.getLabel()}</Text>
517
+ <Include name="actions" style={{ width: 'auto' }} />
518
+ </View>
519
+ )}
520
+ {isShowInner() && (
521
+ <>
522
+ <View style={getStyle('inner')}>
523
+ <Inner />
524
+ </View>
525
+ {error && (
526
+ <View
527
+ style={getStyle('error', {
528
+ fontSize: 12,
529
+ paddingTop: 4,
530
+ color: '#e55b5b',
531
+ })}
532
+ >
533
+ {error}
534
+ </View>
535
+ )}
536
+ </>
537
+ )}
538
+ {scope.isType('list', 'repeat') && (
539
+ <UIList {...props} scope={scope} crud={crud} />
540
+ )}
541
+ {scope.isType('order') && (
542
+ <UIOrder {...props} scope={scope} crud={crud} />
543
+ )}
544
+
545
+ {scope.isType('chart') && (
546
+ <ElChart {...props} scope={scope} crud={crud} />
547
+ )}
548
+ {scope.isType('tabs') && (
549
+ <ElTabs {...props} scope={scope} crud={crud} />
550
+ )}
551
+
552
+ {scope.isType('view') && (
553
+ <UIView {...props} scope={scope} crud={crud} />
554
+ )}
555
+
556
+ {isShowChild() && (
557
+ <UIChildren
558
+ {...props}
559
+ scope={scope}
560
+ crud={crud}
561
+ style={getStyle('inner')}
562
+ />
563
+ )}
564
+ <UIModal {...props} scope={scope} crud={crud} />
565
+ </>
566
+ );
567
+ };
568
+
569
+ let Card = (props: any) => {
570
+ let isCard = scope.is('type|layout', 'card');
571
+
572
+ if (scope.isType('list')) {
573
+ let empty = scope.getPart('empty', null, undefined);
574
+ let items = scope.getItems();
575
+
576
+ if (empty === false && Utils.isEmpty(items)) {
577
+ isCard = false;
578
+ }
579
+ }
580
+
581
+ if (isCard) {
582
+ let box = {
583
+ ...getStyle('box', { ...boxStyle.box, alignSelf: 'stretch' }),
584
+ };
585
+
586
+ return (
587
+ <View style={getStyle('card', { ...box })}>
588
+ <View
589
+ style={getStyle('boxInner', {
590
+ paddingHorizontal: 15,
591
+ paddingVertical: 10,
592
+ })}
593
+ >
594
+ {props.children}
595
+ </View>
596
+ </View>
597
+ );
598
+ }
599
+
600
+ if (scope.isInput() || original.container) {
601
+ return (
602
+ <View
603
+ style={getStyle('container', { paddingVertical: 5, width: '100%' })}
604
+ >
605
+ {props.children}
606
+ </View>
607
+ );
608
+ }
609
+ return <>{props.children}</>;
610
+ };
611
+
612
+ scope.dialogShow = (args?: MethodType) => {
613
+ let event = Utils.nvl(args?.event, {});
614
+
615
+ if (event?.debug) console.log(args);
616
+
617
+ let caller = args.caller;
618
+ let main = ViewUtils.getCrud('view');
619
+ let parent = main.dialog;
620
+ let { crud } = args;
621
+ let name = scope.getName('modal');
622
+ let edit = args.edit === true;
623
+ let def: any = {};
624
+ let rowItem = null;
625
+ let component = event?.component;
626
+ let elo = Utils.nvl(caller?.original, original);
627
+
628
+ if (crud.is('row')) {
629
+ def.parent = crud.parent.parent;
630
+ def.search = crud.parent;
631
+
632
+ rowItem = crud.data;
633
+ } else if (crud.is('search')) {
634
+ def.parent = crud.parent;
635
+ def.search = crud;
636
+ }
637
+
638
+ let crudData = crud.data;
639
+ let eventData = Utils.nvl(event.data, event.send);
640
+
641
+ if (typeof eventData === 'function') {
642
+ eventData = eventData.call(this, args);
643
+ }
644
+
645
+ if (event.send === false || event.data === false) {
646
+ crudData = {};
647
+ }
648
+
649
+ let data = Utils.nvl(eventData, args.item, rowItem, crudData, {});
650
+
651
+ let d = CrudUtils.create('dialog', {
652
+ parent: crud,
653
+ root: crud,
654
+ name,
655
+ data,
656
+ edit,
657
+ scope,
658
+ ...def,
659
+ });
660
+
661
+ let el: any = {
662
+ label: elo.label,
663
+ icon: elo.icon,
664
+ type: 'dialog',
665
+ };
666
+
667
+ let close = event.dialog?.close;
668
+
669
+ if (typeof event.dialog === 'object') {
670
+ el = { ...el, ...event.dialog };
671
+ }
672
+
673
+ if (event.header) el.header = event.header;
674
+ if (event.label) el.label = event.label;
675
+ if (event.title) el.title = event.title;
676
+
677
+ let label = Utils.nvl(el.title, el.label);
678
+
679
+ el.label = label;
680
+
681
+ let dialogScope = ScopeUtils.create({
682
+ parent: scope,
683
+ crud: d,
684
+ ...el,
685
+ owner: scope,
686
+ });
687
+
688
+ let dialog = {
689
+ crud: d,
690
+ label,
691
+ parent,
692
+ component,
693
+ scope: dialogScope,
694
+ close,
695
+ props: event.props,
696
+ debug: event.debug,
697
+ };
698
+
699
+ main.dialog = dialog;
700
+ scope.currentDialog = dialog;
701
+
702
+ if (parent) parent.update?.();
703
+ scope.update();
704
+ };
705
+
706
+ scope.dialogHide = (args?: MethodType) => {
707
+ let main = ViewUtils.getCrud('view');
708
+ let current = main.dialog;
709
+ let next = Utils.nvl(current.parent, null);
710
+
711
+ main.dialog = next;
712
+ scope.currentDialog = next;
713
+
714
+ let nextScope = next?.scope?.parent;
715
+ let currScope = current?.scope?.parent;
716
+
717
+ if (currScope) {
718
+ const close = current.close;
719
+
720
+ currScope.update();
721
+
722
+ if (close) {
723
+ if (close?.debug) console.log('Fechando');
724
+ current.scope.call('close', { close });
725
+ }
726
+ }
727
+
728
+ if (nextScope) {
729
+ nextScope.update();
730
+ }
731
+ };
732
+
733
+ return (
734
+ <CrudContext.Provider value={{ crud, theme }}>
735
+ <Tag ref={ref} style={getStyle()} {...custom}>
736
+ <Card>
737
+ <Container />
738
+ </Card>
739
+ </Tag>
740
+ </CrudContext.Provider>
741
+ );
742
+ }
743
+
744
+ let boxStyle = StyleSheet.create({
745
+ box: {
746
+ borderWidth: 0,
747
+ borderColor: '#dedede',
748
+ borderStyle: 'solid',
749
+ backgroundColor: 'white',
750
+ borderRadius: 12,
751
+ width: '100%',
752
+ shadowColor: '#000',
753
+ shadowOpacity: 0.1,
754
+ shadowRadius: 4,
755
+ },
756
+ });
757
+
758
+ const box: any = {
759
+ ...boxStyle.box,
760
+ };
761
+ //v4
762
+ const elementStyle: any = {};
763
+
764
+ elementStyle.view = {
765
+ inner: {
766
+ width: '100%',
767
+ alignItems: 'normal',
768
+ flex: 1,
769
+ },
770
+ container: {
771
+ width: '100%',
772
+ backgroundColor: 'background',
773
+ flex: 1,
774
+ gap: 10,
775
+ },
776
+ root: {
777
+ width: '100%',
778
+ flex: 1,
779
+ alignItems: 'normal',
780
+ padding: 0,
781
+ },
782
+ };
783
+
784
+ elementStyle.input = StyleSheet.create({
785
+ label: {
786
+ paddingLeft: 0,
787
+ },
788
+ inner: {
789
+ flex: 1,
790
+ width: '100%',
791
+ padding: 0,
792
+ gap: 10,
793
+ alignSelf: 'flex-start',
794
+ flexDirection: 'row',
795
+ flexWrap: 'wrap',
796
+ },
797
+ });
798
+
799
+ elementStyle.quantity = {
800
+ inner: {
801
+ ...box,
802
+ backgroundColor: 'primarySoft',
803
+ fontWeight: 600,
804
+ fontSize: 16,
805
+ borderRadius: 25,
806
+ borderWidth: 0,
807
+ paddingHorizontal: 5,
808
+ paddingVertical: 5,
809
+ flexWrap: 'nowrap',
810
+ flex: 1,
811
+ flexDirection: 'row',
812
+ justifyContent: 'center',
813
+ alignItems: 'center',
814
+ },
815
+ };
816
+
817
+ elementStyle.toggle = StyleSheet.create({
818
+ inner: {
819
+ ...box,
820
+ flex: 1,
821
+ width: '100%',
822
+ gap: 10,
823
+ justifyContent: 'center',
824
+ flexDirection: 'row',
825
+ paddingHorizontal: 10,
826
+ paddingVertical: 0,
827
+ alignSelf: 'flex-start',
828
+ flexWrap: 'nowrap',
829
+ },
830
+ });
831
+
832
+ const styles = StyleSheet.create({
833
+ root: {
834
+ gap: 5,
835
+ flexDirection: 'column',
836
+ flexWrap: 'wrap',
837
+ width: '100%',
838
+ alignItems: 'flex-start',
839
+ },
840
+ label: {
841
+ fontWeight: 400,
842
+ fontSize: 12,
843
+ paddingVertical: 3,
844
+ color: 'labelColor',
845
+ },
846
+ inner: { width: '100%' },
847
+ });
848
+
849
+ const withChildStyles = StyleSheet.create({
850
+ root: {
851
+ gap: 10,
852
+ },
853
+ label: {
854
+ width: '100%',
855
+ fontWeight: 500,
856
+ fontSize: 24,
857
+ },
858
+ });