@krak-stack/registry 0.10.11 → 0.10.13
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/CHANGELOG.md +25 -0
- package/dist/components/support-dialog.d.ts +49 -0
- package/dist/components/support-dialog.js +651 -0
- package/dist/components/ui/data-table.d.ts +14 -0
- package/dist/components/ui/data-table.js +353 -79
- package/dist/components/ui/pagination.js +1 -1
- package/dist/lib/query.d.ts +1 -0
- package/dist/lib/query.js +5 -3
- package/dist/services/events/browser.js +4 -3
- package/dist/services/events/client/audit-log-table.js +353 -79
- package/dist/services/events/index.js +4 -3
- package/dist/services/events/schema.js +4 -3
- package/dist/services/webhooks/client/delivery-table.js +353 -79
- package/dist/services/webhooks/index.js +4 -3
- package/dist/services/webhooks/schema.js +4 -3
- package/package.json +5 -1
|
@@ -4,7 +4,9 @@ import { Check as Check3, Clock, FileJson as FileJson2, X as X2 } from "lucide-r
|
|
|
4
4
|
|
|
5
5
|
// ../../src/components/ui/data-table.tsx
|
|
6
6
|
import { useAtom, useAtomSet } from "@effect/atom-react";
|
|
7
|
+
import { ScrollArea as ScrollAreaPrimitive2 } from "@base-ui/react/scroll-area";
|
|
7
8
|
import { BrowserKeyValueStore } from "@effect/platform-browser";
|
|
9
|
+
import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual";
|
|
8
10
|
import { DateTime as DateTime2, Effect as Effect2, Formatter, Option as Option2, Schema as Schema2, Stream } from "effect";
|
|
9
11
|
import { Csv } from "effect/encoding";
|
|
10
12
|
import { AsyncResult, Atom } from "effect/reactivity";
|
|
@@ -760,7 +762,7 @@ function Pagination({
|
|
|
760
762
|
page,
|
|
761
763
|
pageCount,
|
|
762
764
|
pageSize,
|
|
763
|
-
pageSizes = [
|
|
765
|
+
pageSizes = [20, 50, 100],
|
|
764
766
|
selectedRows = 0,
|
|
765
767
|
showResults = true,
|
|
766
768
|
totalRows
|
|
@@ -1168,14 +1170,15 @@ var ColumnFilters = Schema.declare(Schema.is(ColumnFiltersArray), {
|
|
|
1168
1170
|
toCodec: () => Schema.link()(ColumnFiltersArray, SchemaTransformation.passthrough()),
|
|
1169
1171
|
toCodecStringTree: () => Schema.link()(Schema.fromJsonString(ColumnFiltersArray), SchemaTransformation.passthrough())
|
|
1170
1172
|
});
|
|
1173
|
+
var DEFAULT_PAGE_SIZE = 100;
|
|
1171
1174
|
var Query = Schema.Struct({
|
|
1172
1175
|
page: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isGreaterThanOrEqualTo(0)), {
|
|
1173
1176
|
decode: SchemaGetter.withDefault(Effect.succeed(0)),
|
|
1174
1177
|
encode: SchemaGetter.transformOptional(Option.filter((page) => page !== 0))
|
|
1175
1178
|
})),
|
|
1176
1179
|
pageSize: Schema.optional(Schema.Union([Schema.Finite, Schema.FiniteFromString]).check(Schema.isInt(), Schema.isBetween({ minimum: 1, maximum: 100 }))).pipe(Schema.decodeTo(Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 100 })), {
|
|
1177
|
-
decode: SchemaGetter.withDefault(Effect.succeed(
|
|
1178
|
-
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !==
|
|
1180
|
+
decode: SchemaGetter.withDefault(Effect.succeed(DEFAULT_PAGE_SIZE)),
|
|
1181
|
+
encode: SchemaGetter.transformOptional(Option.filter((pageSize) => pageSize !== DEFAULT_PAGE_SIZE))
|
|
1179
1182
|
})),
|
|
1180
1183
|
globalFilter: Schema.optional(Schema.String),
|
|
1181
1184
|
sort: Schema.optional(SortParams),
|
|
@@ -1187,7 +1190,7 @@ var Query = Schema.Struct({
|
|
|
1187
1190
|
examples: [
|
|
1188
1191
|
{
|
|
1189
1192
|
page: 0,
|
|
1190
|
-
pageSize:
|
|
1193
|
+
pageSize: DEFAULT_PAGE_SIZE,
|
|
1191
1194
|
globalFilter: "housing",
|
|
1192
1195
|
sort: [
|
|
1193
1196
|
{ id: "publicName", direction: "desc" },
|
|
@@ -1413,7 +1416,7 @@ var DEFAULT_WIDTH = 208;
|
|
|
1413
1416
|
var DEFAULT_MAX_WIDTH = 640;
|
|
1414
1417
|
var DEFAULT_QUERY = {
|
|
1415
1418
|
page: 0,
|
|
1416
|
-
pageSize:
|
|
1419
|
+
pageSize: DEFAULT_PAGE_SIZE
|
|
1417
1420
|
};
|
|
1418
1421
|
var DEFAULT_UI_STATE = {
|
|
1419
1422
|
columnVisibility: {},
|
|
@@ -1799,7 +1802,7 @@ var buildDataTableModel = (store) => {
|
|
|
1799
1802
|
const selection = store.config.features.selection;
|
|
1800
1803
|
const rowId = selection && selection.getRowId || store.config.getRowId || undefined;
|
|
1801
1804
|
const rows = buildDataTableRows(store.rowData, columns, rowId);
|
|
1802
|
-
const pagination = store.config.features.pagination ??
|
|
1805
|
+
const pagination = store.config.features.pagination ?? false;
|
|
1803
1806
|
const server = pagination !== false && pagination.mode === "server";
|
|
1804
1807
|
const filteredRows = server ? [...rows] : filterDataTableColumnRows(filterDataTableRows(rows, columns, store.state.globalFilter ?? "", store.config.locale), columns, store.state.filters ?? []);
|
|
1805
1808
|
const sortedRows = server ? filteredRows : sortDataTableRows(filteredRows, columns, store.state.sort ?? []);
|
|
@@ -1812,7 +1815,7 @@ var buildDataTableModel = (store) => {
|
|
|
1812
1815
|
filteredRows,
|
|
1813
1816
|
sortedRows,
|
|
1814
1817
|
pageRows,
|
|
1815
|
-
pageCount: Math.max(1, Math.ceil(totalRows / Math.max(1, store.state.pageSize))),
|
|
1818
|
+
pageCount: pagination ? Math.max(1, Math.ceil(totalRows / Math.max(1, store.state.pageSize))) : 1,
|
|
1816
1819
|
totalRows
|
|
1817
1820
|
};
|
|
1818
1821
|
};
|
|
@@ -1846,7 +1849,13 @@ var groupDataTableRows = (rows, fields, depth = 0, parentKey = "") => {
|
|
|
1846
1849
|
const ids = field.getRowGroupIds?.(row.data) ?? [
|
|
1847
1850
|
field.getGroupId(row.data)
|
|
1848
1851
|
];
|
|
1849
|
-
ids.forEach((id) =>
|
|
1852
|
+
ids.forEach((id) => {
|
|
1853
|
+
const group = groups.get(id);
|
|
1854
|
+
if (group)
|
|
1855
|
+
group.push(row);
|
|
1856
|
+
else
|
|
1857
|
+
groups.set(id, [row]);
|
|
1858
|
+
});
|
|
1850
1859
|
});
|
|
1851
1860
|
return Array.from(groups, ([groupId, groupRows]) => {
|
|
1852
1861
|
const segment = `${encodeURIComponent(field.id)}:${encodeURIComponent(groupId)}`;
|
|
@@ -2056,20 +2065,18 @@ var DataTableRowActions = ({
|
|
|
2056
2065
|
});
|
|
2057
2066
|
};
|
|
2058
2067
|
var DataTableRowActionMenu = ({
|
|
2059
|
-
tableAtom
|
|
2068
|
+
tableAtom,
|
|
2069
|
+
row
|
|
2060
2070
|
}) => {
|
|
2061
2071
|
const [store] = useTableAtom(tableAtom);
|
|
2062
|
-
const rowId =
|
|
2063
|
-
const model = deriveModel(store);
|
|
2064
|
-
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
2065
|
-
if (!row)
|
|
2066
|
-
return null;
|
|
2072
|
+
const rowId = row.id;
|
|
2067
2073
|
const rowActions = store.config.features.rowActions || undefined;
|
|
2068
|
-
const visibleRows = model.pageRows;
|
|
2069
|
-
const rowIndex = visibleRows.findIndex((candidate) => candidate.id === rowId);
|
|
2070
2074
|
const reordering = store.config.features.reordering;
|
|
2071
2075
|
const reorderActions = [];
|
|
2072
2076
|
if (reordering && canReorderRows(store)) {
|
|
2077
|
+
const model = deriveModel(store);
|
|
2078
|
+
const visibleRows = model.pageRows;
|
|
2079
|
+
const rowIndex = visibleRows.findIndex((candidate) => candidate.id === rowId);
|
|
2073
2080
|
const move = (targetIndex) => reordering.onReorder(reorderDataTableRows(model.rows, rowId, visibleRows[targetIndex].id));
|
|
2074
2081
|
if (rowIndex > 0) {
|
|
2075
2082
|
reorderActions.push({
|
|
@@ -2136,7 +2143,7 @@ var DataTableToolbar = ({
|
|
|
2136
2143
|
}
|
|
2137
2144
|
};
|
|
2138
2145
|
return /* @__PURE__ */ jsxs9("div", {
|
|
2139
|
-
className: "
|
|
2146
|
+
className: cn("grid min-w-0 items-center gap-2 pb-4", features.search !== false && "md:grid-cols-[minmax(12rem,1fr)_minmax(0,auto)]"),
|
|
2140
2147
|
children: [
|
|
2141
2148
|
features.search !== false ? /* @__PURE__ */ jsxs9("div", {
|
|
2142
2149
|
className: "relative min-w-0",
|
|
@@ -2169,9 +2176,10 @@ var DataTableToolbar = ({
|
|
|
2169
2176
|
]
|
|
2170
2177
|
}) : null,
|
|
2171
2178
|
/* @__PURE__ */ jsx15("div", {
|
|
2172
|
-
className: "-m-1 flex overflow-x-auto p-1",
|
|
2179
|
+
className: "-m-1 flex min-w-0 overflow-x-auto p-1",
|
|
2173
2180
|
children: /* @__PURE__ */ jsxs9(Menubar2, {
|
|
2174
|
-
|
|
2181
|
+
modal: false,
|
|
2182
|
+
className: "border-input h-auto w-max min-w-full justify-start bg-transparent [&_[data-slot=menubar-trigger]]:gap-2 [&_[data-slot=menubar-trigger]_svg]:size-4",
|
|
2175
2183
|
children: [
|
|
2176
2184
|
visibleBulkActions.length ? /* @__PURE__ */ jsxs9(MenubarMenu, {
|
|
2177
2185
|
children: [
|
|
@@ -2333,7 +2341,7 @@ var DataTableToolbar = ({
|
|
|
2333
2341
|
}),
|
|
2334
2342
|
exportFeature && exportFailed ? /* @__PURE__ */ jsx15("p", {
|
|
2335
2343
|
role: "alert",
|
|
2336
|
-
className: "text-destructive text-sm",
|
|
2344
|
+
className: "text-destructive col-span-full text-sm",
|
|
2337
2345
|
children: labels.exportFailed ?? dataTableMessages(store.config.locale).exportFailed
|
|
2338
2346
|
}) : null
|
|
2339
2347
|
]
|
|
@@ -2614,6 +2622,7 @@ var FilterMenu = ({
|
|
|
2614
2622
|
children: [
|
|
2615
2623
|
/* @__PURE__ */ jsx15(ListFilter, {}),
|
|
2616
2624
|
/* @__PURE__ */ jsx15("span", {
|
|
2625
|
+
className: "hidden sm:inline",
|
|
2617
2626
|
children: store.config.labels.filters
|
|
2618
2627
|
}),
|
|
2619
2628
|
filters.length ? /* @__PURE__ */ jsx15(Badge, {
|
|
@@ -3070,18 +3079,20 @@ var toggleRow = (store, setStore, rowId, selected) => changeState(setStore, (sta
|
|
|
3070
3079
|
return { ...state, rowSelection };
|
|
3071
3080
|
});
|
|
3072
3081
|
var TableDataRow = ({
|
|
3073
|
-
tableAtom
|
|
3082
|
+
tableAtom,
|
|
3083
|
+
row,
|
|
3084
|
+
virtualIndex,
|
|
3085
|
+
measureRef
|
|
3074
3086
|
}) => {
|
|
3075
3087
|
const [store, setStore] = useTableAtom(tableAtom);
|
|
3076
|
-
const rowId = useRequiredId(RowIdContext);
|
|
3077
3088
|
const model = deriveModel(store);
|
|
3078
|
-
const row = model.sortedRows.find((candidate) => candidate.id === rowId);
|
|
3079
|
-
if (!row)
|
|
3080
|
-
return null;
|
|
3081
3089
|
const selection = store.config.features.selection;
|
|
3082
3090
|
const selectable = !!selection && (selection.isRowSelectable?.(row.data) ?? true);
|
|
3083
3091
|
const draggable = canDragRows(store);
|
|
3084
3092
|
return /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3093
|
+
ref: measureRef,
|
|
3094
|
+
"data-index": virtualIndex,
|
|
3095
|
+
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3085
3096
|
className: cn("group/row data-[drop-position=before]:[&>td]:border-primary data-[drop-position=after]:[&>td]:border-primary h-16 data-[drag-source=true]:opacity-40 data-[drop-position=after]:[&>td]:border-b-2 data-[drop-position=before]:[&>td]:border-t-2", store.config.onRowClicked && "cursor-pointer"),
|
|
3086
3097
|
"data-state": store.state.rowSelection[row.id] && "selected",
|
|
3087
3098
|
"data-table-row": row.id,
|
|
@@ -3124,6 +3135,7 @@ var TableDataRow = ({
|
|
|
3124
3135
|
children: /* @__PURE__ */ jsx15("div", {
|
|
3125
3136
|
className: "flex h-16 items-center justify-end pr-1",
|
|
3126
3137
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3138
|
+
row,
|
|
3127
3139
|
tableAtom
|
|
3128
3140
|
})
|
|
3129
3141
|
})
|
|
@@ -3173,70 +3185,88 @@ var GroupActions = ({
|
|
|
3173
3185
|
]
|
|
3174
3186
|
});
|
|
3175
3187
|
};
|
|
3188
|
+
var GroupHeaderRow = ({
|
|
3189
|
+
tableAtom,
|
|
3190
|
+
section,
|
|
3191
|
+
colSpan,
|
|
3192
|
+
virtualIndex,
|
|
3193
|
+
measureRef
|
|
3194
|
+
}) => {
|
|
3195
|
+
const [store, setStore] = useTableAtom(tableAtom);
|
|
3196
|
+
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3197
|
+
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3198
|
+
ref: measureRef,
|
|
3199
|
+
"data-index": virtualIndex,
|
|
3200
|
+
"aria-rowindex": virtualIndex === undefined ? undefined : virtualIndex + 2,
|
|
3201
|
+
className: "bg-muted/40 hover:bg-accent! cursor-pointer",
|
|
3202
|
+
onClick: () => changeState(setStore, (state) => ({
|
|
3203
|
+
...state,
|
|
3204
|
+
collapsedGroups: {
|
|
3205
|
+
...state.collapsedGroups,
|
|
3206
|
+
[section.key]: !collapsed
|
|
3207
|
+
}
|
|
3208
|
+
})),
|
|
3209
|
+
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3210
|
+
className: "p-0",
|
|
3211
|
+
colSpan,
|
|
3212
|
+
children: /* @__PURE__ */ jsxs9("div", {
|
|
3213
|
+
className: "sticky left-0 flex w-[100cqw] max-w-full items-center gap-2 py-2 pr-1 pl-2",
|
|
3214
|
+
children: [
|
|
3215
|
+
/* @__PURE__ */ jsxs9("button", {
|
|
3216
|
+
"aria-expanded": !collapsed,
|
|
3217
|
+
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left font-medium",
|
|
3218
|
+
style: { paddingLeft: section.depth * 20 },
|
|
3219
|
+
type: "button",
|
|
3220
|
+
children: [
|
|
3221
|
+
collapsed ? /* @__PURE__ */ jsx15(ChevronRight2, {
|
|
3222
|
+
className: "size-4 shrink-0"
|
|
3223
|
+
}) : /* @__PURE__ */ jsx15(ChevronDown, {
|
|
3224
|
+
className: "size-4 shrink-0"
|
|
3225
|
+
}),
|
|
3226
|
+
/* @__PURE__ */ jsx15("span", {
|
|
3227
|
+
className: "min-w-0 flex-1 truncate",
|
|
3228
|
+
children: section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.data)) ?? section.groupId
|
|
3229
|
+
})
|
|
3230
|
+
]
|
|
3231
|
+
}),
|
|
3232
|
+
/* @__PURE__ */ jsx15(Badge, {
|
|
3233
|
+
className: "shrink-0",
|
|
3234
|
+
variant: "secondary",
|
|
3235
|
+
children: section.rows.length
|
|
3236
|
+
}),
|
|
3237
|
+
/* @__PURE__ */ jsx15(GroupActions, {
|
|
3238
|
+
actions: section.field.actions,
|
|
3239
|
+
groupId: section.groupId,
|
|
3240
|
+
title: section.field.actionsLabel ?? store.config.labels.actions
|
|
3241
|
+
})
|
|
3242
|
+
]
|
|
3243
|
+
})
|
|
3244
|
+
})
|
|
3245
|
+
});
|
|
3246
|
+
};
|
|
3176
3247
|
var GroupedTable = ({
|
|
3177
3248
|
tableAtom,
|
|
3178
3249
|
sections
|
|
3179
3250
|
}) => {
|
|
3180
|
-
const [store
|
|
3251
|
+
const [store] = useTableAtom(tableAtom);
|
|
3181
3252
|
const model = deriveModel(store);
|
|
3182
3253
|
const extra = (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3183
3254
|
const renderSections = (items) => items.flatMap((section) => {
|
|
3184
3255
|
const collapsed = !!store.state.collapsedGroups[section.key];
|
|
3185
3256
|
const targetKey = getGroupDropKey(section.field.id, section.groupId);
|
|
3186
|
-
const toggleCollapsed = () => changeState(setStore, (state) => ({
|
|
3187
|
-
...state,
|
|
3188
|
-
collapsedGroups: {
|
|
3189
|
-
...state.collapsedGroups,
|
|
3190
|
-
[section.key]: !collapsed
|
|
3191
|
-
}
|
|
3192
|
-
}));
|
|
3193
3257
|
const body = /* @__PURE__ */ jsxs9(TableBody2, {
|
|
3194
3258
|
className: "data-[drop-target=true]:outline-primary relative data-[drop-target=true]:z-30 data-[drop-target=true]:outline-2 data-[drop-target=true]:-outline-offset-2 data-[drop-target=true]:[&>tr]:border-transparent data-[drop-target=true]:[&>tr>td:last-child]:z-0",
|
|
3195
3259
|
"data-table-group": section.field.onMoveToGroup ? targetKey : undefined,
|
|
3196
3260
|
children: [
|
|
3197
|
-
/* @__PURE__ */ jsx15(
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
className: "p-0",
|
|
3202
|
-
colSpan: model.visibleColumns.length + extra,
|
|
3203
|
-
children: /* @__PURE__ */ jsxs9("div", {
|
|
3204
|
-
className: "sticky left-0 flex w-[100cqw] max-w-full items-center gap-2 py-2 pr-1 pl-2",
|
|
3205
|
-
children: [
|
|
3206
|
-
/* @__PURE__ */ jsxs9("button", {
|
|
3207
|
-
"aria-expanded": !collapsed,
|
|
3208
|
-
className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 text-left font-medium",
|
|
3209
|
-
style: { paddingLeft: section.depth * 20 },
|
|
3210
|
-
type: "button",
|
|
3211
|
-
children: [
|
|
3212
|
-
collapsed ? /* @__PURE__ */ jsx15(ChevronRight2, {
|
|
3213
|
-
className: "size-4 shrink-0"
|
|
3214
|
-
}) : /* @__PURE__ */ jsx15(ChevronDown, {
|
|
3215
|
-
className: "size-4 shrink-0"
|
|
3216
|
-
}),
|
|
3217
|
-
/* @__PURE__ */ jsx15("span", {
|
|
3218
|
-
className: "min-w-0 flex-1 truncate",
|
|
3219
|
-
children: section.field.renderGroupLabel?.(section.groupId, section.rows.map((row) => row.data)) ?? section.groupId
|
|
3220
|
-
})
|
|
3221
|
-
]
|
|
3222
|
-
}),
|
|
3223
|
-
/* @__PURE__ */ jsx15(Badge, {
|
|
3224
|
-
className: "shrink-0",
|
|
3225
|
-
variant: "secondary",
|
|
3226
|
-
children: section.rows.length
|
|
3227
|
-
}),
|
|
3228
|
-
/* @__PURE__ */ jsx15(GroupActions, {
|
|
3229
|
-
actions: section.field.actions,
|
|
3230
|
-
groupId: section.groupId,
|
|
3231
|
-
title: section.field.actionsLabel ?? store.config.labels.actions
|
|
3232
|
-
})
|
|
3233
|
-
]
|
|
3234
|
-
})
|
|
3235
|
-
})
|
|
3261
|
+
/* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3262
|
+
tableAtom,
|
|
3263
|
+
section,
|
|
3264
|
+
colSpan: model.visibleColumns.length + extra
|
|
3236
3265
|
}),
|
|
3237
3266
|
!collapsed && !section.children.length ? section.rows.length ? section.rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3238
3267
|
value: row.id,
|
|
3239
3268
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3269
|
+
row,
|
|
3240
3270
|
tableAtom
|
|
3241
3271
|
})
|
|
3242
3272
|
}, `${section.key}:${row.id}`)) : [
|
|
@@ -3434,7 +3464,8 @@ var ColumnHeaderMenu = ({
|
|
|
3434
3464
|
});
|
|
3435
3465
|
};
|
|
3436
3466
|
var DataTableHeader = ({
|
|
3437
|
-
tableAtom
|
|
3467
|
+
tableAtom,
|
|
3468
|
+
sticky
|
|
3438
3469
|
}) => {
|
|
3439
3470
|
const [store, setStore] = useTableAtom(tableAtom);
|
|
3440
3471
|
const model = deriveModel(store);
|
|
@@ -3445,7 +3476,9 @@ var DataTableHeader = ({
|
|
|
3445
3476
|
const allSelected = selectableRows.length > 0 && selectableRows.every((row) => store.state.rowSelection[row.id]);
|
|
3446
3477
|
const someSelected = selectableRows.some((row) => store.state.rowSelection[row.id]);
|
|
3447
3478
|
return /* @__PURE__ */ jsx15(TableHeader2, {
|
|
3479
|
+
className: sticky ? "bg-background after:border-border sticky top-0 z-30 after:pointer-events-none after:absolute after:inset-x-0 after:bottom-0 after:border-b [&_tr]:border-b-0" : undefined,
|
|
3448
3480
|
children: /* @__PURE__ */ jsxs9(TableRow2, {
|
|
3481
|
+
"aria-rowindex": sticky ? 1 : undefined,
|
|
3449
3482
|
children: [
|
|
3450
3483
|
selection ? /* @__PURE__ */ jsx15(TableHead2, {
|
|
3451
3484
|
className: "w-10 pr-0",
|
|
@@ -3493,8 +3526,127 @@ var DataTableHeader = ({
|
|
|
3493
3526
|
})
|
|
3494
3527
|
});
|
|
3495
3528
|
};
|
|
3529
|
+
var VirtualTableRows = ({
|
|
3530
|
+
tableAtom,
|
|
3531
|
+
rows,
|
|
3532
|
+
sections,
|
|
3533
|
+
viewport,
|
|
3534
|
+
colSpan
|
|
3535
|
+
}) => {
|
|
3536
|
+
const [{ state, config }] = useTableAtom(tableAtom);
|
|
3537
|
+
const { element: scrollElement, headerHeight } = viewport;
|
|
3538
|
+
const pageScroll = viewport.options.scroll === "page";
|
|
3539
|
+
const scrollMargin = viewport.pageOffset ?? headerHeight;
|
|
3540
|
+
const entries = useMemo2(() => {
|
|
3541
|
+
const result = [];
|
|
3542
|
+
const addSections = (groups) => {
|
|
3543
|
+
for (const section of groups) {
|
|
3544
|
+
result.push({ key: `${section.key}/header`, kind: "header", section });
|
|
3545
|
+
if (state.collapsedGroups[section.key])
|
|
3546
|
+
continue;
|
|
3547
|
+
if (section.children.length)
|
|
3548
|
+
addSections(section.children);
|
|
3549
|
+
else if (section.rows.length) {
|
|
3550
|
+
for (const row of section.rows) {
|
|
3551
|
+
result.push({
|
|
3552
|
+
key: `${section.key}/row:${row.id}`,
|
|
3553
|
+
kind: "data",
|
|
3554
|
+
row
|
|
3555
|
+
});
|
|
3556
|
+
}
|
|
3557
|
+
} else
|
|
3558
|
+
result.push({ key: `${section.key}/empty`, kind: "empty", section });
|
|
3559
|
+
}
|
|
3560
|
+
};
|
|
3561
|
+
if (sections.length)
|
|
3562
|
+
addSections(sections);
|
|
3563
|
+
else
|
|
3564
|
+
for (const row of rows)
|
|
3565
|
+
result.push({ key: `row:${row.id}`, kind: "data", row });
|
|
3566
|
+
return result;
|
|
3567
|
+
}, [rows, sections, state.collapsedGroups]);
|
|
3568
|
+
useLayoutEffect(() => {
|
|
3569
|
+
if (!pageScroll && scrollElement)
|
|
3570
|
+
scrollElement.scrollTop = 0;
|
|
3571
|
+
}, [
|
|
3572
|
+
pageScroll,
|
|
3573
|
+
scrollElement,
|
|
3574
|
+
state.page,
|
|
3575
|
+
state.pageSize,
|
|
3576
|
+
state.globalFilter,
|
|
3577
|
+
state.filters,
|
|
3578
|
+
state.sort,
|
|
3579
|
+
state.grouping
|
|
3580
|
+
]);
|
|
3581
|
+
const options = {
|
|
3582
|
+
count: entries.length,
|
|
3583
|
+
getItemKey: useCallback((index) => entries[index].key, [entries]),
|
|
3584
|
+
estimateSize: () => viewport.options.estimateRowHeight ?? 64,
|
|
3585
|
+
overscan: viewport.options.overscan ?? 5,
|
|
3586
|
+
scrollMargin
|
|
3587
|
+
};
|
|
3588
|
+
const tableVirtualizer = useVirtualizer({
|
|
3589
|
+
...options,
|
|
3590
|
+
enabled: !pageScroll,
|
|
3591
|
+
getScrollElement: () => scrollElement,
|
|
3592
|
+
scrollPaddingStart: headerHeight
|
|
3593
|
+
});
|
|
3594
|
+
const pageVirtualizer = useWindowVirtualizer({
|
|
3595
|
+
...options,
|
|
3596
|
+
enabled: pageScroll && viewport.pageOffset !== undefined
|
|
3597
|
+
});
|
|
3598
|
+
const virtualizer = pageScroll ? pageVirtualizer : tableVirtualizer;
|
|
3599
|
+
const items = virtualizer.getVirtualItems();
|
|
3600
|
+
const first = items[0];
|
|
3601
|
+
const last = items.at(-1);
|
|
3602
|
+
const before = first ? first.start - scrollMargin : 0;
|
|
3603
|
+
const after = virtualizer.getTotalSize() - (last ? last.end - scrollMargin : 0);
|
|
3604
|
+
const spacer = (height) => height > 0 ? /* @__PURE__ */ jsx15("tr", {
|
|
3605
|
+
"aria-hidden": "true",
|
|
3606
|
+
children: /* @__PURE__ */ jsx15("td", {
|
|
3607
|
+
colSpan: Math.max(1, colSpan),
|
|
3608
|
+
className: "border-0 p-0",
|
|
3609
|
+
style: { height }
|
|
3610
|
+
})
|
|
3611
|
+
}) : null;
|
|
3612
|
+
return /* @__PURE__ */ jsxs9(Fragment, {
|
|
3613
|
+
children: [
|
|
3614
|
+
spacer(before),
|
|
3615
|
+
items.map(({ index, key }) => {
|
|
3616
|
+
const entry = entries[index];
|
|
3617
|
+
if (entry.kind === "data")
|
|
3618
|
+
return /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3619
|
+
measureRef: virtualizer.measureElement,
|
|
3620
|
+
row: entry.row,
|
|
3621
|
+
tableAtom,
|
|
3622
|
+
virtualIndex: index
|
|
3623
|
+
}, key);
|
|
3624
|
+
if (entry.kind === "header")
|
|
3625
|
+
return /* @__PURE__ */ jsx15(GroupHeaderRow, {
|
|
3626
|
+
measureRef: virtualizer.measureElement,
|
|
3627
|
+
section: entry.section,
|
|
3628
|
+
colSpan,
|
|
3629
|
+
tableAtom,
|
|
3630
|
+
virtualIndex: index
|
|
3631
|
+
}, key);
|
|
3632
|
+
return /* @__PURE__ */ jsx15(TableRow2, {
|
|
3633
|
+
ref: virtualizer.measureElement,
|
|
3634
|
+
"data-index": index,
|
|
3635
|
+
"aria-rowindex": index + 2,
|
|
3636
|
+
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3637
|
+
className: "text-muted-foreground h-16",
|
|
3638
|
+
colSpan,
|
|
3639
|
+
children: entry.section.field.renderEmptyGroup?.(entry.section.groupId) ?? config.labels.empty
|
|
3640
|
+
})
|
|
3641
|
+
}, key);
|
|
3642
|
+
}),
|
|
3643
|
+
spacer(after)
|
|
3644
|
+
]
|
|
3645
|
+
});
|
|
3646
|
+
};
|
|
3496
3647
|
var DataTableBody = ({
|
|
3497
|
-
tableAtom
|
|
3648
|
+
tableAtom,
|
|
3649
|
+
viewport
|
|
3498
3650
|
}) => {
|
|
3499
3651
|
const styles = useContext(DataTableStylesContext);
|
|
3500
3652
|
const [store] = useTableAtom(tableAtom);
|
|
@@ -3502,23 +3654,24 @@ var DataTableBody = ({
|
|
|
3502
3654
|
const fields = getActiveGrouping(store);
|
|
3503
3655
|
const grouped = fields.length > 0;
|
|
3504
3656
|
const rows = grouped ? model.sortedRows : model.pageRows;
|
|
3505
|
-
const sections = groupDataTableRows(rows, fields);
|
|
3657
|
+
const sections = useMemo2(() => groupDataTableRows(rows, fields), [rows, fields]);
|
|
3506
3658
|
const colSpan = model.visibleColumns.length + (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0);
|
|
3507
|
-
|
|
3659
|
+
const showGroups = sections.length && (rows.length || !store.config.status.loading) && !store.config.status.error;
|
|
3660
|
+
if (showGroups && !viewport) {
|
|
3508
3661
|
return /* @__PURE__ */ jsx15(GroupedTable, {
|
|
3509
3662
|
tableAtom,
|
|
3510
3663
|
sections
|
|
3511
3664
|
});
|
|
3512
3665
|
}
|
|
3513
3666
|
return /* @__PURE__ */ jsx15(TableBody2, {
|
|
3514
|
-
children: store.config.status.error || !rows.length && !store.config.status.loading ? /* @__PURE__ */ jsx15(TableRow2, {
|
|
3667
|
+
children: store.config.status.error || !showGroups && !rows.length && !store.config.status.loading ? /* @__PURE__ */ jsx15(TableRow2, {
|
|
3515
3668
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3516
3669
|
"data-table-slot": store.config.status.error ? "error" : "empty",
|
|
3517
3670
|
className: cn("h-24 text-center", store.config.status.error ? styles?.feedback?.error : styles?.feedback?.empty),
|
|
3518
3671
|
colSpan: Math.max(colSpan, 1),
|
|
3519
3672
|
children: store.config.status.error ?? store.config.status.empty ?? store.config.labels.empty
|
|
3520
3673
|
})
|
|
3521
|
-
}) : store.config.status.loading && !rows.length ? /* @__PURE__ */ jsx15(TableRow2, {
|
|
3674
|
+
}) : !showGroups && store.config.status.loading && !rows.length ? /* @__PURE__ */ jsx15(TableRow2, {
|
|
3522
3675
|
children: /* @__PURE__ */ jsx15(TableCell2, {
|
|
3523
3676
|
"data-table-slot": "loading",
|
|
3524
3677
|
className: cn("h-24 p-0", styles?.feedback?.loading),
|
|
@@ -3528,9 +3681,16 @@ var DataTableBody = ({
|
|
|
3528
3681
|
label: store.config.labels.loading
|
|
3529
3682
|
})
|
|
3530
3683
|
})
|
|
3684
|
+
}) : viewport ? /* @__PURE__ */ jsx15(VirtualTableRows, {
|
|
3685
|
+
colSpan,
|
|
3686
|
+
rows,
|
|
3687
|
+
sections,
|
|
3688
|
+
tableAtom,
|
|
3689
|
+
viewport
|
|
3531
3690
|
}) : rows.map((row) => /* @__PURE__ */ jsx15(RowIdContext.Provider, {
|
|
3532
3691
|
value: row.id,
|
|
3533
3692
|
children: /* @__PURE__ */ jsx15(TableDataRow, {
|
|
3693
|
+
row,
|
|
3534
3694
|
tableAtom
|
|
3535
3695
|
})
|
|
3536
3696
|
}, row.id))
|
|
@@ -3652,6 +3812,7 @@ var GalleryCard = ({
|
|
|
3652
3812
|
className: "absolute top-0 right-4",
|
|
3653
3813
|
onClick: (event) => event.stopPropagation(),
|
|
3654
3814
|
children: /* @__PURE__ */ jsx15(DataTableRowActionMenu, {
|
|
3815
|
+
row,
|
|
3655
3816
|
tableAtom
|
|
3656
3817
|
})
|
|
3657
3818
|
}) : null
|
|
@@ -3776,7 +3937,7 @@ var DataTablePagination = ({
|
|
|
3776
3937
|
const styles = useContext(DataTableStylesContext);
|
|
3777
3938
|
const [store, setStore] = useTableAtom(tableAtom);
|
|
3778
3939
|
const model = deriveModel(store);
|
|
3779
|
-
const pagination = store.config.features.pagination ??
|
|
3940
|
+
const pagination = store.config.features.pagination ?? false;
|
|
3780
3941
|
const clientGrouping = pagination !== false && pagination.mode === "client" && getActiveGrouping(store).length > 0;
|
|
3781
3942
|
const paginationVisible = pagination !== false && !clientGrouping;
|
|
3782
3943
|
const pageIndex = store.state.page;
|
|
@@ -3955,6 +4116,37 @@ var DataTableContent = ({
|
|
|
3955
4116
|
tableAtom
|
|
3956
4117
|
}) => {
|
|
3957
4118
|
const [store] = useTableAtom(tableAtom);
|
|
4119
|
+
const [scrollElement, setScrollElement] = useState(null);
|
|
4120
|
+
const [headerHeight, setHeaderHeight] = useState(48);
|
|
4121
|
+
const [pageTable, setPageTable] = useState(null);
|
|
4122
|
+
const [pageOffset, setPageOffset] = useState();
|
|
4123
|
+
useLayoutEffect(() => {
|
|
4124
|
+
const header = pageTable?.querySelector("thead");
|
|
4125
|
+
if (!pageTable || !header)
|
|
4126
|
+
return;
|
|
4127
|
+
const measure = () => setPageOffset(window.scrollY + header.getBoundingClientRect().bottom);
|
|
4128
|
+
measure();
|
|
4129
|
+
window.addEventListener("resize", measure);
|
|
4130
|
+
const observer = globalThis.ResizeObserver ? new ResizeObserver(measure) : undefined;
|
|
4131
|
+
observer?.observe(document.body);
|
|
4132
|
+
observer?.observe(header);
|
|
4133
|
+
return () => {
|
|
4134
|
+
window.removeEventListener("resize", measure);
|
|
4135
|
+
observer?.disconnect();
|
|
4136
|
+
};
|
|
4137
|
+
}, [pageTable]);
|
|
4138
|
+
useLayoutEffect(() => {
|
|
4139
|
+
const header = scrollElement?.querySelector("thead");
|
|
4140
|
+
if (!header)
|
|
4141
|
+
return;
|
|
4142
|
+
const measure = () => setHeaderHeight(header.getBoundingClientRect().height);
|
|
4143
|
+
measure();
|
|
4144
|
+
if (!globalThis.ResizeObserver)
|
|
4145
|
+
return;
|
|
4146
|
+
const observer = new globalThis.ResizeObserver(measure);
|
|
4147
|
+
observer.observe(header);
|
|
4148
|
+
return () => observer.disconnect();
|
|
4149
|
+
}, [scrollElement]);
|
|
3958
4150
|
if (store.config.features.gallery && store.state.view === "gallery") {
|
|
3959
4151
|
return /* @__PURE__ */ jsx15(DataTableGallery, {
|
|
3960
4152
|
tableAtom
|
|
@@ -3962,6 +4154,87 @@ var DataTableContent = ({
|
|
|
3962
4154
|
}
|
|
3963
4155
|
const model = deriveModel(store);
|
|
3964
4156
|
const width = getDataTableWidth(model.visibleColumns, (store.config.features.selection ? 1 : 0) + (hasRowActionMenu(store) ? 1 : 0) + (canDragRows(store) ? 1 : 0));
|
|
4157
|
+
const virtualization = store.config.features.virtualization;
|
|
4158
|
+
const fields = getActiveGrouping(store);
|
|
4159
|
+
const visibleCount = (sections) => sections.reduce((count, section) => count + 1 + (store.state.collapsedGroups[section.key] ? 0 : section.children.length ? visibleCount(section.children) : Math.max(1, section.rows.length)), 0);
|
|
4160
|
+
const automaticallyVirtualize = virtualization === undefined && !store.config.status.error && (fields.length ? visibleCount(groupDataTableRows(model.sortedRows, fields)) : model.pageRows.length) >= 100;
|
|
4161
|
+
if ((virtualization || automaticallyVirtualize) && !canDragRows(store)) {
|
|
4162
|
+
const options = virtualization && virtualization !== true ? virtualization : {};
|
|
4163
|
+
const rowCount = !getActiveGrouping(store).length && model.pageRows.length && !store.config.status.error ? model.pageRows.length + 1 : undefined;
|
|
4164
|
+
if (options.scroll === "page") {
|
|
4165
|
+
return /* @__PURE__ */ jsx15("div", {
|
|
4166
|
+
ref: setPageTable,
|
|
4167
|
+
"data-table-page-virtualization": "",
|
|
4168
|
+
className: "[overflow-anchor:none]",
|
|
4169
|
+
children: /* @__PURE__ */ jsxs9(ScrollArea, {
|
|
4170
|
+
className: "@container max-w-full min-w-0",
|
|
4171
|
+
children: [
|
|
4172
|
+
/* @__PURE__ */ jsxs9(Table2, {
|
|
4173
|
+
"aria-rowcount": rowCount,
|
|
4174
|
+
className: "table-fixed",
|
|
4175
|
+
style: { width: `max(100%, ${width}px)` },
|
|
4176
|
+
children: [
|
|
4177
|
+
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4178
|
+
tableAtom
|
|
4179
|
+
}),
|
|
4180
|
+
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4181
|
+
tableAtom,
|
|
4182
|
+
viewport: {
|
|
4183
|
+
element: null,
|
|
4184
|
+
headerHeight: 0,
|
|
4185
|
+
pageOffset,
|
|
4186
|
+
options
|
|
4187
|
+
}
|
|
4188
|
+
})
|
|
4189
|
+
]
|
|
4190
|
+
}),
|
|
4191
|
+
/* @__PURE__ */ jsx15(ScrollBar, {
|
|
4192
|
+
orientation: "horizontal"
|
|
4193
|
+
})
|
|
4194
|
+
]
|
|
4195
|
+
})
|
|
4196
|
+
});
|
|
4197
|
+
}
|
|
4198
|
+
return /* @__PURE__ */ jsxs9(ScrollAreaPrimitive2.Root, {
|
|
4199
|
+
className: "relative isolate max-w-full min-w-0",
|
|
4200
|
+
children: [
|
|
4201
|
+
/* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Viewport, {
|
|
4202
|
+
ref: setScrollElement,
|
|
4203
|
+
"data-table-virtual-viewport": "",
|
|
4204
|
+
className: "@container [overflow-anchor:none] data-has-overflow-y:me-2.5 [&_[data-slot=table-container]]:overflow-visible",
|
|
4205
|
+
style: {
|
|
4206
|
+
maxHeight: options.height ?? 480,
|
|
4207
|
+
scrollPaddingTop: headerHeight
|
|
4208
|
+
},
|
|
4209
|
+
children: /* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Content, {
|
|
4210
|
+
children: /* @__PURE__ */ jsxs9(Table2, {
|
|
4211
|
+
"aria-rowcount": rowCount,
|
|
4212
|
+
className: "table-fixed",
|
|
4213
|
+
style: { width: `max(100%, ${width}px)` },
|
|
4214
|
+
children: [
|
|
4215
|
+
/* @__PURE__ */ jsx15(DataTableHeader, {
|
|
4216
|
+
sticky: true,
|
|
4217
|
+
tableAtom
|
|
4218
|
+
}),
|
|
4219
|
+
/* @__PURE__ */ jsx15(DataTableBody, {
|
|
4220
|
+
tableAtom,
|
|
4221
|
+
viewport: { element: scrollElement, headerHeight, options }
|
|
4222
|
+
})
|
|
4223
|
+
]
|
|
4224
|
+
})
|
|
4225
|
+
})
|
|
4226
|
+
}),
|
|
4227
|
+
/* @__PURE__ */ jsx15(ScrollBar, {
|
|
4228
|
+
className: "data-vertical:h-auto",
|
|
4229
|
+
style: { top: headerHeight }
|
|
4230
|
+
}),
|
|
4231
|
+
/* @__PURE__ */ jsx15(ScrollBar, {
|
|
4232
|
+
orientation: "horizontal"
|
|
4233
|
+
}),
|
|
4234
|
+
/* @__PURE__ */ jsx15(ScrollAreaPrimitive2.Corner, {})
|
|
4235
|
+
]
|
|
4236
|
+
});
|
|
4237
|
+
}
|
|
3965
4238
|
return /* @__PURE__ */ jsxs9(ScrollArea, {
|
|
3966
4239
|
className: "@container max-w-full min-w-0",
|
|
3967
4240
|
children: [
|
|
@@ -4143,6 +4416,7 @@ var DataTableListMenu = ({
|
|
|
4143
4416
|
const labels = dataTableMessages(locale, messages);
|
|
4144
4417
|
const resolvedLabel = label ?? (hasActions ? labels.actions : labels.listDetails);
|
|
4145
4418
|
return /* @__PURE__ */ jsxs9(DropdownMenu, {
|
|
4419
|
+
modal: false,
|
|
4146
4420
|
children: [
|
|
4147
4421
|
/* @__PURE__ */ jsx15(DropdownMenuTrigger2, {
|
|
4148
4422
|
onClick: (event) => event.stopPropagation(),
|