@controleonline/ui-default 1.0.265 → 1.0.267

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.
@@ -16,15 +16,14 @@ const styles = StyleSheet.create({
16
16
  flex: 1,
17
17
  width: '100%',
18
18
  minHeight: 0,
19
- borderWidth: 1,
20
- borderRadius: 10,
21
- overflow: 'visible',
19
+ borderRadius: 8,
20
+ overflow: 'hidden',
22
21
  position: 'relative',
23
22
  },
24
23
  toolbar: {
25
- minHeight: 36,
26
- paddingHorizontal: 8,
27
- paddingVertical: 4,
24
+ minHeight: 52,
25
+ paddingHorizontal: 16,
26
+ paddingVertical: 10,
28
27
  borderBottomWidth: 1,
29
28
  flexDirection: 'row',
30
29
  flexWrap: 'nowrap',
@@ -51,7 +50,7 @@ const styles = StyleSheet.create({
51
50
  flexDirection: 'row',
52
51
  flexWrap: 'nowrap',
53
52
  alignItems: 'center',
54
- gap: 6,
53
+ gap: 8,
55
54
  flexShrink: 0,
56
55
  marginLeft: 'auto',
57
56
  },
@@ -76,8 +75,8 @@ const styles = StyleSheet.create({
76
75
  marginLeft: 0,
77
76
  },
78
77
  toolbarSearch: {
79
- width: 190,
80
- maxWidth: 220,
78
+ width: 260,
79
+ maxWidth: 360,
81
80
  flexShrink: 1,
82
81
  },
83
82
  toolbarSearchButton: {
@@ -111,10 +110,10 @@ const styles = StyleSheet.create({
111
110
  fontWeight: '900',
112
111
  },
113
112
  toolbarButton: {
114
- minWidth: 28,
115
- height: 28,
116
- borderRadius: 14,
117
- paddingHorizontal: 7,
113
+ minWidth: 36,
114
+ height: 36,
115
+ borderRadius: 8,
116
+ paddingHorizontal: 10,
118
117
  borderWidth: 1,
119
118
  flexDirection: 'row',
120
119
  alignItems: 'center',
@@ -123,11 +122,23 @@ const styles = StyleSheet.create({
123
122
  },
124
123
  toolbarButtonActive: {
125
124
  },
126
- toolbarAddButton: {
127
- minWidth: 30,
128
- width: 30,
129
- paddingHorizontal: 0,
130
- },
125
+ toolbarAddButton: {
126
+ minWidth: 36,
127
+ width: 36,
128
+ paddingHorizontal: 0,
129
+ },
130
+ floatingAddButton: {
131
+ position: 'absolute',
132
+ right: 16,
133
+ bottom: 16,
134
+ width: 52,
135
+ height: 52,
136
+ borderRadius: 26,
137
+ alignItems: 'center',
138
+ justifyContent: 'center',
139
+ zIndex: 30,
140
+ ...shadow,
141
+ },
131
142
  toolbarBadgeText: {
132
143
  fontSize: 10,
133
144
  fontWeight: '900',
@@ -271,8 +282,8 @@ const styles = StyleSheet.create({
271
282
  minWidth: '100%',
272
283
  minHeight: 0,
273
284
  },
274
- headerRow: {
275
- minHeight: 34,
285
+ headerRow: {
286
+ minHeight: 40,
276
287
  width: '100%',
277
288
  flexDirection: 'row',
278
289
  alignItems: 'center',
@@ -280,8 +291,8 @@ const styles = StyleSheet.create({
280
291
  borderBottomWidth: 1,
281
292
  borderBottomColor: '#E2E8F0',
282
293
  },
283
- filterRow: {
284
- minHeight: 40,
294
+ filterRow: {
295
+ minHeight: 46,
285
296
  width: '100%',
286
297
  flexDirection: 'row',
287
298
  alignItems: 'stretch',
@@ -289,25 +300,24 @@ const styles = StyleSheet.create({
289
300
  borderBottomWidth: 1,
290
301
  borderBottomColor: '#E2E8F0',
291
302
  },
292
- row: {
293
- minHeight: 44,
303
+ row: {
304
+ minHeight: 48,
294
305
  width: '100%',
295
306
  flexDirection: 'row',
296
307
  alignItems: 'stretch',
297
308
  borderBottomWidth: 1,
298
309
  borderBottomColor: '#EEF2F7',
299
310
  },
300
- cell: {
301
- minWidth: 118,
302
- flexBasis: 118,
311
+ cell: {
312
+ minWidth: 118,
313
+ flexBasis: 118,
303
314
  flexGrow: 1,
304
315
  flexShrink: 0,
305
- paddingHorizontal: 10,
306
- paddingVertical: 8,
307
- justifyContent: 'center',
308
- borderRightWidth: 1,
309
- borderRightColor: '#EEF2F7',
310
- },
316
+ paddingHorizontal: 14,
317
+ paddingVertical: 10,
318
+ justifyContent: 'center',
319
+ borderRightWidth: 0,
320
+ },
311
321
  identityCell: {
312
322
  minWidth: 76,
313
323
  flexBasis: 76,
@@ -365,13 +375,12 @@ const styles = StyleSheet.create({
365
375
  flexBasis: 132,
366
376
  flexGrow: 0.9,
367
377
  },
368
- headerText: {
369
- color: '#64748B',
370
- fontSize: 10,
371
- fontWeight: '900',
372
- letterSpacing: 0.35,
373
- textTransform: 'uppercase',
374
- },
378
+ headerText: {
379
+ fontSize: 11,
380
+ fontWeight: '800',
381
+ letterSpacing: 0,
382
+ textTransform: 'uppercase',
383
+ },
375
384
  sortableHeader: {
376
385
  flexDirection: 'row',
377
386
  alignItems: 'center',
@@ -392,11 +401,10 @@ const styles = StyleSheet.create({
392
401
  fontSize: 11,
393
402
  fontWeight: '700',
394
403
  },
395
- cellText: {
396
- color: '#0F172A',
397
- fontSize: 12,
398
- fontWeight: '700',
399
- },
404
+ cellText: {
405
+ fontSize: 13,
406
+ fontWeight: '600',
407
+ },
400
408
  mutedCellText: {
401
409
  color: '#94A3B8',
402
410
  },
@@ -479,23 +487,30 @@ const styles = StyleSheet.create({
479
487
  flexGrow: 1,
480
488
  width: '100%',
481
489
  },
482
- cardItem: {
483
- position: 'relative',
484
- },
490
+ cardItem: {
491
+ position: 'relative',
492
+ },
493
+ cardItemWithActions: {
494
+ flexDirection: 'row',
495
+ alignItems: 'center',
496
+ gap: 8,
497
+ },
498
+ cardContent: {
499
+ flex: 1,
500
+ minWidth: 0,
501
+ },
485
502
  cardActions: {
486
- position: 'absolute',
487
- right: 10,
488
- bottom: 10,
489
503
  flexDirection: 'row',
490
504
  alignItems: 'center',
505
+ justifyContent: 'flex-end',
491
506
  gap: 6,
507
+ flexShrink: 0,
492
508
  },
493
509
  cardActionGroup: {
494
- position: 'absolute',
495
- right: 8,
496
- top: 8,
497
510
  flexDirection: 'row',
498
511
  alignItems: 'center',
512
+ justifyContent: 'flex-end',
513
+ alignSelf: 'flex-end',
499
514
  gap: 6,
500
515
  },
501
516
  defaultCard: {
@@ -81,15 +81,24 @@ const DefaultTableCards = ({ storeName }) => {
81
81
 
82
82
  if (typeof configs.renderCard === 'function') {
83
83
  return (
84
- <View key={row?.['@id'] || row?.id} style={[styles.cardItem, rowStyleValue]}>
85
- {configs.renderCard({
86
- item: row,
87
- openEdit: () => configs.onEditRow?.(row),
88
- openRow: hasRowPress ? () => configs.onRowPress(row) : null,
89
- renderField,
90
- renderValue,
91
- row,
92
- })}
84
+ <View
85
+ key={row?.['@id'] || row?.id}
86
+ style={[
87
+ styles.cardItem,
88
+ hasRowActions ? styles.cardItemWithActions : null,
89
+ rowStyleValue,
90
+ ]}
91
+ >
92
+ <View style={styles.cardContent}>
93
+ {configs.renderCard({
94
+ item: row,
95
+ openEdit: () => configs.onEditRow?.(row),
96
+ openRow: hasRowPress ? () => configs.onRowPress(row) : null,
97
+ renderField,
98
+ renderValue,
99
+ row,
100
+ })}
101
+ </View>
93
102
  {hasRowActions ? (
94
103
  <View style={styles.cardActions}>
95
104
  {customRowActions}
@@ -1,208 +1,205 @@
1
- import React from 'react';
2
- import { Text, TouchableOpacity } from 'react-native';
3
- import Icon from 'react-native-vector-icons/Feather';
4
- import { useStore } from '@store';
5
- import DefaultColumnMenu from './DefaultColumnMenu';
6
- import DefaultDebug from './DefaultDebug';
7
- import DefaultFiltersModal from './DefaultFiltersModal';
8
- import DefaultModalButton from './DefaultModalButton';
9
- import styles from './DefaultTable.styles';
10
- import { normalizeText } from '../inputs/defaultInputUtils';
11
- import {
12
- persistTableViewModePreference,
13
- resolveDefaultTablePreferenceScope,
14
- } from '../../utils/tableVisibleColumnsPreferences';
15
- import { shouldIncludeColumn } from './DefaultTable.utils';
16
- import useDefaultTableTheme from './useDefaultTableTheme';
17
-
18
- const DefaultTableControls = ({ storeName }) => {
19
- const store = useStore(storeName);
20
- const configs = store?.getters?.configs || {};
21
- const effectiveViewMode =
22
- configs.effectiveViewMode ||
23
- configs.viewMode ||
24
- configs.initialViewMode ||
25
- 'table';
26
- const tablePreferenceScope =
27
- configs.tablePreferenceScope ||
28
- resolveDefaultTablePreferenceScope({ storeName });
29
- const columns = Array.isArray(store?.getters?.columns) ? store.getters.columns : [];
30
- const filters = store?.getters?.filters || {};
31
- const hasFilterableColumns = columns.some(
32
- column =>
33
- configs.showColumnFiltersButton !== false &&
34
- shouldIncludeColumn(column) &&
35
- column?.filter !== false &&
36
- column?.filters !== false,
37
- );
38
- const tableFiltersVisible = Boolean(configs.tableFiltersVisible);
39
- const activeFilterCount = Object.values(filters).filter(value => normalizeText(value) !== '').length;
40
- const addConfig = store?.getters?.add;
41
- const shouldRenderAddButton =
42
- (addConfig === true || configs.add === true) &&
43
- (typeof configs.onAdd === 'function' || typeof store?.actions?.save === 'function');
44
- const { tableButtonColors } = useDefaultTableTheme();
45
- const {
46
- backgroundColor,
47
- borderColor,
48
- iconColor,
49
- pressedBackgroundColor,
50
- pressedBorderColor,
51
- pressedIconColor,
52
- textColor,
53
- } = tableButtonColors;
54
-
55
- const buttonStyle = [
56
- styles.toolbarButton,
57
- { borderColor, backgroundColor },
58
- ];
59
- const pressedStyle = {
60
- backgroundColor: pressedBackgroundColor,
61
- borderColor: pressedBorderColor,
62
- };
63
- const updateConfigs = nextConfigs => {
64
- if (typeof store?.actions?.setConfigs === 'function') {
65
- store.actions.setConfigs(nextConfigs);
66
- return;
67
- }
68
-
69
- if (store?.getters) {
70
- store.getters.configs = nextConfigs;
71
- }
72
- };
73
-
74
- return (
75
- <>
76
- <DefaultDebug storeName={storeName} />
77
- {hasFilterableColumns && effectiveViewMode === 'table' ? (
78
- <TouchableOpacity
79
- style={[
80
- ...buttonStyle,
81
- tableFiltersVisible ? pressedStyle : null,
82
- ]}
83
- activeOpacity={0.82}
84
- onPress={() =>
85
- updateConfigs({
86
- ...configs,
87
- tableFiltersVisible: !tableFiltersVisible,
88
- })
89
- }
90
- >
91
- <Icon
92
- name="filter"
93
- size={14}
94
- color={tableFiltersVisible ? pressedIconColor : iconColor}
95
- />
96
- {activeFilterCount > 0 ? (
97
- <Text
98
- style={[
99
- styles.toolbarBadgeText,
100
- { color: tableFiltersVisible ? pressedIconColor : iconColor },
101
- ]}
102
- >
103
- {activeFilterCount}
104
- </Text>
105
- ) : null}
106
- </TouchableOpacity>
107
- ) : null}
108
- {hasFilterableColumns && effectiveViewMode === 'cards' ? (
109
- <DefaultModalButton
110
- renderButton={({ isOpen, open }) => (
111
- <TouchableOpacity
112
- style={[
113
- ...buttonStyle,
114
- isOpen ? pressedStyle : null,
115
- ]}
116
- activeOpacity={0.82}
117
- onPress={open}
118
- >
119
- <Icon
120
- name="filter"
121
- size={14}
122
- color={isOpen ? pressedIconColor : iconColor}
123
- />
124
- {activeFilterCount > 0 ? (
125
- <Text
126
- style={[
127
- styles.toolbarBadgeText,
128
- { color: isOpen ? pressedIconColor : iconColor },
129
- ]}>
130
- {activeFilterCount}
131
- </Text>
132
- ) : null}
133
- </TouchableOpacity>
134
- )}
135
- >
136
- {({ close, isOpen }) => (
137
- <DefaultFiltersModal
138
- storeName={storeName}
139
- visible={isOpen}
140
- onClose={close}
141
- />
142
- )}
143
- </DefaultModalButton>
144
- ) : null}
145
- <TouchableOpacity
146
- style={[
147
- ...buttonStyle,
148
- effectiveViewMode !== 'table' ? pressedStyle : null,
149
- ]}
150
- activeOpacity={0.82}
151
- onPress={() => {
152
- const nextViewMode = effectiveViewMode === 'table' ? 'cards' : 'table';
153
- const nextConfigs = {
154
- ...configs,
155
- effectiveViewMode: nextViewMode,
156
- viewMode: nextViewMode,
157
- };
158
-
159
- persistTableViewModePreference(tablePreferenceScope, nextConfigs.viewMode);
160
- updateConfigs(nextConfigs);
161
- }}
162
- >
163
- <Icon
164
- name={effectiveViewMode === 'table' ? 'list' : 'grid'}
165
- size={14}
166
- color={effectiveViewMode !== 'table' ? pressedIconColor : iconColor}
167
- />
168
- </TouchableOpacity>
169
- <DefaultModalButton
170
- renderButton={({ isOpen, toggle }) => (
171
- <TouchableOpacity
172
- style={[
173
- ...buttonStyle,
174
- isOpen ? pressedStyle : null,
175
- ]}
176
- activeOpacity={0.82}
177
- onPress={toggle}
178
- >
179
- <Icon name="columns" size={14} color={isOpen ? pressedIconColor : textColor} />
180
- </TouchableOpacity>
181
- )}
182
- >
183
- {({ close, isOpen }) => (
184
- <DefaultColumnMenu
185
- storeName={storeName}
186
- visible={isOpen}
187
- onClose={close}
188
- />
189
- )}
190
- </DefaultModalButton>
191
- {shouldRenderAddButton ? (
192
- <TouchableOpacity
193
- style={[
194
- styles.toolbarButton,
195
- styles.toolbarAddButton,
196
- { backgroundColor: backgroundColor, borderColor: backgroundColor },
197
- ]}
198
- activeOpacity={0.85}
199
- onPress={() => configs.onAdd?.()}
200
- >
201
- <Icon name="plus" size={16} color={textColor} />
202
- </TouchableOpacity>
203
- ) : null}
204
- </>
205
- );
206
- };
207
-
208
- export default DefaultTableControls;
1
+ import React from 'react';
2
+ import { Text, TouchableOpacity } from 'react-native';
3
+ import Icon from 'react-native-vector-icons/Feather';
4
+ import { useStore } from '@store';
5
+ import DefaultColumnMenu from './DefaultColumnMenu';
6
+ import DefaultDebug from './DefaultDebug';
7
+ import DefaultFiltersModal from './DefaultFiltersModal';
8
+ import DefaultModalButton from './DefaultModalButton';
9
+ import styles from './DefaultTable.styles';
10
+ import { normalizeText } from '../inputs/defaultInputUtils';
11
+ import {
12
+ persistTableViewModePreference,
13
+ resolveDefaultTablePreferenceScope,
14
+ } from '../../utils/tableVisibleColumnsPreferences';
15
+ import { shouldIncludeColumn } from './DefaultTable.utils';
16
+ import useDefaultTableTheme from './useDefaultTableTheme';
17
+
18
+ const DefaultTableControls = ({ storeName }) => {
19
+ const store = useStore(storeName);
20
+ const configs = store?.getters?.configs || {};
21
+ const effectiveViewMode =
22
+ configs.effectiveViewMode ||
23
+ configs.viewMode ||
24
+ configs.initialViewMode ||
25
+ 'table';
26
+ const tablePreferenceScope =
27
+ configs.tablePreferenceScope ||
28
+ resolveDefaultTablePreferenceScope({ storeName });
29
+ const columns = Array.isArray(store?.getters?.columns) ? store.getters.columns : [];
30
+ const filters = store?.getters?.filters || {};
31
+ const hasFilterableColumns = columns.some(
32
+ column =>
33
+ configs.showColumnFiltersButton !== false &&
34
+ shouldIncludeColumn(column) &&
35
+ column?.filter !== false &&
36
+ column?.filters !== false,
37
+ );
38
+ const tableFiltersVisible = Boolean(configs.tableFiltersVisible);
39
+ const activeFilterCount = Object.values(filters).filter(value => normalizeText(value) !== '').length;
40
+ const addConfig = store?.getters?.add;
41
+ const shouldRenderAddButton =
42
+ (addConfig === true || configs.add === true) &&
43
+ (typeof configs.onAdd === 'function' || typeof store?.actions?.save === 'function');
44
+ const { tableButtonColors } = useDefaultTableTheme();
45
+ const {
46
+ backgroundColor,
47
+ borderColor,
48
+ iconColor,
49
+ pressedBackgroundColor,
50
+ pressedBorderColor,
51
+ pressedIconColor,
52
+ textColor,
53
+ } = tableButtonColors;
54
+
55
+ const buttonStyle = [
56
+ styles.toolbarButton,
57
+ { borderColor, backgroundColor },
58
+ ];
59
+ const pressedStyle = {
60
+ backgroundColor: pressedBackgroundColor,
61
+ borderColor: pressedBorderColor,
62
+ };
63
+ const updateConfigs = nextConfigs => {
64
+ if (typeof store?.actions?.setConfigs === 'function') {
65
+ store.actions.setConfigs(nextConfigs);
66
+ return;
67
+ }
68
+
69
+ if (store?.getters) {
70
+ store.getters.configs = nextConfigs;
71
+ }
72
+ };
73
+ const nextViewMode = effectiveViewMode === 'table' ? 'cards' : 'table';
74
+
75
+ return (
76
+ <>
77
+ <DefaultDebug storeName={storeName} />
78
+ {hasFilterableColumns && effectiveViewMode === 'table' ? (
79
+ <TouchableOpacity
80
+ style={[
81
+ ...buttonStyle,
82
+ tableFiltersVisible ? pressedStyle : null,
83
+ ]}
84
+ activeOpacity={0.82}
85
+ onPress={() =>
86
+ updateConfigs({
87
+ ...configs,
88
+ tableFiltersVisible: !tableFiltersVisible,
89
+ })
90
+ }
91
+ >
92
+ <Icon
93
+ name="filter"
94
+ size={14}
95
+ color={tableFiltersVisible ? pressedIconColor : textColor}
96
+ />
97
+ {activeFilterCount > 0 ? (
98
+ <Text
99
+ style={[
100
+ styles.toolbarBadgeText,
101
+ { color: tableFiltersVisible ? pressedIconColor : textColor },
102
+ ]}
103
+ >
104
+ {activeFilterCount}
105
+ </Text>
106
+ ) : null}
107
+ </TouchableOpacity>
108
+ ) : null}
109
+ {hasFilterableColumns && effectiveViewMode === 'cards' ? (
110
+ <DefaultModalButton
111
+ renderButton={({ isOpen, open }) => (
112
+ <TouchableOpacity
113
+ style={[
114
+ ...buttonStyle,
115
+ isOpen ? pressedStyle : null,
116
+ ]}
117
+ activeOpacity={0.82}
118
+ onPress={open}
119
+ >
120
+ <Icon
121
+ name="filter"
122
+ size={14}
123
+ color={isOpen ? pressedIconColor : textColor}
124
+ />
125
+ {activeFilterCount > 0 ? (
126
+ <Text
127
+ style={[
128
+ styles.toolbarBadgeText,
129
+ { color: isOpen ? pressedIconColor : textColor },
130
+ ]}>
131
+ {activeFilterCount}
132
+ </Text>
133
+ ) : null}
134
+ </TouchableOpacity>
135
+ )}
136
+ >
137
+ {({ close, isOpen }) => (
138
+ <DefaultFiltersModal
139
+ storeName={storeName}
140
+ visible={isOpen}
141
+ onClose={close}
142
+ />
143
+ )}
144
+ </DefaultModalButton>
145
+ ) : null}
146
+ <TouchableOpacity
147
+ style={buttonStyle}
148
+ activeOpacity={0.82}
149
+ onPress={() => {
150
+ const nextConfigs = {
151
+ ...configs,
152
+ effectiveViewMode: nextViewMode,
153
+ viewMode: nextViewMode,
154
+ };
155
+
156
+ persistTableViewModePreference(tablePreferenceScope, nextConfigs.viewMode);
157
+ updateConfigs(nextConfigs);
158
+ }}
159
+ >
160
+ <Icon
161
+ name={nextViewMode === 'cards' ? 'grid' : 'list'}
162
+ size={14}
163
+ color={textColor}
164
+ />
165
+ </TouchableOpacity>
166
+ <DefaultModalButton
167
+ renderButton={({ isOpen, toggle }) => (
168
+ <TouchableOpacity
169
+ style={[
170
+ ...buttonStyle,
171
+ isOpen ? pressedStyle : null,
172
+ ]}
173
+ activeOpacity={0.82}
174
+ onPress={toggle}
175
+ >
176
+ <Icon name="columns" size={14} color={isOpen ? pressedIconColor : textColor} />
177
+ </TouchableOpacity>
178
+ )}
179
+ >
180
+ {({ close, isOpen }) => (
181
+ <DefaultColumnMenu
182
+ storeName={storeName}
183
+ visible={isOpen}
184
+ onClose={close}
185
+ />
186
+ )}
187
+ </DefaultModalButton>
188
+ {shouldRenderAddButton ? (
189
+ <TouchableOpacity
190
+ style={[
191
+ styles.toolbarButton,
192
+ styles.toolbarAddButton,
193
+ { backgroundColor: backgroundColor, borderColor: backgroundColor },
194
+ ]}
195
+ activeOpacity={0.85}
196
+ onPress={() => configs.onAdd?.()}
197
+ >
198
+ <Icon name="plus" size={16} color={textColor} />
199
+ </TouchableOpacity>
200
+ ) : null}
201
+ </>
202
+ );
203
+ };
204
+
205
+ export default DefaultTableControls;