@pnkx-lib/ui 1.9.327 → 1.9.328

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,18 +1,14 @@
1
- import { Button } from './Button.js';
1
+ export { Button } from './Button.js';
2
2
  export { CascaderField } from './Cascader.js';
3
3
  export { ErrorMessage } from './ErrorMessage.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';
4
+ export { Typography } from './Typography.js';
5
+ export { A as ActionRowTable, B as BulkActions, T as Table } from '../chunks/index-kvqVmred.js';
10
6
  export { Modal } from './Modal.js';
11
- import { Tooltip } from './Tooltip.js';
7
+ export { Tooltip } from './Tooltip.js';
12
8
  export { Tabs } from './Tabs.js';
13
9
  export { Label } from './Label.js';
14
10
  export { Skeleton } from './Skeleton.js';
15
- import { Popover } from './Popover.js';
11
+ export { Popover } from './Popover.js';
16
12
  export { SearchFiltersForm } from './SearchFilterForm.js';
17
13
  export { Container } from './Container.js';
18
14
  export { Badge, typeColorMap } from './Badge.js';
@@ -51,13 +47,9 @@ export { Collapse } from './Collapse.js';
51
47
  export { ColorPicker } from './ColorPicker.js';
52
48
  export { Empty } from './Empty.js';
53
49
  export { Image } from './Image.js';
54
- import { ConfirmModal } from './ConfirmModal.js';
50
+ export { ConfirmModal } from './ConfirmModal.js';
55
51
  export { ErrorBoundary } from './ErrorBoundary.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';
52
+ export { CATEGORY_LIST_ENUM, CategoryStatus, badgeStatusCategoryConfig } from './CategoryStatus.js';
61
53
  export { BreadcrumbHeading } from './BreadcrumbHeading.js';
62
54
  export { Card } from './Card.js';
63
55
  export { ConfigProvider } from './ConfigProvider.js';
@@ -67,887 +59,6 @@ export { UploadMultiple } from './UploadMultiple.js';
67
59
  export { ImportFile } from './ImportFile.js';
68
60
  export { ExportFile } from './ExportFile.js';
69
61
  export { UploadComponent } from './UploadComponent.js';
62
+ export { useMessage } from './Message.js';
70
63
  export { a as MAX_TAG_COUNT, M as MAX_TAG_TEXT_LENGTH, T as TINY_API } from '../chunks/common-BygVXrbX.js';
71
-
72
- const iconTableNoData = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAA7dSURBVHgB7Z1bbFTXFYb/PTO+gDFMApgQkngIvRAgwZFKlbRqPK5SqS+VjQQkSithPyQRVArQvFR5sa1ESlOlBV6KCJVsP6RtgAaTh6hVq86QNqKS02YI4NK0geNcgNikDAaDL3PO7lpnZowvczv7nBlfsj9pmNuxPZz/rLXXWnvtPYBGo9FoNBqNRqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDSaghAoMsEOGeS71NN4vEXEoSkZRRE4eEiGTYntkGjCbXHTGPRXo36BrvjTIgpNUfFUYBbWstAhgVCBP2L4LTTEdwgDmqxELpAXrESwYaXz8+SDRyw+KPeaFiIOxGVCpg8XFh+SrdBkxe9H2D9qe0PHeCJw9WuSrXY3FJEW2rTIOWkkX9sIBVwLbAsj0QyX2CIflMoXyTyHrTdsu2qHuBI4eFA2sTDwCPICrcEDMgTNOO98LMcDVb/PuSEF4AIL2AtvCcqRax33bHiyPdObUvriZWU3DSPW/aVItf76iQxLiV3p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luBVZCzwHcCOyFniOoCqyFngOoSKyFniO4VRkLfAcxInIWuA5SkEil+NhLfAcJq/IAi3ztmXnywB/vxR/LUK29/0ScS3wHCeHyHFYiGmB5wEssgXsmfBlKAZ/TZEXX3aimWXwt9FBo9FoNBqNRqPRaDQajUaj0Wg0Go1Go9FoNBqNRqPRaDQajXP+D0/tlZm0R8ESAAAAAElFTkSuQmCC";
73
-
74
- const { Option } = Select;
75
- const CustomPagination = ({
76
- current = 1,
77
- pageSize = 10,
78
- total = 0,
79
- pageSizeOptions = ["10", "50", "100", "150", "200"],
80
- onChange,
81
- onShowSizeChange,
82
- size,
83
- ...rest
84
- }) => {
85
- const [jumpValue, setJumpValue] = useState("");
86
- const showTotal = (total2, range) => `${range[0]}-${range[1]} trên tổng ${total2}`;
87
- const totalPages = Math.ceil(total / pageSize);
88
- const handleJump = () => {
89
- const pageNumber = parseInt(jumpValue);
90
- if (pageNumber && pageNumber >= 1 && pageNumber <= totalPages && pageNumber !== current) {
91
- onChange?.(pageNumber, pageSize);
92
- }
93
- setJumpValue("");
94
- };
95
- const handleJumpKeyPress = (e) => {
96
- if (e.key === "Enter") {
97
- handleJump();
98
- }
99
- };
100
- const handleJumpInputChange = (e) => {
101
- const value = e.target.value;
102
- if (value === "" || /^\d+$/.test(value) && parseInt(value) <= totalPages) {
103
- setJumpValue(value);
104
- }
105
- };
106
- const handleKeyDown = (e) => {
107
- const allowedKeys = [
108
- "Backspace",
109
- "Delete",
110
- "Tab",
111
- "Escape",
112
- "Enter",
113
- "ArrowLeft",
114
- "ArrowRight",
115
- "ArrowUp",
116
- "ArrowDown"
117
- ];
118
- if (!allowedKeys.includes(e.key) && !/^[0-9]$/.test(e.key)) {
119
- e.preventDefault();
120
- }
121
- };
122
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between py-2", children: [
123
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
124
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 pnkx-default-select-container !w-fit !h-fit", children: /* @__PURE__ */ jsx(
125
- Select,
126
- {
127
- value: pageSize.toString(),
128
- onChange: (value) => {
129
- const newSize = parseInt(value);
130
- onShowSizeChange?.(current, newSize);
131
- },
132
- size: "small",
133
- className: "min-w-16",
134
- popupMatchSelectWidth: true,
135
- getPopupContainer: (trigger) => trigger.parentElement,
136
- children: pageSizeOptions.map((option) => /* @__PURE__ */ jsx(Option, { value: option, children: option }, option))
137
- }
138
- ) }),
139
- showTotal && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-600", children: showTotal(total, [
140
- (current - 1) * pageSize + 1,
141
- Math.min(current * pageSize, total)
142
- ]) })
143
- ] }),
144
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
145
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
146
- /* @__PURE__ */ jsx(Typography.Text, { className: "text-sm text-gray-600 whitespace-nowrap", children: "Xem trang" }),
147
- /* @__PURE__ */ jsx(
148
- Input,
149
- {
150
- value: jumpValue,
151
- onChange: handleJumpInputChange,
152
- onKeyUp: handleJumpKeyPress,
153
- onKeyDown: handleKeyDown,
154
- onBlur: handleJump,
155
- placeholder: current.toString(),
156
- size: "small",
157
- className: "text-center w-10! !border-[#bde3ff]",
158
- type: "text",
159
- min: 1,
160
- max: totalPages
161
- }
162
- )
163
- ] }),
164
- /* @__PURE__ */ jsx(
165
- Pagination,
166
- {
167
- current,
168
- pageSize,
169
- total,
170
- onChange,
171
- size,
172
- showQuickJumper: false,
173
- showSizeChanger: false,
174
- ...rest
175
- }
176
- )
177
- ] })
178
- ] });
179
- };
180
-
181
- const useTableHeightWrapper = (options = {}) => {
182
- const {
183
- tableContainerId = "table_content",
184
- extraOffset = 24,
185
- // Layout padding bottom mặc định
186
- minHeight = 200
187
- } = options;
188
- const [tableHeight, setTableHeight] = useState(minHeight);
189
- const calculateTableHeight = useCallback(() => {
190
- try {
191
- const viewportHeight = window.innerHeight;
192
- const layoutWrapper = document.getElementById("layout-wrapper-table");
193
- if (!layoutWrapper) {
194
- console.error("Layout wrapper table container not found");
195
- setTableHeight(minHeight);
196
- return;
197
- }
198
- const wrapperRect = layoutWrapper.getBoundingClientRect();
199
- const availableHeight = viewportHeight - wrapperRect.top;
200
- const tableContainer = document.getElementById(tableContainerId);
201
- if (!tableContainer) {
202
- console.error(`Table container "${tableContainerId}" not found`);
203
- setTableHeight(minHeight);
204
- return;
205
- }
206
- const directChildren = Array.from(layoutWrapper.children);
207
- let otherElementsHeight = 0;
208
- directChildren.forEach((child) => {
209
- const rect = child.getBoundingClientRect();
210
- const styles = window.getComputedStyle(child);
211
- const marginTop = parseInt(styles.marginTop, 10) || 0;
212
- const marginBottom = parseInt(styles.marginBottom, 10) || 0;
213
- const totalHeight = rect.height + marginTop + marginBottom;
214
- const isTableContent = child.id === tableContainerId;
215
- const isBulkActionTable = child.id === "bulkaction_table";
216
- if (!isTableContent && !isBulkActionTable) {
217
- otherElementsHeight += totalHeight;
218
- }
219
- });
220
- const tableStyles = window.getComputedStyle(tableContainer);
221
- const tablePaddingTop = parseInt(tableStyles.paddingTop, 10) || 0;
222
- const tablePaddingBottom = parseInt(tableStyles.paddingBottom, 10) || 0;
223
- const tableHeader = tableContainer.querySelector(".ant-table-header");
224
- const headerHeight = tableHeader ? tableHeader.getBoundingClientRect().height : 0;
225
- let paginationHeight = 0;
226
- const paginationSelectors = [
227
- ".ant-pagination",
228
- ".ant-table-pagination",
229
- ".ant-pagination-mini"
230
- ];
231
- for (const selector of paginationSelectors) {
232
- const pagination = tableContainer.querySelector(selector);
233
- if (pagination) {
234
- const paginationRect = pagination.getBoundingClientRect();
235
- const paginationStyles = window.getComputedStyle(pagination);
236
- const paginationMarginTop = parseInt(paginationStyles.marginTop, 10) || 0;
237
- const paginationMarginBottom = parseInt(paginationStyles.marginBottom, 10) || 0;
238
- paginationHeight = paginationRect.height + paginationMarginTop + paginationMarginBottom;
239
- break;
240
- }
241
- }
242
- if (paginationHeight === 0) {
243
- paginationHeight = 44;
244
- }
245
- const bulkActionHeight = 0;
246
- const tableBodyHeight = availableHeight - otherElementsHeight - tablePaddingTop - tablePaddingBottom - headerHeight - paginationHeight - bulkActionHeight - extraOffset;
247
- const finalHeight = Math.max(tableBodyHeight, minHeight);
248
- setTableHeight(finalHeight);
249
- } catch (error) {
250
- console.error("Error calculating table height:", error);
251
- setTableHeight(minHeight);
252
- }
253
- }, [tableContainerId, extraOffset, minHeight]);
254
- useEffect(() => {
255
- const timer = setTimeout(() => {
256
- calculateTableHeight();
257
- }, 300);
258
- const handleResize = () => {
259
- calculateTableHeight();
260
- };
261
- window.addEventListener("resize", handleResize);
262
- const observer = new MutationObserver((mutations) => {
263
- let shouldRecalculate = false;
264
- mutations.forEach((mutation) => {
265
- if (mutation.type === "childList") {
266
- shouldRecalculate = true;
267
- }
268
- });
269
- if (shouldRecalculate) {
270
- setTimeout(calculateTableHeight, 100);
271
- }
272
- });
273
- const layoutWrapper = document.getElementById("layout-wrapper-table");
274
- const tableContainer = document.getElementById(tableContainerId);
275
- if (layoutWrapper) {
276
- observer.observe(layoutWrapper, {
277
- childList: true,
278
- subtree: true,
279
- attributes: true,
280
- attributeFilter: ["style", "class"]
281
- });
282
- }
283
- if (tableContainer && tableContainer !== layoutWrapper) {
284
- observer.observe(tableContainer, {
285
- childList: true,
286
- subtree: true,
287
- attributes: true,
288
- attributeFilter: ["style", "class"]
289
- });
290
- }
291
- return () => {
292
- clearTimeout(timer);
293
- window.removeEventListener("resize", handleResize);
294
- observer.disconnect();
295
- };
296
- }, [calculateTableHeight, tableContainerId]);
297
- return {
298
- tableHeight,
299
- recalculate: calculateTableHeight
300
- };
301
- };
302
-
303
- const Table = ({
304
- dataSource = [],
305
- columns,
306
- loading = false,
307
- totalItems = 100,
308
- filters,
309
- onChangePage,
310
- onChangePageSize,
311
- onSort,
312
- rowsSelected,
313
- onSelect,
314
- onRowClick,
315
- rowKey = "id",
316
- showIndexColumn = true,
317
- size = "small",
318
- defaultEllipsis = true,
319
- onDoubleClickRow,
320
- handleSubmit,
321
- ...rest
322
- }) => {
323
- const status = filters?.status;
324
- //! State
325
- const tableContainerRef = useRef(null);
326
- const rowSelection = {
327
- selectedRowKeys: rowsSelected,
328
- onChange: onSelect,
329
- getCheckboxProps: () => ({
330
- disabled: status === TypeStatusTable.ALL
331
- })
332
- };
333
- const ellipsisColumns = columns.map((column) => ({
334
- ...column,
335
- ellipsis: column?.ellipsis !== void 0 ? column?.ellipsis : defaultEllipsis
336
- }));
337
- const startIndex = (filters.page - 1) * filters.size;
338
- const columnsWithIndex = showIndexColumn ? [
339
- {
340
- title: "STT",
341
- dataIndex: "index",
342
- key: "index",
343
- width: 70,
344
- align: "center",
345
- render: (_, __, index) => startIndex + index + 1
346
- },
347
- ...ellipsisColumns
348
- ] : ellipsisColumns;
349
- //! Function
350
- const renderSizePagination = () => {
351
- switch (size) {
352
- case "small":
353
- return "small";
354
- // Dạng nhỏ gọn
355
- default:
356
- return "default";
357
- }
358
- };
359
- const handleTableChange = (_pagination, _filters, sorter) => {
360
- if (sorter && onSort) {
361
- onSort(sorter);
362
- }
363
- };
364
- const handleOnClickRow = (record, onRowClick2) => (e) => {
365
- const target = e.target;
366
- if (target.closest("input") || // ⛔ Checkbox
367
- target.closest("button") || // ⛔ Button trong row
368
- target.closest("svg") || // ⛔ Icon
369
- target.closest(".ant-checkbox") || // ⛔ AntD checkbox
370
- target.closest("a")) {
371
- return;
372
- }
373
- onRowClick2?.(record);
374
- };
375
- const handleDoubleClickRow = (record, onDoubleClickRow2) => (e) => {
376
- const target = e.target;
377
- if (target.closest("input") || // ⛔ Checkbox
378
- target.closest("button") || // ⛔ Button trong row
379
- target.closest("svg") || // ⛔ Icon
380
- target.closest(".ant-checkbox") || // ⛔ AntD checkbox
381
- target.closest("a")) {
382
- return;
383
- }
384
- onDoubleClickRow2?.(record);
385
- };
386
- const { tableHeight } = useTableHeightWrapper({
387
- tableContainerId: "table_content",
388
- // ID của table container
389
- minHeight: 200
390
- // chiều cao tối thiểu
391
- });
392
- useEffect(() => {
393
- const scrollToTop = () => {
394
- if (tableContainerRef.current) {
395
- const tableBody = tableContainerRef.current.querySelector(".ant-table-body");
396
- if (tableBody) {
397
- tableBody.scrollTop = 0;
398
- }
399
- }
400
- };
401
- const timeoutId = setTimeout(scrollToTop, 0);
402
- return () => clearTimeout(timeoutId);
403
- }, [filters.page]);
404
- const tableContent = /* @__PURE__ */ jsxs(
405
- "div",
406
- {
407
- ref: tableContainerRef,
408
- id: "table_content",
409
- className: "bg-[#FFFFFF] p-2 rounded-bl-lg rounded-br-lg",
410
- children: [
411
- /* @__PURE__ */ jsx(
412
- Table$1,
413
- {
414
- rowKey,
415
- dataSource,
416
- columns: columnsWithIndex,
417
- pagination: false,
418
- loading,
419
- rowSelection: rowsSelected ? rowSelection : void 0,
420
- onChange: handleTableChange,
421
- onRow: (record) => ({
422
- onClick: handleOnClickRow(record, onRowClick),
423
- onDoubleClick: handleDoubleClickRow(record, onDoubleClickRow)
424
- }),
425
- locale: {
426
- emptyText: loading ? null : /* @__PURE__ */ jsx(EmptyTable, {})
427
- },
428
- scroll: { y: tableHeight },
429
- size,
430
- ...rest,
431
- className: "table-scroll-bar"
432
- }
433
- ),
434
- /* @__PURE__ */ jsx(
435
- CustomPagination,
436
- {
437
- current: filters?.page,
438
- pageSize: filters?.size,
439
- total: totalItems,
440
- onChange: (page) => onChangePage(page),
441
- onShowSizeChange: (_, size2) => onChangePageSize(size2),
442
- size: renderSizePagination()
443
- }
444
- )
445
- ]
446
- }
447
- );
448
- const renderTable = () => {
449
- if (handleSubmit) {
450
- return /* @__PURE__ */ jsx("form", { onSubmit: handleSubmit, children: tableContent });
451
- }
452
- return tableContent;
453
- };
454
- //! Render
455
- return renderTable();
456
- };
457
- const EmptyTable = () => {
458
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center text-center", children: [
459
- /* @__PURE__ */ jsx("img", { src: iconTableNoData, alt: "no data" }),
460
- /* @__PURE__ */ jsx("span", { className: "text-lg font-bold text-black", children: "Không có dữ liệu nào phù hợp" }),
461
- /* @__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" })
462
- ] });
463
- };
464
-
465
- const EditIcon = ({ stroke, fill = "#007BE5" }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 14, height: 15, fill: "none", children: /* @__PURE__ */ jsx(
466
- "path",
467
- {
468
- fill,
469
- stroke,
470
- 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"
471
- }
472
- ) });
473
-
474
- const RestoreIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
475
- "path",
476
- {
477
- stroke,
478
- fill,
479
- strokeLinecap: "round",
480
- strokeLinejoin: "round",
481
- strokeWidth: 1.5,
482
- 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"
483
- }
484
- ) });
485
-
486
- const SendApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
487
- "path",
488
- {
489
- fill,
490
- stroke,
491
- strokeLinecap: "round",
492
- strokeWidth: 1.714,
493
- 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"
494
- }
495
- ) });
496
-
497
- const CancelSendApprovalIcon = ({ fill, stroke }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
498
- "path",
499
- {
500
- fill,
501
- stroke,
502
- strokeLinecap: "round",
503
- strokeWidth: 1.5,
504
- 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"
505
- }
506
- ) });
507
-
508
- const ApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
509
- "path",
510
- {
511
- fill,
512
- stroke,
513
- strokeLinecap: "round",
514
- strokeWidth: 1.714,
515
- 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"
516
- }
517
- ) });
518
-
519
- const CancelApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
520
- "path",
521
- {
522
- fill,
523
- stroke,
524
- strokeLinecap: "round",
525
- strokeWidth: 1.5,
526
- 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"
527
- }
528
- ) });
529
-
530
- const RefuseApprovalIcon = ({ stroke, fill }) => /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: [
531
- /* @__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" }) }),
532
- /* @__PURE__ */ jsx(
533
- "path",
534
- {
535
- fill: "#fff",
536
- 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"
537
- }
538
- ),
539
- /* @__PURE__ */ jsx(
540
- "path",
541
- {
542
- fill,
543
- stroke,
544
- 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",
545
- mask: "url(#a)"
546
- }
547
- )
548
- ] });
549
-
550
- const ActivateIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 22, height: 22, fill: "none", children: /* @__PURE__ */ jsx(
551
- "path",
552
- {
553
- fill,
554
- stroke,
555
- strokeLinecap: "round",
556
- strokeWidth: 1.714,
557
- 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"
558
- }
559
- ) });
560
-
561
- const DeleteIcon = ({ stroke, fill = "#DD4338" }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 23, height: 24, fill: "none", children: /* @__PURE__ */ jsx(
562
- "path",
563
- {
564
- fill,
565
- stroke,
566
- 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"
567
- }
568
- ) });
569
-
570
- const InActiveIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx(
571
- "svg",
572
- {
573
- xmlns: "http://www.w3.org/2000/svg",
574
- width: 22,
575
- height: 22,
576
- fill: "none",
577
- children: /* @__PURE__ */ jsx(
578
- "path",
579
- {
580
- fill,
581
- stroke,
582
- strokeLinecap: "round",
583
- strokeWidth: 1.714,
584
- 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"
585
- }
586
- )
587
- }
588
- );
589
-
590
- const MoreIcon = ({ stroke, fill }) => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: 18, height: 18, fill: "none", children: /* @__PURE__ */ jsx(
591
- "path",
592
- {
593
- fill,
594
- stroke,
595
- fillRule: "evenodd",
596
- d: "M4 8h2v2H4V8Zm4 0h2v2H8V8Zm4 0h2v2h-2V8Z",
597
- clipRule: "evenodd"
598
- }
599
- ) });
600
-
601
- const ActionRowTable = ({
602
- type,
603
- contentTooltip,
604
- handleClick
605
- }) => {
606
- //! State
607
- const {
608
- shouldRender: shouldRenderDelete,
609
- open: openDelete,
610
- toggle: toggleDelete
611
- } = useToggle();
612
- //! Function
613
- const handleDelete = () => {
614
- handleClick?.();
615
- toggleDelete();
616
- };
617
- const renderAction = () => {
618
- switch (type) {
619
- case TypeActionRowTable.EDIT:
620
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Tooltip, { title: contentTooltip, children: /* @__PURE__ */ jsx(
621
- Button,
622
- {
623
- onClick: handleClick,
624
- type: "text",
625
- className: "cursor-pointer",
626
- shape: "circle",
627
- icon: /* @__PURE__ */ jsx(EditIcon, { fill: "#007BE5" })
628
- }
629
- ) }) });
630
- case TypeActionRowTable.DELETE:
631
- return /* @__PURE__ */ jsx(Tooltip, { title: contentTooltip, children: /* @__PURE__ */ jsx(
632
- Button,
633
- {
634
- onClick: toggleDelete,
635
- type: "text",
636
- className: "cursor-pointer",
637
- shape: "circle",
638
- icon: /* @__PURE__ */ jsx(DeleteIcon, { fill: "#DD4338" })
639
- }
640
- ) });
641
- }
642
- };
643
- //! Render
644
- return /* @__PURE__ */ jsxs("div", { children: [
645
- shouldRenderDelete && /* @__PURE__ */ jsx(
646
- ConfirmModal,
647
- {
648
- title: "Xác nhận xóa",
649
- 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.",
650
- typeIcon: "error",
651
- open: openDelete,
652
- handleCancel: toggleDelete,
653
- handleSubmit: handleDelete
654
- }
655
- ),
656
- renderAction()
657
- ] });
658
- };
659
-
660
- const BulkAction = ({
661
- quantity = 0,
662
- listIcon,
663
- status,
664
- setNotifyContent,
665
- toggle
666
- }) => {
667
- //! State
668
- //! Function
669
- const IsShow = (arrStatus) => {
670
- return arrStatus.includes(status);
671
- };
672
- //! Render
673
- 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: [
674
- /* @__PURE__ */ jsxs("div", { className: "text-white px-3", children: [
675
- "Đã chọn: ",
676
- quantity
677
- ] }),
678
- /* @__PURE__ */ jsx("div", { className: "h-5 border-l border-white mx-1" }),
679
- /* @__PURE__ */ jsx("div", { className: "flex items-center space-x-3", children: !isEmpty(listIcon) && listIcon?.map(
680
- (item, index) => IsShow(item?.arrShow) && /* @__PURE__ */ jsx(Tooltip, { title: item?.name, children: /* @__PURE__ */ jsx(
681
- "button",
682
- {
683
- className: "p-1 rounded-sm transition duration-200 cursor-pointer hover:bg-[#1B4ACB] hover:rounded-sm",
684
- onClick: () => {
685
- toggle();
686
- setNotifyContent({
687
- title: item?.title || "",
688
- content: item?.content || "",
689
- typeIcon: item?.typeIcon,
690
- handleCancel: () => {
691
- toggle();
692
- },
693
- handleSubmit: () => {
694
- if (item?.action) {
695
- item?.action();
696
- }
697
- toggle();
698
- }
699
- });
700
- },
701
- children: item.icon
702
- },
703
- index
704
- ) })
705
- ) })
706
- ] }) });
707
- };
708
-
709
- const DropListActions = ({
710
- listIcon,
711
- status,
712
- setNotifyContent,
713
- toggle
714
- }) => {
715
- //! State
716
- //! Function
717
- const IsShow = (arrStatus) => {
718
- return arrStatus.includes(status);
719
- };
720
- const renderContentPopover = () => {
721
- return /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: !isEmpty(listIcon) && listIcon?.map(
722
- (item, index) => item?.showTitle && IsShow(item?.arrShow) && /* @__PURE__ */ jsxs(
723
- "button",
724
- {
725
- className: twMerge(
726
- "flex gap-4 px-3 py-2 rounded-sm transition duration-200 hover:rounded-sm",
727
- IsShow(item?.arrShow) ? "hover:bg-[#F5F6F7] cursor-pointer" : "text-[#B2B7C2] cursor-not-allowed"
728
- ),
729
- disabled: IsShow(item?.arrShow) ? false : true,
730
- onClick: () => {
731
- toggle();
732
- setNotifyContent({
733
- title: item?.title || "",
734
- content: item?.content || "",
735
- typeIcon: item?.typeIcon,
736
- handleCancel: () => {
737
- toggle();
738
- },
739
- handleSubmit: () => {
740
- if (item?.action) {
741
- item?.action();
742
- }
743
- toggle();
744
- }
745
- });
746
- },
747
- children: [
748
- item.iconDropList,
749
- /* @__PURE__ */ jsx("span", { children: item.name || "" })
750
- ]
751
- },
752
- index
753
- )
754
- ) });
755
- };
756
- //! Render
757
- 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(
758
- Popover,
759
- {
760
- placement: "bottom",
761
- content: renderContentPopover(),
762
- trigger: "click",
763
- children: /* @__PURE__ */ jsx("div", { className: "p-1 border-[#BDE3FF] rounded-full border cursor-pointer", children: /* @__PURE__ */ jsx(MoreIcon, { fill: "#007BE5" }) })
764
- }
765
- ) }) });
766
- };
767
-
768
- const BulkActions = ({
769
- quantity = 0,
770
- handleDelete,
771
- handleSubmitForApproval,
772
- handleCancelSubmission,
773
- handleApprove,
774
- handleCancelApproval,
775
- handleReject,
776
- handleDeactivate,
777
- handleActivate,
778
- handleRestore,
779
- status,
780
- typeBulkaction,
781
- isApproved = false
782
- // Chỉ sử dụng khi là danh sách icon
783
- }) => {
784
- //! State
785
- const listIcon = [
786
- {
787
- icon: /* @__PURE__ */ jsx(RestoreIcon, { stroke: "white" }),
788
- iconDropList: /* @__PURE__ */ jsx(RestoreIcon, { stroke: "#0F1D40" }),
789
- iconDisable: /* @__PURE__ */ jsx(RestoreIcon, { stroke: "#B2B7C2" }),
790
- action: handleRestore,
791
- name: "Khôi phục",
792
- typeIcon: "info",
793
- title: "Xác nhận khôi phục",
794
- content: "Bạn có chắc chắn muốn khôi phục không?",
795
- arrShow: [CATEGORY_LIST_ENUM?.DELETE, CATEGORY_LIST_ENUM?.REJECT],
796
- showTitle: true
797
- },
798
- {
799
- icon: /* @__PURE__ */ jsx(SendApprovalIcon, { stroke: "white" }),
800
- iconDropList: /* @__PURE__ */ jsx(SendApprovalIcon, { stroke: "#0F1D40" }),
801
- iconDisable: /* @__PURE__ */ jsx(SendApprovalIcon, { stroke: "#B2B7C2" }),
802
- action: handleSubmitForApproval,
803
- name: "Gửi duyệt",
804
- typeIcon: "info",
805
- title: "Xác nhận gửi duyệt",
806
- content: "Bạn có chắc chắn muốn gửi duyệt không?",
807
- arrShow: [CATEGORY_LIST_ENUM?.DRAFT],
808
- showTitle: true
809
- },
810
- {
811
- icon: /* @__PURE__ */ jsx(CancelSendApprovalIcon, { stroke: "white" }),
812
- iconDropList: /* @__PURE__ */ jsx(CancelSendApprovalIcon, { stroke: "#0F1D40" }),
813
- iconDisable: /* @__PURE__ */ jsx(CancelSendApprovalIcon, { stroke: "#B2B7C2" }),
814
- action: handleCancelSubmission,
815
- name: "Huỷ gửi duyệt",
816
- typeIcon: "error",
817
- title: "Xác nhận hủy gửi duyệt",
818
- content: "Bạn có chắc chắn muốn hủy gửi duyệt không?",
819
- arrShow: [CATEGORY_LIST_ENUM?.WATING_APPROVAL],
820
- showTitle: true
821
- },
822
- {
823
- icon: /* @__PURE__ */ jsx(RefuseApprovalIcon, { stroke: "white" }),
824
- iconDropList: /* @__PURE__ */ jsx(RefuseApprovalIcon, { stroke: "#0F1D40" }),
825
- iconDisable: /* @__PURE__ */ jsx(RefuseApprovalIcon, { stroke: "#B2B7C2" }),
826
- action: handleReject,
827
- name: "Từ chối duyệt",
828
- typeIcon: "error",
829
- title: "Xác nhận từ chối duyệt",
830
- 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.",
831
- arrShow: [CATEGORY_LIST_ENUM?.WATING_APPROVAL],
832
- showTitle: true
833
- },
834
- {
835
- icon: /* @__PURE__ */ jsx(ApprovalIcon, { stroke: "white" }),
836
- iconDropList: /* @__PURE__ */ jsx(ApprovalIcon, { stroke: "#0F1D40" }),
837
- iconDisable: /* @__PURE__ */ jsx(ApprovalIcon, { stroke: "#B2B7C2" }),
838
- action: handleApprove,
839
- name: "Duyệt",
840
- typeIcon: "info",
841
- title: "Xác nhận duyệt",
842
- content: "Bạn có chắc chắn muốn duyệt không?",
843
- arrShow: [CATEGORY_LIST_ENUM?.WATING_APPROVAL],
844
- showTitle: true
845
- },
846
- {
847
- icon: /* @__PURE__ */ jsx(CancelApprovalIcon, { stroke: "white" }),
848
- iconDropList: /* @__PURE__ */ jsx(CancelApprovalIcon, { stroke: "#0F1D40" }),
849
- iconDisable: /* @__PURE__ */ jsx(CancelApprovalIcon, { stroke: "#B2B7C2" }),
850
- action: handleCancelApproval,
851
- typeIcon: "error",
852
- name: "Hủy duyệt",
853
- title: "Xác nhận hủy duyệt",
854
- content: "Bạn có chắc chắn muốn hủy duyệt không?",
855
- arrShow: isApproved ? [CATEGORY_LIST_ENUM?.ACTIVE] : [],
856
- showTitle: true
857
- },
858
- {
859
- icon: /* @__PURE__ */ jsx(DeleteIcon, { fill: "white" }),
860
- iconDropList: /* @__PURE__ */ jsx(DeleteIcon, { fill: "#0F1D40" }),
861
- iconDisable: /* @__PURE__ */ jsx(DeleteIcon, { fill: "#B2B7C2" }),
862
- action: handleDelete,
863
- typeIcon: "error",
864
- name: "Xoá",
865
- title: "Xác nhận xóa",
866
- 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.",
867
- arrShow: [
868
- CATEGORY_LIST_ENUM?.DRAFT,
869
- CATEGORY_LIST_ENUM?.ACTIVE,
870
- CATEGORY_LIST_ENUM?.INACTIVE
871
- ],
872
- showTitle: false
873
- },
874
- {
875
- icon: /* @__PURE__ */ jsx(ActivateIcon, { stroke: "white" }),
876
- iconDropList: /* @__PURE__ */ jsx(ActivateIcon, { stroke: "#0F1D40" }),
877
- iconDisable: /* @__PURE__ */ jsx(ActivateIcon, { stroke: "#B2B7C2" }),
878
- action: handleActivate,
879
- typeIcon: "info",
880
- name: "Kích hoạt",
881
- title: "Xác nhận kích hoạt",
882
- content: "Bạn có chắc chắn muốn kích hoạt không?",
883
- arrShow: [CATEGORY_LIST_ENUM?.INACTIVE],
884
- showTitle: true
885
- },
886
- {
887
- icon: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "white" }),
888
- iconDropList: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "#0F1D40" }),
889
- iconDisable: /* @__PURE__ */ jsx(InActiveIcon, { stroke: "#B2B7C2" }),
890
- action: handleDeactivate,
891
- name: "Vô hiệu hóa",
892
- typeIcon: "error",
893
- title: "Xác nhận vô hiệu hóa",
894
- content: "Bạn có chắc chắn muốn vô hiệu hóa không?",
895
- arrShow: [CATEGORY_LIST_ENUM?.ACTIVE],
896
- showTitle: true
897
- }
898
- ];
899
- console.log("listIcon", listIcon);
900
- const { open, shouldRender, toggle } = useToggle();
901
- const [notifyContent, setNotifyContent] = useState({
902
- title: "",
903
- content: "",
904
- typeIcon: "info",
905
- handleCancel: () => {
906
- },
907
- handleSubmit: () => {
908
- }
909
- });
910
- //! Function
911
- const renderBulkActions = () => {
912
- switch (typeBulkaction) {
913
- case TypeBulkActions.BULKACTION:
914
- return /* @__PURE__ */ jsx(
915
- BulkAction,
916
- {
917
- listIcon,
918
- quantity,
919
- setNotifyContent,
920
- toggle,
921
- status
922
- }
923
- );
924
- case TypeBulkActions.DROPLIST:
925
- return /* @__PURE__ */ jsx(
926
- DropListActions,
927
- {
928
- listIcon,
929
- setNotifyContent,
930
- toggle,
931
- status
932
- }
933
- );
934
- }
935
- };
936
- //! Render
937
- return /* @__PURE__ */ jsxs("div", { children: [
938
- renderBulkActions(),
939
- shouldRender && /* @__PURE__ */ jsx(
940
- ConfirmModal,
941
- {
942
- title: notifyContent?.title,
943
- content: notifyContent?.content,
944
- typeIcon: notifyContent?.typeIcon,
945
- open,
946
- handleCancel: notifyContent?.handleCancel,
947
- handleSubmit: notifyContent?.handleSubmit
948
- }
949
- )
950
- ] });
951
- };
952
-
953
- export { ActionRowTable, BulkActions, Button, CATEGORY_LIST_ENUM, ConfirmModal, Popover, Table, Tooltip, TypeActionRowTable, TypeBulkActions, TypeStatusTable, Typography };
64
+ export { PAGE_NUMBER, PAGE_SIZE, SORT, START_PAGE, START_PAGE_SIZE, TypeActionRowTable, TypeBulkActions, TypeStatusTable } from '../constants/index.js';