@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.
- package/package.json +1 -1
- package/src/react/components/inputs/DefaultInput.js +71 -33
- package/src/react/components/inputs/DefaultInput.styles.js +36 -4
- package/src/react/components/inputs/DefaultSelect.js +83 -35
- package/src/react/components/inputs/defaultInputUtils.js +173 -26
- package/src/react/components/table/DefaultDebug.js +234 -233
- package/src/react/components/table/DefaultTable.js +431 -396
- package/src/react/components/table/DefaultTable.styles.js +69 -54
- package/src/react/components/table/DefaultTableCards.js +18 -9
- package/src/react/components/table/DefaultTableControls.js +205 -208
- package/src/react/components/table/DefaultTableFooter.js +10 -1
- package/src/react/components/table/DefaultTableRows.js +360 -333
- package/src/react/components/table/DefaultTableToolbar.js +8 -2
- package/src/react/components/table/useDefaultTableTheme.js +90 -47
- package/src/tests/react/components/table/DefaultTable.test.js +376 -241
- package/src/tests/react/inputs/defaultInputUtils.test.js +80 -9
|
@@ -6,14 +6,18 @@ jest.mock('@store', () => ({
|
|
|
6
6
|
|
|
7
7
|
jest.mock('@controleonline/ui-common/src/utils/formatter.js', () => ({}));
|
|
8
8
|
|
|
9
|
-
jest.mock('@controleonline/ui-common/src/react/utils/storeColumns', () => ({
|
|
10
|
-
formatStoreColumnValue: ({value}) => value,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const {
|
|
9
|
+
jest.mock('@controleonline/ui-common/src/react/utils/storeColumns', () => ({
|
|
10
|
+
formatStoreColumnValue: ({value}) => value?.status || value?.category || value,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const {
|
|
14
|
+
buildReadPresentationStyles,
|
|
15
|
+
mapOptions,
|
|
16
|
+
resolveCellPresentation,
|
|
17
|
+
} = require('../../../react/components/inputs/defaultInputUtils');
|
|
14
18
|
|
|
15
19
|
describe('defaultInputUtils', () => {
|
|
16
|
-
it('deduplicates list options by normalized key', () => {
|
|
20
|
+
it('deduplicates list options by normalized key', () => {
|
|
17
21
|
const column = {
|
|
18
22
|
formatList(item) {
|
|
19
23
|
return {
|
|
@@ -40,6 +44,73 @@ describe('defaultInputUtils', () => {
|
|
|
40
44
|
label: 'Cielo',
|
|
41
45
|
raw: {id: 4579, wallet: 'Cielo'},
|
|
42
46
|
},
|
|
43
|
-
]);
|
|
44
|
-
});
|
|
45
|
-
|
|
47
|
+
]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('preserves option color and icon metadata from formatList', () => {
|
|
51
|
+
const column = {
|
|
52
|
+
formatList(item) {
|
|
53
|
+
return {
|
|
54
|
+
color: item.color,
|
|
55
|
+
icon: item.icon,
|
|
56
|
+
value: item.id,
|
|
57
|
+
label: item.status,
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const options = mapOptions(column, [
|
|
63
|
+
{id: 1, status: 'Em rota', color: '#2563EB', icon: 'truck'},
|
|
64
|
+
]);
|
|
65
|
+
|
|
66
|
+
expect(options).toEqual([
|
|
67
|
+
{
|
|
68
|
+
color: '#2563EB',
|
|
69
|
+
icon: 'truck',
|
|
70
|
+
key: '1',
|
|
71
|
+
label: 'Em rota',
|
|
72
|
+
raw: {id: 1, status: 'Em rota', color: '#2563EB', icon: 'truck'},
|
|
73
|
+
},
|
|
74
|
+
]);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('resolves table cell presentation from row value and column style', () => {
|
|
78
|
+
const presentation = resolveCellPresentation({
|
|
79
|
+
column: {
|
|
80
|
+
name: 'status',
|
|
81
|
+
style: row => ({color: row.status.color}),
|
|
82
|
+
},
|
|
83
|
+
row: {
|
|
84
|
+
status: {
|
|
85
|
+
status: 'Aprovado',
|
|
86
|
+
color: '#16A34A',
|
|
87
|
+
icon: 'check-circle',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
storeName: 'orders',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
expect(presentation).toEqual({
|
|
94
|
+
backgroundColor: undefined,
|
|
95
|
+
borderColor: undefined,
|
|
96
|
+
color: '#16A34A',
|
|
97
|
+
icon: 'check-circle',
|
|
98
|
+
image: undefined,
|
|
99
|
+
label: 'Aprovado',
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('builds subtle badge colors from resource colors', () => {
|
|
104
|
+
expect(buildReadPresentationStyles({
|
|
105
|
+
color: '#16A34A',
|
|
106
|
+
label: 'Aprovado',
|
|
107
|
+
})).toEqual({
|
|
108
|
+
badgeStyle: {
|
|
109
|
+
backgroundColor: 'rgba(22, 163, 74, 0.1)',
|
|
110
|
+
borderColor: 'rgba(22, 163, 74, 0.32)',
|
|
111
|
+
},
|
|
112
|
+
color: '#16A34A',
|
|
113
|
+
hasDecoration: true,
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|