@expcat/tigercat-react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/chunk-2DOPHSZP.js +32 -0
- package/dist/chunk-2TS6X5RA.js +73 -0
- package/dist/chunk-2Y327ZU4.js +493 -0
- package/dist/chunk-3GD3LOII.mjs +23 -0
- package/dist/chunk-3OF7XPIQ.js +90 -0
- package/dist/chunk-3WPKVV4N.js +140 -0
- package/dist/chunk-3XXXM4OB.mjs +203 -0
- package/dist/chunk-427CM2U6.mjs +76 -0
- package/dist/chunk-472D2S4R.mjs +23 -0
- package/dist/chunk-5FRENLDC.js +194 -0
- package/dist/chunk-5HUYCSA4.mjs +77 -0
- package/dist/chunk-5QKMQRCW.js +89 -0
- package/dist/chunk-5ZVSFIZD.js +50 -0
- package/dist/chunk-6575DOCV.mjs +117 -0
- package/dist/chunk-672SCJWZ.mjs +88 -0
- package/dist/chunk-6MGEGOYJ.js +108 -0
- package/dist/chunk-6PUSRC6S.js +68 -0
- package/dist/chunk-6YDIBMCM.mjs +33 -0
- package/dist/chunk-72ZRDBXN.js +25 -0
- package/dist/chunk-77D7VQMG.js +43 -0
- package/dist/chunk-7CAJK2ZK.mjs +54 -0
- package/dist/chunk-7JQ7LURS.mjs +25 -0
- package/dist/chunk-7KRBDT2Z.mjs +269 -0
- package/dist/chunk-7O2OQKVY.mjs +10 -0
- package/dist/chunk-7OLWGHUR.mjs +169 -0
- package/dist/chunk-7P6PHSFM.js +548 -0
- package/dist/chunk-ADOPAXPG.mjs +301 -0
- package/dist/chunk-AG6GVQ5O.js +271 -0
- package/dist/chunk-ALP3KYYY.mjs +47 -0
- package/dist/chunk-AQ6DHCP6.js +53 -0
- package/dist/chunk-AQQRWISY.js +184 -0
- package/dist/chunk-C52ZCGYG.mjs +313 -0
- package/dist/chunk-C5EFBJBR.js +540 -0
- package/dist/chunk-CES6LGQ7.mjs +546 -0
- package/dist/chunk-CKUSQR2H.mjs +41 -0
- package/dist/chunk-CR4QK2AB.mjs +88 -0
- package/dist/chunk-CTAMMQBC.mjs +297 -0
- package/dist/chunk-D3I2SY7X.js +301 -0
- package/dist/chunk-DCRVIDMY.mjs +41 -0
- package/dist/chunk-DIZNY6N4.mjs +71 -0
- package/dist/chunk-DZJUFU55.js +300 -0
- package/dist/chunk-EB6EDLJZ.mjs +50 -0
- package/dist/chunk-EI2GHMQS.js +37 -0
- package/dist/chunk-ENR3RIMM.js +205 -0
- package/dist/chunk-EQWQXURG.js +18 -0
- package/dist/chunk-EUHWE7MN.js +267 -0
- package/dist/chunk-FAKTU64M.js +67 -0
- package/dist/chunk-FQ6UHRAO.js +499 -0
- package/dist/chunk-G6FSHN2I.mjs +111 -0
- package/dist/chunk-GIYBVWR4.mjs +213 -0
- package/dist/chunk-HDDBBZQH.js +321 -0
- package/dist/chunk-HQLZL3XQ.mjs +48 -0
- package/dist/chunk-HQXZVTP4.mjs +199 -0
- package/dist/chunk-HUMGEP7S.mjs +17 -0
- package/dist/chunk-IFY46RWU.js +25 -0
- package/dist/chunk-IQINYCU6.js +99 -0
- package/dist/chunk-IWENGARY.mjs +32 -0
- package/dist/chunk-IY4LEJYF.js +78 -0
- package/dist/chunk-JW64IJP2.js +210 -0
- package/dist/chunk-K7ZMB2TH.mjs +696 -0
- package/dist/chunk-KAEHFMTQ.mjs +537 -0
- package/dist/chunk-KMQOLVWP.mjs +65 -0
- package/dist/chunk-KUCFT2OA.js +43 -0
- package/dist/chunk-LADCWARG.mjs +97 -0
- package/dist/chunk-LAZGEMA2.mjs +176 -0
- package/dist/chunk-LNKI6HQ3.js +152 -0
- package/dist/chunk-LXA2YBAO.js +38 -0
- package/dist/chunk-MKWXJZ3T.js +74 -0
- package/dist/chunk-MQXBU5YX.mjs +87 -0
- package/dist/chunk-NEULKOYJ.js +48 -0
- package/dist/chunk-NI2WNZRT.js +38 -0
- package/dist/chunk-NOOPXNR4.mjs +36 -0
- package/dist/chunk-NSGDRTSQ.mjs +138 -0
- package/dist/chunk-O3EUFIOS.mjs +142 -0
- package/dist/chunk-OCVQ3LOT.mjs +45 -0
- package/dist/chunk-OFCKGWTS.js +12 -0
- package/dist/chunk-OQTPXPAP.mjs +10 -0
- package/dist/chunk-OTRGVENC.js +305 -0
- package/dist/chunk-P273E6XE.js +219 -0
- package/dist/chunk-PAD2DX5M.mjs +331 -0
- package/dist/chunk-PUDU34R4.mjs +106 -0
- package/dist/chunk-Q3DPJHNM.js +407 -0
- package/dist/chunk-QEAC4MIG.mjs +295 -0
- package/dist/chunk-QFVE7GKD.js +109 -0
- package/dist/chunk-QL6OBKEN.js +84 -0
- package/dist/chunk-QL6UEG3U.js +27 -0
- package/dist/chunk-QN7NIX7D.mjs +82 -0
- package/dist/chunk-QORSSZX4.js +144 -0
- package/dist/chunk-R4JSBXGG.js +12 -0
- package/dist/chunk-R5BQHZWB.js +698 -0
- package/dist/chunk-R7MS42PL.js +90 -0
- package/dist/chunk-RTQNWZN4.mjs +405 -0
- package/dist/chunk-SIVJX7VU.mjs +16 -0
- package/dist/chunk-SJ5RFU2O.mjs +17 -0
- package/dist/chunk-T4TJJMLM.mjs +34 -0
- package/dist/chunk-TB2UHDOZ.js +19 -0
- package/dist/chunk-TBIEWDY5.js +175 -0
- package/dist/chunk-TJFS44SH.js +48 -0
- package/dist/chunk-TR246HQP.mjs +69 -0
- package/dist/chunk-TZ26HQAW.js +85 -0
- package/dist/chunk-U4ZVEPYD.js +71 -0
- package/dist/chunk-UFAXJVMD.js +120 -0
- package/dist/chunk-V2HVHLBY.mjs +83 -0
- package/dist/chunk-VD3IK5XT.mjs +35 -0
- package/dist/chunk-VEGBO77D.mjs +20 -0
- package/dist/chunk-VJJ76I7U.js +19 -0
- package/dist/chunk-VO4WDK4K.js +37 -0
- package/dist/chunk-VSF4DF7N.js +84 -0
- package/dist/chunk-VVO4V4IK.js +56 -0
- package/dist/chunk-W7HUFFPJ.mjs +263 -0
- package/dist/chunk-WDAMDVLU.mjs +106 -0
- package/dist/chunk-WEGU7O4J.mjs +66 -0
- package/dist/chunk-WK5HN4OH.js +113 -0
- package/dist/chunk-WSCSDSV7.mjs +145 -0
- package/dist/chunk-WSJO2PIE.mjs +72 -0
- package/dist/chunk-XDKXL2BP.mjs +188 -0
- package/dist/chunk-XS5JP2KO.mjs +491 -0
- package/dist/chunk-XZDJ5FRB.js +333 -0
- package/dist/chunk-YE2M2HNM.js +168 -0
- package/dist/chunk-YYGTJKP5.js +39 -0
- package/dist/chunk-YYKJ63LD.mjs +497 -0
- package/dist/chunk-Z4Z3I74Q.mjs +166 -0
- package/dist/chunk-ZO4XVOHU.mjs +45 -0
- package/dist/chunk-ZREFCRX3.js +52 -0
- package/dist/components/Alert.d.mts +24 -0
- package/dist/components/Alert.d.ts +24 -0
- package/dist/components/Alert.js +10 -0
- package/dist/components/Alert.mjs +1 -0
- package/dist/components/Avatar.d.mts +12 -0
- package/dist/components/Avatar.d.ts +12 -0
- package/dist/components/Avatar.js +10 -0
- package/dist/components/Avatar.mjs +1 -0
- package/dist/components/Badge.d.mts +12 -0
- package/dist/components/Badge.d.ts +12 -0
- package/dist/components/Badge.js +10 -0
- package/dist/components/Badge.mjs +1 -0
- package/dist/components/Breadcrumb.d.mts +13 -0
- package/dist/components/Breadcrumb.d.ts +13 -0
- package/dist/components/Breadcrumb.js +14 -0
- package/dist/components/Breadcrumb.mjs +1 -0
- package/dist/components/BreadcrumbItem.d.mts +21 -0
- package/dist/components/BreadcrumbItem.d.ts +21 -0
- package/dist/components/BreadcrumbItem.js +11 -0
- package/dist/components/BreadcrumbItem.mjs +2 -0
- package/dist/components/Button.d.mts +8 -0
- package/dist/components/Button.d.ts +8 -0
- package/dist/components/Button.js +10 -0
- package/dist/components/Button.mjs +1 -0
- package/dist/components/Card.d.mts +33 -0
- package/dist/components/Card.d.ts +33 -0
- package/dist/components/Card.js +10 -0
- package/dist/components/Card.mjs +1 -0
- package/dist/components/Checkbox.d.mts +48 -0
- package/dist/components/Checkbox.d.ts +48 -0
- package/dist/components/Checkbox.js +11 -0
- package/dist/components/Checkbox.mjs +2 -0
- package/dist/components/CheckboxGroup.d.mts +39 -0
- package/dist/components/CheckboxGroup.d.ts +39 -0
- package/dist/components/CheckboxGroup.js +14 -0
- package/dist/components/CheckboxGroup.mjs +1 -0
- package/dist/components/Col.d.mts +7 -0
- package/dist/components/Col.d.ts +7 -0
- package/dist/components/Col.js +11 -0
- package/dist/components/Col.mjs +2 -0
- package/dist/components/ConfigProvider.d.mts +14 -0
- package/dist/components/ConfigProvider.d.ts +14 -0
- package/dist/components/ConfigProvider.js +14 -0
- package/dist/components/ConfigProvider.mjs +1 -0
- package/dist/components/Container.d.mts +13 -0
- package/dist/components/Container.d.ts +13 -0
- package/dist/components/Container.js +10 -0
- package/dist/components/Container.mjs +1 -0
- package/dist/components/Content.d.mts +9 -0
- package/dist/components/Content.d.ts +9 -0
- package/dist/components/Content.js +10 -0
- package/dist/components/Content.mjs +1 -0
- package/dist/components/DatePicker.d.mts +24 -0
- package/dist/components/DatePicker.d.ts +24 -0
- package/dist/components/DatePicker.js +10 -0
- package/dist/components/DatePicker.mjs +1 -0
- package/dist/components/Descriptions.d.mts +53 -0
- package/dist/components/Descriptions.d.ts +53 -0
- package/dist/components/Descriptions.js +16 -0
- package/dist/components/Descriptions.mjs +1 -0
- package/dist/components/Divider.d.mts +12 -0
- package/dist/components/Divider.d.ts +12 -0
- package/dist/components/Divider.js +10 -0
- package/dist/components/Divider.mjs +1 -0
- package/dist/components/Drawer.d.mts +19 -0
- package/dist/components/Drawer.d.ts +19 -0
- package/dist/components/Drawer.js +11 -0
- package/dist/components/Drawer.mjs +2 -0
- package/dist/components/Dropdown.d.mts +22 -0
- package/dist/components/Dropdown.d.ts +22 -0
- package/dist/components/Dropdown.js +16 -0
- package/dist/components/Dropdown.mjs +3 -0
- package/dist/components/DropdownItem.d.mts +17 -0
- package/dist/components/DropdownItem.d.ts +17 -0
- package/dist/components/DropdownItem.js +13 -0
- package/dist/components/DropdownItem.mjs +4 -0
- package/dist/components/DropdownMenu.d.mts +13 -0
- package/dist/components/DropdownMenu.d.ts +13 -0
- package/dist/components/DropdownMenu.js +10 -0
- package/dist/components/DropdownMenu.mjs +1 -0
- package/dist/components/Footer.d.mts +9 -0
- package/dist/components/Footer.d.ts +9 -0
- package/dist/components/Footer.js +10 -0
- package/dist/components/Footer.mjs +1 -0
- package/dist/components/Form.d.mts +56 -0
- package/dist/components/Form.d.ts +56 -0
- package/dist/components/Form.js +14 -0
- package/dist/components/Form.mjs +1 -0
- package/dist/components/FormItem.d.mts +16 -0
- package/dist/components/FormItem.d.ts +16 -0
- package/dist/components/FormItem.js +11 -0
- package/dist/components/FormItem.mjs +2 -0
- package/dist/components/Header.d.mts +9 -0
- package/dist/components/Header.d.ts +9 -0
- package/dist/components/Header.js +10 -0
- package/dist/components/Header.mjs +1 -0
- package/dist/components/Icon.d.mts +9 -0
- package/dist/components/Icon.d.ts +9 -0
- package/dist/components/Icon.js +10 -0
- package/dist/components/Icon.mjs +1 -0
- package/dist/components/Input.d.mts +28 -0
- package/dist/components/Input.d.ts +28 -0
- package/dist/components/Input.js +10 -0
- package/dist/components/Input.mjs +1 -0
- package/dist/components/Layout.d.mts +9 -0
- package/dist/components/Layout.d.ts +9 -0
- package/dist/components/Layout.js +10 -0
- package/dist/components/Layout.mjs +1 -0
- package/dist/components/Link.d.mts +10 -0
- package/dist/components/Link.d.ts +10 -0
- package/dist/components/Link.js +10 -0
- package/dist/components/Link.mjs +1 -0
- package/dist/components/List.d.mts +94 -0
- package/dist/components/List.d.ts +94 -0
- package/dist/components/List.js +12 -0
- package/dist/components/List.mjs +3 -0
- package/dist/components/Loading.d.mts +8 -0
- package/dist/components/Loading.d.ts +8 -0
- package/dist/components/Loading.js +10 -0
- package/dist/components/Loading.mjs +1 -0
- package/dist/components/Menu.d.mts +35 -0
- package/dist/components/Menu.d.ts +35 -0
- package/dist/components/Menu.js +14 -0
- package/dist/components/Menu.mjs +1 -0
- package/dist/components/MenuItem.d.mts +20 -0
- package/dist/components/MenuItem.d.ts +20 -0
- package/dist/components/MenuItem.js +11 -0
- package/dist/components/MenuItem.mjs +2 -0
- package/dist/components/MenuItemGroup.d.mts +16 -0
- package/dist/components/MenuItemGroup.d.ts +16 -0
- package/dist/components/MenuItemGroup.js +12 -0
- package/dist/components/MenuItemGroup.mjs +3 -0
- package/dist/components/Message.d.mts +44 -0
- package/dist/components/Message.d.ts +44 -0
- package/dist/components/Message.js +20 -0
- package/dist/components/Message.mjs +1 -0
- package/dist/components/Modal.d.mts +41 -0
- package/dist/components/Modal.d.ts +41 -0
- package/dist/components/Modal.js +11 -0
- package/dist/components/Modal.mjs +2 -0
- package/dist/components/Notification.d.mts +40 -0
- package/dist/components/Notification.d.ts +40 -0
- package/dist/components/Notification.js +20 -0
- package/dist/components/Notification.mjs +1 -0
- package/dist/components/Pagination.d.mts +11 -0
- package/dist/components/Pagination.d.ts +11 -0
- package/dist/components/Pagination.js +16 -0
- package/dist/components/Pagination.mjs +1 -0
- package/dist/components/Popconfirm.d.mts +34 -0
- package/dist/components/Popconfirm.d.ts +34 -0
- package/dist/components/Popconfirm.js +10 -0
- package/dist/components/Popconfirm.mjs +1 -0
- package/dist/components/Popover.d.mts +14 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Popover.js +10 -0
- package/dist/components/Popover.mjs +1 -0
- package/dist/components/Progress.d.mts +8 -0
- package/dist/components/Progress.d.ts +8 -0
- package/dist/components/Progress.js +10 -0
- package/dist/components/Progress.mjs +1 -0
- package/dist/components/Radio.d.mts +20 -0
- package/dist/components/Radio.d.ts +20 -0
- package/dist/components/Radio.js +11 -0
- package/dist/components/Radio.mjs +2 -0
- package/dist/components/RadioGroup.d.mts +28 -0
- package/dist/components/RadioGroup.d.ts +28 -0
- package/dist/components/RadioGroup.js +14 -0
- package/dist/components/RadioGroup.mjs +1 -0
- package/dist/components/Row.d.mts +11 -0
- package/dist/components/Row.d.ts +11 -0
- package/dist/components/Row.js +14 -0
- package/dist/components/Row.mjs +1 -0
- package/dist/components/Select.d.mts +23 -0
- package/dist/components/Select.d.ts +23 -0
- package/dist/components/Select.js +10 -0
- package/dist/components/Select.mjs +1 -0
- package/dist/components/Sidebar.d.mts +9 -0
- package/dist/components/Sidebar.d.ts +9 -0
- package/dist/components/Sidebar.js +10 -0
- package/dist/components/Sidebar.mjs +1 -0
- package/dist/components/Skeleton.d.mts +7 -0
- package/dist/components/Skeleton.d.ts +7 -0
- package/dist/components/Skeleton.js +10 -0
- package/dist/components/Skeleton.mjs +1 -0
- package/dist/components/Slider.d.mts +12 -0
- package/dist/components/Slider.d.ts +12 -0
- package/dist/components/Slider.js +10 -0
- package/dist/components/Slider.mjs +1 -0
- package/dist/components/Space.d.mts +11 -0
- package/dist/components/Space.d.ts +11 -0
- package/dist/components/Space.js +10 -0
- package/dist/components/Space.mjs +1 -0
- package/dist/components/Steps.d.mts +31 -0
- package/dist/components/Steps.d.ts +31 -0
- package/dist/components/Steps.js +14 -0
- package/dist/components/Steps.mjs +1 -0
- package/dist/components/StepsItem.d.mts +36 -0
- package/dist/components/StepsItem.d.ts +36 -0
- package/dist/components/StepsItem.js +10 -0
- package/dist/components/StepsItem.mjs +1 -0
- package/dist/components/SubMenu.d.mts +20 -0
- package/dist/components/SubMenu.d.ts +20 -0
- package/dist/components/SubMenu.js +13 -0
- package/dist/components/SubMenu.mjs +4 -0
- package/dist/components/Switch.d.mts +12 -0
- package/dist/components/Switch.d.ts +12 -0
- package/dist/components/Switch.js +10 -0
- package/dist/components/Switch.mjs +1 -0
- package/dist/components/TabPane.d.mts +42 -0
- package/dist/components/TabPane.d.ts +42 -0
- package/dist/components/TabPane.js +10 -0
- package/dist/components/TabPane.mjs +1 -0
- package/dist/components/Table.d.mts +46 -0
- package/dist/components/Table.d.ts +46 -0
- package/dist/components/Table.js +10 -0
- package/dist/components/Table.mjs +1 -0
- package/dist/components/Tabs.d.mts +43 -0
- package/dist/components/Tabs.d.ts +43 -0
- package/dist/components/Tabs.js +14 -0
- package/dist/components/Tabs.mjs +1 -0
- package/dist/components/Tag.d.mts +16 -0
- package/dist/components/Tag.d.ts +16 -0
- package/dist/components/Tag.js +10 -0
- package/dist/components/Tag.mjs +1 -0
- package/dist/components/Text.d.mts +9 -0
- package/dist/components/Text.d.ts +9 -0
- package/dist/components/Text.js +10 -0
- package/dist/components/Text.mjs +1 -0
- package/dist/components/Textarea.d.mts +13 -0
- package/dist/components/Textarea.d.ts +13 -0
- package/dist/components/Textarea.js +10 -0
- package/dist/components/Textarea.mjs +1 -0
- package/dist/components/TimePicker.d.mts +28 -0
- package/dist/components/TimePicker.d.ts +28 -0
- package/dist/components/TimePicker.js +10 -0
- package/dist/components/TimePicker.mjs +1 -0
- package/dist/components/Timeline.d.mts +47 -0
- package/dist/components/Timeline.d.ts +47 -0
- package/dist/components/Timeline.js +10 -0
- package/dist/components/Timeline.mjs +1 -0
- package/dist/components/Tooltip.d.mts +15 -0
- package/dist/components/Tooltip.d.ts +15 -0
- package/dist/components/Tooltip.js +10 -0
- package/dist/components/Tooltip.mjs +1 -0
- package/dist/components/Tree.d.mts +154 -0
- package/dist/components/Tree.d.ts +154 -0
- package/dist/components/Tree.js +16 -0
- package/dist/components/Tree.mjs +1 -0
- package/dist/components/Upload.d.mts +16 -0
- package/dist/components/Upload.d.ts +16 -0
- package/dist/components/Upload.js +11 -0
- package/dist/components/Upload.mjs +2 -0
- package/dist/index.d.mts +76 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +359 -0
- package/dist/index.mjs +67 -0
- package/package.json +60 -0
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import { useState, useEffect, useMemo, useCallback } from 'react';
|
|
2
|
+
import { getSpinnerSVG, getFixedColumnOffsets, filterData, sortData, paginateData, getRowKey, calculatePagination, getTableHeaderClasses, getCheckboxCellClasses, classNames, getTableHeaderCellClasses, tableEmptyStateClasses, getTableCellClasses, getTableRowClasses, tablePaginationContainerClasses, getTableWrapperClasses, tableBaseClasses, tableLoadingOverlayClasses, getSortIconClasses, getLoadingOverlaySpinnerClasses } from '@expcat/tigercat-core';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Table.tsx
|
|
6
|
+
var spinnerSvg = getSpinnerSVG("spinner");
|
|
7
|
+
var SortIcon = ({ direction }) => {
|
|
8
|
+
if (direction === "asc") {
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
"svg",
|
|
11
|
+
{
|
|
12
|
+
className: getSortIconClasses(true),
|
|
13
|
+
width: "16",
|
|
14
|
+
height: "16",
|
|
15
|
+
viewBox: "0 0 16 16",
|
|
16
|
+
fill: "currentColor",
|
|
17
|
+
children: /* @__PURE__ */ jsx("path", { d: "M8 3l4 4H4l4-4z" })
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (direction === "desc") {
|
|
22
|
+
return /* @__PURE__ */ jsx(
|
|
23
|
+
"svg",
|
|
24
|
+
{
|
|
25
|
+
className: getSortIconClasses(true),
|
|
26
|
+
width: "16",
|
|
27
|
+
height: "16",
|
|
28
|
+
viewBox: "0 0 16 16",
|
|
29
|
+
fill: "currentColor",
|
|
30
|
+
children: /* @__PURE__ */ jsx("path", { d: "M8 13l-4-4h8l-4 4z" })
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
return /* @__PURE__ */ jsx(
|
|
35
|
+
"svg",
|
|
36
|
+
{
|
|
37
|
+
className: getSortIconClasses(false),
|
|
38
|
+
width: "16",
|
|
39
|
+
height: "16",
|
|
40
|
+
viewBox: "0 0 16 16",
|
|
41
|
+
fill: "currentColor",
|
|
42
|
+
children: /* @__PURE__ */ jsx("path", { d: "M8 3l4 4H4l4-4zM8 13l-4-4h8l-4 4z" })
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
var LockIcon = ({ locked }) => {
|
|
47
|
+
return /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: locked ? /* @__PURE__ */ jsx("path", { d: "M17 8h-1V6a4 4 0 10-8 0v2H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V10a2 2 0 00-2-2zm-7-2a2 2 0 114 0v2h-4V6z" }) : /* @__PURE__ */ jsx("path", { d: "M17 8h-1V6a4 4 0 00-7.75-1.41 1 1 0 101.9.62A2 2 0 0114 6v2H7a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2V10a2 2 0 00-2-2zm0 12H7V10h10v10z" }) });
|
|
48
|
+
};
|
|
49
|
+
var LoadingSpinner = () => /* @__PURE__ */ jsx(
|
|
50
|
+
"svg",
|
|
51
|
+
{
|
|
52
|
+
className: getLoadingOverlaySpinnerClasses(),
|
|
53
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
54
|
+
fill: "none",
|
|
55
|
+
viewBox: spinnerSvg.viewBox,
|
|
56
|
+
children: spinnerSvg.elements.map((el, index) => {
|
|
57
|
+
if (el.type === "circle") return /* @__PURE__ */ jsx("circle", { ...el.attrs }, index);
|
|
58
|
+
if (el.type === "path") return /* @__PURE__ */ jsx("path", { ...el.attrs }, index);
|
|
59
|
+
return null;
|
|
60
|
+
})
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
function Table({
|
|
64
|
+
columns,
|
|
65
|
+
columnLockable = false,
|
|
66
|
+
dataSource = [],
|
|
67
|
+
sort,
|
|
68
|
+
defaultSort,
|
|
69
|
+
filters,
|
|
70
|
+
defaultFilters,
|
|
71
|
+
size = "md",
|
|
72
|
+
bordered = false,
|
|
73
|
+
striped = false,
|
|
74
|
+
hoverable = true,
|
|
75
|
+
loading = false,
|
|
76
|
+
emptyText = "No data",
|
|
77
|
+
pagination = {
|
|
78
|
+
current: 1,
|
|
79
|
+
pageSize: 10,
|
|
80
|
+
total: 0,
|
|
81
|
+
pageSizeOptions: [10, 20, 50, 100],
|
|
82
|
+
showSizeChanger: true,
|
|
83
|
+
showTotal: true
|
|
84
|
+
},
|
|
85
|
+
rowSelection,
|
|
86
|
+
rowKey = "id",
|
|
87
|
+
rowClassName,
|
|
88
|
+
stickyHeader = false,
|
|
89
|
+
maxHeight,
|
|
90
|
+
onChange,
|
|
91
|
+
onRowClick,
|
|
92
|
+
onSelectionChange,
|
|
93
|
+
onSortChange,
|
|
94
|
+
onFilterChange,
|
|
95
|
+
onPageChange,
|
|
96
|
+
className,
|
|
97
|
+
...props
|
|
98
|
+
}) {
|
|
99
|
+
const isSortControlled = sort !== void 0;
|
|
100
|
+
const isFiltersControlled = filters !== void 0;
|
|
101
|
+
const paginationConfig = pagination !== false && typeof pagination === "object" ? pagination : null;
|
|
102
|
+
const isCurrentPageControlled = paginationConfig?.current !== void 0;
|
|
103
|
+
const isPageSizeControlled = paginationConfig?.pageSize !== void 0;
|
|
104
|
+
const isSelectionControlled = rowSelection?.selectedRowKeys !== void 0 && Array.isArray(rowSelection.selectedRowKeys);
|
|
105
|
+
const [uncontrolledSortState, setUncontrolledSortState] = useState(
|
|
106
|
+
defaultSort ?? { key: null, direction: null }
|
|
107
|
+
);
|
|
108
|
+
const [uncontrolledFilterState, setUncontrolledFilterState] = useState(
|
|
109
|
+
defaultFilters ?? {}
|
|
110
|
+
);
|
|
111
|
+
const [uncontrolledCurrentPage, setUncontrolledCurrentPage] = useState(
|
|
112
|
+
() => paginationConfig?.defaultCurrent ?? paginationConfig?.current ?? 1
|
|
113
|
+
);
|
|
114
|
+
const [uncontrolledCurrentPageSize, setUncontrolledCurrentPageSize] = useState(
|
|
115
|
+
() => paginationConfig?.defaultPageSize ?? paginationConfig?.pageSize ?? 10
|
|
116
|
+
);
|
|
117
|
+
const [uncontrolledSelectedRowKeys, setUncontrolledSelectedRowKeys] = useState(rowSelection?.defaultSelectedRowKeys ?? rowSelection?.selectedRowKeys ?? []);
|
|
118
|
+
const sortState = isSortControlled ? sort : uncontrolledSortState;
|
|
119
|
+
const filterState = isFiltersControlled ? filters : uncontrolledFilterState;
|
|
120
|
+
const currentPage = isCurrentPageControlled ? paginationConfig.current : uncontrolledCurrentPage;
|
|
121
|
+
const currentPageSize = isPageSizeControlled ? paginationConfig.pageSize : uncontrolledCurrentPageSize;
|
|
122
|
+
const selectedRowKeys = isSelectionControlled ? rowSelection.selectedRowKeys : uncontrolledSelectedRowKeys;
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (isSortControlled && sort) {
|
|
125
|
+
setUncontrolledSortState(sort);
|
|
126
|
+
}
|
|
127
|
+
}, [isSortControlled, sort?.key, sort?.direction]);
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
if (isFiltersControlled && filters) {
|
|
130
|
+
setUncontrolledFilterState(filters);
|
|
131
|
+
}
|
|
132
|
+
}, [isFiltersControlled, filters]);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (isCurrentPageControlled) {
|
|
135
|
+
setUncontrolledCurrentPage(paginationConfig.current);
|
|
136
|
+
}
|
|
137
|
+
}, [isCurrentPageControlled, paginationConfig?.current]);
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (isPageSizeControlled) {
|
|
140
|
+
setUncontrolledCurrentPageSize(paginationConfig.pageSize);
|
|
141
|
+
}
|
|
142
|
+
}, [isPageSizeControlled, paginationConfig?.pageSize]);
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (isSelectionControlled) {
|
|
145
|
+
setUncontrolledSelectedRowKeys(rowSelection?.selectedRowKeys ?? []);
|
|
146
|
+
}
|
|
147
|
+
}, [isSelectionControlled, rowSelection?.selectedRowKeys]);
|
|
148
|
+
const [fixedOverrides, setFixedOverrides] = useState({});
|
|
149
|
+
const displayColumns = useMemo(() => {
|
|
150
|
+
return columns.map((column) => {
|
|
151
|
+
const hasOverride = Object.prototype.hasOwnProperty.call(fixedOverrides, column.key);
|
|
152
|
+
return {
|
|
153
|
+
...column,
|
|
154
|
+
fixed: hasOverride ? fixedOverrides[column.key] : column.fixed
|
|
155
|
+
};
|
|
156
|
+
});
|
|
157
|
+
}, [columns, fixedOverrides]);
|
|
158
|
+
const columnByKey = useMemo(() => {
|
|
159
|
+
const map = {};
|
|
160
|
+
for (const column of displayColumns) {
|
|
161
|
+
map[column.key] = column;
|
|
162
|
+
}
|
|
163
|
+
return map;
|
|
164
|
+
}, [displayColumns]);
|
|
165
|
+
const fixedColumnsInfo = useMemo(() => {
|
|
166
|
+
return getFixedColumnOffsets(displayColumns);
|
|
167
|
+
}, [displayColumns]);
|
|
168
|
+
const toggleColumnLock = useCallback(
|
|
169
|
+
(columnKey) => {
|
|
170
|
+
setFixedOverrides((prev) => {
|
|
171
|
+
const original = columns.find((c) => c.key === columnKey)?.fixed;
|
|
172
|
+
const current = Object.prototype.hasOwnProperty.call(prev, columnKey) ? prev[columnKey] : original;
|
|
173
|
+
const isLocked = current === "left" || current === "right";
|
|
174
|
+
return {
|
|
175
|
+
...prev,
|
|
176
|
+
[columnKey]: isLocked ? false : "left"
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
[columns]
|
|
181
|
+
);
|
|
182
|
+
const processedData = useMemo(() => {
|
|
183
|
+
let data = dataSource;
|
|
184
|
+
data = filterData(data, filterState);
|
|
185
|
+
if (sortState.key && sortState.direction) {
|
|
186
|
+
const column = columnByKey[sortState.key];
|
|
187
|
+
data = sortData(data, sortState.key, sortState.direction, column?.sortFn);
|
|
188
|
+
}
|
|
189
|
+
return data;
|
|
190
|
+
}, [dataSource, filterState, sortState, columnByKey]);
|
|
191
|
+
const paginatedData = useMemo(() => {
|
|
192
|
+
if (pagination === false) {
|
|
193
|
+
return processedData;
|
|
194
|
+
}
|
|
195
|
+
return paginateData(processedData, currentPage, currentPageSize);
|
|
196
|
+
}, [processedData, currentPage, currentPageSize, pagination]);
|
|
197
|
+
const pageRowKeys = useMemo(
|
|
198
|
+
() => paginatedData.map((record, index) => getRowKey(record, rowKey, index)),
|
|
199
|
+
[paginatedData, rowKey]
|
|
200
|
+
);
|
|
201
|
+
const selectedRowKeySet = useMemo(
|
|
202
|
+
() => new Set(selectedRowKeys),
|
|
203
|
+
[selectedRowKeys]
|
|
204
|
+
);
|
|
205
|
+
const paginationInfo = useMemo(() => {
|
|
206
|
+
if (pagination === false) {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
const total = processedData.length;
|
|
210
|
+
return calculatePagination(total, currentPage, currentPageSize);
|
|
211
|
+
}, [processedData.length, currentPage, currentPageSize, pagination]);
|
|
212
|
+
const handleSort = useCallback(
|
|
213
|
+
(columnKey) => {
|
|
214
|
+
const column = columnByKey[columnKey];
|
|
215
|
+
if (!column || !column.sortable) {
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
let newDirection = "asc";
|
|
219
|
+
if (sortState.key === columnKey) {
|
|
220
|
+
if (sortState.direction === "asc") {
|
|
221
|
+
newDirection = "desc";
|
|
222
|
+
} else if (sortState.direction === "desc") {
|
|
223
|
+
newDirection = null;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const newSortState = {
|
|
227
|
+
key: newDirection ? columnKey : null,
|
|
228
|
+
direction: newDirection
|
|
229
|
+
};
|
|
230
|
+
if (!isSortControlled) {
|
|
231
|
+
setUncontrolledSortState(newSortState);
|
|
232
|
+
}
|
|
233
|
+
onSortChange?.(newSortState);
|
|
234
|
+
onChange?.({
|
|
235
|
+
sort: newSortState,
|
|
236
|
+
filters: filterState,
|
|
237
|
+
pagination: pagination !== false ? {
|
|
238
|
+
current: currentPage,
|
|
239
|
+
pageSize: currentPageSize
|
|
240
|
+
} : null
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
[
|
|
244
|
+
columnByKey,
|
|
245
|
+
sortState,
|
|
246
|
+
filterState,
|
|
247
|
+
currentPage,
|
|
248
|
+
currentPageSize,
|
|
249
|
+
pagination,
|
|
250
|
+
isSortControlled,
|
|
251
|
+
onSortChange,
|
|
252
|
+
onChange
|
|
253
|
+
]
|
|
254
|
+
);
|
|
255
|
+
const handleFilter = useCallback(
|
|
256
|
+
(columnKey, value) => {
|
|
257
|
+
const newFilterState = {
|
|
258
|
+
...filterState,
|
|
259
|
+
[columnKey]: value
|
|
260
|
+
};
|
|
261
|
+
if (!isFiltersControlled) {
|
|
262
|
+
setUncontrolledFilterState(newFilterState);
|
|
263
|
+
}
|
|
264
|
+
setUncontrolledCurrentPage(1);
|
|
265
|
+
onFilterChange?.(newFilterState);
|
|
266
|
+
onChange?.({
|
|
267
|
+
sort: sortState,
|
|
268
|
+
filters: newFilterState,
|
|
269
|
+
pagination: pagination !== false ? {
|
|
270
|
+
current: 1,
|
|
271
|
+
pageSize: currentPageSize
|
|
272
|
+
} : null
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
[
|
|
276
|
+
filterState,
|
|
277
|
+
sortState,
|
|
278
|
+
currentPageSize,
|
|
279
|
+
pagination,
|
|
280
|
+
isFiltersControlled,
|
|
281
|
+
onFilterChange,
|
|
282
|
+
onChange
|
|
283
|
+
]
|
|
284
|
+
);
|
|
285
|
+
const handlePageChange = useCallback(
|
|
286
|
+
(page) => {
|
|
287
|
+
if (!isCurrentPageControlled) {
|
|
288
|
+
setUncontrolledCurrentPage(page);
|
|
289
|
+
} else {
|
|
290
|
+
setUncontrolledCurrentPage(page);
|
|
291
|
+
}
|
|
292
|
+
onPageChange?.({ current: page, pageSize: currentPageSize });
|
|
293
|
+
onChange?.({
|
|
294
|
+
sort: sortState,
|
|
295
|
+
filters: filterState,
|
|
296
|
+
pagination: {
|
|
297
|
+
current: page,
|
|
298
|
+
pageSize: currentPageSize
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
[currentPageSize, sortState, filterState, isCurrentPageControlled, onPageChange, onChange]
|
|
303
|
+
);
|
|
304
|
+
const handlePageSizeChange = useCallback(
|
|
305
|
+
(pageSize) => {
|
|
306
|
+
if (!isPageSizeControlled) {
|
|
307
|
+
setUncontrolledCurrentPageSize(pageSize);
|
|
308
|
+
} else {
|
|
309
|
+
setUncontrolledCurrentPageSize(pageSize);
|
|
310
|
+
}
|
|
311
|
+
if (!isCurrentPageControlled) {
|
|
312
|
+
setUncontrolledCurrentPage(1);
|
|
313
|
+
} else {
|
|
314
|
+
setUncontrolledCurrentPage(1);
|
|
315
|
+
}
|
|
316
|
+
onPageChange?.({ current: 1, pageSize });
|
|
317
|
+
onChange?.({
|
|
318
|
+
sort: sortState,
|
|
319
|
+
filters: filterState,
|
|
320
|
+
pagination: {
|
|
321
|
+
current: 1,
|
|
322
|
+
pageSize
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
},
|
|
326
|
+
[sortState, filterState, isPageSizeControlled, isCurrentPageControlled, onPageChange, onChange]
|
|
327
|
+
);
|
|
328
|
+
const handleRowClick = useCallback(
|
|
329
|
+
(record, index) => {
|
|
330
|
+
onRowClick?.(record, index);
|
|
331
|
+
},
|
|
332
|
+
[onRowClick]
|
|
333
|
+
);
|
|
334
|
+
const handleSelectRow = useCallback(
|
|
335
|
+
(key, checked) => {
|
|
336
|
+
let newKeys;
|
|
337
|
+
if (rowSelection?.type === "radio") {
|
|
338
|
+
newKeys = checked ? [key] : [];
|
|
339
|
+
} else {
|
|
340
|
+
if (checked) {
|
|
341
|
+
newKeys = [...selectedRowKeys, key];
|
|
342
|
+
} else {
|
|
343
|
+
newKeys = selectedRowKeys.filter((k) => k !== key);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
if (!isSelectionControlled) {
|
|
347
|
+
setUncontrolledSelectedRowKeys(newKeys);
|
|
348
|
+
}
|
|
349
|
+
onSelectionChange?.(newKeys);
|
|
350
|
+
},
|
|
351
|
+
[rowSelection, selectedRowKeys, isSelectionControlled, onSelectionChange]
|
|
352
|
+
);
|
|
353
|
+
const handleSelectAll = useCallback(
|
|
354
|
+
(checked) => {
|
|
355
|
+
if (checked) {
|
|
356
|
+
const newKeys = pageRowKeys;
|
|
357
|
+
if (!isSelectionControlled) {
|
|
358
|
+
setUncontrolledSelectedRowKeys(newKeys);
|
|
359
|
+
}
|
|
360
|
+
onSelectionChange?.(newKeys);
|
|
361
|
+
} else {
|
|
362
|
+
if (!isSelectionControlled) {
|
|
363
|
+
setUncontrolledSelectedRowKeys([]);
|
|
364
|
+
}
|
|
365
|
+
onSelectionChange?.([]);
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
[pageRowKeys, isSelectionControlled, onSelectionChange]
|
|
369
|
+
);
|
|
370
|
+
const allSelected = useMemo(() => {
|
|
371
|
+
if (pageRowKeys.length === 0) {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
return pageRowKeys.every((key) => selectedRowKeySet.has(key));
|
|
375
|
+
}, [pageRowKeys, selectedRowKeySet]);
|
|
376
|
+
const someSelected = useMemo(() => {
|
|
377
|
+
return selectedRowKeys.length > 0 && !allSelected;
|
|
378
|
+
}, [selectedRowKeys.length, allSelected]);
|
|
379
|
+
const renderTableHeader = useCallback(() => {
|
|
380
|
+
return /* @__PURE__ */ jsx("thead", { className: getTableHeaderClasses(stickyHeader), children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
381
|
+
rowSelection && rowSelection.showCheckbox !== false && rowSelection.type !== "radio" && /* @__PURE__ */ jsx("th", { className: getCheckboxCellClasses(size), children: /* @__PURE__ */ jsx(
|
|
382
|
+
"input",
|
|
383
|
+
{
|
|
384
|
+
type: "checkbox",
|
|
385
|
+
className: "rounded border-gray-300 text-[var(--tiger-primary,#2563eb)] focus:ring-[var(--tiger-primary,#2563eb)]",
|
|
386
|
+
checked: allSelected,
|
|
387
|
+
ref: (el) => {
|
|
388
|
+
if (el) el.indeterminate = someSelected;
|
|
389
|
+
},
|
|
390
|
+
onChange: (e) => handleSelectAll(e.target.checked)
|
|
391
|
+
}
|
|
392
|
+
) }),
|
|
393
|
+
displayColumns.map((column) => {
|
|
394
|
+
const isSorted = sortState.key === column.key;
|
|
395
|
+
const sortDirection = isSorted ? sortState.direction : null;
|
|
396
|
+
const ariaSort = column.sortable ? sortDirection === "asc" ? "ascending" : sortDirection === "desc" ? "descending" : "none" : void 0;
|
|
397
|
+
const isFixedLeft = column.fixed === "left";
|
|
398
|
+
const isFixedRight = column.fixed === "right";
|
|
399
|
+
const fixedStyle = isFixedLeft ? {
|
|
400
|
+
position: "sticky",
|
|
401
|
+
left: `${fixedColumnsInfo.leftOffsets[column.key] || 0}px`,
|
|
402
|
+
zIndex: 15
|
|
403
|
+
} : isFixedRight ? {
|
|
404
|
+
position: "sticky",
|
|
405
|
+
right: `${fixedColumnsInfo.rightOffsets[column.key] || 0}px`,
|
|
406
|
+
zIndex: 15
|
|
407
|
+
} : void 0;
|
|
408
|
+
const widthStyle = column.width ? {
|
|
409
|
+
width: typeof column.width === "number" ? `${column.width}px` : column.width
|
|
410
|
+
} : void 0;
|
|
411
|
+
const style = fixedStyle ? { ...widthStyle, ...fixedStyle } : widthStyle;
|
|
412
|
+
return /* @__PURE__ */ jsxs(
|
|
413
|
+
"th",
|
|
414
|
+
{
|
|
415
|
+
"aria-sort": ariaSort,
|
|
416
|
+
className: classNames(
|
|
417
|
+
getTableHeaderCellClasses(
|
|
418
|
+
size,
|
|
419
|
+
column.align || "left",
|
|
420
|
+
!!column.sortable,
|
|
421
|
+
column.headerClassName
|
|
422
|
+
),
|
|
423
|
+
(isFixedLeft || isFixedRight) && "bg-gray-50"
|
|
424
|
+
),
|
|
425
|
+
style,
|
|
426
|
+
onClick: column.sortable ? () => handleSort(column.key) : void 0,
|
|
427
|
+
children: [
|
|
428
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
429
|
+
column.renderHeader ? column.renderHeader() : column.title,
|
|
430
|
+
columnLockable && /* @__PURE__ */ jsx(
|
|
431
|
+
"button",
|
|
432
|
+
{
|
|
433
|
+
type: "button",
|
|
434
|
+
"aria-label": column.fixed === "left" || column.fixed === "right" ? `Unlock column ${column.title}` : `Lock column ${column.title}`,
|
|
435
|
+
className: classNames(
|
|
436
|
+
"inline-flex items-center",
|
|
437
|
+
column.fixed === "left" || column.fixed === "right" ? "text-[var(--tiger-primary,#2563eb)]" : "text-gray-400 hover:text-gray-700"
|
|
438
|
+
),
|
|
439
|
+
onClick: (e) => {
|
|
440
|
+
e.stopPropagation();
|
|
441
|
+
toggleColumnLock(column.key);
|
|
442
|
+
},
|
|
443
|
+
children: /* @__PURE__ */ jsx(LockIcon, { locked: column.fixed === "left" || column.fixed === "right" })
|
|
444
|
+
}
|
|
445
|
+
),
|
|
446
|
+
column.sortable && /* @__PURE__ */ jsx(SortIcon, { direction: sortDirection })
|
|
447
|
+
] }),
|
|
448
|
+
column.filter && /* @__PURE__ */ jsx("div", { className: "mt-2", children: column.filter.type === "select" && column.filter.options ? /* @__PURE__ */ jsxs(
|
|
449
|
+
"select",
|
|
450
|
+
{
|
|
451
|
+
className: "w-full px-2 py-1 text-sm border border-gray-300 rounded",
|
|
452
|
+
onChange: (e) => handleFilter(column.key, e.target.value),
|
|
453
|
+
onClick: (e) => e.stopPropagation(),
|
|
454
|
+
children: [
|
|
455
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "All" }),
|
|
456
|
+
column.filter.options.map((opt) => /* @__PURE__ */ jsx("option", { value: opt.value, children: opt.label }, opt.value))
|
|
457
|
+
]
|
|
458
|
+
}
|
|
459
|
+
) : /* @__PURE__ */ jsx(
|
|
460
|
+
"input",
|
|
461
|
+
{
|
|
462
|
+
type: "text",
|
|
463
|
+
className: "w-full px-2 py-1 text-sm border border-gray-300 rounded",
|
|
464
|
+
placeholder: column.filter.placeholder || "Filter...",
|
|
465
|
+
onInput: (e) => handleFilter(column.key, e.target.value),
|
|
466
|
+
onClick: (e) => e.stopPropagation()
|
|
467
|
+
}
|
|
468
|
+
) })
|
|
469
|
+
]
|
|
470
|
+
},
|
|
471
|
+
column.key
|
|
472
|
+
);
|
|
473
|
+
})
|
|
474
|
+
] }) });
|
|
475
|
+
}, [
|
|
476
|
+
displayColumns,
|
|
477
|
+
size,
|
|
478
|
+
stickyHeader,
|
|
479
|
+
sortState,
|
|
480
|
+
rowSelection,
|
|
481
|
+
allSelected,
|
|
482
|
+
someSelected,
|
|
483
|
+
handleSort,
|
|
484
|
+
handleFilter,
|
|
485
|
+
handleSelectAll,
|
|
486
|
+
columnLockable,
|
|
487
|
+
toggleColumnLock,
|
|
488
|
+
fixedColumnsInfo
|
|
489
|
+
]);
|
|
490
|
+
const renderTableBody = useCallback(() => {
|
|
491
|
+
if (loading) {
|
|
492
|
+
return null;
|
|
493
|
+
}
|
|
494
|
+
if (paginatedData.length === 0) {
|
|
495
|
+
return /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx(
|
|
496
|
+
"td",
|
|
497
|
+
{
|
|
498
|
+
colSpan: displayColumns.length + (rowSelection ? 1 : 0),
|
|
499
|
+
className: tableEmptyStateClasses,
|
|
500
|
+
children: /* @__PURE__ */ jsx("div", { role: "status", "aria-live": "polite", children: emptyText })
|
|
501
|
+
}
|
|
502
|
+
) }) });
|
|
503
|
+
}
|
|
504
|
+
return /* @__PURE__ */ jsx("tbody", { children: paginatedData.map((record, index) => {
|
|
505
|
+
const key = pageRowKeys[index];
|
|
506
|
+
const isSelected = selectedRowKeySet.has(key);
|
|
507
|
+
const rowClass = typeof rowClassName === "function" ? rowClassName(record, index) : rowClassName;
|
|
508
|
+
return /* @__PURE__ */ jsxs(
|
|
509
|
+
"tr",
|
|
510
|
+
{
|
|
511
|
+
className: classNames(
|
|
512
|
+
getTableRowClasses(hoverable, striped, index % 2 === 0, rowClass),
|
|
513
|
+
fixedColumnsInfo.hasFixedColumns && "group"
|
|
514
|
+
),
|
|
515
|
+
onClick: () => handleRowClick(record, index),
|
|
516
|
+
children: [
|
|
517
|
+
rowSelection && rowSelection.showCheckbox !== false && /* @__PURE__ */ jsx("td", { className: getCheckboxCellClasses(size), children: /* @__PURE__ */ jsx(
|
|
518
|
+
"input",
|
|
519
|
+
{
|
|
520
|
+
type: rowSelection?.type === "radio" ? "radio" : "checkbox",
|
|
521
|
+
className: rowSelection?.type === "radio" ? "border-gray-300 text-[var(--tiger-primary,#2563eb)] focus:ring-[var(--tiger-primary,#2563eb)]" : "rounded border-gray-300 text-[var(--tiger-primary,#2563eb)] focus:ring-[var(--tiger-primary,#2563eb)]",
|
|
522
|
+
checked: isSelected,
|
|
523
|
+
disabled: rowSelection?.getCheckboxProps?.(record)?.disabled,
|
|
524
|
+
onChange: (e) => handleSelectRow(key, e.target.checked),
|
|
525
|
+
onClick: (e) => e.stopPropagation()
|
|
526
|
+
}
|
|
527
|
+
) }),
|
|
528
|
+
displayColumns.map((column) => {
|
|
529
|
+
const dataKey = column.dataKey || column.key;
|
|
530
|
+
const cellValue = record[dataKey];
|
|
531
|
+
const isFixedLeft = column.fixed === "left";
|
|
532
|
+
const isFixedRight = column.fixed === "right";
|
|
533
|
+
const fixedStyle = isFixedLeft ? {
|
|
534
|
+
position: "sticky",
|
|
535
|
+
left: `${fixedColumnsInfo.leftOffsets[column.key] || 0}px`,
|
|
536
|
+
zIndex: 10
|
|
537
|
+
} : isFixedRight ? {
|
|
538
|
+
position: "sticky",
|
|
539
|
+
right: `${fixedColumnsInfo.rightOffsets[column.key] || 0}px`,
|
|
540
|
+
zIndex: 10
|
|
541
|
+
} : void 0;
|
|
542
|
+
const widthStyle = column.width ? {
|
|
543
|
+
width: typeof column.width === "number" ? `${column.width}px` : column.width
|
|
544
|
+
} : void 0;
|
|
545
|
+
const style = fixedStyle ? { ...widthStyle, ...fixedStyle } : widthStyle;
|
|
546
|
+
const stickyBgClass = striped && index % 2 === 0 ? "bg-gray-50/50" : "bg-white";
|
|
547
|
+
const stickyCellClass = isFixedLeft || isFixedRight ? classNames(stickyBgClass, hoverable && "group-hover:bg-gray-50") : void 0;
|
|
548
|
+
return /* @__PURE__ */ jsx(
|
|
549
|
+
"td",
|
|
550
|
+
{
|
|
551
|
+
className: classNames(
|
|
552
|
+
getTableCellClasses(size, column.align || "left", column.className),
|
|
553
|
+
stickyCellClass
|
|
554
|
+
),
|
|
555
|
+
style,
|
|
556
|
+
children: column.render ? column.render(record, index) : cellValue
|
|
557
|
+
},
|
|
558
|
+
column.key
|
|
559
|
+
);
|
|
560
|
+
})
|
|
561
|
+
]
|
|
562
|
+
},
|
|
563
|
+
key
|
|
564
|
+
);
|
|
565
|
+
}) });
|
|
566
|
+
}, [
|
|
567
|
+
loading,
|
|
568
|
+
paginatedData,
|
|
569
|
+
displayColumns,
|
|
570
|
+
rowSelection,
|
|
571
|
+
emptyText,
|
|
572
|
+
pageRowKeys,
|
|
573
|
+
selectedRowKeySet,
|
|
574
|
+
rowClassName,
|
|
575
|
+
hoverable,
|
|
576
|
+
striped,
|
|
577
|
+
size,
|
|
578
|
+
handleRowClick,
|
|
579
|
+
handleSelectRow,
|
|
580
|
+
fixedColumnsInfo
|
|
581
|
+
]);
|
|
582
|
+
const renderPagination = useCallback(() => {
|
|
583
|
+
if (pagination === false || !paginationInfo) {
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
const { totalPages, startIndex, endIndex, hasNext, hasPrev } = paginationInfo;
|
|
587
|
+
const total = processedData.length;
|
|
588
|
+
const paginationConfig2 = pagination;
|
|
589
|
+
return /* @__PURE__ */ jsxs("div", { className: tablePaginationContainerClasses, children: [
|
|
590
|
+
paginationConfig2.showTotal !== false && /* @__PURE__ */ jsx("div", { className: "text-sm text-gray-700", children: paginationConfig2.totalText ? paginationConfig2.totalText(total, [startIndex, endIndex]) : `Showing ${startIndex} to ${endIndex} of ${total} results` }),
|
|
591
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
592
|
+
paginationConfig2.showSizeChanger !== false && /* @__PURE__ */ jsx(
|
|
593
|
+
"select",
|
|
594
|
+
{
|
|
595
|
+
className: "px-3 py-1 border border-gray-300 rounded text-sm",
|
|
596
|
+
value: currentPageSize,
|
|
597
|
+
onChange: (e) => handlePageSizeChange(Number(e.target.value)),
|
|
598
|
+
children: (paginationConfig2.pageSizeOptions || [10, 20, 50, 100]).map((size2) => /* @__PURE__ */ jsxs("option", { value: size2, children: [
|
|
599
|
+
size2,
|
|
600
|
+
" / page"
|
|
601
|
+
] }, size2))
|
|
602
|
+
}
|
|
603
|
+
),
|
|
604
|
+
/* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
605
|
+
/* @__PURE__ */ jsx(
|
|
606
|
+
"button",
|
|
607
|
+
{
|
|
608
|
+
className: classNames(
|
|
609
|
+
"px-3 py-1 border border-gray-300 rounded text-sm",
|
|
610
|
+
hasPrev ? "hover:bg-gray-50 text-gray-700" : "text-gray-400 cursor-not-allowed"
|
|
611
|
+
),
|
|
612
|
+
disabled: !hasPrev,
|
|
613
|
+
onClick: () => handlePageChange(currentPage - 1),
|
|
614
|
+
children: "Previous"
|
|
615
|
+
}
|
|
616
|
+
),
|
|
617
|
+
/* @__PURE__ */ jsxs("span", { className: "px-3 py-1 text-sm text-gray-700", children: [
|
|
618
|
+
"Page ",
|
|
619
|
+
currentPage,
|
|
620
|
+
" of ",
|
|
621
|
+
totalPages
|
|
622
|
+
] }),
|
|
623
|
+
/* @__PURE__ */ jsx(
|
|
624
|
+
"button",
|
|
625
|
+
{
|
|
626
|
+
className: classNames(
|
|
627
|
+
"px-3 py-1 border border-gray-300 rounded text-sm",
|
|
628
|
+
hasNext ? "hover:bg-gray-50 text-gray-700" : "text-gray-400 cursor-not-allowed"
|
|
629
|
+
),
|
|
630
|
+
disabled: !hasNext,
|
|
631
|
+
onClick: () => handlePageChange(currentPage + 1),
|
|
632
|
+
children: "Next"
|
|
633
|
+
}
|
|
634
|
+
)
|
|
635
|
+
] })
|
|
636
|
+
] })
|
|
637
|
+
] });
|
|
638
|
+
}, [
|
|
639
|
+
pagination,
|
|
640
|
+
paginationInfo,
|
|
641
|
+
processedData.length,
|
|
642
|
+
currentPage,
|
|
643
|
+
currentPageSize,
|
|
644
|
+
handlePageChange,
|
|
645
|
+
handlePageSizeChange
|
|
646
|
+
]);
|
|
647
|
+
const wrapperStyle = useMemo(
|
|
648
|
+
() => maxHeight ? {
|
|
649
|
+
maxHeight: typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight
|
|
650
|
+
} : void 0,
|
|
651
|
+
[maxHeight]
|
|
652
|
+
);
|
|
653
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames("relative", className), children: [
|
|
654
|
+
/* @__PURE__ */ jsxs(
|
|
655
|
+
"div",
|
|
656
|
+
{
|
|
657
|
+
className: getTableWrapperClasses(bordered, maxHeight),
|
|
658
|
+
style: wrapperStyle,
|
|
659
|
+
"aria-busy": loading,
|
|
660
|
+
children: [
|
|
661
|
+
/* @__PURE__ */ jsxs(
|
|
662
|
+
"table",
|
|
663
|
+
{
|
|
664
|
+
className: tableBaseClasses,
|
|
665
|
+
...props,
|
|
666
|
+
style: fixedColumnsInfo.hasFixedColumns && fixedColumnsInfo.minTableWidth ? {
|
|
667
|
+
...props.style,
|
|
668
|
+
minWidth: `${fixedColumnsInfo.minTableWidth}px`
|
|
669
|
+
} : props.style,
|
|
670
|
+
children: [
|
|
671
|
+
renderTableHeader(),
|
|
672
|
+
renderTableBody()
|
|
673
|
+
]
|
|
674
|
+
}
|
|
675
|
+
),
|
|
676
|
+
loading && /* @__PURE__ */ jsxs(
|
|
677
|
+
"div",
|
|
678
|
+
{
|
|
679
|
+
className: tableLoadingOverlayClasses,
|
|
680
|
+
role: "status",
|
|
681
|
+
"aria-live": "polite",
|
|
682
|
+
"aria-label": "Loading",
|
|
683
|
+
children: [
|
|
684
|
+
/* @__PURE__ */ jsx(LoadingSpinner, {}),
|
|
685
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "Loading" })
|
|
686
|
+
]
|
|
687
|
+
}
|
|
688
|
+
)
|
|
689
|
+
]
|
|
690
|
+
}
|
|
691
|
+
),
|
|
692
|
+
renderPagination()
|
|
693
|
+
] });
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export { Table };
|