@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,297 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import { getTotalPages, validateCurrentPage, getPageRange, getPaginationContainerClasses, defaultTotalText, getTotalTextClasses, getPaginationButtonBaseClasses, classNames, getPageNumbers, getPaginationEllipsisClasses, getPaginationButtonActiveClasses, getPageSizeSelectorClasses, getQuickJumperInputClasses } from '@expcat/tigercat-core';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Pagination.tsx
|
|
6
|
+
var Pagination = ({
|
|
7
|
+
current: controlledCurrent,
|
|
8
|
+
defaultCurrent = 1,
|
|
9
|
+
total = 0,
|
|
10
|
+
pageSize: controlledPageSize,
|
|
11
|
+
defaultPageSize = 10,
|
|
12
|
+
pageSizeOptions = [10, 20, 50, 100],
|
|
13
|
+
showQuickJumper = false,
|
|
14
|
+
showSizeChanger = false,
|
|
15
|
+
showTotal = true,
|
|
16
|
+
totalText,
|
|
17
|
+
simple = false,
|
|
18
|
+
size = "medium",
|
|
19
|
+
align = "center",
|
|
20
|
+
disabled = false,
|
|
21
|
+
hideOnSinglePage = false,
|
|
22
|
+
showLessItems = false,
|
|
23
|
+
className,
|
|
24
|
+
style,
|
|
25
|
+
onChange,
|
|
26
|
+
onPageSizeChange,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
const { "aria-label": ariaLabelProp, ...navProps } = props;
|
|
30
|
+
const [internalCurrent, setInternalCurrent] = useState(defaultCurrent);
|
|
31
|
+
const [internalPageSize, setInternalPageSize] = useState(defaultPageSize);
|
|
32
|
+
const [quickJumperValue, setQuickJumperValue] = useState("");
|
|
33
|
+
const currentPage = controlledCurrent !== void 0 ? controlledCurrent : internalCurrent;
|
|
34
|
+
const currentPageSize = controlledPageSize !== void 0 ? controlledPageSize : internalPageSize;
|
|
35
|
+
const totalPages = getTotalPages(total, currentPageSize);
|
|
36
|
+
const validatedCurrentPage = validateCurrentPage(currentPage, totalPages);
|
|
37
|
+
const pageRange = getPageRange(validatedCurrentPage, currentPageSize, total);
|
|
38
|
+
if (hideOnSinglePage && totalPages <= 1) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const handlePageChange = useCallback(
|
|
42
|
+
(page) => {
|
|
43
|
+
if (disabled) return;
|
|
44
|
+
if (page === validatedCurrentPage) return;
|
|
45
|
+
if (page < 1 || page > totalPages) return;
|
|
46
|
+
if (controlledCurrent === void 0) {
|
|
47
|
+
setInternalCurrent(page);
|
|
48
|
+
}
|
|
49
|
+
onChange?.(page, currentPageSize);
|
|
50
|
+
},
|
|
51
|
+
[disabled, validatedCurrentPage, totalPages, controlledCurrent, onChange, currentPageSize]
|
|
52
|
+
);
|
|
53
|
+
const handlePageSizeChange = useCallback(
|
|
54
|
+
(newPageSize) => {
|
|
55
|
+
if (disabled) return;
|
|
56
|
+
const newTotalPages = getTotalPages(total, newPageSize);
|
|
57
|
+
let newPage = validatedCurrentPage;
|
|
58
|
+
if (newPage > newTotalPages) {
|
|
59
|
+
newPage = Math.max(1, newTotalPages);
|
|
60
|
+
}
|
|
61
|
+
if (controlledPageSize === void 0) {
|
|
62
|
+
setInternalPageSize(newPageSize);
|
|
63
|
+
}
|
|
64
|
+
if (controlledCurrent === void 0 && newPage !== validatedCurrentPage) {
|
|
65
|
+
setInternalCurrent(newPage);
|
|
66
|
+
}
|
|
67
|
+
onPageSizeChange?.(newPage, newPageSize);
|
|
68
|
+
if (newPage !== validatedCurrentPage) {
|
|
69
|
+
onChange?.(newPage, newPageSize);
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[
|
|
73
|
+
disabled,
|
|
74
|
+
total,
|
|
75
|
+
validatedCurrentPage,
|
|
76
|
+
controlledPageSize,
|
|
77
|
+
controlledCurrent,
|
|
78
|
+
onPageSizeChange,
|
|
79
|
+
onChange
|
|
80
|
+
]
|
|
81
|
+
);
|
|
82
|
+
const handleQuickJumperSubmit = useCallback(() => {
|
|
83
|
+
const page = parseInt(quickJumperValue, 10);
|
|
84
|
+
if (!isNaN(page)) {
|
|
85
|
+
handlePageChange(page);
|
|
86
|
+
}
|
|
87
|
+
setQuickJumperValue("");
|
|
88
|
+
}, [quickJumperValue, handlePageChange]);
|
|
89
|
+
const handleQuickJumperKeyPress = useCallback(
|
|
90
|
+
(event) => {
|
|
91
|
+
if (event.key === "Enter") {
|
|
92
|
+
handleQuickJumperSubmit();
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[handleQuickJumperSubmit]
|
|
96
|
+
);
|
|
97
|
+
const containerClasses = getPaginationContainerClasses(align, className);
|
|
98
|
+
const elements = [];
|
|
99
|
+
if (showTotal) {
|
|
100
|
+
const totalTextFn = totalText || defaultTotalText;
|
|
101
|
+
const totalTextContent = totalTextFn(total, pageRange);
|
|
102
|
+
elements.push(
|
|
103
|
+
/* @__PURE__ */ jsx("span", { className: getTotalTextClasses(size), children: totalTextContent }, "total")
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (simple) {
|
|
107
|
+
const prevDisabled = validatedCurrentPage <= 1 || disabled;
|
|
108
|
+
const nextDisabled = validatedCurrentPage >= totalPages || disabled;
|
|
109
|
+
elements.push(
|
|
110
|
+
/* @__PURE__ */ jsx(
|
|
111
|
+
"button",
|
|
112
|
+
{
|
|
113
|
+
type: "button",
|
|
114
|
+
className: getPaginationButtonBaseClasses(size),
|
|
115
|
+
disabled: prevDisabled,
|
|
116
|
+
onClick: () => handlePageChange(validatedCurrentPage - 1),
|
|
117
|
+
"aria-label": "\u4E0A\u4E00\u9875",
|
|
118
|
+
children: "\u2039"
|
|
119
|
+
},
|
|
120
|
+
"prev"
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
elements.push(
|
|
124
|
+
/* @__PURE__ */ jsxs(
|
|
125
|
+
"span",
|
|
126
|
+
{
|
|
127
|
+
className: classNames(
|
|
128
|
+
"mx-2",
|
|
129
|
+
size === "small" ? "text-sm" : size === "large" ? "text-lg" : "text-base"
|
|
130
|
+
),
|
|
131
|
+
children: [
|
|
132
|
+
validatedCurrentPage,
|
|
133
|
+
" / ",
|
|
134
|
+
totalPages
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"current"
|
|
138
|
+
)
|
|
139
|
+
);
|
|
140
|
+
elements.push(
|
|
141
|
+
/* @__PURE__ */ jsx(
|
|
142
|
+
"button",
|
|
143
|
+
{
|
|
144
|
+
type: "button",
|
|
145
|
+
className: getPaginationButtonBaseClasses(size),
|
|
146
|
+
disabled: nextDisabled,
|
|
147
|
+
onClick: () => handlePageChange(validatedCurrentPage + 1),
|
|
148
|
+
"aria-label": "\u4E0B\u4E00\u9875",
|
|
149
|
+
children: "\u203A"
|
|
150
|
+
},
|
|
151
|
+
"next"
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
} else {
|
|
155
|
+
const prevDisabled = validatedCurrentPage <= 1 || disabled;
|
|
156
|
+
const nextDisabled = validatedCurrentPage >= totalPages || disabled;
|
|
157
|
+
elements.push(
|
|
158
|
+
/* @__PURE__ */ jsx(
|
|
159
|
+
"button",
|
|
160
|
+
{
|
|
161
|
+
type: "button",
|
|
162
|
+
className: getPaginationButtonBaseClasses(size),
|
|
163
|
+
disabled: prevDisabled,
|
|
164
|
+
onClick: () => handlePageChange(validatedCurrentPage - 1),
|
|
165
|
+
"aria-label": "\u4E0A\u4E00\u9875",
|
|
166
|
+
children: "\u2039"
|
|
167
|
+
},
|
|
168
|
+
"prev"
|
|
169
|
+
)
|
|
170
|
+
);
|
|
171
|
+
const pageNumbers = getPageNumbers(validatedCurrentPage, totalPages, showLessItems);
|
|
172
|
+
pageNumbers.forEach((pageNum, index) => {
|
|
173
|
+
if (pageNum === "...") {
|
|
174
|
+
elements.push(
|
|
175
|
+
/* @__PURE__ */ jsx(
|
|
176
|
+
"span",
|
|
177
|
+
{
|
|
178
|
+
className: getPaginationEllipsisClasses(size),
|
|
179
|
+
"aria-hidden": "true",
|
|
180
|
+
children: "..."
|
|
181
|
+
},
|
|
182
|
+
`ellipsis-${index}`
|
|
183
|
+
)
|
|
184
|
+
);
|
|
185
|
+
} else {
|
|
186
|
+
const isActive = pageNum === validatedCurrentPage;
|
|
187
|
+
elements.push(
|
|
188
|
+
/* @__PURE__ */ jsx(
|
|
189
|
+
"button",
|
|
190
|
+
{
|
|
191
|
+
type: "button",
|
|
192
|
+
className: classNames(
|
|
193
|
+
getPaginationButtonBaseClasses(size),
|
|
194
|
+
isActive && getPaginationButtonActiveClasses()
|
|
195
|
+
),
|
|
196
|
+
disabled,
|
|
197
|
+
onClick: () => handlePageChange(pageNum),
|
|
198
|
+
"aria-label": `\u7B2C ${pageNum} \u9875`,
|
|
199
|
+
"aria-current": isActive ? "page" : void 0,
|
|
200
|
+
children: String(pageNum)
|
|
201
|
+
},
|
|
202
|
+
`page-${pageNum}`
|
|
203
|
+
)
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
elements.push(
|
|
208
|
+
/* @__PURE__ */ jsx(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
className: getPaginationButtonBaseClasses(size),
|
|
213
|
+
disabled: nextDisabled,
|
|
214
|
+
onClick: () => handlePageChange(validatedCurrentPage + 1),
|
|
215
|
+
"aria-label": "\u4E0B\u4E00\u9875",
|
|
216
|
+
children: "\u203A"
|
|
217
|
+
},
|
|
218
|
+
"next"
|
|
219
|
+
)
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
if (showSizeChanger) {
|
|
223
|
+
elements.push(
|
|
224
|
+
/* @__PURE__ */ jsx(
|
|
225
|
+
"select",
|
|
226
|
+
{
|
|
227
|
+
className: getPageSizeSelectorClasses(size),
|
|
228
|
+
disabled,
|
|
229
|
+
value: currentPageSize,
|
|
230
|
+
onChange: (e) => handlePageSizeChange(parseInt(e.target.value, 10)),
|
|
231
|
+
"aria-label": "\u6BCF\u9875\u6761\u6570",
|
|
232
|
+
children: pageSizeOptions.map((sizeOption) => /* @__PURE__ */ jsxs("option", { value: sizeOption, children: [
|
|
233
|
+
sizeOption,
|
|
234
|
+
" \u6761/\u9875"
|
|
235
|
+
] }, sizeOption))
|
|
236
|
+
},
|
|
237
|
+
"size-changer"
|
|
238
|
+
)
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
if (showQuickJumper) {
|
|
242
|
+
elements.push(
|
|
243
|
+
/* @__PURE__ */ jsx(
|
|
244
|
+
"span",
|
|
245
|
+
{
|
|
246
|
+
className: classNames(
|
|
247
|
+
"ml-2",
|
|
248
|
+
size === "small" ? "text-sm" : size === "large" ? "text-lg" : "text-base"
|
|
249
|
+
),
|
|
250
|
+
children: "\u8DF3\u81F3"
|
|
251
|
+
},
|
|
252
|
+
"jumper-label-start"
|
|
253
|
+
)
|
|
254
|
+
);
|
|
255
|
+
elements.push(
|
|
256
|
+
/* @__PURE__ */ jsx(
|
|
257
|
+
"input",
|
|
258
|
+
{
|
|
259
|
+
type: "number",
|
|
260
|
+
className: classNames(getQuickJumperInputClasses(size), "mx-2"),
|
|
261
|
+
disabled,
|
|
262
|
+
value: quickJumperValue,
|
|
263
|
+
onChange: (e) => setQuickJumperValue(e.target.value),
|
|
264
|
+
onKeyDown: handleQuickJumperKeyPress,
|
|
265
|
+
min: 1,
|
|
266
|
+
max: totalPages,
|
|
267
|
+
"aria-label": "\u8DF3\u8F6C\u9875\u7801"
|
|
268
|
+
},
|
|
269
|
+
"jumper-input"
|
|
270
|
+
)
|
|
271
|
+
);
|
|
272
|
+
elements.push(
|
|
273
|
+
/* @__PURE__ */ jsx(
|
|
274
|
+
"span",
|
|
275
|
+
{
|
|
276
|
+
className: size === "small" ? "text-sm" : size === "large" ? "text-lg" : "text-base",
|
|
277
|
+
children: "\u9875"
|
|
278
|
+
},
|
|
279
|
+
"jumper-label-end"
|
|
280
|
+
)
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return /* @__PURE__ */ jsx(
|
|
284
|
+
"nav",
|
|
285
|
+
{
|
|
286
|
+
className: containerClasses,
|
|
287
|
+
...navProps,
|
|
288
|
+
role: "navigation",
|
|
289
|
+
"aria-label": ariaLabelProp ?? "\u5206\u9875\u5BFC\u822A",
|
|
290
|
+
style,
|
|
291
|
+
children: elements
|
|
292
|
+
}
|
|
293
|
+
);
|
|
294
|
+
};
|
|
295
|
+
var Pagination_default = Pagination;
|
|
296
|
+
|
|
297
|
+
export { Pagination, Pagination_default };
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkLXA2YBAO_js = require('./chunk-LXA2YBAO.js');
|
|
4
|
+
var chunk3WPKVV4N_js = require('./chunk-3WPKVV4N.js');
|
|
5
|
+
var chunkQFVE7GKD_js = require('./chunk-QFVE7GKD.js');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
13
|
+
|
|
14
|
+
var ExpandIcon = ({ expanded }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
+
"svg",
|
|
16
|
+
{
|
|
17
|
+
className: tigercatCore.getSubMenuExpandIconClasses(expanded),
|
|
18
|
+
width: "12",
|
|
19
|
+
height: "12",
|
|
20
|
+
viewBox: "0 0 12 12",
|
|
21
|
+
fill: "currentColor",
|
|
22
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 9L1.5 4.5L2.205 3.795L6 7.59L9.795 3.795L10.5 4.5L6 9Z" })
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
function getMenuButtonsWithin(menuEl) {
|
|
26
|
+
return Array.from(
|
|
27
|
+
menuEl.querySelectorAll('button[data-tiger-menuitem="true"]')
|
|
28
|
+
).filter((el) => !el.disabled && !el.closest('[data-tiger-menu-hidden="true"]'));
|
|
29
|
+
}
|
|
30
|
+
function roveFocus(current, next) {
|
|
31
|
+
const menuEl = current.closest('ul[role="menu"]');
|
|
32
|
+
if (!menuEl) {
|
|
33
|
+
next.focus();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const items = getMenuButtonsWithin(menuEl);
|
|
37
|
+
items.forEach((el) => {
|
|
38
|
+
el.tabIndex = el === next ? 0 : -1;
|
|
39
|
+
});
|
|
40
|
+
next.focus();
|
|
41
|
+
}
|
|
42
|
+
function moveFocus(current, delta) {
|
|
43
|
+
const menuEl = current.closest('ul[role="menu"]');
|
|
44
|
+
if (!menuEl) return;
|
|
45
|
+
const items = getMenuButtonsWithin(menuEl);
|
|
46
|
+
const currentIndex = items.indexOf(current);
|
|
47
|
+
if (currentIndex < 0) return;
|
|
48
|
+
const nextIndex = (currentIndex + delta + items.length) % items.length;
|
|
49
|
+
roveFocus(current, items[nextIndex]);
|
|
50
|
+
}
|
|
51
|
+
function focusEdge(current, edge) {
|
|
52
|
+
const menuEl = current.closest('ul[role="menu"]');
|
|
53
|
+
if (!menuEl) return;
|
|
54
|
+
const items = getMenuButtonsWithin(menuEl);
|
|
55
|
+
if (items.length === 0) return;
|
|
56
|
+
roveFocus(current, edge === "start" ? items[0] : items[items.length - 1]);
|
|
57
|
+
}
|
|
58
|
+
function focusFirstChildItemFromTitle(titleEl) {
|
|
59
|
+
const li = titleEl.closest("li");
|
|
60
|
+
const submenu = li?.querySelector('ul[role="menu"]');
|
|
61
|
+
if (!submenu) return;
|
|
62
|
+
const items = getMenuButtonsWithin(submenu);
|
|
63
|
+
if (items.length === 0) return;
|
|
64
|
+
items.forEach((el, idx) => {
|
|
65
|
+
el.tabIndex = idx === 0 ? 0 : -1;
|
|
66
|
+
});
|
|
67
|
+
items[0].focus();
|
|
68
|
+
}
|
|
69
|
+
var SubMenu = ({
|
|
70
|
+
itemKey,
|
|
71
|
+
title = "",
|
|
72
|
+
icon,
|
|
73
|
+
disabled = false,
|
|
74
|
+
className,
|
|
75
|
+
level = 0,
|
|
76
|
+
children,
|
|
77
|
+
collapsed: collapsedOverride
|
|
78
|
+
}) => {
|
|
79
|
+
const menuContext = chunkQFVE7GKD_js.useMenuContext();
|
|
80
|
+
if (!menuContext) {
|
|
81
|
+
console.warn("SubMenu must be used within Menu component");
|
|
82
|
+
}
|
|
83
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
84
|
+
const [isOpenByKeyboard, setIsOpenByKeyboard] = React.useState(false);
|
|
85
|
+
const effectiveCollapsed = collapsedOverride ?? (menuContext ? menuContext.collapsed : false);
|
|
86
|
+
const isPopup = !!menuContext && menuContext.mode === "vertical" && effectiveCollapsed;
|
|
87
|
+
const isOpen = !!menuContext && tigercatCore.isKeyOpen(itemKey, menuContext.openKeys);
|
|
88
|
+
const isExpanded = menuContext?.mode === "horizontal" || isPopup ? isHovered || isOpenByKeyboard : isOpen;
|
|
89
|
+
const isInlineOrVertical = menuContext?.mode !== "horizontal" && !isPopup;
|
|
90
|
+
const [hasRenderedInline, setHasRenderedInline] = React.useState(
|
|
91
|
+
() => isInlineOrVertical ? isExpanded : false
|
|
92
|
+
);
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
if (!isInlineOrVertical || !isExpanded || hasRenderedInline) return;
|
|
95
|
+
setHasRenderedInline(true);
|
|
96
|
+
}, [hasRenderedInline, isExpanded, isInlineOrVertical]);
|
|
97
|
+
const titleClasses = React.useMemo(() => {
|
|
98
|
+
if (!menuContext) return "";
|
|
99
|
+
return tigercatCore.getSubMenuTitleClasses(menuContext.theme, disabled);
|
|
100
|
+
}, [menuContext, disabled]);
|
|
101
|
+
const contentClasses = React.useMemo(() => {
|
|
102
|
+
if (!menuContext) return "";
|
|
103
|
+
if (menuContext.mode === "horizontal") return tigercatCore.submenuContentHorizontalClasses;
|
|
104
|
+
if (isPopup) return tigercatCore.submenuContentPopupClasses;
|
|
105
|
+
if (menuContext.mode === "inline") return tigercatCore.submenuContentInlineClasses;
|
|
106
|
+
return tigercatCore.submenuContentVerticalClasses;
|
|
107
|
+
}, [menuContext, isPopup]);
|
|
108
|
+
const handleTitleClick = React.useCallback(() => {
|
|
109
|
+
if (!menuContext || disabled) return;
|
|
110
|
+
if (menuContext.mode === "horizontal") return;
|
|
111
|
+
if (isPopup) {
|
|
112
|
+
setIsOpenByKeyboard((prev) => !prev);
|
|
113
|
+
setIsHovered(true);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
setHasRenderedInline(true);
|
|
117
|
+
menuContext.handleOpenChange(itemKey);
|
|
118
|
+
}, [disabled, menuContext, itemKey, isPopup]);
|
|
119
|
+
const handleMouseEnter = React.useCallback(() => {
|
|
120
|
+
if (menuContext?.mode === "horizontal" || isPopup) setIsHovered(true);
|
|
121
|
+
}, [menuContext, isPopup]);
|
|
122
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
123
|
+
if (menuContext?.mode === "horizontal" || isPopup) {
|
|
124
|
+
setIsHovered(false);
|
|
125
|
+
setIsOpenByKeyboard(false);
|
|
126
|
+
}
|
|
127
|
+
}, [menuContext, isPopup]);
|
|
128
|
+
const openInline = React.useCallback(
|
|
129
|
+
(titleEl) => {
|
|
130
|
+
if (!menuContext) return;
|
|
131
|
+
setHasRenderedInline(true);
|
|
132
|
+
menuContext.handleOpenChange(itemKey);
|
|
133
|
+
setTimeout(() => focusFirstChildItemFromTitle(titleEl), 0);
|
|
134
|
+
},
|
|
135
|
+
[menuContext, itemKey]
|
|
136
|
+
);
|
|
137
|
+
const handleTitleKeyDown = React.useCallback(
|
|
138
|
+
(event) => {
|
|
139
|
+
if (!menuContext || disabled) return;
|
|
140
|
+
const current = event.currentTarget;
|
|
141
|
+
const rootMenu = current.closest('ul[role="menu"]');
|
|
142
|
+
const isRoot = rootMenu?.dataset.tigerMenuRoot === "true";
|
|
143
|
+
const isHorizontalRoot = isRoot && menuContext.mode === "horizontal";
|
|
144
|
+
const nextKey = isHorizontalRoot ? "ArrowRight" : "ArrowDown";
|
|
145
|
+
const prevKey = isHorizontalRoot ? "ArrowLeft" : "ArrowUp";
|
|
146
|
+
if (event.key === nextKey) {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
moveFocus(current, 1);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (event.key === prevKey) {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
moveFocus(current, -1);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
if (event.key === "Home") {
|
|
157
|
+
event.preventDefault();
|
|
158
|
+
focusEdge(current, "start");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (event.key === "End") {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
focusEdge(current, "end");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (event.key === "Escape" || event.key === "ArrowLeft") {
|
|
167
|
+
if (menuContext.mode === "horizontal" || isPopup) {
|
|
168
|
+
event.preventDefault();
|
|
169
|
+
setIsOpenByKeyboard(false);
|
|
170
|
+
setIsHovered(false);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (isOpen) {
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
menuContext.handleOpenChange(itemKey);
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
if (menuContext.mode === "horizontal" || isPopup) {
|
|
182
|
+
setIsOpenByKeyboard(true);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
openInline(current);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown") {
|
|
189
|
+
if (menuContext.mode === "horizontal" || isPopup) {
|
|
190
|
+
event.preventDefault();
|
|
191
|
+
setIsOpenByKeyboard(true);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (!isOpen) {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
openInline(current);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
[menuContext, disabled, isOpen, isPopup, openInline]
|
|
201
|
+
);
|
|
202
|
+
const indentStyle = !menuContext || menuContext.mode === "horizontal" || level === 0 ? {} : tigercatCore.getMenuItemIndent(level, menuContext.inlineIndent);
|
|
203
|
+
if (!menuContext) return null;
|
|
204
|
+
const renderIcon = () => {
|
|
205
|
+
if (!icon) return null;
|
|
206
|
+
if (typeof icon === "string") {
|
|
207
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: tigercatCore.menuItemIconClasses, dangerouslySetInnerHTML: { __html: icon } });
|
|
208
|
+
}
|
|
209
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: tigercatCore.menuItemIconClasses, children: icon });
|
|
210
|
+
};
|
|
211
|
+
const renderTitle = () => {
|
|
212
|
+
if (!effectiveCollapsed) {
|
|
213
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
214
|
+
renderIcon(),
|
|
215
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1", children: title }),
|
|
216
|
+
menuContext.mode !== "horizontal" && !isPopup && /* @__PURE__ */ jsxRuntime.jsx(ExpandIcon, { expanded: isExpanded })
|
|
217
|
+
] });
|
|
218
|
+
} else if (!icon) {
|
|
219
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 text-center", children: title.charAt(0).toUpperCase() });
|
|
220
|
+
} else {
|
|
221
|
+
return renderIcon();
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
const renderContent = () => {
|
|
225
|
+
const nextLevel = level + 1;
|
|
226
|
+
const enhancedChildren = React__default.default.Children.map(children, (child) => {
|
|
227
|
+
if (!React__default.default.isValidElement(child)) return child;
|
|
228
|
+
if (child.type === chunk3WPKVV4N_js.MenuItem || child.type === SubMenu || child.type === chunkLXA2YBAO_js.MenuItemGroup) {
|
|
229
|
+
return React__default.default.cloneElement(
|
|
230
|
+
child,
|
|
231
|
+
{
|
|
232
|
+
level: nextLevel,
|
|
233
|
+
collapsed: isPopup ? false : void 0
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
return child;
|
|
238
|
+
});
|
|
239
|
+
if (menuContext.mode === "horizontal" || isPopup) {
|
|
240
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
241
|
+
"ul",
|
|
242
|
+
{
|
|
243
|
+
className: contentClasses,
|
|
244
|
+
style: { display: isExpanded ? "block" : "none" },
|
|
245
|
+
role: "menu",
|
|
246
|
+
"aria-hidden": isExpanded ? void 0 : "true",
|
|
247
|
+
children: enhancedChildren
|
|
248
|
+
}
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
if (!hasRenderedInline) return null;
|
|
252
|
+
const isHidden = !isExpanded;
|
|
253
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
className: tigercatCore.classNames(
|
|
257
|
+
"grid overflow-hidden transition-[grid-template-rows,opacity] duration-200 ease-in-out",
|
|
258
|
+
isHidden ? "grid-rows-[0fr] opacity-0" : "grid-rows-[1fr] opacity-100"
|
|
259
|
+
),
|
|
260
|
+
"aria-hidden": isHidden ? "true" : void 0,
|
|
261
|
+
"data-tiger-menu-hidden": isHidden ? "true" : void 0,
|
|
262
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("ul", { className: tigercatCore.classNames(contentClasses, "min-h-0"), role: "menu", children: enhancedChildren })
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
267
|
+
"li",
|
|
268
|
+
{
|
|
269
|
+
className: tigercatCore.classNames(
|
|
270
|
+
menuContext.mode === "horizontal" || isPopup ? "relative" : "",
|
|
271
|
+
className
|
|
272
|
+
),
|
|
273
|
+
onMouseEnter: handleMouseEnter,
|
|
274
|
+
onMouseLeave: handleMouseLeave,
|
|
275
|
+
role: "none",
|
|
276
|
+
children: [
|
|
277
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
278
|
+
"button",
|
|
279
|
+
{
|
|
280
|
+
type: "button",
|
|
281
|
+
className: titleClasses,
|
|
282
|
+
style: indentStyle,
|
|
283
|
+
onClick: handleTitleClick,
|
|
284
|
+
onKeyDown: handleTitleKeyDown,
|
|
285
|
+
role: "menuitem",
|
|
286
|
+
"data-tiger-menuitem": "true",
|
|
287
|
+
"aria-expanded": isExpanded ? "true" : "false",
|
|
288
|
+
"aria-haspopup": "true",
|
|
289
|
+
"aria-disabled": disabled ? "true" : void 0,
|
|
290
|
+
disabled,
|
|
291
|
+
tabIndex: -1,
|
|
292
|
+
children: renderTitle()
|
|
293
|
+
}
|
|
294
|
+
),
|
|
295
|
+
renderContent()
|
|
296
|
+
]
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
exports.SubMenu = SubMenu;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DropdownContext } from './chunk-WSCSDSV7.mjs';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import { classNames, getDropdownItemClasses } from '@expcat/tigercat-core';
|
|
4
|
+
import { jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
var DropdownItem = ({
|
|
7
|
+
disabled = false,
|
|
8
|
+
divided = false,
|
|
9
|
+
className,
|
|
10
|
+
onClick,
|
|
11
|
+
children,
|
|
12
|
+
...buttonProps
|
|
13
|
+
}) => {
|
|
14
|
+
const context = useContext(DropdownContext);
|
|
15
|
+
const handleClick = (event) => {
|
|
16
|
+
if (disabled) {
|
|
17
|
+
event.preventDefault();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
onClick?.(event);
|
|
21
|
+
if (context?.closeOnClick) {
|
|
22
|
+
context.handleItemClick();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const itemClasses = classNames(getDropdownItemClasses(disabled, divided), className);
|
|
26
|
+
return /* @__PURE__ */ jsx(
|
|
27
|
+
"button",
|
|
28
|
+
{
|
|
29
|
+
type: "button",
|
|
30
|
+
className: itemClasses,
|
|
31
|
+
role: "menuitem",
|
|
32
|
+
"aria-disabled": disabled,
|
|
33
|
+
disabled,
|
|
34
|
+
onClick: handleClick,
|
|
35
|
+
...buttonProps,
|
|
36
|
+
children
|
|
37
|
+
}
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export { DropdownItem };
|