react-crud-mobile 1.3.359 → 1.3.361

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 (32) hide show
  1. package/dist/react-crud-mobile.cjs.development.js +4 -9
  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 -9
  6. package/dist/react-crud-mobile.esm.js.map +1 -1
  7. package/package.json +76 -76
  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 +872 -878
  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/UIButton.tsx +144 -144
  17. package/src/elements/core/UIHeader.tsx +38 -38
  18. package/src/elements/core/UIIcon.tsx +32 -32
  19. package/src/elements/core/UIInclude.tsx +40 -40
  20. package/src/elements/core/UIInput.tsx +149 -149
  21. package/src/elements/core/UIList.tsx +180 -180
  22. package/src/elements/core/UIListRow.tsx +132 -132
  23. package/src/elements/core/UIModal.tsx +212 -212
  24. package/src/elements/core/UIOrder.tsx +194 -194
  25. package/src/elements/core/UIQuantity.tsx +98 -98
  26. package/src/elements/core/UISelect.tsx +194 -194
  27. package/src/elements/core/UIToast.tsx +44 -44
  28. package/src/elements/core/UIToggle.tsx +114 -114
  29. package/src/elements/core/UIView.tsx +69 -69
  30. package/src/elements/index.ts +1 -1
  31. package/src/elements/tabs/ElTabs.tsx +178 -178
  32. package/src/index.ts +1 -1
@@ -1,878 +1,872 @@
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 (scope.isType('icon')) return false;
313
- if (hasChildren()) {
314
- return false;
315
- }
316
- return true;
317
- };
318
-
319
- if (!scope.isRendered() || scope.is('type', 'define')) {
320
- return <></>;
321
- }
322
-
323
- const isShowChild = () => {
324
- if (
325
- scope.isType(
326
- 'tabs',
327
- 'view',
328
- 'grid',
329
- 'list',
330
- 'define',
331
- 'repeat',
332
- 'modal',
333
- 'dialog',
334
- 'chart'
335
- )
336
- ) {
337
- return false;
338
- }
339
-
340
- return true;
341
- };
342
-
343
- let isTouch =
344
- !scope.isType('input', 'grid', 'list', 'order', 'repeat') && original.click;
345
- let custom: any = {};
346
-
347
- if (isTouch) {
348
- custom.underlayColor = 'transparent';
349
- custom.onPress = onClick;
350
- }
351
-
352
- let Tag = (props: any) => {
353
- let Aux: any = View;
354
-
355
- if (isTouch) {
356
- Aux = TouchableHighlight;
357
- }
358
-
359
- if (scope.isType('dialog', 'order') || original.transient) {
360
- return <>{props.children}</>;
361
- }
362
-
363
- return <Aux {...props} />;
364
- };
365
-
366
- let Inner = () => {
367
- return (
368
- <>
369
- {scope.getPart('render', null, <></>)}
370
- {scope.is('type', 'button') && (
371
- <UIButton
372
- {...defaultsUI}
373
- onClick={onClick}
374
- variant={scope.attr('variant', 'outlined')}
375
- >
376
- {original.icon && <CustomIcon />}
377
- {original.label && (
378
- <Text style={scope.getPart('label', 'button')}>
379
- {scope.getLabel()}
380
- </Text>
381
- )}
382
- </UIButton>
383
- )}
384
- {scope.is('type', 'link') && (
385
- <UILink
386
- {...defaultsUI}
387
- onClick={onClick}
388
- variant={scope.attr('variant', 'outlined')}
389
- >
390
- {original.icon && <CustomIcon />}
391
- {original.label && (
392
- <Text style={scope.getPart('label', 'link')}>
393
- {scope.getLabel()}
394
- </Text>
395
- )}
396
- </UILink>
397
- )}
398
- {isInput && (
399
- <UIInput
400
- {...defaultsInput}
401
- {...defaultsUI}
402
- InputProps={{ ...original.inputProps }}
403
- />
404
- )}
405
- {scope.is('type', 'complete', 'autocomplete') && (
406
- <UIComplete
407
- scope={scope}
408
- defaultsInput={defaultsInput}
409
- defaultsUI={defaultsUI}
410
- />
411
- )}
412
- {scope.is('type', 'quantity') && (
413
- <UIQuantity
414
- scope={scope}
415
- defaultsInput={defaultsInput}
416
- defaultsUI={defaultsUI}
417
- />
418
- )}
419
- {scope.is('type', 'checkbox', 'boolean', 'switch') && (
420
- <UISwitch
421
- checked={isChecked()}
422
- {...defaultsInput}
423
- onChange={onCheck}
424
- />
425
- )}
426
- {scope.isType('slider') && (
427
- <UISlider {...defaultsInput} onChange={onCheck} />
428
- )}
429
- {scope.is('type', 'select') && (
430
- <UISelect
431
- {...defaultsInput}
432
- {...defaultsUI}
433
- value={scope.getSelectedValue()}
434
- />
435
- )}
436
- {scope.is('type', 'toggle') && (
437
- <UIToggle
438
- {...defaultsInput}
439
- {...defaultsUI}
440
- value={scope.getSelectedValue()}
441
- />
442
- )}
443
- {scope.is('type', 'radio') && (
444
- <UIRadio {...defaultsInput} {...defaultsUI} row>
445
- {options.map((row: any, i: number) => (
446
- <UIOption
447
- key={'i' + i}
448
- control={<UIRadio {...defaultsUI} />}
449
- label={row.label}
450
- value={row.value}
451
- />
452
- ))}
453
- </UIRadio>
454
- )}
455
- {scope.is('type', 'custom') && <Custom />}
456
- {scope.is('type', 'column') && (
457
- <>
458
- {scope.is('format', 'img') && (
459
- <Image source={scope.getDisplayValue()} />
460
- )}
461
- {scope.is('format', 'icon') && <UIIcon scope={scope} crud={crud} />}
462
- {!scope.is('format', 'icon', 'img') && (
463
- <Text>{scope.getDisplayValue()}</Text>
464
- )}
465
- </>
466
- )}
467
- {scope.is('type', 'output', 'value') && (
468
- <Text style={getStyle('value')}>{scope.getDisplayValue()}</Text>
469
- )}
470
- </>
471
- );
472
- };
473
-
474
- let Include = ({ name, style }: any) => {
475
- if (props[name]) {
476
- let define = ComponentUtils.getDefine(props, name);
477
-
478
- if (!Utils.isEmpty(define)) {
479
- return (
480
- <UIChildren
481
- {...props}
482
- scope={scope}
483
- crud={crud}
484
- style={getStyle(name, style)}
485
- >
486
- {define}
487
- </UIChildren>
488
- );
489
- }
490
- }
491
- return <></>;
492
- };
493
-
494
- let Container = () => {
495
- return (
496
- <>
497
- {isShowLabel() && (
498
- <View
499
- style={getStyle('outerLabel', {
500
- alignSelf: 'flex-start',
501
- flexDirection: 'row',
502
- display: 'flex',
503
- justifyContent: 'space-between',
504
- alignItems: 'center',
505
- width: '100%',
506
- })}
507
- >
508
- <Text style={getStyle('label')}>{scope.getLabel()}</Text>
509
- <Include name="actions" style={{ width: 'auto' }} />
510
- </View>
511
- )}
512
- {isShowInner() && (
513
- <>
514
- <View style={getStyle('inner')}>
515
- <Inner />
516
- </View>
517
- {error && (
518
- <View
519
- style={getStyle('error', {
520
- fontSize: 12,
521
- paddingTop: 4,
522
- color: '#e55b5b',
523
- })}
524
- >
525
- {error}
526
- </View>
527
- )}
528
- </>
529
- )}
530
- {scope.isType('list', 'repeat') && (
531
- <UIList {...props} scope={scope} crud={crud} />
532
- )}
533
- {scope.isType('order') && (
534
- <UIOrder {...props} scope={scope} crud={crud} />
535
- )}
536
-
537
- {scope.isType('chart') && (
538
- <ElChart {...props} scope={scope} crud={crud} />
539
- )}
540
- {scope.isType('tabs') && (
541
- <ElTabs {...props} scope={scope} crud={crud} />
542
- )}
543
-
544
- {scope.isType('view') && (
545
- <UIView {...props} scope={scope} crud={crud} />
546
- )}
547
-
548
- {scope.is('type', 'icon') && (
549
- <UIIcon
550
- {...defaultsUI}
551
- onClick={onClick}
552
- variant={scope.attr('variant', 'outlined')}
553
- >
554
- {scope.getDisplayValue()}
555
- </UIIcon>
556
- )}
557
-
558
- {isShowChild() && (
559
- <UIChildren
560
- {...props}
561
- scope={scope}
562
- crud={crud}
563
- style={getStyle('inner')}
564
- />
565
- )}
566
- <UIModal {...props} scope={scope} crud={crud} />
567
- </>
568
- );
569
- };
570
-
571
- let Card = (props: any) => {
572
- let isCard = scope.is('type|layout', 'card');
573
-
574
- if (scope.isType('list')) {
575
- let empty = scope.getPart('empty', null, undefined);
576
- let items = scope.getItems();
577
-
578
- if (empty === false && Utils.isEmpty(items)) {
579
- isCard = false;
580
- }
581
- }
582
-
583
- if (isCard) {
584
- let box = {
585
- ...getStyle('box', { ...boxStyle.box, alignSelf: 'stretch' }),
586
- };
587
-
588
- let borderWidth = original.boxBorder;
589
-
590
- if (borderWidth || borderWidth === 0) {
591
- if (borderWidth === true) {
592
- borderWidth = 1;
593
- }
594
-
595
- box = { ...box, borderWidth };
596
- }
597
-
598
- return (
599
- <View style={getStyle('card', { ...box })}>
600
- <View
601
- style={getStyle('boxInner', {
602
- paddingHorizontal: 15,
603
- paddingVertical: 10,
604
- })}
605
- >
606
- {props.children}
607
- </View>
608
- </View>
609
- );
610
- }
611
-
612
- if (scope.isInput() || original.container) {
613
- return (
614
- <View
615
- style={getStyle('container', { paddingVertical: 5, width: '100%' })}
616
- >
617
- {props.children}
618
- </View>
619
- );
620
- }
621
- return <>{props.children}</>;
622
- };
623
-
624
- scope.dialogShow = (args?: MethodType) => {
625
- let event = Utils.nvl(args?.event, {});
626
-
627
- if (event?.debug) console.log(args);
628
-
629
- let caller = args.caller;
630
- let main = ViewUtils.getCrud('view');
631
- let parent = main.dialog;
632
- let { crud } = args;
633
- let name = scope.getName('modal');
634
- let edit = args.edit === true;
635
- let def: any = {};
636
- let rowItem = null;
637
- let component = event?.component;
638
- let elo = Utils.nvl(caller?.original, original);
639
-
640
- if (crud.is('row')) {
641
- def.parent = crud.parent.parent;
642
- def.search = crud.parent;
643
-
644
- rowItem = crud.data;
645
- } else if (crud.is('search')) {
646
- def.parent = crud.parent;
647
- def.search = crud;
648
- }
649
-
650
- let crudData = crud.data;
651
- let eventData = Utils.nvl(event.data, event.send);
652
-
653
- if (typeof eventData === 'function') {
654
- eventData = eventData.call(this, args);
655
- }
656
-
657
- if (event.send === false || event.data === false) {
658
- crudData = {};
659
- }
660
-
661
- let data = Utils.nvl(eventData, args.item, rowItem, crudData, {});
662
-
663
- let d = CrudUtils.create('dialog', {
664
- parent: crud,
665
- root: crud,
666
- name,
667
- data,
668
- edit,
669
- scope,
670
- ...def,
671
- });
672
-
673
- let el: any = {
674
- label: elo.label,
675
- icon: elo.icon,
676
- type: 'dialog',
677
- };
678
-
679
- let close = event.dialog?.close;
680
-
681
- if (typeof event.dialog === 'object') {
682
- el = { ...el, ...event.dialog };
683
- }
684
-
685
- if (event.header) el.header = event.header;
686
- if (event.label) el.label = event.label;
687
- if (event.title) el.title = event.title;
688
-
689
- let label = Utils.nvl(el.title, el.label);
690
-
691
- el.label = label;
692
-
693
- let dialogScope = ScopeUtils.create({
694
- parent: scope,
695
- crud: d,
696
- ...el,
697
- owner: scope,
698
- });
699
-
700
- let dialog = {
701
- crud: d,
702
- label,
703
- parent,
704
- component,
705
- scope: dialogScope,
706
- close,
707
- props: event.props,
708
- debug: event.debug,
709
- };
710
-
711
- main.dialog = dialog;
712
- scope.currentDialog = dialog;
713
-
714
- if (parent) parent.update?.();
715
- scope.update();
716
- };
717
-
718
- scope.dialogHide = (args?: MethodType) => {
719
- let main = ViewUtils.getCrud('view');
720
- let current = main.dialog;
721
- let next = Utils.nvl(current.parent, null);
722
-
723
- main.dialog = next;
724
- scope.currentDialog = next;
725
-
726
- let nextScope = next?.scope?.parent;
727
- let currScope = current?.scope?.parent;
728
-
729
- if (currScope) {
730
- const close = current.close;
731
-
732
- currScope.update();
733
-
734
- if (close) {
735
- if (close?.debug) console.log('Fechando');
736
- current.scope.call('close', { close });
737
- }
738
- }
739
-
740
- if (nextScope) {
741
- nextScope.update();
742
- }
743
- };
744
-
745
- if (original.hideEmpty && !scope.isType('list', 'select', 'complete')) {
746
- let value = scope.getValue();
747
-
748
- if (Utils.isEmpty(value)) return <></>;
749
- }
750
-
751
- return (
752
- <CrudContext.Provider value={{ crud, theme }}>
753
- <Tag ref={ref} style={getStyle()} {...custom}>
754
- <Card>
755
- <Container />
756
- </Card>
757
- </Tag>
758
- </CrudContext.Provider>
759
- );
760
- }
761
-
762
- let boxStyle = StyleSheet.create({
763
- box: {
764
- borderWidth: 1,
765
- borderColor: '#dedede',
766
- borderStyle: 'solid',
767
- backgroundColor: 'white',
768
- borderRadius: 12,
769
- width: '100%',
770
- shadowColor: '#000',
771
- shadowOpacity: 0.1,
772
- shadowRadius: 4,
773
- },
774
- });
775
-
776
- const box: any = {
777
- ...boxStyle.box,
778
- };
779
- //v4
780
- const elementStyle: any = {};
781
-
782
- elementStyle.view = {
783
- inner: {
784
- width: '100%',
785
- alignItems: 'normal',
786
- flex: 1,
787
- },
788
- container: {
789
- width: '100%',
790
- backgroundColor: 'background',
791
- flex: 1,
792
- gap: 10,
793
- },
794
- root: {
795
- width: '100%',
796
- flex: 1,
797
- alignItems: 'normal',
798
- padding: 0,
799
- },
800
- };
801
-
802
- elementStyle.input = StyleSheet.create({
803
- label: {
804
- paddingLeft: 0,
805
- },
806
- inner: {
807
- flex: 1,
808
- width: '100%',
809
- padding: 0,
810
- gap: 10,
811
- alignSelf: 'flex-start',
812
- flexDirection: 'row',
813
- flexWrap: 'wrap',
814
- },
815
- });
816
-
817
- elementStyle.quantity = {
818
- inner: {
819
- ...box,
820
- backgroundColor: 'primarySoft',
821
- fontWeight: 600,
822
- fontSize: 16,
823
- borderRadius: 25,
824
- borderWidth: 0,
825
- paddingHorizontal: 5,
826
- paddingVertical: 5,
827
- flexWrap: 'nowrap',
828
- flex: 1,
829
- flexDirection: 'row',
830
- justifyContent: 'center',
831
- alignItems: 'center',
832
- },
833
- };
834
-
835
- elementStyle.toggle = StyleSheet.create({
836
- root: {
837
- height: 'auto',
838
- },
839
- inner: {
840
- ...box,
841
- flex: 1,
842
- width: '100%',
843
- gap: 10,
844
- borderRadius: 2,
845
- justifyContent: 'center',
846
- flexDirection: 'row',
847
- alignSelf: 'flex-start',
848
- flexWrap: 'nowrap',
849
- },
850
- });
851
-
852
- const styles = StyleSheet.create({
853
- root: {
854
- gap: 5,
855
- flexDirection: 'column',
856
- flexWrap: 'wrap',
857
- width: '100%',
858
- alignItems: 'flex-start',
859
- },
860
- label: {
861
- fontWeight: 600,
862
- fontSize: 12,
863
- paddingVertical: 3,
864
- color: 'labelColor',
865
- },
866
- inner: { width: '100%' },
867
- });
868
-
869
- const withChildStyles = StyleSheet.create({
870
- root: {
871
- gap: 10,
872
- },
873
- label: {
874
- width: '100%',
875
- fontWeight: 500,
876
- fontSize: 24,
877
- },
878
- });
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 (scope.isType('icon')) return false;
313
+ if (hasChildren()) {
314
+ return false;
315
+ }
316
+ return true;
317
+ };
318
+
319
+ if (!scope.isRendered() || scope.is('type', 'define')) {
320
+ return <></>;
321
+ }
322
+
323
+ const isShowChild = () => {
324
+ if (
325
+ scope.isType(
326
+ 'tabs',
327
+ 'view',
328
+ 'grid',
329
+ 'list',
330
+ 'define',
331
+ 'repeat',
332
+ 'modal',
333
+ 'dialog',
334
+ 'chart'
335
+ )
336
+ ) {
337
+ return false;
338
+ }
339
+
340
+ return true;
341
+ };
342
+
343
+ let isTouch =
344
+ !scope.isType('input', 'grid', 'list', 'order', 'repeat') && original.click;
345
+ let custom: any = {};
346
+
347
+ if (isTouch) {
348
+ custom.underlayColor = 'transparent';
349
+ custom.onPress = onClick;
350
+ }
351
+
352
+ let Tag = (props: any) => {
353
+ let Aux: any = View;
354
+
355
+ if (isTouch) {
356
+ Aux = TouchableHighlight;
357
+ }
358
+
359
+ if (scope.isType('dialog', 'order') || original.transient) {
360
+ return <>{props.children}</>;
361
+ }
362
+
363
+ return <Aux {...props} />;
364
+ };
365
+
366
+ let Inner = () => {
367
+ return (
368
+ <>
369
+ {scope.getPart('render', null, <></>)}
370
+ {scope.is('type', 'button') && (
371
+ <UIButton
372
+ {...defaultsUI}
373
+ onClick={onClick}
374
+ variant={scope.attr('variant', 'outlined')}
375
+ >
376
+ {original.icon && <CustomIcon />}
377
+ {original.label && (
378
+ <Text style={scope.getPart('label', 'button')}>
379
+ {scope.getLabel()}
380
+ </Text>
381
+ )}
382
+ </UIButton>
383
+ )}
384
+ {scope.is('type', 'link') && (
385
+ <UILink
386
+ {...defaultsUI}
387
+ onClick={onClick}
388
+ variant={scope.attr('variant', 'outlined')}
389
+ >
390
+ {original.icon && <CustomIcon />}
391
+ {original.label && (
392
+ <Text style={scope.getPart('label', 'link')}>
393
+ {scope.getLabel()}
394
+ </Text>
395
+ )}
396
+ </UILink>
397
+ )}
398
+ {isInput && (
399
+ <UIInput
400
+ {...defaultsInput}
401
+ {...defaultsUI}
402
+ InputProps={{ ...original.inputProps }}
403
+ />
404
+ )}
405
+ {scope.is('type', 'complete', 'autocomplete') && (
406
+ <UIComplete
407
+ scope={scope}
408
+ defaultsInput={defaultsInput}
409
+ defaultsUI={defaultsUI}
410
+ />
411
+ )}
412
+ {scope.is('type', 'quantity') && (
413
+ <UIQuantity
414
+ scope={scope}
415
+ defaultsInput={defaultsInput}
416
+ defaultsUI={defaultsUI}
417
+ />
418
+ )}
419
+ {scope.is('type', 'checkbox', 'boolean', 'switch') && (
420
+ <UISwitch
421
+ checked={isChecked()}
422
+ {...defaultsInput}
423
+ onChange={onCheck}
424
+ />
425
+ )}
426
+ {scope.isType('slider') && (
427
+ <UISlider {...defaultsInput} onChange={onCheck} />
428
+ )}
429
+ {scope.is('type', 'select') && (
430
+ <UISelect
431
+ {...defaultsInput}
432
+ {...defaultsUI}
433
+ value={scope.getSelectedValue()}
434
+ />
435
+ )}
436
+ {scope.is('type', 'toggle') && (
437
+ <UIToggle
438
+ {...defaultsInput}
439
+ {...defaultsUI}
440
+ value={scope.getSelectedValue()}
441
+ />
442
+ )}
443
+ {scope.is('type', 'radio') && (
444
+ <UIRadio {...defaultsInput} {...defaultsUI} row>
445
+ {options.map((row: any, i: number) => (
446
+ <UIOption
447
+ key={'i' + i}
448
+ control={<UIRadio {...defaultsUI} />}
449
+ label={row.label}
450
+ value={row.value}
451
+ />
452
+ ))}
453
+ </UIRadio>
454
+ )}
455
+ {scope.is('type', 'custom') && <Custom />}
456
+ {scope.is('type', 'column') && (
457
+ <>
458
+ {scope.is('format', 'img') && (
459
+ <Image source={scope.getDisplayValue()} />
460
+ )}
461
+ {scope.is('format', 'icon') && <UIIcon scope={scope} crud={crud} />}
462
+ {!scope.is('format', 'icon', 'img') && (
463
+ <Text>{scope.getDisplayValue()}</Text>
464
+ )}
465
+ </>
466
+ )}
467
+ {scope.is('type', 'output', 'value') && (
468
+ <Text style={getStyle('value')}>{scope.getDisplayValue()}</Text>
469
+ )}
470
+ </>
471
+ );
472
+ };
473
+
474
+ let Include = ({ name, style }: any) => {
475
+ if (props[name]) {
476
+ let define = ComponentUtils.getDefine(props, name);
477
+
478
+ if (!Utils.isEmpty(define)) {
479
+ return (
480
+ <UIChildren
481
+ {...props}
482
+ scope={scope}
483
+ crud={crud}
484
+ style={getStyle(name, style)}
485
+ >
486
+ {define}
487
+ </UIChildren>
488
+ );
489
+ }
490
+ }
491
+ return <></>;
492
+ };
493
+
494
+ let Container = () => {
495
+ return (
496
+ <>
497
+ {isShowLabel() && (
498
+ <View
499
+ style={getStyle('outerLabel', {
500
+ alignSelf: 'flex-start',
501
+ flexDirection: 'row',
502
+ display: 'flex',
503
+ justifyContent: 'space-between',
504
+ alignItems: 'center',
505
+ width: '100%',
506
+ })}
507
+ >
508
+ <Text style={getStyle('label')}>{scope.getLabel()}</Text>
509
+ <Include name="actions" style={{ width: 'auto' }} />
510
+ </View>
511
+ )}
512
+ {isShowInner() && (
513
+ <>
514
+ <View style={getStyle('inner')}>
515
+ <Inner />
516
+ </View>
517
+ {error && (
518
+ <View
519
+ style={getStyle('error', {
520
+ fontSize: 12,
521
+ paddingTop: 4,
522
+ color: '#e55b5b',
523
+ })}
524
+ >
525
+ {error}
526
+ </View>
527
+ )}
528
+ </>
529
+ )}
530
+ {scope.isType('list', 'repeat') && (
531
+ <UIList {...props} scope={scope} crud={crud} />
532
+ )}
533
+ {scope.isType('order') && (
534
+ <UIOrder {...props} scope={scope} crud={crud} />
535
+ )}
536
+
537
+ {scope.isType('chart') && (
538
+ <ElChart {...props} scope={scope} crud={crud} />
539
+ )}
540
+ {scope.isType('tabs') && (
541
+ <ElTabs {...props} scope={scope} crud={crud} />
542
+ )}
543
+
544
+ {scope.isType('view') && (
545
+ <UIView {...props} scope={scope} crud={crud} />
546
+ )}
547
+
548
+ {scope.is('type', 'icon') && (
549
+ <UIIcon
550
+ {...defaultsUI}
551
+ onClick={onClick}
552
+ variant={scope.attr('variant', 'outlined')}
553
+ >
554
+ {scope.getDisplayValue()}
555
+ </UIIcon>
556
+ )}
557
+
558
+ {isShowChild() && (
559
+ <UIChildren
560
+ {...props}
561
+ scope={scope}
562
+ crud={crud}
563
+ style={getStyle('inner')}
564
+ />
565
+ )}
566
+ <UIModal {...props} scope={scope} crud={crud} />
567
+ </>
568
+ );
569
+ };
570
+
571
+ let Card = (props: any) => {
572
+ let isCard = scope.is('type|layout', 'card');
573
+
574
+ if (scope.isType('list')) {
575
+ let empty = scope.getPart('empty', null, undefined);
576
+ let items = scope.getItems();
577
+
578
+ if (empty === false && Utils.isEmpty(items)) {
579
+ isCard = false;
580
+ }
581
+ }
582
+
583
+ if (isCard) {
584
+ let box = {
585
+ ...getStyle('box', { ...boxStyle.box, alignSelf: 'stretch' }),
586
+ };
587
+
588
+ let borderWidth = original.boxBorder;
589
+
590
+ if (borderWidth || borderWidth === 0) {
591
+ if (borderWidth === true) {
592
+ borderWidth = 1;
593
+ }
594
+
595
+ box = { ...box, borderWidth };
596
+ }
597
+
598
+ return (
599
+ <View style={getStyle('card', { ...box })}>
600
+ <View
601
+ style={getStyle('boxInner', {
602
+ paddingHorizontal: 15,
603
+ paddingVertical: 10,
604
+ })}
605
+ >
606
+ {props.children}
607
+ </View>
608
+ </View>
609
+ );
610
+ }
611
+
612
+ if (scope.isInput() || original.container) {
613
+ return (
614
+ <View
615
+ style={getStyle('container', { paddingVertical: 5, width: '100%' })}
616
+ >
617
+ {props.children}
618
+ </View>
619
+ );
620
+ }
621
+ return <>{props.children}</>;
622
+ };
623
+
624
+ scope.dialogShow = (args?: MethodType) => {
625
+ let event = Utils.nvl(args?.event, {});
626
+
627
+ if (event?.debug) console.log(args);
628
+
629
+ let caller = args.caller;
630
+ let main = ViewUtils.getCrud('view');
631
+ let parent = main.dialog;
632
+ let { crud } = args;
633
+ let name = scope.getName('modal');
634
+ let edit = args.edit === true;
635
+ let def: any = {};
636
+ let rowItem = null;
637
+ let component = event?.component;
638
+ let elo = Utils.nvl(caller?.original, original);
639
+
640
+ if (crud.is('row')) {
641
+ def.parent = crud.parent.parent;
642
+ def.search = crud.parent;
643
+
644
+ rowItem = crud.data;
645
+ } else if (crud.is('search')) {
646
+ def.parent = crud.parent;
647
+ def.search = crud;
648
+ }
649
+
650
+ let crudData = crud.data;
651
+ let eventData = Utils.nvl(event.data, event.send);
652
+
653
+ if (typeof eventData === 'function') {
654
+ eventData = eventData.call(this, args);
655
+ }
656
+
657
+ if (event.send === false || event.data === false) {
658
+ crudData = {};
659
+ }
660
+
661
+ let data = Utils.nvl(eventData, args.item, rowItem, crudData, {});
662
+
663
+ let d = CrudUtils.create('dialog', {
664
+ parent: crud,
665
+ root: crud,
666
+ name,
667
+ data,
668
+ edit,
669
+ scope,
670
+ ...def,
671
+ });
672
+
673
+ let el: any = {
674
+ label: elo.label,
675
+ icon: elo.icon,
676
+ type: 'dialog',
677
+ };
678
+
679
+ let close = event.dialog?.close;
680
+
681
+ if (typeof event.dialog === 'object') {
682
+ el = { ...el, ...event.dialog };
683
+ }
684
+
685
+ if (event.header) el.header = event.header;
686
+ if (event.label) el.label = event.label;
687
+ if (event.title) el.title = event.title;
688
+
689
+ let label = Utils.nvl(el.title, el.label);
690
+
691
+ el.label = label;
692
+
693
+ let dialogScope = ScopeUtils.create({
694
+ parent: scope,
695
+ crud: d,
696
+ ...el,
697
+ owner: scope,
698
+ });
699
+
700
+ let dialog = {
701
+ crud: d,
702
+ label,
703
+ parent,
704
+ component,
705
+ scope: dialogScope,
706
+ close,
707
+ props: event.props,
708
+ debug: event.debug,
709
+ };
710
+
711
+ main.dialog = dialog;
712
+ scope.currentDialog = dialog;
713
+
714
+ if (parent) parent.update?.();
715
+ scope.update();
716
+ };
717
+
718
+ scope.dialogHide = (args?: MethodType) => {
719
+ let main = ViewUtils.getCrud('view');
720
+ let current = main.dialog;
721
+ let next = Utils.nvl(current.parent, null);
722
+
723
+ main.dialog = next;
724
+ scope.currentDialog = next;
725
+
726
+ let nextScope = next?.scope?.parent;
727
+ let currScope = current?.scope?.parent;
728
+
729
+ if (currScope) {
730
+ const close = current.close;
731
+
732
+ currScope.update();
733
+
734
+ if (close) {
735
+ if (close?.debug) console.log('Fechando');
736
+ current.scope.call('close', { close });
737
+ }
738
+ }
739
+
740
+ if (nextScope) {
741
+ nextScope.update();
742
+ }
743
+ };
744
+
745
+ if (original.hideEmpty && !scope.isType('list', 'select', 'complete')) {
746
+ let value = scope.getValue();
747
+
748
+ if (Utils.isEmpty(value)) return <></>;
749
+ }
750
+
751
+ return (
752
+ <CrudContext.Provider value={{ crud, theme }}>
753
+ <Tag ref={ref} style={getStyle()} {...custom}>
754
+ <Card>
755
+ <Container />
756
+ </Card>
757
+ </Tag>
758
+ </CrudContext.Provider>
759
+ );
760
+ }
761
+
762
+ let boxStyle = StyleSheet.create({
763
+ box: {
764
+ borderWidth: 1,
765
+ borderColor: '#dedede',
766
+ borderStyle: 'solid',
767
+ backgroundColor: 'white',
768
+ borderRadius: 12,
769
+ width: '100%',
770
+ shadowColor: '#000',
771
+ shadowOpacity: 0.1,
772
+ shadowRadius: 4,
773
+ },
774
+ });
775
+
776
+ const box: any = {
777
+ ...boxStyle.box,
778
+ };
779
+ //v4
780
+ const elementStyle: any = {};
781
+
782
+ elementStyle.view = {
783
+ inner: {
784
+ width: '100%',
785
+ alignItems: 'normal',
786
+ flex: 1,
787
+ },
788
+ container: {
789
+ width: '100%',
790
+ backgroundColor: 'background',
791
+ flex: 1,
792
+ },
793
+ root: {
794
+ width: '100%',
795
+ flex: 1,
796
+ alignItems: 'normal',
797
+ padding: 0,
798
+ },
799
+ };
800
+
801
+ elementStyle.input = StyleSheet.create({
802
+ label: {
803
+ paddingLeft: 0,
804
+ },
805
+ inner: {
806
+ flex: 1,
807
+ width: '100%',
808
+ padding: 0,
809
+ alignSelf: 'flex-start',
810
+ flexDirection: 'row',
811
+ flexWrap: 'wrap',
812
+ },
813
+ });
814
+
815
+ elementStyle.quantity = {
816
+ inner: {
817
+ ...box,
818
+ backgroundColor: 'primarySoft',
819
+ fontWeight: 600,
820
+ fontSize: 16,
821
+ borderRadius: 25,
822
+ borderWidth: 0,
823
+ paddingHorizontal: 5,
824
+ paddingVertical: 5,
825
+ flexWrap: 'nowrap',
826
+ flex: 1,
827
+ flexDirection: 'row',
828
+ justifyContent: 'center',
829
+ alignItems: 'center',
830
+ },
831
+ };
832
+
833
+ elementStyle.toggle = StyleSheet.create({
834
+ root: {
835
+ height: 'auto',
836
+ },
837
+ inner: {
838
+ ...box,
839
+ flex: 1,
840
+ width: '100%',
841
+ borderRadius: 2,
842
+ justifyContent: 'center',
843
+ flexDirection: 'row',
844
+ alignSelf: 'flex-start',
845
+ flexWrap: 'nowrap',
846
+ },
847
+ });
848
+
849
+ const styles = StyleSheet.create({
850
+ root: {
851
+ flexDirection: 'column',
852
+ flexWrap: 'wrap',
853
+ width: '100%',
854
+ alignItems: 'flex-start',
855
+ },
856
+ label: {
857
+ fontWeight: 600,
858
+ fontSize: 12,
859
+ paddingVertical: 3,
860
+ color: 'labelColor',
861
+ },
862
+ inner: { flexDirection: 'row', gap: 10 },
863
+ });
864
+
865
+ const withChildStyles = StyleSheet.create({
866
+ root: {},
867
+ label: {
868
+ width: '100%',
869
+ fontWeight: 500,
870
+ fontSize: 24,
871
+ },
872
+ });