react-crud-mobile 1.3.86 → 1.3.87

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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.86",
2
+ "version": "1.3.87",
3
3
  "license": "MIT",
4
4
  "description": "Uma biblioteca de componentes para React Native",
5
5
  "main": "dist/index.js",
@@ -58,7 +58,6 @@ export default function UIElement(props: ElementType) {
58
58
  let crud: Crud = Utils.nvl(props.crud, ctx?.crud);
59
59
  let [scope] = useState(ScopeUtils.create({ crud, ...props, theme }));
60
60
  let [index, setIndex] = useState(0);
61
- let [dialog, setDialog] = useState(null);
62
61
  let [error, setError]: string | any = useState(null);
63
62
 
64
63
  scope.compile(props);
@@ -533,16 +532,14 @@ export default function UIElement(props: ElementType) {
533
532
  <UIModal {...props} scope={scope} crud={crud} />
534
533
  )}
535
534
 
536
- {dialog && (
535
+ {scope.currentDialog?.component && (
537
536
  <UIModal
538
537
  {...props}
539
538
  scope={scope}
540
- crud={dialog.crud}
539
+ crud={scope.currentDialog?.crud}
541
540
  open
542
- dialog={dialog}
543
- >
544
- {dialog.component}
545
- </UIModal>
541
+ dialog={scope.currentDialog}
542
+ />
546
543
  )}
547
544
 
548
545
  {scope.isType('chart') && (
@@ -601,46 +598,42 @@ export default function UIElement(props: ElementType) {
601
598
  };
602
599
 
603
600
  scope.dialogOpen = (args?: MethodType) => {
604
- if (!dialog) {
605
- let { crud, event } = args;
606
- let name = scope.getName('modal');
607
- let edit = args.edit === true;
608
- let def: any = {};
609
- let rowItem = null;
610
- let main = ViewUtils.getCrud('view');
611
-
612
- if (crud.is('row')) {
613
- def.parent = crud.parent.parent;
614
- def.search = crud.parent;
615
-
616
- rowItem = crud.data;
617
- } else if (crud.is('search')) {
618
- def.parent = crud.parent;
619
- def.search = crud;
620
- }
621
-
622
- let data = Utils.nvl(args.item, rowItem, {});
623
- let component = event?.component;
624
-
625
- if (component) {
626
- let d = CrudUtils.create('dialog', {
627
- parent: crud,
628
- root: crud,
629
- name,
630
- dialog: main.dialog,
631
- data,
632
- edit,
633
- scope,
634
- ...def,
635
- });
636
-
637
- main.dialog = d;
638
-
639
- scope.currentDialog = d;
601
+ let { crud, event } = args;
602
+ let name = scope.getName('modal');
603
+ let edit = args.edit === true;
604
+ let def: any = {};
605
+ let rowItem = null;
606
+ let main = ViewUtils.getCrud('view');
607
+
608
+ if (crud.is('row')) {
609
+ def.parent = crud.parent.parent;
610
+ def.search = crud.parent;
611
+
612
+ rowItem = crud.data;
613
+ } else if (crud.is('search')) {
614
+ def.parent = crud.parent;
615
+ def.search = crud;
616
+ }
640
617
 
641
- dialog = { component, crud: d };
642
- setDialog(dialog);
643
- }
618
+ let data = Utils.nvl(args.item, rowItem, {});
619
+ let component = event?.component;
620
+
621
+ if (component) {
622
+ let d = CrudUtils.create('dialog', {
623
+ parent: crud,
624
+ root: crud,
625
+ name,
626
+ dialog: main.dialog,
627
+ data,
628
+ edit,
629
+ scope,
630
+ ...def,
631
+ });
632
+
633
+ main.dialog = d;
634
+
635
+ scope.currentDialog = { component, crud: d };
636
+ scope.update();
644
637
  }
645
638
  };
646
639
 
@@ -48,7 +48,7 @@ export default function UIModal({
48
48
  };
49
49
 
50
50
  const onClose = () => {
51
- scope.close({ scope, crud: scope.currentDialog, event: {} });
51
+ scope.close({ scope, crud: scope.currentDialog?.crud, event: {} });
52
52
  };
53
53
 
54
54
  const toggle = vis => {
@@ -92,7 +92,7 @@ export default function UIModal({
92
92
 
93
93
  main.dialog = d;
94
94
 
95
- scope.currentDialog = d;
95
+ scope.currentDialog = { crud: d };
96
96
 
97
97
  toggle(true);
98
98
  scope.update();
@@ -112,7 +112,7 @@ export default function UIModal({
112
112
  scope.update();
113
113
  };
114
114
 
115
- let curr = scope.currentDialog;
115
+ let curr = scope.currentDialog?.crud;
116
116
 
117
117
  if (!curr) {
118
118
  return <></>;
@@ -131,16 +131,16 @@ export default function UIModal({
131
131
 
132
132
  let color = Utils.nvl(headerStyle.color, 'white');
133
133
  let defaults = { color };
134
- let key = `${scope.currentDialog.name}-${index}`;
134
+ let key = `${curr.name}-${index}`;
135
135
 
136
136
  let Content = () => {
137
137
  if (dialog?.component) {
138
138
  let Aux = dialog?.component;
139
139
 
140
- return <Aux crud={scope.currentDialog} />;
140
+ return <Aux crud={curr} />;
141
141
  }
142
142
  return (
143
- <UIChildren scope={scope} crud={scope.currentDialog}>
143
+ <UIChildren scope={scope} crud={curr}>
144
144
  {props.children}
145
145
  </UIChildren>
146
146
  );
@@ -167,7 +167,7 @@ export default function UIModal({
167
167
  </TouchableOpacity>
168
168
  <Text style={style('modalTitle', defaults)}>{label}</Text>
169
169
  {!Utils.isEmpty(headerRight) && (
170
- <UIChildren scope={scope} crud={scope.currentDialog} transient>
170
+ <UIChildren scope={scope} crud={curr} transient>
171
171
  {headerRight}
172
172
  </UIChildren>
173
173
  )}