@controleonline/ui-default 1.0.263 → 1.0.265
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 +47 -45
- package/package.json +20 -20
- package/src/react/components/errors/DefaultErrors.js +307 -325
- package/src/react/components/files/DefaultFile.js +46 -46
- package/src/react/components/filters/CompactFilterSelector.js +78 -24
- package/src/react/components/filters/CompactFilterSelector.styles.js +17 -5
- package/src/react/components/filters/DefaultColumnFilter.js +191 -57
- package/src/react/components/filters/DefaultExternalFilters.js +245 -182
- package/src/react/components/filters/DefaultSearch.js +131 -92
- package/src/react/components/filters/DefaultSearch.styles.js +65 -70
- package/src/react/components/form/DefaultForm.js +172 -151
- package/src/react/components/form/DefaultForm.styles.js +71 -66
- package/src/react/components/help/DefaultTooltip.js +87 -87
- package/src/react/components/help/DefaultTooltip.styles.js +61 -61
- package/src/react/components/inputs/DefaultDateInput.js +150 -0
- package/src/react/components/inputs/DefaultInput.js +162 -127
- package/src/react/components/inputs/DefaultInput.styles.js +6 -0
- package/src/react/components/inputs/DefaultSelect.js +320 -152
- package/src/react/components/inputs/defaultInputUtils.js +40 -19
- 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/DefaultColumnMenu.js +108 -0
- package/src/react/components/table/DefaultDebug.js +233 -0
- package/src/react/components/table/DefaultFiltersModal.js +142 -0
- package/src/react/components/table/DefaultModalButton.js +18 -0
- package/src/react/components/table/DefaultSearchModal.js +49 -0
- package/src/react/components/table/DefaultTable.js +345 -1846
- package/src/react/components/table/DefaultTable.styles.js +247 -136
- package/src/react/components/table/DefaultTable.utils.js +502 -0
- package/src/react/components/table/DefaultTableBody.js +26 -0
- package/src/react/components/table/DefaultTableCards.js +171 -0
- package/src/react/components/table/DefaultTableControls.js +208 -0
- package/src/react/components/table/DefaultTableEmptyState.js +22 -0
- package/src/react/components/table/DefaultTableFooter.js +172 -0
- package/src/react/components/table/DefaultTableInput.js +145 -0
- package/src/react/components/table/DefaultTableRows.js +340 -0
- package/src/react/components/table/DefaultTableSearch.js +100 -0
- package/src/react/components/table/DefaultTableToolbar.js +98 -0
- package/src/react/components/table/DefaultToolbarAction.js +56 -0
- package/src/react/components/table/useDefaultTablePagination.js +370 -0
- package/src/react/components/table/useDefaultTableSorting.js +126 -0
- package/src/react/components/table/useDefaultTableTheme.js +58 -0
- package/src/react/index.js +10 -10
- package/src/react/utils/tableVisibleColumnsPreferences.js +239 -211
- package/src/store/default/actions.js +51 -13
- package/src/store/default/getters.js +10 -8
- package/src/store/default/mutation_types.js +4 -2
- package/src/store/default/mutations.js +10 -1
- 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/form/DefaultForm.test.js +81 -0
- package/src/tests/react/components/inputs/DefaultSelect.test.js +185 -0
- package/src/tests/react/components/table/DefaultTable.test.js +1183 -0
- package/src/tests/react/store/defaultActions.test.js +59 -0
- package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +247 -168
|
@@ -1,103 +1,142 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
-
import Icon from 'react-native-vector-icons/Feather';
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
autoFocus = false,
|
|
11
|
-
compact = false,
|
|
12
|
-
filters = null,
|
|
13
|
-
onChangeFilters = null,
|
|
14
|
-
onClear = null,
|
|
15
|
-
onSearch = null,
|
|
16
|
-
placeholder = '',
|
|
17
|
-
searchKey = 'search',
|
|
18
|
-
storeName = '',
|
|
19
|
-
style = null,
|
|
20
|
-
value,
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { TextInput, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import Icon from 'react-native-vector-icons/Feather';
|
|
4
|
+
import { useStore } from '@store';
|
|
5
|
+
import styles from './DefaultSearch.styles';
|
|
6
|
+
|
|
7
|
+
const normalizeText = value => String(value || '').trim();
|
|
8
|
+
|
|
9
|
+
const DefaultSearch = ({
|
|
10
|
+
autoFocus = false,
|
|
11
|
+
compact = false,
|
|
12
|
+
filters = null,
|
|
13
|
+
onChangeFilters = null,
|
|
14
|
+
onClear = null,
|
|
15
|
+
onSearch = null,
|
|
16
|
+
placeholder = '',
|
|
17
|
+
searchKey = 'search',
|
|
18
|
+
storeName = '',
|
|
19
|
+
style = null,
|
|
20
|
+
value,
|
|
21
21
|
}) => {
|
|
22
|
+
const store = useStore(storeName);
|
|
23
|
+
const themeStore = useStore('theme');
|
|
24
|
+
const themeColors = themeStore.getters.colors;
|
|
25
|
+
const resolvedFilters = filters || store?.getters?.filters || {};
|
|
26
|
+
const resolvedChangeFilters = onChangeFilters || store?.actions?.setFilters || null;
|
|
27
|
+
const palette = useMemo(
|
|
28
|
+
() => ({
|
|
29
|
+
buttonBackgroundSecondary: themeColors.buttonBackgroundSecondary,
|
|
30
|
+
buttonBorder: themeColors.buttonBorder,
|
|
31
|
+
buttonIcon: themeColors.buttonIcon,
|
|
32
|
+
buttonIconSecondary: themeColors.buttonIconSecondary,
|
|
33
|
+
inputBackground: themeColors.inputBackground,
|
|
34
|
+
inputBorder: themeColors.inputBorder,
|
|
35
|
+
inputIcon: themeColors.inputIcon,
|
|
36
|
+
inputPlaceholderText: themeColors.inputPlaceholderText,
|
|
37
|
+
inputText: themeColors.inputText,
|
|
38
|
+
}),
|
|
39
|
+
[themeColors],
|
|
40
|
+
);
|
|
22
41
|
const resolvedValue = useMemo(
|
|
23
|
-
() => normalizeText(value ??
|
|
24
|
-
[
|
|
42
|
+
() => normalizeText(value ?? resolvedFilters?.[searchKey]),
|
|
43
|
+
[resolvedFilters, searchKey, value],
|
|
25
44
|
);
|
|
26
|
-
const [draftValue, setDraftValue] = useState(resolvedValue);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
setDraftValue(resolvedValue);
|
|
30
|
-
}, [resolvedValue]);
|
|
31
|
-
|
|
32
|
-
const commitSearch = nextValue => {
|
|
33
|
-
const searchValue = normalizeText(nextValue ?? draftValue);
|
|
34
|
-
|
|
35
|
-
if (typeof
|
|
36
|
-
const nextFilters = { ...(
|
|
45
|
+
const [draftValue, setDraftValue] = useState(resolvedValue);
|
|
46
|
+
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
setDraftValue(resolvedValue);
|
|
49
|
+
}, [resolvedValue]);
|
|
50
|
+
|
|
51
|
+
const commitSearch = nextValue => {
|
|
52
|
+
const searchValue = normalizeText(nextValue ?? draftValue);
|
|
53
|
+
|
|
54
|
+
if (typeof resolvedChangeFilters === 'function') {
|
|
55
|
+
const nextFilters = { ...(resolvedFilters || {}) };
|
|
37
56
|
if (searchValue) nextFilters[searchKey] = searchValue;
|
|
38
57
|
else delete nextFilters[searchKey];
|
|
39
|
-
|
|
58
|
+
resolvedChangeFilters(nextFilters);
|
|
40
59
|
}
|
|
41
|
-
|
|
42
|
-
onSearch?.(searchValue);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const clearSearch = () => {
|
|
46
|
-
setDraftValue('');
|
|
47
|
-
|
|
48
|
-
if (typeof
|
|
49
|
-
const nextFilters = { ...(
|
|
60
|
+
|
|
61
|
+
onSearch?.(searchValue);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const clearSearch = () => {
|
|
65
|
+
setDraftValue('');
|
|
66
|
+
|
|
67
|
+
if (typeof resolvedChangeFilters === 'function') {
|
|
68
|
+
const nextFilters = { ...(resolvedFilters || {}) };
|
|
50
69
|
delete nextFilters[searchKey];
|
|
51
|
-
|
|
70
|
+
resolvedChangeFilters(nextFilters);
|
|
52
71
|
}
|
|
53
|
-
|
|
54
|
-
onClear?.();
|
|
55
|
-
onSearch?.('');
|
|
56
|
-
};
|
|
57
|
-
|
|
72
|
+
|
|
73
|
+
onClear?.();
|
|
74
|
+
onSearch?.('');
|
|
75
|
+
};
|
|
76
|
+
|
|
58
77
|
const resolvedPlaceholder =
|
|
59
78
|
placeholder ||
|
|
60
79
|
global.t?.t(storeName, 'input', searchKey) ||
|
|
61
|
-
global.t?.t(storeName, 'placeholder', searchKey)
|
|
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
|
-
|
|
80
|
+
global.t?.t(storeName, 'placeholder', searchKey);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<View
|
|
84
|
+
style={[
|
|
85
|
+
styles.wrap,
|
|
86
|
+
compact ? styles.wrapCompact : null,
|
|
87
|
+
{
|
|
88
|
+
backgroundColor: palette.inputBackground,
|
|
89
|
+
borderColor: palette.inputBorder,
|
|
90
|
+
},
|
|
91
|
+
style,
|
|
92
|
+
]}
|
|
93
|
+
>
|
|
94
|
+
<Icon name="search" size={compact ? 14 : 16} color={palette.inputIcon} />
|
|
95
|
+
<TextInput
|
|
96
|
+
autoCapitalize="none"
|
|
97
|
+
autoCorrect={false}
|
|
98
|
+
autoFocus={autoFocus}
|
|
99
|
+
placeholder={resolvedPlaceholder}
|
|
100
|
+
placeholderTextColor={palette.inputPlaceholderText}
|
|
101
|
+
returnKeyType="search"
|
|
102
|
+
style={[
|
|
103
|
+
styles.input,
|
|
104
|
+
compact ? styles.inputCompact : null,
|
|
105
|
+
{ color: palette.inputText },
|
|
106
|
+
]}
|
|
107
|
+
value={draftValue}
|
|
108
|
+
onChangeText={setDraftValue}
|
|
109
|
+
onSubmitEditing={() => commitSearch()}
|
|
110
|
+
/>
|
|
111
|
+
{draftValue ? (
|
|
112
|
+
<TouchableOpacity
|
|
113
|
+
style={[
|
|
114
|
+
styles.iconButton,
|
|
115
|
+
compact ? styles.iconButtonCompact : null,
|
|
116
|
+
{ backgroundColor: palette.buttonBackgroundSecondary },
|
|
117
|
+
]}
|
|
118
|
+
activeOpacity={0.82}
|
|
119
|
+
onPress={clearSearch}
|
|
120
|
+
>
|
|
121
|
+
<Icon name="x" size={14} color={palette.buttonIconSecondary} />
|
|
122
|
+
</TouchableOpacity>
|
|
123
|
+
) : null}
|
|
124
|
+
<TouchableOpacity
|
|
125
|
+
style={[
|
|
126
|
+
styles.searchButton,
|
|
127
|
+
compact ? styles.searchButtonCompact : null,
|
|
128
|
+
{
|
|
129
|
+
backgroundColor: palette.buttonBackgroundSecondary,
|
|
130
|
+
borderColor: palette.buttonBorder,
|
|
131
|
+
},
|
|
132
|
+
]}
|
|
133
|
+
activeOpacity={0.82}
|
|
134
|
+
onPress={() => commitSearch()}
|
|
135
|
+
>
|
|
136
|
+
<Icon name="arrow-right" size={compact ? 13 : 15} color={palette.buttonIcon} />
|
|
137
|
+
</TouchableOpacity>
|
|
138
|
+
</View>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default DefaultSearch;
|
|
@@ -1,70 +1,65 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native';
|
|
2
|
-
|
|
3
|
-
const styles = StyleSheet.create({
|
|
4
|
-
wrap: {
|
|
5
|
-
minHeight: 40,
|
|
6
|
-
minWidth: 180,
|
|
7
|
-
borderWidth: 1,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
borderRadius: 12,
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export default styles;
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const styles = StyleSheet.create({
|
|
4
|
+
wrap: {
|
|
5
|
+
minHeight: 40,
|
|
6
|
+
minWidth: 180,
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
borderRadius: 12,
|
|
9
|
+
paddingLeft: 10,
|
|
10
|
+
paddingRight: 5,
|
|
11
|
+
paddingVertical: 5,
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
gap: 8,
|
|
15
|
+
},
|
|
16
|
+
wrapCompact: {
|
|
17
|
+
minHeight: 30,
|
|
18
|
+
minWidth: 150,
|
|
19
|
+
maxWidth: 240,
|
|
20
|
+
borderRadius: 15,
|
|
21
|
+
paddingLeft: 9,
|
|
22
|
+
paddingRight: 3,
|
|
23
|
+
paddingVertical: 3,
|
|
24
|
+
gap: 6,
|
|
25
|
+
},
|
|
26
|
+
input: {
|
|
27
|
+
flex: 1,
|
|
28
|
+
minWidth: 0,
|
|
29
|
+
padding: 0,
|
|
30
|
+
fontSize: 13,
|
|
31
|
+
lineHeight: 16,
|
|
32
|
+
fontWeight: '700',
|
|
33
|
+
},
|
|
34
|
+
inputCompact: {
|
|
35
|
+
fontSize: 12,
|
|
36
|
+
lineHeight: 14,
|
|
37
|
+
},
|
|
38
|
+
iconButton: {
|
|
39
|
+
width: 28,
|
|
40
|
+
height: 28,
|
|
41
|
+
borderRadius: 14,
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
justifyContent: 'center',
|
|
44
|
+
},
|
|
45
|
+
iconButtonCompact: {
|
|
46
|
+
width: 22,
|
|
47
|
+
height: 22,
|
|
48
|
+
borderRadius: 11,
|
|
49
|
+
},
|
|
50
|
+
searchButton: {
|
|
51
|
+
width: 30,
|
|
52
|
+
height: 30,
|
|
53
|
+
borderRadius: 15,
|
|
54
|
+
borderWidth: 1,
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
},
|
|
58
|
+
searchButtonCompact: {
|
|
59
|
+
width: 24,
|
|
60
|
+
height: 24,
|
|
61
|
+
borderRadius: 12,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default styles;
|