@ox0/data-grid 0.0.0-stage → 0.1.0
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/LICENSE +21 -0
- package/README.md +9 -2
- package/dist/components/ColumnChooser.d.ts +21 -0
- package/dist/components/ColumnChooser.d.ts.map +1 -0
- package/dist/components/ColumnChooser.test.d.ts +2 -0
- package/dist/components/ColumnChooser.test.d.ts.map +1 -0
- package/dist/components/DataGrid.d.ts +14 -0
- package/dist/components/DataGrid.d.ts.map +1 -0
- package/dist/components/DataGrid.test.d.ts +2 -0
- package/dist/components/DataGrid.test.d.ts.map +1 -0
- package/dist/components/VirtualScroller.d.ts +42 -0
- package/dist/components/VirtualScroller.d.ts.map +1 -0
- package/dist/components/column-layout.d.ts +31 -0
- package/dist/components/column-layout.d.ts.map +1 -0
- package/dist/components/column-layout.test.d.ts +2 -0
- package/dist/components/column-layout.test.d.ts.map +1 -0
- package/dist/hooks/use-grid.d.ts +32 -0
- package/dist/hooks/use-grid.d.ts.map +1 -0
- package/dist/hooks/use-grid.test.d.ts +2 -0
- package/dist/hooks/use-grid.test.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1861 -0
- package/dist/ingest.d.ts +14 -0
- package/dist/ingest.d.ts.map +1 -0
- package/dist/ingest.test.d.ts +2 -0
- package/dist/ingest.test.d.ts.map +1 -0
- package/dist/store/grid-store.d.ts +43 -0
- package/dist/store/grid-store.d.ts.map +1 -0
- package/dist/store/grid-store.test.d.ts +2 -0
- package/dist/store/grid-store.test.d.ts.map +1 -0
- package/dist/types.d.ts +437 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.test.d.ts +2 -0
- package/dist/types.test.d.ts.map +1 -0
- package/dist/worker/dataset.d.ts +20 -0
- package/dist/worker/dataset.d.ts.map +1 -0
- package/dist/worker/date.d.ts +10 -0
- package/dist/worker/date.d.ts.map +1 -0
- package/dist/worker/date.test.d.ts +2 -0
- package/dist/worker/date.test.d.ts.map +1 -0
- package/dist/worker/filter.d.ts +6 -0
- package/dist/worker/filter.d.ts.map +1 -0
- package/dist/worker/filter.test.d.ts +2 -0
- package/dist/worker/filter.test.d.ts.map +1 -0
- package/dist/worker/resolve-value.d.ts +4 -0
- package/dist/worker/resolve-value.d.ts.map +1 -0
- package/dist/worker/sort.d.ts +8 -0
- package/dist/worker/sort.d.ts.map +1 -0
- package/dist/worker/sort.test.d.ts +2 -0
- package/dist/worker/sort.test.d.ts.map +1 -0
- package/dist/worker/sync-engine.d.ts +9 -0
- package/dist/worker/sync-engine.d.ts.map +1 -0
- package/dist/worker/sync-engine.test.d.ts +2 -0
- package/dist/worker/sync-engine.test.d.ts.map +1 -0
- package/dist/worker/types.d.ts +65 -0
- package/dist/worker/types.d.ts.map +1 -0
- package/package.json +36 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,1861 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useControllableState, useDebouncedValue } from "@ox0/hooks";
|
|
3
|
+
import { Checkbox, Drawer, MarkProvider, Markable, Popover, PopoverContent, PopoverTrigger, SearchField } from "@ox0/ui";
|
|
4
|
+
import { useEffect, useRef, useState, useTransition } from "react";
|
|
5
|
+
import { useStore } from "zustand";
|
|
6
|
+
import { createStore } from "zustand/vanilla";
|
|
7
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
8
|
+
var __webpack_modules__ = {};
|
|
9
|
+
var __webpack_module_cache__ = {};
|
|
10
|
+
function __webpack_require__(moduleId) {
|
|
11
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
12
|
+
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
13
|
+
var module = __webpack_module_cache__[moduleId] = {
|
|
14
|
+
id: moduleId,
|
|
15
|
+
exports: {}
|
|
16
|
+
};
|
|
17
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
|
+
return module.exports;
|
|
19
|
+
}
|
|
20
|
+
__webpack_require__.m = __webpack_modules__;
|
|
21
|
+
(()=>{
|
|
22
|
+
__webpack_require__.n = (module)=>{
|
|
23
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
24
|
+
__webpack_require__.d(getter, {
|
|
25
|
+
a: getter
|
|
26
|
+
});
|
|
27
|
+
return getter;
|
|
28
|
+
};
|
|
29
|
+
})();
|
|
30
|
+
(()=>{
|
|
31
|
+
__webpack_require__.d = (exports, getters, values)=>{
|
|
32
|
+
var define = (defs, kind)=>{
|
|
33
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
[kind]: defs[key]
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
define(getters, "get");
|
|
39
|
+
define(values, "value");
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
(()=>{
|
|
43
|
+
__webpack_require__.add = function(modules) {
|
|
44
|
+
Object.assign(__webpack_require__.m, modules);
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
(()=>{
|
|
48
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
49
|
+
})();
|
|
50
|
+
(()=>{
|
|
51
|
+
__webpack_require__.nc = void 0;
|
|
52
|
+
})();
|
|
53
|
+
__webpack_require__.add({
|
|
54
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[1].oneOf[4].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[1].oneOf[4].use[2]!./src/components/column-chooser.module.css" (module, __webpack_exports__, __webpack_require__) {
|
|
55
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js");
|
|
56
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(_node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0);
|
|
57
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/api.js");
|
|
58
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1_default = /*#__PURE__*/ __webpack_require__.n(_node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1);
|
|
59
|
+
var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1_default()(_node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0_default());
|
|
60
|
+
___CSS_LOADER_EXPORT___.push([
|
|
61
|
+
module.id,
|
|
62
|
+
`.chooser-qS0iYd {
|
|
63
|
+
gap: var(--ox0-space-sm);
|
|
64
|
+
min-width: 220px;
|
|
65
|
+
padding: var(--ox0-space-sm);
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
display: flex;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.section-cM2NE1 {
|
|
71
|
+
gap: var(--ox0-space-xs);
|
|
72
|
+
flex-direction: column;
|
|
73
|
+
display: flex;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.section-cM2NE1 + .section-cM2NE1 {
|
|
77
|
+
border-top: 1px solid var(--ox0-color-border);
|
|
78
|
+
padding-top: var(--ox0-space-xs);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.sectionLabel-rZyK6c {
|
|
82
|
+
color: var(--ox0-color-muted);
|
|
83
|
+
font-size: var(--ox0-font-size-xs);
|
|
84
|
+
font-weight: var(--ox0-font-weight-medium);
|
|
85
|
+
text-transform: uppercase;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.emptySection-XqFgOr {
|
|
89
|
+
border: 1px dashed var(--ox0-color-border);
|
|
90
|
+
border-radius: var(--ox0-radius-sm);
|
|
91
|
+
color: var(--ox0-color-muted);
|
|
92
|
+
font-size: var(--ox0-font-size-xs);
|
|
93
|
+
padding: var(--ox0-space-sm);
|
|
94
|
+
text-align: center;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.row-Jg2ejL {
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: var(--ox0-space-xs);
|
|
100
|
+
display: flex;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.grip-a1Ef9e {
|
|
104
|
+
color: var(--ox0-color-muted);
|
|
105
|
+
cursor: grab;
|
|
106
|
+
padding: var(--ox0-space-xs);
|
|
107
|
+
touch-action: none;
|
|
108
|
+
background: none;
|
|
109
|
+
border: none;
|
|
110
|
+
display: flex;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.grip-a1Ef9e:disabled {
|
|
114
|
+
cursor: not-allowed;
|
|
115
|
+
opacity: .4;
|
|
116
|
+
}
|
|
117
|
+
`,
|
|
118
|
+
""
|
|
119
|
+
]);
|
|
120
|
+
___CSS_LOADER_EXPORT___.locals = {
|
|
121
|
+
chooser: "chooser-qS0iYd",
|
|
122
|
+
section: "section-cM2NE1",
|
|
123
|
+
sectionLabel: "sectionLabel-rZyK6c",
|
|
124
|
+
emptySection: "emptySection-XqFgOr",
|
|
125
|
+
row: "row-Jg2ejL",
|
|
126
|
+
grip: "grip-a1Ef9e"
|
|
127
|
+
};
|
|
128
|
+
const __rspack_default_export = ___CSS_LOADER_EXPORT___;
|
|
129
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
130
|
+
A: __rspack_default_export
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[1].oneOf[4].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[1].oneOf[4].use[2]!./src/components/data-grid.module.css" (module, __webpack_exports__, __webpack_require__) {
|
|
134
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js");
|
|
135
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(_node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0);
|
|
136
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/api.js");
|
|
137
|
+
var _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1_default = /*#__PURE__*/ __webpack_require__.n(_node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1);
|
|
138
|
+
var ___CSS_LOADER_EXPORT___ = _node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_api_js__rspack_import_1_default()(_node_modules_pnpm_rsbuild_core_2_1_13_core_js_3_47_0_node_modules_rsbuild_core_compiled_css_loader_noSourceMaps_js__rspack_import_0_default());
|
|
139
|
+
___CSS_LOADER_EXPORT___.push([
|
|
140
|
+
module.id,
|
|
141
|
+
`.toolbar-Yfzupl {
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: var(--ox0-space-sm);
|
|
144
|
+
margin-bottom: var(--ox0-space-sm);
|
|
145
|
+
display: flex;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.searchInput-kLIczx {
|
|
149
|
+
background: var(--ox0-color-surface);
|
|
150
|
+
border: 1px solid var(--ox0-color-border);
|
|
151
|
+
border-radius: var(--ox0-radius-sm);
|
|
152
|
+
color: inherit;
|
|
153
|
+
font: inherit;
|
|
154
|
+
padding: var(--ox0-space-xs) var(--ox0-space-sm);
|
|
155
|
+
flex: 1;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.columnChooserTrigger-Xg6_us {
|
|
159
|
+
border-radius: var(--ox0-radius-sm);
|
|
160
|
+
color: var(--ox0-color-muted);
|
|
161
|
+
cursor: pointer;
|
|
162
|
+
padding: var(--ox0-space-xs) var(--ox0-space-sm);
|
|
163
|
+
background: none;
|
|
164
|
+
border: 1px solid #0000;
|
|
165
|
+
flex-shrink: 0;
|
|
166
|
+
justify-content: center;
|
|
167
|
+
align-items: center;
|
|
168
|
+
display: flex;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
.columnChooserTrigger-Xg6_us:hover {
|
|
172
|
+
background: var(--ox0-color-surface-hover);
|
|
173
|
+
color: var(--ox0-color-foreground);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.columnChooserPanel-UzdRTT {
|
|
177
|
+
max-height: 400px;
|
|
178
|
+
overflow: auto;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.layout-WlvV4u {
|
|
182
|
+
align-items: stretch;
|
|
183
|
+
gap: var(--ox0-space-md);
|
|
184
|
+
width: 100%;
|
|
185
|
+
height: 100%;
|
|
186
|
+
display: flex;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.viewport-SXETwl {
|
|
190
|
+
border: 1px solid var(--ox0-color-border);
|
|
191
|
+
border-radius: var(--ox0-radius-md);
|
|
192
|
+
flex-direction: column;
|
|
193
|
+
flex: 1;
|
|
194
|
+
min-width: 0;
|
|
195
|
+
min-height: 0;
|
|
196
|
+
transition: opacity .1s;
|
|
197
|
+
display: flex;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.viewport-SXETwl[data-pending] {
|
|
201
|
+
opacity: .6;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.scroller-ooenQP {
|
|
205
|
+
flex: 1;
|
|
206
|
+
min-height: 0;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.headerScroll-qdlbzY {
|
|
210
|
+
overflow: hidden;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.headerRow-CJGPN2, .row-hfdKNj, .selectedRow-qs8lAI {
|
|
214
|
+
display: flex;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.headerRow-CJGPN2 {
|
|
218
|
+
background: var(--ox0-color-surface);
|
|
219
|
+
border-bottom: 1px solid var(--ox0-color-border);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.row-hfdKNj, .selectedRow-qs8lAI {
|
|
223
|
+
background: var(--ox0-color-surface);
|
|
224
|
+
border-bottom: 1px solid var(--ox0-color-border-subtle);
|
|
225
|
+
position: absolute;
|
|
226
|
+
top: 0;
|
|
227
|
+
left: 0;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.selectedRow-qs8lAI {
|
|
231
|
+
background: var(--ox0-color-accent-subtle);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.headerCell-wMAKKp {
|
|
235
|
+
align-items: center;
|
|
236
|
+
gap: var(--ox0-space-xs);
|
|
237
|
+
padding: var(--ox0-space-sm) var(--ox0-space-md);
|
|
238
|
+
text-align: left;
|
|
239
|
+
justify-content: space-between;
|
|
240
|
+
display: flex;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.sortButton-Lww6wI {
|
|
244
|
+
color: inherit;
|
|
245
|
+
cursor: pointer;
|
|
246
|
+
font: inherit;
|
|
247
|
+
font-weight: var(--ox0-font-weight-medium);
|
|
248
|
+
text-overflow: ellipsis;
|
|
249
|
+
white-space: nowrap;
|
|
250
|
+
background: none;
|
|
251
|
+
border: none;
|
|
252
|
+
padding: 0;
|
|
253
|
+
overflow: hidden;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.cell-q3dXM7 {
|
|
257
|
+
padding: 0 var(--ox0-space-md);
|
|
258
|
+
text-overflow: ellipsis;
|
|
259
|
+
white-space: nowrap;
|
|
260
|
+
align-items: center;
|
|
261
|
+
display: flex;
|
|
262
|
+
overflow: hidden;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.emptyCell-gA63FL {
|
|
266
|
+
color: var(--ox0-color-muted);
|
|
267
|
+
padding: var(--ox0-space-lg) var(--ox0-space-md);
|
|
268
|
+
text-align: center;
|
|
269
|
+
}
|
|
270
|
+
`,
|
|
271
|
+
""
|
|
272
|
+
]);
|
|
273
|
+
___CSS_LOADER_EXPORT___.locals = {
|
|
274
|
+
toolbar: "toolbar-Yfzupl",
|
|
275
|
+
searchInput: "searchInput-kLIczx",
|
|
276
|
+
columnChooserTrigger: "columnChooserTrigger-Xg6_us",
|
|
277
|
+
columnChooserPanel: "columnChooserPanel-UzdRTT",
|
|
278
|
+
layout: "layout-WlvV4u",
|
|
279
|
+
viewport: "viewport-SXETwl",
|
|
280
|
+
scroller: "scroller-ooenQP",
|
|
281
|
+
headerScroll: "headerScroll-qdlbzY",
|
|
282
|
+
headerRow: "headerRow-CJGPN2",
|
|
283
|
+
row: "row-hfdKNj",
|
|
284
|
+
selectedRow: "selectedRow-qs8lAI",
|
|
285
|
+
headerCell: "headerCell-wMAKKp",
|
|
286
|
+
sortButton: "sortButton-Lww6wI",
|
|
287
|
+
cell: "cell-q3dXM7",
|
|
288
|
+
emptyCell: "emptyCell-gA63FL"
|
|
289
|
+
};
|
|
290
|
+
const __rspack_default_export = ___CSS_LOADER_EXPORT___;
|
|
291
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
292
|
+
A: __rspack_default_export
|
|
293
|
+
});
|
|
294
|
+
},
|
|
295
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/api.js" (module) {
|
|
296
|
+
module.exports = function(cssWithMappingToString) {
|
|
297
|
+
var list = [];
|
|
298
|
+
list.toString = function() {
|
|
299
|
+
return this.map(function(item) {
|
|
300
|
+
var content = "";
|
|
301
|
+
var needLayer = void 0 !== item[5];
|
|
302
|
+
if (item[4]) content += "@supports (".concat(item[4], ") {");
|
|
303
|
+
if (item[2]) content += "@media ".concat(item[2], " {");
|
|
304
|
+
if (needLayer) content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
|
|
305
|
+
content += cssWithMappingToString(item);
|
|
306
|
+
if (needLayer) content += "}";
|
|
307
|
+
if (item[2]) content += "}";
|
|
308
|
+
if (item[4]) content += "}";
|
|
309
|
+
return content;
|
|
310
|
+
}).join("");
|
|
311
|
+
};
|
|
312
|
+
list.i = function(modules, media, dedupe, supports, layer) {
|
|
313
|
+
if ("string" == typeof modules) modules = [
|
|
314
|
+
[
|
|
315
|
+
null,
|
|
316
|
+
modules,
|
|
317
|
+
void 0
|
|
318
|
+
]
|
|
319
|
+
];
|
|
320
|
+
var alreadyImportedModules = {};
|
|
321
|
+
if (dedupe) for(var k = 0; k < this.length; k++){
|
|
322
|
+
var id = this[k][0];
|
|
323
|
+
if (null != id) alreadyImportedModules[id] = true;
|
|
324
|
+
}
|
|
325
|
+
for(var _k = 0; _k < modules.length; _k++){
|
|
326
|
+
var item = [].concat(modules[_k]);
|
|
327
|
+
if (!dedupe || !alreadyImportedModules[item[0]]) {
|
|
328
|
+
if (void 0 !== layer) if (void 0 === item[5]) item[5] = layer;
|
|
329
|
+
else {
|
|
330
|
+
item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
|
|
331
|
+
item[5] = layer;
|
|
332
|
+
}
|
|
333
|
+
if (media) if (item[2]) {
|
|
334
|
+
item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
|
|
335
|
+
item[2] = media;
|
|
336
|
+
} else item[2] = media;
|
|
337
|
+
if (supports) if (item[4]) {
|
|
338
|
+
item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
|
|
339
|
+
item[4] = supports;
|
|
340
|
+
} else item[4] = "".concat(supports);
|
|
341
|
+
list.push(item);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
return list;
|
|
346
|
+
};
|
|
347
|
+
},
|
|
348
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/noSourceMaps.js" (module) {
|
|
349
|
+
module.exports = function(i) {
|
|
350
|
+
return i[1];
|
|
351
|
+
};
|
|
352
|
+
},
|
|
353
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/injectStylesIntoStyleTag.js" (module) {
|
|
354
|
+
var stylesInDOM = [];
|
|
355
|
+
function getIndexByIdentifier(identifier) {
|
|
356
|
+
var result = -1;
|
|
357
|
+
for(var i = 0; i < stylesInDOM.length; i++)if (stylesInDOM[i].identifier === identifier) {
|
|
358
|
+
result = i;
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
return result;
|
|
362
|
+
}
|
|
363
|
+
function modulesToDom(list, options) {
|
|
364
|
+
var idCountMap = {};
|
|
365
|
+
var identifiers = [];
|
|
366
|
+
for(var i = 0; i < list.length; i++){
|
|
367
|
+
var item = list[i];
|
|
368
|
+
var id = options.base ? item[0] + options.base : item[0];
|
|
369
|
+
var count = idCountMap[id] || 0;
|
|
370
|
+
var identifier = "".concat(id, " ").concat(count);
|
|
371
|
+
idCountMap[id] = count + 1;
|
|
372
|
+
var indexByIdentifier = getIndexByIdentifier(identifier);
|
|
373
|
+
var obj = {
|
|
374
|
+
css: item[1],
|
|
375
|
+
media: item[2],
|
|
376
|
+
sourceMap: item[3],
|
|
377
|
+
supports: item[4],
|
|
378
|
+
layer: item[5]
|
|
379
|
+
};
|
|
380
|
+
if (-1 !== indexByIdentifier) {
|
|
381
|
+
stylesInDOM[indexByIdentifier].references++;
|
|
382
|
+
stylesInDOM[indexByIdentifier].updater(obj);
|
|
383
|
+
} else {
|
|
384
|
+
var updater = addElementStyle(obj, options);
|
|
385
|
+
options.byIndex = i;
|
|
386
|
+
stylesInDOM.splice(i, 0, {
|
|
387
|
+
identifier: identifier,
|
|
388
|
+
updater: updater,
|
|
389
|
+
references: 1
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
identifiers.push(identifier);
|
|
393
|
+
}
|
|
394
|
+
return identifiers;
|
|
395
|
+
}
|
|
396
|
+
function addElementStyle(obj, options) {
|
|
397
|
+
var api = options.domAPI(options);
|
|
398
|
+
api.update(obj);
|
|
399
|
+
var updater = function(newObj) {
|
|
400
|
+
if (newObj) {
|
|
401
|
+
if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) return;
|
|
402
|
+
api.update(obj = newObj);
|
|
403
|
+
} else api.remove();
|
|
404
|
+
};
|
|
405
|
+
return updater;
|
|
406
|
+
}
|
|
407
|
+
module.exports = function(list, options) {
|
|
408
|
+
options = options || {};
|
|
409
|
+
list = list || [];
|
|
410
|
+
var lastIdentifiers = modulesToDom(list, options);
|
|
411
|
+
return function(newList) {
|
|
412
|
+
newList = newList || [];
|
|
413
|
+
for(var i = 0; i < lastIdentifiers.length; i++){
|
|
414
|
+
var identifier = lastIdentifiers[i];
|
|
415
|
+
var index = getIndexByIdentifier(identifier);
|
|
416
|
+
stylesInDOM[index].references--;
|
|
417
|
+
}
|
|
418
|
+
var newLastIdentifiers = modulesToDom(newList, options);
|
|
419
|
+
for(var _i = 0; _i < lastIdentifiers.length; _i++){
|
|
420
|
+
var _identifier = lastIdentifiers[_i];
|
|
421
|
+
var _index = getIndexByIdentifier(_identifier);
|
|
422
|
+
if (0 === stylesInDOM[_index].references) {
|
|
423
|
+
stylesInDOM[_index].updater();
|
|
424
|
+
stylesInDOM.splice(_index, 1);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
lastIdentifiers = newLastIdentifiers;
|
|
428
|
+
};
|
|
429
|
+
};
|
|
430
|
+
},
|
|
431
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/insertBySelector.js" (module) {
|
|
432
|
+
var memo = {};
|
|
433
|
+
function getTarget(target) {
|
|
434
|
+
if (void 0 === memo[target]) {
|
|
435
|
+
var styleTarget = document.querySelector(target);
|
|
436
|
+
if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) try {
|
|
437
|
+
styleTarget = styleTarget.contentDocument.head;
|
|
438
|
+
} catch (e) {
|
|
439
|
+
styleTarget = null;
|
|
440
|
+
}
|
|
441
|
+
memo[target] = styleTarget;
|
|
442
|
+
}
|
|
443
|
+
return memo[target];
|
|
444
|
+
}
|
|
445
|
+
function insertBySelector(insert, style) {
|
|
446
|
+
var target = getTarget(insert);
|
|
447
|
+
if (!target) throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
|
|
448
|
+
target.appendChild(style);
|
|
449
|
+
}
|
|
450
|
+
module.exports = insertBySelector;
|
|
451
|
+
},
|
|
452
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/insertStyleElement.js" (module) {
|
|
453
|
+
function insertStyleElement(options) {
|
|
454
|
+
var element = document.createElement("style");
|
|
455
|
+
options.setAttributes(element, options.attributes);
|
|
456
|
+
options.insert(element, options.options);
|
|
457
|
+
return element;
|
|
458
|
+
}
|
|
459
|
+
module.exports = insertStyleElement;
|
|
460
|
+
},
|
|
461
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/setAttributesWithoutAttributes.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
462
|
+
function setAttributesWithoutAttributes(styleElement) {
|
|
463
|
+
var nonce = __webpack_require__.nc;
|
|
464
|
+
if (nonce) styleElement.setAttribute("nonce", nonce);
|
|
465
|
+
}
|
|
466
|
+
module.exports = setAttributesWithoutAttributes;
|
|
467
|
+
},
|
|
468
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/styleDomAPI.js" (module) {
|
|
469
|
+
function apply(styleElement, options, obj) {
|
|
470
|
+
var css = "";
|
|
471
|
+
if (obj.supports) css += "@supports (".concat(obj.supports, ") {");
|
|
472
|
+
if (obj.media) css += "@media ".concat(obj.media, " {");
|
|
473
|
+
var needLayer = void 0 !== obj.layer;
|
|
474
|
+
if (needLayer) css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
|
|
475
|
+
css += obj.css;
|
|
476
|
+
if (needLayer) css += "}";
|
|
477
|
+
if (obj.media) css += "}";
|
|
478
|
+
if (obj.supports) css += "}";
|
|
479
|
+
var sourceMap = obj.sourceMap;
|
|
480
|
+
if (sourceMap && "u" > typeof btoa) css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
|
|
481
|
+
options.styleTagTransform(css, styleElement, options.options);
|
|
482
|
+
}
|
|
483
|
+
function removeStyleElement(styleElement) {
|
|
484
|
+
if (null === styleElement.parentNode) return false;
|
|
485
|
+
styleElement.parentNode.removeChild(styleElement);
|
|
486
|
+
}
|
|
487
|
+
function domAPI(options) {
|
|
488
|
+
if ("u" < typeof document) return {
|
|
489
|
+
update: function() {},
|
|
490
|
+
remove: function() {}
|
|
491
|
+
};
|
|
492
|
+
var styleElement = options.insertStyleElement(options);
|
|
493
|
+
return {
|
|
494
|
+
update: function(obj) {
|
|
495
|
+
apply(styleElement, options, obj);
|
|
496
|
+
},
|
|
497
|
+
remove: function() {
|
|
498
|
+
removeStyleElement(styleElement);
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
module.exports = domAPI;
|
|
503
|
+
},
|
|
504
|
+
"../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/styleTagTransform.js" (module) {
|
|
505
|
+
function styleTagTransform(css, styleElement) {
|
|
506
|
+
if (styleElement.styleSheet) styleElement.styleSheet.cssText = css;
|
|
507
|
+
else {
|
|
508
|
+
while(styleElement.firstChild)styleElement.removeChild(styleElement.firstChild);
|
|
509
|
+
styleElement.appendChild(document.createTextNode(css));
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
module.exports = styleTagTransform;
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
function isDerivedColumnDef(column) {
|
|
516
|
+
return "function" == typeof column.accessorFn;
|
|
517
|
+
}
|
|
518
|
+
function materializeRows(rows, columnDefs, getRowId) {
|
|
519
|
+
const derivedColumns = columnDefs.filter(isDerivedColumnDef);
|
|
520
|
+
const seenRowIds = new Set();
|
|
521
|
+
const materialized = [];
|
|
522
|
+
const duplicateRowIds = [];
|
|
523
|
+
for (const row of rows){
|
|
524
|
+
const rowId = getRowId(row);
|
|
525
|
+
if (seenRowIds.has(rowId)) {
|
|
526
|
+
duplicateRowIds.push(rowId);
|
|
527
|
+
continue;
|
|
528
|
+
}
|
|
529
|
+
seenRowIds.add(rowId);
|
|
530
|
+
const derived = {};
|
|
531
|
+
for (const column of derivedColumns)derived[`__derived_${column.id}`] = column.accessorFn(row);
|
|
532
|
+
materialized.push(Object.assign({}, row, {
|
|
533
|
+
__rowId: rowId
|
|
534
|
+
}, derived));
|
|
535
|
+
}
|
|
536
|
+
if (duplicateRowIds.length > 0 && "production" !== process.env.NODE_ENV) console.warn(`[@ox0/data-grid] getRowId returned a duplicate id for ${duplicateRowIds.length} row(s): ${duplicateRowIds.join(", ")}. Keeping the first occurrence of each; later rows with the same id were dropped.`);
|
|
537
|
+
return {
|
|
538
|
+
rows: materialized,
|
|
539
|
+
duplicateRowIds
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function toggleSelectionKey(selection, key) {
|
|
543
|
+
if ("include" === selection.mode) {
|
|
544
|
+
const keys = new Set(selection.keys);
|
|
545
|
+
if (keys.has(key)) keys.delete(key);
|
|
546
|
+
else keys.add(key);
|
|
547
|
+
return {
|
|
548
|
+
mode: "include",
|
|
549
|
+
keys
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
const excluded = new Set(selection.excluded);
|
|
553
|
+
if (excluded.has(key)) excluded.delete(key);
|
|
554
|
+
else excluded.add(key);
|
|
555
|
+
return {
|
|
556
|
+
mode: "all-except",
|
|
557
|
+
excluded
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
function createGridStore(init) {
|
|
561
|
+
return createStore()((set)=>({
|
|
562
|
+
columns: init.columns,
|
|
563
|
+
setColumnWidth: (id, width)=>{
|
|
564
|
+
set((state)=>({
|
|
565
|
+
columns: state.columns.map((c)=>c.id === id ? {
|
|
566
|
+
...c,
|
|
567
|
+
width
|
|
568
|
+
} : c)
|
|
569
|
+
}));
|
|
570
|
+
},
|
|
571
|
+
setColumnOrder: (ids)=>{
|
|
572
|
+
set((state)=>{
|
|
573
|
+
const byId = new Map(state.columns.map((c)=>[
|
|
574
|
+
c.id,
|
|
575
|
+
c
|
|
576
|
+
]));
|
|
577
|
+
const reordered = ids.map((id)=>byId.get(id)).filter((c)=>void 0 !== c);
|
|
578
|
+
return {
|
|
579
|
+
columns: reordered
|
|
580
|
+
};
|
|
581
|
+
});
|
|
582
|
+
},
|
|
583
|
+
setColumnVisible: (id, visible)=>{
|
|
584
|
+
set((state)=>({
|
|
585
|
+
columns: state.columns.map((c)=>c.id === id ? {
|
|
586
|
+
...c,
|
|
587
|
+
visible
|
|
588
|
+
} : c)
|
|
589
|
+
}));
|
|
590
|
+
},
|
|
591
|
+
setColumnPin: (id, side)=>{
|
|
592
|
+
set((state)=>({
|
|
593
|
+
columns: state.columns.map((c)=>c.id === id ? {
|
|
594
|
+
...c,
|
|
595
|
+
pinned: side
|
|
596
|
+
} : c)
|
|
597
|
+
}));
|
|
598
|
+
},
|
|
599
|
+
reorderColumns: (order)=>{
|
|
600
|
+
set((state)=>{
|
|
601
|
+
const byId = new Map(state.columns.map((c)=>[
|
|
602
|
+
c.id,
|
|
603
|
+
c
|
|
604
|
+
]));
|
|
605
|
+
const mentioned = new Set(order.map((entry)=>entry.id));
|
|
606
|
+
const next = order.map(({ id, pinned })=>{
|
|
607
|
+
const existing = byId.get(id);
|
|
608
|
+
return existing ? {
|
|
609
|
+
...existing,
|
|
610
|
+
pinned
|
|
611
|
+
} : null;
|
|
612
|
+
}).filter((c)=>null !== c);
|
|
613
|
+
const omitted = state.columns.filter((c)=>!mentioned.has(c.id));
|
|
614
|
+
return {
|
|
615
|
+
columns: [
|
|
616
|
+
...next,
|
|
617
|
+
...omitted
|
|
618
|
+
]
|
|
619
|
+
};
|
|
620
|
+
});
|
|
621
|
+
},
|
|
622
|
+
sort: init.initialSort ?? [],
|
|
623
|
+
maxSortColumns: init.maxSortColumns ?? 3,
|
|
624
|
+
cycleSort: (columnId)=>{
|
|
625
|
+
set((state)=>{
|
|
626
|
+
const [primary] = state.sort;
|
|
627
|
+
if (primary?.columnId === columnId) {
|
|
628
|
+
const toggled = [
|
|
629
|
+
...state.sort
|
|
630
|
+
];
|
|
631
|
+
toggled[0] = {
|
|
632
|
+
columnId,
|
|
633
|
+
direction: "asc" === primary.direction ? "desc" : "asc"
|
|
634
|
+
};
|
|
635
|
+
return {
|
|
636
|
+
sort: toggled
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
const rest = state.sort.filter((entry)=>entry.columnId !== columnId);
|
|
640
|
+
const next = [
|
|
641
|
+
{
|
|
642
|
+
columnId,
|
|
643
|
+
direction: "asc"
|
|
644
|
+
},
|
|
645
|
+
...rest
|
|
646
|
+
];
|
|
647
|
+
return {
|
|
648
|
+
sort: next.slice(0, state.maxSortColumns)
|
|
649
|
+
};
|
|
650
|
+
});
|
|
651
|
+
},
|
|
652
|
+
removeSort: (columnId)=>{
|
|
653
|
+
set((state)=>({
|
|
654
|
+
sort: state.sort.filter((entry)=>entry.columnId !== columnId)
|
|
655
|
+
}));
|
|
656
|
+
},
|
|
657
|
+
clearSort: ()=>{
|
|
658
|
+
set({
|
|
659
|
+
sort: []
|
|
660
|
+
});
|
|
661
|
+
},
|
|
662
|
+
filterTokens: init.initialFilterTokens ?? [],
|
|
663
|
+
setFilterTokens: (tokens)=>{
|
|
664
|
+
set({
|
|
665
|
+
filterTokens: tokens
|
|
666
|
+
});
|
|
667
|
+
},
|
|
668
|
+
selectionMode: init.selectionMode ?? null,
|
|
669
|
+
selectedRowId: null,
|
|
670
|
+
setSelectedRowId: (id)=>{
|
|
671
|
+
set({
|
|
672
|
+
selectedRowId: id
|
|
673
|
+
});
|
|
674
|
+
},
|
|
675
|
+
selection: {
|
|
676
|
+
mode: "include",
|
|
677
|
+
keys: new Set()
|
|
678
|
+
},
|
|
679
|
+
toggleRow: (key)=>{
|
|
680
|
+
set((state)=>({
|
|
681
|
+
selection: toggleSelectionKey(state.selection, key)
|
|
682
|
+
}));
|
|
683
|
+
},
|
|
684
|
+
selectExplicitKeys: (keys)=>{
|
|
685
|
+
set({
|
|
686
|
+
selection: {
|
|
687
|
+
mode: "include",
|
|
688
|
+
keys: new Set(keys)
|
|
689
|
+
}
|
|
690
|
+
});
|
|
691
|
+
},
|
|
692
|
+
selectAllExcept: ()=>{
|
|
693
|
+
set({
|
|
694
|
+
selection: {
|
|
695
|
+
mode: "all-except",
|
|
696
|
+
excluded: new Set()
|
|
697
|
+
}
|
|
698
|
+
});
|
|
699
|
+
},
|
|
700
|
+
clearSelection: ()=>{
|
|
701
|
+
set({
|
|
702
|
+
selectedRowId: null,
|
|
703
|
+
selection: {
|
|
704
|
+
mode: "include",
|
|
705
|
+
keys: new Set()
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
},
|
|
709
|
+
totalCount: -1,
|
|
710
|
+
setTotalCount: (n)=>{
|
|
711
|
+
set({
|
|
712
|
+
totalCount: n
|
|
713
|
+
});
|
|
714
|
+
},
|
|
715
|
+
density: init.initialDensity ?? "comfortable",
|
|
716
|
+
setDensity: (density)=>{
|
|
717
|
+
set({
|
|
718
|
+
density
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
}));
|
|
722
|
+
}
|
|
723
|
+
const dayFormatters = new Map();
|
|
724
|
+
function getDayFormatter(timeZone) {
|
|
725
|
+
let formatter = dayFormatters.get(timeZone);
|
|
726
|
+
if (!formatter) {
|
|
727
|
+
formatter = new Intl.DateTimeFormat("en-CA", {
|
|
728
|
+
timeZone,
|
|
729
|
+
year: "numeric",
|
|
730
|
+
month: "2-digit",
|
|
731
|
+
day: "2-digit"
|
|
732
|
+
});
|
|
733
|
+
dayFormatters.set(timeZone, formatter);
|
|
734
|
+
}
|
|
735
|
+
return formatter;
|
|
736
|
+
}
|
|
737
|
+
function toCalendarDay(value, timeZone) {
|
|
738
|
+
if ("string" == typeof value && /^\d{4}-\d{2}-\d{2}$/.test(value)) return value;
|
|
739
|
+
const date = new Date(value);
|
|
740
|
+
if (Number.isNaN(date.getTime())) return null;
|
|
741
|
+
return getDayFormatter(timeZone).format(date);
|
|
742
|
+
}
|
|
743
|
+
function shiftDay(day, amount, unit) {
|
|
744
|
+
const [year, month, date] = day.split("-").map(Number);
|
|
745
|
+
const shifted = new Date(Date.UTC(year, month - 1, date));
|
|
746
|
+
if ("d" === unit) shifted.setUTCDate(shifted.getUTCDate() + amount);
|
|
747
|
+
else if ("w" === unit) shifted.setUTCDate(shifted.getUTCDate() + 7 * amount);
|
|
748
|
+
else if ("m" === unit) shifted.setUTCMonth(shifted.getUTCMonth() + amount);
|
|
749
|
+
else shifted.setUTCFullYear(shifted.getUTCFullYear() + amount);
|
|
750
|
+
return shifted.toISOString().slice(0, 10);
|
|
751
|
+
}
|
|
752
|
+
function resolveValue(row, column) {
|
|
753
|
+
return Reflect.get(row, column.valueSource.key);
|
|
754
|
+
}
|
|
755
|
+
function evaluateTextColumn(token, value) {
|
|
756
|
+
if (null == value) return false;
|
|
757
|
+
const stringValue = String(value);
|
|
758
|
+
switch(token.operator){
|
|
759
|
+
case "contains":
|
|
760
|
+
return stringValue.toLowerCase().includes(token.value.toLowerCase());
|
|
761
|
+
case "not-contains":
|
|
762
|
+
return !stringValue.toLowerCase().includes(token.value.toLowerCase());
|
|
763
|
+
case "equals":
|
|
764
|
+
return stringValue === token.value;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function evaluateNumericColumn(token, value) {
|
|
768
|
+
const n = Number(value);
|
|
769
|
+
if (null == value || !Number.isFinite(n)) return false;
|
|
770
|
+
if ("between" === token.operator) {
|
|
771
|
+
if (void 0 !== token.value && n < token.value) return false;
|
|
772
|
+
if (void 0 !== token.valueTo && n > token.valueTo) return false;
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
if (void 0 === token.value) return false;
|
|
776
|
+
const target = token.value;
|
|
777
|
+
switch(token.operator){
|
|
778
|
+
case "eq":
|
|
779
|
+
return n === target;
|
|
780
|
+
case "gt":
|
|
781
|
+
return n > target;
|
|
782
|
+
case "gte":
|
|
783
|
+
return n >= target;
|
|
784
|
+
case "lt":
|
|
785
|
+
return n < target;
|
|
786
|
+
case "lte":
|
|
787
|
+
return n <= target;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
function evaluateDateColumn(token, value, timeZone, evalNow) {
|
|
791
|
+
if (null == value || "string" != typeof value && "number" != typeof value) return false;
|
|
792
|
+
const day = toCalendarDay(value, timeZone);
|
|
793
|
+
if (null === day) return false;
|
|
794
|
+
switch(token.operator){
|
|
795
|
+
case "on":
|
|
796
|
+
return void 0 !== token.value && day === token.value;
|
|
797
|
+
case "before":
|
|
798
|
+
return void 0 !== token.value && day < token.value;
|
|
799
|
+
case "after":
|
|
800
|
+
return void 0 !== token.value && day > token.value;
|
|
801
|
+
case "between":
|
|
802
|
+
{
|
|
803
|
+
const lower = token.openStart ? null : token.value ?? null;
|
|
804
|
+
const upper = token.openEnd ? evalNow : token.valueTo ?? null;
|
|
805
|
+
if (null !== lower && day < lower) return false;
|
|
806
|
+
if (null !== upper && day > upper) return false;
|
|
807
|
+
return true;
|
|
808
|
+
}
|
|
809
|
+
case "within-last":
|
|
810
|
+
{
|
|
811
|
+
if (void 0 === token.value || void 0 === token.unit) return false;
|
|
812
|
+
const lower = shiftDay(evalNow, -Number(token.value), token.unit);
|
|
813
|
+
return day >= lower && day <= evalNow;
|
|
814
|
+
}
|
|
815
|
+
case "within-next":
|
|
816
|
+
{
|
|
817
|
+
if (void 0 === token.value || void 0 === token.unit) return false;
|
|
818
|
+
const upper = shiftDay(evalNow, Number(token.value), token.unit);
|
|
819
|
+
return day >= evalNow && day <= upper;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
function evaluateEnumColumn(token, value) {
|
|
824
|
+
if (null == value) return false;
|
|
825
|
+
const stringValue = String(value).toLowerCase();
|
|
826
|
+
const values = token.values.map((v)=>v.toLowerCase());
|
|
827
|
+
const isMember = values.includes(stringValue);
|
|
828
|
+
return "in" === token.operator ? isMember : !isMember;
|
|
829
|
+
}
|
|
830
|
+
function matchesFreeText(row, term, searchableColumns) {
|
|
831
|
+
const lowerTerm = term.toLowerCase();
|
|
832
|
+
return searchableColumns.some((column)=>{
|
|
833
|
+
const value = resolveValue(row, column);
|
|
834
|
+
return null != value && String(value).toLowerCase().includes(lowerTerm);
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
function evaluateToken(row, token, columnsById, searchableColumns, timeZone, evalNow) {
|
|
838
|
+
if ("text" === token.type) {
|
|
839
|
+
const matches = matchesFreeText(row, token.term, searchableColumns);
|
|
840
|
+
return token.negated ? !matches : matches;
|
|
841
|
+
}
|
|
842
|
+
const column = columnsById.get(token.columnId);
|
|
843
|
+
if (!column) return false;
|
|
844
|
+
const value = resolveValue(row, column);
|
|
845
|
+
switch(token.dataType){
|
|
846
|
+
case "text":
|
|
847
|
+
return evaluateTextColumn(token, value);
|
|
848
|
+
case "numeric":
|
|
849
|
+
return evaluateNumericColumn(token, value);
|
|
850
|
+
case "date":
|
|
851
|
+
return evaluateDateColumn(token, value, timeZone, evalNow);
|
|
852
|
+
case "enum":
|
|
853
|
+
return evaluateEnumColumn(token, value);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
function evaluateTokens(row, tokens, columnsById, timeZone, evalNow) {
|
|
857
|
+
const searchableColumns = [
|
|
858
|
+
...columnsById.values()
|
|
859
|
+
].filter((c)=>c.searchable);
|
|
860
|
+
return tokens.every((token)=>evaluateToken(row, token, columnsById, searchableColumns, timeZone, evalNow));
|
|
861
|
+
}
|
|
862
|
+
function toSortKey(value, dataType) {
|
|
863
|
+
if (null == value) return null;
|
|
864
|
+
switch(dataType){
|
|
865
|
+
case "numeric":
|
|
866
|
+
{
|
|
867
|
+
const n = Number(value);
|
|
868
|
+
return Number.isFinite(n) ? n : null;
|
|
869
|
+
}
|
|
870
|
+
case "date":
|
|
871
|
+
{
|
|
872
|
+
const t = "number" == typeof value ? value : Date.parse(String(value));
|
|
873
|
+
return Number.isFinite(t) ? t : null;
|
|
874
|
+
}
|
|
875
|
+
case "text":
|
|
876
|
+
case "enum":
|
|
877
|
+
return String(value);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
function compareNullish(a, b) {
|
|
881
|
+
if (null === a && null === b) return 0;
|
|
882
|
+
if (null === a) return 1;
|
|
883
|
+
if (null === b) return -1;
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
function compareKeys(a, b) {
|
|
887
|
+
if ("number" == typeof a && "number" == typeof b) return a - b;
|
|
888
|
+
return String(a).localeCompare(String(b));
|
|
889
|
+
}
|
|
890
|
+
function sortIndices(rows, sort, columnsById) {
|
|
891
|
+
const indices = rows.map((_, index)=>index);
|
|
892
|
+
if (0 === sort.length) return indices;
|
|
893
|
+
const keys = sort.map((entry)=>{
|
|
894
|
+
const column = columnsById.get(entry.columnId);
|
|
895
|
+
return {
|
|
896
|
+
direction: entry.direction,
|
|
897
|
+
values: rows.map((row)=>column ? toSortKey(resolveValue(row, column), column.dataType) : null)
|
|
898
|
+
};
|
|
899
|
+
});
|
|
900
|
+
return indices.toSorted((a, b)=>{
|
|
901
|
+
for (const key of keys){
|
|
902
|
+
const nullCmp = compareNullish(key.values[a], key.values[b]);
|
|
903
|
+
if (null !== nullCmp) {
|
|
904
|
+
if (0 !== nullCmp) return nullCmp;
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
const cmp = compareKeys(key.values[a], key.values[b]);
|
|
908
|
+
if (0 !== cmp) return "asc" === key.direction ? cmp : -cmp;
|
|
909
|
+
}
|
|
910
|
+
return 0;
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
function createDataset() {
|
|
914
|
+
let columnsById = new Map();
|
|
915
|
+
let timeZone = "UTC";
|
|
916
|
+
let rows = [];
|
|
917
|
+
let sortEntries = [];
|
|
918
|
+
let filterTokens = [];
|
|
919
|
+
let evalNow = "";
|
|
920
|
+
let sortedIndices = [];
|
|
921
|
+
let filteredIndices = [];
|
|
922
|
+
function recomputeSort() {
|
|
923
|
+
sortedIndices = sortIndices(rows, sortEntries, columnsById);
|
|
924
|
+
}
|
|
925
|
+
function recomputeFilter() {
|
|
926
|
+
filteredIndices = 0 === filterTokens.length ? sortedIndices : sortedIndices.filter((index)=>evaluateTokens(rows[index], filterTokens, columnsById, timeZone, evalNow));
|
|
927
|
+
}
|
|
928
|
+
return {
|
|
929
|
+
configure (columns, nextTimeZone) {
|
|
930
|
+
columnsById = new Map(columns.map((column)=>[
|
|
931
|
+
column.id,
|
|
932
|
+
column
|
|
933
|
+
]));
|
|
934
|
+
timeZone = nextTimeZone;
|
|
935
|
+
},
|
|
936
|
+
ingestRows (nextRows, replace) {
|
|
937
|
+
rows = replace ? [
|
|
938
|
+
...nextRows
|
|
939
|
+
] : [
|
|
940
|
+
...rows,
|
|
941
|
+
...nextRows
|
|
942
|
+
];
|
|
943
|
+
recomputeSort();
|
|
944
|
+
recomputeFilter();
|
|
945
|
+
},
|
|
946
|
+
sort (nextSort) {
|
|
947
|
+
sortEntries = nextSort;
|
|
948
|
+
recomputeSort();
|
|
949
|
+
recomputeFilter();
|
|
950
|
+
},
|
|
951
|
+
filter (tokens, nextEvalNow) {
|
|
952
|
+
filterTokens = tokens;
|
|
953
|
+
evalNow = nextEvalNow;
|
|
954
|
+
recomputeFilter();
|
|
955
|
+
},
|
|
956
|
+
slice (start, end) {
|
|
957
|
+
const clampedEnd = Math.min(end, filteredIndices.length);
|
|
958
|
+
const entries = [];
|
|
959
|
+
for(let i = Math.max(start, 0); i < clampedEnd; i++)entries.push({
|
|
960
|
+
kind: "row",
|
|
961
|
+
data: rows[filteredIndices[i]]
|
|
962
|
+
});
|
|
963
|
+
return {
|
|
964
|
+
start,
|
|
965
|
+
entries
|
|
966
|
+
};
|
|
967
|
+
},
|
|
968
|
+
get totalCount () {
|
|
969
|
+
return filteredIndices.length;
|
|
970
|
+
}
|
|
971
|
+
};
|
|
972
|
+
}
|
|
973
|
+
function createSyncEngine() {
|
|
974
|
+
const dataset = createDataset();
|
|
975
|
+
return {
|
|
976
|
+
configure (columns, _mode, timeZone) {
|
|
977
|
+
dataset.configure(columns, timeZone);
|
|
978
|
+
},
|
|
979
|
+
ingestRows (rows, replace) {
|
|
980
|
+
dataset.ingestRows(rows, replace);
|
|
981
|
+
},
|
|
982
|
+
sort (sort) {
|
|
983
|
+
dataset.sort(sort);
|
|
984
|
+
},
|
|
985
|
+
filter (tokens, evalNow) {
|
|
986
|
+
dataset.filter(tokens, evalNow);
|
|
987
|
+
},
|
|
988
|
+
slice (start, end) {
|
|
989
|
+
return dataset.slice(start, end);
|
|
990
|
+
},
|
|
991
|
+
get totalCount () {
|
|
992
|
+
return dataset.totalCount;
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
const REF_CHANGE_SAMPLE_SIZE = 20;
|
|
997
|
+
function resolveTimeZone(explicit) {
|
|
998
|
+
return explicit ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
999
|
+
}
|
|
1000
|
+
function toSerializableColumnMeta(column) {
|
|
1001
|
+
const needsDataType = column.sortable || column.filterable || column.searchable;
|
|
1002
|
+
if (needsDataType && !column.dataType && "production" !== process.env.NODE_ENV) throw new Error(`[@ox0/data-grid] column "${column.id}" is sortable, filterable, or searchable but declares no dataType. dataType is required for every such column.`);
|
|
1003
|
+
const valueSource = "string" == typeof column.accessorKey ? {
|
|
1004
|
+
kind: "key",
|
|
1005
|
+
key: column.accessorKey
|
|
1006
|
+
} : {
|
|
1007
|
+
kind: "derived",
|
|
1008
|
+
key: `__derived_${column.id}`
|
|
1009
|
+
};
|
|
1010
|
+
return {
|
|
1011
|
+
id: column.id,
|
|
1012
|
+
dataType: column.dataType ?? "text",
|
|
1013
|
+
sortable: column.sortable ?? false,
|
|
1014
|
+
searchable: column.searchable ?? false,
|
|
1015
|
+
filterable: column.filterable ?? false,
|
|
1016
|
+
enumValues: column.enumValues,
|
|
1017
|
+
aggregate: column.aggregate,
|
|
1018
|
+
valueSource
|
|
1019
|
+
};
|
|
1020
|
+
}
|
|
1021
|
+
function warnIfRowsLookUnchanged(previous, next, getRowId) {
|
|
1022
|
+
if (previous.length !== next.length) return;
|
|
1023
|
+
const sampleSize = Math.min(previous.length, REF_CHANGE_SAMPLE_SIZE);
|
|
1024
|
+
for(let i = 0; i < sampleSize; i++){
|
|
1025
|
+
if (getRowId(previous[i]) !== getRowId(next[i])) return;
|
|
1026
|
+
if (JSON.stringify(previous[i]) !== JSON.stringify(next[i])) return;
|
|
1027
|
+
}
|
|
1028
|
+
console.warn(`[@ox0/data-grid] \`rows\` changed identity but its content looks unchanged (sampled the first ${sampleSize} row(s)). This forces a full re-ingest on every render. Memoize \`rows\` so it only changes reference on a real data change, or pass \`rowsVersion\` to control re-ingest explicitly.`);
|
|
1029
|
+
}
|
|
1030
|
+
function useGrid(options) {
|
|
1031
|
+
const engineRef = useRef(null);
|
|
1032
|
+
if (!engineRef.current) engineRef.current = createSyncEngine();
|
|
1033
|
+
const engine = engineRef.current;
|
|
1034
|
+
const storeRef = useRef(null);
|
|
1035
|
+
if (!storeRef.current) storeRef.current = createGridStore({
|
|
1036
|
+
columns: options.columnDefs.map((c)=>({
|
|
1037
|
+
id: c.id,
|
|
1038
|
+
width: c.width ?? "auto",
|
|
1039
|
+
visible: true,
|
|
1040
|
+
pinned: null
|
|
1041
|
+
})),
|
|
1042
|
+
initialSort: options.initialSort,
|
|
1043
|
+
maxSortColumns: options.maxSortColumns,
|
|
1044
|
+
initialFilterTokens: options.initialFilterTokens,
|
|
1045
|
+
selectionMode: options.selectionMode ?? null,
|
|
1046
|
+
initialDensity: options.initialDensity
|
|
1047
|
+
});
|
|
1048
|
+
const store = storeRef.current;
|
|
1049
|
+
const configuredRef = useRef(false);
|
|
1050
|
+
const previousRowsRef = useRef(null);
|
|
1051
|
+
const previousRowsVersionRef = useRef(void 0);
|
|
1052
|
+
function resolveEvalNow() {
|
|
1053
|
+
const now = options.now?.() ?? new Date();
|
|
1054
|
+
return toCalendarDay(now.getTime(), resolveTimeZone(options.timeZone)) ?? now.toISOString().slice(0, 10);
|
|
1055
|
+
}
|
|
1056
|
+
useEffect(()=>{
|
|
1057
|
+
if (!configuredRef.current) {
|
|
1058
|
+
engine.configure(options.columnDefs.map(toSerializableColumnMeta), "client", resolveTimeZone(options.timeZone));
|
|
1059
|
+
configuredRef.current = true;
|
|
1060
|
+
}
|
|
1061
|
+
const usingRowsVersion = void 0 !== options.rowsVersion;
|
|
1062
|
+
const shouldReingest = usingRowsVersion ? options.rowsVersion !== previousRowsVersionRef.current : options.rows !== previousRowsRef.current;
|
|
1063
|
+
if (shouldReingest) {
|
|
1064
|
+
if (!usingRowsVersion && "production" !== process.env.NODE_ENV && null !== previousRowsRef.current) warnIfRowsLookUnchanged(previousRowsRef.current, options.rows, options.getRowId);
|
|
1065
|
+
const { rows: materialized } = materializeRows(options.rows, options.columnDefs, options.getRowId);
|
|
1066
|
+
engine.ingestRows(materialized, true);
|
|
1067
|
+
engine.sort(store.getState().sort);
|
|
1068
|
+
engine.filter(store.getState().filterTokens, resolveEvalNow());
|
|
1069
|
+
store.getState().setTotalCount(engine.totalCount);
|
|
1070
|
+
}
|
|
1071
|
+
previousRowsRef.current = options.rows;
|
|
1072
|
+
previousRowsVersionRef.current = options.rowsVersion;
|
|
1073
|
+
}, [
|
|
1074
|
+
options.rows,
|
|
1075
|
+
options.rowsVersion
|
|
1076
|
+
]);
|
|
1077
|
+
useEffect(()=>store.subscribe((state, previousState)=>{
|
|
1078
|
+
if (state.sort !== previousState.sort) {
|
|
1079
|
+
engine.sort(state.sort);
|
|
1080
|
+
state.setTotalCount(engine.totalCount);
|
|
1081
|
+
} else if (state.filterTokens !== previousState.filterTokens) {
|
|
1082
|
+
engine.filter(state.filterTokens, resolveEvalNow());
|
|
1083
|
+
state.setTotalCount(engine.totalCount);
|
|
1084
|
+
}
|
|
1085
|
+
}), []);
|
|
1086
|
+
const totalCount = useStore(store, (s)=>s.totalCount);
|
|
1087
|
+
return {
|
|
1088
|
+
store,
|
|
1089
|
+
totalCount,
|
|
1090
|
+
slice: (start, end)=>engine.slice(start, end)
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
const DEFAULT_AUTO_WIDTH = 150;
|
|
1094
|
+
function resolveWidth(width) {
|
|
1095
|
+
return "number" == typeof width ? width : DEFAULT_AUTO_WIDTH;
|
|
1096
|
+
}
|
|
1097
|
+
function layoutColumns(columnDefs, columnStates) {
|
|
1098
|
+
const defsById = new Map(columnDefs.map((def)=>[
|
|
1099
|
+
def.id,
|
|
1100
|
+
def
|
|
1101
|
+
]));
|
|
1102
|
+
const pinnedLeft = [];
|
|
1103
|
+
const center = [];
|
|
1104
|
+
const pinnedRightRaw = [];
|
|
1105
|
+
let leftOffset = 0;
|
|
1106
|
+
for (const state of columnStates){
|
|
1107
|
+
if (!state.visible) continue;
|
|
1108
|
+
const def = defsById.get(state.id);
|
|
1109
|
+
if (!def) continue;
|
|
1110
|
+
const width = resolveWidth(state.width);
|
|
1111
|
+
if ("left" === state.pinned) {
|
|
1112
|
+
pinnedLeft.push({
|
|
1113
|
+
def,
|
|
1114
|
+
width,
|
|
1115
|
+
offset: leftOffset
|
|
1116
|
+
});
|
|
1117
|
+
leftOffset += width;
|
|
1118
|
+
} else if ("right" === state.pinned) pinnedRightRaw.push({
|
|
1119
|
+
def,
|
|
1120
|
+
width
|
|
1121
|
+
});
|
|
1122
|
+
else center.push({
|
|
1123
|
+
def,
|
|
1124
|
+
width,
|
|
1125
|
+
offset: 0
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
let rightOffset = 0;
|
|
1129
|
+
const pinnedRight = [];
|
|
1130
|
+
for(let i = pinnedRightRaw.length - 1; i >= 0; i--){
|
|
1131
|
+
const { def, width } = pinnedRightRaw[i];
|
|
1132
|
+
pinnedRight.unshift({
|
|
1133
|
+
def,
|
|
1134
|
+
width,
|
|
1135
|
+
offset: rightOffset
|
|
1136
|
+
});
|
|
1137
|
+
rightOffset += width;
|
|
1138
|
+
}
|
|
1139
|
+
const totalWidth = leftOffset + center.reduce((sum, c)=>sum + c.width, 0) + rightOffset;
|
|
1140
|
+
return {
|
|
1141
|
+
pinnedLeft,
|
|
1142
|
+
center,
|
|
1143
|
+
pinnedRight,
|
|
1144
|
+
totalWidth
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
function flattenLayout(layout) {
|
|
1148
|
+
return [
|
|
1149
|
+
...layout.pinnedLeft.map((c)=>({
|
|
1150
|
+
...c,
|
|
1151
|
+
pinned: "left"
|
|
1152
|
+
})),
|
|
1153
|
+
...layout.center.map((c)=>({
|
|
1154
|
+
...c,
|
|
1155
|
+
pinned: null
|
|
1156
|
+
})),
|
|
1157
|
+
...layout.pinnedRight.map((c)=>({
|
|
1158
|
+
...c,
|
|
1159
|
+
pinned: "right"
|
|
1160
|
+
}))
|
|
1161
|
+
];
|
|
1162
|
+
}
|
|
1163
|
+
const injectStylesIntoStyleTag = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/injectStylesIntoStyleTag.js");
|
|
1164
|
+
var injectStylesIntoStyleTag_default = /*#__PURE__*/ __webpack_require__.n(injectStylesIntoStyleTag);
|
|
1165
|
+
const styleDomAPI = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/styleDomAPI.js");
|
|
1166
|
+
var styleDomAPI_default = /*#__PURE__*/ __webpack_require__.n(styleDomAPI);
|
|
1167
|
+
const insertBySelector = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/insertBySelector.js");
|
|
1168
|
+
var insertBySelector_default = /*#__PURE__*/ __webpack_require__.n(insertBySelector);
|
|
1169
|
+
const setAttributesWithoutAttributes = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/setAttributesWithoutAttributes.js");
|
|
1170
|
+
var setAttributesWithoutAttributes_default = /*#__PURE__*/ __webpack_require__.n(setAttributesWithoutAttributes);
|
|
1171
|
+
const insertStyleElement = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/insertStyleElement.js");
|
|
1172
|
+
var insertStyleElement_default = /*#__PURE__*/ __webpack_require__.n(insertStyleElement);
|
|
1173
|
+
const styleTagTransform = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/style-loader/runtime/styleTagTransform.js");
|
|
1174
|
+
var styleTagTransform_default = /*#__PURE__*/ __webpack_require__.n(styleTagTransform);
|
|
1175
|
+
const column_chooser_module_0 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[1].oneOf[4].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[1].oneOf[4].use[2]!./src/components/column-chooser.module.css");
|
|
1176
|
+
var column_chooser_module_options = {};
|
|
1177
|
+
column_chooser_module_options.styleTagTransform = styleTagTransform_default();
|
|
1178
|
+
column_chooser_module_options.setAttributes = setAttributesWithoutAttributes_default();
|
|
1179
|
+
column_chooser_module_options.insert = insertBySelector_default().bind(null, "head");
|
|
1180
|
+
column_chooser_module_options.domAPI = styleDomAPI_default();
|
|
1181
|
+
column_chooser_module_options.insertStyleElement = insertStyleElement_default();
|
|
1182
|
+
injectStylesIntoStyleTag_default()(column_chooser_module_0.A, column_chooser_module_options);
|
|
1183
|
+
const column_chooser_module = column_chooser_module_0.A && column_chooser_module_0.A.locals ? column_chooser_module_0.A.locals : void 0;
|
|
1184
|
+
function pinnedOf(section) {
|
|
1185
|
+
return "center" === section ? null : section;
|
|
1186
|
+
}
|
|
1187
|
+
function buildRows(columnDefs, columnStates) {
|
|
1188
|
+
const defsById = new Map(columnDefs.map((def)=>[
|
|
1189
|
+
def.id,
|
|
1190
|
+
def
|
|
1191
|
+
]));
|
|
1192
|
+
const rows = [];
|
|
1193
|
+
for (const state of columnStates){
|
|
1194
|
+
const def = defsById.get(state.id);
|
|
1195
|
+
if (def) rows.push({
|
|
1196
|
+
id: state.id,
|
|
1197
|
+
header: def.header,
|
|
1198
|
+
visible: state.visible,
|
|
1199
|
+
pinned: state.pinned,
|
|
1200
|
+
hideable: def.hideable ?? true,
|
|
1201
|
+
pinnable: def.pinnable ?? true,
|
|
1202
|
+
reorderable: def.reorderable ?? true
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
return rows;
|
|
1206
|
+
}
|
|
1207
|
+
function bySection(rows) {
|
|
1208
|
+
return {
|
|
1209
|
+
left: rows.filter((row)=>"left" === row.pinned),
|
|
1210
|
+
center: rows.filter((row)=>null === row.pinned),
|
|
1211
|
+
right: rows.filter((row)=>"right" === row.pinned)
|
|
1212
|
+
};
|
|
1213
|
+
}
|
|
1214
|
+
const SECTION_LABEL = {
|
|
1215
|
+
left: "Pinned left",
|
|
1216
|
+
center: "Columns",
|
|
1217
|
+
right: "Pinned right"
|
|
1218
|
+
};
|
|
1219
|
+
const SECTIONS = [
|
|
1220
|
+
"left",
|
|
1221
|
+
"center",
|
|
1222
|
+
"right"
|
|
1223
|
+
];
|
|
1224
|
+
function isSection(value) {
|
|
1225
|
+
return "left" === value || "center" === value || "right" === value;
|
|
1226
|
+
}
|
|
1227
|
+
function ColumnChooser({ columnDefs, store }) {
|
|
1228
|
+
const columnStates = useStore(store, (state)=>state.columns);
|
|
1229
|
+
const [query, setQuery] = useState("");
|
|
1230
|
+
const [dragId, setDragId] = useState(null);
|
|
1231
|
+
const [previewRows, setPreviewRows] = useState(null);
|
|
1232
|
+
const dragBaseRef = useRef([]);
|
|
1233
|
+
const committedRows = buildRows(columnDefs, columnStates);
|
|
1234
|
+
const rows = previewRows ?? committedRows;
|
|
1235
|
+
const sections = bySection(rows);
|
|
1236
|
+
const normalizedQuery = query.trim().toLowerCase();
|
|
1237
|
+
const isFiltering = normalizedQuery.length > 0;
|
|
1238
|
+
function matches(row) {
|
|
1239
|
+
return row.header.toLowerCase().includes(normalizedQuery);
|
|
1240
|
+
}
|
|
1241
|
+
function handleGripPointerDown(id, event) {
|
|
1242
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
1243
|
+
dragBaseRef.current = committedRows;
|
|
1244
|
+
setDragId(id);
|
|
1245
|
+
}
|
|
1246
|
+
function handleGripPointerMove(event) {
|
|
1247
|
+
if (!dragId) return;
|
|
1248
|
+
const target = document.elementFromPoint(event.clientX, event.clientY);
|
|
1249
|
+
const sectionEl = target instanceof Element ? target.closest("[data-section]") : null;
|
|
1250
|
+
const section = sectionEl?.dataset.section;
|
|
1251
|
+
if (!isSection(section)) return;
|
|
1252
|
+
const draggedRow = dragBaseRef.current.find((row)=>row.id === dragId);
|
|
1253
|
+
if (!draggedRow) return;
|
|
1254
|
+
if ("center" !== section && !draggedRow.pinnable) return;
|
|
1255
|
+
const movedRow = {
|
|
1256
|
+
...draggedRow,
|
|
1257
|
+
pinned: pinnedOf(section)
|
|
1258
|
+
};
|
|
1259
|
+
const nextSections = bySection(dragBaseRef.current.filter((row)=>row.id !== dragId));
|
|
1260
|
+
const rowEl = target instanceof Element ? target.closest("[data-column-row-id]") : null;
|
|
1261
|
+
let insertAt = nextSections[section].length;
|
|
1262
|
+
if (rowEl) {
|
|
1263
|
+
const overIndex = nextSections[section].findIndex((row)=>row.id === rowEl.dataset.columnRowId);
|
|
1264
|
+
if (-1 !== overIndex) {
|
|
1265
|
+
const rect = rowEl.getBoundingClientRect();
|
|
1266
|
+
insertAt = event.clientY > rect.top + rect.height / 2 ? overIndex + 1 : overIndex;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
nextSections[section] = [
|
|
1270
|
+
...nextSections[section].slice(0, insertAt),
|
|
1271
|
+
movedRow,
|
|
1272
|
+
...nextSections[section].slice(insertAt)
|
|
1273
|
+
];
|
|
1274
|
+
setPreviewRows([
|
|
1275
|
+
...nextSections.left,
|
|
1276
|
+
...nextSections.center,
|
|
1277
|
+
...nextSections.right
|
|
1278
|
+
]);
|
|
1279
|
+
}
|
|
1280
|
+
function handleGripPointerUp() {
|
|
1281
|
+
if (dragId && previewRows) store.getState().reorderColumns(previewRows.map((row)=>({
|
|
1282
|
+
id: row.id,
|
|
1283
|
+
pinned: row.pinned
|
|
1284
|
+
})));
|
|
1285
|
+
setDragId(null);
|
|
1286
|
+
setPreviewRows(null);
|
|
1287
|
+
}
|
|
1288
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
1289
|
+
className: column_chooser_module.chooser,
|
|
1290
|
+
children: [
|
|
1291
|
+
/*#__PURE__*/ jsx(SearchField, {
|
|
1292
|
+
ariaLabel: "Find columns",
|
|
1293
|
+
onChange: setQuery,
|
|
1294
|
+
value: query
|
|
1295
|
+
}),
|
|
1296
|
+
SECTIONS.map((section)=>{
|
|
1297
|
+
const visibleRows = sections[section].filter(matches);
|
|
1298
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
1299
|
+
className: column_chooser_module.section,
|
|
1300
|
+
"data-section": section,
|
|
1301
|
+
children: [
|
|
1302
|
+
/*#__PURE__*/ jsx("div", {
|
|
1303
|
+
className: column_chooser_module.sectionLabel,
|
|
1304
|
+
children: SECTION_LABEL[section]
|
|
1305
|
+
}),
|
|
1306
|
+
0 === visibleRows.length && /*#__PURE__*/ jsx("div", {
|
|
1307
|
+
className: column_chooser_module.emptySection,
|
|
1308
|
+
children: isFiltering ? "No matching columns" : "Drag a column here to pin it"
|
|
1309
|
+
}),
|
|
1310
|
+
visibleRows.map((row)=>/*#__PURE__*/ jsxs("div", {
|
|
1311
|
+
className: column_chooser_module.row,
|
|
1312
|
+
"data-column-row-id": row.id,
|
|
1313
|
+
children: [
|
|
1314
|
+
/*#__PURE__*/ jsx("button", {
|
|
1315
|
+
"aria-label": `Reorder ${row.header}`,
|
|
1316
|
+
className: column_chooser_module.grip,
|
|
1317
|
+
disabled: isFiltering || !row.reorderable,
|
|
1318
|
+
onPointerDown: (event)=>handleGripPointerDown(row.id, event),
|
|
1319
|
+
onPointerMove: handleGripPointerMove,
|
|
1320
|
+
onPointerUp: handleGripPointerUp,
|
|
1321
|
+
type: "button",
|
|
1322
|
+
children: /*#__PURE__*/ jsx(GripIcon, {})
|
|
1323
|
+
}),
|
|
1324
|
+
/*#__PURE__*/ jsx(Checkbox, {
|
|
1325
|
+
isDisabled: !row.hideable,
|
|
1326
|
+
isSelected: row.visible,
|
|
1327
|
+
label: row.header,
|
|
1328
|
+
onChange: (isSelected)=>store.getState().setColumnVisible(row.id, isSelected)
|
|
1329
|
+
})
|
|
1330
|
+
]
|
|
1331
|
+
}, row.id))
|
|
1332
|
+
]
|
|
1333
|
+
}, section);
|
|
1334
|
+
})
|
|
1335
|
+
]
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
function GripIcon() {
|
|
1339
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
1340
|
+
"aria-hidden": "true",
|
|
1341
|
+
height: "14",
|
|
1342
|
+
viewBox: "0 0 10 14",
|
|
1343
|
+
width: "10",
|
|
1344
|
+
children: [
|
|
1345
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1346
|
+
cx: "2.5",
|
|
1347
|
+
cy: "2",
|
|
1348
|
+
fill: "currentColor",
|
|
1349
|
+
r: "1.25"
|
|
1350
|
+
}),
|
|
1351
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1352
|
+
cx: "7.5",
|
|
1353
|
+
cy: "2",
|
|
1354
|
+
fill: "currentColor",
|
|
1355
|
+
r: "1.25"
|
|
1356
|
+
}),
|
|
1357
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1358
|
+
cx: "2.5",
|
|
1359
|
+
cy: "7",
|
|
1360
|
+
fill: "currentColor",
|
|
1361
|
+
r: "1.25"
|
|
1362
|
+
}),
|
|
1363
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1364
|
+
cx: "7.5",
|
|
1365
|
+
cy: "7",
|
|
1366
|
+
fill: "currentColor",
|
|
1367
|
+
r: "1.25"
|
|
1368
|
+
}),
|
|
1369
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1370
|
+
cx: "2.5",
|
|
1371
|
+
cy: "12",
|
|
1372
|
+
fill: "currentColor",
|
|
1373
|
+
r: "1.25"
|
|
1374
|
+
}),
|
|
1375
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1376
|
+
cx: "7.5",
|
|
1377
|
+
cy: "12",
|
|
1378
|
+
fill: "currentColor",
|
|
1379
|
+
r: "1.25"
|
|
1380
|
+
})
|
|
1381
|
+
]
|
|
1382
|
+
});
|
|
1383
|
+
}
|
|
1384
|
+
function VirtualScroller({ height, rowHeight, rowCount, heightMode, renderRow, className, apiRef, rowWidth, onScroll }) {
|
|
1385
|
+
const scrollRef = useRef(null);
|
|
1386
|
+
const [fillHeightIsZero, setFillHeightIsZero] = useState(false);
|
|
1387
|
+
const virtualizer = useVirtualizer({
|
|
1388
|
+
count: rowCount,
|
|
1389
|
+
getScrollElement: ()=>scrollRef.current,
|
|
1390
|
+
estimateSize: ()=>rowHeight,
|
|
1391
|
+
overscan: 8,
|
|
1392
|
+
initialRect: {
|
|
1393
|
+
width: 0,
|
|
1394
|
+
height: "number" == typeof height ? height : 480
|
|
1395
|
+
}
|
|
1396
|
+
});
|
|
1397
|
+
useEffect(()=>{
|
|
1398
|
+
if (!apiRef) return;
|
|
1399
|
+
apiRef.current = {
|
|
1400
|
+
scrollToIndex: (index, options)=>virtualizer.scrollToIndex(index, options)
|
|
1401
|
+
};
|
|
1402
|
+
return ()=>{
|
|
1403
|
+
apiRef.current = null;
|
|
1404
|
+
};
|
|
1405
|
+
}, [
|
|
1406
|
+
apiRef,
|
|
1407
|
+
virtualizer
|
|
1408
|
+
]);
|
|
1409
|
+
useEffect(()=>{
|
|
1410
|
+
if ("fill" !== height) return;
|
|
1411
|
+
const el = scrollRef.current;
|
|
1412
|
+
if (!el) return;
|
|
1413
|
+
const observer = new ResizeObserver((entries)=>{
|
|
1414
|
+
const isZero = entries[0]?.contentRect.height === 0;
|
|
1415
|
+
setFillHeightIsZero(isZero);
|
|
1416
|
+
});
|
|
1417
|
+
observer.observe(el);
|
|
1418
|
+
return ()=>observer.disconnect();
|
|
1419
|
+
}, [
|
|
1420
|
+
height
|
|
1421
|
+
]);
|
|
1422
|
+
if ("fill" === height && fillHeightIsZero) {
|
|
1423
|
+
if ("production" !== process.env.NODE_ENV) console.warn('[@ox0/data-grid] DataGrid: height="fill" resolved to 0 — the grid has no bounded parent to fill. Give an ancestor an explicit height, or pass a fixed pixel height instead.');
|
|
1424
|
+
return /*#__PURE__*/ jsx("div", {
|
|
1425
|
+
className: className,
|
|
1426
|
+
ref: scrollRef
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
const totalSize = "total" === heightMode ? rowCount * rowHeight : virtualizer.getTotalSize();
|
|
1430
|
+
return /*#__PURE__*/ jsx("div", {
|
|
1431
|
+
className: className,
|
|
1432
|
+
ref: scrollRef,
|
|
1433
|
+
onScroll: onScroll ? (e)=>onScroll(e.currentTarget.scrollLeft) : void 0,
|
|
1434
|
+
style: {
|
|
1435
|
+
height: "number" == typeof height ? height : "100%",
|
|
1436
|
+
overflow: "auto"
|
|
1437
|
+
},
|
|
1438
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1439
|
+
style: {
|
|
1440
|
+
height: totalSize,
|
|
1441
|
+
position: "relative",
|
|
1442
|
+
width: rowWidth ?? "100%"
|
|
1443
|
+
},
|
|
1444
|
+
children: virtualizer.getVirtualItems().map((virtualRow)=>renderRow(virtualRow.index, {
|
|
1445
|
+
transform: `translateY(${virtualRow.start}px)`
|
|
1446
|
+
}))
|
|
1447
|
+
})
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
const data_grid_module_0 = __webpack_require__("../../node_modules/.pnpm/@rsbuild+core@2.1.13_core-js@3.47.0/node_modules/@rsbuild/core/compiled/css-loader/index.js??ruleSet[1].rules[1].oneOf[4].use[1]!builtin:lightningcss-loader??ruleSet[1].rules[1].oneOf[4].use[2]!./src/components/data-grid.module.css");
|
|
1451
|
+
var data_grid_module_options = {};
|
|
1452
|
+
data_grid_module_options.styleTagTransform = styleTagTransform_default();
|
|
1453
|
+
data_grid_module_options.setAttributes = setAttributesWithoutAttributes_default();
|
|
1454
|
+
data_grid_module_options.insert = insertBySelector_default().bind(null, "head");
|
|
1455
|
+
data_grid_module_options.domAPI = styleDomAPI_default();
|
|
1456
|
+
data_grid_module_options.insertStyleElement = insertStyleElement_default();
|
|
1457
|
+
injectStylesIntoStyleTag_default()(data_grid_module_0.A, data_grid_module_options);
|
|
1458
|
+
const data_grid_module = data_grid_module_0.A && data_grid_module_0.A.locals ? data_grid_module_0.A.locals : void 0;
|
|
1459
|
+
const SIMPLE_FILTER_DEBOUNCE_MS = 150;
|
|
1460
|
+
const ROW_HEIGHT_BY_DENSITY = {
|
|
1461
|
+
compact: 28,
|
|
1462
|
+
comfortable: 36,
|
|
1463
|
+
spacious: 48
|
|
1464
|
+
};
|
|
1465
|
+
function defaultCell(value, searchable) {
|
|
1466
|
+
if (null == value) return "";
|
|
1467
|
+
const text = String(value);
|
|
1468
|
+
return searchable ? /*#__PURE__*/ jsx(Markable, {
|
|
1469
|
+
children: text
|
|
1470
|
+
}) : text;
|
|
1471
|
+
}
|
|
1472
|
+
function isKeyColumnDef(column) {
|
|
1473
|
+
return "string" == typeof column.accessorKey;
|
|
1474
|
+
}
|
|
1475
|
+
function DataGrid_isDerivedColumnDef(column) {
|
|
1476
|
+
return "function" == typeof column.accessorFn;
|
|
1477
|
+
}
|
|
1478
|
+
function renderCell(column, row, meta) {
|
|
1479
|
+
if (isKeyColumnDef(column)) {
|
|
1480
|
+
const value = Reflect.get(row, column.accessorKey);
|
|
1481
|
+
return column.cell ? column.cell(value, row, meta) : defaultCell(value, column.searchable);
|
|
1482
|
+
}
|
|
1483
|
+
if (DataGrid_isDerivedColumnDef(column)) {
|
|
1484
|
+
const value = Reflect.get(row, `__derived_${column.id}`);
|
|
1485
|
+
return column.cell ? column.cell(value, row, meta) : defaultCell(value, column.searchable);
|
|
1486
|
+
}
|
|
1487
|
+
return column.cell(void 0, row, meta);
|
|
1488
|
+
}
|
|
1489
|
+
function MoreIcon() {
|
|
1490
|
+
return /*#__PURE__*/ jsxs("svg", {
|
|
1491
|
+
"aria-hidden": "true",
|
|
1492
|
+
fill: "currentColor",
|
|
1493
|
+
height: "16",
|
|
1494
|
+
viewBox: "0 0 4 16",
|
|
1495
|
+
width: "4",
|
|
1496
|
+
children: [
|
|
1497
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1498
|
+
cx: "2",
|
|
1499
|
+
cy: "2",
|
|
1500
|
+
r: "1.5"
|
|
1501
|
+
}),
|
|
1502
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1503
|
+
cx: "2",
|
|
1504
|
+
cy: "8",
|
|
1505
|
+
r: "1.5"
|
|
1506
|
+
}),
|
|
1507
|
+
/*#__PURE__*/ jsx("circle", {
|
|
1508
|
+
cx: "2",
|
|
1509
|
+
cy: "14",
|
|
1510
|
+
r: "1.5"
|
|
1511
|
+
})
|
|
1512
|
+
]
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
function pinnedCellStyle(pinned, offset, width) {
|
|
1516
|
+
const base = {
|
|
1517
|
+
flex: `0 0 ${width}px`
|
|
1518
|
+
};
|
|
1519
|
+
if (!pinned) return base;
|
|
1520
|
+
return {
|
|
1521
|
+
...base,
|
|
1522
|
+
background: "inherit",
|
|
1523
|
+
position: "sticky",
|
|
1524
|
+
zIndex: 1,
|
|
1525
|
+
[pinned]: offset
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
function DataGrid(props) {
|
|
1529
|
+
if ("client" !== props.source) throw new Error('[@ox0/data-grid] DataGrid: only source="client" is implemented so far.');
|
|
1530
|
+
const { columnDefs, rows, rowsVersion, getRowId, timeZone, height, filter, select, rowDetail } = props;
|
|
1531
|
+
const grid = useGrid({
|
|
1532
|
+
columnDefs,
|
|
1533
|
+
rows,
|
|
1534
|
+
rowsVersion,
|
|
1535
|
+
getRowId,
|
|
1536
|
+
timeZone,
|
|
1537
|
+
initialDensity: props.density ?? props.initialDensity
|
|
1538
|
+
});
|
|
1539
|
+
const sort = useStore(grid.store, (state)=>state.sort);
|
|
1540
|
+
const columnStates = useStore(grid.store, (state)=>state.columns);
|
|
1541
|
+
const density = useStore(grid.store, (state)=>state.density);
|
|
1542
|
+
const rowHeight = props.rowHeight ?? ROW_HEIGHT_BY_DENSITY[density];
|
|
1543
|
+
const totalCount = Math.max(0, grid.totalCount);
|
|
1544
|
+
const columnLayout = layoutColumns(columnDefs, columnStates);
|
|
1545
|
+
const orderedColumns = flattenLayout(columnLayout);
|
|
1546
|
+
const headerScrollRef = useRef(null);
|
|
1547
|
+
const singleSelect = select?.selectionMode === "single" ? select : void 0;
|
|
1548
|
+
const [selectedRowId, setSelectedRowId] = useControllableState({
|
|
1549
|
+
defaultValue: singleSelect?.defaultSelectedRowId ?? null,
|
|
1550
|
+
value: singleSelect?.selectedRowId,
|
|
1551
|
+
onChange: (id)=>singleSelect?.onSelectionChange?.(id)
|
|
1552
|
+
});
|
|
1553
|
+
const [openRowId, setOpenRowId] = useControllableState({
|
|
1554
|
+
defaultValue: rowDetail?.defaultOpenRowId ?? null,
|
|
1555
|
+
value: rowDetail?.openRowId,
|
|
1556
|
+
onChange: (id)=>rowDetail?.onOpenChange?.(id)
|
|
1557
|
+
});
|
|
1558
|
+
const selectedIndexRef = useRef(-1);
|
|
1559
|
+
function selectRow(rowId, index) {
|
|
1560
|
+
selectedIndexRef.current = index;
|
|
1561
|
+
setSelectedRowId(rowId);
|
|
1562
|
+
if (rowDetail) setOpenRowId(rowId);
|
|
1563
|
+
}
|
|
1564
|
+
const simpleFilter = filter?.mode === "simple" ? filter : void 0;
|
|
1565
|
+
const [committedQuery, setCommittedQuery] = useControllableState({
|
|
1566
|
+
defaultValue: simpleFilter?.initialQuery ?? "",
|
|
1567
|
+
value: simpleFilter?.query,
|
|
1568
|
+
onChange: (value)=>simpleFilter?.onQueryChange?.(value)
|
|
1569
|
+
});
|
|
1570
|
+
const [inputValue, setInputValue] = useState(committedQuery);
|
|
1571
|
+
const [isPending, startTransition] = useTransition();
|
|
1572
|
+
useEffect(()=>{
|
|
1573
|
+
setInputValue(committedQuery);
|
|
1574
|
+
}, [
|
|
1575
|
+
committedQuery
|
|
1576
|
+
]);
|
|
1577
|
+
function handleQueryInput(value) {
|
|
1578
|
+
setInputValue(value);
|
|
1579
|
+
startTransition(()=>{
|
|
1580
|
+
setCommittedQuery(value);
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
const debouncedQuery = useDebouncedValue(committedQuery, SIMPLE_FILTER_DEBOUNCE_MS);
|
|
1584
|
+
const hasSimpleFilter = void 0 !== simpleFilter;
|
|
1585
|
+
useEffect(()=>{
|
|
1586
|
+
if (!hasSimpleFilter) return;
|
|
1587
|
+
grid.store.getState().setFilterTokens(debouncedQuery ? [
|
|
1588
|
+
{
|
|
1589
|
+
type: "text",
|
|
1590
|
+
term: debouncedQuery
|
|
1591
|
+
}
|
|
1592
|
+
] : []);
|
|
1593
|
+
}, [
|
|
1594
|
+
debouncedQuery,
|
|
1595
|
+
hasSimpleFilter,
|
|
1596
|
+
grid.store
|
|
1597
|
+
]);
|
|
1598
|
+
const rowRefs = useRef(new Map());
|
|
1599
|
+
const pendingFocusRowIdRef = useRef(null);
|
|
1600
|
+
const searchInputRef = useRef(null);
|
|
1601
|
+
const scrollerApiRef = useRef(null);
|
|
1602
|
+
function registerRowRef(rowId) {
|
|
1603
|
+
return (el)=>{
|
|
1604
|
+
if (el) {
|
|
1605
|
+
rowRefs.current.set(rowId, el);
|
|
1606
|
+
if (pendingFocusRowIdRef.current === rowId) {
|
|
1607
|
+
el.focus();
|
|
1608
|
+
pendingFocusRowIdRef.current = null;
|
|
1609
|
+
}
|
|
1610
|
+
} else rowRefs.current.delete(rowId);
|
|
1611
|
+
};
|
|
1612
|
+
}
|
|
1613
|
+
function focusRowAt(index) {
|
|
1614
|
+
if (0 === totalCount) return;
|
|
1615
|
+
const clamped = Math.max(0, Math.min(index, totalCount - 1));
|
|
1616
|
+
const entry = grid.slice(clamped, clamped + 1).entries[0];
|
|
1617
|
+
if (!entry || "row" !== entry.kind) return;
|
|
1618
|
+
const rowId = entry.data.__rowId;
|
|
1619
|
+
selectRow(rowId, clamped);
|
|
1620
|
+
const mounted = rowRefs.current.get(rowId);
|
|
1621
|
+
if (mounted) mounted.focus();
|
|
1622
|
+
else pendingFocusRowIdRef.current = rowId;
|
|
1623
|
+
scrollerApiRef.current?.scrollToIndex(clamped, {
|
|
1624
|
+
align: "auto"
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
function handleGridKeyDown(event) {
|
|
1628
|
+
const isModified = event.ctrlKey || event.metaKey;
|
|
1629
|
+
if (isModified && ("f" === event.key || "F" === event.key)) {
|
|
1630
|
+
if (!simpleFilter) return;
|
|
1631
|
+
event.preventDefault();
|
|
1632
|
+
searchInputRef.current?.focus();
|
|
1633
|
+
return;
|
|
1634
|
+
}
|
|
1635
|
+
if (!singleSelect || 0 === totalCount) return;
|
|
1636
|
+
const currentIndex = selectedIndexRef.current;
|
|
1637
|
+
if ("ArrowUp" === event.key) {
|
|
1638
|
+
event.preventDefault();
|
|
1639
|
+
focusRowAt(-1 === currentIndex ? 0 : currentIndex - 1);
|
|
1640
|
+
} else if ("ArrowDown" === event.key) {
|
|
1641
|
+
event.preventDefault();
|
|
1642
|
+
focusRowAt(-1 === currentIndex ? 0 : currentIndex + 1);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
function sortMetaFor(columnId) {
|
|
1646
|
+
const index = sort.findIndex((s)=>s.columnId === columnId);
|
|
1647
|
+
return -1 === index ? {
|
|
1648
|
+
direction: null,
|
|
1649
|
+
index: null
|
|
1650
|
+
} : {
|
|
1651
|
+
direction: sort[index].direction,
|
|
1652
|
+
index
|
|
1653
|
+
};
|
|
1654
|
+
}
|
|
1655
|
+
const openRow = rowDetail && openRowId ? rows.find((row)=>getRowId(row) === openRowId) : void 0;
|
|
1656
|
+
const hasColumnChooser = columnDefs.some((column)=>false !== column.hideable || false !== column.pinnable || false !== column.reorderable);
|
|
1657
|
+
function renderRow(index, style) {
|
|
1658
|
+
const entry = grid.slice(index, index + 1).entries[0];
|
|
1659
|
+
if (!entry || "row" !== entry.kind) return null;
|
|
1660
|
+
const row = entry.data;
|
|
1661
|
+
const rowId = row.__rowId;
|
|
1662
|
+
const isSelected = void 0 !== singleSelect && rowId === selectedRowId;
|
|
1663
|
+
return /*#__PURE__*/ jsx("div", {
|
|
1664
|
+
"aria-rowindex": index + 2,
|
|
1665
|
+
"aria-selected": singleSelect ? isSelected : void 0,
|
|
1666
|
+
className: isSelected ? data_grid_module.selectedRow : data_grid_module.row,
|
|
1667
|
+
ref: singleSelect ? registerRowRef(rowId) : void 0,
|
|
1668
|
+
role: "row",
|
|
1669
|
+
style: {
|
|
1670
|
+
...style,
|
|
1671
|
+
width: columnLayout.totalWidth,
|
|
1672
|
+
height: rowHeight
|
|
1673
|
+
},
|
|
1674
|
+
tabIndex: singleSelect ? isSelected || null === selectedRowId && 0 === index ? 0 : -1 : void 0,
|
|
1675
|
+
onClick: singleSelect ? ()=>selectRow(rowId, index) : void 0,
|
|
1676
|
+
children: orderedColumns.map((col, colIndex)=>{
|
|
1677
|
+
const meta = {
|
|
1678
|
+
columnId: col.def.id,
|
|
1679
|
+
rowId,
|
|
1680
|
+
rowIndex: index,
|
|
1681
|
+
isSelected,
|
|
1682
|
+
isDetailOpen: void 0 !== rowDetail && rowId === openRowId
|
|
1683
|
+
};
|
|
1684
|
+
return /*#__PURE__*/ jsx("div", {
|
|
1685
|
+
"aria-colindex": colIndex + 1,
|
|
1686
|
+
className: data_grid_module.cell,
|
|
1687
|
+
role: "gridcell",
|
|
1688
|
+
style: pinnedCellStyle(col.pinned, col.offset, col.width),
|
|
1689
|
+
children: renderCell(col.def, row, meta)
|
|
1690
|
+
}, col.def.id);
|
|
1691
|
+
})
|
|
1692
|
+
}, rowId);
|
|
1693
|
+
}
|
|
1694
|
+
function renderHeaderCell(col, colIndex) {
|
|
1695
|
+
const { direction, index: sortIndex } = sortMetaFor(col.def.id);
|
|
1696
|
+
const isPrimarySort = sort[0]?.columnId === col.def.id;
|
|
1697
|
+
const meta = {
|
|
1698
|
+
columnId: col.def.id,
|
|
1699
|
+
sortDirection: direction,
|
|
1700
|
+
sortIndex,
|
|
1701
|
+
isPinned: col.pinned,
|
|
1702
|
+
width: col.width
|
|
1703
|
+
};
|
|
1704
|
+
return /*#__PURE__*/ jsx("div", {
|
|
1705
|
+
"aria-colindex": colIndex + 1,
|
|
1706
|
+
"aria-sort": isPrimarySort ? "asc" === direction ? "ascending" : "descending" : void 0,
|
|
1707
|
+
className: data_grid_module.headerCell,
|
|
1708
|
+
role: "columnheader",
|
|
1709
|
+
style: pinnedCellStyle(col.pinned, col.offset, col.width),
|
|
1710
|
+
children: col.def.headerCell ? col.def.headerCell(meta) : /*#__PURE__*/ jsx(Fragment, {
|
|
1711
|
+
children: col.def.sortable ? /*#__PURE__*/ jsxs("button", {
|
|
1712
|
+
className: data_grid_module.sortButton,
|
|
1713
|
+
onClick: ()=>grid.store.getState().cycleSort(col.def.id),
|
|
1714
|
+
type: "button",
|
|
1715
|
+
children: [
|
|
1716
|
+
col.def.header,
|
|
1717
|
+
isPrimarySort && ("asc" === direction ? " ↑" : " ↓")
|
|
1718
|
+
]
|
|
1719
|
+
}) : col.def.header
|
|
1720
|
+
})
|
|
1721
|
+
}, col.def.id);
|
|
1722
|
+
}
|
|
1723
|
+
return /*#__PURE__*/ jsxs(MarkProvider, {
|
|
1724
|
+
terms: debouncedQuery ? [
|
|
1725
|
+
debouncedQuery
|
|
1726
|
+
] : [],
|
|
1727
|
+
children: [
|
|
1728
|
+
(simpleFilter || hasColumnChooser) && /*#__PURE__*/ jsxs("div", {
|
|
1729
|
+
className: data_grid_module.toolbar,
|
|
1730
|
+
children: [
|
|
1731
|
+
simpleFilter && /*#__PURE__*/ jsx("input", {
|
|
1732
|
+
"aria-label": "Search",
|
|
1733
|
+
className: data_grid_module.searchInput,
|
|
1734
|
+
onChange: (event)=>handleQueryInput(event.target.value),
|
|
1735
|
+
placeholder: "Search…",
|
|
1736
|
+
ref: searchInputRef,
|
|
1737
|
+
type: "search",
|
|
1738
|
+
value: inputValue
|
|
1739
|
+
}),
|
|
1740
|
+
hasColumnChooser && /*#__PURE__*/ jsxs(Popover, {
|
|
1741
|
+
placement: "bottom-end",
|
|
1742
|
+
children: [
|
|
1743
|
+
/*#__PURE__*/ jsx(PopoverTrigger, {
|
|
1744
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
1745
|
+
"aria-label": "Columns",
|
|
1746
|
+
className: data_grid_module.columnChooserTrigger,
|
|
1747
|
+
type: "button",
|
|
1748
|
+
children: /*#__PURE__*/ jsx(MoreIcon, {})
|
|
1749
|
+
})
|
|
1750
|
+
}),
|
|
1751
|
+
/*#__PURE__*/ jsx(PopoverContent, {
|
|
1752
|
+
className: data_grid_module.columnChooserPanel,
|
|
1753
|
+
children: /*#__PURE__*/ jsx(ColumnChooser, {
|
|
1754
|
+
columnDefs: columnDefs,
|
|
1755
|
+
store: grid.store
|
|
1756
|
+
})
|
|
1757
|
+
})
|
|
1758
|
+
]
|
|
1759
|
+
})
|
|
1760
|
+
]
|
|
1761
|
+
}),
|
|
1762
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1763
|
+
className: data_grid_module.layout,
|
|
1764
|
+
style: "number" == typeof height ? {
|
|
1765
|
+
height
|
|
1766
|
+
} : void 0,
|
|
1767
|
+
children: [
|
|
1768
|
+
/*#__PURE__*/ jsxs("div", {
|
|
1769
|
+
"aria-busy": isPending,
|
|
1770
|
+
"aria-colcount": orderedColumns.length,
|
|
1771
|
+
"aria-multiselectable": select?.selectionMode === "multiple" || void 0,
|
|
1772
|
+
"aria-rowcount": 1 + totalCount,
|
|
1773
|
+
className: data_grid_module.viewport,
|
|
1774
|
+
"data-pending": isPending || void 0,
|
|
1775
|
+
onKeyDown: handleGridKeyDown,
|
|
1776
|
+
role: "grid",
|
|
1777
|
+
tabIndex: -1,
|
|
1778
|
+
children: [
|
|
1779
|
+
/*#__PURE__*/ jsx("div", {
|
|
1780
|
+
className: data_grid_module.headerScroll,
|
|
1781
|
+
ref: headerScrollRef,
|
|
1782
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
1783
|
+
"aria-rowindex": 1,
|
|
1784
|
+
className: data_grid_module.headerRow,
|
|
1785
|
+
role: "row",
|
|
1786
|
+
style: {
|
|
1787
|
+
width: columnLayout.totalWidth
|
|
1788
|
+
},
|
|
1789
|
+
children: orderedColumns.map((col, colIndex)=>renderHeaderCell(col, colIndex))
|
|
1790
|
+
})
|
|
1791
|
+
}),
|
|
1792
|
+
0 === totalCount ? /*#__PURE__*/ jsx("div", {
|
|
1793
|
+
className: data_grid_module.emptyCell,
|
|
1794
|
+
children: 0 === rows.length ? "No rows." : "No rows match your search."
|
|
1795
|
+
}) : /*#__PURE__*/ jsx(VirtualScroller, {
|
|
1796
|
+
apiRef: scrollerApiRef,
|
|
1797
|
+
className: data_grid_module.scroller,
|
|
1798
|
+
height: height,
|
|
1799
|
+
heightMode: "total",
|
|
1800
|
+
onScroll: (scrollLeft)=>{
|
|
1801
|
+
if (headerScrollRef.current) headerScrollRef.current.scrollLeft = scrollLeft;
|
|
1802
|
+
},
|
|
1803
|
+
renderRow: renderRow,
|
|
1804
|
+
rowCount: totalCount,
|
|
1805
|
+
rowHeight: rowHeight,
|
|
1806
|
+
rowWidth: columnLayout.totalWidth
|
|
1807
|
+
})
|
|
1808
|
+
]
|
|
1809
|
+
}),
|
|
1810
|
+
rowDetail && /*#__PURE__*/ jsxs(Drawer, {
|
|
1811
|
+
isOpen: void 0 !== openRow,
|
|
1812
|
+
onClose: ()=>setOpenRowId(null),
|
|
1813
|
+
variant: "push",
|
|
1814
|
+
isResizable: true,
|
|
1815
|
+
children: [
|
|
1816
|
+
/*#__PURE__*/ jsx(Drawer.Header, {
|
|
1817
|
+
children: /*#__PURE__*/ jsx(Drawer.Title, {
|
|
1818
|
+
children: "Details"
|
|
1819
|
+
})
|
|
1820
|
+
}),
|
|
1821
|
+
/*#__PURE__*/ jsx(Drawer.Body, {
|
|
1822
|
+
children: openRow && rowDetail.render(openRow)
|
|
1823
|
+
})
|
|
1824
|
+
]
|
|
1825
|
+
})
|
|
1826
|
+
]
|
|
1827
|
+
})
|
|
1828
|
+
]
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1831
|
+
function serializeSelection(state) {
|
|
1832
|
+
return "include" === state.mode ? {
|
|
1833
|
+
mode: "include",
|
|
1834
|
+
keys: [
|
|
1835
|
+
...state.keys
|
|
1836
|
+
]
|
|
1837
|
+
} : {
|
|
1838
|
+
mode: "all-except",
|
|
1839
|
+
excluded: [
|
|
1840
|
+
...state.excluded
|
|
1841
|
+
]
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
function deserializeSelection(data) {
|
|
1845
|
+
const isValid = null != data && "object" == typeof data && ("include" === data.mode && Array.isArray(data.keys) || "all-except" === data.mode && Array.isArray(data.excluded));
|
|
1846
|
+
if (!isValid) {
|
|
1847
|
+
if ("production" !== process.env.NODE_ENV) throw new Error("deserializeSelection: malformed SerializedSelectionState");
|
|
1848
|
+
return {
|
|
1849
|
+
mode: "include",
|
|
1850
|
+
keys: new Set()
|
|
1851
|
+
};
|
|
1852
|
+
}
|
|
1853
|
+
return "include" === data.mode ? {
|
|
1854
|
+
mode: "include",
|
|
1855
|
+
keys: new Set(data.keys)
|
|
1856
|
+
} : {
|
|
1857
|
+
mode: "all-except",
|
|
1858
|
+
excluded: new Set(data.excluded)
|
|
1859
|
+
};
|
|
1860
|
+
}
|
|
1861
|
+
export { DataGrid, deserializeSelection, serializeSelection };
|