react-crud-mobile 1.1.2 → 1.3.1

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 (87) hide show
  1. package/dist/elements/UI.d.ts +47 -0
  2. package/dist/elements/UIChildren.d.ts +15 -0
  3. package/dist/elements/UIComplete.d.ts +3 -0
  4. package/dist/elements/UIElement.d.ts +3 -0
  5. package/dist/elements/UITag.d.ts +7 -0
  6. package/dist/elements/charts/ElChart.d.ts +3 -0
  7. package/dist/elements/core/SafeView.d.ts +9 -0
  8. package/dist/elements/core/UIAutoComplete.d.ts +2 -0
  9. package/dist/elements/core/UIButton.d.ts +3 -0
  10. package/dist/elements/core/UIIcon.d.ts +3 -0
  11. package/dist/elements/core/UIInclude.d.ts +3 -0
  12. package/dist/elements/core/UIInput.d.ts +3 -0
  13. package/dist/elements/core/UILink.d.ts +2 -0
  14. package/dist/elements/core/UIList.d.ts +3 -0
  15. package/dist/elements/core/UIListItem.d.ts +7 -0
  16. package/dist/elements/core/UIListRow.d.ts +8 -0
  17. package/dist/elements/core/UIModal.d.ts +3 -0
  18. package/dist/elements/core/UIOption.d.ts +2 -0
  19. package/dist/elements/core/UIQuantity.d.ts +3 -0
  20. package/dist/elements/core/UIRadio.d.ts +2 -0
  21. package/dist/elements/core/UISelect.d.ts +3 -0
  22. package/dist/elements/core/UISlider.d.ts +3 -0
  23. package/dist/elements/core/UISwitch.d.ts +3 -0
  24. package/dist/elements/core/UIToast.d.ts +2 -0
  25. package/dist/elements/core/UIToggle.d.ts +3 -0
  26. package/dist/elements/core/UIView.d.ts +3 -0
  27. package/dist/elements/index.d.ts +1 -0
  28. package/dist/elements/tabs/ElTabs.d.ts +3 -0
  29. package/dist/hooks/useIsVisible.d.ts +2 -0
  30. package/dist/index.d.ts +1 -2
  31. package/dist/react-crud-mobile.cjs.development.js +2364 -0
  32. package/dist/react-crud-mobile.cjs.development.js.map +1 -0
  33. package/dist/react-crud-mobile.cjs.production.min.js +2 -0
  34. package/dist/react-crud-mobile.cjs.production.min.js.map +1 -0
  35. package/dist/react-crud-mobile.esm.js +2356 -0
  36. package/dist/react-crud-mobile.esm.js.map +1 -0
  37. package/dist/utils/MobileUtils.d.ts +3 -0
  38. package/package.json +75 -50
  39. package/src/elements/UI.tsx +73 -57
  40. package/src/elements/UIChildren.tsx +139 -117
  41. package/src/elements/UIComplete.tsx +14 -15
  42. package/src/elements/UIElement.tsx +692 -379
  43. package/src/elements/UITag.tsx +13 -13
  44. package/src/elements/charts/ElChart.tsx +10 -10
  45. package/src/elements/core/SafeView.tsx +69 -0
  46. package/src/elements/core/{Link.tsx → UIAutoComplete.tsx} +1 -2
  47. package/src/elements/core/UIButton.tsx +139 -0
  48. package/src/elements/core/UIIcon.tsx +25 -0
  49. package/src/elements/{grid/ElInclude.tsx → core/UIInclude.tsx} +40 -40
  50. package/src/elements/core/UIInput.tsx +96 -0
  51. package/src/elements/core/{Icon.tsx → UILink.tsx} +1 -2
  52. package/src/elements/core/UIList.tsx +168 -0
  53. package/src/elements/core/UIListItem.tsx +32 -0
  54. package/src/elements/core/UIListRow.tsx +123 -0
  55. package/src/elements/core/UIModal.tsx +204 -0
  56. package/src/elements/core/{Input.tsx → UIOption.tsx} +1 -2
  57. package/src/elements/core/UIQuantity.tsx +98 -0
  58. package/src/elements/core/{Radio.tsx → UIRadio.tsx} +1 -2
  59. package/src/elements/core/UISelect.tsx +135 -0
  60. package/src/elements/core/UISlider.tsx +61 -0
  61. package/src/elements/core/UISwitch.tsx +27 -0
  62. package/src/elements/core/UIToast.tsx +44 -0
  63. package/src/elements/core/UIToggle.tsx +102 -0
  64. package/src/elements/core/UIView.tsx +94 -0
  65. package/src/elements/grid/ElInclude +0 -0
  66. package/src/elements/index.ts +1 -1
  67. package/src/elements/tabs/ElTabs.tsx +178 -178
  68. package/src/hooks/useIsVisible.ts +39 -0
  69. package/src/index.ts +1 -1
  70. package/src/utils/MobileUtils.ts +12 -0
  71. package/src/elements/card/ElCard.tsx +0 -26
  72. package/src/elements/core/AutoComplete.tsx +0 -18
  73. package/src/elements/core/Button.tsx +0 -18
  74. package/src/elements/core/Option.tsx +0 -18
  75. package/src/elements/core/Select.tsx +0 -18
  76. package/src/elements/core/Switch.tsx +0 -18
  77. package/src/elements/grid/ElGrid.tsx +0 -50
  78. package/src/elements/grid/ElGridBotom.tsx +0 -21
  79. package/src/elements/grid/ElGridCheck.tsx +0 -67
  80. package/src/elements/grid/ElGridColumn.tsx +0 -32
  81. package/src/elements/grid/ElGridFilter.tsx +0 -5
  82. package/src/elements/grid/ElGridPaginator.tsx +0 -82
  83. package/src/elements/grid/ElGridRow.tsx +0 -123
  84. package/src/elements/grid/ElGridTop.tsx +0 -45
  85. package/src/elements/grid/ElLabel.tsx +0 -50
  86. package/src/elements/grid/ElRepeat.tsx +0 -24
  87. package/src/elements/grid/ElRepeatRow.tsx +0 -40
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
3
-
4
- export default function Option(props: any) {
5
- const handlePress = () => {
6
- Linking.openURL('https://reactnative.dev/');
7
- };
8
-
9
- return (
10
- <TouchableOpacity onPress={handlePress}>
11
- <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
12
- </TouchableOpacity>
13
- );
14
- }
15
-
16
- const styles = {
17
- link: {},
18
- };
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
3
-
4
- export default function Select(props: any) {
5
- const handlePress = () => {
6
- Linking.openURL('https://reactnative.dev/');
7
- };
8
-
9
- return (
10
- <TouchableOpacity onPress={handlePress}>
11
- <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
12
- </TouchableOpacity>
13
- );
14
- }
15
-
16
- const styles = {
17
- link: {},
18
- };
@@ -1,18 +0,0 @@
1
- import React from 'react';
2
- import { Text, TouchableOpacity, Linking, StyleSheet } from 'react-native';
3
-
4
- export default function Switch(props: any) {
5
- const handlePress = () => {
6
- Linking.openURL('https://reactnative.dev/');
7
- };
8
-
9
- return (
10
- <TouchableOpacity onPress={handlePress}>
11
- <Text style={styles.link}>Clique aqui para acessar o React Native</Text>
12
- </TouchableOpacity>
13
- );
14
- }
15
-
16
- const styles = {
17
- link: {},
18
- };
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
-
3
- import ElGridRow from './ElGridRow';
4
- import ElGridTop from './ElGridTop';
5
- import ElGridFilter from './ElGridFilter';
6
- import ElGridBotom from './ElGridBotom';
7
- import ElLabel from './ElLabel';
8
- import { ChildType, ComponentUtils, Scope } from 'react-crud-utils';
9
-
10
- export default function ElGrid(props: ChildType) {
11
- let scope: Scope = props.scope;
12
- let items: any = scope.getItems();
13
- let expansion = ComponentUtils.getDefine(props, 'expansion');
14
-
15
- return (
16
- <div
17
- className={scope.getStyleClass('inner')}
18
- style={scope.getStyle('inner')}
19
- >
20
- <ElLabel {...props} scope={scope} position="outside"></ElLabel>
21
- <div
22
- className={scope.getStyleClass('child')}
23
- style={scope.getStyle('child')}
24
- >
25
- <ElLabel {...props} scope={scope} position="inside"></ElLabel>
26
- <div className="ui-data">
27
- <ElGridTop {...props} scope={scope}></ElGridTop>
28
- <ElGridFilter scope={scope}></ElGridFilter>
29
- <div className="ui-grid-data">
30
- <table className="ui-grid ui-table">
31
- <tbody>
32
- {items.map((row: any, i: number) => (
33
- <ElGridRow
34
- {...props}
35
- expansion={expansion}
36
- key={'r' + i}
37
- scope={scope}
38
- value={row}
39
- index={i}
40
- />
41
- ))}
42
- </tbody>
43
- </table>
44
- </div>
45
- </div>
46
- <ElGridBotom {...props} scope={scope} />
47
- </div>
48
- </div>
49
- );
50
- }
@@ -1,21 +0,0 @@
1
- import React, { useState } from "react";
2
- import ElGridPaginator from "./ElGridPaginator";
3
- import UI from "../UI";
4
- import { ChildType } from "react-crud-utils";
5
-
6
- export default function ElGridBotom(props: ChildType) {
7
- let scope = props.scope;
8
- let children = props.children;
9
-
10
- return (
11
- <div className="ui-grid-bottom">
12
- <div className="ui-grid-bottom-inner">
13
- <UI.Include {...props} transient name="bottomLeft" />
14
- <ElGridPaginator scope={scope} position="bottom">
15
- {children}
16
- </ElGridPaginator>
17
- <UI.Include {...props} transient name="bottomRight" />
18
- </div>
19
- </div>
20
- );
21
- }
@@ -1,67 +0,0 @@
1
- import UI from '../UI';
2
- import Ionicons from '@expo/vector-icons/Ionicons';
3
- import { useState } from 'react';
4
- import { GridRowType, Utils } from 'react-crud-utils';
5
-
6
- export default function ElGridCheck({ scope, value, rowIndex }: GridRowType) {
7
- let original = scope.original;
8
- let [index, setIndex] = useState(0);
9
- let key = scope.key('check', rowIndex, 's', index);
10
-
11
- let check = () => {
12
- let cs = scope.crudSearch;
13
-
14
- if (cs) {
15
- if (!cs.selecteds) {
16
- cs.selecteds = {};
17
- }
18
-
19
- let itemValue = Utils.nvl(original.itemValue, 'id');
20
- let key = value[itemValue];
21
-
22
- if (typeof key !== 'undefined') {
23
- if (typeof cs.selecteds[key] === 'undefined') {
24
- cs.selecteds[key] = value;
25
- } else {
26
- delete cs.selecteds[key];
27
- }
28
- }
29
- }
30
- setIndex(++index);
31
- };
32
-
33
- let getCheckIcon = () => {
34
- if (isChecked()) {
35
- return <Ionicons />;
36
- }
37
- return <Ionicons />;
38
- };
39
-
40
- let isChecked = () => {
41
- let cs = scope.crudSearch;
42
-
43
- if (cs) {
44
- if (!cs.selecteds) {
45
- cs.selecteds = {};
46
- }
47
-
48
- let itemValue = Utils.nvl(original.itemValue, 'id');
49
- let key = value[itemValue];
50
-
51
- if (typeof key !== 'undefined') {
52
- if (typeof cs.selecteds[key] !== 'undefined') {
53
- return true;
54
- }
55
- }
56
- }
57
- return false;
58
- };
59
-
60
- return (
61
- <UI.Button
62
- key={key}
63
- icon={getCheckIcon()}
64
- click={{ action: check }}
65
- ></UI.Button>
66
- );
67
- }
@@ -1,32 +0,0 @@
1
- import React, { useState } from "react";
2
- import UIChildren from "../UIChildren";
3
- import { Scope, Utils } from "react-crud-utils";
4
-
5
- interface ElGridColumnType {
6
- scope: Scope;
7
- styleClass?: string;
8
- children?: any;
9
- colspan?: number;
10
- column?: any;
11
- }
12
-
13
- export default function ElGridColumn(props: ElGridColumnType) {
14
- let scope = props.scope;
15
- let col = Utils.nvl(props.column?.props, {});
16
- let [colScope] = useState(new Scope(col, scope, scope.crud));
17
-
18
- let getStyleClass = () => {
19
- let def = Utils.nvl(props.styleClass, "");
20
-
21
- return "ui-grid-col " + def + " " + colScope.getStyleClass("column");
22
- };
23
- return (
24
- <td
25
- className={getStyleClass()}
26
- style={colScope.getStyle("column")}
27
- colSpan={props.colspan}
28
- >
29
- <UIChildren scope={scope}>{props.children}</UIChildren>
30
- </td>
31
- );
32
- }
@@ -1,5 +0,0 @@
1
- import { ChildType } from "react-crud-utils";
2
-
3
- export default function ElGridFilter(props: ChildType) {
4
- return <></>;
5
- }
@@ -1,82 +0,0 @@
1
- import React, { useState } from 'react';
2
- import UI from '../UI';
3
- import { ChildType, Utils } from 'react-crud-utils';
4
- import Ionicons from '@expo/vector-icons/Ionicons';
5
-
6
- interface ElGridPaginatorType extends ChildType {
7
- next?: boolean;
8
- previous?: boolean;
9
- first?: boolean;
10
- size?: boolean;
11
- last?: boolean;
12
- position: string;
13
- }
14
-
15
- export default function ElGridPaginator({
16
- scope,
17
- next,
18
- previous,
19
- first,
20
- size,
21
- last,
22
- position,
23
- }: ElGridPaginatorType) {
24
- let [sizes] = useState([10, 20, 30, 50, 100, 200, 500]);
25
- let defaults = {
26
- crud: scope.crudSearch,
27
- owner: scope,
28
- variant: scope.attr('variant', 'text'),
29
- };
30
-
31
- let paginatorPosition = Utils.nvl(scope.original.paginatorPosition, 'bottom');
32
-
33
- if (paginatorPosition !== position) {
34
- return <></>;
35
- }
36
-
37
- return (
38
- <>
39
- <UI.Button
40
- field="first"
41
- space={0}
42
- rendered={first !== false}
43
- {...defaults}
44
- click="first"
45
- icon={<Ionicons />}
46
- ></UI.Button>
47
- <UI.Button
48
- field="previous"
49
- space={0}
50
- rendered={previous !== false}
51
- click="previous"
52
- {...defaults}
53
- icon={<Ionicons />}
54
- ></UI.Button>
55
- <UI.Select
56
- field="size"
57
- space={0}
58
- rendered={size !== false}
59
- default={10}
60
- {...defaults}
61
- data={sizes}
62
- change="search"
63
- ></UI.Select>
64
- <UI.Button
65
- field="next"
66
- space={0}
67
- rendered={next !== false}
68
- {...defaults}
69
- click="next"
70
- icon={<Ionicons />}
71
- ></UI.Button>
72
- <UI.Button
73
- field="last"
74
- space={0}
75
- rendered={last !== false}
76
- {...defaults}
77
- click="last"
78
- icon={<Ionicons />}
79
- ></UI.Button>
80
- </>
81
- );
82
- }
@@ -1,123 +0,0 @@
1
- import React, { useState } from 'react';
2
- import ElGridColumn from './ElGridColumn';
3
- import ElGridCheck from './ElGridCheck';
4
- import Ionicons from '@expo/vector-icons/Ionicons';
5
- import UI from '../UI';
6
- import UIChildren from '../UIChildren';
7
- import {
8
- ComponentUtils,
9
- CrudUtils,
10
- ListType,
11
- RowType,
12
- Scope,
13
- Utils,
14
- } from 'react-crud-utils';
15
-
16
- export default function ElGridRow(props: RowType) {
17
- let expansion = props.expansion;
18
- let value = props.value;
19
- let scope = props.scope;
20
- let index = props.index;
21
- let original: ListType = scope.original;
22
-
23
- let row = CrudUtils.create('row', {
24
- index,
25
- row: true,
26
- itemVar: scope.original.itemVar,
27
- parent: scope.crudSearch,
28
- data: value,
29
- });
30
-
31
- let [expanded, setExpanded] = useState(false);
32
- let [rowScope] = useState(new Scope(scope.original, scope, row));
33
-
34
- let getRowStyleClass = () => {
35
- let s = 'ui-grid-row';
36
-
37
- s = s + ' ui-grid-row-';
38
-
39
- if (index % 2 == 0) {
40
- s = s + 'even';
41
- } else {
42
- s = s + 'odd';
43
- }
44
- return s;
45
- };
46
-
47
- let cols = ComponentUtils.getChild(props, 'Column');
48
- let colspan = cols.length;
49
-
50
- let ExpansionStatus = () => {
51
- return (
52
- <>
53
- {!expanded && <Ionicons />}
54
- {expanded && <Ionicons />}
55
- </>
56
- );
57
- };
58
-
59
- let onExpansion = () => {
60
- setExpanded(!expanded);
61
- };
62
-
63
- let hasExpansion = !Utils.isEmpty(expansion);
64
- let multiple = original.multiple;
65
-
66
- if (hasExpansion) colspan++;
67
- if (multiple) colspan++;
68
-
69
- return (
70
- <>
71
- <tr className={getRowStyleClass()} style={rowScope.getStyle('row')}>
72
- {hasExpansion && (
73
- <ElGridColumn
74
- key={'r' + index + 'e'}
75
- scope={rowScope}
76
- styleClass="ui-click ui-icon-only ui-expansion"
77
- >
78
- <UI.Button
79
- icon={<ExpansionStatus />}
80
- click={onExpansion}
81
- ></UI.Button>
82
- </ElGridColumn>
83
- )}
84
- {multiple && (
85
- <ElGridColumn
86
- key={'r' + index + 'c'}
87
- scope={rowScope}
88
- styleClass="ui-click ui-icon-only ui-multiple"
89
- >
90
- <ElGridCheck
91
- key={'check-' + index}
92
- scope={scope}
93
- value={value}
94
- rowIndex={index}
95
- />
96
- </ElGridColumn>
97
- )}
98
- {cols.map((col: any, i: number) => (
99
- <ElGridColumn
100
- column={col}
101
- key={'r' + index + 'c' + i}
102
- scope={rowScope}
103
- >
104
- {col}
105
- </ElGridColumn>
106
- ))}
107
- </tr>
108
- {expanded && (
109
- <tr className={getRowStyleClass()} style={rowScope.getStyle('row')}>
110
- <ElGridColumn
111
- key={'r' + index + '-expanded'}
112
- scope={rowScope}
113
- colspan={colspan}
114
- >
115
- <UIChildren {...props} crud={row}>
116
- {expansion}
117
- </UIChildren>
118
- </ElGridColumn>
119
- </tr>
120
- )}
121
- </>
122
- );
123
- }
@@ -1,45 +0,0 @@
1
- import React from 'react';
2
- import UI from '../UI';
3
- import Ionicons from '@expo/vector-icons/Ionicons';
4
- import ElGridPaginator from './ElGridPaginator';
5
- import { ChildType } from 'react-crud-utils';
6
-
7
- export default function ElGridTop(props: ChildType) {
8
- let scope = props.scope;
9
-
10
- return (
11
- <>
12
- <UI.Output styleClass="ui-grid-top">
13
- <UI.Output field="search" position="left" space={4}>
14
- <UI.Include {...props} transient name="top" position="left" />
15
- <UI.Text
16
- field="query"
17
- space={0}
18
- label="Pesquisar"
19
- placeholder={scope.attr('placeholder', 'Pesquisar')}
20
- >
21
- <UI.Define name="right">
22
- <UI.Button
23
- field="search"
24
- icon={<Ionicons />}
25
- space={0}
26
- variant="text"
27
- owner={scope}
28
- click={'search'}
29
- ></UI.Button>
30
- </UI.Define>
31
- </UI.Text>
32
- </UI.Output>
33
- <UI.Output position="right" space={8}>
34
- <UI.Include {...props} transient name="top" position="right" />
35
- <ElGridPaginator
36
- scope={scope}
37
- last={false}
38
- first={false}
39
- position="top"
40
- ></ElGridPaginator>
41
- </UI.Output>
42
- </UI.Output>
43
- </>
44
- );
45
- }
@@ -1,50 +0,0 @@
1
- import React from 'react';
2
- import UI from '../UI';
3
- import { ChildType, Utils } from 'react-crud-utils';
4
- import Icon from '../core/Icon';
5
-
6
- interface ElLabelType extends ChildType {
7
- position?: string;
8
- }
9
- export default function ElLabel(props: ElLabelType) {
10
- let scope = props.scope;
11
- let original = scope.original;
12
- let defaultPos = 'outside';
13
-
14
- let elPos = Utils.nvl(original.labelPos, defaultPos);
15
- let lbPos = Utils.nvl(props.position, defaultPos);
16
-
17
- if (elPos != lbPos) {
18
- return <></>;
19
- }
20
-
21
- const CustomIcon = () => {
22
- if (!scope.is('type', 'list', 'grid')) {
23
- return <></>;
24
- }
25
-
26
- if (typeof original.icon === 'string') {
27
- return (
28
- <div className="ui-label-icon">
29
- <Icon className={scope.getIcon()}></Icon>
30
- </div>
31
- );
32
- }
33
- return <div className="ui-label-icon">{original.icon}</div>;
34
- };
35
-
36
- let label = scope.getLabel();
37
-
38
- return (
39
- <div className={'ui-label ui-label-' + lbPos}>
40
- <div className="ui-label-left">
41
- <UI.Include {...props} transient name="label" position="left" />
42
- <CustomIcon />
43
- {label && <div className="ui-label-value">{label}</div>}
44
- </div>
45
- <div className="ui-label-right">
46
- <UI.Include {...props} transient name="label" position="right" />
47
- </div>
48
- </div>
49
- );
50
- }
@@ -1,24 +0,0 @@
1
- import ElRepeatRow from './ElRepeatRow';
2
- import { ChildType, Scope } from 'react-crud-utils';
3
-
4
- export default function ElRepeat(props: ChildType) {
5
- let scope: Scope = props.scope;
6
- let items: any = scope.getItems();
7
-
8
- return (
9
- <div
10
- className={scope.getStyleClass('inner')}
11
- style={scope.getStyle('inner')}
12
- >
13
- {items.map((row: any, i: number) => (
14
- <ElRepeatRow
15
- {...props}
16
- key={'r' + i}
17
- scope={scope}
18
- value={row}
19
- index={i}
20
- />
21
- ))}
22
- </div>
23
- );
24
- }
@@ -1,40 +0,0 @@
1
- import React, { useState } from "react";
2
- import UIChildren from "../UIChildren";
3
- import { CrudUtils, RowType, Scope } from "react-crud-utils";
4
-
5
- export default function ElRepeatRow(props: RowType) {
6
- let value = props.value;
7
- let scope = props.scope;
8
- let index = props.index;
9
-
10
- let row = CrudUtils.create("row", {
11
- index,
12
- row: true,
13
- itemVar: scope.original.itemVar,
14
- parent: scope.crudSearch,
15
- data: value,
16
- });
17
-
18
- let [rowScope] = useState(new Scope(scope.original, scope, row));
19
-
20
- let getRowStyleClass = () => {
21
- let s = rowScope.getStyleClass("row");
22
-
23
- s = s + " ui-repeat-row-";
24
-
25
- if (index % 2 == 0) {
26
- s = s + "even";
27
- } else {
28
- s = s + "odd";
29
- }
30
- return s;
31
- };
32
-
33
- return (
34
- <div className={getRowStyleClass()} style={rowScope.getStyle("row")}>
35
- <UIChildren transient {...props} crud={row}>
36
- {props.children}
37
- </UIChildren>
38
- </div>
39
- );
40
- }