baaz-custom-components 5.2.0 → 5.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -11
- package/dist/index.d.ts +10 -11
- package/dist/index.js +167 -214
- package/dist/index.mjs +156 -202
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import { IApi } from '@svar-ui/react-grid';
|
|
4
4
|
|
|
5
5
|
type NavbarData = NavbarEntry[];
|
|
@@ -48,7 +48,7 @@ interface NavbarProps {
|
|
|
48
48
|
hubIdChangeHandler: (value: string) => void;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
declare function Navbar({ navbarData, userData, onLogout, notificationData, router, hubDetails, hubIdEnable, hubIdChangeHandler, notificationHandler, }: NavbarProps):
|
|
51
|
+
declare function Navbar({ navbarData, userData, onLogout, notificationData, router, hubDetails, hubIdEnable, hubIdChangeHandler, notificationHandler, }: NavbarProps): React$1.JSX.Element | null;
|
|
52
52
|
|
|
53
53
|
type BreadcrumbProps = {
|
|
54
54
|
layoutName: string;
|
|
@@ -57,7 +57,7 @@ type BreadcrumbProps = {
|
|
|
57
57
|
pathname?: string;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
declare const CustomBreadcrumb: ({ layoutName, includeFrom, pathname, }: BreadcrumbProps) =>
|
|
60
|
+
declare const CustomBreadcrumb: ({ layoutName, includeFrom, pathname, }: BreadcrumbProps) => React$1.JSX.Element;
|
|
61
61
|
|
|
62
62
|
type SortOrder = "asc" | "desc";
|
|
63
63
|
|
|
@@ -145,12 +145,11 @@ type AnyRow = {
|
|
|
145
145
|
interface SelectionAction {
|
|
146
146
|
id: string;
|
|
147
147
|
label: string;
|
|
148
|
-
icon?:
|
|
149
|
-
needsConfirmation?: boolean;
|
|
148
|
+
icon?: React__default.ReactNode;
|
|
150
149
|
}
|
|
151
150
|
interface GridSelectionProps {
|
|
151
|
+
getSelectedIds: () => RowId[];
|
|
152
152
|
selectionEnabled?: boolean;
|
|
153
|
-
selectedIds?: RowId[];
|
|
154
153
|
onRowSelectionChange?: (id: RowId, rowData: AnyRow, checked: boolean) => void;
|
|
155
154
|
onSelectAllPage?: (pageData: AnyRow[], checked: boolean) => void;
|
|
156
155
|
}
|
|
@@ -162,7 +161,7 @@ interface GridHeaderSelectionProps {
|
|
|
162
161
|
onClearSelection?: () => void;
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
declare const
|
|
164
|
+
declare const _default$1: React__default.NamedExoticComponent<GridProps & GridSelectionProps & GridHeaderSelectionProps & React__default.RefAttributes<IApi | null>>;
|
|
166
165
|
|
|
167
166
|
type Props = {
|
|
168
167
|
cell: {
|
|
@@ -173,7 +172,7 @@ type Props = {
|
|
|
173
172
|
sortOrder?: SortOrder | null;
|
|
174
173
|
onSortChange?: (key: string, order: SortOrder) => void;
|
|
175
174
|
};
|
|
176
|
-
declare const _default:
|
|
175
|
+
declare const _default: React__default.MemoExoticComponent<({ cell, sortKey, sortOrder, onSortChange }: Props) => React__default.JSX.Element>;
|
|
177
176
|
|
|
178
177
|
type Pagination$1 = {
|
|
179
178
|
totalCount: number;
|
|
@@ -187,7 +186,7 @@ type Pagination$1 = {
|
|
|
187
186
|
sizeChangerOptions?: number[];
|
|
188
187
|
};
|
|
189
188
|
|
|
190
|
-
declare function Pagination({ totalCount, count, currentPage, totalPages, pageSize, onPageChange, onPageSizeChange, showSizeChanger, sizeChangerOptions, }: Pagination$1):
|
|
189
|
+
declare function Pagination({ totalCount, count, currentPage, totalPages, pageSize, onPageChange, onPageSizeChange, showSizeChanger, sizeChangerOptions, }: Pagination$1): React$1.JSX.Element;
|
|
191
190
|
|
|
192
191
|
interface ToolbarItem {
|
|
193
192
|
id: string;
|
|
@@ -207,4 +206,4 @@ interface SlideToolbarProps {
|
|
|
207
206
|
|
|
208
207
|
declare const SlideToolbar: React.FC<SlideToolbarProps>;
|
|
209
208
|
|
|
210
|
-
export { type BreadcrumbProps, CustomBreadcrumb, Grid, type GridProps, Navbar, type NavbarData, type NavbarEntry, type NavbarProps, type NotificationDataTypes, Pagination, type Pagination$1 as PaginationProps, type RouteTree, type RouterAdapter, SlideToolbar, type SlideToolbarProps, _default as SortableHeaderCell, type ToolbarItem, type UserData };
|
|
209
|
+
export { type BreadcrumbProps, CustomBreadcrumb, _default$1 as Grid, type GridProps, Navbar, type NavbarData, type NavbarEntry, type NavbarProps, type NotificationDataTypes, Pagination, type Pagination$1 as PaginationProps, type RouteTree, type RouterAdapter, SlideToolbar, type SlideToolbarProps, _default as SortableHeaderCell, type ToolbarItem, type UserData };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
3
|
import { IApi } from '@svar-ui/react-grid';
|
|
4
4
|
|
|
5
5
|
type NavbarData = NavbarEntry[];
|
|
@@ -48,7 +48,7 @@ interface NavbarProps {
|
|
|
48
48
|
hubIdChangeHandler: (value: string) => void;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
declare function Navbar({ navbarData, userData, onLogout, notificationData, router, hubDetails, hubIdEnable, hubIdChangeHandler, notificationHandler, }: NavbarProps):
|
|
51
|
+
declare function Navbar({ navbarData, userData, onLogout, notificationData, router, hubDetails, hubIdEnable, hubIdChangeHandler, notificationHandler, }: NavbarProps): React$1.JSX.Element | null;
|
|
52
52
|
|
|
53
53
|
type BreadcrumbProps = {
|
|
54
54
|
layoutName: string;
|
|
@@ -57,7 +57,7 @@ type BreadcrumbProps = {
|
|
|
57
57
|
pathname?: string;
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
declare const CustomBreadcrumb: ({ layoutName, includeFrom, pathname, }: BreadcrumbProps) =>
|
|
60
|
+
declare const CustomBreadcrumb: ({ layoutName, includeFrom, pathname, }: BreadcrumbProps) => React$1.JSX.Element;
|
|
61
61
|
|
|
62
62
|
type SortOrder = "asc" | "desc";
|
|
63
63
|
|
|
@@ -145,12 +145,11 @@ type AnyRow = {
|
|
|
145
145
|
interface SelectionAction {
|
|
146
146
|
id: string;
|
|
147
147
|
label: string;
|
|
148
|
-
icon?:
|
|
149
|
-
needsConfirmation?: boolean;
|
|
148
|
+
icon?: React__default.ReactNode;
|
|
150
149
|
}
|
|
151
150
|
interface GridSelectionProps {
|
|
151
|
+
getSelectedIds: () => RowId[];
|
|
152
152
|
selectionEnabled?: boolean;
|
|
153
|
-
selectedIds?: RowId[];
|
|
154
153
|
onRowSelectionChange?: (id: RowId, rowData: AnyRow, checked: boolean) => void;
|
|
155
154
|
onSelectAllPage?: (pageData: AnyRow[], checked: boolean) => void;
|
|
156
155
|
}
|
|
@@ -162,7 +161,7 @@ interface GridHeaderSelectionProps {
|
|
|
162
161
|
onClearSelection?: () => void;
|
|
163
162
|
}
|
|
164
163
|
|
|
165
|
-
declare const
|
|
164
|
+
declare const _default$1: React__default.NamedExoticComponent<GridProps & GridSelectionProps & GridHeaderSelectionProps & React__default.RefAttributes<IApi | null>>;
|
|
166
165
|
|
|
167
166
|
type Props = {
|
|
168
167
|
cell: {
|
|
@@ -173,7 +172,7 @@ type Props = {
|
|
|
173
172
|
sortOrder?: SortOrder | null;
|
|
174
173
|
onSortChange?: (key: string, order: SortOrder) => void;
|
|
175
174
|
};
|
|
176
|
-
declare const _default:
|
|
175
|
+
declare const _default: React__default.MemoExoticComponent<({ cell, sortKey, sortOrder, onSortChange }: Props) => React__default.JSX.Element>;
|
|
177
176
|
|
|
178
177
|
type Pagination$1 = {
|
|
179
178
|
totalCount: number;
|
|
@@ -187,7 +186,7 @@ type Pagination$1 = {
|
|
|
187
186
|
sizeChangerOptions?: number[];
|
|
188
187
|
};
|
|
189
188
|
|
|
190
|
-
declare function Pagination({ totalCount, count, currentPage, totalPages, pageSize, onPageChange, onPageSizeChange, showSizeChanger, sizeChangerOptions, }: Pagination$1):
|
|
189
|
+
declare function Pagination({ totalCount, count, currentPage, totalPages, pageSize, onPageChange, onPageSizeChange, showSizeChanger, sizeChangerOptions, }: Pagination$1): React$1.JSX.Element;
|
|
191
190
|
|
|
192
191
|
interface ToolbarItem {
|
|
193
192
|
id: string;
|
|
@@ -207,4 +206,4 @@ interface SlideToolbarProps {
|
|
|
207
206
|
|
|
208
207
|
declare const SlideToolbar: React.FC<SlideToolbarProps>;
|
|
209
208
|
|
|
210
|
-
export { type BreadcrumbProps, CustomBreadcrumb, Grid, type GridProps, Navbar, type NavbarData, type NavbarEntry, type NavbarProps, type NotificationDataTypes, Pagination, type Pagination$1 as PaginationProps, type RouteTree, type RouterAdapter, SlideToolbar, type SlideToolbarProps, _default as SortableHeaderCell, type ToolbarItem, type UserData };
|
|
209
|
+
export { type BreadcrumbProps, CustomBreadcrumb, _default$1 as Grid, type GridProps, Navbar, type NavbarData, type NavbarEntry, type NavbarProps, type NotificationDataTypes, Pagination, type Pagination$1 as PaginationProps, type RouteTree, type RouterAdapter, SlideToolbar, type SlideToolbarProps, _default as SortableHeaderCell, type ToolbarItem, type UserData };
|
package/dist/index.js
CHANGED
|
@@ -1947,7 +1947,7 @@ var CustomBreadcrumb = ({
|
|
|
1947
1947
|
var breadcrumb_default = CustomBreadcrumb;
|
|
1948
1948
|
|
|
1949
1949
|
// src/components/custom/grid/index.tsx
|
|
1950
|
-
var
|
|
1950
|
+
var import_react9 = __toESM(require("react"));
|
|
1951
1951
|
var import_react_grid = require("@svar-ui/react-grid");
|
|
1952
1952
|
|
|
1953
1953
|
// src/utils/exportPdf.ts
|
|
@@ -1981,7 +1981,7 @@ function exportExcel(rows, name) {
|
|
|
1981
1981
|
}
|
|
1982
1982
|
|
|
1983
1983
|
// src/components/custom/grid/gridHeader/index.tsx
|
|
1984
|
-
var import_react6 = require("react");
|
|
1984
|
+
var import_react6 = __toESM(require("react"));
|
|
1985
1985
|
var import_lucide_react14 = require("lucide-react");
|
|
1986
1986
|
|
|
1987
1987
|
// src/components/custom/grid/gridHeader/components/filters.tsx
|
|
@@ -2039,13 +2039,13 @@ var Filters = ({
|
|
|
2039
2039
|
}
|
|
2040
2040
|
]);
|
|
2041
2041
|
};
|
|
2042
|
-
const updateCondition = (
|
|
2042
|
+
const updateCondition = (id, next) => {
|
|
2043
2043
|
setConditions(
|
|
2044
|
-
(prev) => prev.map((c) => c.id ===
|
|
2044
|
+
(prev) => prev.map((c) => c.id === id ? __spreadValues(__spreadValues({}, c), next) : c)
|
|
2045
2045
|
);
|
|
2046
2046
|
};
|
|
2047
|
-
const deleteCondition = (
|
|
2048
|
-
const updatedConditions = conditions.filter((c) => c.id !==
|
|
2047
|
+
const deleteCondition = (id) => {
|
|
2048
|
+
const updatedConditions = conditions.filter((c) => c.id !== id);
|
|
2049
2049
|
setConditions(updatedConditions);
|
|
2050
2050
|
if (updatedConditions.length === 0) {
|
|
2051
2051
|
setFilterMenu(false);
|
|
@@ -2412,6 +2412,7 @@ function GridHeader({
|
|
|
2412
2412
|
onSelectionAction,
|
|
2413
2413
|
onClearSelection
|
|
2414
2414
|
}) {
|
|
2415
|
+
console.log("GridHeader rendered");
|
|
2415
2416
|
const [downloadMenu, setDownloadMenu] = (0, import_react6.useState)(false);
|
|
2416
2417
|
const [searchOpen, setSearchOpen] = (0, import_react6.useState)(false);
|
|
2417
2418
|
const downloadRef = (0, import_react6.useRef)(null);
|
|
@@ -2509,70 +2510,48 @@ function GridHeader({
|
|
|
2509
2510
|
value: searchValue
|
|
2510
2511
|
}
|
|
2511
2512
|
),
|
|
2512
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2513
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2514
|
+
"button",
|
|
2515
|
+
{
|
|
2516
|
+
onClick: () => setSearchOpen(false),
|
|
2517
|
+
className: "cursor-pointer",
|
|
2518
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_lucide_react14.X, { size: 16 })
|
|
2519
|
+
}
|
|
2520
|
+
)
|
|
2513
2521
|
] })
|
|
2514
2522
|
}
|
|
2515
2523
|
) })
|
|
2516
2524
|
] });
|
|
2517
2525
|
}
|
|
2518
|
-
var gridHeader_default = GridHeader;
|
|
2526
|
+
var gridHeader_default = import_react6.default.memo(GridHeader);
|
|
2519
2527
|
|
|
2520
2528
|
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2521
|
-
var
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
return {
|
|
2529
|
-
detect: () => true,
|
|
2530
|
-
addEvent: function(node, event, handler) {
|
|
2531
|
-
node.addEventListener(event, handler);
|
|
2532
|
-
return () => node.removeEventListener(event, handler);
|
|
2533
|
-
},
|
|
2534
|
-
addGlobalEvent: function(event, handler) {
|
|
2535
|
-
document.addEventListener(event, handler);
|
|
2536
|
-
return () => document.removeEventListener(event, handler);
|
|
2537
|
-
},
|
|
2538
|
-
getTopNode: function() {
|
|
2539
|
-
return window.document.body;
|
|
2529
|
+
var import_react7 = __toESM(require("react"));
|
|
2530
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2531
|
+
var CheckboxCell = ({ row, api, column }) => {
|
|
2532
|
+
const [isSelected, setIsSelected] = (0, import_react7.useState)(
|
|
2533
|
+
() => {
|
|
2534
|
+
var _a;
|
|
2535
|
+
return ((_a = api.getState().selectedRows) != null ? _a : []).includes(row.id);
|
|
2540
2536
|
}
|
|
2541
|
-
|
|
2542
|
-
}
|
|
2543
|
-
var env = getEnv();
|
|
2544
|
-
var id2 = (/* @__PURE__ */ new Date()).valueOf();
|
|
2545
|
-
|
|
2546
|
-
// node_modules/@svar-ui/lib-react/dist/index.js
|
|
2547
|
-
function useWritable(writable2, initialValue, name) {
|
|
2548
|
-
const [state, setState] = (0, import_react7.useState)(() => initialValue);
|
|
2549
|
-
if (!writable2) console.warn(`Writable ${name} is not defined`);
|
|
2537
|
+
);
|
|
2550
2538
|
(0, import_react7.useEffect)(() => {
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2539
|
+
const unsub = api.on("select-row", (ev) => {
|
|
2540
|
+
var _a;
|
|
2541
|
+
if ((ev == null ? void 0 : ev.id) === row.id) {
|
|
2542
|
+
setIsSelected(
|
|
2543
|
+
((_a = api.getState().selectedRows) != null ? _a : []).includes(row.id)
|
|
2544
|
+
);
|
|
2545
|
+
}
|
|
2554
2546
|
});
|
|
2555
|
-
return
|
|
2556
|
-
}, [
|
|
2557
|
-
return state;
|
|
2558
|
-
}
|
|
2559
|
-
function useStore(store, name) {
|
|
2560
|
-
const s = store.getState();
|
|
2561
|
-
const r = store.getReactiveState();
|
|
2562
|
-
return useWritable(r[name], s[name], name);
|
|
2563
|
-
}
|
|
2564
|
-
|
|
2565
|
-
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2566
|
-
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2567
|
-
var CheckboxCell = ({ row, api, column }) => {
|
|
2568
|
-
const selectedRows = useStore(api, "selectedRows");
|
|
2569
|
-
const isSelected = selectedRows.includes(row.id);
|
|
2547
|
+
return () => typeof unsub === "function" && unsub();
|
|
2548
|
+
}, [api, row.id]);
|
|
2570
2549
|
const handleChange = (e) => {
|
|
2571
2550
|
var _a, _b;
|
|
2572
2551
|
e.stopPropagation();
|
|
2573
|
-
const
|
|
2574
|
-
api.exec("select-row", { id: row.id, mode:
|
|
2575
|
-
(_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.onSelectionChange) == null ? void 0 : _b.call(_a, row.id, row,
|
|
2552
|
+
const checked = e.target.checked;
|
|
2553
|
+
api.exec("select-row", { id: row.id, mode: checked, toggle: true });
|
|
2554
|
+
(_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.onSelectionChange) == null ? void 0 : _b.call(_a, row.id, row, checked);
|
|
2576
2555
|
};
|
|
2577
2556
|
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2578
2557
|
"div",
|
|
@@ -2592,55 +2571,37 @@ var CheckboxCell = ({ row, api, column }) => {
|
|
|
2592
2571
|
}
|
|
2593
2572
|
);
|
|
2594
2573
|
};
|
|
2595
|
-
var checkBoxCell_default =
|
|
2574
|
+
var checkBoxCell_default = import_react7.default.memo(CheckboxCell);
|
|
2596
2575
|
|
|
2597
2576
|
// src/components/custom/grid/checkboxCell/headerCheckBox.tsx
|
|
2598
|
-
var
|
|
2577
|
+
var import_react8 = __toESM(require("react"));
|
|
2599
2578
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2600
2579
|
var HeaderCheckbox = ({ api, column }) => {
|
|
2601
|
-
var _a;
|
|
2602
|
-
const checkboxRef = (0,
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2605
|
-
const
|
|
2606
|
-
|
|
2607
|
-
const selectedOnPage = pageData.filter(
|
|
2608
|
-
(r) => selectedRows.includes(r.id)
|
|
2609
|
-
).length;
|
|
2610
|
-
return {
|
|
2611
|
-
allSelected: pageData.length > 0 && selectedOnPage === pageData.length,
|
|
2612
|
-
someSelected: selectedOnPage > 0 && selectedOnPage < pageData.length
|
|
2613
|
-
};
|
|
2614
|
-
};
|
|
2615
|
-
const [, forceUpdate] = (0, import_react9.useReducer)((x) => x + 1, 0);
|
|
2616
|
-
(0, import_react9.useEffect)(() => {
|
|
2617
|
-
const unsub = api.on("select-row", () => {
|
|
2618
|
-
forceUpdate();
|
|
2619
|
-
});
|
|
2620
|
-
return () => {
|
|
2621
|
-
if (typeof unsub === "function") unsub();
|
|
2622
|
-
};
|
|
2580
|
+
var _a, _b, _c;
|
|
2581
|
+
const checkboxRef = (0, import_react8.useRef)(null);
|
|
2582
|
+
const [, forceUpdate] = (0, import_react8.useReducer)((x) => x + 1, 0);
|
|
2583
|
+
(0, import_react8.useEffect)(() => {
|
|
2584
|
+
const unsub = api.on("select-row", () => forceUpdate());
|
|
2585
|
+
return () => typeof unsub === "function" && unsub();
|
|
2623
2586
|
}, [api]);
|
|
2624
|
-
(0
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
const
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
}, [state.someSelected]);
|
|
2587
|
+
const pageData = (_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.getPageData()) != null ? _b : [];
|
|
2588
|
+
const selectedRows = (_c = api.getState().selectedRows) != null ? _c : [];
|
|
2589
|
+
const selectedOnPage = pageData.filter(
|
|
2590
|
+
(r) => selectedRows.includes(r.id)
|
|
2591
|
+
).length;
|
|
2592
|
+
const allSelected = pageData.length > 0 && selectedOnPage === pageData.length;
|
|
2593
|
+
const someSelected = selectedOnPage > 0 && selectedOnPage < pageData.length;
|
|
2594
|
+
(0, import_react8.useEffect)(() => {
|
|
2595
|
+
if (checkboxRef.current) checkboxRef.current.indeterminate = someSelected;
|
|
2596
|
+
}, [someSelected]);
|
|
2635
2597
|
const handleChange = (e) => {
|
|
2636
|
-
var _a2,
|
|
2598
|
+
var _a2, _b2;
|
|
2637
2599
|
e.stopPropagation();
|
|
2638
|
-
const
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
(_d = (_c = column == null ? void 0 : column.config) == null ? void 0 : _c.onSelectAllPage) == null ? void 0 : _d.call(_c, pageData, isChecked);
|
|
2600
|
+
const checked = e.target.checked;
|
|
2601
|
+
pageData.forEach(
|
|
2602
|
+
(row) => api.exec("select-row", { id: row.id, mode: checked, toggle: true })
|
|
2603
|
+
);
|
|
2604
|
+
(_b2 = (_a2 = column == null ? void 0 : column.config) == null ? void 0 : _a2.onSelectAllPage) == null ? void 0 : _b2.call(_a2, pageData, checked);
|
|
2644
2605
|
};
|
|
2645
2606
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2646
2607
|
"div",
|
|
@@ -2653,7 +2614,7 @@ var HeaderCheckbox = ({ api, column }) => {
|
|
|
2653
2614
|
{
|
|
2654
2615
|
ref: checkboxRef,
|
|
2655
2616
|
type: "checkbox",
|
|
2656
|
-
checked:
|
|
2617
|
+
checked: allSelected,
|
|
2657
2618
|
onChange: handleChange,
|
|
2658
2619
|
className: "w-4 h-4 rounded border border-border bg-background accent-primary cursor-pointer focus:outline-none focus:ring-1 focus:ring-primary"
|
|
2659
2620
|
}
|
|
@@ -2661,27 +2622,21 @@ var HeaderCheckbox = ({ api, column }) => {
|
|
|
2661
2622
|
}
|
|
2662
2623
|
);
|
|
2663
2624
|
};
|
|
2664
|
-
var headerCheckBox_default =
|
|
2625
|
+
var headerCheckBox_default = import_react8.default.memo(HeaderCheckbox);
|
|
2665
2626
|
|
|
2666
2627
|
// src/components/custom/grid/utils/buildCheckboxColumn.tsx
|
|
2667
2628
|
function buildCheckboxColumn({
|
|
2668
2629
|
getPageData,
|
|
2669
2630
|
onSelectionChange,
|
|
2670
|
-
onSelectAllPage
|
|
2671
|
-
clearToken
|
|
2631
|
+
onSelectAllPage
|
|
2672
2632
|
}) {
|
|
2673
|
-
const
|
|
2674
|
-
getPageData,
|
|
2675
|
-
onSelectionChange,
|
|
2676
|
-
onSelectAllPage,
|
|
2677
|
-
clearToken
|
|
2678
|
-
};
|
|
2633
|
+
const config = { getPageData, onSelectionChange, onSelectAllPage };
|
|
2679
2634
|
return {
|
|
2680
2635
|
id: "__selection__",
|
|
2681
2636
|
width: 58,
|
|
2682
2637
|
sortable: false,
|
|
2683
2638
|
resize: false,
|
|
2684
|
-
config
|
|
2639
|
+
config,
|
|
2685
2640
|
header: { cell: headerCheckBox_default },
|
|
2686
2641
|
cell: checkBoxCell_default
|
|
2687
2642
|
};
|
|
@@ -2689,7 +2644,7 @@ function buildCheckboxColumn({
|
|
|
2689
2644
|
|
|
2690
2645
|
// src/components/custom/grid/index.tsx
|
|
2691
2646
|
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2692
|
-
var Grid = (0,
|
|
2647
|
+
var Grid = (0, import_react9.forwardRef)(
|
|
2693
2648
|
(_a, ref) => {
|
|
2694
2649
|
var _b = _a, {
|
|
2695
2650
|
data,
|
|
@@ -2707,11 +2662,9 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2707
2662
|
children,
|
|
2708
2663
|
onFocusCell = () => false,
|
|
2709
2664
|
selectionEnabled = false,
|
|
2710
|
-
|
|
2665
|
+
getSelectedIds,
|
|
2711
2666
|
onRowSelectionChange,
|
|
2712
2667
|
onSelectAllPage,
|
|
2713
|
-
selectedCount,
|
|
2714
|
-
selectedData,
|
|
2715
2668
|
selectionActions,
|
|
2716
2669
|
onSelectionAction,
|
|
2717
2670
|
onClearSelection
|
|
@@ -2731,138 +2684,139 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2731
2684
|
"children",
|
|
2732
2685
|
"onFocusCell",
|
|
2733
2686
|
"selectionEnabled",
|
|
2734
|
-
"
|
|
2687
|
+
"getSelectedIds",
|
|
2735
2688
|
"onRowSelectionChange",
|
|
2736
2689
|
"onSelectAllPage",
|
|
2737
|
-
"selectedCount",
|
|
2738
|
-
"selectedData",
|
|
2739
2690
|
"selectionActions",
|
|
2740
2691
|
"onSelectionAction",
|
|
2741
2692
|
"onClearSelection"
|
|
2742
2693
|
]);
|
|
2743
|
-
|
|
2744
|
-
const
|
|
2745
|
-
const
|
|
2746
|
-
const dataRef = (0,
|
|
2747
|
-
(0,
|
|
2694
|
+
const apiRef = (0, import_react9.useRef)(null);
|
|
2695
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
2696
|
+
const [internalSelectedCount, setInternalSelectedCount] = (0, import_react9.useState)(0);
|
|
2697
|
+
const dataRef = (0, import_react9.useRef)(data);
|
|
2698
|
+
(0, import_react9.useEffect)(() => {
|
|
2748
2699
|
dataRef.current = data;
|
|
2749
2700
|
}, [data]);
|
|
2750
|
-
const onRowSelectionChangeRef = (0,
|
|
2751
|
-
(0,
|
|
2701
|
+
const onRowSelectionChangeRef = (0, import_react9.useRef)(onRowSelectionChange);
|
|
2702
|
+
(0, import_react9.useEffect)(() => {
|
|
2752
2703
|
onRowSelectionChangeRef.current = onRowSelectionChange;
|
|
2753
2704
|
}, [onRowSelectionChange]);
|
|
2754
|
-
const onSelectAllPageRef = (0,
|
|
2755
|
-
(0,
|
|
2705
|
+
const onSelectAllPageRef = (0, import_react9.useRef)(onSelectAllPage);
|
|
2706
|
+
(0, import_react9.useEffect)(() => {
|
|
2756
2707
|
onSelectAllPageRef.current = onSelectAllPage;
|
|
2757
2708
|
}, [onSelectAllPage]);
|
|
2758
|
-
(0,
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
if (!selectionEnabled) return columns;
|
|
2709
|
+
(0, import_react9.useImperativeHandle)(ref, () => apiRef.current, []);
|
|
2710
|
+
const getSelectedData = (0, import_react9.useCallback)(() => {
|
|
2711
|
+
var _a2, _b2, _c;
|
|
2712
|
+
const ids = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
|
|
2713
|
+
return ((_c = dataRef.current) != null ? _c : []).filter((row) => ids.includes(row.id));
|
|
2714
|
+
}, []);
|
|
2715
|
+
const resolvedColumns = (0, import_react9.useMemo)(() => {
|
|
2716
|
+
if (!selectionEnabled || columns.length === 0) return columns;
|
|
2767
2717
|
const checkboxCol = buildCheckboxColumn({
|
|
2768
2718
|
getPageData: () => {
|
|
2769
|
-
var
|
|
2770
|
-
return (
|
|
2719
|
+
var _a2;
|
|
2720
|
+
return (_a2 = dataRef.current) != null ? _a2 : [];
|
|
2771
2721
|
},
|
|
2772
|
-
onSelectionChange: (
|
|
2773
|
-
var
|
|
2774
|
-
(
|
|
2722
|
+
onSelectionChange: (id, rowData, checked) => {
|
|
2723
|
+
var _a2;
|
|
2724
|
+
(_a2 = onRowSelectionChangeRef.current) == null ? void 0 : _a2.call(onRowSelectionChangeRef, id, rowData, checked);
|
|
2775
2725
|
},
|
|
2776
2726
|
onSelectAllPage: (pageData, checked) => {
|
|
2777
|
-
var
|
|
2778
|
-
(
|
|
2779
|
-
}
|
|
2780
|
-
clearToken: clearTokenRef.current
|
|
2727
|
+
var _a2;
|
|
2728
|
+
(_a2 = onSelectAllPageRef.current) == null ? void 0 : _a2.call(onSelectAllPageRef, pageData, checked);
|
|
2729
|
+
}
|
|
2781
2730
|
});
|
|
2782
2731
|
return [checkboxCol, ...columns];
|
|
2783
|
-
}, [selectionEnabled, columns
|
|
2784
|
-
const resizeColumns = (0,
|
|
2732
|
+
}, [selectionEnabled, columns]);
|
|
2733
|
+
const resizeColumns = (0, import_react9.useCallback)(() => {
|
|
2785
2734
|
const api = apiRef.current;
|
|
2786
2735
|
const container = containerRef.current;
|
|
2787
2736
|
if (!api || !container) return;
|
|
2788
2737
|
const gridWidth = container.clientWidth;
|
|
2789
|
-
const
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2792
|
-
)
|
|
2793
|
-
|
|
2794
|
-
(col)
|
|
2795
|
-
|
|
2796
|
-
const totalFixedWidth = fixedColumns.reduce((sum, col) => {
|
|
2797
|
-
var _a3, _b2;
|
|
2798
|
-
const column = api.getColumn(col.id);
|
|
2799
|
-
const width = (_b2 = (_a3 = column == null ? void 0 : column.width) != null ? _a3 : col.width) != null ? _b2 : 0;
|
|
2800
|
-
return sum + (isNaN(width) ? 0 : width);
|
|
2738
|
+
const isFixed = (col) => col.id === "__selection__";
|
|
2739
|
+
const resizable = resolvedColumns.filter((col) => !isFixed(col));
|
|
2740
|
+
const fixed = resolvedColumns.filter((col) => isFixed(col));
|
|
2741
|
+
const fixedTotal = fixed.reduce((sum, col) => {
|
|
2742
|
+
var _a2, _b2, _c;
|
|
2743
|
+
const w = (_c = (_b2 = (_a2 = api.getColumn(col.id)) == null ? void 0 : _a2.width) != null ? _b2 : col.width) != null ? _c : 0;
|
|
2744
|
+
return sum + (isNaN(w) ? 0 : w);
|
|
2801
2745
|
}, 0);
|
|
2802
|
-
const
|
|
2746
|
+
const available = Math.max(gridWidth - fixedTotal, 0);
|
|
2803
2747
|
if (data && data.length > 0) {
|
|
2804
|
-
|
|
2805
|
-
api.exec("resize-column", { id: col.id, auto: "data" })
|
|
2806
|
-
|
|
2807
|
-
const
|
|
2808
|
-
var
|
|
2809
|
-
const
|
|
2810
|
-
|
|
2811
|
-
return sum + (isNaN(width) ? 0 : width);
|
|
2748
|
+
resizable.forEach(
|
|
2749
|
+
(col) => api.exec("resize-column", { id: col.id, auto: "data" })
|
|
2750
|
+
);
|
|
2751
|
+
const autoTotal = resizable.reduce((sum, col) => {
|
|
2752
|
+
var _a2, _b2;
|
|
2753
|
+
const w = (_b2 = (_a2 = api.getColumn(col.id)) == null ? void 0 : _a2.width) != null ? _b2 : 0;
|
|
2754
|
+
return sum + (isNaN(w) ? 0 : w);
|
|
2812
2755
|
}, 0);
|
|
2813
|
-
if (
|
|
2814
|
-
const extra = (
|
|
2815
|
-
|
|
2816
|
-
var
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
api.exec("resize-column", {
|
|
2821
|
-
id: col.id,
|
|
2822
|
-
width: currentWidth + extra
|
|
2823
|
-
});
|
|
2824
|
-
}
|
|
2756
|
+
if (autoTotal < available && resizable.length > 0) {
|
|
2757
|
+
const extra = (available - autoTotal) / resizable.length;
|
|
2758
|
+
resizable.forEach((col) => {
|
|
2759
|
+
var _a2, _b2;
|
|
2760
|
+
const w = (_b2 = (_a2 = api.getColumn(col.id)) == null ? void 0 : _a2.width) != null ? _b2 : 0;
|
|
2761
|
+
if (!isNaN(w))
|
|
2762
|
+
api.exec("resize-column", { id: col.id, width: w + extra });
|
|
2825
2763
|
});
|
|
2826
2764
|
}
|
|
2827
2765
|
} else {
|
|
2828
|
-
const
|
|
2829
|
-
|
|
2830
|
-
api.exec("resize-column", {
|
|
2831
|
-
|
|
2832
|
-
width: equalWidth
|
|
2833
|
-
});
|
|
2834
|
-
});
|
|
2766
|
+
const eq = resizable.length > 0 ? available / resizable.length : 0;
|
|
2767
|
+
resizable.forEach(
|
|
2768
|
+
(col) => api.exec("resize-column", { id: col.id, width: eq })
|
|
2769
|
+
);
|
|
2835
2770
|
}
|
|
2836
2771
|
}, [resolvedColumns, data]);
|
|
2837
|
-
(0,
|
|
2838
|
-
if (!containerRef.current) return;
|
|
2839
|
-
const observer = new ResizeObserver(() => resizeColumns());
|
|
2840
|
-
observer.observe(containerRef.current);
|
|
2841
|
-
return () => observer.disconnect();
|
|
2842
|
-
}, [resizeColumns]);
|
|
2843
|
-
const init = (0, import_react10.useCallback)(
|
|
2772
|
+
const init = (0, import_react9.useCallback)(
|
|
2844
2773
|
(api) => {
|
|
2845
2774
|
apiRef.current = api;
|
|
2846
2775
|
resizeColumns();
|
|
2847
2776
|
api.intercept("focus-cell", onFocusCell);
|
|
2777
|
+
if (selectionEnabled) {
|
|
2778
|
+
api.on("select-row", () => {
|
|
2779
|
+
var _a2;
|
|
2780
|
+
setInternalSelectedCount(
|
|
2781
|
+
((_a2 = api.getState().selectedRows) != null ? _a2 : []).length
|
|
2782
|
+
);
|
|
2783
|
+
});
|
|
2784
|
+
}
|
|
2848
2785
|
},
|
|
2849
|
-
[resizeColumns, onFocusCell]
|
|
2786
|
+
[resizeColumns, onFocusCell, selectionEnabled]
|
|
2850
2787
|
);
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
const
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2788
|
+
(0, import_react9.useEffect)(() => {
|
|
2789
|
+
if (!containerRef.current) return;
|
|
2790
|
+
const observer = new ResizeObserver(() => resizeColumns());
|
|
2791
|
+
observer.observe(containerRef.current);
|
|
2792
|
+
return () => observer.disconnect();
|
|
2793
|
+
}, [resizeColumns]);
|
|
2794
|
+
(0, import_react9.useEffect)(() => {
|
|
2795
|
+
if (!selectionEnabled || !getSelectedIds || !apiRef.current) return;
|
|
2796
|
+
const pageIds = new Set((data != null ? data : []).map((r) => r.id));
|
|
2797
|
+
const toRestore = getSelectedIds().filter((id) => pageIds.has(id));
|
|
2798
|
+
toRestore.forEach(
|
|
2799
|
+
(id) => apiRef.current.exec("select-row", { id, mode: true })
|
|
2800
|
+
);
|
|
2801
|
+
}, [data, selectionEnabled, getSelectedIds]);
|
|
2802
|
+
const handleClearSelection = (0, import_react9.useCallback)(() => {
|
|
2803
|
+
var _a2;
|
|
2804
|
+
const api = apiRef.current;
|
|
2805
|
+
if (!api) return;
|
|
2806
|
+
const ids = [...(_a2 = api.getState().selectedRows) != null ? _a2 : []];
|
|
2807
|
+
ids.forEach((id) => api.exec("select-row", { id, mode: false }));
|
|
2808
|
+
onClearSelection == null ? void 0 : onClearSelection();
|
|
2809
|
+
}, [onClearSelection]);
|
|
2810
|
+
const handleExportPdf = (0, import_react9.useCallback)(() => {
|
|
2857
2811
|
const selected = getSelectedData();
|
|
2858
2812
|
if (selected.length) exportPdf(selected, fileName);
|
|
2859
2813
|
else onExportPdf == null ? void 0 : onExportPdf();
|
|
2860
|
-
}, [
|
|
2861
|
-
const handleExportExcel = (0,
|
|
2814
|
+
}, [getSelectedData, fileName, onExportPdf]);
|
|
2815
|
+
const handleExportExcel = (0, import_react9.useCallback)(() => {
|
|
2862
2816
|
const selected = getSelectedData();
|
|
2863
2817
|
if (selected.length) exportExcel(selected, fileName);
|
|
2864
2818
|
else onExportExcel == null ? void 0 : onExportExcel();
|
|
2865
|
-
}, [
|
|
2819
|
+
}, [getSelectedData, fileName, onExportExcel]);
|
|
2866
2820
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
2867
2821
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
2868
2822
|
gridHeader_default,
|
|
@@ -2877,11 +2831,11 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2877
2831
|
filterList: rest.filterList,
|
|
2878
2832
|
onFilterChange,
|
|
2879
2833
|
initialFilters,
|
|
2880
|
-
selectedCount,
|
|
2881
|
-
selectedData,
|
|
2834
|
+
selectedCount: internalSelectedCount,
|
|
2835
|
+
selectedData: getSelectedData(),
|
|
2882
2836
|
selectionActions,
|
|
2883
2837
|
onSelectionAction,
|
|
2884
|
-
onClearSelection,
|
|
2838
|
+
onClearSelection: handleClearSelection,
|
|
2885
2839
|
children
|
|
2886
2840
|
}
|
|
2887
2841
|
),
|
|
@@ -2896,7 +2850,6 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2896
2850
|
data,
|
|
2897
2851
|
columns: resolvedColumns,
|
|
2898
2852
|
init,
|
|
2899
|
-
selectedRows: selectionEnabled ? selectedIds : void 0,
|
|
2900
2853
|
select: selectionEnabled ? false : rest.select
|
|
2901
2854
|
})
|
|
2902
2855
|
) }) })
|
|
@@ -2905,11 +2858,11 @@ var Grid = (0, import_react10.forwardRef)(
|
|
|
2905
2858
|
] });
|
|
2906
2859
|
}
|
|
2907
2860
|
);
|
|
2908
|
-
var grid_default = Grid;
|
|
2861
|
+
var grid_default = import_react9.default.memo(Grid);
|
|
2909
2862
|
|
|
2910
2863
|
// src/components/custom/grid/sortableHeaderCell.tsx
|
|
2911
2864
|
var import_lucide_react15 = require("lucide-react");
|
|
2912
|
-
var
|
|
2865
|
+
var import_react10 = __toESM(require("react"));
|
|
2913
2866
|
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2914
2867
|
var SortableHeaderCell = ({ cell, sortKey, sortOrder, onSortChange }) => {
|
|
2915
2868
|
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { children: cell == null ? void 0 : cell.text });
|
|
@@ -2939,7 +2892,7 @@ var SortableHeaderCell = ({ cell, sortKey, sortOrder, onSortChange }) => {
|
|
|
2939
2892
|
}
|
|
2940
2893
|
);
|
|
2941
2894
|
};
|
|
2942
|
-
var sortableHeaderCell_default =
|
|
2895
|
+
var sortableHeaderCell_default = import_react10.default.memo(SortableHeaderCell, (prev, next) => {
|
|
2943
2896
|
var _a, _b, _c, _d;
|
|
2944
2897
|
if (((_a = prev.cell) == null ? void 0 : _a.id) !== ((_b = next.cell) == null ? void 0 : _b.id)) return false;
|
|
2945
2898
|
if (((_c = prev.cell) == null ? void 0 : _c.text) !== ((_d = next.cell) == null ? void 0 : _d.text)) return false;
|
|
@@ -3066,7 +3019,7 @@ var pagination_default = Pagination;
|
|
|
3066
3019
|
|
|
3067
3020
|
// src/components/custom/toolbar/index.tsx
|
|
3068
3021
|
var import_lucide_react17 = require("lucide-react");
|
|
3069
|
-
var
|
|
3022
|
+
var import_react11 = require("react");
|
|
3070
3023
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
3071
3024
|
var SlideToolbar = ({
|
|
3072
3025
|
items,
|
|
@@ -3079,9 +3032,9 @@ var SlideToolbar = ({
|
|
|
3079
3032
|
className = ""
|
|
3080
3033
|
}) => {
|
|
3081
3034
|
const resolvedItems = items != null ? items : children ? void 0 : [];
|
|
3082
|
-
const [open, setOpen] = (0,
|
|
3083
|
-
const panelRef = (0,
|
|
3084
|
-
(0,
|
|
3035
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
3036
|
+
const panelRef = (0, import_react11.useRef)(null);
|
|
3037
|
+
(0, import_react11.useEffect)(() => {
|
|
3085
3038
|
if (!open || !closeOnBackdrop) return;
|
|
3086
3039
|
const handlePointerDown = (e) => {
|
|
3087
3040
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
package/dist/index.mjs
CHANGED
|
@@ -1909,13 +1909,14 @@ var CustomBreadcrumb = ({
|
|
|
1909
1909
|
var breadcrumb_default = CustomBreadcrumb;
|
|
1910
1910
|
|
|
1911
1911
|
// src/components/custom/grid/index.tsx
|
|
1912
|
-
import {
|
|
1912
|
+
import React6, {
|
|
1913
1913
|
useCallback as useCallback2,
|
|
1914
|
-
useRef as
|
|
1914
|
+
useRef as useRef4,
|
|
1915
1915
|
useImperativeHandle,
|
|
1916
1916
|
forwardRef,
|
|
1917
1917
|
useEffect as useEffect9,
|
|
1918
|
-
useMemo as useMemo4
|
|
1918
|
+
useMemo as useMemo4,
|
|
1919
|
+
useState as useState9
|
|
1919
1920
|
} from "react";
|
|
1920
1921
|
import { Grid as SvarGrid, WillowDark } from "@svar-ui/react-grid";
|
|
1921
1922
|
|
|
@@ -1950,7 +1951,7 @@ function exportExcel(rows, name) {
|
|
|
1950
1951
|
}
|
|
1951
1952
|
|
|
1952
1953
|
// src/components/custom/grid/gridHeader/index.tsx
|
|
1953
|
-
import { useEffect as useEffect6, useRef as useRef2, useState as useState7 } from "react";
|
|
1954
|
+
import React3, { useEffect as useEffect6, useRef as useRef2, useState as useState7 } from "react";
|
|
1954
1955
|
import { FileText, FileSpreadsheet, Search, Ellipsis, X as X4 } from "lucide-react";
|
|
1955
1956
|
|
|
1956
1957
|
// src/components/custom/grid/gridHeader/components/filters.tsx
|
|
@@ -2008,13 +2009,13 @@ var Filters = ({
|
|
|
2008
2009
|
}
|
|
2009
2010
|
]);
|
|
2010
2011
|
};
|
|
2011
|
-
const updateCondition = (
|
|
2012
|
+
const updateCondition = (id, next) => {
|
|
2012
2013
|
setConditions(
|
|
2013
|
-
(prev) => prev.map((c) => c.id ===
|
|
2014
|
+
(prev) => prev.map((c) => c.id === id ? __spreadValues(__spreadValues({}, c), next) : c)
|
|
2014
2015
|
);
|
|
2015
2016
|
};
|
|
2016
|
-
const deleteCondition = (
|
|
2017
|
-
const updatedConditions = conditions.filter((c) => c.id !==
|
|
2017
|
+
const deleteCondition = (id) => {
|
|
2018
|
+
const updatedConditions = conditions.filter((c) => c.id !== id);
|
|
2018
2019
|
setConditions(updatedConditions);
|
|
2019
2020
|
if (updatedConditions.length === 0) {
|
|
2020
2021
|
setFilterMenu(false);
|
|
@@ -2381,6 +2382,7 @@ function GridHeader({
|
|
|
2381
2382
|
onSelectionAction,
|
|
2382
2383
|
onClearSelection
|
|
2383
2384
|
}) {
|
|
2385
|
+
console.log("GridHeader rendered");
|
|
2384
2386
|
const [downloadMenu, setDownloadMenu] = useState7(false);
|
|
2385
2387
|
const [searchOpen, setSearchOpen] = useState7(false);
|
|
2386
2388
|
const downloadRef = useRef2(null);
|
|
@@ -2478,70 +2480,48 @@ function GridHeader({
|
|
|
2478
2480
|
value: searchValue
|
|
2479
2481
|
}
|
|
2480
2482
|
),
|
|
2481
|
-
/* @__PURE__ */ jsx25(
|
|
2483
|
+
/* @__PURE__ */ jsx25(
|
|
2484
|
+
"button",
|
|
2485
|
+
{
|
|
2486
|
+
onClick: () => setSearchOpen(false),
|
|
2487
|
+
className: "cursor-pointer",
|
|
2488
|
+
children: /* @__PURE__ */ jsx25(X4, { size: 16 })
|
|
2489
|
+
}
|
|
2490
|
+
)
|
|
2482
2491
|
] })
|
|
2483
2492
|
}
|
|
2484
2493
|
) })
|
|
2485
2494
|
] });
|
|
2486
2495
|
}
|
|
2487
|
-
var gridHeader_default = GridHeader;
|
|
2496
|
+
var gridHeader_default = React3.memo(GridHeader);
|
|
2488
2497
|
|
|
2489
2498
|
// src/components/custom/grid/checkboxCell/checkBoxCell.tsx
|
|
2490
|
-
import
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
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;
|
|
2499
|
+
import React4, { useState as useState8, useEffect as useEffect7 } from "react";
|
|
2500
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
2501
|
+
var CheckboxCell = ({ row, api, column }) => {
|
|
2502
|
+
const [isSelected, setIsSelected] = useState8(
|
|
2503
|
+
() => {
|
|
2504
|
+
var _a;
|
|
2505
|
+
return ((_a = api.getState().selectedRows) != null ? _a : []).includes(row.id);
|
|
2509
2506
|
}
|
|
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`);
|
|
2507
|
+
);
|
|
2519
2508
|
useEffect7(() => {
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2509
|
+
const unsub = api.on("select-row", (ev) => {
|
|
2510
|
+
var _a;
|
|
2511
|
+
if ((ev == null ? void 0 : ev.id) === row.id) {
|
|
2512
|
+
setIsSelected(
|
|
2513
|
+
((_a = api.getState().selectedRows) != null ? _a : []).includes(row.id)
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2523
2516
|
});
|
|
2524
|
-
return
|
|
2525
|
-
}, [
|
|
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);
|
|
2517
|
+
return () => typeof unsub === "function" && unsub();
|
|
2518
|
+
}, [api, row.id]);
|
|
2539
2519
|
const handleChange = (e) => {
|
|
2540
2520
|
var _a, _b;
|
|
2541
2521
|
e.stopPropagation();
|
|
2542
|
-
const
|
|
2543
|
-
api.exec("select-row", { id: row.id, mode:
|
|
2544
|
-
(_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.onSelectionChange) == null ? void 0 : _b.call(_a, row.id, row,
|
|
2522
|
+
const checked = e.target.checked;
|
|
2523
|
+
api.exec("select-row", { id: row.id, mode: checked, toggle: true });
|
|
2524
|
+
(_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.onSelectionChange) == null ? void 0 : _b.call(_a, row.id, row, checked);
|
|
2545
2525
|
};
|
|
2546
2526
|
return /* @__PURE__ */ jsx26(
|
|
2547
2527
|
"div",
|
|
@@ -2561,55 +2541,37 @@ var CheckboxCell = ({ row, api, column }) => {
|
|
|
2561
2541
|
}
|
|
2562
2542
|
);
|
|
2563
2543
|
};
|
|
2564
|
-
var checkBoxCell_default =
|
|
2544
|
+
var checkBoxCell_default = React4.memo(CheckboxCell);
|
|
2565
2545
|
|
|
2566
2546
|
// src/components/custom/grid/checkboxCell/headerCheckBox.tsx
|
|
2567
|
-
import
|
|
2547
|
+
import React5, { useEffect as useEffect8, useRef as useRef3, useReducer } from "react";
|
|
2568
2548
|
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
2569
2549
|
var HeaderCheckbox = ({ api, column }) => {
|
|
2570
|
-
var _a;
|
|
2571
|
-
const checkboxRef =
|
|
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
|
-
};
|
|
2550
|
+
var _a, _b, _c;
|
|
2551
|
+
const checkboxRef = useRef3(null);
|
|
2584
2552
|
const [, forceUpdate] = useReducer((x) => x + 1, 0);
|
|
2585
2553
|
useEffect8(() => {
|
|
2586
|
-
const unsub = api.on("select-row", () =>
|
|
2587
|
-
|
|
2588
|
-
});
|
|
2589
|
-
return () => {
|
|
2590
|
-
if (typeof unsub === "function") unsub();
|
|
2591
|
-
};
|
|
2554
|
+
const unsub = api.on("select-row", () => forceUpdate());
|
|
2555
|
+
return () => typeof unsub === "function" && unsub();
|
|
2592
2556
|
}, [api]);
|
|
2557
|
+
const pageData = (_b = (_a = column == null ? void 0 : column.config) == null ? void 0 : _a.getPageData()) != null ? _b : [];
|
|
2558
|
+
const selectedRows = (_c = api.getState().selectedRows) != null ? _c : [];
|
|
2559
|
+
const selectedOnPage = pageData.filter(
|
|
2560
|
+
(r) => selectedRows.includes(r.id)
|
|
2561
|
+
).length;
|
|
2562
|
+
const allSelected = pageData.length > 0 && selectedOnPage === pageData.length;
|
|
2563
|
+
const someSelected = selectedOnPage > 0 && selectedOnPage < pageData.length;
|
|
2593
2564
|
useEffect8(() => {
|
|
2594
|
-
|
|
2595
|
-
|
|
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]);
|
|
2565
|
+
if (checkboxRef.current) checkboxRef.current.indeterminate = someSelected;
|
|
2566
|
+
}, [someSelected]);
|
|
2604
2567
|
const handleChange = (e) => {
|
|
2605
|
-
var _a2,
|
|
2568
|
+
var _a2, _b2;
|
|
2606
2569
|
e.stopPropagation();
|
|
2607
|
-
const
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
(_d = (_c = column == null ? void 0 : column.config) == null ? void 0 : _c.onSelectAllPage) == null ? void 0 : _d.call(_c, pageData, isChecked);
|
|
2570
|
+
const checked = e.target.checked;
|
|
2571
|
+
pageData.forEach(
|
|
2572
|
+
(row) => api.exec("select-row", { id: row.id, mode: checked, toggle: true })
|
|
2573
|
+
);
|
|
2574
|
+
(_b2 = (_a2 = column == null ? void 0 : column.config) == null ? void 0 : _a2.onSelectAllPage) == null ? void 0 : _b2.call(_a2, pageData, checked);
|
|
2613
2575
|
};
|
|
2614
2576
|
return /* @__PURE__ */ jsx27(
|
|
2615
2577
|
"div",
|
|
@@ -2622,7 +2584,7 @@ var HeaderCheckbox = ({ api, column }) => {
|
|
|
2622
2584
|
{
|
|
2623
2585
|
ref: checkboxRef,
|
|
2624
2586
|
type: "checkbox",
|
|
2625
|
-
checked:
|
|
2587
|
+
checked: allSelected,
|
|
2626
2588
|
onChange: handleChange,
|
|
2627
2589
|
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
2590
|
}
|
|
@@ -2630,27 +2592,21 @@ var HeaderCheckbox = ({ api, column }) => {
|
|
|
2630
2592
|
}
|
|
2631
2593
|
);
|
|
2632
2594
|
};
|
|
2633
|
-
var headerCheckBox_default =
|
|
2595
|
+
var headerCheckBox_default = React5.memo(HeaderCheckbox);
|
|
2634
2596
|
|
|
2635
2597
|
// src/components/custom/grid/utils/buildCheckboxColumn.tsx
|
|
2636
2598
|
function buildCheckboxColumn({
|
|
2637
2599
|
getPageData,
|
|
2638
2600
|
onSelectionChange,
|
|
2639
|
-
onSelectAllPage
|
|
2640
|
-
clearToken
|
|
2601
|
+
onSelectAllPage
|
|
2641
2602
|
}) {
|
|
2642
|
-
const
|
|
2643
|
-
getPageData,
|
|
2644
|
-
onSelectionChange,
|
|
2645
|
-
onSelectAllPage,
|
|
2646
|
-
clearToken
|
|
2647
|
-
};
|
|
2603
|
+
const config = { getPageData, onSelectionChange, onSelectAllPage };
|
|
2648
2604
|
return {
|
|
2649
2605
|
id: "__selection__",
|
|
2650
2606
|
width: 58,
|
|
2651
2607
|
sortable: false,
|
|
2652
2608
|
resize: false,
|
|
2653
|
-
config
|
|
2609
|
+
config,
|
|
2654
2610
|
header: { cell: headerCheckBox_default },
|
|
2655
2611
|
cell: checkBoxCell_default
|
|
2656
2612
|
};
|
|
@@ -2676,11 +2632,9 @@ var Grid = forwardRef(
|
|
|
2676
2632
|
children,
|
|
2677
2633
|
onFocusCell = () => false,
|
|
2678
2634
|
selectionEnabled = false,
|
|
2679
|
-
|
|
2635
|
+
getSelectedIds,
|
|
2680
2636
|
onRowSelectionChange,
|
|
2681
2637
|
onSelectAllPage,
|
|
2682
|
-
selectedCount,
|
|
2683
|
-
selectedData,
|
|
2684
2638
|
selectionActions,
|
|
2685
2639
|
onSelectionAction,
|
|
2686
2640
|
onClearSelection
|
|
@@ -2700,138 +2654,139 @@ var Grid = forwardRef(
|
|
|
2700
2654
|
"children",
|
|
2701
2655
|
"onFocusCell",
|
|
2702
2656
|
"selectionEnabled",
|
|
2703
|
-
"
|
|
2657
|
+
"getSelectedIds",
|
|
2704
2658
|
"onRowSelectionChange",
|
|
2705
2659
|
"onSelectAllPage",
|
|
2706
|
-
"selectedCount",
|
|
2707
|
-
"selectedData",
|
|
2708
2660
|
"selectionActions",
|
|
2709
2661
|
"onSelectionAction",
|
|
2710
2662
|
"onClearSelection"
|
|
2711
2663
|
]);
|
|
2712
|
-
|
|
2713
|
-
const
|
|
2714
|
-
const
|
|
2715
|
-
const dataRef =
|
|
2664
|
+
const apiRef = useRef4(null);
|
|
2665
|
+
const containerRef = useRef4(null);
|
|
2666
|
+
const [internalSelectedCount, setInternalSelectedCount] = useState9(0);
|
|
2667
|
+
const dataRef = useRef4(data);
|
|
2716
2668
|
useEffect9(() => {
|
|
2717
2669
|
dataRef.current = data;
|
|
2718
2670
|
}, [data]);
|
|
2719
|
-
const onRowSelectionChangeRef =
|
|
2671
|
+
const onRowSelectionChangeRef = useRef4(onRowSelectionChange);
|
|
2720
2672
|
useEffect9(() => {
|
|
2721
2673
|
onRowSelectionChangeRef.current = onRowSelectionChange;
|
|
2722
2674
|
}, [onRowSelectionChange]);
|
|
2723
|
-
const onSelectAllPageRef =
|
|
2675
|
+
const onSelectAllPageRef = useRef4(onSelectAllPage);
|
|
2724
2676
|
useEffect9(() => {
|
|
2725
2677
|
onSelectAllPageRef.current = onSelectAllPage;
|
|
2726
2678
|
}, [onSelectAllPage]);
|
|
2727
2679
|
useImperativeHandle(ref, () => apiRef.current, []);
|
|
2728
|
-
const
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
}
|
|
2733
|
-
prevSelectedCountRef.current = selectedCount != null ? selectedCount : 0;
|
|
2680
|
+
const getSelectedData = useCallback2(() => {
|
|
2681
|
+
var _a2, _b2, _c;
|
|
2682
|
+
const ids = (_b2 = (_a2 = apiRef.current) == null ? void 0 : _a2.getState().selectedRows) != null ? _b2 : [];
|
|
2683
|
+
return ((_c = dataRef.current) != null ? _c : []).filter((row) => ids.includes(row.id));
|
|
2684
|
+
}, []);
|
|
2734
2685
|
const resolvedColumns = useMemo4(() => {
|
|
2735
|
-
if (!selectionEnabled) return columns;
|
|
2686
|
+
if (!selectionEnabled || columns.length === 0) return columns;
|
|
2736
2687
|
const checkboxCol = buildCheckboxColumn({
|
|
2737
2688
|
getPageData: () => {
|
|
2738
|
-
var
|
|
2739
|
-
return (
|
|
2689
|
+
var _a2;
|
|
2690
|
+
return (_a2 = dataRef.current) != null ? _a2 : [];
|
|
2740
2691
|
},
|
|
2741
|
-
onSelectionChange: (
|
|
2742
|
-
var
|
|
2743
|
-
(
|
|
2692
|
+
onSelectionChange: (id, rowData, checked) => {
|
|
2693
|
+
var _a2;
|
|
2694
|
+
(_a2 = onRowSelectionChangeRef.current) == null ? void 0 : _a2.call(onRowSelectionChangeRef, id, rowData, checked);
|
|
2744
2695
|
},
|
|
2745
2696
|
onSelectAllPage: (pageData, checked) => {
|
|
2746
|
-
var
|
|
2747
|
-
(
|
|
2748
|
-
}
|
|
2749
|
-
clearToken: clearTokenRef.current
|
|
2697
|
+
var _a2;
|
|
2698
|
+
(_a2 = onSelectAllPageRef.current) == null ? void 0 : _a2.call(onSelectAllPageRef, pageData, checked);
|
|
2699
|
+
}
|
|
2750
2700
|
});
|
|
2751
2701
|
return [checkboxCol, ...columns];
|
|
2752
|
-
}, [selectionEnabled, columns
|
|
2702
|
+
}, [selectionEnabled, columns]);
|
|
2753
2703
|
const resizeColumns = useCallback2(() => {
|
|
2754
2704
|
const api = apiRef.current;
|
|
2755
2705
|
const container = containerRef.current;
|
|
2756
2706
|
if (!api || !container) return;
|
|
2757
2707
|
const gridWidth = container.clientWidth;
|
|
2758
|
-
const
|
|
2759
|
-
const
|
|
2760
|
-
|
|
2761
|
-
)
|
|
2762
|
-
|
|
2763
|
-
(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);
|
|
2708
|
+
const isFixed = (col) => col.id === "__selection__";
|
|
2709
|
+
const resizable = resolvedColumns.filter((col) => !isFixed(col));
|
|
2710
|
+
const fixed = resolvedColumns.filter((col) => isFixed(col));
|
|
2711
|
+
const fixedTotal = fixed.reduce((sum, col) => {
|
|
2712
|
+
var _a2, _b2, _c;
|
|
2713
|
+
const w = (_c = (_b2 = (_a2 = api.getColumn(col.id)) == null ? void 0 : _a2.width) != null ? _b2 : col.width) != null ? _c : 0;
|
|
2714
|
+
return sum + (isNaN(w) ? 0 : w);
|
|
2770
2715
|
}, 0);
|
|
2771
|
-
const
|
|
2716
|
+
const available = Math.max(gridWidth - fixedTotal, 0);
|
|
2772
2717
|
if (data && data.length > 0) {
|
|
2773
|
-
|
|
2774
|
-
api.exec("resize-column", { id: col.id, auto: "data" })
|
|
2775
|
-
|
|
2776
|
-
const
|
|
2777
|
-
var
|
|
2778
|
-
const
|
|
2779
|
-
|
|
2780
|
-
return sum + (isNaN(width) ? 0 : width);
|
|
2718
|
+
resizable.forEach(
|
|
2719
|
+
(col) => api.exec("resize-column", { id: col.id, auto: "data" })
|
|
2720
|
+
);
|
|
2721
|
+
const autoTotal = resizable.reduce((sum, col) => {
|
|
2722
|
+
var _a2, _b2;
|
|
2723
|
+
const w = (_b2 = (_a2 = api.getColumn(col.id)) == null ? void 0 : _a2.width) != null ? _b2 : 0;
|
|
2724
|
+
return sum + (isNaN(w) ? 0 : w);
|
|
2781
2725
|
}, 0);
|
|
2782
|
-
if (
|
|
2783
|
-
const extra = (
|
|
2784
|
-
|
|
2785
|
-
var
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
api.exec("resize-column", {
|
|
2790
|
-
id: col.id,
|
|
2791
|
-
width: currentWidth + extra
|
|
2792
|
-
});
|
|
2793
|
-
}
|
|
2726
|
+
if (autoTotal < available && resizable.length > 0) {
|
|
2727
|
+
const extra = (available - autoTotal) / resizable.length;
|
|
2728
|
+
resizable.forEach((col) => {
|
|
2729
|
+
var _a2, _b2;
|
|
2730
|
+
const w = (_b2 = (_a2 = api.getColumn(col.id)) == null ? void 0 : _a2.width) != null ? _b2 : 0;
|
|
2731
|
+
if (!isNaN(w))
|
|
2732
|
+
api.exec("resize-column", { id: col.id, width: w + extra });
|
|
2794
2733
|
});
|
|
2795
2734
|
}
|
|
2796
2735
|
} else {
|
|
2797
|
-
const
|
|
2798
|
-
|
|
2799
|
-
api.exec("resize-column", {
|
|
2800
|
-
|
|
2801
|
-
width: equalWidth
|
|
2802
|
-
});
|
|
2803
|
-
});
|
|
2736
|
+
const eq = resizable.length > 0 ? available / resizable.length : 0;
|
|
2737
|
+
resizable.forEach(
|
|
2738
|
+
(col) => api.exec("resize-column", { id: col.id, width: eq })
|
|
2739
|
+
);
|
|
2804
2740
|
}
|
|
2805
2741
|
}, [resolvedColumns, data]);
|
|
2806
|
-
useEffect9(() => {
|
|
2807
|
-
if (!containerRef.current) return;
|
|
2808
|
-
const observer = new ResizeObserver(() => resizeColumns());
|
|
2809
|
-
observer.observe(containerRef.current);
|
|
2810
|
-
return () => observer.disconnect();
|
|
2811
|
-
}, [resizeColumns]);
|
|
2812
2742
|
const init = useCallback2(
|
|
2813
2743
|
(api) => {
|
|
2814
2744
|
apiRef.current = api;
|
|
2815
2745
|
resizeColumns();
|
|
2816
2746
|
api.intercept("focus-cell", onFocusCell);
|
|
2747
|
+
if (selectionEnabled) {
|
|
2748
|
+
api.on("select-row", () => {
|
|
2749
|
+
var _a2;
|
|
2750
|
+
setInternalSelectedCount(
|
|
2751
|
+
((_a2 = api.getState().selectedRows) != null ? _a2 : []).length
|
|
2752
|
+
);
|
|
2753
|
+
});
|
|
2754
|
+
}
|
|
2817
2755
|
},
|
|
2818
|
-
[resizeColumns, onFocusCell]
|
|
2756
|
+
[resizeColumns, onFocusCell, selectionEnabled]
|
|
2819
2757
|
);
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
const
|
|
2823
|
-
|
|
2824
|
-
|
|
2758
|
+
useEffect9(() => {
|
|
2759
|
+
if (!containerRef.current) return;
|
|
2760
|
+
const observer = new ResizeObserver(() => resizeColumns());
|
|
2761
|
+
observer.observe(containerRef.current);
|
|
2762
|
+
return () => observer.disconnect();
|
|
2763
|
+
}, [resizeColumns]);
|
|
2764
|
+
useEffect9(() => {
|
|
2765
|
+
if (!selectionEnabled || !getSelectedIds || !apiRef.current) return;
|
|
2766
|
+
const pageIds = new Set((data != null ? data : []).map((r) => r.id));
|
|
2767
|
+
const toRestore = getSelectedIds().filter((id) => pageIds.has(id));
|
|
2768
|
+
toRestore.forEach(
|
|
2769
|
+
(id) => apiRef.current.exec("select-row", { id, mode: true })
|
|
2770
|
+
);
|
|
2771
|
+
}, [data, selectionEnabled, getSelectedIds]);
|
|
2772
|
+
const handleClearSelection = useCallback2(() => {
|
|
2773
|
+
var _a2;
|
|
2774
|
+
const api = apiRef.current;
|
|
2775
|
+
if (!api) return;
|
|
2776
|
+
const ids = [...(_a2 = api.getState().selectedRows) != null ? _a2 : []];
|
|
2777
|
+
ids.forEach((id) => api.exec("select-row", { id, mode: false }));
|
|
2778
|
+
onClearSelection == null ? void 0 : onClearSelection();
|
|
2779
|
+
}, [onClearSelection]);
|
|
2825
2780
|
const handleExportPdf = useCallback2(() => {
|
|
2826
2781
|
const selected = getSelectedData();
|
|
2827
2782
|
if (selected.length) exportPdf(selected, fileName);
|
|
2828
2783
|
else onExportPdf == null ? void 0 : onExportPdf();
|
|
2829
|
-
}, [
|
|
2784
|
+
}, [getSelectedData, fileName, onExportPdf]);
|
|
2830
2785
|
const handleExportExcel = useCallback2(() => {
|
|
2831
2786
|
const selected = getSelectedData();
|
|
2832
2787
|
if (selected.length) exportExcel(selected, fileName);
|
|
2833
2788
|
else onExportExcel == null ? void 0 : onExportExcel();
|
|
2834
|
-
}, [
|
|
2789
|
+
}, [getSelectedData, fileName, onExportExcel]);
|
|
2835
2790
|
return /* @__PURE__ */ jsxs20("div", { className: "w-full h-full flex flex-col overflow-hidden", children: [
|
|
2836
2791
|
/* @__PURE__ */ jsx28(
|
|
2837
2792
|
gridHeader_default,
|
|
@@ -2846,11 +2801,11 @@ var Grid = forwardRef(
|
|
|
2846
2801
|
filterList: rest.filterList,
|
|
2847
2802
|
onFilterChange,
|
|
2848
2803
|
initialFilters,
|
|
2849
|
-
selectedCount,
|
|
2850
|
-
selectedData,
|
|
2804
|
+
selectedCount: internalSelectedCount,
|
|
2805
|
+
selectedData: getSelectedData(),
|
|
2851
2806
|
selectionActions,
|
|
2852
2807
|
onSelectionAction,
|
|
2853
|
-
onClearSelection,
|
|
2808
|
+
onClearSelection: handleClearSelection,
|
|
2854
2809
|
children
|
|
2855
2810
|
}
|
|
2856
2811
|
),
|
|
@@ -2865,7 +2820,6 @@ var Grid = forwardRef(
|
|
|
2865
2820
|
data,
|
|
2866
2821
|
columns: resolvedColumns,
|
|
2867
2822
|
init,
|
|
2868
|
-
selectedRows: selectionEnabled ? selectedIds : void 0,
|
|
2869
2823
|
select: selectionEnabled ? false : rest.select
|
|
2870
2824
|
})
|
|
2871
2825
|
) }) })
|
|
@@ -2874,11 +2828,11 @@ var Grid = forwardRef(
|
|
|
2874
2828
|
] });
|
|
2875
2829
|
}
|
|
2876
2830
|
);
|
|
2877
|
-
var grid_default = Grid;
|
|
2831
|
+
var grid_default = React6.memo(Grid);
|
|
2878
2832
|
|
|
2879
2833
|
// src/components/custom/grid/sortableHeaderCell.tsx
|
|
2880
2834
|
import { MoveDown, MoveUp, ArrowUpDown } from "lucide-react";
|
|
2881
|
-
import
|
|
2835
|
+
import React7 from "react";
|
|
2882
2836
|
import { jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2883
2837
|
var SortableHeaderCell = ({ cell, sortKey, sortOrder, onSortChange }) => {
|
|
2884
2838
|
if (!(cell == null ? void 0 : cell.id)) return /* @__PURE__ */ jsx29("span", { children: cell == null ? void 0 : cell.text });
|
|
@@ -2908,7 +2862,7 @@ var SortableHeaderCell = ({ cell, sortKey, sortOrder, onSortChange }) => {
|
|
|
2908
2862
|
}
|
|
2909
2863
|
);
|
|
2910
2864
|
};
|
|
2911
|
-
var sortableHeaderCell_default =
|
|
2865
|
+
var sortableHeaderCell_default = React7.memo(SortableHeaderCell, (prev, next) => {
|
|
2912
2866
|
var _a, _b, _c, _d;
|
|
2913
2867
|
if (((_a = prev.cell) == null ? void 0 : _a.id) !== ((_b = next.cell) == null ? void 0 : _b.id)) return false;
|
|
2914
2868
|
if (((_c = prev.cell) == null ? void 0 : _c.text) !== ((_d = next.cell) == null ? void 0 : _d.text)) return false;
|
|
@@ -3035,7 +2989,7 @@ var pagination_default = Pagination;
|
|
|
3035
2989
|
|
|
3036
2990
|
// src/components/custom/toolbar/index.tsx
|
|
3037
2991
|
import { ChevronRight as ChevronRight4, X as X5 } from "lucide-react";
|
|
3038
|
-
import { useState as
|
|
2992
|
+
import { useState as useState10, useRef as useRef5, useEffect as useEffect10 } from "react";
|
|
3039
2993
|
import { Fragment as Fragment4, jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3040
2994
|
var SlideToolbar = ({
|
|
3041
2995
|
items,
|
|
@@ -3048,8 +3002,8 @@ var SlideToolbar = ({
|
|
|
3048
3002
|
className = ""
|
|
3049
3003
|
}) => {
|
|
3050
3004
|
const resolvedItems = items != null ? items : children ? void 0 : [];
|
|
3051
|
-
const [open, setOpen] =
|
|
3052
|
-
const panelRef =
|
|
3005
|
+
const [open, setOpen] = useState10(false);
|
|
3006
|
+
const panelRef = useRef5(null);
|
|
3053
3007
|
useEffect10(() => {
|
|
3054
3008
|
if (!open || !closeOnBackdrop) return;
|
|
3055
3009
|
const handlePointerDown = (e) => {
|