shadcn-ui-react 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -26
- package/dist/index.cjs +333 -132
- package/dist/index.d.cts +146 -9
- package/dist/index.d.ts +146 -9
- package/dist/index.js +340 -138
- package/dist/style.css +535 -21
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -8182,18 +8182,223 @@ function Breadcrumbs({ items, className, classNameList }) {
|
|
|
8182
8182
|
}
|
|
8183
8183
|
|
|
8184
8184
|
// src/shared/data-table.tsx
|
|
8185
|
-
import React67, {
|
|
8185
|
+
import React67, { useMemo as useMemo3 } from "react";
|
|
8186
8186
|
import { AnimatePresence, motion as motion2 } from "framer-motion";
|
|
8187
|
-
import {
|
|
8187
|
+
import {
|
|
8188
|
+
DoubleArrowLeftIcon,
|
|
8189
|
+
DoubleArrowRightIcon
|
|
8190
|
+
} from "@radix-ui/react-icons";
|
|
8188
8191
|
import {
|
|
8189
8192
|
flexRender,
|
|
8190
8193
|
getCoreRowModel,
|
|
8191
8194
|
getFilteredRowModel,
|
|
8192
|
-
getPaginationRowModel,
|
|
8193
8195
|
useReactTable
|
|
8194
8196
|
} from "@tanstack/react-table";
|
|
8195
|
-
import {
|
|
8197
|
+
import { ChevronLeft as ChevronLeft3, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
8196
8198
|
import { jsx as jsx48, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
8199
|
+
var TablePlain = React67.forwardRef((_a, ref) => {
|
|
8200
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
8201
|
+
return /* @__PURE__ */ jsx48(
|
|
8202
|
+
"table",
|
|
8203
|
+
__spreadValues({
|
|
8204
|
+
ref,
|
|
8205
|
+
className: cn("w-full caption-bottom text-sm", className)
|
|
8206
|
+
}, props)
|
|
8207
|
+
);
|
|
8208
|
+
});
|
|
8209
|
+
TablePlain.displayName = "TablePlain";
|
|
8210
|
+
var ACCENT_COLOR = {
|
|
8211
|
+
primary: "var(--primary)",
|
|
8212
|
+
emerald: "#10b981",
|
|
8213
|
+
indigo: "#6366f1",
|
|
8214
|
+
rose: "#f43f5e",
|
|
8215
|
+
amber: "#f59e0b",
|
|
8216
|
+
zinc: "#71717a"
|
|
8217
|
+
};
|
|
8218
|
+
function resolveAccent(accent, accentColor) {
|
|
8219
|
+
var _a;
|
|
8220
|
+
const custom = accentColor == null ? void 0 : accentColor.trim();
|
|
8221
|
+
if (custom) return custom;
|
|
8222
|
+
if (!accent) return void 0;
|
|
8223
|
+
return (_a = ACCENT_COLOR[accent]) != null ? _a : ACCENT_COLOR.primary;
|
|
8224
|
+
}
|
|
8225
|
+
var DATA_TABLE_TEMPLATES = {
|
|
8226
|
+
neo: {
|
|
8227
|
+
root: cn(
|
|
8228
|
+
"relative w-full overflow-hidden rounded-2xl border shadow-sm",
|
|
8229
|
+
"bg-background/70 supports-[backdrop-filter]:bg-background/45 backdrop-blur",
|
|
8230
|
+
"flex flex-col",
|
|
8231
|
+
"before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
|
|
8232
|
+
"data-[accent=on]:before:bg-[color:var(--dt-accent)]"
|
|
8233
|
+
),
|
|
8234
|
+
table: cn("w-full text-sm"),
|
|
8235
|
+
thead: "border-b",
|
|
8236
|
+
theadSticky: "sticky top-0 z-10 bg-background/85 supports-[backdrop-filter]:bg-background/60 backdrop-blur",
|
|
8237
|
+
trHead: "hover:bg-transparent",
|
|
8238
|
+
th: cn(
|
|
8239
|
+
"h-11 px-4 text-left align-middle whitespace-nowrap",
|
|
8240
|
+
"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground"
|
|
8241
|
+
),
|
|
8242
|
+
tbody: cn(
|
|
8243
|
+
"[&_tr:last-child]:border-0",
|
|
8244
|
+
"[&>tr:nth-child(even)]:bg-muted/20"
|
|
8245
|
+
),
|
|
8246
|
+
tr: cn(
|
|
8247
|
+
"border-b transition-colors",
|
|
8248
|
+
"data-[state=selected]:bg-muted/35",
|
|
8249
|
+
"data-[accent=on]:data-[state=selected]:bg-[color:var(--dt-accent)]/10"
|
|
8250
|
+
),
|
|
8251
|
+
trClickable: cn(
|
|
8252
|
+
"cursor-pointer",
|
|
8253
|
+
"hover:bg-muted/35 active:bg-muted/45",
|
|
8254
|
+
"data-[accent=on]:hover:bg-[color:var(--dt-accent)]/8",
|
|
8255
|
+
"data-[accent=on]:active:bg-[color:var(--dt-accent)]/12"
|
|
8256
|
+
),
|
|
8257
|
+
td: "px-4 py-3 align-middle",
|
|
8258
|
+
footer: cn(
|
|
8259
|
+
"border-t",
|
|
8260
|
+
"bg-background/80 supports-[backdrop-filter]:bg-background/55 backdrop-blur"
|
|
8261
|
+
),
|
|
8262
|
+
footerInner: "px-4 py-3",
|
|
8263
|
+
metaWrap: "flex flex-wrap items-center gap-x-3 gap-y-1 text-sm text-muted-foreground",
|
|
8264
|
+
controlsWrap: "flex flex-wrap items-center justify-between gap-3 sm:justify-end",
|
|
8265
|
+
pageSizeLabel: "text-sm font-medium whitespace-nowrap",
|
|
8266
|
+
pageSizeTrigger: cn(
|
|
8267
|
+
"h-8 w-[5rem]",
|
|
8268
|
+
"border-muted-foreground/20",
|
|
8269
|
+
"focus-visible:ring-2 focus-visible:ring-ring",
|
|
8270
|
+
"data-[accent=on]:focus-visible:ring-[color:var(--dt-accent)]/35"
|
|
8271
|
+
),
|
|
8272
|
+
pageLabel: "hidden sm:flex min-w-[9.25rem] items-center justify-center text-sm font-medium",
|
|
8273
|
+
navButton: cn(
|
|
8274
|
+
"h-8 w-8 p-0 rounded-md",
|
|
8275
|
+
"border-muted-foreground/20",
|
|
8276
|
+
"hover:bg-muted/35 hover:border-muted-foreground/40",
|
|
8277
|
+
"focus-visible:ring-2 focus-visible:ring-ring",
|
|
8278
|
+
"data-[accent=on]:hover:border-[color:var(--dt-accent)]/45",
|
|
8279
|
+
"data-[accent=on]:hover:bg-[color:var(--dt-accent)]/10",
|
|
8280
|
+
"data-[accent=on]:focus-visible:ring-[color:var(--dt-accent)]/35"
|
|
8281
|
+
)
|
|
8282
|
+
},
|
|
8283
|
+
glass: {
|
|
8284
|
+
root: cn(
|
|
8285
|
+
"relative w-full overflow-hidden rounded-2xl border shadow-md",
|
|
8286
|
+
"bg-background/55 supports-[backdrop-filter]:bg-background/25 backdrop-blur-xl",
|
|
8287
|
+
"flex flex-col",
|
|
8288
|
+
"before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
|
|
8289
|
+
"data-[accent=on]:before:bg-[color:var(--dt-accent)]"
|
|
8290
|
+
),
|
|
8291
|
+
theadSticky: "sticky top-0 z-10 bg-background/70 supports-[backdrop-filter]:bg-background/35 backdrop-blur-xl",
|
|
8292
|
+
tbody: cn("[&_tr:last-child]:border-0", "[&>tr:nth-child(even)]:bg-background/20")
|
|
8293
|
+
},
|
|
8294
|
+
compact: {
|
|
8295
|
+
th: "h-10 px-3 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground whitespace-nowrap",
|
|
8296
|
+
td: "px-3 py-2 text-xs align-middle",
|
|
8297
|
+
pageSizeTrigger: "h-8 w-[4.5rem]"
|
|
8298
|
+
},
|
|
8299
|
+
minimal: {
|
|
8300
|
+
root: cn("relative w-full overflow-hidden rounded-xl border-0 shadow-none bg-transparent flex flex-col"),
|
|
8301
|
+
theadSticky: "sticky top-0 z-10 bg-background",
|
|
8302
|
+
footer: "border-t bg-transparent",
|
|
8303
|
+
tbody: "[&_tr:last-child]:border-0"
|
|
8304
|
+
},
|
|
8305
|
+
clean: {
|
|
8306
|
+
root: cn(
|
|
8307
|
+
"relative w-full overflow-hidden rounded-2xl border shadow-none",
|
|
8308
|
+
"bg-background flex flex-col",
|
|
8309
|
+
"before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
|
|
8310
|
+
"data-[accent=on]:before:bg-[color:var(--dt-accent)]"
|
|
8311
|
+
),
|
|
8312
|
+
theadSticky: "sticky top-0 z-10 bg-background",
|
|
8313
|
+
tbody: cn("[&_tr:last-child]:border-0", "[&>tr:nth-child(even)]:bg-transparent"),
|
|
8314
|
+
tr: cn(
|
|
8315
|
+
"border-b",
|
|
8316
|
+
"data-[state=selected]:bg-muted/35",
|
|
8317
|
+
"data-[accent=on]:data-[state=selected]:bg-[color:var(--dt-accent)]/10"
|
|
8318
|
+
),
|
|
8319
|
+
trClickable: cn(
|
|
8320
|
+
"cursor-pointer",
|
|
8321
|
+
"hover:bg-muted/30 active:bg-muted/40",
|
|
8322
|
+
"data-[accent=on]:hover:bg-[color:var(--dt-accent)]/8",
|
|
8323
|
+
"data-[accent=on]:active:bg-[color:var(--dt-accent)]/12"
|
|
8324
|
+
)
|
|
8325
|
+
},
|
|
8326
|
+
elevated: {
|
|
8327
|
+
root: cn(
|
|
8328
|
+
"relative w-full overflow-hidden rounded-3xl border shadow-lg",
|
|
8329
|
+
"bg-card flex flex-col",
|
|
8330
|
+
"before:absolute before:inset-x-0 before:top-0 before:h-[2px] before:bg-transparent",
|
|
8331
|
+
"data-[accent=on]:before:bg-[color:var(--dt-accent)]"
|
|
8332
|
+
),
|
|
8333
|
+
theadSticky: "sticky top-0 z-10 bg-card/95 supports-[backdrop-filter]:bg-card/75 backdrop-blur",
|
|
8334
|
+
tbody: cn("[&_tr:last-child]:border-0", "[&>tr:nth-child(even)]:bg-muted/10"),
|
|
8335
|
+
th: cn(
|
|
8336
|
+
"h-12 px-5 text-left align-middle whitespace-nowrap",
|
|
8337
|
+
"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground"
|
|
8338
|
+
),
|
|
8339
|
+
td: "px-5 py-3 align-middle"
|
|
8340
|
+
},
|
|
8341
|
+
grid: {
|
|
8342
|
+
root: cn("relative w-full overflow-hidden rounded-2xl border shadow-sm bg-background flex flex-col"),
|
|
8343
|
+
table: cn(
|
|
8344
|
+
"w-full text-sm border-separate border-spacing-0",
|
|
8345
|
+
"[&_th]:border-b [&_td]:border-b",
|
|
8346
|
+
"[&_th:not(:last-child)]:border-r [&_td:not(:last-child)]:border-r",
|
|
8347
|
+
"[&_th]:border-muted-foreground/15 [&_td]:border-muted-foreground/10"
|
|
8348
|
+
),
|
|
8349
|
+
thead: "border-b-0",
|
|
8350
|
+
tbody: "[&_tr:last-child_td]:border-b-0",
|
|
8351
|
+
tr: cn(
|
|
8352
|
+
"transition-colors",
|
|
8353
|
+
"data-[state=selected]:bg-muted/35",
|
|
8354
|
+
"data-[accent=on]:data-[state=selected]:bg-[color:var(--dt-accent)]/10"
|
|
8355
|
+
),
|
|
8356
|
+
trClickable: cn(
|
|
8357
|
+
"cursor-pointer",
|
|
8358
|
+
"hover:bg-muted/25 active:bg-muted/35",
|
|
8359
|
+
"data-[accent=on]:hover:bg-[color:var(--dt-accent)]/7",
|
|
8360
|
+
"data-[accent=on]:active:bg-[color:var(--dt-accent)]/10"
|
|
8361
|
+
)
|
|
8362
|
+
},
|
|
8363
|
+
cards: {
|
|
8364
|
+
root: cn("relative w-full overflow-hidden rounded-2xl border bg-transparent shadow-none flex flex-col"),
|
|
8365
|
+
table: cn(
|
|
8366
|
+
"w-full text-sm border-separate border-spacing-y-2",
|
|
8367
|
+
"[&_tbody_tr_td]:bg-background",
|
|
8368
|
+
"[&_tbody_tr_td:first-child]:rounded-l-xl",
|
|
8369
|
+
"[&_tbody_tr_td:last-child]:rounded-r-xl",
|
|
8370
|
+
"[&_tbody_tr_td]:shadow-sm",
|
|
8371
|
+
"[&_thead_tr]:border-b"
|
|
8372
|
+
),
|
|
8373
|
+
theadSticky: "sticky top-0 z-10 bg-background",
|
|
8374
|
+
tr: cn(
|
|
8375
|
+
"border-0",
|
|
8376
|
+
"data-[state=selected]:opacity-100",
|
|
8377
|
+
"data-[state=selected]:[&_td]:ring-1 data-[state=selected]:[&_td]:ring-muted-foreground/15",
|
|
8378
|
+
"data-[accent=on]:data-[state=selected]:[&_td]:ring-[color:var(--dt-accent)]/25"
|
|
8379
|
+
),
|
|
8380
|
+
trClickable: cn(
|
|
8381
|
+
"cursor-pointer",
|
|
8382
|
+
"[&_td]:transition-colors",
|
|
8383
|
+
"hover:[&_td]:bg-muted/25 active:[&_td]:bg-muted/35",
|
|
8384
|
+
"data-[accent=on]:hover:[&_td]:bg-[color:var(--dt-accent)]/7",
|
|
8385
|
+
"data-[accent=on]:active:[&_td]:bg-[color:var(--dt-accent)]/10"
|
|
8386
|
+
),
|
|
8387
|
+
tbody: "[&_tr:last-child]:border-0"
|
|
8388
|
+
}
|
|
8389
|
+
};
|
|
8390
|
+
function mergeSlots(...parts) {
|
|
8391
|
+
const out = {};
|
|
8392
|
+
for (const p of parts) {
|
|
8393
|
+
if (!p) continue;
|
|
8394
|
+
for (const k of Object.keys(p)) {
|
|
8395
|
+
const v = p[k];
|
|
8396
|
+
if (!v) continue;
|
|
8397
|
+
out[k] = out[k] ? cn(out[k], v) : v;
|
|
8398
|
+
}
|
|
8399
|
+
}
|
|
8400
|
+
return out;
|
|
8401
|
+
}
|
|
8197
8402
|
function DataTable({
|
|
8198
8403
|
columns,
|
|
8199
8404
|
data,
|
|
@@ -8207,132 +8412,138 @@ function DataTable({
|
|
|
8207
8412
|
isRowsSelected = true,
|
|
8208
8413
|
totalRows,
|
|
8209
8414
|
rowsSelectedLabel = "row(s) selected",
|
|
8210
|
-
|
|
8415
|
+
template = "neo",
|
|
8416
|
+
classNames,
|
|
8417
|
+
accent = null,
|
|
8418
|
+
accentColor = null,
|
|
8211
8419
|
emptyData,
|
|
8212
|
-
bodyClassName,
|
|
8213
|
-
cellClassName,
|
|
8214
|
-
headerClassName,
|
|
8215
|
-
rowClassName,
|
|
8216
|
-
tableClassName,
|
|
8217
8420
|
onPageChange,
|
|
8218
8421
|
onClick,
|
|
8219
8422
|
onPageSizeChange,
|
|
8220
8423
|
animate = true,
|
|
8221
8424
|
stickyHeader = true,
|
|
8425
|
+
headerScroll = false,
|
|
8222
8426
|
heightClassName = "h-[clamp(22rem,80vh,44rem)] supports-[height:100dvh]:h-[clamp(22rem,80dvh,44rem)]"
|
|
8223
8427
|
}) {
|
|
8224
8428
|
const safePageCount = Math.max(pageCount != null ? pageCount : 1, 1);
|
|
8225
|
-
const
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
const nextIndex = Math.max(page - 1, 0);
|
|
8232
|
-
const nextSize = perPage;
|
|
8233
|
-
if (prev.pageIndex === nextIndex && prev.pageSize === nextSize) return prev;
|
|
8234
|
-
return { pageIndex: nextIndex, pageSize: nextSize };
|
|
8235
|
-
});
|
|
8236
|
-
}, [page, perPage]);
|
|
8237
|
-
useEffect4(() => {
|
|
8238
|
-
setPagination((prev) => {
|
|
8239
|
-
const maxIndex = Math.max(safePageCount - 1, 0);
|
|
8240
|
-
const clamped = Math.min(prev.pageIndex, maxIndex);
|
|
8241
|
-
if (clamped === prev.pageIndex) return prev;
|
|
8242
|
-
return __spreadProps(__spreadValues({}, prev), { pageIndex: clamped });
|
|
8243
|
-
});
|
|
8244
|
-
}, [safePageCount]);
|
|
8429
|
+
const pageIndex = Math.min(Math.max(page - 1, 0), safePageCount - 1);
|
|
8430
|
+
const pageSize = Math.max(perPage, 1);
|
|
8431
|
+
const paginationState = useMemo3(
|
|
8432
|
+
() => ({ pageIndex, pageSize }),
|
|
8433
|
+
[pageIndex, pageSize]
|
|
8434
|
+
);
|
|
8245
8435
|
const table = useReactTable({
|
|
8246
8436
|
data,
|
|
8247
8437
|
columns,
|
|
8248
8438
|
pageCount: safePageCount,
|
|
8439
|
+
state: { pagination: paginationState },
|
|
8249
8440
|
getCoreRowModel: getCoreRowModel(),
|
|
8250
8441
|
getFilteredRowModel: getFilteredRowModel(),
|
|
8251
|
-
state: { pagination },
|
|
8252
|
-
onPaginationChange: setPagination,
|
|
8253
|
-
getPaginationRowModel: getPaginationRowModel(),
|
|
8254
8442
|
manualPagination: true,
|
|
8255
|
-
manualFiltering: true
|
|
8443
|
+
manualFiltering: true,
|
|
8444
|
+
autoResetAll: false,
|
|
8445
|
+
autoResetPageIndex: false
|
|
8256
8446
|
});
|
|
8257
8447
|
const clickable = !!onClick;
|
|
8258
|
-
useEffect4(() => {
|
|
8259
|
-
onPageChange == null ? void 0 : onPageChange(pagination.pageIndex + 1);
|
|
8260
|
-
}, [pagination.pageIndex, onPageChange]);
|
|
8261
8448
|
const pageKey = useMemo3(
|
|
8262
|
-
() => `${
|
|
8263
|
-
[
|
|
8449
|
+
() => `${pageIndex}-${pageSize}-${data.length}`,
|
|
8450
|
+
[pageIndex, pageSize, data.length]
|
|
8264
8451
|
);
|
|
8452
|
+
const goToPage = (nextPageIndex) => {
|
|
8453
|
+
const clamped = Math.min(Math.max(nextPageIndex, 0), safePageCount - 1);
|
|
8454
|
+
if (clamped === pageIndex) return;
|
|
8455
|
+
onPageChange == null ? void 0 : onPageChange(clamped + 1);
|
|
8456
|
+
};
|
|
8457
|
+
const changePageSize = (newSize) => {
|
|
8458
|
+
const size = Math.max(Number(newSize) || 1, 1);
|
|
8459
|
+
if (size === pageSize) return;
|
|
8460
|
+
onPageSizeChange == null ? void 0 : onPageSizeChange(size);
|
|
8461
|
+
onPageChange == null ? void 0 : onPageChange(1);
|
|
8462
|
+
};
|
|
8463
|
+
const ui = useMemo3(() => {
|
|
8464
|
+
var _a;
|
|
8465
|
+
const builtIn = (_a = DATA_TABLE_TEMPLATES[template]) != null ? _a : DATA_TABLE_TEMPLATES.neo;
|
|
8466
|
+
return mergeSlots(DATA_TABLE_TEMPLATES.neo, builtIn, classNames);
|
|
8467
|
+
}, [template, classNames]);
|
|
8468
|
+
const dtAccent = resolveAccent(accent, accentColor);
|
|
8469
|
+
const accentOn = !!dtAccent;
|
|
8470
|
+
const dataAccent = accentOn ? "on" : "off";
|
|
8471
|
+
const headerIsSticky = stickyHeader && !headerScroll;
|
|
8265
8472
|
return /* @__PURE__ */ jsxs23(
|
|
8266
8473
|
"div",
|
|
8267
8474
|
{
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
heightClassName,
|
|
8272
|
-
className
|
|
8273
|
-
),
|
|
8475
|
+
"data-accent": dataAccent,
|
|
8476
|
+
className: cn(ui.root, heightClassName),
|
|
8477
|
+
style: accentOn ? { "--dt-accent": dtAccent } : void 0,
|
|
8274
8478
|
children: [
|
|
8275
|
-
/* @__PURE__ */ jsx48("div", { className: "
|
|
8276
|
-
/* @__PURE__ */ jsxs23(
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
TableHeader,
|
|
8284
|
-
{
|
|
8285
|
-
className: cn(
|
|
8286
|
-
headerClassName,
|
|
8287
|
-
stickyHeader ? "sticky top-0 z-10 bg-background/80 backdrop-blur border-b" : ""
|
|
8288
|
-
),
|
|
8289
|
-
children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx48(TableRow, { className: cn("hover:bg-transparent", rowClassName), children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx48(TableHead, { className: cn("whitespace-nowrap", headerClassName), children: header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext()) }, header.id)) }, headerGroup.id))
|
|
8290
|
-
}
|
|
8479
|
+
/* @__PURE__ */ jsx48("div", { className: "min-h-0 flex-1", children: /* @__PURE__ */ jsxs23(ScrollArea, { className: "h-full", children: [
|
|
8480
|
+
/* @__PURE__ */ jsx48("div", { className: "relative min-w-full w-max", children: /* @__PURE__ */ jsxs23(TablePlain, { className: cn(ui.table), children: [
|
|
8481
|
+
/* @__PURE__ */ jsx48(TableHeader, { className: cn(ui.thead), children: table.getHeaderGroups().map((headerGroup) => /* @__PURE__ */ jsx48(TableRow, { className: cn(ui.trHead), children: headerGroup.headers.map((header) => /* @__PURE__ */ jsx48(
|
|
8482
|
+
TableHead,
|
|
8483
|
+
{
|
|
8484
|
+
className: cn(
|
|
8485
|
+
ui.th,
|
|
8486
|
+
headerIsSticky ? cn(ui.theadSticky, "z-20") : void 0
|
|
8291
8487
|
),
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
|
|
8302
|
-
|
|
8303
|
-
|
|
8304
|
-
|
|
8305
|
-
|
|
8306
|
-
|
|
8307
|
-
|
|
8308
|
-
),
|
|
8309
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cellClassName, children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
8310
|
-
},
|
|
8311
|
-
row.id
|
|
8312
|
-
)) : emptyData || /* @__PURE__ */ jsx48(TableRow, { children: /* @__PURE__ */ jsx48(TableCell, { colSpan: columns.length, className: "h-28 text-center text-muted-foreground", children: "No results." }) })
|
|
8313
|
-
},
|
|
8314
|
-
pageKey
|
|
8315
|
-
) }) : /* @__PURE__ */ jsx48(TableBody, { className: bodyClassName, children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx48(
|
|
8488
|
+
children: header.isPlaceholder ? null : flexRender(
|
|
8489
|
+
header.column.columnDef.header,
|
|
8490
|
+
header.getContext()
|
|
8491
|
+
)
|
|
8492
|
+
},
|
|
8493
|
+
header.id
|
|
8494
|
+
)) }, headerGroup.id)) }),
|
|
8495
|
+
animate ? /* @__PURE__ */ jsx48(AnimatePresence, { mode: "wait", initial: false, children: /* @__PURE__ */ jsx48(
|
|
8496
|
+
motion2.tbody,
|
|
8497
|
+
{
|
|
8498
|
+
className: cn(ui.tbody),
|
|
8499
|
+
initial: { opacity: 0, y: 6 },
|
|
8500
|
+
animate: { opacity: 1, y: 0 },
|
|
8501
|
+
exit: { opacity: 0, y: -6 },
|
|
8502
|
+
transition: { duration: 0.18 },
|
|
8503
|
+
children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx48(
|
|
8316
8504
|
TableRow,
|
|
8317
8505
|
{
|
|
8506
|
+
"data-accent": dataAccent,
|
|
8318
8507
|
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
8319
8508
|
onClick: () => onClick == null ? void 0 : onClick(row.original),
|
|
8320
|
-
className: cn(
|
|
8321
|
-
|
|
8322
|
-
clickable ? "cursor-pointer hover:bg-muted/60 active:bg-muted/80" : ""
|
|
8323
|
-
),
|
|
8324
|
-
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cn(cellClassName), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
8509
|
+
className: cn(ui.tr, clickable ? ui.trClickable : void 0),
|
|
8510
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cn(ui.td), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
8325
8511
|
},
|
|
8326
8512
|
row.id
|
|
8327
|
-
)) : emptyData || /* @__PURE__ */ jsx48(TableRow, { children: /* @__PURE__ */ jsx48(
|
|
8328
|
-
|
|
8329
|
-
|
|
8330
|
-
|
|
8513
|
+
)) : emptyData || /* @__PURE__ */ jsx48(TableRow, { "data-accent": dataAccent, children: /* @__PURE__ */ jsx48(
|
|
8514
|
+
TableCell,
|
|
8515
|
+
{
|
|
8516
|
+
colSpan: columns.length,
|
|
8517
|
+
className: cn(ui.td, "text-muted-foreground h-28 text-center"),
|
|
8518
|
+
children: "No results."
|
|
8519
|
+
}
|
|
8520
|
+
) })
|
|
8521
|
+
},
|
|
8522
|
+
pageKey
|
|
8523
|
+
) }) : /* @__PURE__ */ jsx48(TableBody, { className: cn(ui.tbody), children: table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => /* @__PURE__ */ jsx48(
|
|
8524
|
+
TableRow,
|
|
8525
|
+
{
|
|
8526
|
+
"data-accent": dataAccent,
|
|
8527
|
+
"data-state": row.getIsSelected() ? "selected" : void 0,
|
|
8528
|
+
onClick: () => onClick == null ? void 0 : onClick(row.original),
|
|
8529
|
+
className: cn(ui.tr, clickable ? ui.trClickable : void 0),
|
|
8530
|
+
children: row.getVisibleCells().map((cell) => /* @__PURE__ */ jsx48(TableCell, { className: cn(ui.td), children: flexRender(cell.column.columnDef.cell, cell.getContext()) }, cell.id))
|
|
8531
|
+
},
|
|
8532
|
+
row.id
|
|
8533
|
+
)) : emptyData || /* @__PURE__ */ jsx48(TableRow, { "data-accent": dataAccent, children: /* @__PURE__ */ jsx48(
|
|
8534
|
+
TableCell,
|
|
8535
|
+
{
|
|
8536
|
+
colSpan: columns.length,
|
|
8537
|
+
className: cn(ui.td, "text-muted-foreground h-28 text-center"),
|
|
8538
|
+
children: "No results."
|
|
8539
|
+
}
|
|
8540
|
+
) }) })
|
|
8541
|
+
] }) }),
|
|
8331
8542
|
/* @__PURE__ */ jsx48(ScrollBar, { orientation: "horizontal" })
|
|
8332
8543
|
] }) }),
|
|
8333
|
-
/* @__PURE__ */ jsx48("div", { className:
|
|
8334
|
-
/* @__PURE__ */ jsxs23("div", { className:
|
|
8335
|
-
isRowsSelected && /* @__PURE__ */ jsxs23("div", {
|
|
8544
|
+
/* @__PURE__ */ jsx48("div", { className: cn(ui.footer), children: /* @__PURE__ */ jsx48("div", { className: cn(ui.footerInner), children: /* @__PURE__ */ jsxs23("div", { className: "grid grid-cols-1 gap-3 sm:grid-cols-[1fr_auto] sm:items-center", children: [
|
|
8545
|
+
/* @__PURE__ */ jsxs23("div", { className: cn(ui.metaWrap), children: [
|
|
8546
|
+
isRowsSelected && /* @__PURE__ */ jsxs23("div", { children: [
|
|
8336
8547
|
table.getFilteredSelectedRowModel().rows.length,
|
|
8337
8548
|
" ",
|
|
8338
8549
|
ofLabel,
|
|
@@ -8341,37 +8552,25 @@ function DataTable({
|
|
|
8341
8552
|
" ",
|
|
8342
8553
|
rowsSelectedLabel
|
|
8343
8554
|
] }),
|
|
8344
|
-
typeof totalRows === "number" && /* @__PURE__ */ jsxs23("div", {
|
|
8555
|
+
typeof totalRows === "number" && /* @__PURE__ */ jsxs23("div", { children: [
|
|
8345
8556
|
"Total: ",
|
|
8346
8557
|
totalRows,
|
|
8347
8558
|
" registros"
|
|
8348
8559
|
] })
|
|
8349
8560
|
] }),
|
|
8350
|
-
/* @__PURE__ */ jsxs23("div", { className:
|
|
8561
|
+
/* @__PURE__ */ jsxs23("div", { className: cn(ui.controlsWrap), children: [
|
|
8351
8562
|
/* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-2", children: [
|
|
8352
|
-
/* @__PURE__ */ jsx48("p", { className:
|
|
8353
|
-
/* @__PURE__ */ jsxs23(
|
|
8354
|
-
|
|
8355
|
-
{
|
|
8356
|
-
|
|
8357
|
-
onValueChange: (value) => {
|
|
8358
|
-
const newSize = Number(value);
|
|
8359
|
-
setPagination((p) => __spreadProps(__spreadValues({}, p), { pageSize: newSize, pageIndex: 0 }));
|
|
8360
|
-
onPageSizeChange == null ? void 0 : onPageSizeChange(newSize);
|
|
8361
|
-
onPageChange == null ? void 0 : onPageChange(1);
|
|
8362
|
-
},
|
|
8363
|
-
children: [
|
|
8364
|
-
/* @__PURE__ */ jsx48(SelectTrigger, { className: "h-8 w-21", children: /* @__PURE__ */ jsx48(SelectValue, { placeholder: pagination.pageSize }) }),
|
|
8365
|
-
/* @__PURE__ */ jsx48(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ jsx48(SelectItem, { value: `${size}`, children: size }, size)) })
|
|
8366
|
-
]
|
|
8367
|
-
}
|
|
8368
|
-
)
|
|
8563
|
+
/* @__PURE__ */ jsx48("p", { className: cn(ui.pageSizeLabel), children: rowPerPageLabel }),
|
|
8564
|
+
/* @__PURE__ */ jsxs23(Select2, { value: `${pageSize}`, onValueChange: (v) => changePageSize(Number(v)), children: [
|
|
8565
|
+
/* @__PURE__ */ jsx48(SelectTrigger, { "data-accent": dataAccent, className: cn(ui.pageSizeTrigger), children: /* @__PURE__ */ jsx48(SelectValue, { placeholder: `${pageSize}` }) }),
|
|
8566
|
+
/* @__PURE__ */ jsx48(SelectContent, { side: "top", children: pageSizeOptions.map((size) => /* @__PURE__ */ jsx48(SelectItem, { value: `${size}`, children: size }, size)) })
|
|
8567
|
+
] })
|
|
8369
8568
|
] }),
|
|
8370
8569
|
/* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-2", children: [
|
|
8371
|
-
/* @__PURE__ */ jsxs23("div", { className:
|
|
8570
|
+
/* @__PURE__ */ jsxs23("div", { className: cn(ui.pageLabel), children: [
|
|
8372
8571
|
pageLabel,
|
|
8373
8572
|
" ",
|
|
8374
|
-
|
|
8573
|
+
pageIndex + 1,
|
|
8375
8574
|
" ",
|
|
8376
8575
|
ofLabel,
|
|
8377
8576
|
" ",
|
|
@@ -8380,54 +8579,56 @@ function DataTable({
|
|
|
8380
8579
|
/* @__PURE__ */ jsx48(
|
|
8381
8580
|
Button,
|
|
8382
8581
|
{
|
|
8582
|
+
"data-accent": dataAccent,
|
|
8383
8583
|
"aria-label": "Go to first page",
|
|
8384
8584
|
variant: "outline",
|
|
8385
|
-
className: "hidden
|
|
8386
|
-
onClick: () =>
|
|
8387
|
-
disabled:
|
|
8585
|
+
className: cn("hidden lg:flex", ui.navButton),
|
|
8586
|
+
onClick: () => goToPage(0),
|
|
8587
|
+
disabled: pageIndex === 0,
|
|
8388
8588
|
children: /* @__PURE__ */ jsx48(DoubleArrowLeftIcon, { className: "h-4 w-4" })
|
|
8389
8589
|
}
|
|
8390
8590
|
),
|
|
8391
8591
|
/* @__PURE__ */ jsx48(
|
|
8392
8592
|
Button,
|
|
8393
8593
|
{
|
|
8594
|
+
"data-accent": dataAccent,
|
|
8394
8595
|
"aria-label": "Go to previous page",
|
|
8395
8596
|
variant: "outline",
|
|
8396
|
-
className:
|
|
8397
|
-
onClick: () =>
|
|
8398
|
-
disabled:
|
|
8399
|
-
children: /* @__PURE__ */ jsx48(
|
|
8597
|
+
className: cn(ui.navButton),
|
|
8598
|
+
onClick: () => goToPage(pageIndex - 1),
|
|
8599
|
+
disabled: pageIndex === 0,
|
|
8600
|
+
children: /* @__PURE__ */ jsx48(ChevronLeft3, { className: "h-4 w-4" })
|
|
8400
8601
|
}
|
|
8401
8602
|
),
|
|
8402
8603
|
/* @__PURE__ */ jsx48(
|
|
8403
8604
|
Button,
|
|
8404
8605
|
{
|
|
8606
|
+
"data-accent": dataAccent,
|
|
8405
8607
|
"aria-label": "Go to next page",
|
|
8406
8608
|
variant: "outline",
|
|
8407
|
-
className:
|
|
8408
|
-
onClick: () =>
|
|
8409
|
-
|
|
8410
|
-
})
|
|
8411
|
-
disabled: pagination.pageIndex + 1 >= safePageCount,
|
|
8412
|
-
children: /* @__PURE__ */ jsx48(ChevronRightIcon6, { className: "h-4 w-4" })
|
|
8609
|
+
className: cn(ui.navButton),
|
|
8610
|
+
onClick: () => goToPage(pageIndex + 1),
|
|
8611
|
+
disabled: pageIndex + 1 >= safePageCount,
|
|
8612
|
+
children: /* @__PURE__ */ jsx48(ChevronRight3, { className: "h-4 w-4" })
|
|
8413
8613
|
}
|
|
8414
8614
|
),
|
|
8415
8615
|
/* @__PURE__ */ jsx48(
|
|
8416
8616
|
Button,
|
|
8417
8617
|
{
|
|
8618
|
+
"data-accent": dataAccent,
|
|
8418
8619
|
"aria-label": "Go to last page",
|
|
8419
8620
|
variant: "outline",
|
|
8420
|
-
className: "hidden
|
|
8421
|
-
onClick: () =>
|
|
8422
|
-
disabled:
|
|
8621
|
+
className: cn("hidden lg:flex", ui.navButton),
|
|
8622
|
+
onClick: () => goToPage(safePageCount - 1),
|
|
8623
|
+
disabled: pageIndex + 1 >= safePageCount,
|
|
8423
8624
|
children: /* @__PURE__ */ jsx48(DoubleArrowRightIcon, { className: "h-4 w-4" })
|
|
8424
8625
|
}
|
|
8425
8626
|
)
|
|
8426
8627
|
] }),
|
|
8427
|
-
/* @__PURE__ */ jsxs23("div", { className: "
|
|
8628
|
+
/* @__PURE__ */ jsxs23("div", { className: "text-muted-foreground w-full text-center text-xs sm:hidden", children: [
|
|
8428
8629
|
pageLabel,
|
|
8429
8630
|
" ",
|
|
8430
|
-
|
|
8631
|
+
pageIndex + 1,
|
|
8431
8632
|
" ",
|
|
8432
8633
|
ofLabel,
|
|
8433
8634
|
" ",
|
|
@@ -8483,7 +8684,7 @@ function DataTableSkeleton({
|
|
|
8483
8684
|
// src/shared/fileupload.tsx
|
|
8484
8685
|
import { AvatarIcon } from "@radix-ui/react-icons";
|
|
8485
8686
|
import { CameraIcon } from "lucide-react";
|
|
8486
|
-
import { useEffect as
|
|
8687
|
+
import { useEffect as useEffect4, useState as useState5 } from "react";
|
|
8487
8688
|
import { useDropzone } from "react-dropzone";
|
|
8488
8689
|
import { jsx as jsx50, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
8489
8690
|
function FileUpload({
|
|
@@ -8522,7 +8723,7 @@ function FileUpload({
|
|
|
8522
8723
|
}
|
|
8523
8724
|
function ImagePreview({ file }) {
|
|
8524
8725
|
const [objectUrl, setObjectUrl] = useState5(null);
|
|
8525
|
-
|
|
8726
|
+
useEffect4(() => {
|
|
8526
8727
|
const url = URL.createObjectURL(file);
|
|
8527
8728
|
setObjectUrl(url);
|
|
8528
8729
|
return () => {
|
|
@@ -8917,6 +9118,7 @@ export {
|
|
|
8917
9118
|
ContextMenuSubContent,
|
|
8918
9119
|
ContextMenuSubTrigger,
|
|
8919
9120
|
ContextMenuTrigger,
|
|
9121
|
+
DATA_TABLE_TEMPLATES,
|
|
8920
9122
|
DataTable,
|
|
8921
9123
|
DataTableSkeleton,
|
|
8922
9124
|
Dialog,
|