@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.
Files changed (61) hide show
  1. package/AGENTS.md +47 -45
  2. package/package.json +20 -20
  3. package/src/react/components/errors/DefaultErrors.js +307 -325
  4. package/src/react/components/files/DefaultFile.js +46 -46
  5. package/src/react/components/filters/CompactFilterSelector.js +78 -24
  6. package/src/react/components/filters/CompactFilterSelector.styles.js +17 -5
  7. package/src/react/components/filters/DefaultColumnFilter.js +191 -57
  8. package/src/react/components/filters/DefaultExternalFilters.js +245 -182
  9. package/src/react/components/filters/DefaultSearch.js +131 -92
  10. package/src/react/components/filters/DefaultSearch.styles.js +65 -70
  11. package/src/react/components/form/DefaultForm.js +172 -151
  12. package/src/react/components/form/DefaultForm.styles.js +71 -66
  13. package/src/react/components/help/DefaultTooltip.js +87 -87
  14. package/src/react/components/help/DefaultTooltip.styles.js +61 -61
  15. package/src/react/components/inputs/DefaultDateInput.js +150 -0
  16. package/src/react/components/inputs/DefaultInput.js +162 -127
  17. package/src/react/components/inputs/DefaultInput.styles.js +6 -0
  18. package/src/react/components/inputs/DefaultSelect.js +320 -152
  19. package/src/react/components/inputs/defaultInputUtils.js +40 -19
  20. package/src/react/components/map/DefaultGoogleMap.styles.js +115 -9
  21. package/src/react/components/map/DefaultGoogleMap.web.js +560 -446
  22. package/src/react/components/map/DefaultMap.native.js +73 -71
  23. package/src/react/components/map/DefaultMap.styles.js +16 -16
  24. package/src/react/components/map/DefaultMap.web.js +68 -66
  25. package/src/react/components/map/DefaultNativeMap.native.js +307 -183
  26. package/src/react/components/map/DefaultNativeMap.shared.js +439 -340
  27. package/src/react/components/map/DefaultNativeMap.styles.js +156 -122
  28. package/src/react/components/table/DefaultColumnMenu.js +108 -0
  29. package/src/react/components/table/DefaultDebug.js +233 -0
  30. package/src/react/components/table/DefaultFiltersModal.js +142 -0
  31. package/src/react/components/table/DefaultModalButton.js +18 -0
  32. package/src/react/components/table/DefaultSearchModal.js +49 -0
  33. package/src/react/components/table/DefaultTable.js +345 -1846
  34. package/src/react/components/table/DefaultTable.styles.js +247 -136
  35. package/src/react/components/table/DefaultTable.utils.js +502 -0
  36. package/src/react/components/table/DefaultTableBody.js +26 -0
  37. package/src/react/components/table/DefaultTableCards.js +171 -0
  38. package/src/react/components/table/DefaultTableControls.js +208 -0
  39. package/src/react/components/table/DefaultTableEmptyState.js +22 -0
  40. package/src/react/components/table/DefaultTableFooter.js +172 -0
  41. package/src/react/components/table/DefaultTableInput.js +145 -0
  42. package/src/react/components/table/DefaultTableRows.js +340 -0
  43. package/src/react/components/table/DefaultTableSearch.js +100 -0
  44. package/src/react/components/table/DefaultTableToolbar.js +98 -0
  45. package/src/react/components/table/DefaultToolbarAction.js +56 -0
  46. package/src/react/components/table/useDefaultTablePagination.js +370 -0
  47. package/src/react/components/table/useDefaultTableSorting.js +126 -0
  48. package/src/react/components/table/useDefaultTableTheme.js +58 -0
  49. package/src/react/index.js +10 -10
  50. package/src/react/utils/tableVisibleColumnsPreferences.js +239 -211
  51. package/src/store/default/actions.js +51 -13
  52. package/src/store/default/getters.js +10 -8
  53. package/src/store/default/mutation_types.js +4 -2
  54. package/src/store/default/mutations.js +10 -1
  55. package/src/tests/react/components/errors/DefaultErrors.test.js +162 -162
  56. package/src/tests/react/components/files/DefaultFile.test.js +80 -80
  57. package/src/tests/react/components/form/DefaultForm.test.js +81 -0
  58. package/src/tests/react/components/inputs/DefaultSelect.test.js +185 -0
  59. package/src/tests/react/components/table/DefaultTable.test.js +1183 -0
  60. package/src/tests/react/store/defaultActions.test.js +59 -0
  61. package/src/tests/react/utils/tableVisibleColumnsPreferences.test.js +247 -168
@@ -1,72 +1,107 @@
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 {
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
5
  getColumnKey,
6
+ isDateLikeColumn,
6
7
  isEditableColumn,
7
- normalizeText,
8
- resolveCellText,
9
- resolveEditValue,
8
+ normalizeText,
9
+ resolveCellText,
10
+ resolveEditValue,
10
11
  } from './defaultInputUtils';
12
+ import DefaultDateInput from './DefaultDateInput';
11
13
  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,
14
+ import styles from './DefaultInput.styles';
15
+
16
+ const DefaultInput = ({
17
+ accentColor = '#2563EB',
18
+ autoFocus = true,
19
+ autoSave = true,
20
+ column,
21
+ columns = [],
22
+ containerStyle = null,
23
+ displayValue,
24
+ editing = false,
25
+ getOptionsForColumn = null,
26
+ inputStyle = null,
27
+ label = '',
28
+ numberOfLines = 1,
29
+ onBeforeOpen = null,
27
30
  onCancelEditing = null,
28
31
  onChangeValue = null,
29
32
  onSave = null,
33
+ onSearchChange = null,
30
34
  onStartEditing = null,
31
- readTextStyle = null,
32
- row = {},
33
- saving = false,
34
- showLabel = false,
35
- storeName = '',
36
- value,
37
- variant = 'cell',
38
- }) => {
39
- const fieldName = getColumnKey(column);
40
- const isForm = variant === 'form';
41
- const canEdit = isEditableColumn(column) && typeof onStartEditing === 'function';
42
- const editValue = useMemo(
43
- () => normalizeText(value ?? resolveEditValue(column, row)),
44
- [column, row, value],
45
- );
46
- const [draftValue, setDraftValue] = useState(editValue);
47
- const resolvedLabel =
48
- displayValue ?? resolveCellText({ column, columns, row, storeName, value });
49
-
50
- useEffect(() => {
51
- setDraftValue(editValue);
52
- }, [editValue, editing]);
53
-
35
+ readTextStyle = null,
36
+ row = {},
37
+ saving = false,
38
+ showLabel = false,
39
+ storeName = '',
40
+ value,
41
+ variant = 'cell',
42
+ }) => {
43
+ const fieldName = getColumnKey(column);
44
+ const isForm = variant === 'form';
45
+ const canEdit = isEditableColumn(column) && typeof onStartEditing === 'function';
46
+ const editValue = useMemo(
47
+ () => normalizeText(value ?? resolveEditValue(column, row)),
48
+ [column, row, value],
49
+ );
50
+ const [draftValue, setDraftValue] = useState(editValue);
51
+ const resolvedLabel =
52
+ displayValue ?? resolveCellText({ column, columns, row, storeName, value });
53
+
54
+ useEffect(() => {
55
+ setDraftValue(editValue);
56
+ }, [editValue, editing]);
57
+
54
58
  if (column?.list) {
59
+ return (
60
+ <DefaultSelect
61
+ accentColor={accentColor}
62
+ autoSave={autoSave}
63
+ column={column}
64
+ columns={columns}
65
+ containerStyle={containerStyle}
66
+ displayValue={displayValue}
67
+ editing={editing}
68
+ getOptionsForColumn={getOptionsForColumn}
69
+ label={label}
70
+ numberOfLines={numberOfLines}
71
+ onBeforeOpen={onBeforeOpen}
72
+ onCancelEditing={onCancelEditing}
73
+ onChangeValue={onChangeValue}
74
+ onSave={onSave}
75
+ onStartEditing={onStartEditing}
76
+ readTextStyle={readTextStyle}
77
+ row={row}
78
+ saving={saving}
79
+ showLabel={showLabel}
80
+ storeName={storeName}
81
+ value={value}
82
+ variant={variant}
83
+ />
84
+ );
85
+ }
86
+
87
+ if (isDateLikeColumn(column)) {
55
88
  return (
56
- <DefaultSelect
89
+ <DefaultDateInput
57
90
  accentColor={accentColor}
91
+ autoFocus={autoFocus}
58
92
  autoSave={autoSave}
59
93
  column={column}
60
94
  columns={columns}
61
95
  containerStyle={containerStyle}
62
96
  displayValue={displayValue}
63
97
  editing={editing}
64
- getOptionsForColumn={getOptionsForColumn}
98
+ inputStyle={inputStyle}
65
99
  label={label}
66
100
  numberOfLines={numberOfLines}
67
101
  onCancelEditing={onCancelEditing}
68
102
  onChangeValue={onChangeValue}
69
103
  onSave={onSave}
104
+ onSearchChange={onSearchChange}
70
105
  onStartEditing={onStartEditing}
71
106
  readTextStyle={readTextStyle}
72
107
  row={row}
@@ -78,83 +113,83 @@ const DefaultInput = ({
78
113
  />
79
114
  );
80
115
  }
81
-
82
- const saveDraft = () => {
83
- if (autoSave) {
84
- onSave?.(draftValue);
85
- return;
86
- }
87
-
88
- onChangeValue?.(draftValue);
89
- };
90
-
91
- const updateDraft = nextValue => {
92
- setDraftValue(nextValue);
93
- if (!autoSave) onChangeValue?.(nextValue);
94
- };
95
-
96
- if (!editing && !isForm) {
97
- return (
98
- <View style={[styles.wrap, containerStyle]}>
99
- {showLabel ? <Text style={styles.fieldLabel}>{label || column?.label || fieldName}</Text> : null}
100
- <TouchableOpacity
101
- style={styles.readButton}
102
- activeOpacity={canEdit ? 0.78 : 1}
103
- disabled={!canEdit}
104
- onPress={() => onStartEditing?.()}
105
- >
106
- <Text
107
- style={[
108
- styles.readText,
109
- resolvedLabel === '-' ? styles.mutedText : null,
110
- readTextStyle,
111
- ]}
112
- numberOfLines={numberOfLines}
113
- >
114
- {column?.prefix || ''}
115
- {resolvedLabel || '-'}
116
- {column?.sufix || column?.suffix || ''}
117
- </Text>
118
- {saving ? (
119
- <Text style={[styles.savingText, { color: accentColor }]}>Salvando</Text>
120
- ) : canEdit ? (
121
- <Icon style={styles.editIcon} name="edit-2" size={13} color="#64748B" />
122
- ) : null}
123
- </TouchableOpacity>
124
- </View>
125
- );
126
- }
127
-
128
- return (
129
- <View style={[styles.wrap, containerStyle]}>
130
- {showLabel ? <Text style={styles.fieldLabel}>{label || column?.label || fieldName}</Text> : null}
131
- <View style={styles.editingWrap}>
132
- <View style={styles.editingRow}>
133
- <TextInput
134
- style={[
135
- styles.input,
136
- isForm ? styles.formInput : null,
137
- inputStyle,
138
- ]}
139
- value={draftValue}
140
- keyboardType={column?.inputType === 'number' || column?.inputType === 'float' ? 'numeric' : 'default'}
141
- placeholder={global.t?.t(storeName, 'input', column?.label || fieldName)}
142
- onBlur={autoSave ? saveDraft : undefined}
143
- onChangeText={updateDraft}
144
- onSubmitEditing={saveDraft}
145
- autoFocus={autoFocus && !isForm}
146
- selectTextOnFocus
147
- />
148
- {!isForm ? (
149
- <TouchableOpacity style={styles.cancelButton} activeOpacity={0.8} onPress={onCancelEditing}>
150
- <Icon name="x" size={14} color="#64748B" />
151
- </TouchableOpacity>
152
- ) : null}
153
- </View>
154
- {saving ? <Text style={styles.savingText}>Salvando</Text> : null}
155
- </View>
156
- </View>
157
- );
158
- };
159
-
160
- export default DefaultInput;
116
+
117
+ const saveDraft = () => {
118
+ if (autoSave) {
119
+ onSave?.(draftValue);
120
+ return;
121
+ }
122
+
123
+ onChangeValue?.(draftValue);
124
+ };
125
+
126
+ const updateDraft = nextValue => {
127
+ setDraftValue(nextValue);
128
+ if (!autoSave) onChangeValue?.(nextValue);
129
+ };
130
+
131
+ if (!editing && !isForm) {
132
+ return (
133
+ <View style={[styles.wrap, containerStyle]}>
134
+ {showLabel ? <Text style={styles.fieldLabel}>{label || column?.label || fieldName}</Text> : null}
135
+ <TouchableOpacity
136
+ style={styles.readButton}
137
+ activeOpacity={canEdit ? 0.78 : 1}
138
+ disabled={!canEdit}
139
+ onPress={() => onStartEditing?.()}
140
+ >
141
+ <Text
142
+ style={[
143
+ styles.readText,
144
+ resolvedLabel === '-' ? styles.mutedText : null,
145
+ readTextStyle,
146
+ ]}
147
+ numberOfLines={numberOfLines}
148
+ >
149
+ {column?.prefix || ''}
150
+ {resolvedLabel || '-'}
151
+ {column?.sufix || column?.suffix || ''}
152
+ </Text>
153
+ {saving ? (
154
+ <Text style={[styles.savingText, { color: accentColor }]}>Salvando</Text>
155
+ ) : canEdit ? (
156
+ <Icon style={styles.editIcon} name="edit-2" size={13} color="#64748B" />
157
+ ) : null}
158
+ </TouchableOpacity>
159
+ </View>
160
+ );
161
+ }
162
+
163
+ return (
164
+ <View style={[styles.wrap, containerStyle]}>
165
+ {showLabel ? <Text style={styles.fieldLabel}>{label || column?.label || fieldName}</Text> : null}
166
+ <View style={styles.editingWrap}>
167
+ <View style={styles.editingRow}>
168
+ <TextInput
169
+ style={[
170
+ styles.input,
171
+ isForm ? styles.formInput : null,
172
+ inputStyle,
173
+ ]}
174
+ value={draftValue}
175
+ keyboardType={column?.inputType === 'number' || column?.inputType === 'float' ? 'numeric' : 'default'}
176
+ placeholder={global.t?.t(storeName, 'input', column?.label || fieldName)}
177
+ onBlur={autoSave ? saveDraft : undefined}
178
+ onChangeText={updateDraft}
179
+ onSubmitEditing={saveDraft}
180
+ autoFocus={autoFocus && !isForm}
181
+ selectTextOnFocus
182
+ />
183
+ {!isForm ? (
184
+ <TouchableOpacity style={styles.cancelButton} activeOpacity={0.8} onPress={onCancelEditing}>
185
+ <Icon name="x" size={14} color="#64748B" />
186
+ </TouchableOpacity>
187
+ ) : null}
188
+ </View>
189
+ {saving ? <Text style={styles.savingText}>Salvando</Text> : null}
190
+ </View>
191
+ </View>
192
+ );
193
+ };
194
+
195
+ export default DefaultInput;
@@ -88,6 +88,12 @@ const styles = StyleSheet.create({
88
88
  fontWeight: '800',
89
89
  textTransform: 'uppercase',
90
90
  },
91
+ validationText: {
92
+ marginTop: 3,
93
+ color: '#DC2626',
94
+ fontSize: 10,
95
+ fontWeight: '800',
96
+ },
91
97
  });
92
98
 
93
99
  export default styles;