@pnkx-lib/ui 1.9.328 → 1.9.329

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/es/ui/index.js CHANGED
@@ -1,14 +1,18 @@
1
- export { Button } from './Button.js';
1
+ import { Button } from './Button.js';
2
2
  export { CascaderField } from './Cascader.js';
3
3
  export { ErrorMessage } from './ErrorMessage.js';
4
- export { Typography } from './Typography.js';
5
- export { A as ActionRowTable, B as BulkActions, T as Table } from '../chunks/index-kvqVmred.js';
4
+ import { Typography } from './Typography.js';
5
+ import { jsxs, jsx } from 'react/jsx-runtime';
6
+ import { useState, useCallback, useEffect, useRef } from 'react';
7
+ import { Select, Input, Pagination, Table as Table$1, Tooltip as Tooltip$1 } from 'antd';
8
+ import { TypeStatusTable, TypeActionRowTable, TypeBulkActions } from '../constants/index.js';
9
+ export { PAGE_NUMBER, PAGE_SIZE, SORT, START_PAGE, START_PAGE_SIZE } from '../constants/index.js';
6
10
  export { Modal } from './Modal.js';
7
- export { Tooltip } from './Tooltip.js';
11
+ import { Tooltip } from './Tooltip.js';
8
12
  export { Tabs } from './Tabs.js';
9
13
  export { Label } from './Label.js';
10
14
  export { Skeleton } from './Skeleton.js';
11
- export { Popover } from './Popover.js';
15
+ import { Popover } from './Popover.js';
12
16
  export { SearchFiltersForm } from './SearchFilterForm.js';
13
17
  export { Container } from './Container.js';
14
18
  export { Badge, typeColorMap } from './Badge.js';
@@ -47,9 +51,13 @@ export { Collapse } from './Collapse.js';
47
51
  export { ColorPicker } from './ColorPicker.js';
48
52
  export { Empty } from './Empty.js';
49
53
  export { Image } from './Image.js';
50
- export { ConfirmModal } from './ConfirmModal.js';
54
+ import { ConfirmModal } from './ConfirmModal.js';
51
55
  export { ErrorBoundary } from './ErrorBoundary.js';
52
- export { CATEGORY_LIST_ENUM, CategoryStatus, badgeStatusCategoryConfig } from './CategoryStatus.js';
56
+ import { CATEGORY_LIST_ENUM } from './CategoryStatus.js';
57
+ export { CategoryStatus, badgeStatusCategoryConfig } from './CategoryStatus.js';
58
+ import { useToggle } from '@pnkx-lib/core';
59
+ import { isEmpty } from 'lodash';
60
+ import { t as twMerge } from '../chunks/bundle-mjs-BBFHkixS.js';
53
61
  export { BreadcrumbHeading } from './BreadcrumbHeading.js';
54
62
  export { Card } from './Card.js';
55
63
  export { ConfigProvider } from './ConfigProvider.js';
@@ -59,6 +67,888 @@ export { UploadMultiple } from './UploadMultiple.js';
59
67
  export { ImportFile } from './ImportFile.js';
60
68
  export { ExportFile } from './ExportFile.js';
61
69
  export { UploadComponent } from './UploadComponent.js';
62
- export { useMessage } from './Message.js';
70
+ export { useAppMessage } from './Message.js';
63
71
  export { a as MAX_TAG_COUNT, M as MAX_TAG_TEXT_LENGTH, T as TINY_API } from '../chunks/common-BygVXrbX.js';
64
- export { PAGE_NUMBER, PAGE_SIZE, SORT, START_PAGE, START_PAGE_SIZE, TypeActionRowTable, TypeBulkActions, TypeStatusTable } from '../constants/index.js';
72
+
73
+ const iconTableNoData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA7dSURBVHgB7Z1bbFTXFYb/PTO+gDFMApgQkngIvRAgwZFKlbRqPK5SqS+VjQQkSithPyQRVArQvFR5sa1ESlOlBV6KCJVsP6RtgAaTh6hVq86QNqKS02YI4NK0geNcgNikDAaDL3PO7lpnZowvczv7nBlfsj9pmNuxPZz/rLXXWnvtPYBGo9FoNBqNRqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDSaghAoMsEOGeS71NN4vEXEoSkZRRE4eEiGTYntkGjCbXHTGPRXo36BrvjTIgpNUfFUYBbWstAhgVCBP2L4LTTEdwgDmqxELpAXrESwYaXz8+SDRyw+KPeaFiIOxGVCpg8XFh+SrdBkxe9H2D9qe0PHeCJw9WuSrXY3FJEW2rTIOWkkX9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KaEymZILX/56iqT4jfQzNCPHXEtRSaNtEGUachaUa876pZciqg3K3L/d3UhUssha4CLDYwuev462YyU3fXswiRJ/Fgo/5o5fP5U5/Fh2QbcKXc/VkQSJrgWcxXoisBZ7luBVZCzwHcCOyFniOoCqyFngOoSKyFniO4VRkLfAcxInIWuA5SkEil+NhLfAcJq/IAi3ztmXnywB/vxR/LUK29/0ScS3wHCeHyHFYiGmB5wEssgXsmfBlKAZ/TZEXX3aimWXwt9FBo9FoNBqNRqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDQajXP+D0/tlZm0R8ESAAAAAElFTkSuQmCC";
74
+
75
+ const { Option } = Select;
76
+ const CustomPagination = ({
77
+ current = 1,
78
+ pageSize = 10,
79
+ total = 0,
80
+ pageSizeOptions = ["10", "50", "100", "150", "200"],
81
+ onChange,
82
+ onShowSizeChange,
83
+ size,
84
+ ...rest
85
+ }) => {
86
+ const [jumpValue, setJumpValue] = useState("");
87
+ const showTotal = (total2, range) => `${range[0]}-${range[1]} trên tổng ${total2}`;
88
+ const totalPages = Math.ceil(total / pageSize);
89
+ const handleJump = () => {
90
+ const pageNumber = parseInt(jumpValue);
91
+ if (pageNumber && pageNumber >= 1 && pageNumber <= totalPages && pageNumber !== current) {
92
+ onChange?.(pageNumber, pageSize);
93
+ }
94
+ setJumpValue("");
95
+ };
96
+ const handleJumpKeyPress = (e) => {
97
+ if (e.key === "Enter") {
98
+ handleJump();
99
+ }
100
+ };
101
+ const handleJumpInputChange = (e) => {
102
+ const value = e.target.value;
103
+ if (value === "" || /^\d+$/.test(value) && parseInt(value) <= totalPages) {
104
+ setJumpValue(value);
105
+ }
106
+ };
107
+ const handleKeyDown = (e) => {
108
+ const allowedKeys = [
109
+ "Backspace",
110
+ "Delete",
111
+ "Tab",
112
+ "Escape",
113
+ "Enter",
114
+ "ArrowLeft",
115
+ "ArrowRight",
116
+ "ArrowUp",
117
+ "ArrowDown"
118
+ ];
119
+ if (!allowedKeys.includes(e.key) && !/^[0-9]$/.test(e.key)) {
120
+ e.preventDefault();
121
+ }
122
+ };
123
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between py-2", children: [
124
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
125
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 pnkx-default-select-container !w-fit !h-fit", children: /* @__PURE__ */ jsx(
126
+ Select,
127
+ {
128
+ value: pageSize.toString(),
129
+ onChange: (value) => {
130
+ const newSize = parseInt(value);
131
+ onShowSizeChange?.(current, newSize);
132
+ },
133
+ size: "small",
134
+ className: "min-w-16",
135
+ popupMatchSelectWidth: true,
136
+ getPopupContainer: (trigger) => trigger.parentElement,
137
+ children: pageSizeOptions.map((option) => /* @__PURE__ */ jsx(Option, { value: option, children: option }, option))
138
+ }
139
+ ) }),
140
+ showTotal && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-600", children: showTotal(total, [
141
+ (current - 1) * pageSize + 1,
142
+ Math.min(current * pageSize, total)
143
+ ]) })
144
+ ] }),
145
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
146
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
147
+ /* @__PURE__ */ jsx(Typography.Text, { className: "text-sm text-gray-600 whitespace-nowrap", children: "Xem trang" }),
148
+ /* @__PURE__ */ jsx(
149
+ Input,
150
+ {
151
+ value: jumpValue,
152
+ onChange: handleJumpInputChange,
153
+ onKeyUp: handleJumpKeyPress,
154
+ onKeyDown: handleKeyDown,
155
+ onBlur: handleJump,
156
+ placeholder: current.toString(),
157
+ size: "small",
158
+ className: "text-center w-10! !border-[#bde3ff]",
159
+ type: "text",
160
+ min: 1,
161
+ max: totalPages
162
+ }
163
+ )
164
+ ] }),
165
+ /* @__PURE__ */ jsx(
166
+ Pagination,
167
+ {
168
+ current,
169
+ pageSize,
170
+ total,
171
+ onChange,
172
+ size,
173
+ showQuickJumper: false,
174
+ showSizeChanger: false,
175
+ ...rest
176
+ }
177
+ )
178
+ ] })
179
+ ] });
180
+ };
181
+
182
+ const useTableHeightWrapper = (options = {}) => {
183
+ const {
184
+ tableContainerId = "table_content",
185
+ extraOffset = 24,
186
+ // Layout padding bottom mặc định
187
+ minHeight = 200
188
+ } = options;
189
+ const [tableHeight, setTableHeight] = useState(minHeight);
190
+ const calculateTableHeight = useCallback(() => {
191
+ try {
192
+ const viewportHeight = window.innerHeight;
193
+ const layoutWrapper = document.getElementById("layout-wrapper-table");
194
+ if (!layoutWrapper) {
195
+ console.error("Layout wrapper table container not found");
196
+ setTableHeight(minHeight);
197
+ return;
198
+ }
199
+ const wrapperRect = layoutWrapper.getBoundingClientRect();
200
+ const availableHeight = viewportHeight - wrapperRect.top;
201
+ const tableContainer = document.getElementById(tableContainerId);
202
+ if (!tableContainer) {
203
+ console.error(`Table container "${tableContainerId}" not found`);
204
+ setTableHeight(minHeight);
205
+ return;
206
+ }
207
+ const directChildren = Array.from(layoutWrapper.children);
208
+ let otherElementsHeight = 0;
209
+ directChildren.forEach((child) => {
210
+ const rect = child.getBoundingClientRect();
211
+ const styles = window.getComputedStyle(child);
212
+ const marginTop = parseInt(styles.marginTop, 10) || 0;
213
+ const marginBottom = parseInt(styles.marginBottom, 10) || 0;
214
+ const totalHeight = rect.height + marginTop + marginBottom;
215
+ const isTableContent = child.id === tableContainerId;
216
+ const isBulkActionTable = child.id === "bulkaction_table";
217
+ if (!isTableContent && !isBulkActionTable) {
218
+ otherElementsHeight += totalHeight;
219
+ }
220
+ });
221
+ const tableStyles = window.getComputedStyle(tableContainer);
222
+ const tablePaddingTop = parseInt(tableStyles.paddingTop, 10) || 0;
223
+ const tablePaddingBottom = parseInt(tableStyles.paddingBottom, 10) || 0;
224
+ const tableHeader = tableContainer.querySelector(".ant-table-header");
225
+ const headerHeight = tableHeader ? tableHeader.getBoundingClientRect().height : 0;
226
+ let paginationHeight = 0;
227
+ const paginationSelectors = [
228
+ ".ant-pagination",
229
+ ".ant-table-pagination",
230
+ ".ant-pagination-mini"
231
+ ];
232
+ for (const selector of paginationSelectors) {
233
+ const pagination = tableContainer.querySelector(selector);
234
+ if (pagination) {
235
+ const paginationRect = pagination.getBoundingClientRect();
236
+ const paginationStyles = window.getComputedStyle(pagination);
237
+ const paginationMarginTop = parseInt(paginationStyles.marginTop, 10) || 0;
238
+ const paginationMarginBottom = parseInt(paginationStyles.marginBottom, 10) || 0;
239
+ paginationHeight = paginationRect.height + paginationMarginTop + paginationMarginBottom;
240
+ break;
241
+ }
242
+ }
243
+ if (paginationHeight === 0) {
244
+ paginationHeight = 44;
245
+ }
246
+ const bulkActionHeight = 0;
247
+ const tableBodyHeight = availableHeight - otherElementsHeight - tablePaddingTop - tablePaddingBottom - headerHeight - paginationHeight - bulkActionHeight - extraOffset;
248
+ const finalHeight = Math.max(tableBodyHeight, minHeight);
249
+ setTableHeight(finalHeight);
250
+ } catch (error) {
251
+ console.error("Error calculating table height:", error);
252
+ setTableHeight(minHeight);
253
+ }
254
+ }, [tableContainerId, extraOffset, minHeight]);
255
+ useEffect(() => {
256
+ const timer = setTimeout(() => {
257
+ calculateTableHeight();
258
+ }, 300);
259
+ const handleResize = () => {
260
+ calculateTableHeight();
261
+ };
262
+ window.addEventListener("resize", handleResize);
263
+ const observer = new MutationObserver((mutations) => {
264
+ let shouldRecalculate = false;
265
+ mutations.forEach((mutation) => {
266
+ if (mutation.type === "childList") {
267
+ shouldRecalculate = true;
268
+ }
269
+ });
270
+ if (shouldRecalculate) {
271
+ setTimeout(calculateTableHeight, 100);
272
+ }
273
+ });
274
+ const layoutWrapper = document.getElementById("layout-wrapper-table");
275
+ const tableContainer = document.getElementById(tableContainerId);
276
+ if (layoutWrapper) {
277
+ observer.observe(layoutWrapper, {
278
+ childList: true,
279
+ subtree: true,
280
+ attributes: true,
281
+ attributeFilter: ["style", "class"]
282
+ });
283
+ }
284
+ if (tableContainer && tableContainer !== layoutWrapper) {
285
+ observer.observe(tableContainer, {
286
+ childList: true,
287
+ subtree: true,
288
+ attributes: true,
289
+ attributeFilter: ["style", "class"]
290
+ });
291
+ }
292
+ return () => {
293
+ clearTimeout(timer);
294
+ window.removeEventListener("resize", handleResize);
295
+ observer.disconnect();
296
+ };
297
+ }, [calculateTableHeight, tableContainerId]);
298
+ return {
299
+ tableHeight,
300
+ recalculate: calculateTableHeight
301
+ };
302
+ };
303
+
304
+ const Table = ({
305
+ dataSource = [],
306
+ columns,
307
+ loading = false,
308
+ totalItems = 100,
309
+ filters,
310
+ onChangePage,
311
+ onChangePageSize,
312
+ onSort,
313
+ rowsSelected,
314
+ onSelect,
315
+ onRowClick,
316
+ rowKey = "id",
317
+ showIndexColumn = true,
318
+ size = "small",
319
+ defaultEllipsis = true,
320
+ onDoubleClickRow,
321
+ handleSubmit,
322
+ ...rest
323
+ }) => {
324
+ const status = filters?.status;
325
+ //! State
326
+ const tableContainerRef = useRef(null);
327
+ const rowSelection = {
328
+ selectedRowKeys: rowsSelected,
329
+ onChange: onSelect,
330
+ getCheckboxProps: () => ({
331
+ disabled: status === TypeStatusTable.ALL
332
+ })
333
+ };
334
+ const ellipsisColumns = columns.map((column) => ({
335
+ ...column,
336
+ ellipsis: column?.ellipsis !== void 0 ? column?.ellipsis : defaultEllipsis
337
+ }));
338
+ const startIndex = (filters.page - 1) * filters.size;
339
+ const columnsWithIndex = showIndexColumn ? [
340
+ {
341
+ title: "STT",
342
+ dataIndex: "index",
343
+ key: "index",
344
+ width: 70,
345
+ align: "center",
346
+ render: (_, __, index) => startIndex + index + 1
347
+ },
348
+ ...ellipsisColumns
349
+ ] : ellipsisColumns;
350
+ //! Function
351
+ const renderSizePagination = () => {
352
+ switch (size) {
353
+ case "small":
354
+ return "small";
355
+ // Dạng nhỏ gọn
356
+ default:
357
+ return "default";
358
+ }
359
+ };
360
+ const handleTableChange = (_pagination, _filters, sorter) => {
361
+ if (sorter && onSort) {
362
+ onSort(sorter);
363
+ }
364
+ };
365
+ const handleOnClickRow = (record, onRowClick2) => (e) => {
366
+ const target = e.target;
367
+ if (target.closest("input") || // ⛔ Checkbox
368
+ target.closest("button") || // ⛔ Button trong row
369
+ target.closest("svg") || // ⛔ Icon
370
+ target.closest(".ant-checkbox") || // ⛔ AntD checkbox
371
+ target.closest("a")) {
372
+ return;
373
+ }
374
+ onRowClick2?.(record);
375
+ };
376
+ const handleDoubleClickRow = (record, onDoubleClickRow2) => (e) => {
377
+ const target = e.target;
378
+ if (target.closest("input") || // ⛔ Checkbox
379
+ target.closest("button") || // ⛔ Button trong row
380
+ target.closest("svg") || // ⛔ Icon
381
+ target.closest(".ant-checkbox") || // ⛔ AntD checkbox
382
+ target.closest("a")) {
383
+ return;
384
+ }
385
+ onDoubleClickRow2?.(record);
386
+ };
387
+ const { tableHeight } = useTableHeightWrapper({
388
+ tableContainerId: "table_content",
389
+ // ID của table container
390
+ minHeight: 200
391
+ // chiều cao tối thiểu
392
+ });
393
+ useEffect(() => {
394
+ const scrollToTop = () => {
395
+ if (tableContainerRef.current) {
396
+ const tableBody = tableContainerRef.current.querySelector(".ant-table-body");
397
+ if (tableBody) {
398
+ tableBody.scrollTop = 0;
399
+ }
400
+ }
401
+ };
402
+ const timeoutId = setTimeout(scrollToTop, 0);
403
+ return () => clearTimeout(timeoutId);
404
+ }, [filters.page]);
405
+ const tableContent = /* @__PURE__ */ jsxs(
406
+ "div",
407
+ {
408
+ ref: tableContainerRef,
409
+ id: "table_content",
410
+ className: "bg-[#FFFFFF] p-2 rounded-bl-lg rounded-br-lg",
411
+ children: [
412
+ /* @__PURE__ */ jsx(
413
+ Table$1,
414
+ {
415
+ rowKey,
416
+ dataSource,
417
+ columns: columnsWithIndex,
418
+ pagination: false,
419
+ loading,
420
+ rowSelection: rowsSelected ? rowSelection : void 0,
421
+ onChange: handleTableChange,
422
+ onRow: (record) => ({
423
+ onClick: handleOnClickRow(record, onRowClick),
424
+ onDoubleClick: handleDoubleClickRow(record, onDoubleClickRow)
425
+ }),
426
+ locale: {
427
+ emptyText: loading ? null : /* @__PURE__ */ jsx(EmptyTable, {})
428
+ },
429
+ scroll: { y: tableHeight },
430
+ size,
431
+ ...rest,
432
+ className: "table-scroll-bar"
433
+ }
434
+ ),
435
+ /* @__PURE__ */ jsx(
436
+ CustomPagination,
437
+ {
438
+ current: filters?.page,
439
+ pageSize: filters?.size,
440
+ total: totalItems,
441
+ onChange: (page) => onChangePage(page),
442
+ onShowSizeChange: (_, size2) => onChangePageSize(size2),
443
+ size: renderSizePagination()
444
+ }
445
+ )
446
+ ]
447
+ }
448
+ );
449
+ const renderTable = () => {
450
+ if (handleSubmit) {
451
+ return /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, children: tableContent });
452
+ }
453
+ return tableContent;
454
+ };
455
+ //! Render
456
+ return renderTable();
457
+ };
458
+ const EmptyTable = () => {
459
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center text-center", children: [
460
+ /* @__PURE__ */ jsx("img", { src: iconTableNoData, alt: "no data" }),
461
+ /* @__PURE__ */ jsx("span", { className: "text-lg font-bold text-black", children: "Không có dữ liệu nào phù hợp" }),
462
+ /* @__PURE__ */ jsx("p", { className: "text-gray-500", children: "Kiểm tra lại bộ lọc hoặc thêm mới dữ liệu" })
463
+ ] });
464
+ };
465
+
466
+ const EditIcon = ({ stroke, fill = "#007BE5" }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 14, height: 15, fill: "none", children: /* @__PURE__ */ jsx(
467
+ "path",
468
+ {
469
+ fill,
470
+ stroke,
471
+ d: "m1.177 11.137.711.237-.711-.237ZM1.8 9.264l-.712-.238.712.238Zm.644-1.043.53.53-.53-.53ZM8.667 2l-.53-.53.53.53ZM12 5.333l.53.53-.53-.53Zm-6.222 6.222-.53-.53.53.53Zm-1.042.644.237.711-.237-.711Zm-1.873.624.237.712-.237-.712Zm2.574-.95-.452-.598.452.599Zm-.263.163-.333-.672.333.672Zm7.629-9.11-.672.333.672-.333Zm0 1.48-.672-.333.672.333Zm-3.21-3.21.333.673-.333-.672Zm1.48 0-.333.673.333-.672Zm-9.11 7.63.673.333-.672-.333Zm.163-.263-.599-.452.6.452Zm-1.26 4.066-.706.252.706-.252Zm.505.505-.252.706.252-.706ZM8.364 2.303a.75.75 0 0 0-1.061 1.06l1.06-1.06Zm2.272 4.394a.75.75 0 0 0 1.061-1.06l-1.06 1.06ZM7 12.917a.75.75 0 0 0 0 1.5v-1.5Zm5.833 1.5a.75.75 0 0 0 0-1.5v1.5Zm-11.656-3.28.711.237.624-1.873-.711-.237-.712-.238L.465 10.9l.712.238ZM2.445 8.22l.53.53 6.222-6.22L8.667 2l-.53-.53-6.222 6.22.53.531ZM12 5.333l-.53-.53-6.222 6.221.53.53.53.53 6.222-6.22-.53-.53ZM4.736 12.2l-.237-.712-1.873.625.237.711.237.712 1.873-.625-.237-.711Zm1.042-.644-.53-.53c-.18.18-.222.219-.263.25l.452.599.451.598c.144-.108.269-.235.42-.387l-.53-.53Zm-1.042.644.237.711c.204-.068.373-.122.535-.202l-.334-.672-.333-.672c-.047.023-.1.043-.342.123l.237.712Zm.7-.325-.451-.6a.92.92 0 0 1-.144.09l.333.672.334.672c.134-.067.261-.146.38-.236l-.451-.598ZM12 2l-.53.53c.497.497.608.622.661.73l.672-.334.672-.333c-.19-.383-.533-.712-.945-1.124L12 2Zm0 3.333.53.53c.412-.411.755-.74.945-1.124l-.672-.333-.672-.333c-.053.107-.164.233-.661.73l.53.53Zm.803-2.407-.672.333a.917.917 0 0 1 0 .814l.672.333.672.333a2.417 2.417 0 0 0 0-2.146l-.672.333ZM8.667 2l.53.53c.497-.497.622-.608.73-.661l-.334-.672L9.26.525c-.383.19-.712.533-1.124.944l.53.53ZM12 2l.53-.53c-.411-.412-.74-.755-1.124-.945l-.333.672-.333.672c.107.053.232.164.73.661L12 2Zm-2.407-.803.333.672a.917.917 0 0 1 .814 0l.333-.672.333-.672a2.417 2.417 0 0 0-2.146 0l.333.672ZM1.801 9.264l.711.237c.081-.242.1-.295.124-.342l-.672-.333-.672-.334c-.08.161-.135.33-.203.534l.712.238Zm.644-1.043-.53-.53c-.152.152-.279.276-.388.42l.6.452.598.452a2.99 2.99 0 0 1 .25-.263l-.53-.53Zm-.481.605.672.333c.025-.05.055-.1.089-.144l-.599-.452-.599-.452c-.09.12-.168.247-.235.381l.672.334Zm-.787 2.31L.465 10.9c-.13.393-.246.737-.312 1.016-.063.267-.118.617.007.966l.706-.252.706-.252c.028.078-.007.088.041-.119.046-.196.135-.463.275-.884l-.711-.237Zm1.686 1.687-.237-.711c-.421.14-.688.228-.884.274-.208.049-.197.014-.12.041l-.251.707-.252.706c.349.124.698.07.966.007.278-.066.622-.181 1.015-.312l-.237-.712ZM.866 12.63l-.706.252c.16.447.511.8.96.96l.251-.707.252-.707a.083.083 0 0 1-.05-.05l-.707.252Zm6.967-9.796-.53.53 3.333 3.334.53-.53.531-.53-3.333-3.334-.53.53ZM7 13.666v.75h5.833v-1.5H7v.75Z"
472
+ }
473
+ ) });
474
+
475
+ const RestoreIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
476
+ "path",
477
+ {
478
+ stroke,
479
+ fill,
480
+ strokeLinecap: "round",
481
+ strokeLinejoin: "round",
482
+ strokeWidth: 1.5,
483
+ d: "M3.405 6.611a8.824 8.824 0 0 1 7.64-4.388c3.701 0 6.87 2.269 8.179 5.486m-13.14 0h-4.41V3.32m16.92 12.069a8.824 8.824 0 0 1-7.64 4.388 8.822 8.822 0 0 1-8.178-5.486m13.14 0h4.41v4.389"
484
+ }
485
+ ) });
486
+
487
+ const SendApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
488
+ "path",
489
+ {
490
+ fill,
491
+ stroke,
492
+ strokeLinecap: "round",
493
+ strokeWidth: 1.714,
494
+ d: "M6.44 11h4.45m-4.584-.521L2.912 4.37c-.513-.922.474-1.953 1.419-1.481l14.304 7.15a1.073 1.073 0 0 1 0 1.92L4.33 19.11c-.945.472-1.932-.559-1.42-1.482l3.395-6.107c.18-.324.18-.718 0-1.042Z"
495
+ }
496
+ ) });
497
+
498
+ const CancelSendApprovalIcon = ({ fill, stroke }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
499
+ "path",
500
+ {
501
+ fill,
502
+ stroke,
503
+ strokeLinecap: "round",
504
+ strokeWidth: 1.5,
505
+ d: "M12.829 7.343 9.17 14.657M20.143 11a9.143 9.143 0 1 1-18.286 0 9.143 9.143 0 0 1 18.286 0Z"
506
+ }
507
+ ) });
508
+
509
+ const ApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
510
+ "path",
511
+ {
512
+ fill,
513
+ stroke,
514
+ strokeLinecap: "round",
515
+ strokeWidth: 1.714,
516
+ d: "m15.33 6.429-8.667 8.89a.827.827 0 0 1-1.19 0L1.856 11.61m9.618 3.707 8.668-8.89"
517
+ }
518
+ ) });
519
+
520
+ const CancelApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
521
+ "path",
522
+ {
523
+ fill,
524
+ stroke,
525
+ strokeLinecap: "round",
526
+ strokeWidth: 1.5,
527
+ d: "M13.743 8.257 11 11m0 0-2.743 2.743M11 11l2.743 2.743M11 11 8.257 8.257M20.143 11a9.143 9.143 0 1 1-18.286 0 9.143 9.143 0 0 1 18.286 0Z"
528
+ }
529
+ ) });
530
+
531
+ const RefuseApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: [
532
+ /* @__PURE__ */ jsx("mask", { id: "a", fill: "#fff", children: /* @__PURE__ */ jsx("path", { d: "M11 2.086A8.914 8.914 0 1 0 19.914 11 8.924 8.924 0 0 0 11 2.086ZM18.543 11a7.505 7.505 0 0 1-1.75 4.824L6.176 5.206A7.543 7.543 0 0 1 18.543 11ZM3.457 11a7.505 7.505 0 0 1 1.75-4.824l10.617 10.618A7.544 7.544 0 0 1 3.457 11Z" }) }),
533
+ /* @__PURE__ */ jsx(
534
+ "path",
535
+ {
536
+ fill: "#fff",
537
+ d: "M11 2.086A8.914 8.914 0 1 0 19.914 11 8.924 8.924 0 0 0 11 2.086ZM18.543 11a7.505 7.505 0 0 1-1.75 4.824L6.176 5.206A7.543 7.543 0 0 1 18.543 11ZM3.457 11a7.505 7.505 0 0 1 1.75-4.824l10.617 10.618A7.544 7.544 0 0 1 3.457 11Z"
538
+ }
539
+ ),
540
+ /* @__PURE__ */ jsx(
541
+ "path",
542
+ {
543
+ fill,
544
+ stroke,
545
+ d: "m11 2.086.002-1.714H11v1.714ZM19.914 11h1.715v-.002L19.914 11Zm-1.371 0-1.714.001h1.714Zm-1.75 4.824-1.212 1.212 1.325 1.325 1.202-1.437-1.315-1.1ZM6.176 5.206 5.08 3.888 3.635 5.089l1.329 1.329 1.212-1.212ZM3.457 11h1.714v-.002L3.457 11Zm1.75-4.824 1.212-1.212-1.325-1.325-1.202 1.437 1.315 1.1Zm10.617 10.618 1.096 1.318 1.445-1.201-1.329-1.329-1.212 1.212ZM11 2.086V.372c-2.102 0-4.157.623-5.905 1.79l.952 1.426L7 5.014A7.2 7.2 0 0 1 11 3.8V2.086ZM6.047 3.588l-.952-1.425a10.629 10.629 0 0 0-3.915 4.77l1.584.656 1.584.656A7.2 7.2 0 0 1 7 5.014l-.953-1.426Zm-3.283 4L1.18 6.934a10.629 10.629 0 0 0-.604 6.14l1.681-.334 1.681-.334a7.2 7.2 0 0 1 .41-4.16l-1.584-.656Zm-.507 5.151-1.681.335a10.628 10.628 0 0 0 2.908 5.442l1.213-1.212 1.212-1.213a7.2 7.2 0 0 1-1.97-3.686l-1.682.334Zm2.44 4.564-1.213 1.213a10.628 10.628 0 0 0 5.442 2.908l.335-1.68.334-1.682a7.201 7.201 0 0 1-3.686-1.97l-1.212 1.212Zm4.564 2.44-.335 1.681c2.062.41 4.2.2 6.141-.604l-.656-1.584-.656-1.584a7.2 7.2 0 0 1-4.16.41l-.334 1.681Zm5.15-.507.656 1.584a10.628 10.628 0 0 0 4.77-3.915l-1.425-.952L16.987 15a7.2 7.2 0 0 1-3.232 2.652l.656 1.584Zm4-3.283 1.426.952A10.628 10.628 0 0 0 21.63 11H18.2a7.2 7.2 0 0 1-1.213 4l1.425.953ZM19.915 11l1.715-.002a10.638 10.638 0 0 0-3.116-7.51L17.3 4.7l-1.213 1.212a7.21 7.21 0 0 1 2.112 5.09L19.914 11Zm-2.613-6.3 1.212-1.213A10.638 10.638 0 0 0 11.002.372L11 2.086 10.998 3.8a7.21 7.21 0 0 1 5.09 2.112L17.301 4.7Zm1.242 6.3-1.714.002a5.79 5.79 0 0 1-1.35 3.722l1.314 1.1 1.315 1.1a9.22 9.22 0 0 0 2.15-5.926L18.542 11Zm-1.75 4.824 1.213-1.212L7.388 3.994 6.176 5.206 4.964 6.418 15.58 17.036l1.212-1.212ZM6.176 5.206l1.096 1.318a5.828 5.828 0 0 1 2.985-1.3l-.219-1.7-.219-1.701a9.257 9.257 0 0 0-4.74 2.065l1.097 1.318Zm3.862-1.683.219 1.7a5.828 5.828 0 0 1 3.216.503l.727-1.552.728-1.552a9.257 9.257 0 0 0-5.109-.8l.22 1.701Zm4.162.651-.727 1.552a5.829 5.829 0 0 1 2.445 2.15l1.446-.92 1.447-.92a9.257 9.257 0 0 0-3.883-3.414L14.2 4.174Zm3.164 2.782-1.446.92c.594.934.91 2.018.91 3.125h1.715l1.714-.002a9.257 9.257 0 0 0-1.447-4.964l-1.446.92ZM3.457 11l1.714-.002a5.79 5.79 0 0 1 1.35-3.722l-1.314-1.1-1.315-1.1a9.22 9.22 0 0 0-2.15 5.926L3.458 11Zm1.75-4.824L3.994 7.388l10.618 10.618 1.212-1.212 1.212-1.212L6.42 4.964 5.207 6.176Zm10.617 10.618-1.096-1.318a5.828 5.828 0 0 1-2.985 1.3l.219 1.701.219 1.7a9.257 9.257 0 0 0 4.74-2.065l-1.097-1.318Zm-3.862 1.683-.219-1.7a5.829 5.829 0 0 1-3.216-.503L7.8 17.826l-.728 1.552a9.257 9.257 0 0 0 5.109.8l-.22-1.7Zm-4.162-.65.727-1.553a5.83 5.83 0 0 1-2.445-2.15l-1.446.92-1.447.92a9.257 9.257 0 0 0 3.883 3.414l.728-1.552Zm-3.164-2.782 1.446-.92a5.829 5.829 0 0 1-.91-3.126L3.456 11l-1.714.001a9.257 9.257 0 0 0 1.446 4.964l1.447-.92Z",
546
+ mask: "url(#a)"
547
+ }
548
+ )
549
+ ] });
550
+
551
+ const ActivateIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
552
+ "path",
553
+ {
554
+ fill,
555
+ stroke,
556
+ strokeLinecap: "round",
557
+ strokeWidth: 1.714,
558
+ d: "M14.657 8.257V6.43a3.657 3.657 0 0 0-6.076-2.743M7.526 19.229h6.948c1.024 0 1.536 0 1.927-.2.345-.175.624-.455.8-.799.199-.391.199-.903.199-1.927v-5.12c0-1.024 0-1.536-.2-1.928a1.83 1.83 0 0 0-.799-.799c-.39-.199-.903-.199-1.927-.199H7.526c-1.025 0-1.537 0-1.928.2a1.829 1.829 0 0 0-.799.798c-.2.392-.2.904-.2 1.928v5.12c0 1.024 0 1.536.2 1.927.175.344.455.624.8.8.39.198.902.198 1.927.198Z"
559
+ }
560
+ ) });
561
+
562
+ const DeleteIcon = ({ stroke, fill = "#DD4338" }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 23, height: 24, fill: "none", children: /* @__PURE__ */ jsx(
563
+ "path",
564
+ {
565
+ fill,
566
+ stroke,
567
+ d: "m18.219 17.634.75.006-.75-.006ZM4.319 5.65a.75.75 0 1 0 0 1.5v-1.5Zm14.934 1.5a.75.75 0 0 0 0-1.5v1.5Zm-8.584 2.984a.75.75 0 1 0-1.5 0h1.5ZM9.17 17.6a.75.75 0 0 0 1.5 0h-1.5Zm5.234-7.466a.75.75 0 1 0-1.5 0h1.5Zm-1.5 7.466a.75.75 0 0 0 1.5 0h-1.5Zm5.416-11.2-.75-.006-.1 11.233.75.007.75.006.1-11.233-.75-.007Zm-3.833 14.934v-.75h-5.5v1.5h5.5v-.75ZM5.253 6.4h-.75v11.2h1.5V6.4h-.75Zm-.934 0v.75h.934v-1.5h-.934v.75Zm.934 0v.75h2.8v-1.5h-2.8v.75Zm2.8 0v.75h7.466v-1.5H8.053v.75Zm7.466 0v.75h2.8v-1.5h-2.8v.75Zm2.8 0v.75h.934v-1.5h-.934v.75ZM8.053 5.985h.75c0-1.338 1.25-2.568 2.983-2.568v-1.5c-2.39 0-4.483 1.74-4.483 4.068h.75Zm3.733-3.318v.75c1.733 0 2.983 1.23 2.983 2.568h1.5c0-2.327-2.092-4.068-4.483-4.068v.75ZM8.053 5.985h-.75V6.4h1.5v-.415h-.75Zm7.466 0h-.75V6.4h1.5v-.415h-.75ZM8.986 21.334v-.75A2.983 2.983 0 0 1 6.003 17.6h-1.5a4.483 4.483 0 0 0 4.483 4.484v-.75Zm9.233-3.7-.75-.007a2.983 2.983 0 0 1-2.983 2.957v1.5a4.483 4.483 0 0 0 4.483-4.444l-.75-.006Zm-8.3-7.5h-.75V17.6h1.5v-7.466h-.75Zm3.734 0h-.75V17.6h1.5v-7.466h-.75Z"
568
+ }
569
+ ) });
570
+
571
+ const InActiveIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx(
572
+ "svg",
573
+ {
574
+ xmlns: "http://www.w3.org/2000/svg",
575
+ width: 22,
576
+ height: 22,
577
+ fill: "none",
578
+ children: /* @__PURE__ */ jsx(
579
+ "path",
580
+ {
581
+ fill,
582
+ stroke,
583
+ strokeLinecap: "round",
584
+ strokeWidth: 1.714,
585
+ d: "M7.343 8.257V6.43a3.657 3.657 0 0 1 7.314 0v1.828M7.526 19.23h6.948c1.024 0 1.536 0 1.927-.2.345-.175.624-.455.8-.799.199-.391.199-.903.199-1.927v-5.12c0-1.024 0-1.536-.2-1.928a1.83 1.83 0 0 0-.799-.799c-.39-.199-.903-.199-1.927-.199H7.526c-1.025 0-1.537 0-1.928.2a1.829 1.829 0 0 0-.799.798c-.2.392-.2.904-.2 1.928v5.12c0 1.024 0 1.536.2 1.927.175.344.455.624.8.8.39.198.902.198 1.927.198Z"
586
+ }
587
+ )
588
+ }
589
+ );
590
+
591
+ const MoreIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 18, height: 18, fill: "none", children: /* @__PURE__ */ jsx(
592
+ "path",
593
+ {
594
+ fill,
595
+ stroke,
596
+ fillRule: "evenodd",
597
+ d: "M4 8h2v2H4V8Zm4 0h2v2H8V8Zm4 0h2v2h-2V8Z",
598
+ clipRule: "evenodd"
599
+ }
600
+ ) });
601
+
602
+ const ActionRowTable = ({
603
+ type,
604
+ contentTooltip,
605
+ handleClick
606
+ }) => {
607
+ //! State
608
+ const {
609
+ shouldRender: shouldRenderDelete,
610
+ open: openDelete,
611
+ toggle: toggleDelete
612
+ } = useToggle();
613
+ //! Function
614
+ const handleDelete = () => {
615
+ handleClick?.();
616
+ toggleDelete();
617
+ };
618
+ const renderAction = () => {
619
+ switch (type) {
620
+ case TypeActionRowTable.EDIT:
621
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Tooltip, { title: contentTooltip, children: /* @__PURE__ */ jsx(
622
+ Button,
623
+ {
624
+ onClick: handleClick,
625
+ type: "text",
626
+ className: "cursor-pointer",
627
+ shape: "circle",
628
+ icon: /* @__PURE__ */ jsx(EditIcon, { fill: "#007BE5" })
629
+ }
630
+ ) }) });
631
+ case TypeActionRowTable.DELETE:
632
+ return /* @__PURE__ */ jsx(Tooltip, { title: contentTooltip, children: /* @__PURE__ */ jsx(
633
+ Button,
634
+ {
635
+ onClick: toggleDelete,
636
+ type: "text",
637
+ className: "cursor-pointer",
638
+ shape: "circle",
639
+ icon: /* @__PURE__ */ jsx(DeleteIcon, { fill: "#DD4338" })
640
+ }
641
+ ) });
642
+ }
643
+ };
644
+ //! Render
645
+ return /* @__PURE__ */ jsxs("div", { children: [
646
+ shouldRenderDelete && /* @__PURE__ */ jsx(
647
+ ConfirmModal,
648
+ {
649
+ title: "Xác nhận xóa",
650
+ content: "Bạn có chắc chắn muốn xóa không? Hành động này không thể hoàn tác.",
651
+ typeIcon: "error",
652
+ open: openDelete,
653
+ handleCancel: toggleDelete,
654
+ handleSubmit: handleDelete
655
+ }
656
+ ),
657
+ renderAction()
658
+ ] });
659
+ };
660
+
661
+ const BulkAction = ({
662
+ quantity = 0,
663
+ listIcon,
664
+ status,
665
+ setNotifyContent,
666
+ toggle
667
+ }) => {
668
+ //! State
669
+ //! Function
670
+ const IsShow = (arrStatus) => {
671
+ return arrStatus.includes(status);
672
+ };
673
+ //! Render
674
+ return /* @__PURE__ */ jsx("div", { className: "w-full flex justify-center items-center", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 px-[10px] py-3 bg-[#2561ED] rounded-lg w-fit", children: [
675
+ /* @__PURE__ */ jsxs("div", { className: "text-white px-3", children: [
676
+ "Đã chọn: ",
677
+ quantity
678
+ ] }),
679
+ /* @__PURE__ */ jsx("div", { className: "h-5 border-l border-white mx-1" }),
680
+ /* @__PURE__ */ jsx("div", { className: "flex items-center space-x-3", children: !isEmpty(listIcon) && listIcon?.map(
681
+ (item, index) => IsShow(item?.arrShow) && /* @__PURE__ */ jsx(Tooltip, { title: item?.name, children: /* @__PURE__ */ jsx(
682
+ "button",
683
+ {
684
+ className: "p-1 rounded-sm transition duration-200 cursor-pointer hover:bg-[#1B4ACB] hover:rounded-sm",
685
+ onClick: () => {
686
+ toggle();
687
+ setNotifyContent({
688
+ title: item?.title || "",
689
+ content: item?.content || "",
690
+ typeIcon: item?.typeIcon,
691
+ handleCancel: () => {
692
+ toggle();
693
+ },
694
+ handleSubmit: () => {
695
+ if (item?.action) {
696
+ item?.action();
697
+ }
698
+ toggle();
699
+ }
700
+ });
701
+ },
702
+ children: item.icon
703
+ },
704
+ index
705
+ ) })
706
+ ) })
707
+ ] }) });
708
+ };
709
+
710
+ const DropListActions = ({
711
+ listIcon,
712
+ status,
713
+ setNotifyContent,
714
+ toggle
715
+ }) => {
716
+ //! State
717
+ //! Function
718
+ const IsShow = (arrStatus) => {
719
+ return arrStatus.includes(status);
720
+ };
721
+ const renderContentPopover = () => {
722
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: !isEmpty(listIcon) && listIcon?.map(
723
+ (item, index) => item?.showTitle && IsShow(item?.arrShow) && /* @__PURE__ */ jsxs(
724
+ "button",
725
+ {
726
+ className: twMerge(
727
+ "flex gap-4 px-3 py-2 rounded-sm transition duration-200 hover:rounded-sm",
728
+ IsShow(item?.arrShow) ? "hover:bg-[#F5F6F7] cursor-pointer" : "text-[#B2B7C2] cursor-not-allowed"
729
+ ),
730
+ disabled: IsShow(item?.arrShow) ? false : true,
731
+ onClick: () => {
732
+ toggle();
733
+ setNotifyContent({
734
+ title: item?.title || "",
735
+ content: item?.content || "",
736
+ typeIcon: item?.typeIcon,
737
+ handleCancel: () => {
738
+ toggle();
739
+ },
740
+ handleSubmit: () => {
741
+ if (item?.action) {
742
+ item?.action();
743
+ }
744
+ toggle();
745
+ }
746
+ });
747
+ },
748
+ children: [
749
+ item.iconDropList,
750
+ /* @__PURE__ */ jsx("span", { children: item.name || "" })
751
+ ]
752
+ },
753
+ index
754
+ )
755
+ ) });
756
+ };
757
+ //! Render
758
+ return /* @__PURE__ */ jsx("div", { className: "w-full flex justify-center items-center", children: /* @__PURE__ */ jsx(Tooltip$1, { title: "Thao tác khác", children: /* @__PURE__ */ jsx(
759
+ Popover,
760
+ {
761
+ placement: "bottom",
762
+ content: renderContentPopover(),
763
+ trigger: "click",
764
+ children: /* @__PURE__ */ jsx("div", { className: "p-1 border-[#BDE3FF] rounded-full border cursor-pointer", children: /* @__PURE__ */ jsx(MoreIcon, { fill: "#007BE5" }) })
765
+ }
766
+ ) }) });
767
+ };
768
+
769
+ const BulkActions = ({
770
+ quantity = 0,
771
+ handleDelete,
772
+ handleSubmitForApproval,
773
+ handleCancelSubmission,
774
+ handleApprove,
775
+ handleCancelApproval,
776
+ handleReject,
777
+ handleDeactivate,
778
+ handleActivate,
779
+ handleRestore,
780
+ status,
781
+ typeBulkaction,
782
+ isApproved = false
783
+ // Chỉ sử dụng khi là danh sách icon
784
+ }) => {
785
+ //! State
786
+ const listIcon = [
787
+ {
788
+ icon: /* @__PURE__ */ jsx(RestoreIcon, { stroke: "white" }),
789
+ iconDropList: /* @__PURE__ */ jsx(RestoreIcon, { stroke: "#0F1D40" }),
790
+ iconDisable: /* @__PURE__ */ jsx(RestoreIcon, { stroke: "#B2B7C2" }),
791
+ action: handleRestore,
792
+ name: "Khôi phục",
793
+ typeIcon: "info",
794
+ title: "Xác nhận khôi phục",
795
+ content: "Bạn có chắc chắn muốn khôi phục không?",
796
+ arrShow: [CATEGORY_LIST_ENUM?.DELETE, CATEGORY_LIST_ENUM?.REJECT],
797
+ showTitle: true
798
+ },
799
+ {
800
+ icon: /* @__PURE__ */ jsx(SendApprovalIcon, { stroke: "white" }),
801
+ iconDropList: /* @__PURE__ */ jsx(SendApprovalIcon, { stroke: "#0F1D40" }),
802
+ iconDisable: /* @__PURE__ */ jsx(SendApprovalIcon, { stroke: "#B2B7C2" }),
803
+ action: handleSubmitForApproval,
804
+ name: "Gửi duyệt",
805
+ typeIcon: "info",
806
+ title: "Xác nhận gửi duyệt",
807
+ content: "Bạn có chắc chắn muốn gửi duyệt không?",
808
+ arrShow: [CATEGORY_LIST_ENUM?.DRAFT],
809
+ showTitle: true
810
+ },
811
+ {
812
+ icon: /* @__PURE__ */ jsx(CancelSendApprovalIcon, { stroke: "white" }),
813
+ iconDropList: /* @__PURE__ */ jsx(CancelSendApprovalIcon, { stroke: "#0F1D40" }),
814
+ iconDisable: /* @__PURE__ */ jsx(CancelSendApprovalIcon, { stroke: "#B2B7C2" }),
815
+ action: handleCancelSubmission,
816
+ name: "Huỷ gửi duyệt",
817
+ typeIcon: "error",
818
+ title: "Xác nhận hủy gửi duyệt",
819
+ content: "Bạn có chắc chắn muốn hủy gửi duyệt không?",
820
+ arrShow: [CATEGORY_LIST_ENUM?.WATING_APPROVAL],
821
+ showTitle: true
822
+ },
823
+ {
824
+ icon: /* @__PURE__ */ jsx(RefuseApprovalIcon, { stroke: "white" }),
825
+ iconDropList: /* @__PURE__ */ jsx(RefuseApprovalIcon, { stroke: "#0F1D40" }),
826
+ iconDisable: /* @__PURE__ */ jsx(RefuseApprovalIcon, { stroke: "#B2B7C2" }),
827
+ action: handleReject,
828
+ name: "Từ chối duyệt",
829
+ typeIcon: "error",
830
+ title: "Xác nhận từ chối duyệt",
831
+ content: "Bạn có chắc chắn muốn từ chối duyệt không? Hành động này không thể hoàn tác.",
832
+ arrShow: [CATEGORY_LIST_ENUM?.WATING_APPROVAL],
833
+ showTitle: true
834
+ },
835
+ {
836
+ icon: /* @__PURE__ */ jsx(ApprovalIcon, { stroke: "white" }),
837
+ iconDropList: /* @__PURE__ */ jsx(ApprovalIcon, { stroke: "#0F1D40" }),
838
+ iconDisable: /* @__PURE__ */ jsx(ApprovalIcon, { stroke: "#B2B7C2" }),
839
+ action: handleApprove,
840
+ name: "Duyệt",
841
+ typeIcon: "info",
842
+ title: "Xác nhận duyệt",
843
+ content: "Bạn có chắc chắn muốn duyệt không?",
844
+ arrShow: [CATEGORY_LIST_ENUM?.WATING_APPROVAL],
845
+ showTitle: true
846
+ },
847
+ {
848
+ icon: /* @__PURE__ */ jsx(CancelApprovalIcon, { stroke: "white" }),
849
+ iconDropList: /* @__PURE__ */ jsx(CancelApprovalIcon, { stroke: "#0F1D40" }),
850
+ iconDisable: /* @__PURE__ */ jsx(CancelApprovalIcon, { stroke: "#B2B7C2" }),
851
+ action: handleCancelApproval,
852
+ typeIcon: "error",
853
+ name: "Hủy duyệt",
854
+ title: "Xác nhận hủy duyệt",
855
+ content: "Bạn có chắc chắn muốn hủy duyệt không?",
856
+ arrShow: isApproved ? [CATEGORY_LIST_ENUM?.ACTIVE] : [],
857
+ showTitle: true
858
+ },
859
+ {
860
+ icon: /* @__PURE__ */ jsx(DeleteIcon, { fill: "white" }),
861
+ iconDropList: /* @__PURE__ */ jsx(DeleteIcon, { fill: "#0F1D40" }),
862
+ iconDisable: /* @__PURE__ */ jsx(DeleteIcon, { fill: "#B2B7C2" }),
863
+ action: handleDelete,
864
+ typeIcon: "error",
865
+ name: "Xoá",
866
+ title: "Xác nhận xóa",
867
+ content: "Bạn có chắc chắn muốn xóa không? Hành động này không thể hoàn tác.",
868
+ arrShow: [
869
+ CATEGORY_LIST_ENUM?.DRAFT,
870
+ CATEGORY_LIST_ENUM?.ACTIVE,
871
+ CATEGORY_LIST_ENUM?.INACTIVE
872
+ ],
873
+ showTitle: false
874
+ },
875
+ {
876
+ icon: /* @__PURE__ */ jsx(ActivateIcon, { stroke: "white" }),
877
+ iconDropList: /* @__PURE__ */ jsx(ActivateIcon, { stroke: "#0F1D40" }),
878
+ iconDisable: /* @__PURE__ */ jsx(ActivateIcon, { stroke: "#B2B7C2" }),
879
+ action: handleActivate,
880
+ typeIcon: "info",
881
+ name: "Kích hoạt",
882
+ title: "Xác nhận kích hoạt",
883
+ content: "Bạn có chắc chắn muốn kích hoạt không?",
884
+ arrShow: [CATEGORY_LIST_ENUM?.INACTIVE],
885
+ showTitle: true
886
+ },
887
+ {
888
+ icon: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "white" }),
889
+ iconDropList: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "#0F1D40" }),
890
+ iconDisable: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "#B2B7C2" }),
891
+ action: handleDeactivate,
892
+ name: "Vô hiệu hóa",
893
+ typeIcon: "error",
894
+ title: "Xác nhận vô hiệu hóa",
895
+ content: "Bạn có chắc chắn muốn vô hiệu hóa không?",
896
+ arrShow: [CATEGORY_LIST_ENUM?.ACTIVE],
897
+ showTitle: true
898
+ }
899
+ ];
900
+ console.log("listIcon", listIcon);
901
+ const { open, shouldRender, toggle } = useToggle();
902
+ const [notifyContent, setNotifyContent] = useState({
903
+ title: "",
904
+ content: "",
905
+ typeIcon: "info",
906
+ handleCancel: () => {
907
+ },
908
+ handleSubmit: () => {
909
+ }
910
+ });
911
+ //! Function
912
+ const renderBulkActions = () => {
913
+ switch (typeBulkaction) {
914
+ case TypeBulkActions.BULKACTION:
915
+ return /* @__PURE__ */ jsx(
916
+ BulkAction,
917
+ {
918
+ listIcon,
919
+ quantity,
920
+ setNotifyContent,
921
+ toggle,
922
+ status
923
+ }
924
+ );
925
+ case TypeBulkActions.DROPLIST:
926
+ return /* @__PURE__ */ jsx(
927
+ DropListActions,
928
+ {
929
+ listIcon,
930
+ setNotifyContent,
931
+ toggle,
932
+ status
933
+ }
934
+ );
935
+ }
936
+ };
937
+ //! Render
938
+ return /* @__PURE__ */ jsxs("div", { children: [
939
+ renderBulkActions(),
940
+ shouldRender && /* @__PURE__ */ jsx(
941
+ ConfirmModal,
942
+ {
943
+ title: notifyContent?.title,
944
+ content: notifyContent?.content,
945
+ typeIcon: notifyContent?.typeIcon,
946
+ open,
947
+ handleCancel: notifyContent?.handleCancel,
948
+ handleSubmit: notifyContent?.handleSubmit
949
+ }
950
+ )
951
+ ] });
952
+ };
953
+
954
+ export { ActionRowTable, BulkActions, Button, CATEGORY_LIST_ENUM, ConfirmModal, Popover, Table, Tooltip, TypeActionRowTable, TypeBulkActions, TypeStatusTable, Typography };