najm-kit 2.1.56 → 2.2.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/CHANGELOG.md +15 -2
- package/dist/index.d.ts +42 -5
- package/dist/index.mjs +664 -491
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -12197,6 +12197,7 @@ var createTableStore = () => {
|
|
|
12197
12197
|
addButtonText: "",
|
|
12198
12198
|
pageSizeOptions: [10, 20, 30, 40, 50],
|
|
12199
12199
|
calculatedPageSize: 10,
|
|
12200
|
+
calculatedCardPageSize: 0,
|
|
12200
12201
|
skeletonRowCount: 6,
|
|
12201
12202
|
maxHeight: null,
|
|
12202
12203
|
bodyWidth: 0,
|
|
@@ -12354,6 +12355,7 @@ var DEFAULT_TABLE_HEADER_HEIGHT = 48;
|
|
|
12354
12355
|
var DEFAULT_CARD_HEIGHT = 176;
|
|
12355
12356
|
var DEFAULT_CARD_GAP = 12;
|
|
12356
12357
|
var ROOT_SECTION_GAP_COUNT = 2;
|
|
12358
|
+
var DYNAMIC_PAGE_SIZE_DEBOUNCE_MS = 200;
|
|
12357
12359
|
function useStoreSync(props) {
|
|
12358
12360
|
const storeRef = useRef(null);
|
|
12359
12361
|
const isControlled = props.mode !== void 0;
|
|
@@ -12441,6 +12443,14 @@ function calculateCardSkeletonCount(input) {
|
|
|
12441
12443
|
const rows = Math.max(1, Math.ceil((input.bodyHeight + gap) / (cardHeight + gap)));
|
|
12442
12444
|
return rows * columns;
|
|
12443
12445
|
}
|
|
12446
|
+
function calculateCardPageSize(input) {
|
|
12447
|
+
const columns = Math.max(1, input.columnCount || 1);
|
|
12448
|
+
const cardHeight = Math.max(1, input.cardHeight ?? DEFAULT_CARD_HEIGHT);
|
|
12449
|
+
const gap = Math.max(0, input.gap ?? DEFAULT_CARD_GAP);
|
|
12450
|
+
if (input.bodyHeight <= 0) return columns;
|
|
12451
|
+
const rows = Math.max(1, Math.floor((input.bodyHeight + gap) / (cardHeight + gap)));
|
|
12452
|
+
return rows * columns;
|
|
12453
|
+
}
|
|
12444
12454
|
function fallbackCardColumns(width) {
|
|
12445
12455
|
if (width >= 1280) return 4;
|
|
12446
12456
|
if (width >= 1024) return 3;
|
|
@@ -12493,8 +12503,19 @@ function useDynamicPageSize(containerRef, effectiveViewMode) {
|
|
|
12493
12503
|
const cardGap = Number.parseFloat(gridStyles?.rowGap || gridStyles?.gap || "") || DEFAULT_CARD_GAP;
|
|
12494
12504
|
const firstCard = cardsGridEl?.querySelector("[data-ntable-loading-card], [data-row]");
|
|
12495
12505
|
const cardRowHeight = firstCard?.offsetHeight || firstCard?.getBoundingClientRect().height || DEFAULT_CARD_HEIGHT;
|
|
12506
|
+
const cardPageSize = calculateCardPageSize({
|
|
12507
|
+
bodyHeight,
|
|
12508
|
+
columnCount: cardColumnCount,
|
|
12509
|
+
cardHeight: cardRowHeight,
|
|
12510
|
+
gap: cardGap
|
|
12511
|
+
});
|
|
12496
12512
|
const updates = {
|
|
12497
|
-
|
|
12513
|
+
// Measured page sizes are published in both pagination modes. Manual
|
|
12514
|
+
// pagination consumes them through onPaginationChange rather than by
|
|
12515
|
+
// mutating the table directly, so the consumer still owns fetching.
|
|
12516
|
+
calculatedPageSize: newPageSize,
|
|
12517
|
+
calculatedCardPageSize: cardPageSize,
|
|
12518
|
+
...!manualPagination ? { maxHeight: calculatedMaxHeight } : {},
|
|
12498
12519
|
skeletonRowCount: newPageSize,
|
|
12499
12520
|
bodyWidth,
|
|
12500
12521
|
bodyHeight,
|
|
@@ -12543,6 +12564,9 @@ function useTable(effectiveViewModeOverride) {
|
|
|
12543
12564
|
const effectiveViewMode = useTableStore.use.effectiveViewMode();
|
|
12544
12565
|
const cardPagination = useTableStore.use.cardPagination();
|
|
12545
12566
|
const calculatedPageSize = useTableStore.use.calculatedPageSize();
|
|
12567
|
+
const calculatedCardPageSize = useTableStore.use.calculatedCardPageSize();
|
|
12568
|
+
const measuredBodyHeight = useTableStore.use.bodyHeight();
|
|
12569
|
+
const measuredBodyWidth = useTableStore.use.bodyWidth();
|
|
12546
12570
|
const syncWithProps = useTableStore.use.syncWithProps();
|
|
12547
12571
|
const onStateChange = useTableStore.use.onStateChange();
|
|
12548
12572
|
const getRowId = useTableStore.use.getRowId();
|
|
@@ -12633,7 +12657,7 @@ function useTable(effectiveViewModeOverride) {
|
|
|
12633
12657
|
}, [storePagination, storeRowSelection, setPagination, sorting, columnFilters, columnVisibility, globalFilter, notifyStateChange]);
|
|
12634
12658
|
const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
|
|
12635
12659
|
const renderedMode = effectiveViewModeOverride ?? effectiveViewMode ?? viewMode;
|
|
12636
|
-
const renderAllSuppliedRows = renderedMode === "cards" && cardPagination.mode !== "paged";
|
|
12660
|
+
const renderAllSuppliedRows = cardPagination.mode === "all" || renderedMode === "cards" && cardPagination.mode !== "paged";
|
|
12637
12661
|
const tableConfig = {
|
|
12638
12662
|
data,
|
|
12639
12663
|
columns: finalColumns,
|
|
@@ -12669,6 +12693,32 @@ function useTable(effectiveViewModeOverride) {
|
|
|
12669
12693
|
table.setPageSize(data.length || 9999);
|
|
12670
12694
|
}
|
|
12671
12695
|
}, [calculatedPageSize, dynamicHeight, renderedMode, viewMode, cardPagination.mode, table, data.length, manualPagination]);
|
|
12696
|
+
const dynamicPageSizeTarget = renderedMode === "cards" ? calculatedCardPageSize : calculatedPageSize;
|
|
12697
|
+
const geometryKey = `${renderedMode}:${measuredBodyWidth}x${measuredBodyHeight}`;
|
|
12698
|
+
const reportedGeometryRef = useRef(null);
|
|
12699
|
+
useEffect(() => {
|
|
12700
|
+
if (!manualPagination || !dynamicHeight) return;
|
|
12701
|
+
if (cardPagination.mode !== "paged") return;
|
|
12702
|
+
if (measuredBodyHeight <= 0) return;
|
|
12703
|
+
if (!dynamicPageSizeTarget || dynamicPageSizeTarget < 1) return;
|
|
12704
|
+
if (dynamicPageSizeTarget === storePagination.pageSize) return;
|
|
12705
|
+
if (reportedGeometryRef.current === geometryKey) return;
|
|
12706
|
+
const timer = setTimeout(() => {
|
|
12707
|
+
reportedGeometryRef.current = geometryKey;
|
|
12708
|
+
setPagination({ pageIndex: storePagination.pageIndex, pageSize: dynamicPageSizeTarget });
|
|
12709
|
+
}, DYNAMIC_PAGE_SIZE_DEBOUNCE_MS);
|
|
12710
|
+
return () => clearTimeout(timer);
|
|
12711
|
+
}, [
|
|
12712
|
+
manualPagination,
|
|
12713
|
+
dynamicHeight,
|
|
12714
|
+
cardPagination.mode,
|
|
12715
|
+
measuredBodyHeight,
|
|
12716
|
+
geometryKey,
|
|
12717
|
+
dynamicPageSizeTarget,
|
|
12718
|
+
storePagination.pageIndex,
|
|
12719
|
+
storePagination.pageSize,
|
|
12720
|
+
setPagination
|
|
12721
|
+
]);
|
|
12672
12722
|
return { table, finalColumns, sorting, setSorting, columnFilters, setColumnFilters, columnVisibility, setColumnVisibility, globalFilter, setGlobalFilter };
|
|
12673
12723
|
}
|
|
12674
12724
|
function useTableKeyboard(options = {}) {
|
|
@@ -13131,268 +13181,642 @@ function NDataCardShell({ row, onClick, onContextMenu, actions, children, classN
|
|
|
13131
13181
|
}
|
|
13132
13182
|
);
|
|
13133
13183
|
}
|
|
13134
|
-
var
|
|
13135
|
-
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
|
|
13144
|
-
|
|
13145
|
-
const onBackgroundContextMenu = useTableStore.use.onBackgroundContextMenu();
|
|
13146
|
-
const getRowClassName = useTableStore.use.getRowClassName();
|
|
13147
|
-
const openRowMenu = useTableStore.use.openRowMenu();
|
|
13148
|
-
const menuButton = useTableStore.use.menuButton();
|
|
13149
|
-
const onView = useTableStore.use.onView();
|
|
13150
|
-
const onEdit = useTableStore.use.onEdit();
|
|
13151
|
-
const onDelete = useTableStore.use.onDelete();
|
|
13152
|
-
const showCheckbox = useTableStore.use.showCheckbox();
|
|
13153
|
-
const selectedRowId = useTableStore.use.selectedRowId();
|
|
13154
|
-
const CardComponent = useTableStore.use.CardComponent();
|
|
13155
|
-
const storeIsCardView = useTableStore.use.isCardView();
|
|
13156
|
-
const isLoading = useTableStore.use.isLoading();
|
|
13157
|
-
const error = useTableStore.use.error();
|
|
13158
|
-
const hasNoData = useTableStore.use.hasNoData();
|
|
13159
|
-
const showContent = useTableStore.use.showContent();
|
|
13160
|
-
const classNames = useTableStore.use.classNames();
|
|
13161
|
-
const bordered = useTableStore.use.bordered();
|
|
13162
|
-
const borderColor = useTableStore.use.borderColor();
|
|
13163
|
-
const renderSubRow = useTableStore.use.renderSubRow();
|
|
13164
|
-
const userGetRowCanExpand = useTableStore.use.getRowCanExpand();
|
|
13165
|
-
const handleContainerContextMenu = useCallback((e) => {
|
|
13166
|
-
if (isRowContextHandled(e)) return;
|
|
13167
|
-
const gridContainer = e.currentTarget;
|
|
13168
|
-
let el = e.target;
|
|
13169
|
-
let gridChild = null;
|
|
13170
|
-
while (el && el.parentElement && el.parentElement !== gridContainer) {
|
|
13171
|
-
el = el.parentElement;
|
|
13172
|
-
}
|
|
13173
|
-
gridChild = el.parentElement === gridContainer ? el : null;
|
|
13174
|
-
if (gridChild) {
|
|
13175
|
-
const rows2 = table?.getRowModel()?.rows;
|
|
13176
|
-
if (!rows2) return;
|
|
13177
|
-
const children = Array.from(gridContainer.children);
|
|
13178
|
-
const idx = children.indexOf(gridChild);
|
|
13179
|
-
if (idx >= 0 && idx < rows2.length) {
|
|
13180
|
-
const row = rows2[idx];
|
|
13181
|
-
if (onRowContextMenu) {
|
|
13182
|
-
markRowContextHandled(e);
|
|
13183
|
-
onRowContextMenu(e, row.original);
|
|
13184
|
-
}
|
|
13185
|
-
return;
|
|
13186
|
-
}
|
|
13187
|
-
}
|
|
13188
|
-
if (onBackgroundContextMenu) {
|
|
13189
|
-
onBackgroundContextMenu(e);
|
|
13190
|
-
}
|
|
13191
|
-
}, [table, onRowContextMenu, onBackgroundContextMenu]);
|
|
13192
|
-
if (isLoading || error || hasNoData || !showContent || !table) return null;
|
|
13193
|
-
const isCardView = effectiveMode ? effectiveMode === "cards" : storeIsCardView;
|
|
13194
|
-
if (!isCardView) return null;
|
|
13195
|
-
const rows = table.getRowModel().rows;
|
|
13196
|
-
if (!CardComponent) return /* @__PURE__ */ jsx("div", { className: "text-center py-8 text-muted-foreground", children: "No CardComponent provided." });
|
|
13197
|
-
const defaultContainerClass = "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3";
|
|
13198
|
-
const containerClass = classNames?.cards ?? defaultContainerClass;
|
|
13199
|
-
const actions = !menuButton && (onView || onEdit || onDelete) ? { onView, onEdit, onDelete } : void 0;
|
|
13200
|
-
return /* @__PURE__ */ jsx(NajmScroll, { axis: "y", className: "min-h-0 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx("div", { "data-ntable-cards-grid": true, className: cn(containerClass), onContextMenu: handleContainerContextMenu, children: rows.map((row) => {
|
|
13201
|
-
const noShell = Boolean(row.original?.__smsNoShell);
|
|
13202
|
-
const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
|
|
13203
|
-
const canExpand = hasExpansion && row.getCanExpand();
|
|
13204
|
-
const isExpanded = canExpand && row.getIsExpanded();
|
|
13205
|
-
const handleClick = onRowClick ? () => onRowClick(row.original) : void 0;
|
|
13206
|
-
const rowClassName = getRowClassName?.(row.original);
|
|
13207
|
-
const handleCardContextMenu = onRowContextMenu ? (e) => {
|
|
13208
|
-
if (isRowContextHandled(e)) return;
|
|
13209
|
-
markRowContextHandled(e);
|
|
13210
|
-
onRowContextMenu(e, row.original);
|
|
13211
|
-
} : void 0;
|
|
13212
|
-
if (noShell) {
|
|
13213
|
-
return /* @__PURE__ */ jsxs(
|
|
13184
|
+
var DEFAULT_ROWS2 = 6;
|
|
13185
|
+
var DEFAULT_CARD_COUNT = 16;
|
|
13186
|
+
function NTableCardSkeleton({ surface }) {
|
|
13187
|
+
return /* @__PURE__ */ jsx(
|
|
13188
|
+
"div",
|
|
13189
|
+
{
|
|
13190
|
+
"data-ntable-loading-card": true,
|
|
13191
|
+
"data-bordered": surface.bordered === false ? "false" : surface.bordered ? "true" : void 0,
|
|
13192
|
+
style: surface.style,
|
|
13193
|
+
className: cn("rounded-lg p-3 sm:p-4", surface.className),
|
|
13194
|
+
children: /* @__PURE__ */ jsxs(
|
|
13214
13195
|
"div",
|
|
13215
13196
|
{
|
|
13216
|
-
|
|
13217
|
-
"
|
|
13218
|
-
"data-row-id": row.id,
|
|
13219
|
-
className: cn("group relative text-card-foreground", rowClassName),
|
|
13197
|
+
"data-ntable-loading-card-layout": "responsive-avatar",
|
|
13198
|
+
className: "grid grid-cols-[80px_minmax(0,1fr)] gap-3 sm:grid-cols-[72px_minmax(0,1fr)]",
|
|
13220
13199
|
children: [
|
|
13221
|
-
|
|
13222
|
-
|
|
13200
|
+
/* @__PURE__ */ jsx("div", { className: "col-start-1 row-start-1 flex items-start justify-center sm:justify-start", children: /* @__PURE__ */ jsx(
|
|
13201
|
+
NSkeleton,
|
|
13223
13202
|
{
|
|
13224
|
-
|
|
13225
|
-
|
|
13226
|
-
onClick: (e) => {
|
|
13227
|
-
e.stopPropagation();
|
|
13228
|
-
openRowMenu(e, row.original);
|
|
13229
|
-
},
|
|
13230
|
-
"data-ntable-card-action": true,
|
|
13231
|
-
className: "ntable-card-action absolute end-2 top-2 z-10 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md p-0 text-muted-foreground transition-all duration-200 hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
13232
|
-
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-4 w-4" })
|
|
13203
|
+
"data-ntable-loading-card-avatar": true,
|
|
13204
|
+
className: "size-20 shrink-0 rounded-full sm:size-16"
|
|
13233
13205
|
}
|
|
13234
|
-
),
|
|
13206
|
+
) }),
|
|
13207
|
+
/* @__PURE__ */ jsxs("div", { className: "col-start-2 row-start-1 flex min-w-0 items-start justify-between gap-3", children: [
|
|
13208
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-2", children: [
|
|
13209
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-5 w-36 max-w-full" }),
|
|
13210
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "hidden h-3 w-16 sm:block" })
|
|
13211
|
+
] }),
|
|
13212
|
+
/* @__PURE__ */ jsx(
|
|
13213
|
+
NSkeleton,
|
|
13214
|
+
{
|
|
13215
|
+
"data-ntable-loading-card-status": true,
|
|
13216
|
+
className: "hidden h-6 w-14 shrink-0 rounded-full sm:block"
|
|
13217
|
+
}
|
|
13218
|
+
)
|
|
13219
|
+
] }),
|
|
13235
13220
|
/* @__PURE__ */ jsx(
|
|
13236
|
-
|
|
13221
|
+
"div",
|
|
13237
13222
|
{
|
|
13238
|
-
data:
|
|
13239
|
-
row,
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13223
|
+
"data-ntable-loading-card-details": true,
|
|
13224
|
+
className: "col-start-2 row-start-2 space-y-1 sm:col-span-full sm:col-start-1 sm:space-y-2 sm:rounded-lg sm:bg-muted/50 sm:p-3",
|
|
13225
|
+
children: Array.from({ length: 3 }).map((_, detailIndex) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 sm:gap-2", children: [
|
|
13226
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "size-3.5 shrink-0 rounded-sm sm:size-4" }),
|
|
13227
|
+
/* @__PURE__ */ jsx(
|
|
13228
|
+
NSkeleton,
|
|
13229
|
+
{
|
|
13230
|
+
className: cn(
|
|
13231
|
+
"h-3 max-w-full sm:h-4",
|
|
13232
|
+
detailIndex === 0 ? "w-full" : detailIndex === 1 ? "w-4/5" : "w-3/4"
|
|
13233
|
+
)
|
|
13234
|
+
}
|
|
13235
|
+
)
|
|
13236
|
+
] }, detailIndex))
|
|
13248
13237
|
}
|
|
13249
13238
|
)
|
|
13250
13239
|
]
|
|
13251
|
-
}
|
|
13252
|
-
|
|
13253
|
-
);
|
|
13240
|
+
}
|
|
13241
|
+
)
|
|
13254
13242
|
}
|
|
13255
|
-
|
|
13256
|
-
NDataCardShell,
|
|
13257
|
-
{
|
|
13258
|
-
row,
|
|
13259
|
-
onClick: handleClick,
|
|
13260
|
-
onContextMenu: handleCardContextMenu,
|
|
13261
|
-
actions,
|
|
13262
|
-
showCheckbox,
|
|
13263
|
-
selectedRowId,
|
|
13264
|
-
openRowMenu,
|
|
13265
|
-
menuButton,
|
|
13266
|
-
bordered,
|
|
13267
|
-
borderColor,
|
|
13268
|
-
className: rowClassName || void 0,
|
|
13269
|
-
children: /* @__PURE__ */ jsx(
|
|
13270
|
-
CardComponent,
|
|
13271
|
-
{
|
|
13272
|
-
data: row.original,
|
|
13273
|
-
row,
|
|
13274
|
-
isExpanded,
|
|
13275
|
-
onToggleExpanded: () => row.toggleExpanded(),
|
|
13276
|
-
canExpand,
|
|
13277
|
-
renderSubRow: canExpand && isExpanded ? renderSubRow : void 0
|
|
13278
|
-
}
|
|
13279
|
-
)
|
|
13280
|
-
},
|
|
13281
|
-
row.id
|
|
13282
|
-
);
|
|
13283
|
-
}) }) });
|
|
13243
|
+
);
|
|
13284
13244
|
}
|
|
13285
|
-
function
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
const
|
|
13292
|
-
const
|
|
13293
|
-
const
|
|
13294
|
-
const
|
|
13295
|
-
|
|
13296
|
-
const restoreFocusRef = React__default.useRef(false);
|
|
13297
|
-
const previousRowCountRef = React__default.useRef(rowCount);
|
|
13298
|
-
const errorId = React__default.useId();
|
|
13299
|
-
const pending = Boolean(config.loadingMore || internalPending);
|
|
13300
|
-
const error = config.loadMoreError ?? internalError;
|
|
13301
|
-
React__default.useEffect(() => {
|
|
13302
|
-
const previous = previousRowCountRef.current;
|
|
13303
|
-
if (rowCount > previous) {
|
|
13304
|
-
const appended = rowCount - previous;
|
|
13305
|
-
setAnnouncement(
|
|
13306
|
-
config.itemsLoadedLabel?.(appended) ?? `${appended} more ${appended === 1 ? "item" : "items"} loaded.`
|
|
13307
|
-
);
|
|
13308
|
-
}
|
|
13309
|
-
previousRowCountRef.current = rowCount;
|
|
13310
|
-
}, [config.itemsLoadedLabel, rowCount]);
|
|
13311
|
-
React__default.useEffect(() => {
|
|
13312
|
-
if (pending || !restoreFocusRef.current) return;
|
|
13313
|
-
restoreFocusRef.current = false;
|
|
13314
|
-
const frame = requestAnimationFrame(() => buttonRef.current?.focus());
|
|
13315
|
-
return () => cancelAnimationFrame(frame);
|
|
13316
|
-
}, [pending]);
|
|
13317
|
-
const loadMore = async () => {
|
|
13318
|
-
if (pendingRef.current || pending || !config.hasNextPage && !error) return;
|
|
13319
|
-
pendingRef.current = true;
|
|
13320
|
-
restoreFocusRef.current = document.activeElement === buttonRef.current;
|
|
13321
|
-
setInternalPending(true);
|
|
13322
|
-
setInternalError(null);
|
|
13323
|
-
const loadingAnnouncement = config.loadingMoreLabel ?? "Loading more items...";
|
|
13324
|
-
setAnnouncement(loadingAnnouncement);
|
|
13325
|
-
try {
|
|
13326
|
-
await config.onLoadMore();
|
|
13327
|
-
} catch {
|
|
13328
|
-
setInternalError(config.loadMoreErrorLabel ?? "Couldn't load more items.");
|
|
13329
|
-
setAnnouncement("");
|
|
13330
|
-
} finally {
|
|
13331
|
-
pendingRef.current = false;
|
|
13332
|
-
setInternalPending(false);
|
|
13333
|
-
setAnnouncement((current) => current === loadingAnnouncement ? "" : current);
|
|
13334
|
-
}
|
|
13335
|
-
};
|
|
13336
|
-
if (!config.hasNextPage && !pending && !error) {
|
|
13337
|
-
return /* @__PURE__ */ jsx(
|
|
13338
|
-
"div",
|
|
13339
|
-
{
|
|
13340
|
-
"data-ntable-load-more-end": true,
|
|
13341
|
-
role: "status",
|
|
13342
|
-
"aria-live": "polite",
|
|
13343
|
-
className: cn("py-2 text-center text-sm text-muted-foreground", className),
|
|
13344
|
-
children: config.endLabel ?? "No more items."
|
|
13345
|
-
}
|
|
13346
|
-
);
|
|
13347
|
-
}
|
|
13245
|
+
function NTableHeaderSkeleton() {
|
|
13246
|
+
const filters = useTableStore.use.filters();
|
|
13247
|
+
const showViewToggle = useTableStore.use.showViewToggle();
|
|
13248
|
+
const showColumnVisibility = useTableStore.use.showColumnVisibility();
|
|
13249
|
+
const showAddButton = useTableStore.use.showAddButton();
|
|
13250
|
+
const hasHeaderSlot = Boolean(useTableStore.use.headerSlot());
|
|
13251
|
+
const hasToolbar = Boolean(useTableStore.use.renderToolbar());
|
|
13252
|
+
const filterCount = Math.min(Math.max(filters?.length ?? 0, 1), 3);
|
|
13253
|
+
const hasActions = showViewToggle || showColumnVisibility || showAddButton || hasHeaderSlot || hasToolbar;
|
|
13254
|
+
const hasSettings = showViewToggle || showColumnVisibility || hasHeaderSlot || hasToolbar;
|
|
13255
|
+
if (!filters?.length && !hasActions) return null;
|
|
13348
13256
|
return /* @__PURE__ */ jsxs(
|
|
13349
13257
|
"div",
|
|
13350
13258
|
{
|
|
13351
|
-
"data-ntable-
|
|
13352
|
-
className:
|
|
13259
|
+
"data-ntable-loading-header": true,
|
|
13260
|
+
className: "flex shrink-0 flex-wrap items-center justify-between gap-2",
|
|
13353
13261
|
children: [
|
|
13354
|
-
|
|
13262
|
+
filters?.length ? /* @__PURE__ */ jsx(
|
|
13263
|
+
"div",
|
|
13264
|
+
{
|
|
13265
|
+
"data-ntable-loading-desktop-filters": true,
|
|
13266
|
+
className: "hidden min-w-0 flex-1 flex-wrap gap-2 md:flex",
|
|
13267
|
+
children: Array.from({ length: filterCount }).map((_, index) => /* @__PURE__ */ jsx(
|
|
13268
|
+
NSkeleton,
|
|
13269
|
+
{
|
|
13270
|
+
className: cn("h-10 w-full rounded-lg", index < 2 ? "max-w-64" : "max-w-48")
|
|
13271
|
+
},
|
|
13272
|
+
index
|
|
13273
|
+
))
|
|
13274
|
+
}
|
|
13275
|
+
) : /* @__PURE__ */ jsx("span", { className: "hidden min-w-0 flex-1 md:block" }),
|
|
13355
13276
|
/* @__PURE__ */ jsxs(
|
|
13356
|
-
|
|
13277
|
+
"div",
|
|
13357
13278
|
{
|
|
13358
|
-
|
|
13359
|
-
|
|
13360
|
-
bordered,
|
|
13361
|
-
variant: "outline",
|
|
13362
|
-
autoLoading: false,
|
|
13363
|
-
disabled: pending,
|
|
13364
|
-
"aria-describedby": error ? errorId : void 0,
|
|
13365
|
-
"aria-busy": pending ? "true" : void 0,
|
|
13366
|
-
onClick: loadMore,
|
|
13279
|
+
"data-ntable-loading-mobile-toolbar": true,
|
|
13280
|
+
className: "flex w-full min-w-0 items-center gap-2 md:hidden",
|
|
13367
13281
|
children: [
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
13371
|
-
|
|
13372
|
-
|
|
13373
|
-
|
|
13374
|
-
|
|
13375
|
-
|
|
13376
|
-
|
|
13377
|
-
|
|
13378
|
-
|
|
13379
|
-
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
|
|
13383
|
-
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
|
|
13388
|
-
|
|
13389
|
-
|
|
13282
|
+
filters?.length ? /* @__PURE__ */ jsx(
|
|
13283
|
+
NSkeleton,
|
|
13284
|
+
{
|
|
13285
|
+
"data-ntable-loading-mobile-primary": true,
|
|
13286
|
+
className: "h-10 min-w-0 flex-1 rounded-lg"
|
|
13287
|
+
}
|
|
13288
|
+
) : null,
|
|
13289
|
+
filters?.length > 1 ? /* @__PURE__ */ jsx(
|
|
13290
|
+
NSkeleton,
|
|
13291
|
+
{
|
|
13292
|
+
"data-ntable-loading-mobile-filter-button": true,
|
|
13293
|
+
className: "h-10 w-10 shrink-0 rounded-lg"
|
|
13294
|
+
}
|
|
13295
|
+
) : null,
|
|
13296
|
+
showAddButton ? /* @__PURE__ */ jsx(
|
|
13297
|
+
NSkeleton,
|
|
13298
|
+
{
|
|
13299
|
+
"data-ntable-loading-mobile-add-button": true,
|
|
13300
|
+
className: "h-10 w-10 shrink-0 rounded-lg"
|
|
13301
|
+
}
|
|
13302
|
+
) : null
|
|
13303
|
+
]
|
|
13304
|
+
}
|
|
13305
|
+
),
|
|
13306
|
+
hasActions && /* @__PURE__ */ jsxs("div", { className: "hidden shrink-0 gap-2 md:flex", children: [
|
|
13307
|
+
hasSettings && /* @__PURE__ */ jsx(NSkeleton, { className: "h-10 w-10 rounded-lg" }),
|
|
13308
|
+
showAddButton && /* @__PURE__ */ jsx(NSkeleton, { className: "h-10 w-10 rounded-lg" })
|
|
13309
|
+
] })
|
|
13310
|
+
]
|
|
13311
|
+
}
|
|
13312
|
+
);
|
|
13313
|
+
}
|
|
13314
|
+
function NTableLoadingSkeleton({ rows }) {
|
|
13315
|
+
const rawColumns = useTableStore.use.columns();
|
|
13316
|
+
const responsiveColumns = React__default.useMemo(() => filterResponsiveColumns(rawColumns), [rawColumns]);
|
|
13317
|
+
const columns = responsiveColumns;
|
|
13318
|
+
const showCheckbox = useTableStore.use.showCheckbox();
|
|
13319
|
+
const headerClassName = useTableStore.use.headerClassName();
|
|
13320
|
+
const classNames = useTableStore.use.classNames();
|
|
13321
|
+
const dynamicHeight = useTableStore.use.dynamicHeight();
|
|
13322
|
+
const bordered = useTableStore.use.bordered();
|
|
13323
|
+
const borderColor = useTableStore.use.borderColor();
|
|
13324
|
+
const surface = useTableSurfaceAppearance(bordered, borderColor);
|
|
13325
|
+
const bodyHeight = useTableStore.use.bodyHeight();
|
|
13326
|
+
const skeletonRowCount = useTableStore.use.skeletonRowCount();
|
|
13327
|
+
const renderSubRow = useTableStore.use.renderSubRow();
|
|
13328
|
+
const userGetRowCanExpand = useTableStore.use.getRowCanExpand();
|
|
13329
|
+
const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
|
|
13330
|
+
const loadingText = useTableStore.use.loadingText();
|
|
13331
|
+
const rowCount = rows ?? (dynamicHeight && bodyHeight > 0 ? skeletonRowCount : DEFAULT_ROWS2);
|
|
13332
|
+
const renderHeaderLabel = (header) => typeof header === "string" ? header : null;
|
|
13333
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
13334
|
+
/* @__PURE__ */ jsx(NTableHeaderSkeleton, {}),
|
|
13335
|
+
/* @__PURE__ */ jsxs(
|
|
13336
|
+
"div",
|
|
13337
|
+
{
|
|
13338
|
+
"data-testid": "ntable-loading-skeleton",
|
|
13339
|
+
"data-ntable-loading-row-count": rowCount,
|
|
13340
|
+
"data-bordered": surface.bordered === false ? "false" : surface.bordered ? "true" : void 0,
|
|
13341
|
+
"aria-busy": "true",
|
|
13342
|
+
"aria-label": loadingText,
|
|
13343
|
+
role: "status",
|
|
13344
|
+
style: surface.style,
|
|
13345
|
+
className: cn("min-h-0 flex-1 rounded-md p-0", surface.className, dynamicHeight ? "overflow-hidden" : "najm-overlay-scroll", classNames?.content),
|
|
13346
|
+
children: [
|
|
13347
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }),
|
|
13348
|
+
/* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: dynamicHeight ? "najm-overlay-scroll h-full" : void 0, children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
13349
|
+
/* @__PURE__ */ jsx(TableHeader, { "data-ntable-table-header": true, className: cn(headerClassName, "sticky top-0 z-10", classNames?.tableHeader), children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-muted/30", children: [
|
|
13350
|
+
showCheckbox && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Select column", className: "w-10 text-foreground h-12" }),
|
|
13351
|
+
hasExpansion && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Expand column", className: "w-10 text-foreground h-12" }),
|
|
13352
|
+
columns.map((col, i) => /* @__PURE__ */ jsx(
|
|
13353
|
+
TableHead,
|
|
13354
|
+
{
|
|
13355
|
+
className: cn("text-foreground h-12", resolveHiddenBelowClass(col?.meta?.hiddenBelow)),
|
|
13356
|
+
style: col?.size ? { width: col.size } : void 0,
|
|
13357
|
+
children: renderHeaderLabel(col?.header)
|
|
13358
|
+
},
|
|
13359
|
+
col?.id ?? col?.accessorKey ?? i
|
|
13360
|
+
))
|
|
13361
|
+
] }) }),
|
|
13362
|
+
/* @__PURE__ */ jsx(TableBody, { children: Array.from({ length: rowCount }).map((_, r) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
13363
|
+
showCheckbox && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
|
|
13364
|
+
hasExpansion && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
|
|
13365
|
+
columns.map((col, c) => /* @__PURE__ */ jsx(
|
|
13366
|
+
TableCell,
|
|
13367
|
+
{
|
|
13368
|
+
className: cn("h-14", resolveHiddenBelowClass(col?.meta?.hiddenBelow)),
|
|
13369
|
+
style: col?.size ? { width: col.size } : void 0,
|
|
13370
|
+
children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-full" })
|
|
13371
|
+
},
|
|
13372
|
+
`skeleton-${r}-${col?.id ?? col?.accessorKey ?? c}`
|
|
13373
|
+
))
|
|
13374
|
+
] }, `skeleton-${r}`)) })
|
|
13375
|
+
] }) })
|
|
13376
|
+
]
|
|
13377
|
+
}
|
|
13378
|
+
)
|
|
13379
|
+
] });
|
|
13380
|
+
}
|
|
13381
|
+
function NTableCardsLoadingSkeleton({ rows }) {
|
|
13382
|
+
const filters = useTableStore.use.filters();
|
|
13383
|
+
const showViewToggle = useTableStore.use.showViewToggle();
|
|
13384
|
+
const showColumnVisibility = useTableStore.use.showColumnVisibility();
|
|
13385
|
+
const showAddButton = useTableStore.use.showAddButton();
|
|
13386
|
+
const hasHeaderSlot = Boolean(useTableStore.use.headerSlot());
|
|
13387
|
+
const hasToolbar = Boolean(useTableStore.use.renderToolbar());
|
|
13388
|
+
const hasHeaderSkeleton = Boolean(
|
|
13389
|
+
filters?.length || showViewToggle || showColumnVisibility || showAddButton || hasHeaderSlot || hasToolbar
|
|
13390
|
+
);
|
|
13391
|
+
const classNames = useTableStore.use.classNames();
|
|
13392
|
+
const bordered = useTableStore.use.bordered();
|
|
13393
|
+
const borderColor = useTableStore.use.borderColor();
|
|
13394
|
+
const surface = useTableSurfaceAppearance(bordered, borderColor);
|
|
13395
|
+
const dynamicHeight = useTableStore.use.dynamicHeight();
|
|
13396
|
+
const bodyHeight = useTableStore.use.bodyHeight();
|
|
13397
|
+
const cardColumnCount = useTableStore.use.cardColumnCount();
|
|
13398
|
+
const cardRowHeight = useTableStore.use.cardRowHeight();
|
|
13399
|
+
const cardGap = useTableStore.use.cardGap();
|
|
13400
|
+
const loadingText = useTableStore.use.loadingText();
|
|
13401
|
+
const cardCount = rows ?? (dynamicHeight && bodyHeight > 0 ? calculateCardSkeletonCount({
|
|
13402
|
+
bodyHeight,
|
|
13403
|
+
columnCount: cardColumnCount,
|
|
13404
|
+
cardHeight: cardRowHeight,
|
|
13405
|
+
gap: cardGap
|
|
13406
|
+
}) : DEFAULT_CARD_COUNT);
|
|
13407
|
+
const defaultContainerClass = "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4";
|
|
13408
|
+
const containerClass = classNames?.cards ?? defaultContainerClass;
|
|
13409
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
13410
|
+
hasHeaderSkeleton && /* @__PURE__ */ jsx(NTableHeaderSkeleton, {}),
|
|
13411
|
+
/* @__PURE__ */ jsxs(
|
|
13412
|
+
NajmScroll,
|
|
13413
|
+
{
|
|
13414
|
+
axis: "y",
|
|
13415
|
+
"aria-busy": "true",
|
|
13416
|
+
"aria-label": loadingText,
|
|
13417
|
+
role: "status",
|
|
13418
|
+
className: "min-h-0 flex-1 overflow-hidden",
|
|
13419
|
+
children: [
|
|
13420
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }),
|
|
13421
|
+
/* @__PURE__ */ jsx(
|
|
13422
|
+
"div",
|
|
13423
|
+
{
|
|
13424
|
+
"data-testid": "ntable-cards-loading-skeleton",
|
|
13425
|
+
"data-ntable-loading-cards-grid": true,
|
|
13426
|
+
"data-ntable-loading-card-count": cardCount,
|
|
13427
|
+
"aria-hidden": "true",
|
|
13428
|
+
className: cn(containerClass),
|
|
13429
|
+
children: Array.from({ length: cardCount }).map((_, index) => /* @__PURE__ */ jsx(NTableCardSkeleton, { surface }, index))
|
|
13430
|
+
}
|
|
13431
|
+
)
|
|
13432
|
+
]
|
|
13433
|
+
}
|
|
13434
|
+
)
|
|
13435
|
+
] });
|
|
13436
|
+
}
|
|
13437
|
+
var DEFAULT_ROOT_MARGIN = "80px";
|
|
13438
|
+
function useCardContinuation({
|
|
13439
|
+
config,
|
|
13440
|
+
rowCount,
|
|
13441
|
+
viewportRef
|
|
13442
|
+
}) {
|
|
13443
|
+
const [internalPending, setInternalPending] = React__default.useState(false);
|
|
13444
|
+
const [internalError, setInternalError] = React__default.useState(null);
|
|
13445
|
+
const [announcement, setAnnouncement] = React__default.useState("");
|
|
13446
|
+
const [viewportReady, setViewportReady] = React__default.useState(false);
|
|
13447
|
+
const pendingRef = React__default.useRef(false);
|
|
13448
|
+
const previousRowCountRef = React__default.useRef(rowCount);
|
|
13449
|
+
const configRef = React__default.useRef(config);
|
|
13450
|
+
configRef.current = config;
|
|
13451
|
+
const enabled = Boolean(config);
|
|
13452
|
+
const pending = Boolean(config?.loadingMore || internalPending);
|
|
13453
|
+
const error = config?.loadMoreError ?? internalError;
|
|
13454
|
+
const hasNextPage = Boolean(config?.hasNextPage);
|
|
13455
|
+
const load = React__default.useCallback(async () => {
|
|
13456
|
+
const current = configRef.current;
|
|
13457
|
+
if (!current) return;
|
|
13458
|
+
if (pendingRef.current || current.loadingMore || !current.hasNextPage) return;
|
|
13459
|
+
pendingRef.current = true;
|
|
13460
|
+
setInternalPending(true);
|
|
13461
|
+
setInternalError(null);
|
|
13462
|
+
const loadingAnnouncement = current.loadingMoreLabel ?? "Loading more items...";
|
|
13463
|
+
setAnnouncement(loadingAnnouncement);
|
|
13464
|
+
try {
|
|
13465
|
+
await current.onLoadMore();
|
|
13466
|
+
} catch {
|
|
13467
|
+
setInternalError(current.loadMoreErrorLabel ?? "Couldn't load more items.");
|
|
13468
|
+
setAnnouncement("");
|
|
13469
|
+
} finally {
|
|
13470
|
+
pendingRef.current = false;
|
|
13471
|
+
setInternalPending(false);
|
|
13472
|
+
setAnnouncement((value) => value === loadingAnnouncement ? "" : value);
|
|
13473
|
+
}
|
|
13474
|
+
}, []);
|
|
13475
|
+
const { sentinelRef, scrollContainerRef, observe, doneLoading } = useInfiniteScroll(
|
|
13476
|
+
enabled && hasNextPage && !error,
|
|
13477
|
+
load,
|
|
13478
|
+
{ rootMargin: config?.rootMargin ?? DEFAULT_ROOT_MARGIN }
|
|
13479
|
+
);
|
|
13480
|
+
React__default.useLayoutEffect(() => {
|
|
13481
|
+
const node = viewportRef.current ?? null;
|
|
13482
|
+
scrollContainerRef.current = node;
|
|
13483
|
+
const ready = Boolean(node);
|
|
13484
|
+
setViewportReady((value) => value === ready ? value : ready);
|
|
13485
|
+
});
|
|
13486
|
+
React__default.useEffect(() => {
|
|
13487
|
+
const previous = previousRowCountRef.current;
|
|
13488
|
+
if (rowCount > previous) {
|
|
13489
|
+
const appended = rowCount - previous;
|
|
13490
|
+
setAnnouncement(
|
|
13491
|
+
configRef.current?.itemsLoadedLabel?.(appended) ?? `${appended} more ${appended === 1 ? "item" : "items"} loaded.`
|
|
13492
|
+
);
|
|
13493
|
+
}
|
|
13494
|
+
previousRowCountRef.current = rowCount;
|
|
13495
|
+
}, [rowCount]);
|
|
13496
|
+
React__default.useEffect(() => {
|
|
13497
|
+
if (!pending) doneLoading();
|
|
13498
|
+
}, [pending, doneLoading]);
|
|
13499
|
+
React__default.useEffect(() => {
|
|
13500
|
+
if (!enabled || !hasNextPage || error) return;
|
|
13501
|
+
return observe();
|
|
13502
|
+
}, [enabled, hasNextPage, error, observe, viewportReady, rowCount]);
|
|
13503
|
+
return {
|
|
13504
|
+
/** Attach to an element rendered after the last card. */
|
|
13505
|
+
sentinelRef,
|
|
13506
|
+
/** True while a page is in flight; render shaped placeholders. */
|
|
13507
|
+
pending,
|
|
13508
|
+
/** Present only after an append failure; render the retry target. */
|
|
13509
|
+
error,
|
|
13510
|
+
/** Retry an append. Also used as the manual escape hatch after failure. */
|
|
13511
|
+
retry: load,
|
|
13512
|
+
/** Polite live-region text. Never rendered visibly. */
|
|
13513
|
+
announcement,
|
|
13514
|
+
/** Whether a sentinel should exist at all. */
|
|
13515
|
+
active: enabled && hasNextPage && !error
|
|
13516
|
+
};
|
|
13517
|
+
}
|
|
13518
|
+
var ROW_CONTEXT_HANDLED2 = "__ntableRowContextHandled";
|
|
13519
|
+
function markRowContextHandled(e) {
|
|
13520
|
+
e.nativeEvent[ROW_CONTEXT_HANDLED2] = true;
|
|
13521
|
+
}
|
|
13522
|
+
function isRowContextHandled(e) {
|
|
13523
|
+
return Boolean(e.nativeEvent[ROW_CONTEXT_HANDLED2]);
|
|
13524
|
+
}
|
|
13525
|
+
function NTableCards({ effectiveMode }) {
|
|
13526
|
+
const table = useTableStore.use.table();
|
|
13527
|
+
const onRowClick = useTableStore.use.onRowClick();
|
|
13528
|
+
const onRowContextMenu = useTableStore.use.onRowContextMenu();
|
|
13529
|
+
const onBackgroundContextMenu = useTableStore.use.onBackgroundContextMenu();
|
|
13530
|
+
const getRowClassName = useTableStore.use.getRowClassName();
|
|
13531
|
+
const openRowMenu = useTableStore.use.openRowMenu();
|
|
13532
|
+
const menuButton = useTableStore.use.menuButton();
|
|
13533
|
+
const onView = useTableStore.use.onView();
|
|
13534
|
+
const onEdit = useTableStore.use.onEdit();
|
|
13535
|
+
const onDelete = useTableStore.use.onDelete();
|
|
13536
|
+
const showCheckbox = useTableStore.use.showCheckbox();
|
|
13537
|
+
const selectedRowId = useTableStore.use.selectedRowId();
|
|
13538
|
+
const CardComponent = useTableStore.use.CardComponent();
|
|
13539
|
+
const storeIsCardView = useTableStore.use.isCardView();
|
|
13540
|
+
const isLoading = useTableStore.use.isLoading();
|
|
13541
|
+
const error = useTableStore.use.error();
|
|
13542
|
+
const hasNoData = useTableStore.use.hasNoData();
|
|
13543
|
+
const showContent = useTableStore.use.showContent();
|
|
13544
|
+
const classNames = useTableStore.use.classNames();
|
|
13545
|
+
const bordered = useTableStore.use.bordered();
|
|
13546
|
+
const borderColor = useTableStore.use.borderColor();
|
|
13547
|
+
const renderSubRow = useTableStore.use.renderSubRow();
|
|
13548
|
+
const userGetRowCanExpand = useTableStore.use.getRowCanExpand();
|
|
13549
|
+
const cardPagination = useTableStore.use.cardPagination();
|
|
13550
|
+
const cardColumnCount = useTableStore.use.cardColumnCount();
|
|
13551
|
+
const surface = useTableSurfaceAppearance(bordered, borderColor);
|
|
13552
|
+
const viewportRef = React__default.useRef(null);
|
|
13553
|
+
const continuationConfig = cardPagination.mode === "infinite" ? cardPagination : null;
|
|
13554
|
+
const continuation = useCardContinuation({
|
|
13555
|
+
config: continuationConfig,
|
|
13556
|
+
rowCount: table?.getRowModel().rows.length ?? 0,
|
|
13557
|
+
viewportRef
|
|
13558
|
+
});
|
|
13559
|
+
const handleContainerContextMenu = useCallback((e) => {
|
|
13560
|
+
if (isRowContextHandled(e)) return;
|
|
13561
|
+
const gridContainer = e.currentTarget;
|
|
13562
|
+
let el = e.target;
|
|
13563
|
+
let gridChild = null;
|
|
13564
|
+
while (el && el.parentElement && el.parentElement !== gridContainer) {
|
|
13565
|
+
el = el.parentElement;
|
|
13566
|
+
}
|
|
13567
|
+
gridChild = el.parentElement === gridContainer ? el : null;
|
|
13568
|
+
if (gridChild) {
|
|
13569
|
+
const rows2 = table?.getRowModel()?.rows;
|
|
13570
|
+
if (!rows2) return;
|
|
13571
|
+
const children = Array.from(gridContainer.children);
|
|
13572
|
+
const idx = children.indexOf(gridChild);
|
|
13573
|
+
if (idx >= 0 && idx < rows2.length) {
|
|
13574
|
+
const row = rows2[idx];
|
|
13575
|
+
if (onRowContextMenu) {
|
|
13576
|
+
markRowContextHandled(e);
|
|
13577
|
+
onRowContextMenu(e, row.original);
|
|
13578
|
+
}
|
|
13579
|
+
return;
|
|
13580
|
+
}
|
|
13581
|
+
}
|
|
13582
|
+
if (onBackgroundContextMenu) {
|
|
13583
|
+
onBackgroundContextMenu(e);
|
|
13584
|
+
}
|
|
13585
|
+
}, [table, onRowContextMenu, onBackgroundContextMenu]);
|
|
13586
|
+
if (isLoading || error || hasNoData || !showContent || !table) return null;
|
|
13587
|
+
const isCardView = effectiveMode ? effectiveMode === "cards" : storeIsCardView;
|
|
13588
|
+
if (!isCardView) return null;
|
|
13589
|
+
const rows = table.getRowModel().rows;
|
|
13590
|
+
if (!CardComponent) return /* @__PURE__ */ jsx("div", { className: "text-center py-8 text-muted-foreground", children: "No CardComponent provided." });
|
|
13591
|
+
const defaultContainerClass = "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3";
|
|
13592
|
+
const containerClass = classNames?.cards ?? defaultContainerClass;
|
|
13593
|
+
const actions = !menuButton && (onView || onEdit || onDelete) ? { onView, onEdit, onDelete } : void 0;
|
|
13594
|
+
return /* @__PURE__ */ jsxs(NajmScroll, { axis: "y", viewportRef, className: "min-h-0 flex-1 overflow-hidden", children: [
|
|
13595
|
+
/* @__PURE__ */ jsxs("div", { "data-ntable-cards-grid": true, className: cn(containerClass), onContextMenu: handleContainerContextMenu, children: [
|
|
13596
|
+
rows.map((row) => {
|
|
13597
|
+
const noShell = Boolean(row.original?.__smsNoShell);
|
|
13598
|
+
const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
|
|
13599
|
+
const canExpand = hasExpansion && row.getCanExpand();
|
|
13600
|
+
const isExpanded = canExpand && row.getIsExpanded();
|
|
13601
|
+
const handleClick = onRowClick ? () => onRowClick(row.original) : void 0;
|
|
13602
|
+
const rowClassName = getRowClassName?.(row.original);
|
|
13603
|
+
const handleCardContextMenu = onRowContextMenu ? (e) => {
|
|
13604
|
+
if (isRowContextHandled(e)) return;
|
|
13605
|
+
markRowContextHandled(e);
|
|
13606
|
+
onRowContextMenu(e, row.original);
|
|
13607
|
+
} : void 0;
|
|
13608
|
+
if (noShell) {
|
|
13609
|
+
return /* @__PURE__ */ jsxs(
|
|
13610
|
+
"div",
|
|
13611
|
+
{
|
|
13612
|
+
onContextMenu: handleCardContextMenu,
|
|
13613
|
+
"data-row": "true",
|
|
13614
|
+
"data-row-id": row.id,
|
|
13615
|
+
className: cn("group relative text-card-foreground", rowClassName),
|
|
13616
|
+
children: [
|
|
13617
|
+
menuButton && openRowMenu && /* @__PURE__ */ jsx(
|
|
13618
|
+
"button",
|
|
13619
|
+
{
|
|
13620
|
+
type: "button",
|
|
13621
|
+
"aria-label": "Row actions",
|
|
13622
|
+
onClick: (e) => {
|
|
13623
|
+
e.stopPropagation();
|
|
13624
|
+
openRowMenu(e, row.original);
|
|
13625
|
+
},
|
|
13626
|
+
"data-ntable-card-action": true,
|
|
13627
|
+
className: "ntable-card-action absolute end-2 top-2 z-10 flex h-7 w-7 cursor-pointer items-center justify-center rounded-md p-0 text-muted-foreground transition-all duration-200 hover:bg-muted/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
13628
|
+
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-4 w-4" })
|
|
13629
|
+
}
|
|
13630
|
+
),
|
|
13631
|
+
/* @__PURE__ */ jsx(
|
|
13632
|
+
CardComponent,
|
|
13633
|
+
{
|
|
13634
|
+
data: row.original,
|
|
13635
|
+
row,
|
|
13636
|
+
onClick: handleClick,
|
|
13637
|
+
onContextMenu: handleCardContextMenu,
|
|
13638
|
+
isExpanded,
|
|
13639
|
+
onToggleExpanded: () => row.toggleExpanded(),
|
|
13640
|
+
canExpand,
|
|
13641
|
+
renderSubRow: canExpand && isExpanded ? renderSubRow : void 0,
|
|
13642
|
+
"data-row": "true",
|
|
13643
|
+
"data-row-id": row.id
|
|
13644
|
+
}
|
|
13645
|
+
)
|
|
13646
|
+
]
|
|
13647
|
+
},
|
|
13648
|
+
row.id
|
|
13649
|
+
);
|
|
13650
|
+
}
|
|
13651
|
+
return /* @__PURE__ */ jsx(
|
|
13652
|
+
NDataCardShell,
|
|
13653
|
+
{
|
|
13654
|
+
row,
|
|
13655
|
+
onClick: handleClick,
|
|
13656
|
+
onContextMenu: handleCardContextMenu,
|
|
13657
|
+
actions,
|
|
13658
|
+
showCheckbox,
|
|
13659
|
+
selectedRowId,
|
|
13660
|
+
openRowMenu,
|
|
13661
|
+
menuButton,
|
|
13662
|
+
bordered,
|
|
13663
|
+
borderColor,
|
|
13664
|
+
className: rowClassName || void 0,
|
|
13665
|
+
children: /* @__PURE__ */ jsx(
|
|
13666
|
+
CardComponent,
|
|
13667
|
+
{
|
|
13668
|
+
data: row.original,
|
|
13669
|
+
row,
|
|
13670
|
+
isExpanded,
|
|
13671
|
+
onToggleExpanded: () => row.toggleExpanded(),
|
|
13672
|
+
canExpand,
|
|
13673
|
+
renderSubRow: canExpand && isExpanded ? renderSubRow : void 0
|
|
13674
|
+
}
|
|
13675
|
+
)
|
|
13676
|
+
},
|
|
13677
|
+
row.id
|
|
13678
|
+
);
|
|
13679
|
+
}),
|
|
13680
|
+
continuation.pending ? Array.from({ length: Math.max(1, cardColumnCount || 1) }).map((_, index) => /* @__PURE__ */ jsx(NTableCardSkeleton, { surface }, `ntable-continuation-skeleton-${index}`)) : null
|
|
13681
|
+
] }),
|
|
13682
|
+
continuation.error ? /* @__PURE__ */ jsxs(
|
|
13683
|
+
"div",
|
|
13684
|
+
{
|
|
13685
|
+
"data-ntable-cards-continuation-error": true,
|
|
13686
|
+
className: "flex flex-col items-center gap-2 py-3",
|
|
13687
|
+
children: [
|
|
13688
|
+
/* @__PURE__ */ jsx("div", { role: "alert", className: "text-center text-sm text-destructive", children: continuation.error === true ? continuationConfig?.loadMoreErrorLabel ?? "Couldn't load more items." : continuation.error }),
|
|
13689
|
+
/* @__PURE__ */ jsx(
|
|
13690
|
+
Button,
|
|
13691
|
+
{
|
|
13692
|
+
type: "button",
|
|
13693
|
+
bordered,
|
|
13694
|
+
variant: "outline",
|
|
13695
|
+
autoLoading: false,
|
|
13696
|
+
disabled: continuation.pending,
|
|
13697
|
+
onClick: continuation.retry,
|
|
13698
|
+
children: continuationConfig?.retryLabel ?? "Retry"
|
|
13699
|
+
}
|
|
13700
|
+
)
|
|
13701
|
+
]
|
|
13702
|
+
}
|
|
13703
|
+
) : null,
|
|
13704
|
+
continuation.active ? /* @__PURE__ */ jsx("div", { ref: continuation.sentinelRef, "data-ntable-cards-sentinel": true, "aria-hidden": "true" }) : null,
|
|
13705
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", children: continuation.announcement })
|
|
13706
|
+
] });
|
|
13707
|
+
}
|
|
13708
|
+
function CardLoadMorePagination({
|
|
13709
|
+
config,
|
|
13710
|
+
rowCount,
|
|
13711
|
+
bordered,
|
|
13712
|
+
className
|
|
13713
|
+
}) {
|
|
13714
|
+
const [internalPending, setInternalPending] = React__default.useState(false);
|
|
13715
|
+
const [internalError, setInternalError] = React__default.useState(null);
|
|
13716
|
+
const [announcement, setAnnouncement] = React__default.useState("");
|
|
13717
|
+
const buttonRef = React__default.useRef(null);
|
|
13718
|
+
const pendingRef = React__default.useRef(false);
|
|
13719
|
+
const restoreFocusRef = React__default.useRef(false);
|
|
13720
|
+
const previousRowCountRef = React__default.useRef(rowCount);
|
|
13721
|
+
const errorId = React__default.useId();
|
|
13722
|
+
const pending = Boolean(config.loadingMore || internalPending);
|
|
13723
|
+
const error = config.loadMoreError ?? internalError;
|
|
13724
|
+
React__default.useEffect(() => {
|
|
13725
|
+
const previous = previousRowCountRef.current;
|
|
13726
|
+
if (rowCount > previous) {
|
|
13727
|
+
const appended = rowCount - previous;
|
|
13728
|
+
setAnnouncement(
|
|
13729
|
+
config.itemsLoadedLabel?.(appended) ?? `${appended} more ${appended === 1 ? "item" : "items"} loaded.`
|
|
13730
|
+
);
|
|
13731
|
+
}
|
|
13732
|
+
previousRowCountRef.current = rowCount;
|
|
13733
|
+
}, [config.itemsLoadedLabel, rowCount]);
|
|
13734
|
+
React__default.useEffect(() => {
|
|
13735
|
+
if (pending || !restoreFocusRef.current) return;
|
|
13736
|
+
restoreFocusRef.current = false;
|
|
13737
|
+
const frame = requestAnimationFrame(() => buttonRef.current?.focus());
|
|
13738
|
+
return () => cancelAnimationFrame(frame);
|
|
13739
|
+
}, [pending]);
|
|
13740
|
+
const loadMore = async () => {
|
|
13741
|
+
if (pendingRef.current || pending || !config.hasNextPage && !error) return;
|
|
13742
|
+
pendingRef.current = true;
|
|
13743
|
+
restoreFocusRef.current = document.activeElement === buttonRef.current;
|
|
13744
|
+
setInternalPending(true);
|
|
13745
|
+
setInternalError(null);
|
|
13746
|
+
const loadingAnnouncement = config.loadingMoreLabel ?? "Loading more items...";
|
|
13747
|
+
setAnnouncement(loadingAnnouncement);
|
|
13748
|
+
try {
|
|
13749
|
+
await config.onLoadMore();
|
|
13750
|
+
} catch {
|
|
13751
|
+
setInternalError(config.loadMoreErrorLabel ?? "Couldn't load more items.");
|
|
13752
|
+
setAnnouncement("");
|
|
13753
|
+
} finally {
|
|
13754
|
+
pendingRef.current = false;
|
|
13755
|
+
setInternalPending(false);
|
|
13756
|
+
setAnnouncement((current) => current === loadingAnnouncement ? "" : current);
|
|
13757
|
+
}
|
|
13758
|
+
};
|
|
13759
|
+
if (!config.hasNextPage && !pending && !error) {
|
|
13760
|
+
return /* @__PURE__ */ jsx(
|
|
13761
|
+
"div",
|
|
13762
|
+
{
|
|
13763
|
+
"data-ntable-load-more-end": true,
|
|
13764
|
+
role: "status",
|
|
13765
|
+
"aria-live": "polite",
|
|
13766
|
+
className: cn("py-2 text-center text-sm text-muted-foreground", className),
|
|
13767
|
+
children: config.endLabel ?? "No more items."
|
|
13768
|
+
}
|
|
13769
|
+
);
|
|
13770
|
+
}
|
|
13771
|
+
return /* @__PURE__ */ jsxs(
|
|
13772
|
+
"div",
|
|
13773
|
+
{
|
|
13774
|
+
"data-ntable-load-more": true,
|
|
13775
|
+
className: cn("flex min-w-0 flex-col items-center gap-2 py-2", className),
|
|
13776
|
+
children: [
|
|
13777
|
+
error ? /* @__PURE__ */ jsx("div", { id: errorId, role: "alert", className: "text-center text-sm text-destructive", children: error === true ? config.loadMoreErrorLabel ?? "Couldn't load more items." : error }) : null,
|
|
13778
|
+
/* @__PURE__ */ jsxs(
|
|
13779
|
+
Button,
|
|
13780
|
+
{
|
|
13781
|
+
ref: buttonRef,
|
|
13782
|
+
type: "button",
|
|
13783
|
+
bordered,
|
|
13784
|
+
variant: "outline",
|
|
13785
|
+
autoLoading: false,
|
|
13786
|
+
disabled: pending,
|
|
13787
|
+
"aria-describedby": error ? errorId : void 0,
|
|
13788
|
+
"aria-busy": pending ? "true" : void 0,
|
|
13789
|
+
onClick: loadMore,
|
|
13790
|
+
children: [
|
|
13791
|
+
pending ? /* @__PURE__ */ jsx(Loader2, { "aria-hidden": "true", className: "h-4 w-4 animate-spin motion-reduce:animate-none" }) : null,
|
|
13792
|
+
pending ? config.loadingMoreLabel ?? "Loading more..." : error ? config.retryLabel ?? "Retry" : config.loadMoreLabel ?? "Load more"
|
|
13793
|
+
]
|
|
13794
|
+
}
|
|
13795
|
+
),
|
|
13796
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true", children: announcement })
|
|
13797
|
+
]
|
|
13798
|
+
}
|
|
13799
|
+
);
|
|
13800
|
+
}
|
|
13801
|
+
function NTablePagination() {
|
|
13802
|
+
const table = useTableStore.use.table();
|
|
13803
|
+
const showPagination = useTableStore.use.showPagination();
|
|
13804
|
+
const showContent = useTableStore.use.showContent();
|
|
13805
|
+
const pageSizeOptions = useTableStore.use.pageSizeOptions();
|
|
13806
|
+
const classNames = useTableStore.use.classNames();
|
|
13807
|
+
const effectiveViewMode = useTableStore.use.effectiveViewMode();
|
|
13808
|
+
const cardPagination = useTableStore.use.cardPagination();
|
|
13809
|
+
const data = useTableStore.use.data();
|
|
13810
|
+
const pagination = useTableStore.use.pagination();
|
|
13811
|
+
const manualPagination = useTableStore.use.manualPagination();
|
|
13812
|
+
const pageCount = useTableStore.use.pageCount();
|
|
13390
13813
|
const rowCount = useTableStore.use.rowCount();
|
|
13391
13814
|
const setPagination = useTableStore.use.setPagination();
|
|
13392
13815
|
const isPaginationControlled = useTableStore.use.isPaginationControlled();
|
|
13393
13816
|
const bordered = useTableStore.use.bordered();
|
|
13394
13817
|
if (!table || !showContent || !showPagination || effectiveViewMode === "json" || effectiveViewMode === "files") return null;
|
|
13395
|
-
if (
|
|
13818
|
+
if (cardPagination.mode === "all") return null;
|
|
13819
|
+
if (effectiveViewMode === "cards" && cardPagination.mode === "infinite") return null;
|
|
13396
13820
|
if (effectiveViewMode === "cards" && cardPagination.mode === "load-more") {
|
|
13397
13821
|
return /* @__PURE__ */ jsx(
|
|
13398
13822
|
CardLoadMorePagination,
|
|
@@ -13770,257 +14194,6 @@ function NTableJson() {
|
|
|
13770
14194
|
if (viewMode !== "json") return null;
|
|
13771
14195
|
return /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col min-h-0 overflow-hidden", children: renderJson?.() ?? /* @__PURE__ */ jsx(NajmScroll, { axis: "both", className: "h-full min-h-0 rounded-md border border-border bg-muted/40", children: /* @__PURE__ */ jsx("pre", { className: "p-4 font-mono text-xs leading-relaxed text-foreground", children: formatJsonValue(jsonValue) }) }) });
|
|
13772
14196
|
}
|
|
13773
|
-
var DEFAULT_ROWS2 = 6;
|
|
13774
|
-
var DEFAULT_CARD_COUNT = 16;
|
|
13775
|
-
function NTableHeaderSkeleton() {
|
|
13776
|
-
const filters = useTableStore.use.filters();
|
|
13777
|
-
const showViewToggle = useTableStore.use.showViewToggle();
|
|
13778
|
-
const showColumnVisibility = useTableStore.use.showColumnVisibility();
|
|
13779
|
-
const showAddButton = useTableStore.use.showAddButton();
|
|
13780
|
-
const hasHeaderSlot = Boolean(useTableStore.use.headerSlot());
|
|
13781
|
-
const hasToolbar = Boolean(useTableStore.use.renderToolbar());
|
|
13782
|
-
const filterCount = Math.min(Math.max(filters?.length ?? 0, 1), 3);
|
|
13783
|
-
const hasActions = showViewToggle || showColumnVisibility || showAddButton || hasHeaderSlot || hasToolbar;
|
|
13784
|
-
const hasSettings = showViewToggle || showColumnVisibility || hasHeaderSlot || hasToolbar;
|
|
13785
|
-
if (!filters?.length && !hasActions) return null;
|
|
13786
|
-
return /* @__PURE__ */ jsxs(
|
|
13787
|
-
"div",
|
|
13788
|
-
{
|
|
13789
|
-
"data-ntable-loading-header": true,
|
|
13790
|
-
className: "flex shrink-0 flex-wrap items-center justify-between gap-2",
|
|
13791
|
-
children: [
|
|
13792
|
-
filters?.length ? /* @__PURE__ */ jsx(
|
|
13793
|
-
"div",
|
|
13794
|
-
{
|
|
13795
|
-
"data-ntable-loading-desktop-filters": true,
|
|
13796
|
-
className: "hidden min-w-0 flex-1 flex-wrap gap-2 md:flex",
|
|
13797
|
-
children: Array.from({ length: filterCount }).map((_, index) => /* @__PURE__ */ jsx(
|
|
13798
|
-
NSkeleton,
|
|
13799
|
-
{
|
|
13800
|
-
className: cn("h-10 w-full rounded-lg", index < 2 ? "max-w-64" : "max-w-48")
|
|
13801
|
-
},
|
|
13802
|
-
index
|
|
13803
|
-
))
|
|
13804
|
-
}
|
|
13805
|
-
) : /* @__PURE__ */ jsx("span", { className: "hidden min-w-0 flex-1 md:block" }),
|
|
13806
|
-
/* @__PURE__ */ jsxs(
|
|
13807
|
-
"div",
|
|
13808
|
-
{
|
|
13809
|
-
"data-ntable-loading-mobile-toolbar": true,
|
|
13810
|
-
className: "flex w-full min-w-0 items-center gap-2 md:hidden",
|
|
13811
|
-
children: [
|
|
13812
|
-
filters?.length ? /* @__PURE__ */ jsx(
|
|
13813
|
-
NSkeleton,
|
|
13814
|
-
{
|
|
13815
|
-
"data-ntable-loading-mobile-primary": true,
|
|
13816
|
-
className: "h-10 min-w-0 flex-1 rounded-lg"
|
|
13817
|
-
}
|
|
13818
|
-
) : null,
|
|
13819
|
-
filters?.length > 1 ? /* @__PURE__ */ jsx(
|
|
13820
|
-
NSkeleton,
|
|
13821
|
-
{
|
|
13822
|
-
"data-ntable-loading-mobile-filter-button": true,
|
|
13823
|
-
className: "h-10 w-10 shrink-0 rounded-lg"
|
|
13824
|
-
}
|
|
13825
|
-
) : null,
|
|
13826
|
-
showAddButton ? /* @__PURE__ */ jsx(
|
|
13827
|
-
NSkeleton,
|
|
13828
|
-
{
|
|
13829
|
-
"data-ntable-loading-mobile-add-button": true,
|
|
13830
|
-
className: "h-10 w-10 shrink-0 rounded-lg"
|
|
13831
|
-
}
|
|
13832
|
-
) : null
|
|
13833
|
-
]
|
|
13834
|
-
}
|
|
13835
|
-
),
|
|
13836
|
-
hasActions && /* @__PURE__ */ jsxs("div", { className: "hidden shrink-0 gap-2 md:flex", children: [
|
|
13837
|
-
hasSettings && /* @__PURE__ */ jsx(NSkeleton, { className: "h-10 w-10 rounded-lg" }),
|
|
13838
|
-
showAddButton && /* @__PURE__ */ jsx(NSkeleton, { className: "h-10 w-10 rounded-lg" })
|
|
13839
|
-
] })
|
|
13840
|
-
]
|
|
13841
|
-
}
|
|
13842
|
-
);
|
|
13843
|
-
}
|
|
13844
|
-
function NTableLoadingSkeleton({ rows }) {
|
|
13845
|
-
const rawColumns = useTableStore.use.columns();
|
|
13846
|
-
const responsiveColumns = React__default.useMemo(() => filterResponsiveColumns(rawColumns), [rawColumns]);
|
|
13847
|
-
const columns = responsiveColumns;
|
|
13848
|
-
const showCheckbox = useTableStore.use.showCheckbox();
|
|
13849
|
-
const headerClassName = useTableStore.use.headerClassName();
|
|
13850
|
-
const classNames = useTableStore.use.classNames();
|
|
13851
|
-
const dynamicHeight = useTableStore.use.dynamicHeight();
|
|
13852
|
-
const bordered = useTableStore.use.bordered();
|
|
13853
|
-
const borderColor = useTableStore.use.borderColor();
|
|
13854
|
-
const surface = useTableSurfaceAppearance(bordered, borderColor);
|
|
13855
|
-
const bodyHeight = useTableStore.use.bodyHeight();
|
|
13856
|
-
const skeletonRowCount = useTableStore.use.skeletonRowCount();
|
|
13857
|
-
const renderSubRow = useTableStore.use.renderSubRow();
|
|
13858
|
-
const userGetRowCanExpand = useTableStore.use.getRowCanExpand();
|
|
13859
|
-
const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
|
|
13860
|
-
const loadingText = useTableStore.use.loadingText();
|
|
13861
|
-
const rowCount = rows ?? (dynamicHeight && bodyHeight > 0 ? skeletonRowCount : DEFAULT_ROWS2);
|
|
13862
|
-
const renderHeaderLabel = (header) => typeof header === "string" ? header : null;
|
|
13863
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
13864
|
-
/* @__PURE__ */ jsx(NTableHeaderSkeleton, {}),
|
|
13865
|
-
/* @__PURE__ */ jsxs(
|
|
13866
|
-
"div",
|
|
13867
|
-
{
|
|
13868
|
-
"data-testid": "ntable-loading-skeleton",
|
|
13869
|
-
"data-ntable-loading-row-count": rowCount,
|
|
13870
|
-
"data-bordered": surface.bordered === false ? "false" : surface.bordered ? "true" : void 0,
|
|
13871
|
-
"aria-busy": "true",
|
|
13872
|
-
"aria-label": loadingText,
|
|
13873
|
-
role: "status",
|
|
13874
|
-
style: surface.style,
|
|
13875
|
-
className: cn("min-h-0 flex-1 rounded-md p-0", surface.className, dynamicHeight ? "overflow-hidden" : "najm-overlay-scroll", classNames?.content),
|
|
13876
|
-
children: [
|
|
13877
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }),
|
|
13878
|
-
/* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: dynamicHeight ? "najm-overlay-scroll h-full" : void 0, children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
13879
|
-
/* @__PURE__ */ jsx(TableHeader, { "data-ntable-table-header": true, className: cn(headerClassName, "sticky top-0 z-10", classNames?.tableHeader), children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-muted/30", children: [
|
|
13880
|
-
showCheckbox && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Select column", className: "w-10 text-foreground h-12" }),
|
|
13881
|
-
hasExpansion && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Expand column", className: "w-10 text-foreground h-12" }),
|
|
13882
|
-
columns.map((col, i) => /* @__PURE__ */ jsx(
|
|
13883
|
-
TableHead,
|
|
13884
|
-
{
|
|
13885
|
-
className: cn("text-foreground h-12", resolveHiddenBelowClass(col?.meta?.hiddenBelow)),
|
|
13886
|
-
style: col?.size ? { width: col.size } : void 0,
|
|
13887
|
-
children: renderHeaderLabel(col?.header)
|
|
13888
|
-
},
|
|
13889
|
-
col?.id ?? col?.accessorKey ?? i
|
|
13890
|
-
))
|
|
13891
|
-
] }) }),
|
|
13892
|
-
/* @__PURE__ */ jsx(TableBody, { children: Array.from({ length: rowCount }).map((_, r) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
13893
|
-
showCheckbox && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
|
|
13894
|
-
hasExpansion && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
|
|
13895
|
-
columns.map((col, c) => /* @__PURE__ */ jsx(
|
|
13896
|
-
TableCell,
|
|
13897
|
-
{
|
|
13898
|
-
className: cn("h-14", resolveHiddenBelowClass(col?.meta?.hiddenBelow)),
|
|
13899
|
-
style: col?.size ? { width: col.size } : void 0,
|
|
13900
|
-
children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-full" })
|
|
13901
|
-
},
|
|
13902
|
-
`skeleton-${r}-${col?.id ?? col?.accessorKey ?? c}`
|
|
13903
|
-
))
|
|
13904
|
-
] }, `skeleton-${r}`)) })
|
|
13905
|
-
] }) })
|
|
13906
|
-
]
|
|
13907
|
-
}
|
|
13908
|
-
)
|
|
13909
|
-
] });
|
|
13910
|
-
}
|
|
13911
|
-
function NTableCardsLoadingSkeleton({ rows }) {
|
|
13912
|
-
const filters = useTableStore.use.filters();
|
|
13913
|
-
const showViewToggle = useTableStore.use.showViewToggle();
|
|
13914
|
-
const showColumnVisibility = useTableStore.use.showColumnVisibility();
|
|
13915
|
-
const showAddButton = useTableStore.use.showAddButton();
|
|
13916
|
-
const hasHeaderSlot = Boolean(useTableStore.use.headerSlot());
|
|
13917
|
-
const hasToolbar = Boolean(useTableStore.use.renderToolbar());
|
|
13918
|
-
const hasHeaderSkeleton = Boolean(
|
|
13919
|
-
filters?.length || showViewToggle || showColumnVisibility || showAddButton || hasHeaderSlot || hasToolbar
|
|
13920
|
-
);
|
|
13921
|
-
const classNames = useTableStore.use.classNames();
|
|
13922
|
-
const bordered = useTableStore.use.bordered();
|
|
13923
|
-
const borderColor = useTableStore.use.borderColor();
|
|
13924
|
-
const surface = useTableSurfaceAppearance(bordered, borderColor);
|
|
13925
|
-
const dynamicHeight = useTableStore.use.dynamicHeight();
|
|
13926
|
-
const bodyHeight = useTableStore.use.bodyHeight();
|
|
13927
|
-
const cardColumnCount = useTableStore.use.cardColumnCount();
|
|
13928
|
-
const cardRowHeight = useTableStore.use.cardRowHeight();
|
|
13929
|
-
const cardGap = useTableStore.use.cardGap();
|
|
13930
|
-
const loadingText = useTableStore.use.loadingText();
|
|
13931
|
-
const cardCount = rows ?? (dynamicHeight && bodyHeight > 0 ? calculateCardSkeletonCount({
|
|
13932
|
-
bodyHeight,
|
|
13933
|
-
columnCount: cardColumnCount,
|
|
13934
|
-
cardHeight: cardRowHeight,
|
|
13935
|
-
gap: cardGap
|
|
13936
|
-
}) : DEFAULT_CARD_COUNT);
|
|
13937
|
-
const defaultContainerClass = "grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4";
|
|
13938
|
-
const containerClass = classNames?.cards ?? defaultContainerClass;
|
|
13939
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
13940
|
-
hasHeaderSkeleton && /* @__PURE__ */ jsx(NTableHeaderSkeleton, {}),
|
|
13941
|
-
/* @__PURE__ */ jsxs(
|
|
13942
|
-
NajmScroll,
|
|
13943
|
-
{
|
|
13944
|
-
axis: "y",
|
|
13945
|
-
"aria-busy": "true",
|
|
13946
|
-
"aria-label": loadingText,
|
|
13947
|
-
role: "status",
|
|
13948
|
-
className: "min-h-0 flex-1 overflow-hidden",
|
|
13949
|
-
children: [
|
|
13950
|
-
/* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }),
|
|
13951
|
-
/* @__PURE__ */ jsx(
|
|
13952
|
-
"div",
|
|
13953
|
-
{
|
|
13954
|
-
"data-testid": "ntable-cards-loading-skeleton",
|
|
13955
|
-
"data-ntable-loading-cards-grid": true,
|
|
13956
|
-
"data-ntable-loading-card-count": cardCount,
|
|
13957
|
-
"aria-hidden": "true",
|
|
13958
|
-
className: cn(containerClass),
|
|
13959
|
-
children: Array.from({ length: cardCount }).map((_, index) => /* @__PURE__ */ jsx(
|
|
13960
|
-
"div",
|
|
13961
|
-
{
|
|
13962
|
-
"data-ntable-loading-card": true,
|
|
13963
|
-
"data-bordered": surface.bordered === false ? "false" : surface.bordered ? "true" : void 0,
|
|
13964
|
-
style: surface.style,
|
|
13965
|
-
className: cn("rounded-lg p-3 sm:p-4", surface.className),
|
|
13966
|
-
children: /* @__PURE__ */ jsxs(
|
|
13967
|
-
"div",
|
|
13968
|
-
{
|
|
13969
|
-
"data-ntable-loading-card-layout": "responsive-avatar",
|
|
13970
|
-
className: "grid grid-cols-[80px_minmax(0,1fr)] gap-3 sm:grid-cols-[72px_minmax(0,1fr)]",
|
|
13971
|
-
children: [
|
|
13972
|
-
/* @__PURE__ */ jsx("div", { className: "col-start-1 row-start-1 flex items-start justify-center sm:justify-start", children: /* @__PURE__ */ jsx(
|
|
13973
|
-
NSkeleton,
|
|
13974
|
-
{
|
|
13975
|
-
"data-ntable-loading-card-avatar": true,
|
|
13976
|
-
className: "size-20 shrink-0 rounded-full sm:size-16"
|
|
13977
|
-
}
|
|
13978
|
-
) }),
|
|
13979
|
-
/* @__PURE__ */ jsxs("div", { className: "col-start-2 row-start-1 flex min-w-0 items-start justify-between gap-3", children: [
|
|
13980
|
-
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-2", children: [
|
|
13981
|
-
/* @__PURE__ */ jsx(NSkeleton, { className: "h-5 w-36 max-w-full" }),
|
|
13982
|
-
/* @__PURE__ */ jsx(NSkeleton, { className: "hidden h-3 w-16 sm:block" })
|
|
13983
|
-
] }),
|
|
13984
|
-
/* @__PURE__ */ jsx(
|
|
13985
|
-
NSkeleton,
|
|
13986
|
-
{
|
|
13987
|
-
"data-ntable-loading-card-status": true,
|
|
13988
|
-
className: "hidden h-6 w-14 shrink-0 rounded-full sm:block"
|
|
13989
|
-
}
|
|
13990
|
-
)
|
|
13991
|
-
] }),
|
|
13992
|
-
/* @__PURE__ */ jsx(
|
|
13993
|
-
"div",
|
|
13994
|
-
{
|
|
13995
|
-
"data-ntable-loading-card-details": true,
|
|
13996
|
-
className: "col-start-2 row-start-2 space-y-1 sm:col-span-full sm:col-start-1 sm:space-y-2 sm:rounded-lg sm:bg-muted/50 sm:p-3",
|
|
13997
|
-
children: Array.from({ length: 3 }).map((_2, detailIndex) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 sm:gap-2", children: [
|
|
13998
|
-
/* @__PURE__ */ jsx(NSkeleton, { className: "size-3.5 shrink-0 rounded-sm sm:size-4" }),
|
|
13999
|
-
/* @__PURE__ */ jsx(
|
|
14000
|
-
NSkeleton,
|
|
14001
|
-
{
|
|
14002
|
-
className: cn(
|
|
14003
|
-
"h-3 max-w-full sm:h-4",
|
|
14004
|
-
detailIndex === 0 ? "w-full" : detailIndex === 1 ? "w-4/5" : "w-3/4"
|
|
14005
|
-
)
|
|
14006
|
-
}
|
|
14007
|
-
)
|
|
14008
|
-
] }, detailIndex))
|
|
14009
|
-
}
|
|
14010
|
-
)
|
|
14011
|
-
]
|
|
14012
|
-
}
|
|
14013
|
-
)
|
|
14014
|
-
},
|
|
14015
|
-
index
|
|
14016
|
-
))
|
|
14017
|
-
}
|
|
14018
|
-
)
|
|
14019
|
-
]
|
|
14020
|
-
}
|
|
14021
|
-
)
|
|
14022
|
-
] });
|
|
14023
|
-
}
|
|
14024
14197
|
function TableStateSlot({ children }) {
|
|
14025
14198
|
return /* @__PURE__ */ jsx("div", { className: "flex min-h-64 flex-1 items-center justify-center", children });
|
|
14026
14199
|
}
|