@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.
Files changed (29) hide show
  1. package/AGENTS.md +48 -47
  2. package/package.json +3 -6
  3. package/src/react/components/errors/DefaultErrors.js +360 -360
  4. package/src/react/components/files/DefaultFile.js +46 -46
  5. package/src/react/components/filters/CompactFilterSelector.js +22 -3
  6. package/src/react/components/filters/DefaultColumnFilter.js +15 -13
  7. package/src/react/components/filters/DefaultExternalFilters.js +44 -39
  8. package/src/react/components/filters/DefaultSearch.js +140 -103
  9. package/src/react/components/filters/DefaultSearch.styles.js +65 -70
  10. package/src/react/components/form/DefaultForm.js +200 -198
  11. package/src/react/components/help/DefaultTooltip.js +87 -87
  12. package/src/react/components/help/DefaultTooltip.styles.js +61 -61
  13. package/src/react/components/inputs/DefaultInput.js +162 -160
  14. package/src/react/components/inputs/DefaultSelect.js +203 -192
  15. package/src/react/components/map/DefaultGoogleMap.styles.js +115 -9
  16. package/src/react/components/map/DefaultGoogleMap.web.js +560 -446
  17. package/src/react/components/map/DefaultMap.native.js +73 -71
  18. package/src/react/components/map/DefaultMap.styles.js +16 -16
  19. package/src/react/components/map/DefaultMap.web.js +68 -66
  20. package/src/react/components/map/DefaultNativeMap.native.js +307 -183
  21. package/src/react/components/map/DefaultNativeMap.shared.js +439 -340
  22. package/src/react/components/map/DefaultNativeMap.styles.js +156 -122
  23. package/src/react/components/table/DefaultTable.js +529 -355
  24. package/src/react/components/table/DefaultTable.styles.js +30 -39
  25. package/src/react/index.js +10 -10
  26. package/src/tests/react/components/errors/DefaultErrors.test.js +162 -162
  27. package/src/tests/react/components/files/DefaultFile.test.js +80 -80
  28. package/src/tests/react/components/inputs/DefaultSelect.test.js +93 -0
  29. 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
- onCancelEditing = null,
28
- onChangeValue = null,
29
- onSave = null,
30
- 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
-
54
- if (column?.list) {
55
- return (
56
- <DefaultSelect
57
- accentColor={accentColor}
58
- autoSave={autoSave}
59
- column={column}
60
- columns={columns}
61
- containerStyle={containerStyle}
62
- displayValue={displayValue}
63
- editing={editing}
64
- getOptionsForColumn={getOptionsForColumn}
65
- label={label}
66
- numberOfLines={numberOfLines}
67
- onCancelEditing={onCancelEditing}
68
- onChangeValue={onChangeValue}
69
- onSave={onSave}
70
- onStartEditing={onStartEditing}
71
- readTextStyle={readTextStyle}
72
- row={row}
73
- saving={saving}
74
- showLabel={showLabel}
75
- storeName={storeName}
76
- value={value}
77
- variant={variant}
78
- />
79
- );
80
- }
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;
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;