pixelize-design-library 2.1.69 → 2.1.72
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/Components/Card/PaymentCard/PaymentCard.js +56 -35
- package/dist/Components/Card/PaymentCard/PaymentCardProps.d.ts +2 -2
- package/dist/Components/KaTable/CustomHeader.d.ts +14 -0
- package/dist/Components/KaTable/CustomHeader.js +69 -0
- package/dist/Components/KaTable/KaTable.d.ts +13 -0
- package/dist/Components/KaTable/KaTable.js +111 -0
- package/dist/Components/KaTable/KaTableProps.d.ts +23 -0
- package/dist/Components/KaTable/KaTableProps.js +2 -0
- package/dist/Components/KaTable/SelectionCell.d.ts +8 -0
- package/dist/Components/KaTable/SelectionCell.js +38 -0
- package/dist/Components/KaTable/SelectionHeader.d.ts +3 -0
- package/dist/Components/KaTable/SelectionHeader.js +56 -0
- package/dist/Components/KaTable/ka-table.css +27 -0
- package/dist/Components/KaTable/useMergedChildComponents.d.ts +14 -0
- package/dist/Components/KaTable/useMergedChildComponents.js +224 -0
- package/dist/Components/Table/Components/TableActions.d.ts +9 -1
- package/dist/Components/Table/Components/TableActions.js +146 -10
- package/dist/Components/Table/Table.css +16 -0
- package/dist/Pages/KaTableExample.d.ts +3 -0
- package/dist/Pages/KaTableExample.js +259 -0
- package/dist/Pages/card.js +7 -6
- package/dist/Theme/Default/fonts.d.ts +35 -0
- package/dist/Theme/Default/fonts.js +37 -0
- package/package.json +1 -1
- package/dist/index.d.mts +0 -1468
- package/dist/index.mjs +0 -263
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
45
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
46
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
47
|
+
};
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
var react_1 = __importStar(require("react"));
|
|
50
|
+
var CustomHeader_1 = __importDefault(require("./CustomHeader"));
|
|
51
|
+
var SelectionHeader_1 = __importDefault(require("./SelectionHeader"));
|
|
52
|
+
var SelectionCell_1 = __importDefault(require("./SelectionCell"));
|
|
53
|
+
var useCustomTheme_1 = require("../../Theme/useCustomTheme");
|
|
54
|
+
var table_1 = require("../../Utils/table");
|
|
55
|
+
var useMergedChildComponents = function (_a) {
|
|
56
|
+
var childComponents = _a.childComponents, onSortChange = _a.onSortChange, handleSelection = _a.handleSelection, rowKey = _a.rowKey, onRowClick = _a.onRowClick, selected = _a.selected, dataLength = _a.dataLength, columns = _a.columns, headerBgColor = _a.headerBgColor, freezedBgColor = _a.freezedBgColor, headerTextColor = _a.headerTextColor, freezedTextColor = _a.freezedTextColor, sortState = _a.sortState;
|
|
57
|
+
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
58
|
+
var handleSortChange = (0, react_1.useCallback)(function (newState, columnKey) {
|
|
59
|
+
var newSortState = __spreadArray([], sortState, true);
|
|
60
|
+
var existingIndex = newSortState.findIndex(function (sort) { return sort.column === columnKey; });
|
|
61
|
+
if (existingIndex === -1) {
|
|
62
|
+
newSortState.push({
|
|
63
|
+
column: columnKey,
|
|
64
|
+
direction: newState, // Default to ascending when adding a column
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var existingSort = newSortState[existingIndex];
|
|
69
|
+
existingSort.direction = newState;
|
|
70
|
+
}
|
|
71
|
+
var column = columns.find(function (col) { return col.key === columnKey; });
|
|
72
|
+
column.sortDirection = newState;
|
|
73
|
+
onSortChange(newSortState);
|
|
74
|
+
}, [sortState, onSortChange, columns]);
|
|
75
|
+
var _b = react_1.default.useState(selected), selections = _b[0], setSelections = _b[1];
|
|
76
|
+
(0, react_1.useEffect)(function () {
|
|
77
|
+
setSelections(selected);
|
|
78
|
+
}, [selected]);
|
|
79
|
+
var isAllSelected = (0, react_1.useMemo)(function () {
|
|
80
|
+
return {
|
|
81
|
+
checked: (selections === null || selections === void 0 ? void 0 : selections.length) === (dataLength || -1),
|
|
82
|
+
intederminate: (selections === null || selections === void 0 ? void 0 : selections.length) > 0 && (selections === null || selections === void 0 ? void 0 : selections.length) < dataLength,
|
|
83
|
+
};
|
|
84
|
+
}, [selections, dataLength]);
|
|
85
|
+
var cellSelectionHandle = (0, react_1.useCallback)(function (values, type) {
|
|
86
|
+
if (type === "add") {
|
|
87
|
+
setSelections(__spreadArray(__spreadArray([], selections, true), [values], false));
|
|
88
|
+
handleSelection(__spreadArray(__spreadArray([], selections, true), [values], false));
|
|
89
|
+
}
|
|
90
|
+
else if (type === "remove") {
|
|
91
|
+
setSelections(selections.filter(function (value) { return value !== values; }));
|
|
92
|
+
handleSelection(selections.filter(function (value) { return value !== values; }));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
handleSelection(selections.filter(function (value) { return value !== values; }));
|
|
96
|
+
}
|
|
97
|
+
}, [selections, handleSelection]);
|
|
98
|
+
var headerSelectionHandle = (0, react_1.useCallback)(function (values) {
|
|
99
|
+
setSelections(values);
|
|
100
|
+
handleSelection(values);
|
|
101
|
+
}, [handleSelection]);
|
|
102
|
+
return (0, react_1.useMemo)(function () {
|
|
103
|
+
return __assign(__assign({}, childComponents), { dataRow: {
|
|
104
|
+
elementAttributes: function (props) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
var existingElementAttributes = (_a = childComponents.dataRow) === null || _a === void 0 ? void 0 : _a.elementAttributes;
|
|
107
|
+
var attributes = existingElementAttributes
|
|
108
|
+
? existingElementAttributes(props)
|
|
109
|
+
: {};
|
|
110
|
+
var isSelected = selections === null || selections === void 0 ? void 0 : selections.includes(props.rowData[rowKey]);
|
|
111
|
+
var className = "".concat(attributes.className || "", " ").concat(isSelected ? "ka-row-selected" : "", " ka-row-hover").trim();
|
|
112
|
+
// const className =
|
|
113
|
+
// `${attributes.className || ""} ${isSelected ? "ka-row-selected" : ""}`.trim();
|
|
114
|
+
return __assign(__assign({}, attributes), { className: className, style: __assign(__assign({}, (attributes.style || {})), { backgroundColor: isSelected
|
|
115
|
+
? theme.colors.backgroundColor.subtle
|
|
116
|
+
: undefined, border: "1px solid ".concat((_b = theme.colors) === null || _b === void 0 ? void 0 : _b.gray[200]) }) });
|
|
117
|
+
},
|
|
118
|
+
}, headCell: {
|
|
119
|
+
content: function (props) {
|
|
120
|
+
var _a, _b, _c;
|
|
121
|
+
var existingContent = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.content;
|
|
122
|
+
if (existingContent) {
|
|
123
|
+
var result = existingContent(props);
|
|
124
|
+
if (result) {
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
var column = props.column;
|
|
129
|
+
if (column.sortable || column.filter) {
|
|
130
|
+
return (react_1.default.createElement(CustomHeader_1.default, __assign({}, props, { onSortChange: handleSortChange, menuItems: (_b = column === null || column === void 0 ? void 0 : column.menu) !== null && _b !== void 0 ? _b : [], isSort: props.column.sortable, sortDirection: (_c = props.column.sortDirection) !== null && _c !== void 0 ? _c : "none" })));
|
|
131
|
+
}
|
|
132
|
+
if (props.column.key === "select-cell") {
|
|
133
|
+
return (react_1.default.createElement(SelectionHeader_1.default, { onSelectionChange: headerSelectionHandle, rowKey: rowKey, selected: isAllSelected }));
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
},
|
|
137
|
+
elementAttributes: function (props) {
|
|
138
|
+
var _a, _b, _c, _d, _e, _f;
|
|
139
|
+
var existingElementAttributes = (_a = childComponents.headCell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
|
|
140
|
+
if (existingElementAttributes) {
|
|
141
|
+
var result = existingElementAttributes(props);
|
|
142
|
+
if (result) {
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (props.column.columnFreeze) {
|
|
147
|
+
var stickyLeft = (0, table_1.getPreviousColumnWidth)(columns, props.column.key);
|
|
148
|
+
return {
|
|
149
|
+
style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 3, backgroundColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.backgroundColor.subtle, color: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600] }),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
style: {
|
|
154
|
+
backgroundColor: headerBgColor !== null && headerBgColor !== void 0 ? headerBgColor : (_d = theme.colors.backgroundColor) === null || _d === void 0 ? void 0 : _d.subtle,
|
|
155
|
+
color: headerTextColor !== null && headerTextColor !== void 0 ? headerTextColor : (_e = theme.colors) === null || _e === void 0 ? void 0 : _e.gray[600],
|
|
156
|
+
border: "1px solid ".concat((_f = theme.colors) === null || _f === void 0 ? void 0 : _f.gray[200]),
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
}, cell: {
|
|
161
|
+
elementAttributes: function (props) {
|
|
162
|
+
var _a, _b, _c, _d, _e;
|
|
163
|
+
var existingElementAttributes = (_a = childComponents.cell) === null || _a === void 0 ? void 0 : _a.elementAttributes;
|
|
164
|
+
if (existingElementAttributes) {
|
|
165
|
+
var result = existingElementAttributes(props);
|
|
166
|
+
if (result) {
|
|
167
|
+
return result;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
if (props.column.columnFreeze) {
|
|
171
|
+
var stickyLeft = (0, table_1.getPreviousColumnWidth)(columns, props.column.key);
|
|
172
|
+
return {
|
|
173
|
+
style: __assign(__assign({}, props.column.style), { position: "sticky", left: stickyLeft, zIndex: 2, backgroundColor: freezedBgColor !== null && freezedBgColor !== void 0 ? freezedBgColor : (_b = theme.colors) === null || _b === void 0 ? void 0 : _b.backgroundColor.subtle, color: freezedTextColor !== null && freezedTextColor !== void 0 ? freezedTextColor : (_c = theme.colors) === null || _c === void 0 ? void 0 : _c.gray[600], fontWeight: 600 }),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
style: {
|
|
178
|
+
color: (_d = theme.colors) === null || _d === void 0 ? void 0 : _d.gray[600],
|
|
179
|
+
fontWeight: 500,
|
|
180
|
+
border: "1px solid ".concat((_e = theme.colors) === null || _e === void 0 ? void 0 : _e.gray[200]),
|
|
181
|
+
},
|
|
182
|
+
onClick: function () {
|
|
183
|
+
if (onRowClick) {
|
|
184
|
+
onRowClick(props.rowData, props.column.key);
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
}, tableWrapper: {
|
|
190
|
+
elementAttributes: function () { return ({ style: { maxHeight: 600 } }); },
|
|
191
|
+
}, cellText: {
|
|
192
|
+
content: function (props) {
|
|
193
|
+
var _a;
|
|
194
|
+
var existingContent = (_a = childComponents.cellText) === null || _a === void 0 ? void 0 : _a.content;
|
|
195
|
+
if (existingContent) {
|
|
196
|
+
var result = existingContent(props);
|
|
197
|
+
if (result) {
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (props.column.key === "select-cell") {
|
|
202
|
+
var isSelected = selections === null || selections === void 0 ? void 0 : selections.includes(props.rowData[rowKey]);
|
|
203
|
+
return (react_1.default.createElement(SelectionCell_1.default, __assign({}, props, { selected: isSelected, onSelectionChange: cellSelectionHandle })));
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
} });
|
|
207
|
+
}, [
|
|
208
|
+
childComponents,
|
|
209
|
+
rowKey,
|
|
210
|
+
onRowClick,
|
|
211
|
+
selections,
|
|
212
|
+
columns,
|
|
213
|
+
cellSelectionHandle,
|
|
214
|
+
headerSelectionHandle,
|
|
215
|
+
isAllSelected,
|
|
216
|
+
theme.colors,
|
|
217
|
+
headerBgColor,
|
|
218
|
+
headerTextColor,
|
|
219
|
+
freezedBgColor,
|
|
220
|
+
freezedTextColor,
|
|
221
|
+
handleSortChange,
|
|
222
|
+
]);
|
|
223
|
+
};
|
|
224
|
+
exports.default = useMergedChildComponents;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
2
|
+
type TableRowActions = {
|
|
3
|
+
onLink?: (row: any) => void;
|
|
4
|
+
onEdit?: (row: any) => void;
|
|
5
|
+
onDelete?: (row: any) => void;
|
|
6
|
+
[key: string]: any;
|
|
7
|
+
};
|
|
8
|
+
declare const TableActions: ({ row }: {
|
|
9
|
+
row?: TableRowActions | undefined;
|
|
10
|
+
}) => React.JSX.Element | null;
|
|
3
11
|
export default TableActions;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
// import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
// import {
|
|
4
|
+
// Button,
|
|
5
|
+
// IconButton,
|
|
6
|
+
// Popover,
|
|
7
|
+
// PopoverBody,
|
|
8
|
+
// PopoverContent,
|
|
9
|
+
// PopoverTrigger,
|
|
10
|
+
// Portal,
|
|
11
|
+
// VStack,
|
|
12
|
+
// } from "@chakra-ui/react";
|
|
13
|
+
// import { EllipsisVertical, ExternalLink, Pencil, Trash2 } from "lucide-react";
|
|
2
14
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
15
|
if (k2 === undefined) k2 = k;
|
|
4
16
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -23,6 +35,109 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
35
|
return result;
|
|
24
36
|
};
|
|
25
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
// const TableActions = ({ row }: any) => {
|
|
39
|
+
// const [isOpen, setIsOpen] = useState(false);
|
|
40
|
+
// const ref = useRef<HTMLDivElement>(null);
|
|
41
|
+
// // Listen for "close-all-popovers"
|
|
42
|
+
// useEffect(() => {
|
|
43
|
+
// const handler = () => setIsOpen(false);
|
|
44
|
+
// window.addEventListener("close-all-popovers", handler);
|
|
45
|
+
// return () => window.removeEventListener("close-all-popovers", handler);
|
|
46
|
+
// }, []);
|
|
47
|
+
// // Detect outside click
|
|
48
|
+
// useEffect(() => {
|
|
49
|
+
// const handleClickOutside = (event: MouseEvent) => {
|
|
50
|
+
// if (ref.current && !ref.current.contains(event.target as Node)) {
|
|
51
|
+
// setIsOpen(false);
|
|
52
|
+
// }
|
|
53
|
+
// };
|
|
54
|
+
// if (isOpen) {
|
|
55
|
+
// document.addEventListener("mousedown", handleClickOutside);
|
|
56
|
+
// }
|
|
57
|
+
// return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
58
|
+
// }, [isOpen]);
|
|
59
|
+
// const handleOpen = () => {
|
|
60
|
+
// window.dispatchEvent(new Event("close-all-popovers")); // close others
|
|
61
|
+
// setIsOpen(true);
|
|
62
|
+
// };
|
|
63
|
+
// const handleClose = () => setIsOpen(false);
|
|
64
|
+
// return (
|
|
65
|
+
// <Popover
|
|
66
|
+
// placement="bottom-start"
|
|
67
|
+
// isOpen={isOpen}
|
|
68
|
+
// onClose={handleClose}
|
|
69
|
+
// closeOnBlur={false} // we handle outside click manually
|
|
70
|
+
// >
|
|
71
|
+
// <div ref={ref}>
|
|
72
|
+
// <PopoverTrigger>
|
|
73
|
+
// <IconButton
|
|
74
|
+
// aria-label="Link"
|
|
75
|
+
// color="black"
|
|
76
|
+
// icon={<EllipsisVertical size={17} />}
|
|
77
|
+
// size="sm"
|
|
78
|
+
// p={0}
|
|
79
|
+
// variant="ghost"
|
|
80
|
+
// _hover={{ transform: "scale(1.2)" }}
|
|
81
|
+
// onClick={() => (isOpen ? handleClose() : handleOpen())}
|
|
82
|
+
// />
|
|
83
|
+
// </PopoverTrigger>
|
|
84
|
+
// <Portal>
|
|
85
|
+
// <PopoverContent w="auto" minW="150px" boxShadow="lg" p={0} zIndex={999}>
|
|
86
|
+
// <PopoverBody>
|
|
87
|
+
// <VStack align="stretch" spacing={1}>
|
|
88
|
+
// {row.onLink && (
|
|
89
|
+
// <Button
|
|
90
|
+
// size="sm"
|
|
91
|
+
// variant="ghost"
|
|
92
|
+
// justifyContent="flex-start"
|
|
93
|
+
// gap={2}
|
|
94
|
+
// onClick={() => {
|
|
95
|
+
// row.onLink(row);
|
|
96
|
+
// console.log(row,"row")
|
|
97
|
+
// handleClose();
|
|
98
|
+
// }}
|
|
99
|
+
// >
|
|
100
|
+
// <ExternalLink size={17} /> View
|
|
101
|
+
// </Button>
|
|
102
|
+
// )}
|
|
103
|
+
// {row.onEdit && (
|
|
104
|
+
// <Button
|
|
105
|
+
// size="sm"
|
|
106
|
+
// variant="ghost"
|
|
107
|
+
// justifyContent="flex-start"
|
|
108
|
+
// gap={2}
|
|
109
|
+
// onClick={() => {
|
|
110
|
+
// row.onEdit(row);
|
|
111
|
+
// handleClose();
|
|
112
|
+
// }}
|
|
113
|
+
// >
|
|
114
|
+
// <Pencil size={17} /> Edit
|
|
115
|
+
// </Button>
|
|
116
|
+
// )}
|
|
117
|
+
// {row.onDelete && (
|
|
118
|
+
// <Button
|
|
119
|
+
// size="sm"
|
|
120
|
+
// variant="ghost"
|
|
121
|
+
// justifyContent="flex-start"
|
|
122
|
+
// colorScheme="red"
|
|
123
|
+
// gap={2}
|
|
124
|
+
// onClick={() => {
|
|
125
|
+
// row.onDelete(row);
|
|
126
|
+
// handleClose();
|
|
127
|
+
// }}
|
|
128
|
+
// >
|
|
129
|
+
// <Trash2 size={17} /> Delete
|
|
130
|
+
// </Button>
|
|
131
|
+
// )}
|
|
132
|
+
// </VStack>
|
|
133
|
+
// </PopoverBody>
|
|
134
|
+
// </PopoverContent>
|
|
135
|
+
// </Portal>
|
|
136
|
+
// </div>
|
|
137
|
+
// </Popover>
|
|
138
|
+
// );
|
|
139
|
+
// };
|
|
140
|
+
// export default TableActions;
|
|
26
141
|
var react_1 = __importStar(require("react"));
|
|
27
142
|
var react_2 = require("@chakra-ui/react");
|
|
28
143
|
var lucide_react_1 = require("lucide-react");
|
|
@@ -44,40 +159,61 @@ var TableActions = function (_a) {
|
|
|
44
159
|
}
|
|
45
160
|
};
|
|
46
161
|
if (isOpen) {
|
|
47
|
-
|
|
162
|
+
// ✅ Use click instead of mousedown
|
|
163
|
+
document.addEventListener("click", handleClickOutside);
|
|
48
164
|
}
|
|
49
|
-
return function () {
|
|
165
|
+
return function () {
|
|
166
|
+
document.removeEventListener("click", handleClickOutside);
|
|
167
|
+
};
|
|
50
168
|
}, [isOpen]);
|
|
169
|
+
// useEffect(() => {
|
|
170
|
+
// const handleClickOutside = (event: MouseEvent) => {
|
|
171
|
+
// if (ref.current && !ref.current.contains(event.target as Node)) {
|
|
172
|
+
// setIsOpen(false);
|
|
173
|
+
// }
|
|
174
|
+
// };
|
|
175
|
+
// if (isOpen) {
|
|
176
|
+
// document.addEventListener("mousedown", handleClickOutside);
|
|
177
|
+
// }
|
|
178
|
+
// return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
179
|
+
// }, [isOpen]);
|
|
51
180
|
var handleOpen = function () {
|
|
52
181
|
window.dispatchEvent(new Event("close-all-popovers")); // close others
|
|
53
182
|
setIsOpen(true);
|
|
54
183
|
};
|
|
55
184
|
var handleClose = function () { return setIsOpen(false); };
|
|
185
|
+
// ✅ if row itself is missing, render nothing
|
|
186
|
+
if (!row)
|
|
187
|
+
return null;
|
|
56
188
|
return (react_1.default.createElement(react_2.Popover, { placement: "bottom-start", isOpen: isOpen, onClose: handleClose, closeOnBlur: false },
|
|
57
189
|
react_1.default.createElement("div", { ref: ref },
|
|
58
190
|
react_1.default.createElement(react_2.PopoverTrigger, null,
|
|
59
|
-
react_1.default.createElement(react_2.IconButton, { "aria-label": "
|
|
191
|
+
react_1.default.createElement(react_2.IconButton, { "aria-label": "Actions", color: "black", icon: react_1.default.createElement(lucide_react_1.EllipsisVertical, { size: 17 }), size: "sm", p: 0, variant: "ghost", _hover: { transform: "scale(1.2)" }, onClick: function () { return (isOpen ? handleClose() : handleOpen()); } })),
|
|
60
192
|
react_1.default.createElement(react_2.Portal, null,
|
|
61
193
|
react_1.default.createElement(react_2.PopoverContent, { w: "auto", minW: "150px", boxShadow: "lg", p: 0, zIndex: 999 },
|
|
62
194
|
react_1.default.createElement(react_2.PopoverBody, null,
|
|
63
195
|
react_1.default.createElement(react_2.VStack, { align: "stretch", spacing: 1 },
|
|
64
196
|
row.onLink && (react_1.default.createElement(react_2.Button, { size: "sm", variant: "ghost", justifyContent: "flex-start", gap: 2, onClick: function () {
|
|
65
|
-
|
|
66
|
-
|
|
197
|
+
var _a;
|
|
198
|
+
(_a = row.onLink) === null || _a === void 0 ? void 0 : _a.call(row, row);
|
|
199
|
+
// handleClose();
|
|
67
200
|
} },
|
|
68
201
|
react_1.default.createElement(lucide_react_1.ExternalLink, { size: 17 }),
|
|
69
202
|
" View")),
|
|
70
203
|
row.onEdit && (react_1.default.createElement(react_2.Button, { size: "sm", variant: "ghost", justifyContent: "flex-start", gap: 2, onClick: function () {
|
|
71
|
-
|
|
72
|
-
|
|
204
|
+
var _a;
|
|
205
|
+
(_a = row.onEdit) === null || _a === void 0 ? void 0 : _a.call(row, row);
|
|
206
|
+
// handleClose();
|
|
73
207
|
} },
|
|
74
208
|
react_1.default.createElement(lucide_react_1.Pencil, { size: 17 }),
|
|
75
209
|
" Edit")),
|
|
76
210
|
row.onDelete && (react_1.default.createElement(react_2.Button, { size: "sm", variant: "ghost", justifyContent: "flex-start", colorScheme: "red", gap: 2, onClick: function () {
|
|
77
|
-
|
|
78
|
-
|
|
211
|
+
var _a;
|
|
212
|
+
(_a = row.onDelete) === null || _a === void 0 ? void 0 : _a.call(row, row);
|
|
213
|
+
// handleClose();
|
|
79
214
|
} },
|
|
80
215
|
react_1.default.createElement(lucide_react_1.Trash2, { size: 17 }),
|
|
81
|
-
" Delete"))
|
|
216
|
+
" Delete")),
|
|
217
|
+
!row.onLink && !row.onEdit && !row.onDelete && (react_1.default.createElement(react_2.Button, { size: "sm", variant: "ghost", isDisabled: true, justifyContent: "center" }, "No actions")))))))));
|
|
82
218
|
};
|
|
83
219
|
exports.default = TableActions;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
.table_wrapper {
|
|
2
|
+
width: 100%;
|
|
3
|
+
border-collapse: collapse;
|
|
4
|
+
/* table-layout: fixed; */
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.table_wrapper th .resize-handle {
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
width: 8px;
|
|
12
|
+
height: 100%;
|
|
13
|
+
cursor: col-resize;
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
z-index: 999;
|
|
16
|
+
}
|