@gridui/data-explorer 1.0.4 → 1.1.1
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 +54 -1
- package/dist/data-explorer/column-resize-handle.d.ts +16 -0
- package/dist/data-explorer/data-explorer.d.ts +5 -0
- package/dist/data-explorer/features.d.ts +37 -0
- package/dist/data-explorer/filter-editor.d.ts +16 -0
- package/dist/data-explorer/model.d.ts +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +598 -42
- package/dist/index.js.map +4 -4
- package/dist/styles.css +31 -2
- package/docs/catalog.json +99 -0
- package/package.json +14 -12
package/dist/index.js
CHANGED
|
@@ -40,7 +40,9 @@ var selectExplorerRows = (rows, columns, state, pageSize, filter) => {
|
|
|
40
40
|
return cellText.includes(query);
|
|
41
41
|
});
|
|
42
42
|
const matchesFilter = !filter || !state.filterValue || String(row.values[filter.key] ?? "") === state.filterValue;
|
|
43
|
-
return matchesQuery && matchesFilter
|
|
43
|
+
return matchesQuery && matchesFilter && (state.filters ?? []).every((condition) => {
|
|
44
|
+
return matchesExplorerCondition(row, condition);
|
|
45
|
+
});
|
|
44
46
|
});
|
|
45
47
|
const sort = state.sort;
|
|
46
48
|
if (sort && columnKeys.includes(sort.key)) {
|
|
@@ -68,6 +70,170 @@ var selectExplorerPage = (selectedIds, pageIds, checked) => {
|
|
|
68
70
|
}
|
|
69
71
|
return [...selected];
|
|
70
72
|
};
|
|
73
|
+
var matchesExplorerCondition = (row, condition) => {
|
|
74
|
+
const value = row.values[condition.key];
|
|
75
|
+
if (condition.operator === "empty") {
|
|
76
|
+
return value === null || value === void 0 || value === "";
|
|
77
|
+
}
|
|
78
|
+
if (condition.value === void 0 || condition.value === "") {
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
if (condition.operator === "contains") {
|
|
82
|
+
return String(value ?? "").normalize("NFKC").toLowerCase().includes(String(condition.value).normalize("NFKC").toLowerCase());
|
|
83
|
+
}
|
|
84
|
+
if (condition.operator === "equals") {
|
|
85
|
+
return value === condition.value;
|
|
86
|
+
}
|
|
87
|
+
if (condition.operator === "not-equals") {
|
|
88
|
+
return value !== condition.value;
|
|
89
|
+
}
|
|
90
|
+
if (typeof condition.value !== "number" || !Number.isFinite(condition.value)) {
|
|
91
|
+
throw new RangeError("Numeric filter comparisons require a finite numeric value.");
|
|
92
|
+
}
|
|
93
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
return condition.operator === "greater-than" ? value > condition.value : value < condition.value;
|
|
97
|
+
};
|
|
98
|
+
var resolveExplorerWidth = (column, width = column.width ?? 200) => {
|
|
99
|
+
const min = column.minWidth ?? 80;
|
|
100
|
+
const max = column.maxWidth ?? 1200;
|
|
101
|
+
if (![
|
|
102
|
+
width,
|
|
103
|
+
min,
|
|
104
|
+
max
|
|
105
|
+
].every((value) => {
|
|
106
|
+
return Number.isFinite(value) && value > 0;
|
|
107
|
+
}) || max < min) {
|
|
108
|
+
throw new RangeError("Explorer column widths must be positive and finite with ordered bounds.");
|
|
109
|
+
}
|
|
110
|
+
return Math.max(min, Math.min(max, width));
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// src/data-explorer/column-resize-handle.tsx
|
|
114
|
+
import { isComposingKeyEvent, listenForDragCancellation } from "@gridui/interaction";
|
|
115
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
116
|
+
import { jsx } from "react/jsx-runtime";
|
|
117
|
+
var ColumnResizeHandle = (props) => {
|
|
118
|
+
const { column, width, label, disabled, onChange } = props;
|
|
119
|
+
const handle = useRef(null);
|
|
120
|
+
const drag = useRef(null);
|
|
121
|
+
const min = column.minWidth ?? 80;
|
|
122
|
+
const max = column.maxWidth ?? 1200;
|
|
123
|
+
const change = (next) => {
|
|
124
|
+
onChange(resolveExplorerWidth(column, Math.max(min, Math.min(max, next))));
|
|
125
|
+
};
|
|
126
|
+
const cancelDrag = () => {
|
|
127
|
+
const current = drag.current;
|
|
128
|
+
drag.current = null;
|
|
129
|
+
if (current) {
|
|
130
|
+
current.cleanup();
|
|
131
|
+
change(current.width);
|
|
132
|
+
if (handle.current?.hasPointerCapture(current.pointer)) {
|
|
133
|
+
handle.current.releasePointerCapture(current.pointer);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const cancelLatest = useRef(cancelDrag);
|
|
138
|
+
useLayoutEffect(() => {
|
|
139
|
+
cancelLatest.current = cancelDrag;
|
|
140
|
+
});
|
|
141
|
+
useEffect(() => {
|
|
142
|
+
if (disabled) {
|
|
143
|
+
cancelLatest.current();
|
|
144
|
+
}
|
|
145
|
+
}, [disabled]);
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
const element = handle.current;
|
|
148
|
+
return () => {
|
|
149
|
+
const current = drag.current;
|
|
150
|
+
drag.current = null;
|
|
151
|
+
current?.cleanup();
|
|
152
|
+
if (current && element?.hasPointerCapture(current.pointer)) {
|
|
153
|
+
element.releasePointerCapture(current.pointer);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}, []);
|
|
157
|
+
return /* @__PURE__ */ jsx(
|
|
158
|
+
"div",
|
|
159
|
+
{
|
|
160
|
+
ref: handle,
|
|
161
|
+
role: "separator",
|
|
162
|
+
tabIndex: disabled ? -1 : 0,
|
|
163
|
+
"aria-orientation": "vertical",
|
|
164
|
+
"aria-label": label,
|
|
165
|
+
"aria-valuemin": min,
|
|
166
|
+
"aria-valuemax": max,
|
|
167
|
+
"aria-valuenow": width,
|
|
168
|
+
"aria-disabled": disabled || void 0,
|
|
169
|
+
className: "gridui-explorer-resize gridui-u-min-h-11 gridui-u-w-gridui-16 gridui-u-shrink-0 gridui-u-cursor-col-resize gridui-u-touch-none gridui-u-border-s gridui-u-border-solid gridui-u-border-border",
|
|
170
|
+
onPointerDown: (event) => {
|
|
171
|
+
if (disabled || event.button !== 0 || !event.isPrimary || drag.current) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
event.currentTarget.focus();
|
|
176
|
+
drag.current = {
|
|
177
|
+
pointer: event.pointerId,
|
|
178
|
+
x: event.clientX,
|
|
179
|
+
width,
|
|
180
|
+
direction: getComputedStyle(event.currentTarget).direction === "rtl" ? -1 : 1,
|
|
181
|
+
cleanup: listenForDragCancellation(event.currentTarget, () => {
|
|
182
|
+
cancelLatest.current();
|
|
183
|
+
})
|
|
184
|
+
};
|
|
185
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
186
|
+
},
|
|
187
|
+
onPointerMove: (event) => {
|
|
188
|
+
const current = drag.current;
|
|
189
|
+
if (!disabled && current?.pointer === event.pointerId) {
|
|
190
|
+
change(current.width + (event.clientX - current.x) * current.direction);
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
onPointerUp: (event) => {
|
|
194
|
+
if (drag.current?.pointer === event.pointerId) {
|
|
195
|
+
const current = drag.current;
|
|
196
|
+
drag.current = null;
|
|
197
|
+
current.cleanup();
|
|
198
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
199
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
onPointerCancel: (event) => {
|
|
204
|
+
if (drag.current?.pointer === event.pointerId) {
|
|
205
|
+
cancelDrag();
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
onLostPointerCapture: (event) => {
|
|
209
|
+
if (drag.current?.pointer === event.pointerId) {
|
|
210
|
+
cancelDrag();
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
onKeyDown: (event) => {
|
|
214
|
+
if (disabled || isComposingKeyEvent(event.nativeEvent) || ![
|
|
215
|
+
"ArrowLeft",
|
|
216
|
+
"ArrowRight",
|
|
217
|
+
"Home",
|
|
218
|
+
"End"
|
|
219
|
+
].includes(event.key)) {
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
event.preventDefault();
|
|
223
|
+
const direction = getComputedStyle(event.currentTarget).direction === "rtl" ? -1 : 1;
|
|
224
|
+
const step = (event.shiftKey ? 50 : 10) * direction;
|
|
225
|
+
let next = width + (event.key === "ArrowRight" ? step : -step);
|
|
226
|
+
if (event.key === "Home") {
|
|
227
|
+
next = min;
|
|
228
|
+
}
|
|
229
|
+
if (event.key === "End") {
|
|
230
|
+
next = max;
|
|
231
|
+
}
|
|
232
|
+
change(next);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
};
|
|
71
237
|
|
|
72
238
|
// src/data-explorer/style.ts
|
|
73
239
|
import { cva } from "class-variance-authority";
|
|
@@ -76,16 +242,226 @@ var explorerToolbarStyles = cva("gridui-u-flex gridui-u-min-w-0 gridui-u-flex-wr
|
|
|
76
242
|
var explorerLabelStyles = cva("gridui-u-flex gridui-u-min-w-0 gridui-u-flex-[1_1_10rem] gridui-u-flex-col gridui-u-gap-gridui-4 gridui-u-text-muted gridui-u-type-caption");
|
|
77
243
|
var explorerFooterStyles = cva("gridui-u-flex gridui-u-flex-wrap gridui-u-items-center gridui-u-justify-between gridui-u-gap-gridui-8 gridui-u-p-gridui-16");
|
|
78
244
|
|
|
79
|
-
// src/data-explorer/
|
|
245
|
+
// src/data-explorer/filter-editor.tsx
|
|
80
246
|
import { Button } from "@gridui/button";
|
|
81
|
-
import { Checkbox } from "@gridui/choice";
|
|
82
|
-
import { Split } from "@gridui/grid";
|
|
83
247
|
import { Input } from "@gridui/input";
|
|
84
248
|
import { Select } from "@gridui/select";
|
|
249
|
+
import { useId, useRef as useRef2 } from "react";
|
|
250
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
251
|
+
var FilterEditor = (props) => {
|
|
252
|
+
const { filtering, conditions, disabled, onChange } = props;
|
|
253
|
+
const id = useId();
|
|
254
|
+
const sequence = useRef2(0);
|
|
255
|
+
const addButton = useRef2(null);
|
|
256
|
+
const { definitions, labels } = filtering;
|
|
257
|
+
const first = definitions[0];
|
|
258
|
+
const change = (index, condition) => {
|
|
259
|
+
onChange(conditions.map((current, currentIndex) => {
|
|
260
|
+
return currentIndex === index ? condition : current;
|
|
261
|
+
}));
|
|
262
|
+
};
|
|
263
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
264
|
+
conditions.map((condition, index) => {
|
|
265
|
+
const definition = definitions.find((entry) => {
|
|
266
|
+
return entry.key === condition.key;
|
|
267
|
+
});
|
|
268
|
+
let operators = [
|
|
269
|
+
"contains",
|
|
270
|
+
"equals",
|
|
271
|
+
"not-equals",
|
|
272
|
+
"empty"
|
|
273
|
+
];
|
|
274
|
+
if (definition?.type === "number") {
|
|
275
|
+
operators = [
|
|
276
|
+
"equals",
|
|
277
|
+
"not-equals",
|
|
278
|
+
"greater-than",
|
|
279
|
+
"less-than",
|
|
280
|
+
"empty"
|
|
281
|
+
];
|
|
282
|
+
}
|
|
283
|
+
if (definition?.type === "enum") {
|
|
284
|
+
operators = [
|
|
285
|
+
"equals",
|
|
286
|
+
"not-equals",
|
|
287
|
+
"empty"
|
|
288
|
+
];
|
|
289
|
+
}
|
|
290
|
+
return /* @__PURE__ */ jsxs(
|
|
291
|
+
"div",
|
|
292
|
+
{
|
|
293
|
+
className: explorerToolbarStyles(),
|
|
294
|
+
children: [
|
|
295
|
+
/* @__PURE__ */ jsxs(
|
|
296
|
+
"label",
|
|
297
|
+
{
|
|
298
|
+
className: explorerLabelStyles(),
|
|
299
|
+
children: [
|
|
300
|
+
labels.field,
|
|
301
|
+
/* @__PURE__ */ jsx2(
|
|
302
|
+
Select,
|
|
303
|
+
{
|
|
304
|
+
"aria-label": labels.field,
|
|
305
|
+
disabled,
|
|
306
|
+
value: condition.key,
|
|
307
|
+
options: definitions.map((field) => {
|
|
308
|
+
return {
|
|
309
|
+
value: field.key,
|
|
310
|
+
label: field.label
|
|
311
|
+
};
|
|
312
|
+
}),
|
|
313
|
+
onValueChange: (key) => {
|
|
314
|
+
const field = definitions.find((entry) => {
|
|
315
|
+
return entry.key === key;
|
|
316
|
+
});
|
|
317
|
+
change(index, {
|
|
318
|
+
id: condition.id,
|
|
319
|
+
key,
|
|
320
|
+
operator: field?.type === "text" ? "contains" : "equals",
|
|
321
|
+
value: ""
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
)
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
),
|
|
329
|
+
/* @__PURE__ */ jsxs(
|
|
330
|
+
"label",
|
|
331
|
+
{
|
|
332
|
+
className: explorerLabelStyles(),
|
|
333
|
+
children: [
|
|
334
|
+
labels.operator,
|
|
335
|
+
/* @__PURE__ */ jsx2(
|
|
336
|
+
Select,
|
|
337
|
+
{
|
|
338
|
+
"aria-label": labels.operator,
|
|
339
|
+
disabled,
|
|
340
|
+
value: condition.operator,
|
|
341
|
+
options: operators.map((operator) => {
|
|
342
|
+
return {
|
|
343
|
+
value: operator,
|
|
344
|
+
label: labels.operators[operator]
|
|
345
|
+
};
|
|
346
|
+
}),
|
|
347
|
+
onValueChange: (operator) => {
|
|
348
|
+
const next = operators.find((value) => {
|
|
349
|
+
return value === operator;
|
|
350
|
+
});
|
|
351
|
+
if (next) {
|
|
352
|
+
change(index, {
|
|
353
|
+
...condition,
|
|
354
|
+
operator: next
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
)
|
|
360
|
+
]
|
|
361
|
+
}
|
|
362
|
+
),
|
|
363
|
+
condition.operator !== "empty" && /* @__PURE__ */ jsxs(
|
|
364
|
+
"label",
|
|
365
|
+
{
|
|
366
|
+
className: explorerLabelStyles(),
|
|
367
|
+
children: [
|
|
368
|
+
labels.value,
|
|
369
|
+
definition?.type === "enum" ? /* @__PURE__ */ jsx2(
|
|
370
|
+
Select,
|
|
371
|
+
{
|
|
372
|
+
"aria-label": labels.value,
|
|
373
|
+
disabled,
|
|
374
|
+
value: String(condition.value ?? ""),
|
|
375
|
+
placeholder: labels.value,
|
|
376
|
+
options: definition.options ?? [],
|
|
377
|
+
onValueChange: (value) => {
|
|
378
|
+
change(index, {
|
|
379
|
+
...condition,
|
|
380
|
+
value
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
) : /* @__PURE__ */ jsx2(
|
|
385
|
+
Input,
|
|
386
|
+
{
|
|
387
|
+
"aria-label": labels.value,
|
|
388
|
+
disabled,
|
|
389
|
+
type: definition?.type === "number" ? "number" : "text",
|
|
390
|
+
value: condition.value ?? "",
|
|
391
|
+
onValueChange: (text) => {
|
|
392
|
+
const value = definition?.type === "number" && text !== "" ? Number(text) : text;
|
|
393
|
+
change(index, {
|
|
394
|
+
...condition,
|
|
395
|
+
value
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
)
|
|
400
|
+
]
|
|
401
|
+
}
|
|
402
|
+
),
|
|
403
|
+
/* @__PURE__ */ jsx2(
|
|
404
|
+
Button,
|
|
405
|
+
{
|
|
406
|
+
variant: "quiet",
|
|
407
|
+
disabled,
|
|
408
|
+
onClick: () => {
|
|
409
|
+
onChange(conditions.filter((entry) => {
|
|
410
|
+
return entry.id !== condition.id;
|
|
411
|
+
}));
|
|
412
|
+
addButton.current?.focus();
|
|
413
|
+
},
|
|
414
|
+
children: labels.remove(index)
|
|
415
|
+
}
|
|
416
|
+
)
|
|
417
|
+
]
|
|
418
|
+
},
|
|
419
|
+
condition.id
|
|
420
|
+
);
|
|
421
|
+
}),
|
|
422
|
+
/* @__PURE__ */ jsx2(
|
|
423
|
+
"div",
|
|
424
|
+
{
|
|
425
|
+
className: explorerToolbarStyles(),
|
|
426
|
+
children: /* @__PURE__ */ jsx2(
|
|
427
|
+
Button,
|
|
428
|
+
{
|
|
429
|
+
ref: addButton,
|
|
430
|
+
variant: "secondary",
|
|
431
|
+
disabled: disabled || !first,
|
|
432
|
+
onClick: () => {
|
|
433
|
+
if (!first) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
sequence.current += 1;
|
|
437
|
+
onChange([
|
|
438
|
+
...conditions,
|
|
439
|
+
{
|
|
440
|
+
id: `${id}-${sequence.current}`,
|
|
441
|
+
key: first.key,
|
|
442
|
+
operator: first.type === "text" ? "contains" : "equals",
|
|
443
|
+
value: ""
|
|
444
|
+
}
|
|
445
|
+
]);
|
|
446
|
+
},
|
|
447
|
+
children: labels.add
|
|
448
|
+
}
|
|
449
|
+
)
|
|
450
|
+
}
|
|
451
|
+
)
|
|
452
|
+
] });
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// src/data-explorer/data-explorer.tsx
|
|
456
|
+
import { Button as Button2 } from "@gridui/button";
|
|
457
|
+
import { Checkbox } from "@gridui/choice";
|
|
458
|
+
import { Split } from "@gridui/grid";
|
|
459
|
+
import { Input as Input2 } from "@gridui/input";
|
|
460
|
+
import { Select as Select2 } from "@gridui/select";
|
|
85
461
|
import { cn } from "@gridui/style-utils";
|
|
86
462
|
import { DataTable } from "@gridui/table";
|
|
87
|
-
import { Children } from "react";
|
|
88
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
463
|
+
import { Children, useId as useId2 } from "react";
|
|
464
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
89
465
|
var DataExplorer = (props) => {
|
|
90
466
|
const {
|
|
91
467
|
rows,
|
|
@@ -93,6 +469,10 @@ var DataExplorer = (props) => {
|
|
|
93
469
|
state,
|
|
94
470
|
onStateChange,
|
|
95
471
|
filter,
|
|
472
|
+
columnSettings,
|
|
473
|
+
columnSizing,
|
|
474
|
+
details,
|
|
475
|
+
filtering,
|
|
96
476
|
pageSize = 10,
|
|
97
477
|
selectedIds = [],
|
|
98
478
|
onSelectionChange,
|
|
@@ -104,6 +484,7 @@ var DataExplorer = (props) => {
|
|
|
104
484
|
className,
|
|
105
485
|
...restProps
|
|
106
486
|
} = props;
|
|
487
|
+
const tableId = useId2();
|
|
107
488
|
const hasNotice = Children.toArray(notice).some((child) => {
|
|
108
489
|
return child !== "";
|
|
109
490
|
});
|
|
@@ -128,17 +509,88 @@ var DataExplorer = (props) => {
|
|
|
128
509
|
});
|
|
129
510
|
}
|
|
130
511
|
};
|
|
131
|
-
const
|
|
512
|
+
const visibleColumns = columns.filter((column) => {
|
|
513
|
+
return !columnSettings?.hiddenKeys.includes(column.key);
|
|
514
|
+
});
|
|
515
|
+
if (columns.length > 0 && visibleColumns.length === 0) {
|
|
516
|
+
throw new RangeError("DataExplorer needs at least one visible column.");
|
|
517
|
+
}
|
|
518
|
+
const fixedWidths = columnSizing !== void 0 || visibleColumns.some((column) => {
|
|
519
|
+
return column.width !== void 0 || column.sticky !== void 0;
|
|
520
|
+
});
|
|
521
|
+
const widths = visibleColumns.map((column) => {
|
|
522
|
+
return resolveExplorerWidth(column, columnSizing?.widths[column.key] ?? column.width);
|
|
523
|
+
});
|
|
524
|
+
const tableColumns = visibleColumns.map((column, index) => {
|
|
525
|
+
const width = widths[index];
|
|
526
|
+
const stickyOffset = visibleColumns.reduce((offset, current, currentIndex) => {
|
|
527
|
+
return current.sticky === column.sticky && (column.sticky === "start" ? currentIndex < index : currentIndex > index) ? offset + widths[currentIndex] : offset;
|
|
528
|
+
}, 0);
|
|
132
529
|
return {
|
|
530
|
+
key: `column:${column.key}`,
|
|
133
531
|
label: column.label,
|
|
134
|
-
...column.numeric !== void 0 ? { numeric: column.numeric } : {}
|
|
532
|
+
...column.numeric !== void 0 ? { numeric: column.numeric } : {},
|
|
533
|
+
...fixedWidths ? {
|
|
534
|
+
sizing: {
|
|
535
|
+
width,
|
|
536
|
+
minWidth: width,
|
|
537
|
+
maxWidth: width
|
|
538
|
+
}
|
|
539
|
+
} : {},
|
|
540
|
+
...column.sticky ? {
|
|
541
|
+
sticky: column.sticky,
|
|
542
|
+
stickyOffset
|
|
543
|
+
} : {},
|
|
544
|
+
...columnSizing ? {
|
|
545
|
+
header: /* @__PURE__ */ jsxs2(
|
|
546
|
+
"div",
|
|
547
|
+
{
|
|
548
|
+
className: "gridui-u-flex gridui-u-min-w-0 gridui-u-items-center gridui-u-justify-between gridui-u-gap-gridui-8",
|
|
549
|
+
children: [
|
|
550
|
+
/* @__PURE__ */ jsx3("span", { children: column.label }),
|
|
551
|
+
/* @__PURE__ */ jsx3(
|
|
552
|
+
ColumnResizeHandle,
|
|
553
|
+
{
|
|
554
|
+
column,
|
|
555
|
+
width,
|
|
556
|
+
label: columnSizing.resizeLabel(column),
|
|
557
|
+
disabled: busy,
|
|
558
|
+
onChange: (nextWidth) => {
|
|
559
|
+
columnSizing.onWidthsChange({
|
|
560
|
+
...columnSizing.widths,
|
|
561
|
+
[column.key]: nextWidth
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
)
|
|
566
|
+
]
|
|
567
|
+
}
|
|
568
|
+
)
|
|
569
|
+
} : {}
|
|
135
570
|
};
|
|
136
571
|
});
|
|
137
572
|
if (onSelectionChange) {
|
|
138
|
-
tableColumns.unshift({
|
|
573
|
+
tableColumns.unshift({
|
|
574
|
+
key: "control:selection",
|
|
575
|
+
label: labels.selection,
|
|
576
|
+
...fixedWidths ? { sizing: { width: 56 } } : {}
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
if (details) {
|
|
580
|
+
tableColumns.unshift({
|
|
581
|
+
key: "control:details",
|
|
582
|
+
label: details.columnLabel,
|
|
583
|
+
...fixedWidths ? { sizing: { width: 96 } } : {}
|
|
584
|
+
});
|
|
139
585
|
}
|
|
586
|
+
const tableWidth = widths.reduce((total, width) => {
|
|
587
|
+
return total + width;
|
|
588
|
+
}, 0) + (onSelectionChange ? 56 : 0) + (details ? 96 : 0);
|
|
589
|
+
const detailId = (row) => {
|
|
590
|
+
return `${tableId}-details-${encodeURIComponent(row.id)}`;
|
|
591
|
+
};
|
|
140
592
|
const tableRows = view.rows.map((row) => {
|
|
141
|
-
const cells =
|
|
593
|
+
const cells = visibleColumns.map((column) => {
|
|
142
594
|
const value = row.values[column.key];
|
|
143
595
|
if (renderCell) {
|
|
144
596
|
return renderCell(value, row, column);
|
|
@@ -146,7 +598,7 @@ var DataExplorer = (props) => {
|
|
|
146
598
|
return value ?? "";
|
|
147
599
|
});
|
|
148
600
|
if (onSelectionChange) {
|
|
149
|
-
cells.unshift(/* @__PURE__ */
|
|
601
|
+
cells.unshift(/* @__PURE__ */ jsx3(
|
|
150
602
|
Checkbox,
|
|
151
603
|
{
|
|
152
604
|
"aria-label": labels.selectRow(row),
|
|
@@ -160,32 +612,56 @@ var DataExplorer = (props) => {
|
|
|
160
612
|
"select"
|
|
161
613
|
));
|
|
162
614
|
}
|
|
615
|
+
if (details) {
|
|
616
|
+
const expanded = details.expandedIds.includes(row.id);
|
|
617
|
+
cells.unshift(/* @__PURE__ */ jsx3(
|
|
618
|
+
Button2,
|
|
619
|
+
{
|
|
620
|
+
variant: "quiet",
|
|
621
|
+
disabled: busy,
|
|
622
|
+
"aria-expanded": expanded,
|
|
623
|
+
"aria-controls": expanded ? detailId(row) : void 0,
|
|
624
|
+
onClick: () => {
|
|
625
|
+
details.onExpandedIdsChange(expanded ? details.expandedIds.filter((key) => {
|
|
626
|
+
return key !== row.id;
|
|
627
|
+
}) : [
|
|
628
|
+
.../* @__PURE__ */ new Set([
|
|
629
|
+
...details.expandedIds,
|
|
630
|
+
row.id
|
|
631
|
+
])
|
|
632
|
+
]);
|
|
633
|
+
},
|
|
634
|
+
children: expanded ? details.collapseLabel(row) : details.expandLabel(row)
|
|
635
|
+
},
|
|
636
|
+
"details"
|
|
637
|
+
));
|
|
638
|
+
}
|
|
163
639
|
return cells;
|
|
164
640
|
});
|
|
165
|
-
return /* @__PURE__ */
|
|
641
|
+
return /* @__PURE__ */ jsx3(
|
|
166
642
|
"section",
|
|
167
643
|
{
|
|
168
644
|
...restProps,
|
|
169
645
|
"aria-label": labels.table,
|
|
170
646
|
className: cn(explorerStyles(), className),
|
|
171
|
-
children: /* @__PURE__ */
|
|
647
|
+
children: /* @__PURE__ */ jsxs2(
|
|
172
648
|
Split,
|
|
173
649
|
{
|
|
174
650
|
direction: "column",
|
|
175
651
|
children: [
|
|
176
|
-
/* @__PURE__ */
|
|
652
|
+
/* @__PURE__ */ jsxs2(
|
|
177
653
|
"div",
|
|
178
654
|
{
|
|
179
655
|
className: explorerToolbarStyles(),
|
|
180
656
|
children: [
|
|
181
|
-
/* @__PURE__ */
|
|
657
|
+
/* @__PURE__ */ jsxs2(
|
|
182
658
|
"label",
|
|
183
659
|
{
|
|
184
660
|
className: explorerLabelStyles(),
|
|
185
661
|
children: [
|
|
186
662
|
labels.search,
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
|
|
663
|
+
/* @__PURE__ */ jsx3(
|
|
664
|
+
Input2,
|
|
189
665
|
{
|
|
190
666
|
type: "search",
|
|
191
667
|
value: state.query,
|
|
@@ -201,14 +677,14 @@ var DataExplorer = (props) => {
|
|
|
201
677
|
]
|
|
202
678
|
}
|
|
203
679
|
),
|
|
204
|
-
filter && /* @__PURE__ */
|
|
680
|
+
filter && /* @__PURE__ */ jsxs2(
|
|
205
681
|
"label",
|
|
206
682
|
{
|
|
207
683
|
className: explorerLabelStyles(),
|
|
208
684
|
children: [
|
|
209
685
|
filter.label,
|
|
210
|
-
/* @__PURE__ */
|
|
211
|
-
|
|
686
|
+
/* @__PURE__ */ jsx3(
|
|
687
|
+
Select2,
|
|
212
688
|
{
|
|
213
689
|
"aria-label": filter.label,
|
|
214
690
|
value: state.filterValue,
|
|
@@ -231,14 +707,14 @@ var DataExplorer = (props) => {
|
|
|
231
707
|
]
|
|
232
708
|
}
|
|
233
709
|
),
|
|
234
|
-
/* @__PURE__ */
|
|
710
|
+
/* @__PURE__ */ jsxs2(
|
|
235
711
|
"label",
|
|
236
712
|
{
|
|
237
713
|
className: explorerLabelStyles(),
|
|
238
714
|
children: [
|
|
239
715
|
labels.sort,
|
|
240
|
-
/* @__PURE__ */
|
|
241
|
-
|
|
716
|
+
/* @__PURE__ */ jsx3(
|
|
717
|
+
Select2,
|
|
242
718
|
{
|
|
243
719
|
"aria-label": labels.sort,
|
|
244
720
|
value: state.sort?.key ?? "",
|
|
@@ -269,8 +745,8 @@ var DataExplorer = (props) => {
|
|
|
269
745
|
]
|
|
270
746
|
}
|
|
271
747
|
),
|
|
272
|
-
/* @__PURE__ */
|
|
273
|
-
|
|
748
|
+
/* @__PURE__ */ jsx3(
|
|
749
|
+
Button2,
|
|
274
750
|
{
|
|
275
751
|
variant: "secondary",
|
|
276
752
|
disabled: busy || !state.sort,
|
|
@@ -291,13 +767,78 @@ var DataExplorer = (props) => {
|
|
|
291
767
|
]
|
|
292
768
|
}
|
|
293
769
|
),
|
|
294
|
-
|
|
770
|
+
columnSettings && /* @__PURE__ */ jsxs2(
|
|
771
|
+
"details",
|
|
772
|
+
{
|
|
773
|
+
className: "gridui-u-p-gridui-16",
|
|
774
|
+
children: [
|
|
775
|
+
/* @__PURE__ */ jsx3(
|
|
776
|
+
"summary",
|
|
777
|
+
{
|
|
778
|
+
className: "gridui-u-cursor-pointer gridui-u-type-caption",
|
|
779
|
+
children: columnSettings.label
|
|
780
|
+
}
|
|
781
|
+
),
|
|
782
|
+
/* @__PURE__ */ jsx3(
|
|
783
|
+
"div",
|
|
784
|
+
{
|
|
785
|
+
className: "gridui-u-flex gridui-u-flex-wrap gridui-u-gap-gridui-16 gridui-u-pt-gridui-16",
|
|
786
|
+
children: columns.map((column) => {
|
|
787
|
+
const visible = !columnSettings.hiddenKeys.includes(column.key);
|
|
788
|
+
return /* @__PURE__ */ jsxs2(
|
|
789
|
+
"label",
|
|
790
|
+
{
|
|
791
|
+
className: "gridui-u-flex gridui-u-min-h-11 gridui-u-items-center gridui-u-gap-gridui-8",
|
|
792
|
+
children: [
|
|
793
|
+
/* @__PURE__ */ jsx3(
|
|
794
|
+
Checkbox,
|
|
795
|
+
{
|
|
796
|
+
checked: visible,
|
|
797
|
+
disabled: busy || visible && visibleColumns.length === 1,
|
|
798
|
+
onCheckedChange: (checked) => {
|
|
799
|
+
columnSettings.onHiddenKeysChange(checked ? columnSettings.hiddenKeys.filter((key) => {
|
|
800
|
+
return key !== column.key;
|
|
801
|
+
}) : [
|
|
802
|
+
.../* @__PURE__ */ new Set([
|
|
803
|
+
...columnSettings.hiddenKeys,
|
|
804
|
+
column.key
|
|
805
|
+
])
|
|
806
|
+
]);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
),
|
|
810
|
+
column.label
|
|
811
|
+
]
|
|
812
|
+
},
|
|
813
|
+
column.key
|
|
814
|
+
);
|
|
815
|
+
})
|
|
816
|
+
}
|
|
817
|
+
)
|
|
818
|
+
]
|
|
819
|
+
}
|
|
820
|
+
),
|
|
821
|
+
filtering && /* @__PURE__ */ jsx3(
|
|
822
|
+
FilterEditor,
|
|
823
|
+
{
|
|
824
|
+
filtering,
|
|
825
|
+
conditions: state.filters ?? [],
|
|
826
|
+
disabled: busy,
|
|
827
|
+
onChange: (filters) => {
|
|
828
|
+
updateState({
|
|
829
|
+
filters,
|
|
830
|
+
page: 0
|
|
831
|
+
});
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
),
|
|
835
|
+
onSelectionChange && /* @__PURE__ */ jsxs2(
|
|
295
836
|
"div",
|
|
296
837
|
{
|
|
297
838
|
className: explorerToolbarStyles(),
|
|
298
839
|
children: [
|
|
299
|
-
/* @__PURE__ */
|
|
300
|
-
/* @__PURE__ */
|
|
840
|
+
/* @__PURE__ */ jsxs2("label", { children: [
|
|
841
|
+
/* @__PURE__ */ jsx3(
|
|
301
842
|
Checkbox,
|
|
302
843
|
{
|
|
303
844
|
checked: pageIds.length > 0 && selectedPageCount === pageIds.length,
|
|
@@ -311,7 +852,7 @@ var DataExplorer = (props) => {
|
|
|
311
852
|
" ",
|
|
312
853
|
labels.selectPage
|
|
313
854
|
] }),
|
|
314
|
-
/* @__PURE__ */
|
|
855
|
+
/* @__PURE__ */ jsx3(
|
|
315
856
|
"span",
|
|
316
857
|
{
|
|
317
858
|
role: "status",
|
|
@@ -319,8 +860,8 @@ var DataExplorer = (props) => {
|
|
|
319
860
|
}
|
|
320
861
|
),
|
|
321
862
|
actions.map((action) => {
|
|
322
|
-
return /* @__PURE__ */
|
|
323
|
-
|
|
863
|
+
return /* @__PURE__ */ jsx3(
|
|
864
|
+
Button2,
|
|
324
865
|
{
|
|
325
866
|
variant: "secondary",
|
|
326
867
|
disabled: busy || selectedRowIds.length === 0 || action.disabled,
|
|
@@ -335,14 +876,14 @@ var DataExplorer = (props) => {
|
|
|
335
876
|
]
|
|
336
877
|
}
|
|
337
878
|
),
|
|
338
|
-
hasNotice && /* @__PURE__ */
|
|
339
|
-
/* @__PURE__ */
|
|
879
|
+
hasNotice && /* @__PURE__ */ jsx3("div", { children: notice }),
|
|
880
|
+
/* @__PURE__ */ jsxs2(
|
|
340
881
|
Split,
|
|
341
882
|
{
|
|
342
883
|
direction: "column",
|
|
343
884
|
"aria-busy": busy,
|
|
344
885
|
children: [
|
|
345
|
-
/* @__PURE__ */
|
|
886
|
+
/* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3(
|
|
346
887
|
DataTable,
|
|
347
888
|
{
|
|
348
889
|
label: labels.table,
|
|
@@ -351,10 +892,25 @@ var DataExplorer = (props) => {
|
|
|
351
892
|
inlineEdges: "none",
|
|
352
893
|
columns: tableColumns,
|
|
353
894
|
rows: tableRows,
|
|
354
|
-
rowKeys: pageIds
|
|
895
|
+
rowKeys: pageIds,
|
|
896
|
+
...fixedWidths ? {
|
|
897
|
+
style: {
|
|
898
|
+
width: tableWidth,
|
|
899
|
+
tableLayout: "fixed"
|
|
900
|
+
},
|
|
901
|
+
minWidth: tableWidth
|
|
902
|
+
} : {},
|
|
903
|
+
...details ? {
|
|
904
|
+
rowDetails: view.rows.map((row) => {
|
|
905
|
+
return details.expandedIds.includes(row.id) ? {
|
|
906
|
+
id: detailId(row),
|
|
907
|
+
content: details.render(row)
|
|
908
|
+
} : null;
|
|
909
|
+
})
|
|
910
|
+
} : {}
|
|
355
911
|
}
|
|
356
912
|
) }),
|
|
357
|
-
view.rows.length === 0 && !busy && /* @__PURE__ */
|
|
913
|
+
view.rows.length === 0 && !busy && /* @__PURE__ */ jsx3("div", { children: /* @__PURE__ */ jsx3(
|
|
358
914
|
"p",
|
|
359
915
|
{
|
|
360
916
|
className: "gridui-u-m-0 gridui-u-p-gridui-16",
|
|
@@ -364,13 +920,13 @@ var DataExplorer = (props) => {
|
|
|
364
920
|
]
|
|
365
921
|
}
|
|
366
922
|
),
|
|
367
|
-
/* @__PURE__ */
|
|
923
|
+
/* @__PURE__ */ jsxs2(
|
|
368
924
|
"div",
|
|
369
925
|
{
|
|
370
926
|
className: explorerFooterStyles(),
|
|
371
927
|
children: [
|
|
372
|
-
/* @__PURE__ */
|
|
373
|
-
|
|
928
|
+
/* @__PURE__ */ jsx3(
|
|
929
|
+
Button2,
|
|
374
930
|
{
|
|
375
931
|
variant: "secondary",
|
|
376
932
|
disabled: busy || view.page === 0,
|
|
@@ -380,15 +936,15 @@ var DataExplorer = (props) => {
|
|
|
380
936
|
children: labels.previous
|
|
381
937
|
}
|
|
382
938
|
),
|
|
383
|
-
/* @__PURE__ */
|
|
939
|
+
/* @__PURE__ */ jsx3(
|
|
384
940
|
"span",
|
|
385
941
|
{
|
|
386
942
|
role: "status",
|
|
387
943
|
children: labels.page(view.page + 1, view.pageCount, view.total)
|
|
388
944
|
}
|
|
389
945
|
),
|
|
390
|
-
/* @__PURE__ */
|
|
391
|
-
|
|
946
|
+
/* @__PURE__ */ jsx3(
|
|
947
|
+
Button2,
|
|
392
948
|
{
|
|
393
949
|
variant: "secondary",
|
|
394
950
|
disabled: busy || view.page + 1 >= view.pageCount,
|