react-crud-mobile 1.0.607 → 1.0.608
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/dist/react-crud-mobile.cjs.development.js +49 -46
- package/dist/react-crud-mobile.cjs.development.js.map +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js +1 -1
- package/dist/react-crud-mobile.cjs.production.min.js.map +1 -1
- package/dist/react-crud-mobile.esm.js +49 -46
- package/dist/react-crud-mobile.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/elements/core/UIList.tsx +24 -32
- package/src/elements/core/UIListRow.tsx +13 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { ChildType, ComponentUtils,
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChildType, ComponentUtils, Utils } from 'react-crud-utils';
|
|
3
3
|
import { StyleSheet, Text, TouchableHighlight, View } from 'react-native';
|
|
4
4
|
import UIListRow from './UIListRow';
|
|
5
5
|
import UI from '../UI';
|
|
6
6
|
import { Ionicons } from '@expo/vector-icons';
|
|
7
|
-
import UIChildren from '../UIChildren';
|
|
8
7
|
|
|
9
8
|
export default function UIList(props: ChildType) {
|
|
10
9
|
const scope = props.scope;
|
|
@@ -17,10 +16,24 @@ export default function UIList(props: ChildType) {
|
|
|
17
16
|
const add = ComponentUtils.getDefine(props, 'add');
|
|
18
17
|
const hideAddWhenEmpty = original.hideAddWhenEmpty;
|
|
19
18
|
|
|
19
|
+
const onClick = (item: any) => {
|
|
20
|
+
scope.call('click', { value: item, item, edit: true });
|
|
21
|
+
};
|
|
22
|
+
|
|
20
23
|
const getStyle = (key: string, extra?: any) => {
|
|
21
24
|
return scope.getStyle(key, { ...extra, ...styles[key] });
|
|
22
25
|
};
|
|
23
26
|
|
|
27
|
+
const getRowStyle = (extra?: any) => {
|
|
28
|
+
let row = getStyle('row', {});
|
|
29
|
+
|
|
30
|
+
if (cols > 0) {
|
|
31
|
+
row.width = rowWidth;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return row;
|
|
35
|
+
};
|
|
36
|
+
|
|
24
37
|
const getContainerStyle = (extra?: any) => {
|
|
25
38
|
let row = getStyle('container', {});
|
|
26
39
|
|
|
@@ -70,36 +83,11 @@ export default function UIList(props: ChildType) {
|
|
|
70
83
|
return <>{empty}</>;
|
|
71
84
|
};
|
|
72
85
|
|
|
73
|
-
let RowItem = ({ item, index }) => {
|
|
74
|
-
const name = `${scope.key('row', index)}`;
|
|
75
|
-
const row = {
|
|
76
|
-
parent: scope,
|
|
77
|
-
name,
|
|
78
|
-
crud: scope.crud,
|
|
79
|
-
index,
|
|
80
|
-
type: 'row',
|
|
81
|
-
data: item,
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
let [rowScope] = useState(ScopeUtils.create(row));
|
|
85
|
-
const getRowStyle = (extra?: any) => {
|
|
86
|
-
let row = scope.getStyle('row', { ...extra, ...styles.row });
|
|
87
|
-
|
|
88
|
-
if (cols > 0) {
|
|
89
|
-
row.width = rowWidth;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return row;
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
const onClick = (item: any) => {
|
|
96
|
-
scope.call('click', { value: item, item, edit: true });
|
|
97
|
-
};
|
|
98
|
-
|
|
86
|
+
let RowItem = ({ item, index, children }) => {
|
|
99
87
|
if (!original.click) {
|
|
100
88
|
return (
|
|
101
89
|
<View key={`k-${index}`} style={getRowStyle()}>
|
|
102
|
-
|
|
90
|
+
{children}
|
|
103
91
|
</View>
|
|
104
92
|
);
|
|
105
93
|
}
|
|
@@ -113,7 +101,7 @@ export default function UIList(props: ChildType) {
|
|
|
113
101
|
onClick(item);
|
|
114
102
|
}}
|
|
115
103
|
>
|
|
116
|
-
|
|
104
|
+
{children}
|
|
117
105
|
</TouchableHighlight>
|
|
118
106
|
);
|
|
119
107
|
};
|
|
@@ -131,7 +119,11 @@ export default function UIList(props: ChildType) {
|
|
|
131
119
|
<View style={getContainerStyle()}>
|
|
132
120
|
<Empty />
|
|
133
121
|
{items.map((item: any, i: number) => (
|
|
134
|
-
<RowItem index={i} item={item}
|
|
122
|
+
<RowItem index={i} item={item}>
|
|
123
|
+
<UIListRow scope={scope} item={item} index={i}>
|
|
124
|
+
{props.children}
|
|
125
|
+
</UIListRow>
|
|
126
|
+
</RowItem>
|
|
135
127
|
))}
|
|
136
128
|
{isShowAdd() && <>{add}</>}
|
|
137
129
|
</View>
|
|
@@ -8,7 +8,19 @@ interface UIListRowType extends ChildType {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export default function UIListRow(props: UIListRowType) {
|
|
11
|
-
const
|
|
11
|
+
const parent = props.scope;
|
|
12
|
+
const item = props.item;
|
|
13
|
+
const index = props.index;
|
|
14
|
+
const name = `${parent.key('row', index)}`;
|
|
15
|
+
const row = {
|
|
16
|
+
parent,
|
|
17
|
+
name,
|
|
18
|
+
crud: parent.crud,
|
|
19
|
+
index,
|
|
20
|
+
type: 'row',
|
|
21
|
+
data: item,
|
|
22
|
+
};
|
|
23
|
+
let [scope] = useState(ScopeUtils.create(row));
|
|
12
24
|
|
|
13
25
|
return (
|
|
14
26
|
<>
|