@cdx-ui/data-grid 0.3.10 → 0.3.12
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/README.md +3 -1
- package/coverage.svg +1 -1
- package/lib/commonjs/DataGrid.js +232 -62
- package/lib/commonjs/DataGrid.js.map +1 -1
- package/lib/commonjs/DataGridFilterPanel.js +420 -0
- package/lib/commonjs/DataGridFilterPanel.js.map +1 -0
- package/lib/commonjs/adapter/columnTypes.js +256 -0
- package/lib/commonjs/adapter/columnTypes.js.map +1 -0
- package/lib/commonjs/adapter/columns.js +132 -4
- package/lib/commonjs/adapter/columns.js.map +1 -1
- package/lib/commonjs/adapter/filterOperators.js +422 -0
- package/lib/commonjs/adapter/filterOperators.js.map +1 -0
- package/lib/commonjs/adapter/pinning.js +101 -0
- package/lib/commonjs/adapter/pinning.js.map +1 -0
- package/lib/commonjs/index.js +26 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/numberCells.js +280 -0
- package/lib/commonjs/numberCells.js.map +1 -0
- package/lib/commonjs/styles.js +61 -1
- package/lib/commonjs/styles.js.map +1 -1
- package/lib/commonjs/types.js +29 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/useDataGridTable.js +98 -13
- package/lib/commonjs/useDataGridTable.js.map +1 -1
- package/lib/module/DataGrid.js +237 -67
- package/lib/module/DataGrid.js.map +1 -1
- package/lib/module/DataGridFilterPanel.js +414 -0
- package/lib/module/DataGridFilterPanel.js.map +1 -0
- package/lib/module/adapter/columnTypes.js +240 -0
- package/lib/module/adapter/columnTypes.js.map +1 -0
- package/lib/module/adapter/columns.js +129 -4
- package/lib/module/adapter/columns.js.map +1 -1
- package/lib/module/adapter/filterOperators.js +406 -0
- package/lib/module/adapter/filterOperators.js.map +1 -0
- package/lib/module/adapter/pinning.js +90 -0
- package/lib/module/adapter/pinning.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/numberCells.js +275 -0
- package/lib/module/numberCells.js.map +1 -0
- package/lib/module/styles.js +60 -0
- package/lib/module/styles.js.map +1 -1
- package/lib/module/types.js +28 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/useDataGridTable.js +99 -14
- package/lib/module/useDataGridTable.js.map +1 -1
- package/lib/typescript/DataGrid.d.ts.map +1 -1
- package/lib/typescript/DataGridFilterPanel.d.ts +17 -0
- package/lib/typescript/DataGridFilterPanel.d.ts.map +1 -0
- package/lib/typescript/adapter/columnTypes.d.ts +32 -0
- package/lib/typescript/adapter/columnTypes.d.ts.map +1 -0
- package/lib/typescript/adapter/columns.d.ts +14 -5
- package/lib/typescript/adapter/columns.d.ts.map +1 -1
- package/lib/typescript/adapter/filterOperators.d.ts +43 -0
- package/lib/typescript/adapter/filterOperators.d.ts.map +1 -0
- package/lib/typescript/adapter/pinning.d.ts +25 -0
- package/lib/typescript/adapter/pinning.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +4 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/numberCells.d.ts +46 -0
- package/lib/typescript/numberCells.d.ts.map +1 -0
- package/lib/typescript/styles.d.ts +21 -0
- package/lib/typescript/styles.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +86 -7
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/useDataGridTable.d.ts +18 -4
- package/lib/typescript/useDataGridTable.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/DataGrid.tsx +377 -67
- package/src/DataGridFilterPanel.tsx +477 -0
- package/src/adapter/columnTypes.ts +327 -0
- package/src/adapter/columns.test.ts +75 -1
- package/src/adapter/columns.ts +178 -3
- package/src/adapter/filterOperators.test.ts +292 -0
- package/src/adapter/filterOperators.ts +524 -0
- package/src/adapter/pinning.ts +125 -0
- package/src/index.ts +15 -0
- package/src/numberCells.tsx +379 -0
- package/src/styles.ts +75 -0
- package/src/types.ts +114 -7
- package/src/useDataGridTable.test.ts +69 -0
- package/src/useDataGridTable.ts +127 -8
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { Text } from '@cdx-ui/components';
|
|
5
|
+
import { ArrowDropDown, ArrowDropUp, TrendingDown, TrendingFlat, TrendingUp } from '@cdx-ui/icons';
|
|
6
|
+
import { cn } from '@cdx-ui/utils';
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
+
/** Unicode minus (U+2212). The spec requires this character, not a hyphen. */
|
|
9
|
+
const MINUS = '\u2212';
|
|
10
|
+
const defaultNumberFormat = new Intl.NumberFormat(undefined, {
|
|
11
|
+
maximumFractionDigits: 20
|
|
12
|
+
});
|
|
13
|
+
const TONE_CLASS = {
|
|
14
|
+
success: 'text-content-success',
|
|
15
|
+
danger: 'text-content-danger',
|
|
16
|
+
neutral: 'text-content-primary'
|
|
17
|
+
};
|
|
18
|
+
const ARROW_SLOT = {
|
|
19
|
+
default: 'h-5 w-3.5 items-center justify-center overflow-hidden',
|
|
20
|
+
compact: 'h-4 w-3 items-center justify-center overflow-hidden'
|
|
21
|
+
};
|
|
22
|
+
const ARROW_SIZE = {
|
|
23
|
+
default: 20,
|
|
24
|
+
compact: 16
|
|
25
|
+
};
|
|
26
|
+
const TREND_SIZE = {
|
|
27
|
+
default: 14,
|
|
28
|
+
compact: 12
|
|
29
|
+
};
|
|
30
|
+
function toFiniteNumber(value) {
|
|
31
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
32
|
+
}
|
|
33
|
+
function columnValueFormatter(format) {
|
|
34
|
+
if (!format) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return value => {
|
|
38
|
+
const numeric = toFiniteNumber(value);
|
|
39
|
+
return numeric == null ? '' : format(numeric);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function formatRaw(value, row, col) {
|
|
43
|
+
const formatted = col.valueFormatter?.(value, row, col);
|
|
44
|
+
if (typeof formatted === 'string' && formatted.length > 0) {
|
|
45
|
+
return formatted;
|
|
46
|
+
}
|
|
47
|
+
return defaultNumberFormat.format(value);
|
|
48
|
+
}
|
|
49
|
+
function unsigned(formatted) {
|
|
50
|
+
const withoutSign = formatted.replace(/^[-−+]\s*/, '');
|
|
51
|
+
if (withoutSign.startsWith('(') && withoutSign.endsWith(')')) {
|
|
52
|
+
return withoutSign.slice(1, -1);
|
|
53
|
+
}
|
|
54
|
+
return withoutSign;
|
|
55
|
+
}
|
|
56
|
+
function polarityOf(value) {
|
|
57
|
+
if (value > 0) {
|
|
58
|
+
return 'positive';
|
|
59
|
+
}
|
|
60
|
+
if (value < 0) {
|
|
61
|
+
return 'negative';
|
|
62
|
+
}
|
|
63
|
+
return 'neutral';
|
|
64
|
+
}
|
|
65
|
+
function directionOf(value) {
|
|
66
|
+
if (value > 0) {
|
|
67
|
+
return 'increase';
|
|
68
|
+
}
|
|
69
|
+
if (value < 0) {
|
|
70
|
+
return 'decrease';
|
|
71
|
+
}
|
|
72
|
+
return 'flat';
|
|
73
|
+
}
|
|
74
|
+
function polarityTone(polarity) {
|
|
75
|
+
if (polarity === 'positive') {
|
|
76
|
+
return 'success';
|
|
77
|
+
}
|
|
78
|
+
if (polarity === 'negative') {
|
|
79
|
+
return 'danger';
|
|
80
|
+
}
|
|
81
|
+
return 'neutral';
|
|
82
|
+
}
|
|
83
|
+
function deltaTone(direction, increaseIsGood) {
|
|
84
|
+
if (direction === 'flat') {
|
|
85
|
+
return 'neutral';
|
|
86
|
+
}
|
|
87
|
+
const favorable = direction === 'increase' ? increaseIsGood : !increaseIsGood;
|
|
88
|
+
return favorable ? 'success' : 'danger';
|
|
89
|
+
}
|
|
90
|
+
function polarityLabel(polarity) {
|
|
91
|
+
if (polarity === 'positive') {
|
|
92
|
+
return 'Positive';
|
|
93
|
+
}
|
|
94
|
+
if (polarity === 'negative') {
|
|
95
|
+
return 'Negative';
|
|
96
|
+
}
|
|
97
|
+
return 'Neutral';
|
|
98
|
+
}
|
|
99
|
+
function directionLabel(direction) {
|
|
100
|
+
if (direction === 'increase') {
|
|
101
|
+
return 'Increase';
|
|
102
|
+
}
|
|
103
|
+
if (direction === 'decrease') {
|
|
104
|
+
return 'Decrease';
|
|
105
|
+
}
|
|
106
|
+
return 'No change';
|
|
107
|
+
}
|
|
108
|
+
function NumberReadout({
|
|
109
|
+
label,
|
|
110
|
+
display,
|
|
111
|
+
tone,
|
|
112
|
+
density,
|
|
113
|
+
children
|
|
114
|
+
}) {
|
|
115
|
+
return /*#__PURE__*/_jsxs(View, {
|
|
116
|
+
className: "relative flex-row items-center gap-0.5",
|
|
117
|
+
children: [/*#__PURE__*/_jsx(Text, {
|
|
118
|
+
className: "absolute h-px w-px overflow-hidden opacity-0",
|
|
119
|
+
children: label
|
|
120
|
+
}), /*#__PURE__*/_jsxs(View, {
|
|
121
|
+
"aria-hidden": true,
|
|
122
|
+
accessibilityElementsHidden: true,
|
|
123
|
+
importantForAccessibility: "no-hide-descendants",
|
|
124
|
+
className: "flex-row items-center gap-0.5",
|
|
125
|
+
children: [children, /*#__PURE__*/_jsx(Text, {
|
|
126
|
+
color: tone === 'neutral' ? 'primary' : tone,
|
|
127
|
+
size: density === 'compact' ? 'sm' : 'md',
|
|
128
|
+
children: display
|
|
129
|
+
})]
|
|
130
|
+
})]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function ToneIcon({
|
|
134
|
+
icon: Icon,
|
|
135
|
+
tone,
|
|
136
|
+
size,
|
|
137
|
+
slotClassName
|
|
138
|
+
}) {
|
|
139
|
+
return /*#__PURE__*/_jsx(View, {
|
|
140
|
+
className: cn(TONE_CLASS[tone], slotClassName),
|
|
141
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
142
|
+
size: size
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
function PolarityNumberCell({
|
|
147
|
+
value,
|
|
148
|
+
row,
|
|
149
|
+
col,
|
|
150
|
+
density
|
|
151
|
+
}) {
|
|
152
|
+
const numeric = toFiniteNumber(value);
|
|
153
|
+
if (numeric == null) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const polarity = polarityOf(numeric);
|
|
157
|
+
const magnitude = unsigned(formatRaw(numeric, row, col));
|
|
158
|
+
const display = polarity === 'negative' ? `${MINUS}${magnitude}` : magnitude;
|
|
159
|
+
return /*#__PURE__*/_jsx(NumberReadout, {
|
|
160
|
+
label: `${polarityLabel(polarity)} ${magnitude}`,
|
|
161
|
+
display: display,
|
|
162
|
+
tone: polarityTone(polarity),
|
|
163
|
+
density: density
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function DeltaSymbol({
|
|
167
|
+
direction,
|
|
168
|
+
tone,
|
|
169
|
+
density,
|
|
170
|
+
symbol
|
|
171
|
+
}) {
|
|
172
|
+
if (symbol === 'sign') {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
if (symbol === 'arrow') {
|
|
176
|
+
if (direction === 'flat') {
|
|
177
|
+
return /*#__PURE__*/_jsx(View, {
|
|
178
|
+
className: ARROW_SLOT[density]
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
return /*#__PURE__*/_jsx(ToneIcon, {
|
|
182
|
+
icon: direction === 'increase' ? ArrowDropUp : ArrowDropDown,
|
|
183
|
+
tone: tone,
|
|
184
|
+
size: ARROW_SIZE[density],
|
|
185
|
+
slotClassName: ARROW_SLOT[density]
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
const icon = direction === 'increase' ? TrendingUp : direction === 'decrease' ? TrendingDown : TrendingFlat;
|
|
189
|
+
return /*#__PURE__*/_jsx(ToneIcon, {
|
|
190
|
+
icon: icon,
|
|
191
|
+
tone: tone,
|
|
192
|
+
size: TREND_SIZE[density]
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
function DeltaNumberCell({
|
|
196
|
+
value,
|
|
197
|
+
row,
|
|
198
|
+
col,
|
|
199
|
+
density,
|
|
200
|
+
increaseIsGood,
|
|
201
|
+
symbol
|
|
202
|
+
}) {
|
|
203
|
+
const numeric = toFiniteNumber(value);
|
|
204
|
+
if (numeric == null) {
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
const direction = directionOf(numeric);
|
|
208
|
+
const tone = deltaTone(direction, increaseIsGood);
|
|
209
|
+
const magnitude = unsigned(formatRaw(numeric, row, col));
|
|
210
|
+
let display = magnitude;
|
|
211
|
+
if (symbol === 'sign' && direction === 'increase') {
|
|
212
|
+
display = `+${magnitude}`;
|
|
213
|
+
} else if (symbol === 'sign' && direction === 'decrease') {
|
|
214
|
+
display = `${MINUS}${magnitude}`;
|
|
215
|
+
}
|
|
216
|
+
return /*#__PURE__*/_jsx(NumberReadout, {
|
|
217
|
+
label: `${directionLabel(direction)} ${magnitude}`,
|
|
218
|
+
display: display,
|
|
219
|
+
tone: tone,
|
|
220
|
+
density: density,
|
|
221
|
+
children: /*#__PURE__*/_jsx(DeltaSymbol, {
|
|
222
|
+
direction: direction,
|
|
223
|
+
tone: tone,
|
|
224
|
+
density: density,
|
|
225
|
+
symbol: symbol
|
|
226
|
+
})
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
export function gridPolarityNumberColDef(options = {}) {
|
|
230
|
+
const density = options.density ?? 'default';
|
|
231
|
+
return {
|
|
232
|
+
type: 'number',
|
|
233
|
+
align: 'end',
|
|
234
|
+
headerAlign: 'end',
|
|
235
|
+
...(options.valueFormatter ? {
|
|
236
|
+
valueFormatter: columnValueFormatter(options.valueFormatter)
|
|
237
|
+
} : {}),
|
|
238
|
+
renderCell: ({
|
|
239
|
+
value,
|
|
240
|
+
row,
|
|
241
|
+
col
|
|
242
|
+
}) => /*#__PURE__*/_jsx(PolarityNumberCell, {
|
|
243
|
+
value: value,
|
|
244
|
+
row: row,
|
|
245
|
+
col: col,
|
|
246
|
+
density: density
|
|
247
|
+
})
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export function gridDeltaNumberColDef(options = {}) {
|
|
251
|
+
const density = options.density ?? 'default';
|
|
252
|
+
const increaseIsGood = options.increaseIsGood ?? true;
|
|
253
|
+
const symbol = options.symbol ?? 'arrow';
|
|
254
|
+
return {
|
|
255
|
+
type: 'number',
|
|
256
|
+
align: 'end',
|
|
257
|
+
headerAlign: 'end',
|
|
258
|
+
...(options.valueFormatter ? {
|
|
259
|
+
valueFormatter: columnValueFormatter(options.valueFormatter)
|
|
260
|
+
} : {}),
|
|
261
|
+
renderCell: ({
|
|
262
|
+
value,
|
|
263
|
+
row,
|
|
264
|
+
col
|
|
265
|
+
}) => /*#__PURE__*/_jsx(DeltaNumberCell, {
|
|
266
|
+
value: value,
|
|
267
|
+
row: row,
|
|
268
|
+
col: col,
|
|
269
|
+
density: density,
|
|
270
|
+
increaseIsGood: increaseIsGood,
|
|
271
|
+
symbol: symbol
|
|
272
|
+
})
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=numberCells.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","Text","ArrowDropDown","ArrowDropUp","TrendingDown","TrendingFlat","TrendingUp","cn","jsx","_jsx","jsxs","_jsxs","MINUS","defaultNumberFormat","Intl","NumberFormat","undefined","maximumFractionDigits","TONE_CLASS","success","danger","neutral","ARROW_SLOT","default","compact","ARROW_SIZE","TREND_SIZE","toFiniteNumber","value","Number","isFinite","columnValueFormatter","format","numeric","formatRaw","row","col","formatted","valueFormatter","length","unsigned","withoutSign","replace","startsWith","endsWith","slice","polarityOf","directionOf","polarityTone","polarity","deltaTone","direction","increaseIsGood","favorable","polarityLabel","directionLabel","NumberReadout","label","display","tone","density","children","className","accessibilityElementsHidden","importantForAccessibility","color","size","ToneIcon","icon","Icon","slotClassName","PolarityNumberCell","magnitude","DeltaSymbol","symbol","DeltaNumberCell","gridPolarityNumberColDef","options","type","align","headerAlign","renderCell","gridDeltaNumberColDef"],"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,IAAI,EAAE,QAAQ;IACdC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE,KAAK;IAClB,IAAIH,OAAO,CAACvC,cAAc,GACtB;MAAEA,cAAc,EAAEP,oBAAoB,CAAI8C,OAAO,CAACvC,cAAc;IAAE,CAAC,GACnE,CAAC,CAAC,CAAC;IACP2C,UAAU,EAAEA,CAAC;MAAErD,KAAK;MAAEO,GAAG;MAAEC;IAAI,CAAC,kBAC9B3B,IAAA,CAACkE,eAAe;MACd/C,KAAK,EAAEA,KAAM;MACbO,GAAG,EAAEA,GAAI;MACTC,GAAG,EAAEA,GAAI;MACTwB,OAAO,EAAEA,OAAQ;MACjBR,cAAc,EAAEA,cAAe;MAC/BsB,MAAM,EAAEA;IAAO,CAChB;EAEL,CAAC;AACH","ignoreList":[]}
|
package/lib/module/styles.js
CHANGED
|
@@ -35,6 +35,47 @@ export const dataGridMainVariants = cva('relative min-h-0 w-full min-w-0 max-w-f
|
|
|
35
35
|
overlay: false
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Opaque sticky fill so pinned cells cover scrolled content.
|
|
41
|
+
* Body hover matches the row's 50% secondary tint, mixed over the primary surface
|
|
42
|
+
* so the cell stays opaque while content scrolls underneath.
|
|
43
|
+
*/
|
|
44
|
+
export const dataGridPinnedSurfaceVariants = cva(Platform.select({
|
|
45
|
+
web: 'bg-surface-primary',
|
|
46
|
+
default: ''
|
|
47
|
+
}), {
|
|
48
|
+
variants: {
|
|
49
|
+
header: {
|
|
50
|
+
true: 'bg-neutral-50',
|
|
51
|
+
false: Platform.select({
|
|
52
|
+
web: 'web:[tr:hover_&]:bg-[color-mix(in_srgb,var(--color-surface-secondary)_50%,var(--color-surface-primary))]',
|
|
53
|
+
default: ''
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
defaultVariants: {
|
|
58
|
+
header: false
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export const dataGridPinnedEdgeVariants = cva('', {
|
|
62
|
+
variants: {
|
|
63
|
+
edge: {
|
|
64
|
+
start: Platform.select({
|
|
65
|
+
web: 'border-e border-stroke-secondary',
|
|
66
|
+
default: ''
|
|
67
|
+
}),
|
|
68
|
+
end: Platform.select({
|
|
69
|
+
web: 'border-s border-stroke-secondary',
|
|
70
|
+
default: ''
|
|
71
|
+
}),
|
|
72
|
+
none: ''
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
defaultVariants: {
|
|
76
|
+
edge: 'none'
|
|
77
|
+
}
|
|
78
|
+
});
|
|
38
79
|
export const dataGridToolbarVariants = cva('shrink-0 flex-row items-center gap-3 border-b border-stroke-secondary px-4 py-4');
|
|
39
80
|
export const dataGridToolbarSearchVariants = cva('max-w-80 min-w-0 flex-1');
|
|
40
81
|
export const dataGridToolbarActionsVariants = cva('ms-auto flex-row items-center gap-3');
|
|
@@ -106,6 +147,25 @@ export const dataGridBodyVariants = cva(Platform.select({
|
|
|
106
147
|
default: ''
|
|
107
148
|
}));
|
|
108
149
|
export const dataGridFilterInputVariants = cva('min-w-24');
|
|
150
|
+
export const dataGridFilterPanelVariants = cva('absolute start-4 top-16 z-30 w-max max-w-[calc(100%-2rem)] gap-3 rounded-lg border border-stroke-secondary bg-surface-primary px-3 pb-2 pt-3 shadow-lg');
|
|
151
|
+
|
|
152
|
+
// The panel is as wide as one unwrapped row, capped at the grid's width. Below that, fields wrap
|
|
153
|
+
// onto new lines and grow to fill them, so the layout follows the grid's width, not the viewport.
|
|
154
|
+
export const dataGridFilterPanelRowVariants = cva('flex-row flex-wrap items-end gap-2');
|
|
155
|
+
export const dataGridFilterPanelLogicVariants = cva('min-h-8 w-24 shrink-0 justify-center');
|
|
156
|
+
export const dataGridFilterPanelFieldVariants = cva('min-w-0 shrink grow gap-1', {
|
|
157
|
+
variants: {
|
|
158
|
+
size: {
|
|
159
|
+
column: 'w-40',
|
|
160
|
+
operator: 'w-40',
|
|
161
|
+
value: 'w-56'
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
export const dataGridFilterPanelColumnVariants = cva('w-full');
|
|
166
|
+
export const dataGridFilterPanelOperatorVariants = cva('w-full');
|
|
167
|
+
export const dataGridFilterPanelValueVariants = cva('w-full');
|
|
168
|
+
export const dataGridFilterPanelFooterVariants = cva('flex-row items-center justify-between gap-2 border-t border-stroke-secondary pt-2');
|
|
109
169
|
export const dataGridHeadVariants = cva(['h-12 bg-neutral-50 px-4', Platform.select({
|
|
110
170
|
web: 'border-b border-stroke-secondary',
|
|
111
171
|
default: ''
|
package/lib/module/styles.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","cva","dataGridRootVariants","variants","autoHeight","true","false","defaultVariants","dataGridMainVariants","overlay","compoundVariants","className","dataGridToolbarVariants","dataGridToolbarSearchVariants","dataGridToolbarActionsVariants","dataGridFooterVariants","dataGridOverlayVariants","headerFilters","dataGridEmptyOverlayVariants","dataGridHeaderCellInnerVariants","align","
|
|
1
|
+
{"version":3,"names":["Platform","cva","dataGridRootVariants","variants","autoHeight","true","false","defaultVariants","dataGridMainVariants","overlay","compoundVariants","className","dataGridPinnedSurfaceVariants","select","web","default","header","dataGridPinnedEdgeVariants","edge","start","end","none","dataGridToolbarVariants","dataGridToolbarSearchVariants","dataGridToolbarActionsVariants","dataGridFooterVariants","dataGridOverlayVariants","headerFilters","dataGridEmptyOverlayVariants","dataGridHeaderCellInnerVariants","align","center","fitToColumn","dataGridHeaderLabelVariants","dataGridSortButtonVariants","position","leading","trailing","sorted","dataGridTableVariants","dataGridHeaderVariants","dataGridBodyVariants","dataGridFilterInputVariants","dataGridFilterPanelVariants","dataGridFilterPanelRowVariants","dataGridFilterPanelLogicVariants","dataGridFilterPanelFieldVariants","size","column","operator","value","dataGridFilterPanelColumnVariants","dataGridFilterPanelOperatorVariants","dataGridFilterPanelValueVariants","dataGridFilterPanelFooterVariants","dataGridHeadVariants","dataGridSelectHeadVariants","dataGridCellVariants","dataGridSelectCellVariants","dataGridPaginationVariants","dataGridPaginationRangeVariants"],"sourceRoot":"../../src","sources":["styles.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AACvC,SAASC,GAAG,QAAQ,eAAe;AAEnC,OAAO,MAAMC,oBAAoB,GAAGD,GAAG,CACrC,kHAAkH,EAClH;EACEE,QAAQ,EAAE;IACRC,UAAU,EAAE;MACVC,IAAI,EAAE,EAAE;MACRC,KAAK,EAAE;IACT;EACF,CAAC;EACDC,eAAe,EAAE;IACfH,UAAU,EAAE;EACd;AACF,CACF,CAAC;AAED,OAAO,MAAMI,oBAAoB,GAAGP,GAAG,CACrC,0DAA0D,EAC1D;EACEE,QAAQ,EAAE;IACRC,UAAU,EAAE;MACVC,IAAI,EAAE,WAAW;MACjBC,KAAK,EAAE;IACT,CAAC;IACD;IACAG,OAAO,EAAE;MACPJ,IAAI,EAAE,EAAE;MACRC,KAAK,EAAE;IACT;EACF,CAAC;EACDI,gBAAgB,EAAE,CAAC;IAAEN,UAAU,EAAE,IAAI;IAAEK,OAAO,EAAE,IAAI;IAAEE,SAAS,EAAE;EAAW,CAAC,CAAC;EAC9EJ,eAAe,EAAE;IACfH,UAAU,EAAE,KAAK;IACjBK,OAAO,EAAE;EACX;AACF,CACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,6BAA6B,GAAGX,GAAG,CAC9CD,QAAQ,CAACa,MAAM,CAAC;EACdC,GAAG,EAAE,oBAAoB;EACzBC,OAAO,EAAE;AACX,CAAC,CAAC,EACF;EACEZ,QAAQ,EAAE;IACRa,MAAM,EAAE;MACNX,IAAI,EAAE,eAAe;MACrBC,KAAK,EAAEN,QAAQ,CAACa,MAAM,CAAC;QACrBC,GAAG,EAAE,0GAA0G;QAC/GC,OAAO,EAAE;MACX,CAAC;IACH;EACF,CAAC;EACDR,eAAe,EAAE;IACfS,MAAM,EAAE;EACV;AACF,CACF,CAAC;AA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@@ -1,6 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Filter operators. Names match MUI Data Grid Community so server handlers written for
|
|
5
|
+
* MUI keep working. Which operators a column accepts depends on its `type`.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Columns pinned to the logical start and end edges while the grid scrolls
|
|
10
|
+
* horizontally.
|
|
11
|
+
*
|
|
12
|
+
* `left` and `right` are deprecated compatibility aliases for `start` and `end`
|
|
13
|
+
* (same mapping as `GridColDef.align`).
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** How `filterModel` items combine: every item must match (`'and'`) or any one item (`'or'`). */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Built-in column types. Names and defaults match MUI Data Grid Community.
|
|
20
|
+
* Omit `type` to keep untyped display, alignment, and sort.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A `singleSelect` choice: a primitive (value and label are the same) or an
|
|
25
|
+
* explicit `{ value, label }` pair.
|
|
26
|
+
*/
|
|
27
|
+
|
|
3
28
|
export const SELECT_COLUMN_ID = '__select__';
|
|
29
|
+
|
|
30
|
+
/** MUI X Data Grid checkbox-column field; accepted as an alias for {@link SELECT_COLUMN_ID}. */
|
|
31
|
+
export const MUI_CHECKBOX_FIELD = '__check__';
|
|
4
32
|
export const DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100];
|
|
5
33
|
export const DEFAULT_PAGINATION_MODEL = {
|
|
6
34
|
page: 0,
|
package/lib/module/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SELECT_COLUMN_ID","DEFAULT_PAGE_SIZE_OPTIONS","DEFAULT_PAGINATION_MODEL","page","pageSize","EMPTY_SELECTION","type","ids","Set"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["SELECT_COLUMN_ID","MUI_CHECKBOX_FIELD","DEFAULT_PAGE_SIZE_OPTIONS","DEFAULT_PAGINATION_MODEL","page","pageSize","EMPTY_SELECTION","type","ids","Set"],"sourceRoot":"../../src","sources":["types.ts"],"mappings":";;AA8BA;AACA;AACA;AACA;;AAsCA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;;AAYA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AA+HA,OAAO,MAAMA,gBAAgB,GAAG,YAAY;;AAE5C;AACA,OAAO,MAAMC,kBAAkB,GAAG,WAAW;AAE7C,OAAO,MAAMC,yBAAyB,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,GAAG,CAAU;AAE/D,OAAO,MAAMC,wBAA6C,GAAG;EAC3DC,IAAI,EAAE,CAAC;EACPC,QAAQ,EAAE;AACZ,CAAC;AAED,OAAO,MAAMC,eAAsC,GAAG;EACpDC,IAAI,EAAE,SAAS;EACfC,GAAG,EAAE,IAAIC,GAAG,CAAC;AACf,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
|
-
import { columnFilteringFeature, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_text, tableFeatures, useTable } from '@tanstack/react-table';
|
|
4
|
+
import { columnFilteringFeature, columnPinningFeature, createFilteredRowModel, createPaginatedRowModel, createSortedRowModel, filterFn_includesString, globalFilteringFeature, rowPaginationFeature, rowSelectionFeature, rowSortingFeature, sortFn_alphanumeric, sortFn_text, tableFeatures, useTable } from '@tanstack/react-table';
|
|
5
5
|
import { createSelectColumn } from './adapter/selectColumn';
|
|
6
6
|
import { applyUpdater, gridColDefToColumnDef } from './adapter/columns';
|
|
7
|
+
import { filterFn_displayText, metaUsesDisplayFilter, normalizeFilterQuery, sortFn_boolean, sortFn_datetime, sortFn_number, sortFn_selectLabel, untypedCellIncludesQuery } from './adapter/columnTypes';
|
|
8
|
+
import { filterOperatorNeedsValue, isActiveFilterItem, isBlankFilterValue, isFilterValueGroup, isOperatorFilterValue, rowMatchesFilterItem } from './adapter/filterOperators';
|
|
7
9
|
import { SELECT_COLUMN_ID } from './types';
|
|
10
|
+
function gridGlobalFilterFn(row, columnId, filterValue) {
|
|
11
|
+
if (columnId === SELECT_COLUMN_ID) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const meta = row.getAllCells().find(cell => cell.column.id === columnId)?.column.columnDef.meta;
|
|
15
|
+
if (metaUsesDisplayFilter(meta)) {
|
|
16
|
+
return filterFn_displayText(row, columnId, filterValue);
|
|
17
|
+
}
|
|
18
|
+
return untypedCellIncludesQuery(row.getValue(columnId), normalizeFilterQuery(filterValue));
|
|
19
|
+
}
|
|
8
20
|
const features = tableFeatures({
|
|
9
21
|
columnFilteringFeature,
|
|
22
|
+
columnPinningFeature,
|
|
10
23
|
globalFilteringFeature,
|
|
11
24
|
rowSortingFeature,
|
|
12
25
|
rowPaginationFeature,
|
|
@@ -19,7 +32,11 @@ const features = tableFeatures({
|
|
|
19
32
|
},
|
|
20
33
|
sortFns: {
|
|
21
34
|
alphanumeric: sortFn_alphanumeric,
|
|
22
|
-
text: sortFn_text
|
|
35
|
+
text: sortFn_text,
|
|
36
|
+
number: sortFn_number,
|
|
37
|
+
datetime: sortFn_datetime,
|
|
38
|
+
boolean: sortFn_boolean,
|
|
39
|
+
selectLabel: sortFn_selectLabel
|
|
23
40
|
}
|
|
24
41
|
});
|
|
25
42
|
export function sortModelToSortingState(model) {
|
|
@@ -58,17 +75,60 @@ function columnFilterValueToString(value) {
|
|
|
58
75
|
}
|
|
59
76
|
return '';
|
|
60
77
|
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Items without an `operator` keep today's text filter. Items with one carry the operator and
|
|
81
|
+
* typed operand into the column filter. An item whose operator needs a value but has none is
|
|
82
|
+
* dropped, so `isEmpty` / `isNotEmpty` survive a blank `value` and nothing else does.
|
|
83
|
+
*/
|
|
61
84
|
export function filterModelToColumnFilters(model) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
85
|
+
const valuesByField = new Map();
|
|
86
|
+
for (const item of model) {
|
|
87
|
+
let value;
|
|
88
|
+
if (item.operator !== undefined) {
|
|
89
|
+
if (filterOperatorNeedsValue(item.operator) && isBlankFilterValue(item.value)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
value = {
|
|
93
|
+
operator: item.operator,
|
|
94
|
+
value: item.value
|
|
95
|
+
};
|
|
96
|
+
} else {
|
|
97
|
+
const text = columnFilterValueToString(item.value);
|
|
98
|
+
if (text.trim().length === 0) {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
value = text;
|
|
102
|
+
}
|
|
103
|
+
const values = valuesByField.get(item.field);
|
|
104
|
+
if (values) {
|
|
105
|
+
values.push(value);
|
|
106
|
+
} else {
|
|
107
|
+
valuesByField.set(item.field, [value]);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return [...valuesByField].map(([id, values]) => ({
|
|
111
|
+
id,
|
|
112
|
+
value: values.length === 1 ? values[0] : {
|
|
113
|
+
items: values
|
|
114
|
+
}
|
|
65
115
|
}));
|
|
66
116
|
}
|
|
117
|
+
function columnFilterValueToItem(field, value) {
|
|
118
|
+
if (isOperatorFilterValue(value)) {
|
|
119
|
+
return {
|
|
120
|
+
field,
|
|
121
|
+
operator: value.operator,
|
|
122
|
+
value: value.value
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
field,
|
|
127
|
+
value: columnFilterValueToString(value)
|
|
128
|
+
};
|
|
129
|
+
}
|
|
67
130
|
export function columnFiltersToFilterModel(state) {
|
|
68
|
-
return state.filter(item => item.id !== SELECT_COLUMN_ID).
|
|
69
|
-
field: item.id,
|
|
70
|
-
value: columnFilterValueToString(item.value)
|
|
71
|
-
}));
|
|
131
|
+
return state.filter(item => item.id !== SELECT_COLUMN_ID).flatMap(item => isFilterValueGroup(item.value) ? item.value.items.map(value => columnFilterValueToItem(item.id, value)) : [columnFilterValueToItem(item.id, item.value)]);
|
|
72
132
|
}
|
|
73
133
|
function selectionIdKey(id) {
|
|
74
134
|
return `${typeof id}:${String(id)}`;
|
|
@@ -149,12 +209,30 @@ export function useDataGridTable({
|
|
|
149
209
|
onPaginationModelChange,
|
|
150
210
|
filterModel,
|
|
151
211
|
onFilterModelChange,
|
|
212
|
+
filterLogicOperator,
|
|
152
213
|
quickFilter,
|
|
153
214
|
onQuickFilterChange,
|
|
154
215
|
rowSelectionModel,
|
|
155
|
-
onRowSelectionModelChange
|
|
216
|
+
onRowSelectionModelChange,
|
|
217
|
+
columnPinning
|
|
156
218
|
}) {
|
|
157
|
-
const
|
|
219
|
+
const orFilterItems = useMemo(() => {
|
|
220
|
+
if (filterLogicOperator !== 'or' || filterMode === 'server') {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
const active = filterModel.filter(isActiveFilterItem);
|
|
224
|
+
return active.length > 1 ? active : undefined;
|
|
225
|
+
}, [filterLogicOperator, filterMode, filterModel]);
|
|
226
|
+
const data = useMemo(() => {
|
|
227
|
+
if (!orFilterItems) {
|
|
228
|
+
return [...rows];
|
|
229
|
+
}
|
|
230
|
+
const filterableColumns = new Map(columns.filter(col => col.filterable !== false).map(col => [col.field, col]));
|
|
231
|
+
return rows.filter(row => orFilterItems.some(item => {
|
|
232
|
+
const col = filterableColumns.get(item.field);
|
|
233
|
+
return col !== undefined && rowMatchesFilterItem(col, row, item);
|
|
234
|
+
}));
|
|
235
|
+
}, [columns, orFilterItems, rows]);
|
|
158
236
|
const allIds = useMemo(() => data.map(row => resolveRowId(row, getRowId)), [data, getRowId]);
|
|
159
237
|
const columnDefs = useMemo(() => {
|
|
160
238
|
const mapped = columns.map(col => {
|
|
@@ -168,7 +246,7 @@ export function useDataGridTable({
|
|
|
168
246
|
}, [checkboxSelection, columns, disableColumnSorting]);
|
|
169
247
|
const sortingState = useMemo(() => sortModelToSortingState(sortModel), [sortModel]);
|
|
170
248
|
const paginationState = useMemo(() => paginationModelToState(paginationModel), [paginationModel]);
|
|
171
|
-
const columnFilterState = useMemo(() => filterModelToColumnFilters(filterModel), [filterModel]);
|
|
249
|
+
const columnFilterState = useMemo(() => orFilterItems ? [] : filterModelToColumnFilters(filterModel), [filterModel, orFilterItems]);
|
|
172
250
|
const rowSelectionState = useMemo(() => selectionModelToRowSelection(rowSelectionModel, allIds), [rowSelectionModel, allIds]);
|
|
173
251
|
const resetPaginationPage = () => {
|
|
174
252
|
if (paginationModel.page !== 0) {
|
|
@@ -200,6 +278,7 @@ export function useDataGridTable({
|
|
|
200
278
|
getRowId: row => selectionIdKey(resolveRowId(row, getRowId)),
|
|
201
279
|
enableMultiSort: false,
|
|
202
280
|
enableMultiRowSelection: true,
|
|
281
|
+
globalFilterFn: gridGlobalFilterFn,
|
|
203
282
|
manualPagination: paginationMode === 'server',
|
|
204
283
|
manualSorting: sortingMode === 'server',
|
|
205
284
|
manualFiltering: filterMode === 'server',
|
|
@@ -210,7 +289,8 @@ export function useDataGridTable({
|
|
|
210
289
|
pagination: paginationState,
|
|
211
290
|
columnFilters: columnFilterState,
|
|
212
291
|
globalFilter: quickFilter,
|
|
213
|
-
rowSelection: rowSelectionState
|
|
292
|
+
rowSelection: rowSelectionState,
|
|
293
|
+
columnPinning
|
|
214
294
|
},
|
|
215
295
|
onSortingChange: updater => {
|
|
216
296
|
const next = applyUpdater(updater, sortingState);
|
|
@@ -235,10 +315,15 @@ export function useDataGridTable({
|
|
|
235
315
|
onRowSelectionModelChange(rowSelectionToModel(next, rowSelectionModel, allIds));
|
|
236
316
|
}
|
|
237
317
|
});
|
|
318
|
+
const setFilterModel = model => {
|
|
319
|
+
onFilterModelChange(model);
|
|
320
|
+
resetPaginationPage();
|
|
321
|
+
};
|
|
238
322
|
return {
|
|
239
323
|
table,
|
|
240
324
|
setQuickFilter,
|
|
241
|
-
setColumnFilter
|
|
325
|
+
setColumnFilter,
|
|
326
|
+
setFilterModel
|
|
242
327
|
};
|
|
243
328
|
}
|
|
244
329
|
//# sourceMappingURL=useDataGridTable.js.map
|