@controleonline/ui-default 1.0.263 → 1.0.264
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/AGENTS.md +48 -47
- package/package.json +3 -6
- package/src/react/components/errors/DefaultErrors.js +360 -360
- package/src/react/components/files/DefaultFile.js +46 -46
- package/src/react/components/filters/CompactFilterSelector.js +22 -3
- package/src/react/components/filters/DefaultColumnFilter.js +15 -13
- package/src/react/components/filters/DefaultExternalFilters.js +44 -39
- package/src/react/components/filters/DefaultSearch.js +140 -103
- package/src/react/components/filters/DefaultSearch.styles.js +65 -70
- package/src/react/components/form/DefaultForm.js +200 -198
- package/src/react/components/help/DefaultTooltip.js +87 -87
- package/src/react/components/help/DefaultTooltip.styles.js +61 -61
- package/src/react/components/inputs/DefaultInput.js +162 -160
- package/src/react/components/inputs/DefaultSelect.js +203 -192
- package/src/react/components/map/DefaultGoogleMap.styles.js +115 -9
- package/src/react/components/map/DefaultGoogleMap.web.js +560 -446
- package/src/react/components/map/DefaultMap.native.js +73 -71
- package/src/react/components/map/DefaultMap.styles.js +16 -16
- package/src/react/components/map/DefaultMap.web.js +68 -66
- package/src/react/components/map/DefaultNativeMap.native.js +307 -183
- package/src/react/components/map/DefaultNativeMap.shared.js +439 -340
- package/src/react/components/map/DefaultNativeMap.styles.js +156 -122
- package/src/react/components/table/DefaultTable.js +529 -355
- package/src/react/components/table/DefaultTable.styles.js +30 -39
- package/src/react/index.js +10 -10
- package/src/tests/react/components/errors/DefaultErrors.test.js +162 -162
- package/src/tests/react/components/files/DefaultFile.test.js +80 -80
- package/src/tests/react/components/inputs/DefaultSelect.test.js +93 -0
- package/src/tests/react/components/table/DefaultTable.test.js +334 -0
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
|
|
3
|
-
const styles = StyleSheet.create({
|
|
4
|
-
button: {
|
|
5
|
-
alignItems: 'center',
|
|
6
|
-
borderRadius: 999,
|
|
7
|
-
borderWidth: 1,
|
|
8
|
-
height: 22,
|
|
9
|
-
justifyContent: 'center',
|
|
10
|
-
width: 22,
|
|
11
|
-
},
|
|
12
|
-
label: {
|
|
13
|
-
fontSize: 12,
|
|
14
|
-
fontWeight: '800',
|
|
15
|
-
lineHeight: 12,
|
|
16
|
-
},
|
|
17
|
-
overlay: {
|
|
18
|
-
alignItems: 'center',
|
|
19
|
-
backgroundColor: 'rgba(15, 23, 42, 0.55)',
|
|
20
|
-
flex: 1,
|
|
21
|
-
justifyContent: 'center',
|
|
22
|
-
padding: 18,
|
|
23
|
-
},
|
|
24
|
-
card: {
|
|
25
|
-
backgroundColor: '#FFFFFF',
|
|
26
|
-
borderRadius: 16,
|
|
27
|
-
borderWidth: 1,
|
|
28
|
-
maxWidth: 420,
|
|
29
|
-
padding: 16,
|
|
30
|
-
width: '100%',
|
|
31
|
-
},
|
|
32
|
-
cardHeader: {
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
flexDirection: 'row',
|
|
35
|
-
gap: 10,
|
|
36
|
-
justifyContent: 'space-between',
|
|
37
|
-
marginBottom: 12,
|
|
38
|
-
},
|
|
39
|
-
title: {
|
|
40
|
-
flex: 1,
|
|
41
|
-
fontSize: 15,
|
|
42
|
-
fontWeight: '800',
|
|
43
|
-
},
|
|
44
|
-
message: {
|
|
45
|
-
color: '#334155',
|
|
46
|
-
fontSize: 13,
|
|
47
|
-
lineHeight: 19,
|
|
48
|
-
},
|
|
49
|
-
closeButton: {
|
|
50
|
-
borderRadius: 999,
|
|
51
|
-
borderWidth: 1,
|
|
52
|
-
paddingHorizontal: 10,
|
|
53
|
-
paddingVertical: 6,
|
|
54
|
-
},
|
|
55
|
-
closeButtonText: {
|
|
56
|
-
fontSize: 12,
|
|
57
|
-
fontWeight: '700',
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
export default styles;
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
button: {
|
|
5
|
+
alignItems: 'center',
|
|
6
|
+
borderRadius: 999,
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
height: 22,
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
width: 22,
|
|
11
|
+
},
|
|
12
|
+
label: {
|
|
13
|
+
fontSize: 12,
|
|
14
|
+
fontWeight: '800',
|
|
15
|
+
lineHeight: 12,
|
|
16
|
+
},
|
|
17
|
+
overlay: {
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
backgroundColor: 'rgba(15, 23, 42, 0.55)',
|
|
20
|
+
flex: 1,
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
padding: 18,
|
|
23
|
+
},
|
|
24
|
+
card: {
|
|
25
|
+
backgroundColor: '#FFFFFF',
|
|
26
|
+
borderRadius: 16,
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
maxWidth: 420,
|
|
29
|
+
padding: 16,
|
|
30
|
+
width: '100%',
|
|
31
|
+
},
|
|
32
|
+
cardHeader: {
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
gap: 10,
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
marginBottom: 12,
|
|
38
|
+
},
|
|
39
|
+
title: {
|
|
40
|
+
flex: 1,
|
|
41
|
+
fontSize: 15,
|
|
42
|
+
fontWeight: '800',
|
|
43
|
+
},
|
|
44
|
+
message: {
|
|
45
|
+
color: '#334155',
|
|
46
|
+
fontSize: 13,
|
|
47
|
+
lineHeight: 19,
|
|
48
|
+
},
|
|
49
|
+
closeButton: {
|
|
50
|
+
borderRadius: 999,
|
|
51
|
+
borderWidth: 1,
|
|
52
|
+
paddingHorizontal: 10,
|
|
53
|
+
paddingVertical: 6,
|
|
54
|
+
},
|
|
55
|
+
closeButtonText: {
|
|
56
|
+
fontSize: 12,
|
|
57
|
+
fontWeight: '700',
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export default styles;
|
|
@@ -1,160 +1,162 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import Icon from 'react-native-vector-icons/Feather';
|
|
4
|
-
import {
|
|
5
|
-
getColumnKey,
|
|
6
|
-
isEditableColumn,
|
|
7
|
-
normalizeText,
|
|
8
|
-
resolveCellText,
|
|
9
|
-
resolveEditValue,
|
|
10
|
-
} from './defaultInputUtils';
|
|
11
|
-
import DefaultSelect from './DefaultSelect';
|
|
12
|
-
import styles from './DefaultInput.styles';
|
|
13
|
-
|
|
14
|
-
const DefaultInput = ({
|
|
15
|
-
accentColor = '#2563EB',
|
|
16
|
-
autoFocus = true,
|
|
17
|
-
autoSave = true,
|
|
18
|
-
column,
|
|
19
|
-
columns = [],
|
|
20
|
-
containerStyle = null,
|
|
21
|
-
displayValue,
|
|
22
|
-
editing = false,
|
|
23
|
-
getOptionsForColumn = null,
|
|
24
|
-
inputStyle = null,
|
|
25
|
-
label = '',
|
|
26
|
-
numberOfLines = 1,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
|
|
116
|
-
{column?.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
<
|
|
122
|
-
) :
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { Text, TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import Icon from 'react-native-vector-icons/Feather';
|
|
4
|
+
import {
|
|
5
|
+
getColumnKey,
|
|
6
|
+
isEditableColumn,
|
|
7
|
+
normalizeText,
|
|
8
|
+
resolveCellText,
|
|
9
|
+
resolveEditValue,
|
|
10
|
+
} from './defaultInputUtils';
|
|
11
|
+
import DefaultSelect from './DefaultSelect';
|
|
12
|
+
import styles from './DefaultInput.styles';
|
|
13
|
+
|
|
14
|
+
const DefaultInput = ({
|
|
15
|
+
accentColor = '#2563EB',
|
|
16
|
+
autoFocus = true,
|
|
17
|
+
autoSave = true,
|
|
18
|
+
column,
|
|
19
|
+
columns = [],
|
|
20
|
+
containerStyle = null,
|
|
21
|
+
displayValue,
|
|
22
|
+
editing = false,
|
|
23
|
+
getOptionsForColumn = null,
|
|
24
|
+
inputStyle = null,
|
|
25
|
+
label = '',
|
|
26
|
+
numberOfLines = 1,
|
|
27
|
+
onBeforeOpen = null,
|
|
28
|
+
onCancelEditing = null,
|
|
29
|
+
onChangeValue = null,
|
|
30
|
+
onSave = null,
|
|
31
|
+
onStartEditing = null,
|
|
32
|
+
readTextStyle = null,
|
|
33
|
+
row = {},
|
|
34
|
+
saving = false,
|
|
35
|
+
showLabel = false,
|
|
36
|
+
storeName = '',
|
|
37
|
+
value,
|
|
38
|
+
variant = 'cell',
|
|
39
|
+
}) => {
|
|
40
|
+
const fieldName = getColumnKey(column);
|
|
41
|
+
const isForm = variant === 'form';
|
|
42
|
+
const canEdit = isEditableColumn(column) && typeof onStartEditing === 'function';
|
|
43
|
+
const editValue = useMemo(
|
|
44
|
+
() => normalizeText(value ?? resolveEditValue(column, row)),
|
|
45
|
+
[column, row, value],
|
|
46
|
+
);
|
|
47
|
+
const [draftValue, setDraftValue] = useState(editValue);
|
|
48
|
+
const resolvedLabel =
|
|
49
|
+
displayValue ?? resolveCellText({ column, columns, row, storeName, value });
|
|
50
|
+
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
setDraftValue(editValue);
|
|
53
|
+
}, [editValue, editing]);
|
|
54
|
+
|
|
55
|
+
if (column?.list) {
|
|
56
|
+
return (
|
|
57
|
+
<DefaultSelect
|
|
58
|
+
accentColor={accentColor}
|
|
59
|
+
autoSave={autoSave}
|
|
60
|
+
column={column}
|
|
61
|
+
columns={columns}
|
|
62
|
+
containerStyle={containerStyle}
|
|
63
|
+
displayValue={displayValue}
|
|
64
|
+
editing={editing}
|
|
65
|
+
getOptionsForColumn={getOptionsForColumn}
|
|
66
|
+
label={label}
|
|
67
|
+
numberOfLines={numberOfLines}
|
|
68
|
+
onBeforeOpen={onBeforeOpen}
|
|
69
|
+
onCancelEditing={onCancelEditing}
|
|
70
|
+
onChangeValue={onChangeValue}
|
|
71
|
+
onSave={onSave}
|
|
72
|
+
onStartEditing={onStartEditing}
|
|
73
|
+
readTextStyle={readTextStyle}
|
|
74
|
+
row={row}
|
|
75
|
+
saving={saving}
|
|
76
|
+
showLabel={showLabel}
|
|
77
|
+
storeName={storeName}
|
|
78
|
+
value={value}
|
|
79
|
+
variant={variant}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const saveDraft = () => {
|
|
85
|
+
if (autoSave) {
|
|
86
|
+
onSave?.(draftValue);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onChangeValue?.(draftValue);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const updateDraft = nextValue => {
|
|
94
|
+
setDraftValue(nextValue);
|
|
95
|
+
if (!autoSave) onChangeValue?.(nextValue);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (!editing && !isForm) {
|
|
99
|
+
return (
|
|
100
|
+
<View style={[styles.wrap, containerStyle]}>
|
|
101
|
+
{showLabel ? <Text style={styles.fieldLabel}>{label || column?.label || fieldName}</Text> : null}
|
|
102
|
+
<TouchableOpacity
|
|
103
|
+
style={styles.readButton}
|
|
104
|
+
activeOpacity={canEdit ? 0.78 : 1}
|
|
105
|
+
disabled={!canEdit}
|
|
106
|
+
onPress={() => onStartEditing?.()}
|
|
107
|
+
>
|
|
108
|
+
<Text
|
|
109
|
+
style={[
|
|
110
|
+
styles.readText,
|
|
111
|
+
resolvedLabel === '-' ? styles.mutedText : null,
|
|
112
|
+
readTextStyle,
|
|
113
|
+
]}
|
|
114
|
+
numberOfLines={numberOfLines}
|
|
115
|
+
>
|
|
116
|
+
{column?.prefix || ''}
|
|
117
|
+
{resolvedLabel || '-'}
|
|
118
|
+
{column?.sufix || column?.suffix || ''}
|
|
119
|
+
</Text>
|
|
120
|
+
{saving ? (
|
|
121
|
+
<Text style={[styles.savingText, { color: accentColor }]}>Salvando</Text>
|
|
122
|
+
) : canEdit ? (
|
|
123
|
+
<Icon style={styles.editIcon} name="edit-2" size={13} color="#64748B" />
|
|
124
|
+
) : null}
|
|
125
|
+
</TouchableOpacity>
|
|
126
|
+
</View>
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<View style={[styles.wrap, containerStyle]}>
|
|
132
|
+
{showLabel ? <Text style={styles.fieldLabel}>{label || column?.label || fieldName}</Text> : null}
|
|
133
|
+
<View style={styles.editingWrap}>
|
|
134
|
+
<View style={styles.editingRow}>
|
|
135
|
+
<TextInput
|
|
136
|
+
style={[
|
|
137
|
+
styles.input,
|
|
138
|
+
isForm ? styles.formInput : null,
|
|
139
|
+
inputStyle,
|
|
140
|
+
]}
|
|
141
|
+
value={draftValue}
|
|
142
|
+
keyboardType={column?.inputType === 'number' || column?.inputType === 'float' ? 'numeric' : 'default'}
|
|
143
|
+
placeholder={global.t?.t(storeName, 'input', column?.label || fieldName)}
|
|
144
|
+
onBlur={autoSave ? saveDraft : undefined}
|
|
145
|
+
onChangeText={updateDraft}
|
|
146
|
+
onSubmitEditing={saveDraft}
|
|
147
|
+
autoFocus={autoFocus && !isForm}
|
|
148
|
+
selectTextOnFocus
|
|
149
|
+
/>
|
|
150
|
+
{!isForm ? (
|
|
151
|
+
<TouchableOpacity style={styles.cancelButton} activeOpacity={0.8} onPress={onCancelEditing}>
|
|
152
|
+
<Icon name="x" size={14} color="#64748B" />
|
|
153
|
+
</TouchableOpacity>
|
|
154
|
+
) : null}
|
|
155
|
+
</View>
|
|
156
|
+
{saving ? <Text style={styles.savingText}>Salvando</Text> : null}
|
|
157
|
+
</View>
|
|
158
|
+
</View>
|
|
159
|
+
);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export default DefaultInput;
|