@controleonline/ui-default 1.0.266 → 1.0.268
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 +3 -2
- package/package.json +1 -1
- package/src/react/components/filters/CompactFilterSelector.js +110 -39
- package/src/react/components/filters/CompactFilterSelector.styles.js +34 -12
- package/src/react/components/inputs/DefaultInput.js +97 -33
- package/src/react/components/inputs/DefaultInput.styles.js +42 -4
- package/src/react/components/inputs/DefaultSelect.js +130 -41
- package/src/react/components/inputs/DefaultSelect.styles.js +3 -0
- package/src/react/components/inputs/defaultInputUtils.js +200 -32
- package/src/react/components/table/DefaultTable.js +13 -5
- package/src/react/components/table/DefaultTable.styles.js +56 -51
- package/src/react/components/table/DefaultTable.utils.js +33 -3
- package/src/react/components/table/DefaultTableCards.js +29 -11
- package/src/react/components/table/DefaultTableFooter.js +10 -1
- package/src/react/components/table/DefaultTableRowActions.js +43 -0
- package/src/react/components/table/DefaultTableRows.js +52 -19
- package/src/react/components/table/DefaultTableToolbar.js +8 -2
- package/src/react/components/table/useDefaultTableTheme.js +65 -16
- package/src/tests/react/components/inputs/DefaultSelect.test.js +72 -0
- package/src/tests/react/components/table/DefaultTable.test.js +55 -0
- package/src/tests/react/components/table/DefaultTable.utils.test.js +37 -0
- package/src/tests/react/inputs/defaultInputUtils.test.js +118 -15
|
@@ -16,15 +16,14 @@ const styles = StyleSheet.create({
|
|
|
16
16
|
flex: 1,
|
|
17
17
|
width: '100%',
|
|
18
18
|
minHeight: 0,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
overflow: 'visible',
|
|
19
|
+
borderRadius: 8,
|
|
20
|
+
overflow: 'hidden',
|
|
22
21
|
position: 'relative',
|
|
23
22
|
},
|
|
24
23
|
toolbar: {
|
|
25
|
-
minHeight:
|
|
26
|
-
paddingHorizontal:
|
|
27
|
-
paddingVertical:
|
|
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:
|
|
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:
|
|
80
|
-
maxWidth:
|
|
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:
|
|
115
|
-
height:
|
|
116
|
-
borderRadius:
|
|
117
|
-
paddingHorizontal:
|
|
113
|
+
minWidth: 36,
|
|
114
|
+
height: 36,
|
|
115
|
+
borderRadius: 8,
|
|
116
|
+
paddingHorizontal: 10,
|
|
118
117
|
borderWidth: 1,
|
|
119
118
|
flexDirection: 'row',
|
|
120
119
|
alignItems: 'center',
|
|
@@ -124,8 +123,8 @@ const styles = StyleSheet.create({
|
|
|
124
123
|
toolbarButtonActive: {
|
|
125
124
|
},
|
|
126
125
|
toolbarAddButton: {
|
|
127
|
-
minWidth:
|
|
128
|
-
width:
|
|
126
|
+
minWidth: 36,
|
|
127
|
+
width: 36,
|
|
129
128
|
paddingHorizontal: 0,
|
|
130
129
|
},
|
|
131
130
|
floatingAddButton: {
|
|
@@ -283,8 +282,8 @@ const styles = StyleSheet.create({
|
|
|
283
282
|
minWidth: '100%',
|
|
284
283
|
minHeight: 0,
|
|
285
284
|
},
|
|
286
|
-
headerRow: {
|
|
287
|
-
minHeight:
|
|
285
|
+
headerRow: {
|
|
286
|
+
minHeight: 40,
|
|
288
287
|
width: '100%',
|
|
289
288
|
flexDirection: 'row',
|
|
290
289
|
alignItems: 'center',
|
|
@@ -292,8 +291,8 @@ const styles = StyleSheet.create({
|
|
|
292
291
|
borderBottomWidth: 1,
|
|
293
292
|
borderBottomColor: '#E2E8F0',
|
|
294
293
|
},
|
|
295
|
-
filterRow: {
|
|
296
|
-
minHeight:
|
|
294
|
+
filterRow: {
|
|
295
|
+
minHeight: 46,
|
|
297
296
|
width: '100%',
|
|
298
297
|
flexDirection: 'row',
|
|
299
298
|
alignItems: 'stretch',
|
|
@@ -301,25 +300,24 @@ const styles = StyleSheet.create({
|
|
|
301
300
|
borderBottomWidth: 1,
|
|
302
301
|
borderBottomColor: '#E2E8F0',
|
|
303
302
|
},
|
|
304
|
-
row: {
|
|
305
|
-
minHeight:
|
|
303
|
+
row: {
|
|
304
|
+
minHeight: 48,
|
|
306
305
|
width: '100%',
|
|
307
306
|
flexDirection: 'row',
|
|
308
307
|
alignItems: 'stretch',
|
|
309
308
|
borderBottomWidth: 1,
|
|
310
309
|
borderBottomColor: '#EEF2F7',
|
|
311
310
|
},
|
|
312
|
-
cell: {
|
|
313
|
-
minWidth: 118,
|
|
314
|
-
flexBasis: 118,
|
|
311
|
+
cell: {
|
|
312
|
+
minWidth: 118,
|
|
313
|
+
flexBasis: 118,
|
|
315
314
|
flexGrow: 1,
|
|
316
315
|
flexShrink: 0,
|
|
317
|
-
paddingHorizontal:
|
|
318
|
-
paddingVertical:
|
|
319
|
-
justifyContent: 'center',
|
|
320
|
-
borderRightWidth:
|
|
321
|
-
|
|
322
|
-
},
|
|
316
|
+
paddingHorizontal: 14,
|
|
317
|
+
paddingVertical: 10,
|
|
318
|
+
justifyContent: 'center',
|
|
319
|
+
borderRightWidth: 0,
|
|
320
|
+
},
|
|
323
321
|
identityCell: {
|
|
324
322
|
minWidth: 76,
|
|
325
323
|
flexBasis: 76,
|
|
@@ -377,13 +375,12 @@ const styles = StyleSheet.create({
|
|
|
377
375
|
flexBasis: 132,
|
|
378
376
|
flexGrow: 0.9,
|
|
379
377
|
},
|
|
380
|
-
headerText: {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
},
|
|
378
|
+
headerText: {
|
|
379
|
+
fontSize: 11,
|
|
380
|
+
fontWeight: '800',
|
|
381
|
+
letterSpacing: 0,
|
|
382
|
+
textTransform: 'uppercase',
|
|
383
|
+
},
|
|
387
384
|
sortableHeader: {
|
|
388
385
|
flexDirection: 'row',
|
|
389
386
|
alignItems: 'center',
|
|
@@ -404,11 +401,10 @@ const styles = StyleSheet.create({
|
|
|
404
401
|
fontSize: 11,
|
|
405
402
|
fontWeight: '700',
|
|
406
403
|
},
|
|
407
|
-
cellText: {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
},
|
|
404
|
+
cellText: {
|
|
405
|
+
fontSize: 13,
|
|
406
|
+
fontWeight: '600',
|
|
407
|
+
},
|
|
412
408
|
mutedCellText: {
|
|
413
409
|
color: '#94A3B8',
|
|
414
410
|
},
|
|
@@ -449,9 +445,11 @@ const styles = StyleSheet.create({
|
|
|
449
445
|
},
|
|
450
446
|
rowActionsGroup: {
|
|
451
447
|
flexDirection: 'row',
|
|
448
|
+
flexWrap: 'wrap',
|
|
452
449
|
alignItems: 'center',
|
|
453
450
|
justifyContent: 'center',
|
|
454
451
|
gap: 6,
|
|
452
|
+
width: '100%',
|
|
455
453
|
},
|
|
456
454
|
iconButton: {
|
|
457
455
|
width: 28,
|
|
@@ -491,23 +489,30 @@ const styles = StyleSheet.create({
|
|
|
491
489
|
flexGrow: 1,
|
|
492
490
|
width: '100%',
|
|
493
491
|
},
|
|
494
|
-
cardItem: {
|
|
495
|
-
position: 'relative',
|
|
496
|
-
},
|
|
492
|
+
cardItem: {
|
|
493
|
+
position: 'relative',
|
|
494
|
+
},
|
|
495
|
+
cardItemWithActions: {
|
|
496
|
+
flexDirection: 'row',
|
|
497
|
+
alignItems: 'center',
|
|
498
|
+
gap: 8,
|
|
499
|
+
},
|
|
500
|
+
cardContent: {
|
|
501
|
+
flex: 1,
|
|
502
|
+
minWidth: 0,
|
|
503
|
+
},
|
|
497
504
|
cardActions: {
|
|
498
|
-
position: 'absolute',
|
|
499
|
-
right: 10,
|
|
500
|
-
bottom: 10,
|
|
501
505
|
flexDirection: 'row',
|
|
502
506
|
alignItems: 'center',
|
|
507
|
+
justifyContent: 'flex-end',
|
|
503
508
|
gap: 6,
|
|
509
|
+
flexShrink: 0,
|
|
504
510
|
},
|
|
505
511
|
cardActionGroup: {
|
|
506
|
-
position: 'absolute',
|
|
507
|
-
right: 8,
|
|
508
|
-
top: 8,
|
|
509
512
|
flexDirection: 'row',
|
|
510
513
|
alignItems: 'center',
|
|
514
|
+
justifyContent: 'flex-end',
|
|
515
|
+
alignSelf: 'flex-end',
|
|
511
516
|
gap: 6,
|
|
512
517
|
},
|
|
513
518
|
defaultCard: {
|
|
@@ -485,14 +485,44 @@ export const resolveSortComparable = ({ column, row, storeName, columns }) => {
|
|
|
485
485
|
|
|
486
486
|
export const getColumnStyle = column => {
|
|
487
487
|
const key = getColumnKey(column);
|
|
488
|
-
|
|
488
|
+
const customSize = {};
|
|
489
|
+
const columnWidth = Number(column?.width);
|
|
490
|
+
const columnMinWidth = Number(column?.minWidth);
|
|
491
|
+
const columnFlexBasis = Number(column?.flexBasis);
|
|
492
|
+
|
|
493
|
+
if (Number.isFinite(columnWidth) && columnWidth > 0) {
|
|
494
|
+
customSize.width = columnWidth;
|
|
495
|
+
customSize.flexBasis = columnWidth;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
if (Number.isFinite(columnMinWidth) && columnMinWidth > 0) {
|
|
499
|
+
customSize.minWidth = columnMinWidth;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (Number.isFinite(columnFlexBasis) && columnFlexBasis > 0) {
|
|
503
|
+
customSize.flexBasis = columnFlexBasis;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const columnSizeStyle = Object.keys(customSize).length ? customSize : null;
|
|
507
|
+
|
|
508
|
+
if (column?.isIdentity) return [styles.cell, styles.identityCell, columnSizeStyle];
|
|
489
509
|
if (['price', 'total', 'amount', 'value'].includes(key)) {
|
|
490
|
-
return [styles.cell, styles.moneyCell];
|
|
510
|
+
return [styles.cell, styles.moneyCell, columnSizeStyle];
|
|
491
511
|
}
|
|
492
|
-
return styles.cell;
|
|
512
|
+
return [styles.cell, columnSizeStyle];
|
|
493
513
|
};
|
|
494
514
|
|
|
495
515
|
export const getColumnMinWidth = column => {
|
|
516
|
+
const columnMinWidth = Number(column?.minWidth);
|
|
517
|
+
if (Number.isFinite(columnMinWidth) && columnMinWidth > 0) {
|
|
518
|
+
return columnMinWidth;
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
const columnWidth = Number(column?.width);
|
|
522
|
+
if (Number.isFinite(columnWidth) && columnWidth > 0) {
|
|
523
|
+
return columnWidth;
|
|
524
|
+
}
|
|
525
|
+
|
|
496
526
|
const key = getColumnKey(column);
|
|
497
527
|
if (column?.isIdentity) return IDENTITY_CELL_MIN_WIDTH;
|
|
498
528
|
if (['price', 'total', 'amount', 'value'].includes(key)) {
|
|
@@ -5,6 +5,9 @@ import { formatStoreColumnLabel } from '@controleonline/ui-common/src/react/util
|
|
|
5
5
|
import { getColumnKey, resolveCellText } from '../inputs/defaultInputUtils';
|
|
6
6
|
import DefaultTableEmptyState from './DefaultTableEmptyState';
|
|
7
7
|
import DefaultTableInput from './DefaultTableInput';
|
|
8
|
+
import DefaultTableRowActions, {
|
|
9
|
+
hasDefaultTableRowActionsComponent,
|
|
10
|
+
} from './DefaultTableRowActions';
|
|
8
11
|
import {
|
|
9
12
|
END_REACHED_THRESHOLD,
|
|
10
13
|
getRowKey,
|
|
@@ -63,14 +66,20 @@ const DefaultTableCards = ({ storeName }) => {
|
|
|
63
66
|
};
|
|
64
67
|
const RowActionsComponent = configs.rowActionsComponent;
|
|
65
68
|
const hasRowPress = typeof configs.onRowPress === 'function';
|
|
66
|
-
const hasCustomRowActions =
|
|
69
|
+
const hasCustomRowActions = hasDefaultTableRowActionsComponent(RowActionsComponent);
|
|
67
70
|
const hasEditAction = typeof configs.onEditRow === 'function';
|
|
68
71
|
const hasRowActions = configs.showRowActions !== false && (hasCustomRowActions || hasEditAction);
|
|
69
72
|
const customRowActions = hasCustomRowActions ? (
|
|
70
|
-
<
|
|
73
|
+
<DefaultTableRowActions
|
|
74
|
+
component={RowActionsComponent}
|
|
75
|
+
helpers={{
|
|
76
|
+
openEdit: () => configs.onEditRow?.(row),
|
|
77
|
+
openRow: hasRowPress ? () => configs.onRowPress(row) : null,
|
|
78
|
+
}}
|
|
71
79
|
openEdit={() => configs.onEditRow?.(row)}
|
|
72
80
|
openRow={hasRowPress ? () => configs.onRowPress(row) : null}
|
|
73
81
|
row={row}
|
|
82
|
+
storeName={storeName}
|
|
74
83
|
/>
|
|
75
84
|
) : null;
|
|
76
85
|
const editButton = hasEditAction ? (
|
|
@@ -81,15 +90,24 @@ const DefaultTableCards = ({ storeName }) => {
|
|
|
81
90
|
|
|
82
91
|
if (typeof configs.renderCard === 'function') {
|
|
83
92
|
return (
|
|
84
|
-
<View
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
+
<View
|
|
94
|
+
key={row?.['@id'] || row?.id}
|
|
95
|
+
style={[
|
|
96
|
+
styles.cardItem,
|
|
97
|
+
hasRowActions ? styles.cardItemWithActions : null,
|
|
98
|
+
rowStyleValue,
|
|
99
|
+
]}
|
|
100
|
+
>
|
|
101
|
+
<View style={styles.cardContent}>
|
|
102
|
+
{configs.renderCard({
|
|
103
|
+
item: row,
|
|
104
|
+
openEdit: () => configs.onEditRow?.(row),
|
|
105
|
+
openRow: hasRowPress ? () => configs.onRowPress(row) : null,
|
|
106
|
+
renderField,
|
|
107
|
+
renderValue,
|
|
108
|
+
row,
|
|
109
|
+
})}
|
|
110
|
+
</View>
|
|
93
111
|
{hasRowActions ? (
|
|
94
112
|
<View style={styles.cardActions}>
|
|
95
113
|
{customRowActions}
|
|
@@ -124,7 +124,16 @@ const DefaultTableFooter = ({ storeName }) => {
|
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
return (
|
|
127
|
-
<View
|
|
127
|
+
<View
|
|
128
|
+
style={[
|
|
129
|
+
styles.footerBar,
|
|
130
|
+
{
|
|
131
|
+
backgroundColor: tableFooterBackgroundColor,
|
|
132
|
+
borderTopColor: tableFooterBorderColor,
|
|
133
|
+
borderTopWidth: tableFooterBorderColor ? 1 : 0,
|
|
134
|
+
},
|
|
135
|
+
]}
|
|
136
|
+
>
|
|
128
137
|
{summaryEntries.length > 0 ? (
|
|
129
138
|
<View style={styles.footerSummaryList}>
|
|
130
139
|
{summaryEntries.map(entry => (
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_ROW_ACTIONS_WIDTH = 96;
|
|
4
|
+
|
|
5
|
+
const isReactComponentType = value =>
|
|
6
|
+
value &&
|
|
7
|
+
typeof value === 'object' &&
|
|
8
|
+
typeof value.$$typeof === 'symbol';
|
|
9
|
+
|
|
10
|
+
export const hasDefaultTableRowActionsComponent = component =>
|
|
11
|
+
typeof component === 'function' ||
|
|
12
|
+
React.isValidElement(component) ||
|
|
13
|
+
isReactComponentType(component);
|
|
14
|
+
|
|
15
|
+
export const resolveDefaultTableRowActionsWidth = configs => {
|
|
16
|
+
const rawWidth = configs?.rowActionsWidth ?? configs?.actionsColumnWidth;
|
|
17
|
+
const width = Number(rawWidth);
|
|
18
|
+
|
|
19
|
+
if (Number.isFinite(width) && width > 0) {
|
|
20
|
+
return width;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return DEFAULT_ROW_ACTIONS_WIDTH;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const DefaultTableRowActions = ({ component, ...props }) => {
|
|
27
|
+
if (React.isValidElement(component)) {
|
|
28
|
+
return React.cloneElement(component, {
|
|
29
|
+
...(component.props || {}),
|
|
30
|
+
...props,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (hasDefaultTableRowActionsComponent(component)) {
|
|
35
|
+
const RowActionsComponent = component;
|
|
36
|
+
|
|
37
|
+
return <RowActionsComponent {...props} />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default DefaultTableRowActions;
|
|
@@ -5,8 +5,12 @@ import { useStore } from '@store';
|
|
|
5
5
|
import { formatStoreColumnLabel } from '@controleonline/ui-common/src/react/utils/storeColumns';
|
|
6
6
|
import { getColumnKey } from '../inputs/defaultInputUtils';
|
|
7
7
|
import DefaultColumnFilter from '../filters/DefaultColumnFilter';
|
|
8
|
-
import DefaultTableEmptyState from './DefaultTableEmptyState';
|
|
9
|
-
import DefaultTableInput from './DefaultTableInput';
|
|
8
|
+
import DefaultTableEmptyState from './DefaultTableEmptyState';
|
|
9
|
+
import DefaultTableInput from './DefaultTableInput';
|
|
10
|
+
import DefaultTableRowActions, {
|
|
11
|
+
hasDefaultTableRowActionsComponent,
|
|
12
|
+
resolveDefaultTableRowActionsWidth,
|
|
13
|
+
} from './DefaultTableRowActions';
|
|
10
14
|
import {
|
|
11
15
|
END_REACHED_THRESHOLD,
|
|
12
16
|
getColumnStyle,
|
|
@@ -23,7 +27,7 @@ import useDefaultTableTheme from './useDefaultTableTheme';
|
|
|
23
27
|
const DefaultTableRows = ({ storeName }) => {
|
|
24
28
|
const store = useStore(storeName);
|
|
25
29
|
const configs = store?.getters?.configs || {};
|
|
26
|
-
const { palette, resolvedAccentColor, themeTokens } = useDefaultTableTheme();
|
|
30
|
+
const { palette, resolvedAccentColor, tableBorderColors, themeTokens } = useDefaultTableTheme();
|
|
27
31
|
const columns = Array.isArray(store?.getters?.columns) ? store.getters.columns : [];
|
|
28
32
|
const visibleColumns = store?.getters?.visibleColumns || {};
|
|
29
33
|
const tableColumns = columns.filter(
|
|
@@ -38,7 +42,8 @@ const DefaultTableRows = ({ storeName }) => {
|
|
|
38
42
|
const emptyStateLabel = isLoading
|
|
39
43
|
? global.t?.t(storeName, 'label', 'loading')
|
|
40
44
|
: global.t?.t(storeName, 'label', 'empty');
|
|
41
|
-
const tableBorderColor =
|
|
45
|
+
const tableBorderColor = tableBorderColors.rowBorderColor;
|
|
46
|
+
const tableHeaderBorderColor = tableBorderColors.headerBorderColor || tableBorderColor;
|
|
42
47
|
const tableEvenColor = themeTokens.listItemEvenRow || themeTokens['bg-even-light'] || palette.background;
|
|
43
48
|
const tableHeaderColor = themeTokens['bg-headers-light'] || resolvedAccentColor;
|
|
44
49
|
const tableMutedColor = palette.textSecondary;
|
|
@@ -47,14 +52,14 @@ const DefaultTableRows = ({ storeName }) => {
|
|
|
47
52
|
const tableTextColor = palette.text;
|
|
48
53
|
const rowStyle = configs.rowStyle;
|
|
49
54
|
const hasRowPress = typeof configs.onRowPress === 'function';
|
|
50
|
-
const hasCustomRowActions =
|
|
51
|
-
const hasEditAction = typeof configs.onEditRow === 'function';
|
|
52
|
-
const hasRowActions = configs.showRowActions !== false && (hasCustomRowActions || hasEditAction);
|
|
55
|
+
const hasCustomRowActions = hasDefaultTableRowActionsComponent(configs.rowActionsComponent);
|
|
56
|
+
const hasEditAction = typeof configs.onEditRow === 'function';
|
|
57
|
+
const hasRowActions = configs.showRowActions !== false && (hasCustomRowActions || hasEditAction);
|
|
53
58
|
const shouldPinRowActions = configs.pinRowActions !== false;
|
|
54
59
|
const hasColumnFilters =
|
|
55
60
|
configs.showColumnFiltersButton !== false &&
|
|
56
61
|
configs.tableFiltersVisible === true;
|
|
57
|
-
const actionsCellWidth = hasRowActions ?
|
|
62
|
+
const actionsCellWidth = hasRowActions ? resolveDefaultTableRowActionsWidth(configs) : 0;
|
|
58
63
|
const [horizontalMetrics, setHorizontalMetrics] = useState({
|
|
59
64
|
contentWidth: 0,
|
|
60
65
|
viewportWidth: 0,
|
|
@@ -128,8 +133,12 @@ const DefaultTableRows = ({ storeName }) => {
|
|
|
128
133
|
<RowComponent
|
|
129
134
|
key={getRowKey(row)}
|
|
130
135
|
style={[
|
|
131
|
-
styles.row,
|
|
132
|
-
{
|
|
136
|
+
styles.row,
|
|
137
|
+
{
|
|
138
|
+
backgroundColor: rowBackgroundColor,
|
|
139
|
+
borderBottomColor: tableBorderColor,
|
|
140
|
+
borderBottomWidth: tableBorderColor ? 1 : 0,
|
|
141
|
+
},
|
|
133
142
|
rowStyleValue,
|
|
134
143
|
]}
|
|
135
144
|
{...rowPressProps}
|
|
@@ -174,13 +183,19 @@ const DefaultTableRows = ({ storeName }) => {
|
|
|
174
183
|
]}
|
|
175
184
|
>
|
|
176
185
|
<View style={styles.rowActionsGroup}>
|
|
177
|
-
{hasCustomRowActions ? (
|
|
178
|
-
<
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
186
|
+
{hasCustomRowActions ? (
|
|
187
|
+
<DefaultTableRowActions
|
|
188
|
+
component={RowActionsComponent}
|
|
189
|
+
helpers={{
|
|
190
|
+
openEdit: () => configs.onEditRow?.(row),
|
|
191
|
+
openRow: hasRowPress ? () => configs.onRowPress(row) : null,
|
|
192
|
+
}}
|
|
193
|
+
openEdit={() => configs.onEditRow?.(row)}
|
|
194
|
+
openRow={hasRowPress ? () => configs.onRowPress(row) : null}
|
|
195
|
+
row={row}
|
|
196
|
+
storeName={storeName}
|
|
197
|
+
/>
|
|
198
|
+
) : null}
|
|
184
199
|
{hasEditAction ? (
|
|
185
200
|
<TouchableOpacity
|
|
186
201
|
style={[styles.iconButton, { borderColor: tableBorderColor, backgroundColor: tableSurfaceColor }]}
|
|
@@ -209,7 +224,16 @@ const DefaultTableRows = ({ storeName }) => {
|
|
|
209
224
|
contentContainerStyle={styles.horizontalScrollContent}
|
|
210
225
|
>
|
|
211
226
|
<View style={styles.content}>
|
|
212
|
-
<View
|
|
227
|
+
<View
|
|
228
|
+
style={[
|
|
229
|
+
styles.headerRow,
|
|
230
|
+
{
|
|
231
|
+
backgroundColor: tableHeaderColor,
|
|
232
|
+
borderBottomColor: tableHeaderBorderColor,
|
|
233
|
+
borderBottomWidth: tableHeaderBorderColor ? 1 : 0,
|
|
234
|
+
},
|
|
235
|
+
]}
|
|
236
|
+
>
|
|
213
237
|
{tableColumns.map(column => {
|
|
214
238
|
const fieldName = getColumnKey(column);
|
|
215
239
|
const label = formatStoreColumnLabel({
|
|
@@ -267,7 +291,16 @@ const DefaultTableRows = ({ storeName }) => {
|
|
|
267
291
|
) : null}
|
|
268
292
|
</View>
|
|
269
293
|
{hasColumnFilters ? (
|
|
270
|
-
<View
|
|
294
|
+
<View
|
|
295
|
+
style={[
|
|
296
|
+
styles.filterRow,
|
|
297
|
+
{
|
|
298
|
+
backgroundColor: tableHeaderColor,
|
|
299
|
+
borderBottomColor: tableHeaderBorderColor,
|
|
300
|
+
borderBottomWidth: tableHeaderBorderColor ? 1 : 0,
|
|
301
|
+
},
|
|
302
|
+
]}
|
|
303
|
+
>
|
|
271
304
|
{tableColumns.map(column => {
|
|
272
305
|
const fieldName = getColumnKey(column);
|
|
273
306
|
|
|
@@ -20,13 +20,15 @@ const DefaultTableToolbar = ({ storeName }) => {
|
|
|
20
20
|
const showTotalItemsInCompactToolbar = configs.showTotalItemsInCompactToolbar === true;
|
|
21
21
|
const showTotalItemsInFooter = configs.showTotalItemsInFooter !== false;
|
|
22
22
|
const toolbarActions = Array.isArray(configs.toolbarActions) ? configs.toolbarActions : [];
|
|
23
|
-
const { toolbarColors } = useDefaultTableTheme();
|
|
23
|
+
const { tableBorderColors, toolbarColors } = useDefaultTableTheme();
|
|
24
24
|
const {
|
|
25
25
|
backgroundColor: toolbarBackgroundColor,
|
|
26
26
|
borderColor: toolbarBorderColor,
|
|
27
27
|
countBackgroundColor: toolbarCountBackgroundColor,
|
|
28
28
|
countTextColor: toolbarCountTextColor,
|
|
29
29
|
} = toolbarColors;
|
|
30
|
+
const resolvedToolbarBorderColor =
|
|
31
|
+
tableBorderColors.toolbarBorderColor || toolbarBorderColor;
|
|
30
32
|
const storeTotalItems = store?.getters?.totalItems;
|
|
31
33
|
const resolvedTotalItems = storeTotalItems;
|
|
32
34
|
const totalItemsNumber = Number(resolvedTotalItems);
|
|
@@ -63,7 +65,11 @@ const DefaultTableToolbar = ({ storeName }) => {
|
|
|
63
65
|
style={[
|
|
64
66
|
styles.toolbar,
|
|
65
67
|
shouldRenderCompactToolbarTotalItems ? styles.toolbarWithCompactTotal : null,
|
|
66
|
-
{
|
|
68
|
+
{
|
|
69
|
+
borderBottomColor: resolvedToolbarBorderColor,
|
|
70
|
+
borderBottomWidth: resolvedToolbarBorderColor ? 1 : 0,
|
|
71
|
+
backgroundColor: toolbarBackgroundColor,
|
|
72
|
+
},
|
|
67
73
|
]}
|
|
68
74
|
>
|
|
69
75
|
{shouldRenderCompactToolbarTotalItems ? (
|
|
@@ -1,20 +1,69 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { useStore } from '@store';
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useStore } from '@store';
|
|
3
|
+
|
|
4
|
+
const firstThemeToken = (themeColors, keys) =>
|
|
5
|
+
keys.map(key => themeColors?.[key]).find(Boolean);
|
|
6
|
+
|
|
7
|
+
const useDefaultTableTheme = (accentColor = null) => {
|
|
8
|
+
const themeStore = useStore('theme');
|
|
9
|
+
const rawThemeColors = themeStore?.getters?.colors || {};
|
|
10
|
+
const themeColors = useMemo(
|
|
11
|
+
() => ({ ...rawThemeColors }),
|
|
12
|
+
[rawThemeColors],
|
|
13
|
+
);
|
|
14
|
+
const themeTokens = useMemo(
|
|
15
|
+
() => ({ ...themeColors }),
|
|
16
|
+
[themeColors],
|
|
10
17
|
);
|
|
11
|
-
const palette = themeColors;
|
|
12
|
-
const resolvedAccentColor = accentColor ?? themeColors.primary;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
const palette = themeColors;
|
|
19
|
+
const resolvedAccentColor = accentColor ?? themeColors.primary;
|
|
20
|
+
const tableBorderColors = {
|
|
21
|
+
containerBorderColor: firstThemeToken(themeColors, [
|
|
22
|
+
'tableContainerBorder',
|
|
23
|
+
'tableBorder',
|
|
24
|
+
'tableHeaderBorder',
|
|
25
|
+
'tableToolbarBorder',
|
|
26
|
+
'cardBorder',
|
|
27
|
+
'listItemBorder',
|
|
28
|
+
'dividerBorder',
|
|
29
|
+
'dividerBackground',
|
|
30
|
+
'inputBorder',
|
|
31
|
+
'panelBorder',
|
|
32
|
+
'border',
|
|
33
|
+
]),
|
|
34
|
+
headerBorderColor: firstThemeToken(themeColors, [
|
|
35
|
+
'tableHeaderBorder',
|
|
36
|
+
'tableToolbarBorder',
|
|
37
|
+
'tableBorder',
|
|
38
|
+
'dividerBorder',
|
|
39
|
+
'dividerBackground',
|
|
40
|
+
'listItemBorder',
|
|
41
|
+
'border',
|
|
42
|
+
]),
|
|
43
|
+
rowBorderColor: firstThemeToken(themeColors, [
|
|
44
|
+
'tableRowBorder',
|
|
45
|
+
'listItemBorder',
|
|
46
|
+
'dividerBorder',
|
|
47
|
+
'dividerBackground',
|
|
48
|
+
'tableBorder',
|
|
49
|
+
'border',
|
|
50
|
+
]),
|
|
51
|
+
toolbarBorderColor: firstThemeToken(themeColors, [
|
|
52
|
+
'tableToolbarBorder',
|
|
53
|
+
'tableHeaderBorder',
|
|
54
|
+
'toolbarBorder',
|
|
55
|
+
'tableBorder',
|
|
56
|
+
'dividerBorder',
|
|
57
|
+
'dividerBackground',
|
|
58
|
+
'border',
|
|
59
|
+
]),
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
palette,
|
|
64
|
+
resolvedAccentColor,
|
|
65
|
+
tableBorderColors,
|
|
66
|
+
themeColors,
|
|
18
67
|
themeTokens,
|
|
19
68
|
checkboxBorderColor: themeColors.checkboxBorder,
|
|
20
69
|
checkboxSelectedMarkColor: themeColors.checkboxSelectedMark,
|