@gridui/data-explorer 1.0.4 → 1.2.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/README.md +55 -2
- package/dist/data-explorer/data-explorer.d.ts +3 -37
- package/dist/data-explorer/style.d.ts +0 -3
- package/dist/data-explorer-bulk-actions/data-explorer-bulk-actions.d.ts +10 -0
- package/dist/data-explorer-pagination/data-explorer-pagination.d.ts +10 -0
- package/dist/data-explorer-table/column-resize-handle.d.ts +16 -0
- package/dist/data-explorer-table/data-explorer-table.d.ts +10 -0
- package/dist/data-explorer-toolbar/data-explorer-toolbar.d.ts +10 -0
- package/dist/data-explorer-toolbar/filter-editor.d.ts +16 -0
- package/dist/data-explorer-toolbar/style.d.ts +7 -0
- package/dist/index.d.ts +15 -5
- package/dist/index.js +919 -256
- package/dist/index.js.map +4 -4
- package/dist/shared/control-row-style.d.ts +7 -0
- package/dist/shared/explorer-context.d.ts +161 -0
- package/dist/shared/explorer-options.d.ts +51 -0
- package/dist/shared/features.d.ts +37 -0
- package/dist/{data-explorer → shared}/model.d.ts +24 -1
- package/dist/styles.css +31 -2
- package/docs/catalog.json +139 -0
- package/package.json +14 -12
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/shared/control-row-style.ts
|
|
2
|
+
import { cva } from "class-variance-authority";
|
|
3
|
+
var explorerControlRowStyles = cva("gridui-u-flex gridui-u-min-w-0 gridui-u-flex-wrap gridui-u-items-end gridui-u-gap-gridui-16 gridui-u-p-gridui-16 gridui-u-[&_label]:min-h-11");
|
|
4
|
+
|
|
5
|
+
// src/shared/model.ts
|
|
2
6
|
var compareValues = (left, right, direction) => {
|
|
3
7
|
if (left === null || left === void 0) {
|
|
4
8
|
return right === null || right === void 0 ? 0 : 1;
|
|
@@ -40,7 +44,9 @@ var selectExplorerRows = (rows, columns, state, pageSize, filter) => {
|
|
|
40
44
|
return cellText.includes(query);
|
|
41
45
|
});
|
|
42
46
|
const matchesFilter = !filter || !state.filterValue || String(row.values[filter.key] ?? "") === state.filterValue;
|
|
43
|
-
return matchesQuery && matchesFilter
|
|
47
|
+
return matchesQuery && matchesFilter && (state.filters ?? []).every((condition) => {
|
|
48
|
+
return matchesExplorerCondition(row, condition);
|
|
49
|
+
});
|
|
44
50
|
});
|
|
45
51
|
const sort = state.sort;
|
|
46
52
|
if (sort && columnKeys.includes(sort.key)) {
|
|
@@ -68,45 +74,51 @@ var selectExplorerPage = (selectedIds, pageIds, checked) => {
|
|
|
68
74
|
}
|
|
69
75
|
return [...selected];
|
|
70
76
|
};
|
|
77
|
+
var matchesExplorerCondition = (row, condition) => {
|
|
78
|
+
const value = row.values[condition.key];
|
|
79
|
+
if (condition.operator === "empty") {
|
|
80
|
+
return value === null || value === void 0 || value === "";
|
|
81
|
+
}
|
|
82
|
+
if (condition.value === void 0 || condition.value === "") {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
if (condition.operator === "contains") {
|
|
86
|
+
return String(value ?? "").normalize("NFKC").toLowerCase().includes(String(condition.value).normalize("NFKC").toLowerCase());
|
|
87
|
+
}
|
|
88
|
+
if (condition.operator === "equals") {
|
|
89
|
+
return value === condition.value;
|
|
90
|
+
}
|
|
91
|
+
if (condition.operator === "not-equals") {
|
|
92
|
+
return value !== condition.value;
|
|
93
|
+
}
|
|
94
|
+
if (typeof condition.value !== "number" || !Number.isFinite(condition.value)) {
|
|
95
|
+
throw new RangeError("Numeric filter comparisons require a finite numeric value.");
|
|
96
|
+
}
|
|
97
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return condition.operator === "greater-than" ? value > condition.value : value < condition.value;
|
|
101
|
+
};
|
|
102
|
+
var resolveExplorerWidth = (column, width = column.width ?? 200) => {
|
|
103
|
+
const min = column.minWidth ?? 80;
|
|
104
|
+
const max = column.maxWidth ?? 1200;
|
|
105
|
+
if (![
|
|
106
|
+
width,
|
|
107
|
+
min,
|
|
108
|
+
max
|
|
109
|
+
].every((value) => {
|
|
110
|
+
return Number.isFinite(value) && value > 0;
|
|
111
|
+
}) || max < min) {
|
|
112
|
+
throw new RangeError("Explorer column widths must be positive and finite with ordered bounds.");
|
|
113
|
+
}
|
|
114
|
+
return Math.max(min, Math.min(max, width));
|
|
115
|
+
};
|
|
71
116
|
|
|
72
|
-
// src/
|
|
73
|
-
import {
|
|
74
|
-
var
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
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
|
-
|
|
79
|
-
// src/data-explorer/data-explorer.tsx
|
|
80
|
-
import { Button } from "@gridui/button";
|
|
81
|
-
import { Checkbox } from "@gridui/choice";
|
|
82
|
-
import { Split } from "@gridui/grid";
|
|
83
|
-
import { Input } from "@gridui/input";
|
|
84
|
-
import { Select } from "@gridui/select";
|
|
85
|
-
import { cn } from "@gridui/style-utils";
|
|
86
|
-
import { DataTable } from "@gridui/table";
|
|
87
|
-
import { Children } from "react";
|
|
88
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
89
|
-
var DataExplorer = (props) => {
|
|
90
|
-
const {
|
|
91
|
-
rows,
|
|
92
|
-
columns,
|
|
93
|
-
state,
|
|
94
|
-
onStateChange,
|
|
95
|
-
filter,
|
|
96
|
-
pageSize = 10,
|
|
97
|
-
selectedIds = [],
|
|
98
|
-
onSelectionChange,
|
|
99
|
-
actions = [],
|
|
100
|
-
renderCell,
|
|
101
|
-
busy = false,
|
|
102
|
-
notice,
|
|
103
|
-
labels,
|
|
104
|
-
className,
|
|
105
|
-
...restProps
|
|
106
|
-
} = props;
|
|
107
|
-
const hasNotice = Children.toArray(notice).some((child) => {
|
|
108
|
-
return child !== "";
|
|
109
|
-
});
|
|
117
|
+
// src/shared/explorer-context.ts
|
|
118
|
+
import { createContext, useContext, useId } from "react";
|
|
119
|
+
var useExplorerController = (options) => {
|
|
120
|
+
const { rows, columns, state, onStateChange, filter, pageSize = 10, selectedIds = [], busy = false, columnSettings } = options;
|
|
121
|
+
const tableId = useId();
|
|
110
122
|
const view = selectExplorerRows(rows, columns, state, pageSize, filter);
|
|
111
123
|
const existingRowIds = new Set(rows.map((row) => {
|
|
112
124
|
return row.id;
|
|
@@ -128,17 +140,350 @@ var DataExplorer = (props) => {
|
|
|
128
140
|
});
|
|
129
141
|
}
|
|
130
142
|
};
|
|
131
|
-
const
|
|
143
|
+
const visibleColumns = columns.filter((column) => {
|
|
144
|
+
return !columnSettings?.hiddenKeys.includes(column.key);
|
|
145
|
+
});
|
|
146
|
+
if (columns.length > 0 && visibleColumns.length === 0) {
|
|
147
|
+
throw new RangeError("DataExplorer needs at least one visible column.");
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
...options,
|
|
151
|
+
busy,
|
|
152
|
+
tableId,
|
|
153
|
+
view,
|
|
154
|
+
selectedRowIds,
|
|
155
|
+
pageIds,
|
|
156
|
+
selectedPageCount,
|
|
157
|
+
updateState,
|
|
158
|
+
visibleColumns
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
var explorerContext = createContext(null);
|
|
162
|
+
var useExplorer = () => {
|
|
163
|
+
const explorer = useContext(explorerContext);
|
|
164
|
+
if (!explorer) {
|
|
165
|
+
throw new Error("DataExplorer parts require a DataExplorer.");
|
|
166
|
+
}
|
|
167
|
+
return explorer;
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/data-explorer-bulk-actions/data-explorer-bulk-actions.tsx
|
|
171
|
+
import { Button } from "@gridui/button";
|
|
172
|
+
import { Checkbox } from "@gridui/choice";
|
|
173
|
+
import { cn } from "@gridui/style-utils";
|
|
174
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
175
|
+
var DataExplorerBulkActions = (props) => {
|
|
176
|
+
const { actions = [], busy, labels, onSelectionChange, pageIds, selectedPageCount, selectedRowIds } = useExplorer();
|
|
177
|
+
if (!onSelectionChange) {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
return /* @__PURE__ */ jsxs(
|
|
181
|
+
"div",
|
|
182
|
+
{
|
|
183
|
+
className: cn(explorerControlRowStyles(), props.className),
|
|
184
|
+
children: [
|
|
185
|
+
/* @__PURE__ */ jsxs("label", { children: [
|
|
186
|
+
/* @__PURE__ */ jsx(
|
|
187
|
+
Checkbox,
|
|
188
|
+
{
|
|
189
|
+
checked: pageIds.length > 0 && selectedPageCount === pageIds.length,
|
|
190
|
+
indeterminate: selectedPageCount > 0 && selectedPageCount < pageIds.length,
|
|
191
|
+
disabled: busy || pageIds.length === 0,
|
|
192
|
+
onCheckedChange: (checked) => {
|
|
193
|
+
onSelectionChange(selectExplorerPage(selectedRowIds, pageIds, checked));
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
),
|
|
197
|
+
" ",
|
|
198
|
+
labels.selectPage
|
|
199
|
+
] }),
|
|
200
|
+
/* @__PURE__ */ jsx(
|
|
201
|
+
"span",
|
|
202
|
+
{
|
|
203
|
+
role: "status",
|
|
204
|
+
children: labels.selected(selectedRowIds.length)
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
actions.map((action) => {
|
|
208
|
+
return /* @__PURE__ */ jsx(
|
|
209
|
+
Button,
|
|
210
|
+
{
|
|
211
|
+
variant: "secondary",
|
|
212
|
+
disabled: busy || selectedRowIds.length === 0 || action.disabled,
|
|
213
|
+
onClick: () => {
|
|
214
|
+
action.onAction(selectedRowIds);
|
|
215
|
+
},
|
|
216
|
+
children: action.label
|
|
217
|
+
},
|
|
218
|
+
action.label
|
|
219
|
+
);
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/data-explorer-pagination/data-explorer-pagination.tsx
|
|
227
|
+
import { Button as Button2 } from "@gridui/button";
|
|
228
|
+
import { cn as cn2 } from "@gridui/style-utils";
|
|
229
|
+
import { cva as cva2 } from "class-variance-authority";
|
|
230
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
231
|
+
var explorerFooterStyles = cva2("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");
|
|
232
|
+
var DataExplorerPagination = (props) => {
|
|
233
|
+
const { busy, labels, updateState, view } = useExplorer();
|
|
234
|
+
return /* @__PURE__ */ jsxs2(
|
|
235
|
+
"div",
|
|
236
|
+
{
|
|
237
|
+
className: cn2(explorerFooterStyles(), props.className),
|
|
238
|
+
children: [
|
|
239
|
+
/* @__PURE__ */ jsx2(
|
|
240
|
+
Button2,
|
|
241
|
+
{
|
|
242
|
+
variant: "secondary",
|
|
243
|
+
disabled: busy || view.page === 0,
|
|
244
|
+
onClick: () => {
|
|
245
|
+
updateState({ page: view.page - 1 });
|
|
246
|
+
},
|
|
247
|
+
children: labels.previous
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx2(
|
|
251
|
+
"span",
|
|
252
|
+
{
|
|
253
|
+
role: "status",
|
|
254
|
+
children: labels.page(view.page + 1, view.pageCount, view.total)
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ jsx2(
|
|
258
|
+
Button2,
|
|
259
|
+
{
|
|
260
|
+
variant: "secondary",
|
|
261
|
+
disabled: busy || view.page + 1 >= view.pageCount,
|
|
262
|
+
onClick: () => {
|
|
263
|
+
updateState({ page: view.page + 1 });
|
|
264
|
+
},
|
|
265
|
+
children: labels.next
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
]
|
|
269
|
+
}
|
|
270
|
+
);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// src/data-explorer-table/column-resize-handle.tsx
|
|
274
|
+
import { isComposingKeyEvent, listenForDragCancellation } from "@gridui/interaction";
|
|
275
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
276
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
277
|
+
var ColumnResizeHandle = (props) => {
|
|
278
|
+
const { column, width, label, disabled, onChange } = props;
|
|
279
|
+
const handle = useRef(null);
|
|
280
|
+
const drag = useRef(null);
|
|
281
|
+
const min = column.minWidth ?? 80;
|
|
282
|
+
const max = column.maxWidth ?? 1200;
|
|
283
|
+
const change = (next) => {
|
|
284
|
+
onChange(resolveExplorerWidth(column, Math.max(min, Math.min(max, next))));
|
|
285
|
+
};
|
|
286
|
+
const cancelDrag = () => {
|
|
287
|
+
const current = drag.current;
|
|
288
|
+
drag.current = null;
|
|
289
|
+
if (current) {
|
|
290
|
+
current.cleanup();
|
|
291
|
+
change(current.width);
|
|
292
|
+
if (handle.current?.hasPointerCapture(current.pointer)) {
|
|
293
|
+
handle.current.releasePointerCapture(current.pointer);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
const cancelLatest = useRef(cancelDrag);
|
|
298
|
+
useLayoutEffect(() => {
|
|
299
|
+
cancelLatest.current = cancelDrag;
|
|
300
|
+
});
|
|
301
|
+
useEffect(() => {
|
|
302
|
+
if (disabled) {
|
|
303
|
+
cancelLatest.current();
|
|
304
|
+
}
|
|
305
|
+
}, [disabled]);
|
|
306
|
+
useEffect(() => {
|
|
307
|
+
const element = handle.current;
|
|
308
|
+
return () => {
|
|
309
|
+
const current = drag.current;
|
|
310
|
+
drag.current = null;
|
|
311
|
+
current?.cleanup();
|
|
312
|
+
if (current && element?.hasPointerCapture(current.pointer)) {
|
|
313
|
+
element.releasePointerCapture(current.pointer);
|
|
314
|
+
}
|
|
315
|
+
};
|
|
316
|
+
}, []);
|
|
317
|
+
return /* @__PURE__ */ jsx3(
|
|
318
|
+
"div",
|
|
319
|
+
{
|
|
320
|
+
ref: handle,
|
|
321
|
+
role: "separator",
|
|
322
|
+
tabIndex: disabled ? -1 : 0,
|
|
323
|
+
"aria-orientation": "vertical",
|
|
324
|
+
"aria-label": label,
|
|
325
|
+
"aria-valuemin": min,
|
|
326
|
+
"aria-valuemax": max,
|
|
327
|
+
"aria-valuenow": width,
|
|
328
|
+
"aria-disabled": disabled || void 0,
|
|
329
|
+
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",
|
|
330
|
+
onPointerDown: (event) => {
|
|
331
|
+
if (disabled || event.button !== 0 || !event.isPrimary || drag.current) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
event.preventDefault();
|
|
335
|
+
event.currentTarget.focus();
|
|
336
|
+
drag.current = {
|
|
337
|
+
pointer: event.pointerId,
|
|
338
|
+
x: event.clientX,
|
|
339
|
+
width,
|
|
340
|
+
direction: getComputedStyle(event.currentTarget).direction === "rtl" ? -1 : 1,
|
|
341
|
+
cleanup: listenForDragCancellation(event.currentTarget, () => {
|
|
342
|
+
cancelLatest.current();
|
|
343
|
+
})
|
|
344
|
+
};
|
|
345
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
346
|
+
},
|
|
347
|
+
onPointerMove: (event) => {
|
|
348
|
+
const current = drag.current;
|
|
349
|
+
if (!disabled && current?.pointer === event.pointerId) {
|
|
350
|
+
change(current.width + (event.clientX - current.x) * current.direction);
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
onPointerUp: (event) => {
|
|
354
|
+
if (drag.current?.pointer === event.pointerId) {
|
|
355
|
+
const current = drag.current;
|
|
356
|
+
drag.current = null;
|
|
357
|
+
current.cleanup();
|
|
358
|
+
if (event.currentTarget.hasPointerCapture(event.pointerId)) {
|
|
359
|
+
event.currentTarget.releasePointerCapture(event.pointerId);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
},
|
|
363
|
+
onPointerCancel: (event) => {
|
|
364
|
+
if (drag.current?.pointer === event.pointerId) {
|
|
365
|
+
cancelDrag();
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
onLostPointerCapture: (event) => {
|
|
369
|
+
if (drag.current?.pointer === event.pointerId) {
|
|
370
|
+
cancelDrag();
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
onKeyDown: (event) => {
|
|
374
|
+
if (disabled || isComposingKeyEvent(event.nativeEvent) || ![
|
|
375
|
+
"ArrowLeft",
|
|
376
|
+
"ArrowRight",
|
|
377
|
+
"Home",
|
|
378
|
+
"End"
|
|
379
|
+
].includes(event.key)) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
event.preventDefault();
|
|
383
|
+
const direction = getComputedStyle(event.currentTarget).direction === "rtl" ? -1 : 1;
|
|
384
|
+
const step = (event.shiftKey ? 50 : 10) * direction;
|
|
385
|
+
let next = width + (event.key === "ArrowRight" ? step : -step);
|
|
386
|
+
if (event.key === "Home") {
|
|
387
|
+
next = min;
|
|
388
|
+
}
|
|
389
|
+
if (event.key === "End") {
|
|
390
|
+
next = max;
|
|
391
|
+
}
|
|
392
|
+
change(next);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
// src/data-explorer-table/data-explorer-table.tsx
|
|
399
|
+
import { Button as Button3 } from "@gridui/button";
|
|
400
|
+
import { Checkbox as Checkbox2 } from "@gridui/choice";
|
|
401
|
+
import { Split } from "@gridui/grid";
|
|
402
|
+
import { cn as cn3 } from "@gridui/style-utils";
|
|
403
|
+
import { DataTable } from "@gridui/table";
|
|
404
|
+
import { Children } from "react";
|
|
405
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
406
|
+
var DataExplorerTable = (props) => {
|
|
407
|
+
const { busy, columnSizing, details, labels, notice, onSelectionChange, renderCell, selectedRowIds, tableId, view, visibleColumns } = useExplorer();
|
|
408
|
+
const hasNotice = Children.toArray(notice).some((child) => {
|
|
409
|
+
return child !== "";
|
|
410
|
+
});
|
|
411
|
+
const fixedWidths = columnSizing !== void 0 || visibleColumns.some((column) => {
|
|
412
|
+
return column.width !== void 0 || column.sticky !== void 0;
|
|
413
|
+
});
|
|
414
|
+
const widths = visibleColumns.map((column) => {
|
|
415
|
+
return resolveExplorerWidth(column, columnSizing?.widths[column.key] ?? column.width);
|
|
416
|
+
});
|
|
417
|
+
const tableColumns = visibleColumns.map((column, index) => {
|
|
418
|
+
const width = widths[index];
|
|
419
|
+
const stickyOffset = visibleColumns.reduce((offset, current, currentIndex) => {
|
|
420
|
+
return current.sticky === column.sticky && (column.sticky === "start" ? currentIndex < index : currentIndex > index) ? offset + widths[currentIndex] : offset;
|
|
421
|
+
}, 0);
|
|
132
422
|
return {
|
|
423
|
+
key: `column:${column.key}`,
|
|
133
424
|
label: column.label,
|
|
134
|
-
...column.numeric !== void 0 ? { numeric: column.numeric } : {}
|
|
425
|
+
...column.numeric !== void 0 ? { numeric: column.numeric } : {},
|
|
426
|
+
...fixedWidths ? {
|
|
427
|
+
sizing: {
|
|
428
|
+
width,
|
|
429
|
+
minWidth: width,
|
|
430
|
+
maxWidth: width
|
|
431
|
+
}
|
|
432
|
+
} : {},
|
|
433
|
+
...column.sticky ? {
|
|
434
|
+
sticky: column.sticky,
|
|
435
|
+
stickyOffset
|
|
436
|
+
} : {},
|
|
437
|
+
...columnSizing ? {
|
|
438
|
+
header: /* @__PURE__ */ jsxs3(
|
|
439
|
+
"div",
|
|
440
|
+
{
|
|
441
|
+
className: "gridui-u-flex gridui-u-min-w-0 gridui-u-items-center gridui-u-justify-between gridui-u-gap-gridui-8",
|
|
442
|
+
children: [
|
|
443
|
+
/* @__PURE__ */ jsx4("span", { children: column.label }),
|
|
444
|
+
/* @__PURE__ */ jsx4(
|
|
445
|
+
ColumnResizeHandle,
|
|
446
|
+
{
|
|
447
|
+
column,
|
|
448
|
+
width,
|
|
449
|
+
label: columnSizing.resizeLabel(column),
|
|
450
|
+
disabled: busy,
|
|
451
|
+
onChange: (nextWidth) => {
|
|
452
|
+
columnSizing.onWidthsChange({
|
|
453
|
+
...columnSizing.widths,
|
|
454
|
+
[column.key]: nextWidth
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
)
|
|
459
|
+
]
|
|
460
|
+
}
|
|
461
|
+
)
|
|
462
|
+
} : {}
|
|
135
463
|
};
|
|
136
464
|
});
|
|
137
465
|
if (onSelectionChange) {
|
|
138
|
-
tableColumns.unshift({
|
|
466
|
+
tableColumns.unshift({
|
|
467
|
+
key: "control:selection",
|
|
468
|
+
label: labels.selection,
|
|
469
|
+
...fixedWidths ? { sizing: { width: 56 } } : {}
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
if (details) {
|
|
473
|
+
tableColumns.unshift({
|
|
474
|
+
key: "control:details",
|
|
475
|
+
label: details.columnLabel,
|
|
476
|
+
...fixedWidths ? { sizing: { width: 96 } } : {}
|
|
477
|
+
});
|
|
139
478
|
}
|
|
479
|
+
const tableWidth = widths.reduce((total, width) => {
|
|
480
|
+
return total + width;
|
|
481
|
+
}, 0) + (onSelectionChange ? 56 : 0) + (details ? 96 : 0);
|
|
482
|
+
const detailId = (row) => {
|
|
483
|
+
return `${tableId}-details-${encodeURIComponent(row.id)}`;
|
|
484
|
+
};
|
|
140
485
|
const tableRows = view.rows.map((row) => {
|
|
141
|
-
const cells =
|
|
486
|
+
const cells = visibleColumns.map((column) => {
|
|
142
487
|
const value = row.values[column.key];
|
|
143
488
|
if (renderCell) {
|
|
144
489
|
return renderCell(value, row, column);
|
|
@@ -146,8 +491,8 @@ var DataExplorer = (props) => {
|
|
|
146
491
|
return value ?? "";
|
|
147
492
|
});
|
|
148
493
|
if (onSelectionChange) {
|
|
149
|
-
cells.unshift(/* @__PURE__ */
|
|
150
|
-
|
|
494
|
+
cells.unshift(/* @__PURE__ */ jsx4(
|
|
495
|
+
Checkbox2,
|
|
151
496
|
{
|
|
152
497
|
"aria-label": labels.selectRow(row),
|
|
153
498
|
checked: selectedRowIds.includes(row.id),
|
|
@@ -160,254 +505,572 @@ var DataExplorer = (props) => {
|
|
|
160
505
|
"select"
|
|
161
506
|
));
|
|
162
507
|
}
|
|
163
|
-
|
|
508
|
+
if (details) {
|
|
509
|
+
const expanded = details.expandedIds.includes(row.id);
|
|
510
|
+
cells.unshift(/* @__PURE__ */ jsx4(
|
|
511
|
+
Button3,
|
|
512
|
+
{
|
|
513
|
+
variant: "quiet",
|
|
514
|
+
disabled: busy,
|
|
515
|
+
"aria-expanded": expanded,
|
|
516
|
+
"aria-controls": expanded ? detailId(row) : void 0,
|
|
517
|
+
onClick: () => {
|
|
518
|
+
details.onExpandedIdsChange(expanded ? details.expandedIds.filter((key) => {
|
|
519
|
+
return key !== row.id;
|
|
520
|
+
}) : [
|
|
521
|
+
.../* @__PURE__ */ new Set([
|
|
522
|
+
...details.expandedIds,
|
|
523
|
+
row.id
|
|
524
|
+
])
|
|
525
|
+
]);
|
|
526
|
+
},
|
|
527
|
+
children: expanded ? details.collapseLabel(row) : details.expandLabel(row)
|
|
528
|
+
},
|
|
529
|
+
"details"
|
|
530
|
+
));
|
|
531
|
+
}
|
|
532
|
+
const detail = details?.expandedIds.includes(row.id) ? {
|
|
533
|
+
id: detailId(row),
|
|
534
|
+
content: details.render(row)
|
|
535
|
+
} : void 0;
|
|
536
|
+
return {
|
|
537
|
+
key: row.id,
|
|
538
|
+
cells,
|
|
539
|
+
...detail ? { detail } : {}
|
|
540
|
+
};
|
|
164
541
|
});
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
542
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
543
|
+
hasNotice && /* @__PURE__ */ jsx4("div", { children: notice }),
|
|
544
|
+
/* @__PURE__ */ jsxs3(
|
|
545
|
+
Split,
|
|
546
|
+
{
|
|
547
|
+
direction: "column",
|
|
548
|
+
"aria-busy": busy,
|
|
549
|
+
className: cn3(props.className),
|
|
550
|
+
children: [
|
|
551
|
+
/* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(
|
|
552
|
+
DataTable,
|
|
553
|
+
{
|
|
554
|
+
label: labels.table,
|
|
555
|
+
variant: "structured",
|
|
556
|
+
blockEdges: "none",
|
|
557
|
+
inlineEdges: "none",
|
|
558
|
+
columns: tableColumns,
|
|
559
|
+
rows: tableRows,
|
|
560
|
+
...fixedWidths ? {
|
|
561
|
+
style: {
|
|
562
|
+
width: tableWidth,
|
|
563
|
+
tableLayout: "fixed"
|
|
564
|
+
},
|
|
565
|
+
minWidth: tableWidth
|
|
566
|
+
} : {}
|
|
567
|
+
}
|
|
568
|
+
) }),
|
|
569
|
+
view.rows.length === 0 && !busy && /* @__PURE__ */ jsx4("div", { children: /* @__PURE__ */ jsx4(
|
|
570
|
+
"p",
|
|
571
|
+
{
|
|
572
|
+
className: "gridui-u-m-0 gridui-u-p-gridui-16",
|
|
573
|
+
children: labels.empty
|
|
574
|
+
}
|
|
575
|
+
) })
|
|
576
|
+
]
|
|
577
|
+
}
|
|
578
|
+
)
|
|
579
|
+
] });
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/data-explorer-toolbar/style.ts
|
|
583
|
+
import { cva as cva3 } from "class-variance-authority";
|
|
584
|
+
var explorerLabelStyles = cva3("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");
|
|
585
|
+
|
|
586
|
+
// src/data-explorer-toolbar/filter-editor.tsx
|
|
587
|
+
import { Button as Button4 } from "@gridui/button";
|
|
588
|
+
import { Input } from "@gridui/input";
|
|
589
|
+
import { Select } from "@gridui/select";
|
|
590
|
+
import { useId as useId2, useRef as useRef2 } from "react";
|
|
591
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
592
|
+
var FilterEditor = (props) => {
|
|
593
|
+
const { filtering, conditions, disabled, onChange } = props;
|
|
594
|
+
const id = useId2();
|
|
595
|
+
const sequence = useRef2(0);
|
|
596
|
+
const addButton = useRef2(null);
|
|
597
|
+
const { definitions, labels } = filtering;
|
|
598
|
+
const first = definitions[0];
|
|
599
|
+
const change = (index, condition) => {
|
|
600
|
+
onChange(conditions.map((current, currentIndex) => {
|
|
601
|
+
return currentIndex === index ? condition : current;
|
|
602
|
+
}));
|
|
603
|
+
};
|
|
604
|
+
return /* @__PURE__ */ jsxs4("div", { children: [
|
|
605
|
+
conditions.map((condition, index) => {
|
|
606
|
+
const definition = definitions.find((entry) => {
|
|
607
|
+
return entry.key === condition.key;
|
|
608
|
+
});
|
|
609
|
+
let operators = [
|
|
610
|
+
"contains",
|
|
611
|
+
"equals",
|
|
612
|
+
"not-equals",
|
|
613
|
+
"empty"
|
|
614
|
+
];
|
|
615
|
+
if (definition?.type === "number") {
|
|
616
|
+
operators = [
|
|
617
|
+
"equals",
|
|
618
|
+
"not-equals",
|
|
619
|
+
"greater-than",
|
|
620
|
+
"less-than",
|
|
621
|
+
"empty"
|
|
622
|
+
];
|
|
623
|
+
}
|
|
624
|
+
if (definition?.type === "enum") {
|
|
625
|
+
operators = [
|
|
626
|
+
"equals",
|
|
627
|
+
"not-equals",
|
|
628
|
+
"empty"
|
|
629
|
+
];
|
|
630
|
+
}
|
|
631
|
+
return /* @__PURE__ */ jsxs4(
|
|
632
|
+
"div",
|
|
173
633
|
{
|
|
174
|
-
|
|
634
|
+
className: explorerControlRowStyles(),
|
|
175
635
|
children: [
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
"
|
|
636
|
+
/* @__PURE__ */ jsxs4(
|
|
637
|
+
"label",
|
|
178
638
|
{
|
|
179
|
-
className:
|
|
639
|
+
className: explorerLabelStyles(),
|
|
180
640
|
children: [
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
className: explorerLabelStyles(),
|
|
185
|
-
children: [
|
|
186
|
-
labels.search,
|
|
187
|
-
/* @__PURE__ */ jsx(
|
|
188
|
-
Input,
|
|
189
|
-
{
|
|
190
|
-
type: "search",
|
|
191
|
-
value: state.query,
|
|
192
|
-
disabled: busy,
|
|
193
|
-
onValueChange: (query) => {
|
|
194
|
-
updateState({
|
|
195
|
-
query,
|
|
196
|
-
page: 0
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
)
|
|
201
|
-
]
|
|
202
|
-
}
|
|
203
|
-
),
|
|
204
|
-
filter && /* @__PURE__ */ jsxs(
|
|
205
|
-
"label",
|
|
206
|
-
{
|
|
207
|
-
className: explorerLabelStyles(),
|
|
208
|
-
children: [
|
|
209
|
-
filter.label,
|
|
210
|
-
/* @__PURE__ */ jsx(
|
|
211
|
-
Select,
|
|
212
|
-
{
|
|
213
|
-
"aria-label": filter.label,
|
|
214
|
-
value: state.filterValue,
|
|
215
|
-
disabled: busy,
|
|
216
|
-
options: [
|
|
217
|
-
{
|
|
218
|
-
value: "",
|
|
219
|
-
label: labels.all
|
|
220
|
-
},
|
|
221
|
-
...filter.options
|
|
222
|
-
],
|
|
223
|
-
onValueChange: (filterValue) => {
|
|
224
|
-
updateState({
|
|
225
|
-
filterValue,
|
|
226
|
-
page: 0
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
)
|
|
231
|
-
]
|
|
232
|
-
}
|
|
233
|
-
),
|
|
234
|
-
/* @__PURE__ */ jsxs(
|
|
235
|
-
"label",
|
|
641
|
+
labels.field,
|
|
642
|
+
/* @__PURE__ */ jsx5(
|
|
643
|
+
Select,
|
|
236
644
|
{
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
],
|
|
258
|
-
onValueChange: (key) => {
|
|
259
|
-
updateState({
|
|
260
|
-
sort: key ? {
|
|
261
|
-
key,
|
|
262
|
-
direction: "ascending"
|
|
263
|
-
} : null,
|
|
264
|
-
page: 0
|
|
265
|
-
});
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
)
|
|
269
|
-
]
|
|
270
|
-
}
|
|
271
|
-
),
|
|
272
|
-
/* @__PURE__ */ jsx(
|
|
273
|
-
Button,
|
|
274
|
-
{
|
|
275
|
-
variant: "secondary",
|
|
276
|
-
disabled: busy || !state.sort,
|
|
277
|
-
onClick: () => {
|
|
278
|
-
if (state.sort) {
|
|
279
|
-
updateState({
|
|
280
|
-
sort: {
|
|
281
|
-
...state.sort,
|
|
282
|
-
direction: state.sort.direction === "ascending" ? "descending" : "ascending"
|
|
283
|
-
},
|
|
284
|
-
page: 0
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
},
|
|
288
|
-
children: state.sort?.direction === "descending" ? labels.descending : labels.ascending
|
|
645
|
+
"aria-label": labels.field,
|
|
646
|
+
disabled,
|
|
647
|
+
value: condition.key,
|
|
648
|
+
options: definitions.map((field) => {
|
|
649
|
+
return {
|
|
650
|
+
value: field.key,
|
|
651
|
+
label: field.label
|
|
652
|
+
};
|
|
653
|
+
}),
|
|
654
|
+
onValueChange: (key) => {
|
|
655
|
+
const field = definitions.find((entry) => {
|
|
656
|
+
return entry.key === key;
|
|
657
|
+
});
|
|
658
|
+
change(index, {
|
|
659
|
+
id: condition.id,
|
|
660
|
+
key,
|
|
661
|
+
operator: field?.type === "text" ? "contains" : "equals",
|
|
662
|
+
value: ""
|
|
663
|
+
});
|
|
664
|
+
}
|
|
289
665
|
}
|
|
290
666
|
)
|
|
291
667
|
]
|
|
292
668
|
}
|
|
293
669
|
),
|
|
294
|
-
|
|
295
|
-
"
|
|
670
|
+
/* @__PURE__ */ jsxs4(
|
|
671
|
+
"label",
|
|
296
672
|
{
|
|
297
|
-
className:
|
|
673
|
+
className: explorerLabelStyles(),
|
|
298
674
|
children: [
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
675
|
+
labels.operator,
|
|
676
|
+
/* @__PURE__ */ jsx5(
|
|
677
|
+
Select,
|
|
678
|
+
{
|
|
679
|
+
"aria-label": labels.operator,
|
|
680
|
+
disabled,
|
|
681
|
+
value: condition.operator,
|
|
682
|
+
options: operators.map((operator) => {
|
|
683
|
+
return {
|
|
684
|
+
value: operator,
|
|
685
|
+
label: labels.operators[operator]
|
|
686
|
+
};
|
|
687
|
+
}),
|
|
688
|
+
onValueChange: (operator) => {
|
|
689
|
+
const next = operators.find((value) => {
|
|
690
|
+
return value === operator;
|
|
691
|
+
});
|
|
692
|
+
if (next) {
|
|
693
|
+
change(index, {
|
|
694
|
+
...condition,
|
|
695
|
+
operator: next
|
|
696
|
+
});
|
|
308
697
|
}
|
|
309
698
|
}
|
|
310
|
-
),
|
|
311
|
-
" ",
|
|
312
|
-
labels.selectPage
|
|
313
|
-
] }),
|
|
314
|
-
/* @__PURE__ */ jsx(
|
|
315
|
-
"span",
|
|
316
|
-
{
|
|
317
|
-
role: "status",
|
|
318
|
-
children: labels.selected(selectedRowIds.length)
|
|
319
699
|
}
|
|
320
|
-
)
|
|
321
|
-
actions.map((action) => {
|
|
322
|
-
return /* @__PURE__ */ jsx(
|
|
323
|
-
Button,
|
|
324
|
-
{
|
|
325
|
-
variant: "secondary",
|
|
326
|
-
disabled: busy || selectedRowIds.length === 0 || action.disabled,
|
|
327
|
-
onClick: () => {
|
|
328
|
-
action.onAction(selectedRowIds);
|
|
329
|
-
},
|
|
330
|
-
children: action.label
|
|
331
|
-
},
|
|
332
|
-
action.label
|
|
333
|
-
);
|
|
334
|
-
})
|
|
700
|
+
)
|
|
335
701
|
]
|
|
336
702
|
}
|
|
337
703
|
),
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
Split,
|
|
704
|
+
condition.operator !== "empty" && /* @__PURE__ */ jsxs4(
|
|
705
|
+
"label",
|
|
341
706
|
{
|
|
342
|
-
|
|
343
|
-
"aria-busy": busy,
|
|
707
|
+
className: explorerLabelStyles(),
|
|
344
708
|
children: [
|
|
345
|
-
|
|
346
|
-
|
|
709
|
+
labels.value,
|
|
710
|
+
definition?.type === "enum" ? /* @__PURE__ */ jsx5(
|
|
711
|
+
Select,
|
|
347
712
|
{
|
|
348
|
-
label: labels.
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
713
|
+
"aria-label": labels.value,
|
|
714
|
+
disabled,
|
|
715
|
+
value: String(condition.value ?? ""),
|
|
716
|
+
placeholder: labels.value,
|
|
717
|
+
options: definition.options ?? [],
|
|
718
|
+
onValueChange: (value) => {
|
|
719
|
+
change(index, {
|
|
720
|
+
...condition,
|
|
721
|
+
value
|
|
722
|
+
});
|
|
723
|
+
}
|
|
355
724
|
}
|
|
356
|
-
)
|
|
357
|
-
|
|
358
|
-
"p",
|
|
725
|
+
) : /* @__PURE__ */ jsx5(
|
|
726
|
+
Input,
|
|
359
727
|
{
|
|
360
|
-
|
|
361
|
-
|
|
728
|
+
"aria-label": labels.value,
|
|
729
|
+
disabled,
|
|
730
|
+
type: definition?.type === "number" ? "number" : "text",
|
|
731
|
+
value: condition.value ?? "",
|
|
732
|
+
onValueChange: (text) => {
|
|
733
|
+
const value = definition?.type === "number" && text !== "" ? Number(text) : text;
|
|
734
|
+
change(index, {
|
|
735
|
+
...condition,
|
|
736
|
+
value
|
|
737
|
+
});
|
|
738
|
+
}
|
|
362
739
|
}
|
|
363
|
-
)
|
|
740
|
+
)
|
|
364
741
|
]
|
|
365
742
|
}
|
|
366
743
|
),
|
|
367
|
-
/* @__PURE__ */
|
|
368
|
-
|
|
744
|
+
/* @__PURE__ */ jsx5(
|
|
745
|
+
Button4,
|
|
369
746
|
{
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
747
|
+
variant: "quiet",
|
|
748
|
+
disabled,
|
|
749
|
+
onClick: () => {
|
|
750
|
+
onChange(conditions.filter((entry) => {
|
|
751
|
+
return entry.id !== condition.id;
|
|
752
|
+
}));
|
|
753
|
+
addButton.current?.focus();
|
|
754
|
+
},
|
|
755
|
+
children: labels.remove(index)
|
|
756
|
+
}
|
|
757
|
+
)
|
|
758
|
+
]
|
|
759
|
+
},
|
|
760
|
+
condition.id
|
|
761
|
+
);
|
|
762
|
+
}),
|
|
763
|
+
/* @__PURE__ */ jsx5(
|
|
764
|
+
"div",
|
|
765
|
+
{
|
|
766
|
+
className: explorerControlRowStyles(),
|
|
767
|
+
children: /* @__PURE__ */ jsx5(
|
|
768
|
+
Button4,
|
|
769
|
+
{
|
|
770
|
+
ref: addButton,
|
|
771
|
+
variant: "secondary",
|
|
772
|
+
disabled: disabled || !first,
|
|
773
|
+
onClick: () => {
|
|
774
|
+
if (!first) {
|
|
775
|
+
return;
|
|
776
|
+
}
|
|
777
|
+
sequence.current += 1;
|
|
778
|
+
onChange([
|
|
779
|
+
...conditions,
|
|
780
|
+
{
|
|
781
|
+
id: `${id}-${sequence.current}`,
|
|
782
|
+
key: first.key,
|
|
783
|
+
operator: first.type === "text" ? "contains" : "equals",
|
|
784
|
+
value: ""
|
|
785
|
+
}
|
|
786
|
+
]);
|
|
787
|
+
},
|
|
788
|
+
children: labels.add
|
|
789
|
+
}
|
|
790
|
+
)
|
|
791
|
+
}
|
|
792
|
+
)
|
|
793
|
+
] });
|
|
794
|
+
};
|
|
795
|
+
|
|
796
|
+
// src/data-explorer-toolbar/data-explorer-toolbar.tsx
|
|
797
|
+
import { Button as Button5 } from "@gridui/button";
|
|
798
|
+
import { Checkbox as Checkbox3 } from "@gridui/choice";
|
|
799
|
+
import { Input as Input2 } from "@gridui/input";
|
|
800
|
+
import { Select as Select2 } from "@gridui/select";
|
|
801
|
+
import { cn as cn4 } from "@gridui/style-utils";
|
|
802
|
+
import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
803
|
+
var DataExplorerToolbar = (props) => {
|
|
804
|
+
const { busy, columnSettings, columns, filter, filtering, labels, state, updateState, visibleColumns } = useExplorer();
|
|
805
|
+
return /* @__PURE__ */ jsxs5(Fragment2, { children: [
|
|
806
|
+
/* @__PURE__ */ jsxs5(
|
|
807
|
+
"div",
|
|
808
|
+
{
|
|
809
|
+
className: cn4(explorerControlRowStyles(), props.className),
|
|
810
|
+
children: [
|
|
811
|
+
/* @__PURE__ */ jsxs5(
|
|
812
|
+
"label",
|
|
813
|
+
{
|
|
814
|
+
className: explorerLabelStyles(),
|
|
815
|
+
children: [
|
|
816
|
+
labels.search,
|
|
817
|
+
/* @__PURE__ */ jsx6(
|
|
818
|
+
Input2,
|
|
819
|
+
{
|
|
820
|
+
type: "search",
|
|
821
|
+
value: state.query,
|
|
822
|
+
disabled: busy,
|
|
823
|
+
onValueChange: (query) => {
|
|
824
|
+
updateState({
|
|
825
|
+
query,
|
|
826
|
+
page: 0
|
|
827
|
+
});
|
|
381
828
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
829
|
+
}
|
|
830
|
+
)
|
|
831
|
+
]
|
|
832
|
+
}
|
|
833
|
+
),
|
|
834
|
+
filter && /* @__PURE__ */ jsxs5(
|
|
835
|
+
"label",
|
|
836
|
+
{
|
|
837
|
+
className: explorerLabelStyles(),
|
|
838
|
+
children: [
|
|
839
|
+
filter.label,
|
|
840
|
+
/* @__PURE__ */ jsx6(
|
|
841
|
+
Select2,
|
|
842
|
+
{
|
|
843
|
+
"aria-label": filter.label,
|
|
844
|
+
value: state.filterValue,
|
|
845
|
+
disabled: busy,
|
|
846
|
+
options: [
|
|
847
|
+
{
|
|
848
|
+
value: "",
|
|
849
|
+
label: labels.all
|
|
850
|
+
},
|
|
851
|
+
...filter.options
|
|
852
|
+
],
|
|
853
|
+
onValueChange: (filterValue) => {
|
|
854
|
+
updateState({
|
|
855
|
+
filterValue,
|
|
856
|
+
page: 0
|
|
857
|
+
});
|
|
388
858
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
859
|
+
}
|
|
860
|
+
)
|
|
861
|
+
]
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
/* @__PURE__ */ jsxs5(
|
|
865
|
+
"label",
|
|
866
|
+
{
|
|
867
|
+
className: explorerLabelStyles(),
|
|
868
|
+
children: [
|
|
869
|
+
labels.sort,
|
|
870
|
+
/* @__PURE__ */ jsx6(
|
|
871
|
+
Select2,
|
|
872
|
+
{
|
|
873
|
+
"aria-label": labels.sort,
|
|
874
|
+
value: state.sort?.key ?? "",
|
|
875
|
+
disabled: busy,
|
|
876
|
+
options: [
|
|
877
|
+
{
|
|
878
|
+
value: "",
|
|
879
|
+
label: labels.unsorted
|
|
397
880
|
},
|
|
398
|
-
|
|
881
|
+
...columns.map((column) => {
|
|
882
|
+
return {
|
|
883
|
+
value: column.key,
|
|
884
|
+
label: column.label
|
|
885
|
+
};
|
|
886
|
+
})
|
|
887
|
+
],
|
|
888
|
+
onValueChange: (key) => {
|
|
889
|
+
updateState({
|
|
890
|
+
sort: key ? {
|
|
891
|
+
key,
|
|
892
|
+
direction: "ascending"
|
|
893
|
+
} : null,
|
|
894
|
+
page: 0
|
|
895
|
+
});
|
|
399
896
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
897
|
+
}
|
|
898
|
+
)
|
|
899
|
+
]
|
|
900
|
+
}
|
|
901
|
+
),
|
|
902
|
+
/* @__PURE__ */ jsx6(
|
|
903
|
+
Button5,
|
|
904
|
+
{
|
|
905
|
+
variant: "secondary",
|
|
906
|
+
disabled: busy || !state.sort,
|
|
907
|
+
onClick: () => {
|
|
908
|
+
if (state.sort) {
|
|
909
|
+
updateState({
|
|
910
|
+
sort: {
|
|
911
|
+
...state.sort,
|
|
912
|
+
direction: state.sort.direction === "ascending" ? "descending" : "ascending"
|
|
913
|
+
},
|
|
914
|
+
page: 0
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
},
|
|
918
|
+
children: state.sort?.direction === "descending" ? labels.descending : labels.ascending
|
|
919
|
+
}
|
|
920
|
+
)
|
|
921
|
+
]
|
|
922
|
+
}
|
|
923
|
+
),
|
|
924
|
+
columnSettings && /* @__PURE__ */ jsxs5(
|
|
925
|
+
"details",
|
|
926
|
+
{
|
|
927
|
+
className: "gridui-u-p-gridui-16",
|
|
928
|
+
children: [
|
|
929
|
+
/* @__PURE__ */ jsx6(
|
|
930
|
+
"summary",
|
|
931
|
+
{
|
|
932
|
+
className: "gridui-u-cursor-pointer gridui-u-type-caption",
|
|
933
|
+
children: columnSettings.label
|
|
934
|
+
}
|
|
935
|
+
),
|
|
936
|
+
/* @__PURE__ */ jsx6(
|
|
937
|
+
"div",
|
|
938
|
+
{
|
|
939
|
+
className: "gridui-u-flex gridui-u-flex-wrap gridui-u-gap-gridui-16 gridui-u-pt-gridui-16",
|
|
940
|
+
children: columns.map((column) => {
|
|
941
|
+
const visible = !columnSettings.hiddenKeys.includes(column.key);
|
|
942
|
+
return /* @__PURE__ */ jsxs5(
|
|
943
|
+
"label",
|
|
944
|
+
{
|
|
945
|
+
className: "gridui-u-flex gridui-u-min-h-11 gridui-u-items-center gridui-u-gap-gridui-8",
|
|
946
|
+
children: [
|
|
947
|
+
/* @__PURE__ */ jsx6(
|
|
948
|
+
Checkbox3,
|
|
949
|
+
{
|
|
950
|
+
checked: visible,
|
|
951
|
+
disabled: busy || visible && visibleColumns.length === 1,
|
|
952
|
+
onCheckedChange: (checked) => {
|
|
953
|
+
columnSettings.onHiddenKeysChange(checked ? columnSettings.hiddenKeys.filter((key) => {
|
|
954
|
+
return key !== column.key;
|
|
955
|
+
}) : [
|
|
956
|
+
.../* @__PURE__ */ new Set([
|
|
957
|
+
...columnSettings.hiddenKeys,
|
|
958
|
+
column.key
|
|
959
|
+
])
|
|
960
|
+
]);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
),
|
|
964
|
+
column.label
|
|
965
|
+
]
|
|
966
|
+
},
|
|
967
|
+
column.key
|
|
968
|
+
);
|
|
969
|
+
})
|
|
970
|
+
}
|
|
971
|
+
)
|
|
972
|
+
]
|
|
973
|
+
}
|
|
974
|
+
),
|
|
975
|
+
filtering && /* @__PURE__ */ jsx6(
|
|
976
|
+
FilterEditor,
|
|
977
|
+
{
|
|
978
|
+
filtering,
|
|
979
|
+
conditions: state.filters ?? [],
|
|
980
|
+
disabled: busy,
|
|
981
|
+
onChange: (filters) => {
|
|
982
|
+
updateState({
|
|
983
|
+
filters,
|
|
984
|
+
page: 0
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
)
|
|
989
|
+
] });
|
|
990
|
+
};
|
|
991
|
+
|
|
992
|
+
// src/data-explorer/style.ts
|
|
993
|
+
import { cva as cva4 } from "class-variance-authority";
|
|
994
|
+
var explorerStyles = cva4("gridui-u-min-w-0 gridui-u-border gridui-u-border-border gridui-u-bg-background gridui-u-text-foreground");
|
|
995
|
+
|
|
996
|
+
// src/data-explorer/data-explorer.tsx
|
|
997
|
+
import { Split as Split2 } from "@gridui/grid";
|
|
998
|
+
import { cn as cn5 } from "@gridui/style-utils";
|
|
999
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1000
|
+
var DataExplorer = (props) => {
|
|
1001
|
+
const {
|
|
1002
|
+
rows,
|
|
1003
|
+
columns,
|
|
1004
|
+
state,
|
|
1005
|
+
onStateChange,
|
|
1006
|
+
filter,
|
|
1007
|
+
columnSettings,
|
|
1008
|
+
columnSizing,
|
|
1009
|
+
details,
|
|
1010
|
+
filtering,
|
|
1011
|
+
pageSize,
|
|
1012
|
+
selectedIds,
|
|
1013
|
+
onSelectionChange,
|
|
1014
|
+
actions,
|
|
1015
|
+
renderCell,
|
|
1016
|
+
busy,
|
|
1017
|
+
notice,
|
|
1018
|
+
labels,
|
|
1019
|
+
className,
|
|
1020
|
+
children,
|
|
1021
|
+
...restProps
|
|
1022
|
+
} = props;
|
|
1023
|
+
const explorer = useExplorerController({
|
|
1024
|
+
rows,
|
|
1025
|
+
columns,
|
|
1026
|
+
state,
|
|
1027
|
+
onStateChange,
|
|
1028
|
+
filter,
|
|
1029
|
+
columnSettings,
|
|
1030
|
+
columnSizing,
|
|
1031
|
+
details,
|
|
1032
|
+
filtering,
|
|
1033
|
+
pageSize,
|
|
1034
|
+
selectedIds,
|
|
1035
|
+
onSelectionChange,
|
|
1036
|
+
actions,
|
|
1037
|
+
renderCell,
|
|
1038
|
+
busy,
|
|
1039
|
+
notice,
|
|
1040
|
+
labels
|
|
1041
|
+
});
|
|
1042
|
+
return /* @__PURE__ */ jsx7(
|
|
1043
|
+
explorerContext.Provider,
|
|
1044
|
+
{
|
|
1045
|
+
value: explorer,
|
|
1046
|
+
children: /* @__PURE__ */ jsx7(
|
|
1047
|
+
"section",
|
|
1048
|
+
{
|
|
1049
|
+
...restProps,
|
|
1050
|
+
"aria-label": labels.table,
|
|
1051
|
+
className: cn5(explorerStyles(), className),
|
|
1052
|
+
children: /* @__PURE__ */ jsx7(
|
|
1053
|
+
Split2,
|
|
1054
|
+
{
|
|
1055
|
+
direction: "column",
|
|
1056
|
+
children: children ?? /* @__PURE__ */ jsxs6(Fragment3, { children: [
|
|
1057
|
+
/* @__PURE__ */ jsx7(DataExplorerToolbar, {}),
|
|
1058
|
+
/* @__PURE__ */ jsx7(DataExplorerBulkActions, {}),
|
|
1059
|
+
/* @__PURE__ */ jsx7(DataExplorerTable, {}),
|
|
1060
|
+
/* @__PURE__ */ jsx7(DataExplorerPagination, {})
|
|
1061
|
+
] })
|
|
1062
|
+
}
|
|
1063
|
+
)
|
|
405
1064
|
}
|
|
406
1065
|
)
|
|
407
1066
|
}
|
|
408
1067
|
);
|
|
409
1068
|
};
|
|
410
1069
|
export {
|
|
411
|
-
DataExplorer
|
|
1070
|
+
DataExplorer,
|
|
1071
|
+
DataExplorerBulkActions,
|
|
1072
|
+
DataExplorerPagination,
|
|
1073
|
+
DataExplorerTable,
|
|
1074
|
+
DataExplorerToolbar
|
|
412
1075
|
};
|
|
413
1076
|
//# sourceMappingURL=index.js.map
|