najm-kit 0.0.26 → 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.
Files changed (2) hide show
  1. package/dist/index.mjs +112 -41
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -9278,6 +9278,30 @@ function NTableJson() {
9278
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) }) }) });
9279
9279
  }
9280
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
+ }
9281
9305
  function NTableLoadingSkeleton({ rows = DEFAULT_ROWS }) {
9282
9306
  const columns = useTableStore.use.columns();
9283
9307
  const showCheckbox = useTableStore.use.showCheckbox();
@@ -9289,46 +9313,94 @@ function NTableLoadingSkeleton({ rows = DEFAULT_ROWS }) {
9289
9313
  const hasExpansion = Boolean(renderSubRow || userGetRowCanExpand);
9290
9314
  const loadingText = useTableStore.use.loadingText();
9291
9315
  const renderHeaderLabel = (header) => typeof header === "string" ? header : null;
9292
- return /* @__PURE__ */ jsxs(
9293
- Card,
9294
- {
9295
- "data-testid": "ntable-loading-skeleton",
9296
- "aria-busy": "true",
9297
- "aria-label": loadingText,
9298
- className: cn("rounded-md p-0 border", dynamicHeight ? "overflow-hidden" : "najm-overlay-scroll", classNames?.content),
9299
- children: [
9300
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: loadingText }),
9301
- /* @__PURE__ */ jsx("div", { className: dynamicHeight ? "najm-overlay-scroll" : void 0, children: /* @__PURE__ */ jsxs(Table, { children: [
9302
- /* @__PURE__ */ jsx(TableHeader, { className: cn(headerClassName, dynamicHeight && "sticky top-0 z-10", classNames?.tableHeader), children: /* @__PURE__ */ jsxs(TableRow, { className: "hover:bg-muted/30", children: [
9303
- showCheckbox && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Select column", className: "w-10 text-foreground h-12" }),
9304
- hasExpansion && /* @__PURE__ */ jsx(TableHead, { "aria-label": "Expand column", className: "w-10 text-foreground h-12" }),
9305
- columns.map((col, i) => /* @__PURE__ */ jsx(
9306
- TableHead,
9307
- {
9308
- className: "text-foreground h-12",
9309
- style: col?.size ? { width: col.size } : void 0,
9310
- children: renderHeaderLabel(col?.header)
9311
- },
9312
- col?.id ?? col?.accessorKey ?? i
9313
- ))
9314
- ] }) }),
9315
- /* @__PURE__ */ jsx(TableBody, { children: Array.from({ length: rows }).map((_, r) => /* @__PURE__ */ jsxs(TableRow, { children: [
9316
- showCheckbox && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
9317
- hasExpansion && /* @__PURE__ */ jsx(TableCell, { className: "h-14 w-10", children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-4" }) }),
9318
- columns.map((col, c) => /* @__PURE__ */ jsx(
9319
- TableCell,
9320
- {
9321
- className: "h-14",
9322
- style: col?.size ? { width: col.size } : void 0,
9323
- children: /* @__PURE__ */ jsx(NSkeleton, { className: "h-4 w-full" })
9324
- },
9325
- `skeleton-${r}-${col?.id ?? col?.accessorKey ?? c}`
9326
- ))
9327
- ] }, `skeleton-${r}`)) })
9328
- ] }) })
9329
- ]
9330
- }
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
9331
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
+ ] });
9332
9404
  }
9333
9405
  function TableStateSlot({ children }) {
9334
9406
  return /* @__PURE__ */ jsx("div", { className: "flex min-h-64 flex-1 items-center justify-center", children });
@@ -9370,7 +9442,6 @@ function TableLayout(props) {
9370
9442
  const isLoading = useTableStore.use.isLoading();
9371
9443
  const error = useTableStore.use.error();
9372
9444
  const hasNoData = useTableStore.use.hasNoData();
9373
- const loadingText = useTableStore.use.loadingText();
9374
9445
  const noDataText = useTableStore.use.noDataText();
9375
9446
  const isFilteredEmpty = useTableStore.use.isFilteredEmpty();
9376
9447
  const renderFilteredEmpty = useTableStore.use.renderFilteredEmpty();
@@ -9406,7 +9477,7 @@ function TableLayout(props) {
9406
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: [
9407
9478
  /* @__PURE__ */ jsx(NTableHeader, {}),
9408
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: [
9409
- isLoading && (props.renderLoading ? /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderLoading() }) : effectiveMode === "table" ? /* @__PURE__ */ jsx(NTableLoadingSkeleton, {}) : /* @__PURE__ */ jsx(TableStateSlot, { children: /* @__PURE__ */ jsx(NLoadingState, { label: loadingText }) })),
9480
+ isLoading && (props.renderLoading ? /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderLoading() }) : effectiveMode === "table" ? /* @__PURE__ */ jsx(NTableLoadingSkeleton, {}) : effectiveMode === "cards" ? /* @__PURE__ */ jsx(NTableCardsLoadingSkeleton, {}) : /* @__PURE__ */ jsx(NTableLoadingSkeleton, {})),
9410
9481
  error && !isLoading && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderError ? props.renderError(error) : /* @__PURE__ */ jsx(NErrorState, { message: typeof error === "string" ? error : "An error occurred" }) }),
9411
9482
  showFilteredEmpty && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderFilteredEmpty ? props.renderFilteredEmpty() : renderFilteredEmpty ? renderFilteredEmpty() : props.renderEmpty ? props.renderEmpty() : /* @__PURE__ */ jsx(DefaultTableFilteredEmptyState, {}) }),
9412
9483
  showEmpty && /* @__PURE__ */ jsx(TableStateSlot, { children: props.renderEmpty ? props.renderEmpty() : /* @__PURE__ */ jsx(DefaultTableEmptyState, { title: noDataText }) }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najm-kit",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "type": "module",
5
5
  "description": "Reusable React UI component package for Najm framework",
6
6
  "main": "./dist/index.mjs",