najm-kit 0.0.25 → 0.0.27
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/dist/index.d.ts +1 -0
- package/dist/index.mjs +113 -41
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -2561,6 +2561,7 @@ function useDialog(store) {
|
|
|
2561
2561
|
itemName: options.itemName,
|
|
2562
2562
|
itemType: options.itemType,
|
|
2563
2563
|
icon: options.icon,
|
|
2564
|
+
warningText: options.warningText,
|
|
2564
2565
|
title: dialog.title,
|
|
2565
2566
|
description: dialog.description,
|
|
2566
2567
|
confirmText: dialog.primaryButton?.text,
|
|
@@ -9277,6 +9278,30 @@ function NTableJson() {
|
|
|
9277
9278
|
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) }) }) });
|
|
9278
9279
|
}
|
|
9279
9280
|
var DEFAULT_ROWS = 6;
|
|
9281
|
+
function NTableHeaderSkeleton() {
|
|
9282
|
+
const filters = useTableStore.use.filters();
|
|
9283
|
+
const showViewToggle = useTableStore.use.showViewToggle();
|
|
9284
|
+
const showColumnVisibility = useTableStore.use.showColumnVisibility();
|
|
9285
|
+
const showAddButton = useTableStore.use.showAddButton();
|
|
9286
|
+
const hasHeaderSlot = Boolean(useTableStore.use.headerSlot());
|
|
9287
|
+
const hasToolbar = Boolean(useTableStore.use.renderToolbar());
|
|
9288
|
+
const filterCount = Math.min(Math.max(filters?.length ?? 0, 1), 3);
|
|
9289
|
+
const hasActions = showViewToggle || showColumnVisibility || showAddButton || hasHeaderSlot || hasToolbar;
|
|
9290
|
+
if (!filters?.length && !hasActions) return null;
|
|
9291
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 flex-wrap items-center justify-between gap-2", children: [
|
|
9292
|
+
filters?.length ? /* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 flex-wrap gap-2", children: Array.from({ length: filterCount }).map((_, index) => /* @__PURE__ */ jsx(
|
|
9293
|
+
NSkeleton,
|
|
9294
|
+
{
|
|
9295
|
+
className: cn("h-10 w-full rounded-lg", index < 2 ? "max-w-64" : "max-w-48")
|
|
9296
|
+
},
|
|
9297
|
+
index
|
|
9298
|
+
)) }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
|
|
9299
|
+
hasActions && /* @__PURE__ */ jsxs("div", { className: "flex shrink-0 gap-2", children: [
|
|
9300
|
+
(showViewToggle || showColumnVisibility || hasHeaderSlot || hasToolbar) && /* @__PURE__ */ jsx(NSkeleton, { className: "h-10 w-10 rounded-lg" }),
|
|
9301
|
+
showAddButton && /* @__PURE__ */ jsx(NSkeleton, { className: "h-10 w-10 rounded-lg" })
|
|
9302
|
+
] })
|
|
9303
|
+
] });
|
|
9304
|
+
}
|
|
9280
9305
|
function NTableLoadingSkeleton({ rows = DEFAULT_ROWS }) {
|
|
9281
9306
|
const columns = useTableStore.use.columns();
|
|
9282
9307
|
const showCheckbox = useTableStore.use.showCheckbox();
|
|
@@ -9288,46 +9313,94 @@ function NTableLoadingSkeleton({ rows = DEFAULT_ROWS }) {
|
|
|
9288
9313
|
const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
|
|
9289
9314
|
const loadingText = useTableStore.use.loadingText();
|
|
9290
9315
|
const renderHeaderLabel = (header) => typeof header === "string" ? header : null;
|
|
9291
|
-
return /* @__PURE__ */ jsxs(
|
|
9292
|
-
|
|
9293
|
-
|
|
9294
|
-
|
|
9295
|
-
|
|
9296
|
-
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
/* @__PURE__ */ jsx(
|
|
9302
|
-
|
|
9303
|
-
|
|
9304
|
-
|
|
9305
|
-
TableHead,
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
|
|
9309
|
-
|
|
9310
|
-
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
|
|
9316
|
-
|
|
9317
|
-
|
|
9318
|
-
TableCell,
|
|
9319
|
-
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9323
|
-
|
|
9324
|
-
|
|
9325
|
-
|
|
9326
|
-
|
|
9327
|
-
|
|
9328
|
-
|
|
9329
|
-
|
|
9316
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
9317
|
+
/* @__PURE__ */ jsx(NTableHeaderSkeleton, {}),
|
|
9318
|
+
/* @__PURE__ */ jsxs(
|
|
9319
|
+
Card,
|
|
9320
|
+
{
|
|
9321
|
+
"data-testid": "ntable-loading-skeleton",
|
|
9322
|
+
"aria-busy": "true",
|
|
9323
|
+
"aria-label": loadingText,
|
|
9324
|
+
className: cn("rounded-md p-0 border", dynamicHeight ? "overflow-hidden" : "najm-overlay-scroll", classNames?.content),
|
|
9325
|
+
children: [
|
|
9326
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }),
|
|
9327
|
+
/* @__PURE__ */ jsx("div", { className: dynamicHeight ? "najm-overlay-scroll" : void 0, children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
9328
|
+
/* @__PURE__ */ jsx(TableHeader, { className: cn(headerClassName, dynamicHeight && "sticky top-0 z-10", classNames?.tableHeader), children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-muted/30", children: [
|
|
9329
|
+
showCheckbox && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Select column", className: "w-10 text-foreground h-12" }),
|
|
9330
|
+
hasExpansion && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Expand column", className: "w-10 text-foreground h-12" }),
|
|
9331
|
+
columns.map((col, i) => /* @__PURE__ */ jsx(
|
|
9332
|
+
TableHead,
|
|
9333
|
+
{
|
|
9334
|
+
className: "text-foreground h-12",
|
|
9335
|
+
style: col?.size ? { width: col.size } : void 0,
|
|
9336
|
+
children: renderHeaderLabel(col?.header)
|
|
9337
|
+
},
|
|
9338
|
+
col?.id ?? col?.accessorKey ?? i
|
|
9339
|
+
))
|
|
9340
|
+
] }) }),
|
|
9341
|
+
/* @__PURE__ */ jsx(TableBody, { children: Array.from({ length: rows }).map((_, r) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
9342
|
+
showCheckbox && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
|
|
9343
|
+
hasExpansion && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
|
|
9344
|
+
columns.map((col, c) => /* @__PURE__ */ jsx(
|
|
9345
|
+
TableCell,
|
|
9346
|
+
{
|
|
9347
|
+
className: "h-14",
|
|
9348
|
+
style: col?.size ? { width: col.size } : void 0,
|
|
9349
|
+
children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-full" })
|
|
9350
|
+
},
|
|
9351
|
+
`skeleton-${r}-${col?.id ?? col?.accessorKey ?? c}`
|
|
9352
|
+
))
|
|
9353
|
+
] }, `skeleton-${r}`)) })
|
|
9354
|
+
] }) })
|
|
9355
|
+
]
|
|
9356
|
+
}
|
|
9357
|
+
)
|
|
9358
|
+
] });
|
|
9359
|
+
}
|
|
9360
|
+
function NTableCardsLoadingSkeleton({ rows = 8 }) {
|
|
9361
|
+
const filters = useTableStore.use.filters();
|
|
9362
|
+
const showViewToggle = useTableStore.use.showViewToggle();
|
|
9363
|
+
const showColumnVisibility = useTableStore.use.showColumnVisibility();
|
|
9364
|
+
const showAddButton = useTableStore.use.showAddButton();
|
|
9365
|
+
const hasHeaderSlot = Boolean(useTableStore.use.headerSlot());
|
|
9366
|
+
const hasToolbar = Boolean(useTableStore.use.renderToolbar());
|
|
9367
|
+
const hasHeaderSkeleton = Boolean(
|
|
9368
|
+
filters?.length || showViewToggle || showColumnVisibility || showAddButton || hasHeaderSlot || hasToolbar
|
|
9330
9369
|
);
|
|
9370
|
+
const classNames = useTableStore.use.classNames();
|
|
9371
|
+
const bordered = useTableStore.use.bordered();
|
|
9372
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col gap-2", children: [
|
|
9373
|
+
hasHeaderSkeleton && /* @__PURE__ */ jsx(NTableHeaderSkeleton, {}),
|
|
9374
|
+
/* @__PURE__ */ jsx(
|
|
9375
|
+
"div",
|
|
9376
|
+
{
|
|
9377
|
+
"data-testid": "ntable-cards-loading-skeleton",
|
|
9378
|
+
"aria-busy": "true",
|
|
9379
|
+
className: cn("grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4", classNames?.cards),
|
|
9380
|
+
children: Array.from({ length: rows }).map((_, index) => /* @__PURE__ */ jsx(
|
|
9381
|
+
Card,
|
|
9382
|
+
{
|
|
9383
|
+
className: cn("rounded-lg bg-card p-4 shadow-none", bordered ? "border" : "border border-border"),
|
|
9384
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-4", children: [
|
|
9385
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-12 w-12 shrink-0 rounded-full" }),
|
|
9386
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-3", children: [
|
|
9387
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
9388
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-5 w-36" }),
|
|
9389
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-3 w-48 max-w-full" })
|
|
9390
|
+
] }),
|
|
9391
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
9392
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-full" }),
|
|
9393
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4/5" }),
|
|
9394
|
+
/* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-3/4" })
|
|
9395
|
+
] })
|
|
9396
|
+
] })
|
|
9397
|
+
] })
|
|
9398
|
+
},
|
|
9399
|
+
index
|
|
9400
|
+
))
|
|
9401
|
+
}
|
|
9402
|
+
)
|
|
9403
|
+
] });
|
|
9331
9404
|
}
|
|
9332
9405
|
function TableStateSlot({ children }) {
|
|
9333
9406
|
return /* @__PURE__ */ jsx("div", { className: "flex min-h-64 flex-1 items-center justify-center", children });
|
|
@@ -9369,7 +9442,6 @@ function TableLayout(props) {
|
|
|
9369
9442
|
const isLoading = useTableStore.use.isLoading();
|
|
9370
9443
|
const error = useTableStore.use.error();
|
|
9371
9444
|
const hasNoData = useTableStore.use.hasNoData();
|
|
9372
|
-
const loadingText = useTableStore.use.loadingText();
|
|
9373
9445
|
const noDataText = useTableStore.use.noDataText();
|
|
9374
9446
|
const isFilteredEmpty = useTableStore.use.isFilteredEmpty();
|
|
9375
9447
|
const renderFilteredEmpty = useTableStore.use.renderFilteredEmpty();
|
|
@@ -9405,7 +9477,7 @@ function TableLayout(props) {
|
|
|
9405
9477
|
return /* @__PURE__ */ jsxs("div", { ref: containerRef, "data-ntable-root": true, className: cn("flex h-full min-h-0 flex-1 w-full flex-col gap-2 overflow-hidden", classNames?.root, className), children: [
|
|
9406
9478
|
/* @__PURE__ */ jsx(NTableHeader, {}),
|
|
9407
9479
|
/* @__PURE__ */ jsx("div", { "data-ntable-body": true, className: "flex min-h-0 flex-1 flex-col gap-2 overflow-hidden", children: isCustomMode ? customRenderer ? customRenderer() : null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
9408
|
-
isLoading && (props.renderLoading ? /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderLoading() }) : effectiveMode === "table" ? /* @__PURE__ */ jsx(NTableLoadingSkeleton, {}) : /* @__PURE__ */ jsx(
|
|
9480
|
+
isLoading && (props.renderLoading ? /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderLoading() }) : effectiveMode === "table" ? /* @__PURE__ */ jsx(NTableLoadingSkeleton, {}) : effectiveMode === "cards" ? /* @__PURE__ */ jsx(NTableCardsLoadingSkeleton, {}) : /* @__PURE__ */ jsx(NTableLoadingSkeleton, {})),
|
|
9409
9481
|
error && !isLoading && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderError ? props.renderError(error) : /* @__PURE__ */ jsx(NErrorState, { message: typeof error === "string" ? error : "An error occurred" }) }),
|
|
9410
9482
|
showFilteredEmpty && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderFilteredEmpty ? props.renderFilteredEmpty() : renderFilteredEmpty ? renderFilteredEmpty() : props.renderEmpty ? props.renderEmpty() : /* @__PURE__ */ jsx(DefaultTableFilteredEmptyState, {}) }),
|
|
9411
9483
|
showEmpty && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderEmpty ? props.renderEmpty() : /* @__PURE__ */ jsx(DefaultTableEmptyState, { title: noDataText }) }),
|