baaz-custom-components 5.1.2 → 5.2.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/dist/index.css +56 -0
- package/dist/index.d.mts +40 -9
- package/dist/index.d.ts +40 -9
- package/dist/index.js +450 -142
- package/dist/index.mjs +443 -140
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1911,10 +1911,11 @@ var breadcrumb_default = CustomBreadcrumb;
|
|
|
1911
1911
|
// src/components/custom/grid/index.tsx
|
|
1912
1912
|
import {
|
|
1913
1913
|
useCallback as useCallback2,
|
|
1914
|
-
useRef as
|
|
1914
|
+
useRef as useRef5,
|
|
1915
1915
|
useImperativeHandle,
|
|
1916
1916
|
forwardRef,
|
|
1917
|
-
useEffect as
|
|
1917
|
+
useEffect as useEffect9,
|
|
1918
|
+
useMemo as useMemo4
|
|
1918
1919
|
} from "react";
|
|
1919
1920
|
import { Grid as SvarGrid, WillowDark } from "@svar-ui/react-grid";
|
|
1920
1921
|
|
|
@@ -1950,13 +1951,7 @@ function exportExcel(rows, name) {
|
|
|
1950
1951
|
|
|
1951
1952
|
// src/components/custom/grid/gridHeader/index.tsx
|
|
1952
1953
|
import { useEffect as useEffect6, useRef as useRef2, useState as useState7 } from "react";
|
|
1953
|
-
import {
|
|
1954
|
-
FileText,
|
|
1955
|
-
FileSpreadsheet,
|
|
1956
|
-
Search,
|
|
1957
|
-
Ellipsis,
|
|
1958
|
-
X as X3
|
|
1959
|
-
} from "lucide-react";
|
|
1954
|
+
import { FileText, FileSpreadsheet, Search, Ellipsis, X as X4 } from "lucide-react";
|
|
1960
1955
|
|
|
1961
1956
|
// src/components/custom/grid/gridHeader/components/filters.tsx
|
|
1962
1957
|
import { useEffect as useEffect5, useMemo as useMemo3, useRef, useState as useState6 } from "react";
|
|
@@ -2013,13 +2008,13 @@ var Filters = ({
|
|
|
2013
2008
|
}
|
|
2014
2009
|
]);
|
|
2015
2010
|
};
|
|
2016
|
-
const updateCondition = (
|
|
2011
|
+
const updateCondition = (id3, next) => {
|
|
2017
2012
|
setConditions(
|
|
2018
|
-
(prev) => prev.map((c) => c.id ===
|
|
2013
|
+
(prev) => prev.map((c) => c.id === id3 ? __spreadValues(__spreadValues({}, c), next) : c)
|
|
2019
2014
|
);
|
|
2020
2015
|
};
|
|
2021
|
-
const deleteCondition = (
|
|
2022
|
-
const updatedConditions = conditions.filter((c) => c.id !==
|
|
2016
|
+
const deleteCondition = (id3) => {
|
|
2017
|
+
const updatedConditions = conditions.filter((c) => c.id !== id3);
|
|
2023
2018
|
setConditions(updatedConditions);
|
|
2024
2019
|
if (updatedConditions.length === 0) {
|
|
2025
2020
|
setFilterMenu(false);
|
|
@@ -2322,9 +2317,52 @@ var Filters = ({
|
|
|
2322
2317
|
};
|
|
2323
2318
|
var filters_default = Filters;
|
|
2324
2319
|
|
|
2325
|
-
// src/components/custom/grid/gridHeader/
|
|
2320
|
+
// src/components/custom/grid/gridHeader/components/selectionBar.tsx
|
|
2321
|
+
import { X as X3 } from "lucide-react";
|
|
2326
2322
|
import { jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2327
|
-
|
|
2323
|
+
function SelectionBar({
|
|
2324
|
+
selectedCount,
|
|
2325
|
+
selectedData,
|
|
2326
|
+
actions,
|
|
2327
|
+
onAction,
|
|
2328
|
+
onClear
|
|
2329
|
+
}) {
|
|
2330
|
+
return /* @__PURE__ */ jsxs18("div", { className: "flex items-center gap-2 animate-in fade-in slide-in-from-left-2 duration-150", children: [
|
|
2331
|
+
/* @__PURE__ */ jsx24(
|
|
2332
|
+
"button",
|
|
2333
|
+
{
|
|
2334
|
+
onClick: onClear,
|
|
2335
|
+
title: "Clear selection",
|
|
2336
|
+
className: "p-1.5 rounded-md hover:bg-input text-muted-foreground hover:text-foreground transition-colors cursor-pointer",
|
|
2337
|
+
children: /* @__PURE__ */ jsx24(X3, { size: 15 })
|
|
2338
|
+
}
|
|
2339
|
+
),
|
|
2340
|
+
/* @__PURE__ */ jsxs18("span", { className: "text-xs font-medium text-foreground whitespace-nowrap", children: [
|
|
2341
|
+
selectedCount,
|
|
2342
|
+
" ",
|
|
2343
|
+
selectedCount === 1 ? "row" : "rows",
|
|
2344
|
+
" selected"
|
|
2345
|
+
] }),
|
|
2346
|
+
/* @__PURE__ */ jsx24("div", { className: "h-4 w-px bg-border mx-1" }),
|
|
2347
|
+
actions.map((action) => /* @__PURE__ */ jsxs18(
|
|
2348
|
+
"button",
|
|
2349
|
+
{
|
|
2350
|
+
onClick: () => onAction(action.id, selectedData),
|
|
2351
|
+
title: action.label,
|
|
2352
|
+
className: "flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium border border-border bg-primary/90 hover:bg-primary ease-in-out transition-colors cursor-pointer whitespace-nowrap",
|
|
2353
|
+
children: [
|
|
2354
|
+
action.icon && /* @__PURE__ */ jsx24("span", { className: "shrink-0 text-muted-foreground", children: action.icon }),
|
|
2355
|
+
action.label
|
|
2356
|
+
]
|
|
2357
|
+
},
|
|
2358
|
+
action.id
|
|
2359
|
+
))
|
|
2360
|
+
] });
|
|
2361
|
+
}
|
|
2362
|
+
|
|
2363
|
+
// src/components/custom/grid/gridHeader/index.tsx
|
|
2364
|
+
import { Fragment as Fragment3, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2365
|
+
function GridHeader({
|
|
2328
2366
|
onPdf,
|
|
2329
2367
|
onExcel,
|
|
2330
2368
|
onSearch = () => {
|
|
@@ -2336,11 +2374,17 @@ var GridHeader = ({
|
|
|
2336
2374
|
filterList,
|
|
2337
2375
|
onFilterChange,
|
|
2338
2376
|
initialFilters = [],
|
|
2339
|
-
children
|
|
2340
|
-
|
|
2377
|
+
children,
|
|
2378
|
+
selectedCount = 0,
|
|
2379
|
+
selectedData = [],
|
|
2380
|
+
selectionActions = [],
|
|
2381
|
+
onSelectionAction,
|
|
2382
|
+
onClearSelection
|
|
2383
|
+
}) {
|
|
2341
2384
|
const [downloadMenu, setDownloadMenu] = useState7(false);
|
|
2342
2385
|
const [searchOpen, setSearchOpen] = useState7(false);
|
|
2343
2386
|
const downloadRef = useRef2(null);
|
|
2387
|
+
const isSelecting = selectedCount > 0;
|
|
2344
2388
|
useEffect6(() => {
|
|
2345
2389
|
const handleClickOutside = (e) => {
|
|
2346
2390
|
if (downloadRef.current && !downloadRef.current.contains(e.target)) {
|
|
@@ -2350,9 +2394,18 @@ var GridHeader = ({
|
|
|
2350
2394
|
document.addEventListener("mousedown", handleClickOutside);
|
|
2351
2395
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
2352
2396
|
}, []);
|
|
2353
|
-
return /* @__PURE__ */
|
|
2354
|
-
/* @__PURE__ */
|
|
2355
|
-
|
|
2397
|
+
return /* @__PURE__ */ jsxs19("div", { className: "flex flex-col md:flex-row md:items-center justify-between bg-card py-2 px-2 md:px-4 rounded-tl-md rounded-tr-md border-l border-r border-t min-h-[48px]", children: [
|
|
2398
|
+
/* @__PURE__ */ jsx25("div", { className: "flex items-center gap-3", children: isSelecting ? /* @__PURE__ */ jsx25(
|
|
2399
|
+
SelectionBar,
|
|
2400
|
+
{
|
|
2401
|
+
selectedCount,
|
|
2402
|
+
selectedData,
|
|
2403
|
+
actions: selectionActions,
|
|
2404
|
+
onAction: (actionId, data) => onSelectionAction == null ? void 0 : onSelectionAction(actionId, data),
|
|
2405
|
+
onClear: () => onClearSelection == null ? void 0 : onClearSelection()
|
|
2406
|
+
}
|
|
2407
|
+
) : /* @__PURE__ */ jsxs19(Fragment3, { children: [
|
|
2408
|
+
/* @__PURE__ */ jsx25(
|
|
2356
2409
|
filters_default,
|
|
2357
2410
|
{
|
|
2358
2411
|
onFilterChange,
|
|
@@ -2360,17 +2413,17 @@ var GridHeader = ({
|
|
|
2360
2413
|
filterList
|
|
2361
2414
|
}
|
|
2362
2415
|
),
|
|
2363
|
-
download && /* @__PURE__ */
|
|
2364
|
-
/* @__PURE__ */
|
|
2416
|
+
download && /* @__PURE__ */ jsxs19("div", { className: "relative", ref: downloadRef, children: [
|
|
2417
|
+
/* @__PURE__ */ jsx25(
|
|
2365
2418
|
"button",
|
|
2366
2419
|
{
|
|
2367
2420
|
onClick: () => setDownloadMenu((p) => !p),
|
|
2368
2421
|
className: "p-2 rounded-md hover:bg-input cursor-pointer",
|
|
2369
|
-
children: /* @__PURE__ */
|
|
2422
|
+
children: /* @__PURE__ */ jsx25(Ellipsis, { size: 16 })
|
|
2370
2423
|
}
|
|
2371
2424
|
),
|
|
2372
|
-
downloadMenu && /* @__PURE__ */
|
|
2373
|
-
/* @__PURE__ */
|
|
2425
|
+
downloadMenu && /* @__PURE__ */ jsxs19("div", { className: "absolute top-full right-0 mt-2 w-32 rounded-md border !bg-background shadow-lg z-50 overflow-hidden", children: [
|
|
2426
|
+
/* @__PURE__ */ jsxs19(
|
|
2374
2427
|
"button",
|
|
2375
2428
|
{
|
|
2376
2429
|
onClick: () => {
|
|
@@ -2379,12 +2432,12 @@ var GridHeader = ({
|
|
|
2379
2432
|
},
|
|
2380
2433
|
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2381
2434
|
children: [
|
|
2382
|
-
/* @__PURE__ */
|
|
2383
|
-
"PDF"
|
|
2435
|
+
/* @__PURE__ */ jsx25(FileText, { size: 14 }),
|
|
2436
|
+
" PDF"
|
|
2384
2437
|
]
|
|
2385
2438
|
}
|
|
2386
2439
|
),
|
|
2387
|
-
/* @__PURE__ */
|
|
2440
|
+
/* @__PURE__ */ jsxs19(
|
|
2388
2441
|
"button",
|
|
2389
2442
|
{
|
|
2390
2443
|
onClick: () => {
|
|
@@ -2393,29 +2446,29 @@ var GridHeader = ({
|
|
|
2393
2446
|
},
|
|
2394
2447
|
className: "flex items-center gap-2 w-full px-3 py-2 text-sm hover:bg-muted cursor-pointer",
|
|
2395
2448
|
children: [
|
|
2396
|
-
/* @__PURE__ */
|
|
2397
|
-
"Excel"
|
|
2449
|
+
/* @__PURE__ */ jsx25(FileSpreadsheet, { size: 14 }),
|
|
2450
|
+
" Excel"
|
|
2398
2451
|
]
|
|
2399
2452
|
}
|
|
2400
2453
|
)
|
|
2401
2454
|
] })
|
|
2402
2455
|
] })
|
|
2403
|
-
] }),
|
|
2456
|
+
] }) }),
|
|
2404
2457
|
children,
|
|
2405
|
-
search && /* @__PURE__ */
|
|
2458
|
+
search && /* @__PURE__ */ jsx25("div", { className: "relative h-[40px] flex items-center", children: /* @__PURE__ */ jsx25(
|
|
2406
2459
|
"div",
|
|
2407
2460
|
{
|
|
2408
2461
|
className: `absolute md:right-0 flex items-center transition-all duration-200 ${searchOpen ? "w-[250px]" : "w-[40px]"} h-[40px]`,
|
|
2409
|
-
children: !searchOpen ? /* @__PURE__ */
|
|
2462
|
+
children: !searchOpen ? /* @__PURE__ */ jsx25(
|
|
2410
2463
|
"button",
|
|
2411
2464
|
{
|
|
2412
2465
|
onClick: () => setSearchOpen(true),
|
|
2413
2466
|
className: "w-[40px] h-[40px] flex items-center justify-center rounded-md hover:bg-input cursor-pointer",
|
|
2414
|
-
children: /* @__PURE__ */
|
|
2467
|
+
children: /* @__PURE__ */ jsx25(Search, { size: 18 })
|
|
2415
2468
|
}
|
|
2416
|
-
) : /* @__PURE__ */
|
|
2417
|
-
/* @__PURE__ */
|
|
2418
|
-
/* @__PURE__ */
|
|
2469
|
+
) : /* @__PURE__ */ jsxs19("div", { className: "flex items-center gap-2 w-full h-full px-3 rounded-md border border-input bg-background", children: [
|
|
2470
|
+
/* @__PURE__ */ jsx25(Search, { size: 16 }),
|
|
2471
|
+
/* @__PURE__ */ jsx25(
|
|
2419
2472
|
"input",
|
|
2420
2473
|
{
|
|
2421
2474
|
autoFocus: true,
|
|
@@ -2425,23 +2478,186 @@ var GridHeader = ({
|
|
|
2425
2478
|
value: searchValue
|
|
2426
2479
|
}
|
|
2427
2480
|
),
|
|
2428
|
-
/* @__PURE__ */
|
|
2429
|
-
"button",
|
|
2430
|
-
{
|
|
2431
|
-
onClick: () => setSearchOpen(false),
|
|
2432
|
-
className: "cursor-pointer",
|
|
2433
|
-
children: /* @__PURE__ */ jsx24(X3, { size: 16 })
|
|
2434
|
-
}
|
|
2435
|
-
)
|
|
2481
|
+
/* @__PURE__ */ jsx25("button", { onClick: () => setSearchOpen(false), className: "cursor-pointer", children: /* @__PURE__ */ jsx25(X4, { size: 16 }) })
|
|
2436
2482
|
] })
|
|
2437
2483
|
}
|
|
2438
2484
|
) })
|
|
2439
2485
|
] });
|
|
2440
|
-
}
|
|
2486
|
+
}
|
|
2441
2487
|
var gridHeader_default = GridHeader;
|
|
2442
2488
|
|
|
2489
|
+
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2490
|
+
import React3 from "react";
|
|
2491
|
+
|
|
2492
|
+
// node_modules/@svar-ui/lib-react/dist/index.js
|
|
2493
|
+
import { useState as useState8, useRef as useRef3, useEffect as useEffect7 } from "react";
|
|
2494
|
+
|
|
2495
|
+
// node_modules/@svar-ui/lib-dom/dist/index.js
|
|
2496
|
+
function getEnv() {
|
|
2497
|
+
return {
|
|
2498
|
+
detect: () => true,
|
|
2499
|
+
addEvent: function(node, event, handler) {
|
|
2500
|
+
node.addEventListener(event, handler);
|
|
2501
|
+
return () => node.removeEventListener(event, handler);
|
|
2502
|
+
},
|
|
2503
|
+
addGlobalEvent: function(event, handler) {
|
|
2504
|
+
document.addEventListener(event, handler);
|
|
2505
|
+
return () => document.removeEventListener(event, handler);
|
|
2506
|
+
},
|
|
2507
|
+
getTopNode: function() {
|
|
2508
|
+
return window.document.body;
|
|
2509
|
+
}
|
|
2510
|
+
};
|
|
2511
|
+
}
|
|
2512
|
+
var env = getEnv();
|
|
2513
|
+
var id2 = (/* @__PURE__ */ new Date()).valueOf();
|
|
2514
|
+
|
|
2515
|
+
// node_modules/@svar-ui/lib-react/dist/index.js
|
|
2516
|
+
function useWritable(writable2, initialValue, name) {
|
|
2517
|
+
const [state, setState] = useState8(() => initialValue);
|
|
2518
|
+
if (!writable2) console.warn(`Writable ${name} is not defined`);
|
|
2519
|
+
useEffect7(() => {
|
|
2520
|
+
if (!writable2) return;
|
|
2521
|
+
const unsubscribe = writable2.subscribe((newValue) => {
|
|
2522
|
+
setState(() => newValue);
|
|
2523
|
+
});
|
|
2524
|
+
return unsubscribe;
|
|
2525
|
+
}, [writable2]);
|
|
2526
|
+
return state;
|
|
2527
|
+
}
|
|
2528
|
+
function useStore(store, name) {
|
|
2529
|
+
const s = store.getState();
|
|
2530
|
+
const r = store.getReactiveState();
|
|
2531
|
+
return useWritable(r[name], s[name], name);
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2535
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2536
|
+
var CheckboxCell = ({ row, api, column }) => {
|
|
2537
|
+
const selectedRows = useStore(api, "selectedRows");
|
|
2538
|
+
const isSelected = selectedRows.includes(row.id);
|
|
2539
|
+
const handleChange = (e) => {
|
|
2540
|
+
var _a, _b;
|
|
2541
|
+
e.stopPropagation();
|
|
2542
|
+
const isChecked = e.target.checked;
|
|
2543
|
+
api.exec("select-row", { id: row.id, mode: isChecked, toggle: true });
|
|
2544
|
+
(_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.onSelectionChange) == null ? void 0 : _b.call(_a, row.id, row, isChecked);
|
|
2545
|
+
};
|
|
2546
|
+
return /* @__PURE__ */ jsx26(
|
|
2547
|
+
"div",
|
|
2548
|
+
{
|
|
2549
|
+
className: "flex items-center justify-center w-full h-full",
|
|
2550
|
+
"data-action": "ignore-click",
|
|
2551
|
+
onClick: (e) => e.stopPropagation(),
|
|
2552
|
+
children: /* @__PURE__ */ jsx26(
|
|
2553
|
+
"input",
|
|
2554
|
+
{
|
|
2555
|
+
type: "checkbox",
|
|
2556
|
+
checked: isSelected,
|
|
2557
|
+
onChange: handleChange,
|
|
2558
|
+
className: "w-4 h-4 rounded border border-border bg-background accent-primary cursor-pointer focus:outline-none focus:ring-1 focus:ring-primary"
|
|
2559
|
+
}
|
|
2560
|
+
)
|
|
2561
|
+
}
|
|
2562
|
+
);
|
|
2563
|
+
};
|
|
2564
|
+
var checkBoxCell_default = React3.memo(CheckboxCell);
|
|
2565
|
+
|
|
2566
|
+
// src/components/custom/grid/checkboxCell/headerCheckBox.tsx
|
|
2567
|
+
import React4, { useEffect as useEffect8, useRef as useRef4, useReducer } from "react";
|
|
2568
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
2569
|
+
var HeaderCheckbox = ({ api, column }) => {
|
|
2570
|
+
var _a;
|
|
2571
|
+
const checkboxRef = useRef4(null);
|
|
2572
|
+
const computeState = () => {
|
|
2573
|
+
var _a2, _b, _c;
|
|
2574
|
+
const pageData = (_b = (_a2 = column == null ? void 0 : column.config) == null ? void 0 : _a2.getPageData()) != null ? _b : [];
|
|
2575
|
+
const selectedRows = (_c = api.getState().selectedRows) != null ? _c : [];
|
|
2576
|
+
const selectedOnPage = pageData.filter(
|
|
2577
|
+
(r) => selectedRows.includes(r.id)
|
|
2578
|
+
).length;
|
|
2579
|
+
return {
|
|
2580
|
+
allSelected: pageData.length > 0 && selectedOnPage === pageData.length,
|
|
2581
|
+
someSelected: selectedOnPage > 0 && selectedOnPage < pageData.length
|
|
2582
|
+
};
|
|
2583
|
+
};
|
|
2584
|
+
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
2585
|
+
useEffect8(() => {
|
|
2586
|
+
const unsub = api.on("select-row", () => {
|
|
2587
|
+
forceUpdate();
|
|
2588
|
+
});
|
|
2589
|
+
return () => {
|
|
2590
|
+
if (typeof unsub === "function") unsub();
|
|
2591
|
+
};
|
|
2592
|
+
}, [api]);
|
|
2593
|
+
useEffect8(() => {
|
|
2594
|
+
var _a2;
|
|
2595
|
+
(_a2 = column == null ? void 0 : column.config) == null ? void 0 : _a2.clearToken;
|
|
2596
|
+
forceUpdate();
|
|
2597
|
+
}, [(_a = column == null ? void 0 : column.config) == null ? void 0 : _a.clearToken]);
|
|
2598
|
+
const state = computeState();
|
|
2599
|
+
useEffect8(() => {
|
|
2600
|
+
if (checkboxRef.current) {
|
|
2601
|
+
checkboxRef.current.indeterminate = state.someSelected;
|
|
2602
|
+
}
|
|
2603
|
+
}, [state.someSelected]);
|
|
2604
|
+
const handleChange = (e) => {
|
|
2605
|
+
var _a2, _b, _c, _d;
|
|
2606
|
+
e.stopPropagation();
|
|
2607
|
+
const isChecked = e.target.checked;
|
|
2608
|
+
const pageData = (_b = (_a2 = column == null ? void 0 : column.config) == null ? void 0 : _a2.getPageData()) != null ? _b : [];
|
|
2609
|
+
pageData.forEach((row) => {
|
|
2610
|
+
api.exec("select-row", { id: row.id, mode: isChecked, toggle: true });
|
|
2611
|
+
});
|
|
2612
|
+
(_d = (_c = column == null ? void 0 : column.config) == null ? void 0 : _c.onSelectAllPage) == null ? void 0 : _d.call(_c, pageData, isChecked);
|
|
2613
|
+
};
|
|
2614
|
+
return /* @__PURE__ */ jsx27(
|
|
2615
|
+
"div",
|
|
2616
|
+
{
|
|
2617
|
+
className: "flex items-center justify-center w-full h-full",
|
|
2618
|
+
"data-action": "ignore-click",
|
|
2619
|
+
onClick: (e) => e.stopPropagation(),
|
|
2620
|
+
children: /* @__PURE__ */ jsx27(
|
|
2621
|
+
"input",
|
|
2622
|
+
{
|
|
2623
|
+
ref: checkboxRef,
|
|
2624
|
+
type: "checkbox",
|
|
2625
|
+
checked: state.allSelected,
|
|
2626
|
+
onChange: handleChange,
|
|
2627
|
+
className: "w-4 h-4 rounded border border-border bg-background accent-primary cursor-pointer focus:outline-none focus:ring-1 focus:ring-primary"
|
|
2628
|
+
}
|
|
2629
|
+
)
|
|
2630
|
+
}
|
|
2631
|
+
);
|
|
2632
|
+
};
|
|
2633
|
+
var headerCheckBox_default = React4.memo(HeaderCheckbox);
|
|
2634
|
+
|
|
2635
|
+
// src/components/custom/grid/utils/buildCheckboxColumn.tsx
|
|
2636
|
+
function buildCheckboxColumn({
|
|
2637
|
+
getPageData,
|
|
2638
|
+
onSelectionChange,
|
|
2639
|
+
onSelectAllPage,
|
|
2640
|
+
clearToken
|
|
2641
|
+
}) {
|
|
2642
|
+
const configRef = {
|
|
2643
|
+
getPageData,
|
|
2644
|
+
onSelectionChange,
|
|
2645
|
+
onSelectAllPage,
|
|
2646
|
+
clearToken
|
|
2647
|
+
};
|
|
2648
|
+
return {
|
|
2649
|
+
id: "__selection__",
|
|
2650
|
+
width: 58,
|
|
2651
|
+
sortable: false,
|
|
2652
|
+
resize: false,
|
|
2653
|
+
config: configRef,
|
|
2654
|
+
header: { cell: headerCheckBox_default },
|
|
2655
|
+
cell: checkBoxCell_default
|
|
2656
|
+
};
|
|
2657
|
+
}
|
|
2658
|
+
|
|
2443
2659
|
// src/components/custom/grid/index.tsx
|
|
2444
|
-
import { jsx as
|
|
2660
|
+
import { jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2445
2661
|
var Grid = forwardRef(
|
|
2446
2662
|
(_a, ref) => {
|
|
2447
2663
|
var _b = _a, {
|
|
@@ -2457,7 +2673,17 @@ var Grid = forwardRef(
|
|
|
2457
2673
|
fonts,
|
|
2458
2674
|
onFilterChange,
|
|
2459
2675
|
initialFilters,
|
|
2460
|
-
children
|
|
2676
|
+
children,
|
|
2677
|
+
onFocusCell = () => false,
|
|
2678
|
+
selectionEnabled = false,
|
|
2679
|
+
selectedIds = [],
|
|
2680
|
+
onRowSelectionChange,
|
|
2681
|
+
onSelectAllPage,
|
|
2682
|
+
selectedCount,
|
|
2683
|
+
selectedData,
|
|
2684
|
+
selectionActions,
|
|
2685
|
+
onSelectionAction,
|
|
2686
|
+
onClearSelection
|
|
2461
2687
|
} = _b, rest = __objRest(_b, [
|
|
2462
2688
|
"data",
|
|
2463
2689
|
"columns",
|
|
@@ -2471,33 +2697,91 @@ var Grid = forwardRef(
|
|
|
2471
2697
|
"fonts",
|
|
2472
2698
|
"onFilterChange",
|
|
2473
2699
|
"initialFilters",
|
|
2474
|
-
"children"
|
|
2700
|
+
"children",
|
|
2701
|
+
"onFocusCell",
|
|
2702
|
+
"selectionEnabled",
|
|
2703
|
+
"selectedIds",
|
|
2704
|
+
"onRowSelectionChange",
|
|
2705
|
+
"onSelectAllPage",
|
|
2706
|
+
"selectedCount",
|
|
2707
|
+
"selectedData",
|
|
2708
|
+
"selectionActions",
|
|
2709
|
+
"onSelectionAction",
|
|
2710
|
+
"onClearSelection"
|
|
2475
2711
|
]);
|
|
2476
|
-
|
|
2477
|
-
const
|
|
2712
|
+
var _a2;
|
|
2713
|
+
const apiRef = useRef5(null);
|
|
2714
|
+
const containerRef = useRef5(null);
|
|
2715
|
+
const dataRef = useRef5(data);
|
|
2716
|
+
useEffect9(() => {
|
|
2717
|
+
dataRef.current = data;
|
|
2718
|
+
}, [data]);
|
|
2719
|
+
const onRowSelectionChangeRef = useRef5(onRowSelectionChange);
|
|
2720
|
+
useEffect9(() => {
|
|
2721
|
+
onRowSelectionChangeRef.current = onRowSelectionChange;
|
|
2722
|
+
}, [onRowSelectionChange]);
|
|
2723
|
+
const onSelectAllPageRef = useRef5(onSelectAllPage);
|
|
2724
|
+
useEffect9(() => {
|
|
2725
|
+
onSelectAllPageRef.current = onSelectAllPage;
|
|
2726
|
+
}, [onSelectAllPage]);
|
|
2478
2727
|
useImperativeHandle(ref, () => apiRef.current, []);
|
|
2728
|
+
const clearTokenRef = useRef5(0);
|
|
2729
|
+
const prevSelectedCountRef = useRef5(selectedCount != null ? selectedCount : 0);
|
|
2730
|
+
if (((_a2 = prevSelectedCountRef.current) != null ? _a2 : 0) > 0 && (selectedCount != null ? selectedCount : 0) === 0) {
|
|
2731
|
+
clearTokenRef.current += 1;
|
|
2732
|
+
}
|
|
2733
|
+
prevSelectedCountRef.current = selectedCount != null ? selectedCount : 0;
|
|
2734
|
+
const resolvedColumns = useMemo4(() => {
|
|
2735
|
+
if (!selectionEnabled) return columns;
|
|
2736
|
+
const checkboxCol = buildCheckboxColumn({
|
|
2737
|
+
getPageData: () => {
|
|
2738
|
+
var _a3;
|
|
2739
|
+
return (_a3 = dataRef.current) != null ? _a3 : [];
|
|
2740
|
+
},
|
|
2741
|
+
onSelectionChange: (id3, rowData, checked) => {
|
|
2742
|
+
var _a3;
|
|
2743
|
+
(_a3 = onRowSelectionChangeRef.current) == null ? void 0 : _a3.call(onRowSelectionChangeRef, id3, rowData, checked);
|
|
2744
|
+
},
|
|
2745
|
+
onSelectAllPage: (pageData, checked) => {
|
|
2746
|
+
var _a3;
|
|
2747
|
+
(_a3 = onSelectAllPageRef.current) == null ? void 0 : _a3.call(onSelectAllPageRef, pageData, checked);
|
|
2748
|
+
},
|
|
2749
|
+
clearToken: clearTokenRef.current
|
|
2750
|
+
});
|
|
2751
|
+
return [checkboxCol, ...columns];
|
|
2752
|
+
}, [selectionEnabled, columns, clearTokenRef.current]);
|
|
2479
2753
|
const resizeColumns = useCallback2(() => {
|
|
2480
|
-
var _a2;
|
|
2481
2754
|
const api = apiRef.current;
|
|
2482
2755
|
const container = containerRef.current;
|
|
2483
|
-
if (!api) return;
|
|
2484
|
-
const gridWidth =
|
|
2756
|
+
if (!api || !container) return;
|
|
2757
|
+
const gridWidth = container.clientWidth;
|
|
2758
|
+
const isFixedColumn = (col) => col.id === "__selection__";
|
|
2759
|
+
const resizableColumns = resolvedColumns.filter(
|
|
2760
|
+
(col) => !isFixedColumn(col)
|
|
2761
|
+
);
|
|
2762
|
+
const fixedColumns = resolvedColumns.filter(
|
|
2763
|
+
(col) => isFixedColumn(col)
|
|
2764
|
+
);
|
|
2765
|
+
const totalFixedWidth = fixedColumns.reduce((sum, col) => {
|
|
2766
|
+
var _a3, _b2;
|
|
2767
|
+
const column = api.getColumn(col.id);
|
|
2768
|
+
const width = (_b2 = (_a3 = column == null ? void 0 : column.width) != null ? _a3 : col.width) != null ? _b2 : 0;
|
|
2769
|
+
return sum + (isNaN(width) ? 0 : width);
|
|
2770
|
+
}, 0);
|
|
2771
|
+
const availableWidth = Math.max(gridWidth - totalFixedWidth, 0);
|
|
2485
2772
|
if (data && data.length > 0) {
|
|
2486
|
-
|
|
2487
|
-
api.exec("resize-column", {
|
|
2488
|
-
id: col.id,
|
|
2489
|
-
auto: "data"
|
|
2490
|
-
});
|
|
2773
|
+
resizableColumns.forEach((col) => {
|
|
2774
|
+
api.exec("resize-column", { id: col.id, auto: "data" });
|
|
2491
2775
|
});
|
|
2492
|
-
const
|
|
2776
|
+
const totalAutoWidth = resizableColumns.reduce((sum, col) => {
|
|
2493
2777
|
var _a3;
|
|
2494
2778
|
const column = api.getColumn(col.id);
|
|
2495
2779
|
const width = (_a3 = column == null ? void 0 : column.width) != null ? _a3 : 0;
|
|
2496
2780
|
return sum + (isNaN(width) ? 0 : width);
|
|
2497
2781
|
}, 0);
|
|
2498
|
-
if (
|
|
2499
|
-
const extra = (
|
|
2500
|
-
|
|
2782
|
+
if (totalAutoWidth < availableWidth && resizableColumns.length > 0) {
|
|
2783
|
+
const extra = (availableWidth - totalAutoWidth) / resizableColumns.length;
|
|
2784
|
+
resizableColumns.forEach((col) => {
|
|
2501
2785
|
var _a3;
|
|
2502
2786
|
const column = api.getColumn(col.id);
|
|
2503
2787
|
const currentWidth = (_a3 = column == null ? void 0 : column.width) != null ? _a3 : 0;
|
|
@@ -2510,20 +2794,18 @@ var Grid = forwardRef(
|
|
|
2510
2794
|
});
|
|
2511
2795
|
}
|
|
2512
2796
|
} else {
|
|
2513
|
-
const
|
|
2514
|
-
|
|
2797
|
+
const equalWidth = resizableColumns.length > 0 ? availableWidth / resizableColumns.length : 0;
|
|
2798
|
+
resizableColumns.forEach((col) => {
|
|
2515
2799
|
api.exec("resize-column", {
|
|
2516
2800
|
id: col.id,
|
|
2517
|
-
width:
|
|
2801
|
+
width: equalWidth
|
|
2518
2802
|
});
|
|
2519
2803
|
});
|
|
2520
2804
|
}
|
|
2521
|
-
}, [
|
|
2522
|
-
|
|
2805
|
+
}, [resolvedColumns, data]);
|
|
2806
|
+
useEffect9(() => {
|
|
2523
2807
|
if (!containerRef.current) return;
|
|
2524
|
-
const observer = new ResizeObserver(() =>
|
|
2525
|
-
resizeColumns();
|
|
2526
|
-
});
|
|
2808
|
+
const observer = new ResizeObserver(() => resizeColumns());
|
|
2527
2809
|
observer.observe(containerRef.current);
|
|
2528
2810
|
return () => observer.disconnect();
|
|
2529
2811
|
}, [resizeColumns]);
|
|
@@ -2531,35 +2813,27 @@ var Grid = forwardRef(
|
|
|
2531
2813
|
(api) => {
|
|
2532
2814
|
apiRef.current = api;
|
|
2533
2815
|
resizeColumns();
|
|
2816
|
+
api.intercept("focus-cell", onFocusCell);
|
|
2534
2817
|
},
|
|
2535
|
-
[resizeColumns]
|
|
2818
|
+
[resizeColumns, onFocusCell]
|
|
2536
2819
|
);
|
|
2537
2820
|
const getSelectedData = () => {
|
|
2538
|
-
var
|
|
2539
|
-
const selected = (_b2 = (
|
|
2540
|
-
|
|
2541
|
-
return selected.includes(row.id);
|
|
2542
|
-
});
|
|
2543
|
-
return selectedData;
|
|
2821
|
+
var _a3, _b2;
|
|
2822
|
+
const selected = (_b2 = (_a3 = apiRef.current) == null ? void 0 : _a3.getState().selectedRows) != null ? _b2 : [];
|
|
2823
|
+
return data.filter((row) => selected.includes(row.id));
|
|
2544
2824
|
};
|
|
2545
2825
|
const handleExportPdf = useCallback2(() => {
|
|
2546
2826
|
const selected = getSelectedData();
|
|
2547
|
-
if (selected.length)
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
onExportPdf == null ? void 0 : onExportPdf();
|
|
2551
|
-
}
|
|
2552
|
-
}, [getSelectedData, exportPdf, onExportPdf, fileName]);
|
|
2827
|
+
if (selected.length) exportPdf(selected, fileName);
|
|
2828
|
+
else onExportPdf == null ? void 0 : onExportPdf();
|
|
2829
|
+
}, [data, fileName, onExportPdf]);
|
|
2553
2830
|
const handleExportExcel = useCallback2(() => {
|
|
2554
2831
|
const selected = getSelectedData();
|
|
2555
|
-
if (selected.length)
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
}, [getSelectedData, exportExcel, onExportExcel, fileName]);
|
|
2561
|
-
return /* @__PURE__ */ jsxs19("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
2562
|
-
/* @__PURE__ */ jsx25(
|
|
2832
|
+
if (selected.length) exportExcel(selected, fileName);
|
|
2833
|
+
else onExportExcel == null ? void 0 : onExportExcel();
|
|
2834
|
+
}, [data, fileName, onExportExcel]);
|
|
2835
|
+
return /* @__PURE__ */ jsxs20("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
2836
|
+
/* @__PURE__ */ jsx28(
|
|
2563
2837
|
gridHeader_default,
|
|
2564
2838
|
{
|
|
2565
2839
|
onPdf: handleExportPdf,
|
|
@@ -2572,10 +2846,31 @@ var Grid = forwardRef(
|
|
|
2572
2846
|
filterList: rest.filterList,
|
|
2573
2847
|
onFilterChange,
|
|
2574
2848
|
initialFilters,
|
|
2849
|
+
selectedCount,
|
|
2850
|
+
selectedData,
|
|
2851
|
+
selectionActions,
|
|
2852
|
+
onSelectionAction,
|
|
2853
|
+
onClearSelection,
|
|
2575
2854
|
children
|
|
2576
2855
|
}
|
|
2577
2856
|
),
|
|
2578
|
-
/* @__PURE__ */
|
|
2857
|
+
/* @__PURE__ */ jsx28(
|
|
2858
|
+
"div",
|
|
2859
|
+
{
|
|
2860
|
+
className: "flex-1 w-full border border-border overflow-hidden",
|
|
2861
|
+
ref: containerRef,
|
|
2862
|
+
children: /* @__PURE__ */ jsx28(WillowDark, { fonts, children: /* @__PURE__ */ jsx28("div", { className: "w-full h-full relative", children: rest.loading ? /* @__PURE__ */ jsx28("div", { className: "absolute inset-0 bg-background/60 backdrop-blur-sm flex items-center justify-center z-10", children: /* @__PURE__ */ jsx28("div", { className: "animate-spin rounded-full h-8 w-8 border-2 border-primary border-t-transparent" }) }) : /* @__PURE__ */ jsx28(
|
|
2863
|
+
SvarGrid,
|
|
2864
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
2865
|
+
data,
|
|
2866
|
+
columns: resolvedColumns,
|
|
2867
|
+
init,
|
|
2868
|
+
selectedRows: selectionEnabled ? selectedIds : void 0,
|
|
2869
|
+
select: selectionEnabled ? false : rest.select
|
|
2870
|
+
})
|
|
2871
|
+
) }) })
|
|
2872
|
+
}
|
|
2873
|
+
)
|
|
2579
2874
|
] });
|
|
2580
2875
|
}
|
|
2581
2876
|
);
|
|
@@ -2583,9 +2878,10 @@ var grid_default = Grid;
|
|
|
2583
2878
|
|
|
2584
2879
|
// src/components/custom/grid/sortableHeaderCell.tsx
|
|
2585
2880
|
import { MoveDown, MoveUp, ArrowUpDown } from "lucide-react";
|
|
2586
|
-
import
|
|
2587
|
-
|
|
2588
|
-
|
|
2881
|
+
import React5 from "react";
|
|
2882
|
+
import { jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2883
|
+
var SortableHeaderCell = ({ cell, sortKey, sortOrder, onSortChange }) => {
|
|
2884
|
+
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */ jsx29("span", { children: cell == null ? void 0 : cell.text });
|
|
2589
2885
|
const active = sortKey === cell.id;
|
|
2590
2886
|
const handleClick = () => {
|
|
2591
2887
|
if (!onSortChange || !cell.id) return;
|
|
@@ -2599,20 +2895,27 @@ function SortableHeaderCell({ cell, sortKey, sortOrder, onSortChange }) {
|
|
|
2599
2895
|
}
|
|
2600
2896
|
onSortChange("", null);
|
|
2601
2897
|
};
|
|
2602
|
-
return /* @__PURE__ */
|
|
2898
|
+
return /* @__PURE__ */ jsxs21(
|
|
2603
2899
|
"div",
|
|
2604
2900
|
{
|
|
2605
2901
|
onClick: handleClick,
|
|
2606
2902
|
className: "cursor-pointer flex items-center gap-2 justify-between select-none",
|
|
2607
2903
|
children: [
|
|
2608
|
-
/* @__PURE__ */
|
|
2609
|
-
!active && /* @__PURE__ */
|
|
2610
|
-
active && (sortOrder === "asc" ? /* @__PURE__ */
|
|
2904
|
+
/* @__PURE__ */ jsx29("span", { children: cell.text }),
|
|
2905
|
+
!active && /* @__PURE__ */ jsx29(ArrowUpDown, { className: "w-4 h-4 opacity-50" }),
|
|
2906
|
+
active && (sortOrder === "asc" ? /* @__PURE__ */ jsx29(MoveDown, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx29(MoveUp, { className: "w-4 h-4" }))
|
|
2611
2907
|
]
|
|
2612
2908
|
}
|
|
2613
2909
|
);
|
|
2614
|
-
}
|
|
2615
|
-
var sortableHeaderCell_default = SortableHeaderCell
|
|
2910
|
+
};
|
|
2911
|
+
var sortableHeaderCell_default = React5.memo(SortableHeaderCell, (prev, next) => {
|
|
2912
|
+
var _a, _b, _c, _d;
|
|
2913
|
+
if (((_a = prev.cell) == null ? void 0 : _a.id) !== ((_b = next.cell) == null ? void 0 : _b.id)) return false;
|
|
2914
|
+
if (((_c = prev.cell) == null ? void 0 : _c.text) !== ((_d = next.cell) == null ? void 0 : _d.text)) return false;
|
|
2915
|
+
if (prev.sortKey !== next.sortKey) return false;
|
|
2916
|
+
if (prev.sortOrder !== next.sortOrder) return false;
|
|
2917
|
+
return true;
|
|
2918
|
+
});
|
|
2616
2919
|
|
|
2617
2920
|
// src/utils/pagination.ts
|
|
2618
2921
|
function getPaginationRange(currentPage, totalPages, siblingCount = 2) {
|
|
@@ -2646,7 +2949,7 @@ function getPaginationRange(currentPage, totalPages, siblingCount = 2) {
|
|
|
2646
2949
|
|
|
2647
2950
|
// src/components/custom/pagination/index.tsx
|
|
2648
2951
|
import { ChevronLeft, ChevronRight as ChevronRight3 } from "lucide-react";
|
|
2649
|
-
import { jsx as
|
|
2952
|
+
import { jsx as jsx30, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2650
2953
|
function Pagination({
|
|
2651
2954
|
totalCount,
|
|
2652
2955
|
count = null,
|
|
@@ -2666,47 +2969,47 @@ function Pagination({
|
|
|
2666
2969
|
const handlePageSizeChange = (size) => {
|
|
2667
2970
|
onPageSizeChange == null ? void 0 : onPageSizeChange(size);
|
|
2668
2971
|
};
|
|
2669
|
-
return /* @__PURE__ */
|
|
2670
|
-
/* @__PURE__ */
|
|
2671
|
-
/* @__PURE__ */
|
|
2972
|
+
return /* @__PURE__ */ jsxs22("div", { className: "flex flex-col-reverse gap-2 md:flex-row items-center justify-between bg-card px-3 py-2 rounded-br-md rounded-bl-md border-l border-r border-b", children: [
|
|
2973
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex justify-between w-full md:w-auto items-center gap-3 text-xs text-muted-foreground tracking-wider font-medium", children: [
|
|
2974
|
+
/* @__PURE__ */ jsxs22("span", { children: [
|
|
2672
2975
|
"Showing ",
|
|
2673
|
-
/* @__PURE__ */
|
|
2976
|
+
/* @__PURE__ */ jsx30("span", { className: "text-foreground", children: count }),
|
|
2674
2977
|
" of",
|
|
2675
2978
|
" ",
|
|
2676
|
-
/* @__PURE__ */
|
|
2979
|
+
/* @__PURE__ */ jsx30("span", { className: "text-foreground", children: totalCount })
|
|
2677
2980
|
] }),
|
|
2678
|
-
showSizeChanger && /* @__PURE__ */
|
|
2981
|
+
showSizeChanger && /* @__PURE__ */ jsx30(
|
|
2679
2982
|
"select",
|
|
2680
2983
|
{
|
|
2681
2984
|
value: pageSize,
|
|
2682
2985
|
onChange: (e) => handlePageSizeChange(Number(e.target.value)),
|
|
2683
2986
|
className: "rounded-md border border-input bg-background px-3 py-2 text-xs text-foreground focus:outline-none",
|
|
2684
|
-
children: sizeChangerOptions.map((size) => /* @__PURE__ */
|
|
2987
|
+
children: sizeChangerOptions.map((size) => /* @__PURE__ */ jsxs22("option", { value: size, children: [
|
|
2685
2988
|
size,
|
|
2686
2989
|
" / page"
|
|
2687
2990
|
] }, size))
|
|
2688
2991
|
}
|
|
2689
2992
|
)
|
|
2690
2993
|
] }),
|
|
2691
|
-
/* @__PURE__ */
|
|
2692
|
-
/* @__PURE__ */
|
|
2994
|
+
/* @__PURE__ */ jsxs22("div", { className: "flex w-full md:w-auto justify-between items-center gap-1", children: [
|
|
2995
|
+
/* @__PURE__ */ jsx30(
|
|
2693
2996
|
"button",
|
|
2694
2997
|
{
|
|
2695
2998
|
disabled: currentPage === 1,
|
|
2696
2999
|
onClick: () => handlePageChange(currentPage - 1),
|
|
2697
3000
|
className: "border border-border w-8 h-8 rounded-md flex items-center justify-center disabled:opacity-40 hover:bg-card-foreground transition",
|
|
2698
|
-
children: /* @__PURE__ */
|
|
3001
|
+
children: /* @__PURE__ */ jsx30(ChevronLeft, { className: "w-5 h-5 select-none" })
|
|
2699
3002
|
}
|
|
2700
3003
|
),
|
|
2701
3004
|
pages.map(
|
|
2702
|
-
(page, idx) => page === "dots" ? /* @__PURE__ */
|
|
3005
|
+
(page, idx) => page === "dots" ? /* @__PURE__ */ jsx30(
|
|
2703
3006
|
"span",
|
|
2704
3007
|
{
|
|
2705
3008
|
className: "px-2 text-muted-foreground text-xs tracking-wider font-medium",
|
|
2706
3009
|
children: "\u2026"
|
|
2707
3010
|
},
|
|
2708
3011
|
`dots-${idx}`
|
|
2709
|
-
) : /* @__PURE__ */
|
|
3012
|
+
) : /* @__PURE__ */ jsx30(
|
|
2710
3013
|
"button",
|
|
2711
3014
|
{
|
|
2712
3015
|
onClick: () => handlePageChange(page),
|
|
@@ -2716,13 +3019,13 @@ function Pagination({
|
|
|
2716
3019
|
page
|
|
2717
3020
|
)
|
|
2718
3021
|
),
|
|
2719
|
-
/* @__PURE__ */
|
|
3022
|
+
/* @__PURE__ */ jsx30(
|
|
2720
3023
|
"button",
|
|
2721
3024
|
{
|
|
2722
3025
|
disabled: currentPage === totalPages,
|
|
2723
3026
|
onClick: () => handlePageChange(currentPage + 1),
|
|
2724
3027
|
className: "border border-border w-8 h-8 rounded-md flex items-center justify-center disabled:opacity-40 hover:bg-card-foreground transition",
|
|
2725
|
-
children: /* @__PURE__ */
|
|
3028
|
+
children: /* @__PURE__ */ jsx30(ChevronRight3, { className: "w-5 h-5 select-none" })
|
|
2726
3029
|
}
|
|
2727
3030
|
)
|
|
2728
3031
|
] })
|
|
@@ -2731,9 +3034,9 @@ function Pagination({
|
|
|
2731
3034
|
var pagination_default = Pagination;
|
|
2732
3035
|
|
|
2733
3036
|
// src/components/custom/toolbar/index.tsx
|
|
2734
|
-
import { ChevronRight as ChevronRight4, X as
|
|
2735
|
-
import { useState as
|
|
2736
|
-
import { Fragment as
|
|
3037
|
+
import { ChevronRight as ChevronRight4, X as X5 } from "lucide-react";
|
|
3038
|
+
import { useState as useState9, useRef as useRef6, useEffect as useEffect10 } from "react";
|
|
3039
|
+
import { Fragment as Fragment4, jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2737
3040
|
var SlideToolbar = ({
|
|
2738
3041
|
items,
|
|
2739
3042
|
children,
|
|
@@ -2745,9 +3048,9 @@ var SlideToolbar = ({
|
|
|
2745
3048
|
className = ""
|
|
2746
3049
|
}) => {
|
|
2747
3050
|
const resolvedItems = items != null ? items : children ? void 0 : [];
|
|
2748
|
-
const [open, setOpen] =
|
|
2749
|
-
const panelRef =
|
|
2750
|
-
|
|
3051
|
+
const [open, setOpen] = useState9(false);
|
|
3052
|
+
const panelRef = useRef6(null);
|
|
3053
|
+
useEffect10(() => {
|
|
2751
3054
|
if (!open || !closeOnBackdrop) return;
|
|
2752
3055
|
const handlePointerDown = (e) => {
|
|
2753
3056
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
@@ -2760,8 +3063,8 @@ var SlideToolbar = ({
|
|
|
2760
3063
|
const handleItem = (item) => {
|
|
2761
3064
|
onAction == null ? void 0 : onAction(item.id);
|
|
2762
3065
|
};
|
|
2763
|
-
return /* @__PURE__ */
|
|
2764
|
-
/* @__PURE__ */
|
|
3066
|
+
return /* @__PURE__ */ jsxs23(Fragment4, { children: [
|
|
3067
|
+
/* @__PURE__ */ jsx31("style", { children: `
|
|
2765
3068
|
@keyframes bounceX {
|
|
2766
3069
|
0%, 100% { transform: translateX(0px); }
|
|
2767
3070
|
40% { transform: translateX(4px); }
|
|
@@ -2771,7 +3074,7 @@ var SlideToolbar = ({
|
|
|
2771
3074
|
animation: bounceX 1.4s ease-in-out infinite;
|
|
2772
3075
|
}
|
|
2773
3076
|
` }),
|
|
2774
|
-
/* @__PURE__ */
|
|
3077
|
+
/* @__PURE__ */ jsx31(
|
|
2775
3078
|
"div",
|
|
2776
3079
|
{
|
|
2777
3080
|
role: "button",
|
|
@@ -2785,7 +3088,7 @@ var SlideToolbar = ({
|
|
|
2785
3088
|
"hover:brightness-110 transition-all duration-200",
|
|
2786
3089
|
open ? "opacity-0 pointer-events-none !w-0 border-r-0" : "opacity-100 pointer-events-auto"
|
|
2787
3090
|
].join(" "),
|
|
2788
|
-
children: /* @__PURE__ */
|
|
3091
|
+
children: /* @__PURE__ */ jsx31(
|
|
2789
3092
|
ChevronRight4,
|
|
2790
3093
|
{
|
|
2791
3094
|
className: "text-primary-foreground chevron-bounce",
|
|
@@ -2794,7 +3097,7 @@ var SlideToolbar = ({
|
|
|
2794
3097
|
)
|
|
2795
3098
|
}
|
|
2796
3099
|
),
|
|
2797
|
-
/* @__PURE__ */
|
|
3100
|
+
/* @__PURE__ */ jsxs23(
|
|
2798
3101
|
"div",
|
|
2799
3102
|
{
|
|
2800
3103
|
ref: panelRef,
|
|
@@ -2811,36 +3114,36 @@ var SlideToolbar = ({
|
|
|
2811
3114
|
].join(" "),
|
|
2812
3115
|
style: { width: `${panelWidth}px` },
|
|
2813
3116
|
children: [
|
|
2814
|
-
/* @__PURE__ */
|
|
2815
|
-
/* @__PURE__ */
|
|
2816
|
-
/* @__PURE__ */
|
|
3117
|
+
/* @__PURE__ */ jsxs23("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border shrink-0", children: [
|
|
3118
|
+
/* @__PURE__ */ jsx31("span", { className: "text-sm font-semibold text-foreground tracking-wide", children: title }),
|
|
3119
|
+
/* @__PURE__ */ jsx31(
|
|
2817
3120
|
"button",
|
|
2818
3121
|
{
|
|
2819
3122
|
onClick: () => setOpen(false),
|
|
2820
3123
|
"aria-label": "Close toolbar",
|
|
2821
3124
|
className: "flex items-center justify-center w-6 h-6 rounded-md\n text-foreground/50 hover:text-foreground hover:bg-surface-alt\n transition-all duration-150 cursor-pointer",
|
|
2822
|
-
children: /* @__PURE__ */
|
|
3125
|
+
children: /* @__PURE__ */ jsx31(X5, { size: 13 })
|
|
2823
3126
|
}
|
|
2824
3127
|
)
|
|
2825
3128
|
] }),
|
|
2826
|
-
/* @__PURE__ */
|
|
2827
|
-
/* @__PURE__ */
|
|
2828
|
-
/* @__PURE__ */
|
|
3129
|
+
/* @__PURE__ */ jsx31("div", { className: "flex-1 overflow-y-auto overflow-x-hidden py-2 scrollbar-none", children: resolvedItems ? /* @__PURE__ */ jsxs23(Fragment4, { children: [
|
|
3130
|
+
/* @__PURE__ */ jsx31("p", { className: "px-4 pt-1 pb-2 text-[10px] font-semibold tracking-[0.16em] uppercase text-foreground/35", children: "Actions" }),
|
|
3131
|
+
/* @__PURE__ */ jsx31("nav", { className: "flex flex-col px-2", children: resolvedItems.map((item) => /* @__PURE__ */ jsxs23(
|
|
2829
3132
|
"button",
|
|
2830
3133
|
{
|
|
2831
3134
|
onClick: () => handleItem(item),
|
|
2832
3135
|
className: "group flex items-center gap-3 px-3 py-2.5 rounded-lg w-full\n text-left text-[13px] font-medium cursor-pointer\n text-foreground/60 hover:text-foreground hover:bg-surface-alt\n transition-all duration-150 border-l-2 border-transparent\n hover:border-primary",
|
|
2833
3136
|
children: [
|
|
2834
|
-
/* @__PURE__ */
|
|
2835
|
-
/* @__PURE__ */
|
|
3137
|
+
/* @__PURE__ */ jsx31("span", { className: "flex shrink-0 text-foreground/40 group-hover:text-primary transition-colors duration-150", children: item.icon }),
|
|
3138
|
+
/* @__PURE__ */ jsx31("span", { className: "flex-1 leading-none", children: item.label })
|
|
2836
3139
|
]
|
|
2837
3140
|
},
|
|
2838
3141
|
item.id
|
|
2839
3142
|
)) })
|
|
2840
3143
|
] }) : children }),
|
|
2841
|
-
footerLabel && /* @__PURE__ */
|
|
2842
|
-
/* @__PURE__ */
|
|
2843
|
-
/* @__PURE__ */
|
|
3144
|
+
footerLabel && /* @__PURE__ */ jsxs23("div", { className: "flex items-center gap-2 px-4 py-3 border-t border-border shrink-0", children: [
|
|
3145
|
+
/* @__PURE__ */ jsx31("span", { className: "w-1.5 h-1.5 rounded-full bg-foreground/20 shrink-0" }),
|
|
3146
|
+
/* @__PURE__ */ jsx31("span", { className: "text-[10px] tracking-[0.12em] uppercase text-foreground/30 font-medium", children: footerLabel })
|
|
2844
3147
|
] })
|
|
2845
3148
|
]
|
|
2846
3149
|
}
|