@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,199 @@
|
|
|
1
|
+
import React, { useState, useRef, useEffect, useMemo } from 'react';
|
|
2
|
+
import { classNames, getPopconfirmContainerClasses, getPopconfirmTriggerClasses, getDropdownMenuWrapperClasses, getPopconfirmArrowClasses, getPopconfirmContentClasses, getPopconfirmTitleClasses, getPopconfirmDescriptionClasses, getPopconfirmIconClasses, getPopconfirmButtonsClasses, getPopconfirmCancelButtonClasses, getPopconfirmOkButtonClasses, mergeStyleValues, popconfirmIconStrokeWidth, popconfirmIconViewBox, getPopconfirmIconPath, popconfirmIconPathStrokeLinejoin, popconfirmIconPathStrokeLinecap } from '@expcat/tigercat-core';
|
|
3
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
|
+
|
|
5
|
+
// src/components/Popconfirm.tsx
|
|
6
|
+
var popconfirmIdCounter = 0;
|
|
7
|
+
var createPopconfirmId = () => `tiger-popconfirm-${++popconfirmIdCounter}`;
|
|
8
|
+
var PopconfirmIcon = ({ type }) => /* @__PURE__ */ jsx(
|
|
9
|
+
"svg",
|
|
10
|
+
{
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
fill: "none",
|
|
13
|
+
viewBox: popconfirmIconViewBox,
|
|
14
|
+
strokeWidth: popconfirmIconStrokeWidth,
|
|
15
|
+
stroke: "currentColor",
|
|
16
|
+
children: /* @__PURE__ */ jsx(
|
|
17
|
+
"path",
|
|
18
|
+
{
|
|
19
|
+
strokeLinecap: popconfirmIconPathStrokeLinecap,
|
|
20
|
+
strokeLinejoin: popconfirmIconPathStrokeLinejoin,
|
|
21
|
+
d: getPopconfirmIconPath(type)
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
var Popconfirm = ({
|
|
27
|
+
visible,
|
|
28
|
+
defaultVisible = false,
|
|
29
|
+
title = "\u786E\u5B9A\u8981\u6267\u884C\u6B64\u64CD\u4F5C\u5417\uFF1F",
|
|
30
|
+
description,
|
|
31
|
+
icon = "warning",
|
|
32
|
+
showIcon = true,
|
|
33
|
+
okText = "\u786E\u5B9A",
|
|
34
|
+
cancelText = "\u53D6\u6D88",
|
|
35
|
+
okType = "primary",
|
|
36
|
+
placement = "top",
|
|
37
|
+
disabled = false,
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
40
|
+
children,
|
|
41
|
+
titleContent,
|
|
42
|
+
descriptionContent,
|
|
43
|
+
onVisibleChange,
|
|
44
|
+
onConfirm,
|
|
45
|
+
onCancel,
|
|
46
|
+
...divProps
|
|
47
|
+
}) => {
|
|
48
|
+
const isControlled = visible !== void 0;
|
|
49
|
+
const [internalVisible, setInternalVisible] = useState(defaultVisible);
|
|
50
|
+
const currentVisible = isControlled ? visible : internalVisible;
|
|
51
|
+
const containerRef = useRef(null);
|
|
52
|
+
const popconfirmIdRef = useRef(null);
|
|
53
|
+
if (!popconfirmIdRef.current) {
|
|
54
|
+
popconfirmIdRef.current = createPopconfirmId();
|
|
55
|
+
}
|
|
56
|
+
const popconfirmId = popconfirmIdRef.current;
|
|
57
|
+
const titleId = `${popconfirmId}-title`;
|
|
58
|
+
const descriptionId = `${popconfirmId}-description`;
|
|
59
|
+
const describedBy = description || descriptionContent ? descriptionId : void 0;
|
|
60
|
+
const setVisible = (newVisible) => {
|
|
61
|
+
if (disabled && newVisible) return;
|
|
62
|
+
if (!isControlled) {
|
|
63
|
+
setInternalVisible(newVisible);
|
|
64
|
+
}
|
|
65
|
+
onVisibleChange?.(newVisible);
|
|
66
|
+
};
|
|
67
|
+
const handleConfirm = () => {
|
|
68
|
+
onConfirm?.();
|
|
69
|
+
setVisible(false);
|
|
70
|
+
};
|
|
71
|
+
const handleCancel = () => {
|
|
72
|
+
onCancel?.();
|
|
73
|
+
setVisible(false);
|
|
74
|
+
};
|
|
75
|
+
const handleTriggerClick = () => {
|
|
76
|
+
if (disabled) return;
|
|
77
|
+
setVisible(!currentVisible);
|
|
78
|
+
};
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (!currentVisible) return;
|
|
81
|
+
const handleClickOutside = (event) => {
|
|
82
|
+
const target = event.target;
|
|
83
|
+
if (!target) return;
|
|
84
|
+
if (containerRef.current?.contains(target)) return;
|
|
85
|
+
setVisible(false);
|
|
86
|
+
};
|
|
87
|
+
const timeoutId = window.setTimeout(() => {
|
|
88
|
+
document.addEventListener("click", handleClickOutside);
|
|
89
|
+
}, 0);
|
|
90
|
+
return () => {
|
|
91
|
+
clearTimeout(timeoutId);
|
|
92
|
+
document.removeEventListener("click", handleClickOutside);
|
|
93
|
+
};
|
|
94
|
+
}, [currentVisible]);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!currentVisible) return;
|
|
97
|
+
const handleKeyDown = (event) => {
|
|
98
|
+
if (event.key !== "Escape") return;
|
|
99
|
+
setVisible(false);
|
|
100
|
+
};
|
|
101
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
102
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
103
|
+
}, [currentVisible]);
|
|
104
|
+
const containerClasses = useMemo(
|
|
105
|
+
() => classNames(getPopconfirmContainerClasses(), className),
|
|
106
|
+
[className]
|
|
107
|
+
);
|
|
108
|
+
const triggerClasses = useMemo(() => getPopconfirmTriggerClasses(disabled), [disabled]);
|
|
109
|
+
const contentWrapperClasses = useMemo(
|
|
110
|
+
() => getDropdownMenuWrapperClasses(Boolean(currentVisible), placement),
|
|
111
|
+
[currentVisible, placement]
|
|
112
|
+
);
|
|
113
|
+
const arrowClasses = useMemo(() => getPopconfirmArrowClasses(placement), [placement]);
|
|
114
|
+
const contentClasses = useMemo(() => getPopconfirmContentClasses(), []);
|
|
115
|
+
const titleClasses = useMemo(() => getPopconfirmTitleClasses(), []);
|
|
116
|
+
const descriptionClasses = useMemo(() => getPopconfirmDescriptionClasses(), []);
|
|
117
|
+
const iconClasses = useMemo(() => getPopconfirmIconClasses(icon), [icon]);
|
|
118
|
+
const buttonsClasses = useMemo(() => getPopconfirmButtonsClasses(), []);
|
|
119
|
+
const cancelButtonClasses = useMemo(() => getPopconfirmCancelButtonClasses(), []);
|
|
120
|
+
const okButtonClasses = useMemo(() => getPopconfirmOkButtonClasses(okType), [okType]);
|
|
121
|
+
if (!children) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
const mergedStyle = mergeStyleValues(style);
|
|
125
|
+
const triggerProps = {
|
|
126
|
+
className: triggerClasses,
|
|
127
|
+
onClick: (event) => {
|
|
128
|
+
const target = children;
|
|
129
|
+
if (React.isValidElement(target)) {
|
|
130
|
+
const onChildClick = target.props.onClick;
|
|
131
|
+
if (typeof onChildClick === "function") {
|
|
132
|
+
onChildClick(event);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
if (event.defaultPrevented) return;
|
|
136
|
+
handleTriggerClick();
|
|
137
|
+
},
|
|
138
|
+
"aria-haspopup": "dialog",
|
|
139
|
+
"aria-expanded": Boolean(currentVisible),
|
|
140
|
+
"aria-controls": currentVisible ? popconfirmId : void 0
|
|
141
|
+
};
|
|
142
|
+
const triggerNode = (() => {
|
|
143
|
+
if (React.isValidElement(children)) {
|
|
144
|
+
return React.cloneElement(children, {
|
|
145
|
+
...triggerProps,
|
|
146
|
+
className: classNames(children.props.className, triggerProps.className)
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return /* @__PURE__ */ jsx(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
...triggerProps,
|
|
153
|
+
role: "button",
|
|
154
|
+
tabIndex: disabled ? -1 : 0,
|
|
155
|
+
"aria-disabled": disabled,
|
|
156
|
+
onKeyDown: (event) => {
|
|
157
|
+
if (disabled) return;
|
|
158
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
handleTriggerClick();
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
children
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
})();
|
|
167
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: containerClasses, style: mergedStyle, ...divProps, children: [
|
|
168
|
+
triggerNode,
|
|
169
|
+
/* @__PURE__ */ jsx("div", { className: contentWrapperClasses, hidden: !currentVisible, "aria-hidden": !currentVisible, children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
170
|
+
/* @__PURE__ */ jsx("div", { className: arrowClasses, "aria-hidden": "true" }),
|
|
171
|
+
/* @__PURE__ */ jsxs(
|
|
172
|
+
"div",
|
|
173
|
+
{
|
|
174
|
+
id: popconfirmId,
|
|
175
|
+
role: "dialog",
|
|
176
|
+
"aria-modal": "false",
|
|
177
|
+
"aria-labelledby": titleId,
|
|
178
|
+
"aria-describedby": describedBy,
|
|
179
|
+
className: contentClasses,
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-start", children: [
|
|
182
|
+
showIcon && /* @__PURE__ */ jsx("div", { className: iconClasses, "aria-hidden": "true", children: /* @__PURE__ */ jsx(PopconfirmIcon, { type: icon }) }),
|
|
183
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
184
|
+
/* @__PURE__ */ jsx("div", { id: titleId, className: titleClasses, children: titleContent || title }),
|
|
185
|
+
(description || descriptionContent) && /* @__PURE__ */ jsx("div", { id: descriptionId, className: descriptionClasses, children: descriptionContent || description })
|
|
186
|
+
] })
|
|
187
|
+
] }),
|
|
188
|
+
/* @__PURE__ */ jsxs("div", { className: buttonsClasses, children: [
|
|
189
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: cancelButtonClasses, onClick: handleCancel, children: cancelText }),
|
|
190
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: okButtonClasses, onClick: handleConfirm, children: okText })
|
|
191
|
+
] })
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
)
|
|
195
|
+
] }) })
|
|
196
|
+
] });
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export { Popconfirm };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { classNames, layoutHeaderClasses } from '@expcat/tigercat-core';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
// src/components/Header.tsx
|
|
5
|
+
var Header = ({
|
|
6
|
+
className,
|
|
7
|
+
height = "64px",
|
|
8
|
+
style,
|
|
9
|
+
children,
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
const headerClasses = classNames(layoutHeaderClasses, className);
|
|
13
|
+
const headerStyle = { ...style, height };
|
|
14
|
+
return /* @__PURE__ */ jsx("header", { className: headerClasses, style: headerStyle, ...props, children });
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Header };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/Sidebar.tsx
|
|
7
|
+
var Sidebar = ({
|
|
8
|
+
className,
|
|
9
|
+
width = "256px",
|
|
10
|
+
collapsed = false,
|
|
11
|
+
style,
|
|
12
|
+
children,
|
|
13
|
+
...props
|
|
14
|
+
}) => {
|
|
15
|
+
const sidebarClasses = tigercatCore.classNames(tigercatCore.layoutSidebarClasses, className);
|
|
16
|
+
const sidebarStyle = {
|
|
17
|
+
...style,
|
|
18
|
+
width: collapsed ? "0px" : width,
|
|
19
|
+
minWidth: collapsed ? "0px" : width,
|
|
20
|
+
overflow: "hidden"
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ jsxRuntime.jsx("aside", { className: sidebarClasses, style: sidebarStyle, ...props, children: !collapsed && children });
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.Sidebar = Sidebar;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/Timeline.tsx
|
|
7
|
+
var Timeline = ({
|
|
8
|
+
items = [],
|
|
9
|
+
mode = "left",
|
|
10
|
+
pending = false,
|
|
11
|
+
pendingDot,
|
|
12
|
+
pendingContent,
|
|
13
|
+
reverse = false,
|
|
14
|
+
renderItem,
|
|
15
|
+
renderDot: customRenderDot,
|
|
16
|
+
className,
|
|
17
|
+
...ulProps
|
|
18
|
+
}) => {
|
|
19
|
+
let processedItems = [...items];
|
|
20
|
+
if (reverse) processedItems = processedItems.reverse();
|
|
21
|
+
if (mode === "alternate") {
|
|
22
|
+
processedItems = processedItems.map((item, index) => ({
|
|
23
|
+
...item,
|
|
24
|
+
position: item.position || (index % 2 === 0 ? "left" : "right")
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
const containerClasses = tigercatCore.classNames(
|
|
28
|
+
tigercatCore.getTimelineContainerClasses(mode),
|
|
29
|
+
tigercatCore.timelineListClasses,
|
|
30
|
+
className
|
|
31
|
+
);
|
|
32
|
+
const getItemKey = (item, index) => item.key || index;
|
|
33
|
+
const wrapCustomDot = (node) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.getTimelineDotClasses(void 0, true), children: node });
|
|
34
|
+
const renderDotElement = (item, isPending = false) => {
|
|
35
|
+
if (customRenderDot) return wrapCustomDot(customRenderDot(item));
|
|
36
|
+
if (item.dot) return wrapCustomDot(item.dot);
|
|
37
|
+
if (isPending) {
|
|
38
|
+
if (pendingDot) {
|
|
39
|
+
return wrapCustomDot(pendingDot);
|
|
40
|
+
}
|
|
41
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.getPendingDotClasses() });
|
|
42
|
+
}
|
|
43
|
+
const dotClasses = tigercatCore.getTimelineDotClasses(item.color);
|
|
44
|
+
const dotStyle = item.color ? { backgroundColor: item.color } : {};
|
|
45
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: dotClasses, style: dotStyle });
|
|
46
|
+
};
|
|
47
|
+
const renderTimelineItem = (item, index) => {
|
|
48
|
+
const key = getItemKey(item, index);
|
|
49
|
+
const isLast = index === processedItems.length - 1 && !pending;
|
|
50
|
+
const position = item.position;
|
|
51
|
+
const itemClasses = tigercatCore.getTimelineItemClasses(mode, position, isLast);
|
|
52
|
+
const tailClasses = tigercatCore.getTimelineTailClasses(mode, position, isLast);
|
|
53
|
+
const headClasses = tigercatCore.getTimelineHeadClasses(mode, position);
|
|
54
|
+
const contentClasses = tigercatCore.getTimelineContentClasses(mode, position);
|
|
55
|
+
if (renderItem) {
|
|
56
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: itemClasses, children: [
|
|
57
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: tailClasses }),
|
|
58
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: headClasses, children: renderDotElement(item) }),
|
|
59
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: contentClasses, children: renderItem(item, index) })
|
|
60
|
+
] }, key);
|
|
61
|
+
}
|
|
62
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: itemClasses, children: [
|
|
63
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: tailClasses }),
|
|
64
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: headClasses, children: renderDotElement(item) }),
|
|
65
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: contentClasses, children: [
|
|
66
|
+
item.label && /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.timelineLabelClasses, children: item.label }),
|
|
67
|
+
item.content && /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.timelineDescriptionClasses, children: item.content })
|
|
68
|
+
] })
|
|
69
|
+
] }, key);
|
|
70
|
+
};
|
|
71
|
+
const renderPendingItem = () => {
|
|
72
|
+
if (!pending) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
const index = processedItems.length;
|
|
76
|
+
const position = mode === "alternate" ? index % 2 === 0 ? "left" : "right" : void 0;
|
|
77
|
+
const itemClasses = tigercatCore.getTimelineItemClasses(mode, position, true);
|
|
78
|
+
const headClasses = tigercatCore.getTimelineHeadClasses(mode, position);
|
|
79
|
+
const contentClasses = tigercatCore.getTimelineContentClasses(mode, position);
|
|
80
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("li", { className: itemClasses, children: [
|
|
81
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: headClasses, children: renderDotElement({}, true) }),
|
|
82
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: contentClasses, children: pendingContent || /* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.timelineDescriptionClasses, children: "Loading..." }) })
|
|
83
|
+
] }, "pending");
|
|
84
|
+
};
|
|
85
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
86
|
+
"ul",
|
|
87
|
+
{
|
|
88
|
+
...ulProps,
|
|
89
|
+
className: containerClasses,
|
|
90
|
+
"aria-busy": ulProps["aria-busy"] ?? (pending ? true : void 0),
|
|
91
|
+
children: [
|
|
92
|
+
processedItems.map((item, index) => renderTimelineItem(item, index)),
|
|
93
|
+
renderPendingItem()
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.Timeline = Timeline;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MenuItem } from './chunk-NSGDRTSQ.mjs';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { menuItemGroupTitleClasses } from '@expcat/tigercat-core';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
|
|
6
|
+
function isComponentNamed(elementType, name) {
|
|
7
|
+
if (typeof elementType !== "function" && typeof elementType !== "object") return false;
|
|
8
|
+
const maybeFn = elementType;
|
|
9
|
+
return maybeFn.displayName === name || maybeFn.name === name;
|
|
10
|
+
}
|
|
11
|
+
var MenuItemGroup = ({
|
|
12
|
+
title,
|
|
13
|
+
className,
|
|
14
|
+
children,
|
|
15
|
+
level = 0
|
|
16
|
+
}) => {
|
|
17
|
+
const enhancedChildren = React.Children.map(children, (child) => {
|
|
18
|
+
if (!React.isValidElement(child)) return child;
|
|
19
|
+
if (child.type === MenuItem || isComponentNamed(child.type, "SubMenu")) {
|
|
20
|
+
return React.cloneElement(child, {
|
|
21
|
+
level
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return child;
|
|
25
|
+
});
|
|
26
|
+
return /* @__PURE__ */ jsxs("li", { className: "list-none", children: [
|
|
27
|
+
title && /* @__PURE__ */ jsx("div", { className: menuItemGroupTitleClasses, children: title }),
|
|
28
|
+
/* @__PURE__ */ jsx("ul", { role: "group", className, children: enhancedChildren })
|
|
29
|
+
] });
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { MenuItemGroup };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/Skeleton.tsx
|
|
7
|
+
var Skeleton = (props) => {
|
|
8
|
+
const {
|
|
9
|
+
variant = "text",
|
|
10
|
+
animation = "pulse",
|
|
11
|
+
width,
|
|
12
|
+
height,
|
|
13
|
+
shape = "circle",
|
|
14
|
+
rows = 1,
|
|
15
|
+
paragraph = false,
|
|
16
|
+
className,
|
|
17
|
+
style,
|
|
18
|
+
["aria-label"]: ariaLabelProp,
|
|
19
|
+
["aria-labelledby"]: ariaLabelledByProp,
|
|
20
|
+
["aria-hidden"]: ariaHiddenProp,
|
|
21
|
+
...divProps
|
|
22
|
+
} = props;
|
|
23
|
+
const skeletonClasses = tigercatCore.classNames(tigercatCore.getSkeletonClasses(variant, animation, shape), className);
|
|
24
|
+
const dimensions = tigercatCore.getSkeletonDimensions(variant, width, height);
|
|
25
|
+
const computedAriaHidden = ariaHiddenProp ?? (ariaLabelProp || ariaLabelledByProp ? void 0 : true);
|
|
26
|
+
if (variant === "text" && rows > 1) {
|
|
27
|
+
const rowElements = [];
|
|
28
|
+
for (let i = 0; i < rows; i++) {
|
|
29
|
+
const rowStyle = {
|
|
30
|
+
height: dimensions.height
|
|
31
|
+
};
|
|
32
|
+
if (paragraph) {
|
|
33
|
+
rowStyle.width = tigercatCore.getParagraphRowWidth(i, rows);
|
|
34
|
+
} else if (dimensions.width) {
|
|
35
|
+
rowStyle.width = dimensions.width;
|
|
36
|
+
}
|
|
37
|
+
rowElements.push(
|
|
38
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
39
|
+
"div",
|
|
40
|
+
{
|
|
41
|
+
className: tigercatCore.classNames(skeletonClasses, i < rows - 1 && "mb-2"),
|
|
42
|
+
style: rowStyle,
|
|
43
|
+
"aria-hidden": computedAriaHidden
|
|
44
|
+
},
|
|
45
|
+
i
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
50
|
+
"div",
|
|
51
|
+
{
|
|
52
|
+
...divProps,
|
|
53
|
+
className: tigercatCore.classNames("flex flex-col", className),
|
|
54
|
+
style,
|
|
55
|
+
"aria-hidden": computedAriaHidden,
|
|
56
|
+
children: rowElements
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const skeletonStyle = {
|
|
61
|
+
...style,
|
|
62
|
+
...dimensions.width ? { width: dimensions.width } : null,
|
|
63
|
+
height: dimensions.height
|
|
64
|
+
};
|
|
65
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
66
|
+
"div",
|
|
67
|
+
{
|
|
68
|
+
...divProps,
|
|
69
|
+
className: skeletonClasses,
|
|
70
|
+
style: skeletonStyle,
|
|
71
|
+
"aria-label": ariaLabelProp,
|
|
72
|
+
"aria-labelledby": ariaLabelledByProp,
|
|
73
|
+
"aria-hidden": computedAriaHidden
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.Skeleton = Skeleton;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
10
|
+
|
|
11
|
+
// src/components/Form.tsx
|
|
12
|
+
var FormContext = React.createContext(null);
|
|
13
|
+
var useFormContext = () => {
|
|
14
|
+
const context = React.useContext(FormContext);
|
|
15
|
+
return context;
|
|
16
|
+
};
|
|
17
|
+
var Form = React.forwardRef(
|
|
18
|
+
({
|
|
19
|
+
model = {},
|
|
20
|
+
rules,
|
|
21
|
+
labelWidth,
|
|
22
|
+
labelPosition = "right",
|
|
23
|
+
labelAlign = "right",
|
|
24
|
+
size = "md",
|
|
25
|
+
inlineMessage = true,
|
|
26
|
+
showRequiredAsterisk = true,
|
|
27
|
+
disabled = false,
|
|
28
|
+
children,
|
|
29
|
+
onSubmit,
|
|
30
|
+
onValidate,
|
|
31
|
+
onChange,
|
|
32
|
+
className,
|
|
33
|
+
...props
|
|
34
|
+
}, ref) => {
|
|
35
|
+
const [errors, setErrors] = React.useState([]);
|
|
36
|
+
const [formValues, setFormValues] = React.useState(model);
|
|
37
|
+
const fieldRulesRef = React__default.default.useRef({});
|
|
38
|
+
React__default.default.useEffect(() => {
|
|
39
|
+
setFormValues(model);
|
|
40
|
+
}, [model]);
|
|
41
|
+
const registerFieldRules = React.useCallback(
|
|
42
|
+
(fieldName, nextRules) => {
|
|
43
|
+
if (!fieldName) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (!nextRules) {
|
|
47
|
+
delete fieldRulesRef.current[fieldName];
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
fieldRulesRef.current[fieldName] = nextRules;
|
|
51
|
+
},
|
|
52
|
+
[]
|
|
53
|
+
);
|
|
54
|
+
const getEffectiveRules = React.useCallback(() => {
|
|
55
|
+
const fromForm = rules ?? {};
|
|
56
|
+
const fromItems = fieldRulesRef.current;
|
|
57
|
+
const merged = { ...fromForm, ...fromItems };
|
|
58
|
+
return Object.keys(merged).length > 0 ? merged : void 0;
|
|
59
|
+
}, [rules]);
|
|
60
|
+
const validateField = React.useCallback(
|
|
61
|
+
async (fieldName, rulesOverride, trigger) => {
|
|
62
|
+
const fieldRules = rulesOverride ?? fieldRulesRef.current[fieldName] ?? rules?.[fieldName];
|
|
63
|
+
if (!fieldRules) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const value = tigercatCore.getValueByPath(formValues, fieldName);
|
|
67
|
+
const error = await tigercatCore.validateField(fieldName, value, fieldRules, formValues, trigger);
|
|
68
|
+
setErrors((prevErrors) => {
|
|
69
|
+
const filtered = prevErrors.filter((e) => e.field !== fieldName);
|
|
70
|
+
if (error) {
|
|
71
|
+
return [...filtered, { field: fieldName, message: error }];
|
|
72
|
+
}
|
|
73
|
+
return filtered;
|
|
74
|
+
});
|
|
75
|
+
onValidate?.(fieldName, !error, error);
|
|
76
|
+
},
|
|
77
|
+
[rules, formValues, onValidate]
|
|
78
|
+
);
|
|
79
|
+
const validate = React.useCallback(async () => {
|
|
80
|
+
const effectiveRules = getEffectiveRules();
|
|
81
|
+
if (!effectiveRules) {
|
|
82
|
+
setErrors([]);
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
const result = await tigercatCore.validateForm(formValues, effectiveRules);
|
|
86
|
+
setErrors(result.errors);
|
|
87
|
+
return result.valid;
|
|
88
|
+
}, [getEffectiveRules, formValues]);
|
|
89
|
+
const clearValidate = React.useCallback((fieldNames) => {
|
|
90
|
+
if (!fieldNames) {
|
|
91
|
+
setErrors([]);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const fields = Array.isArray(fieldNames) ? fieldNames : [fieldNames];
|
|
95
|
+
setErrors((prevErrors) => prevErrors.filter((error) => !fields.includes(error.field)));
|
|
96
|
+
}, []);
|
|
97
|
+
const resetFields = React.useCallback(() => {
|
|
98
|
+
clearValidate();
|
|
99
|
+
setFormValues(model);
|
|
100
|
+
}, [model, clearValidate]);
|
|
101
|
+
const updateValue = React.useCallback(
|
|
102
|
+
(fieldName, value) => {
|
|
103
|
+
const setValueByPath = (target, path, nextValue) => {
|
|
104
|
+
if (!path.includes(".")) {
|
|
105
|
+
return { ...target, [path]: nextValue };
|
|
106
|
+
}
|
|
107
|
+
const segments = path.split(".").filter(Boolean);
|
|
108
|
+
if (segments.length === 0) {
|
|
109
|
+
return target;
|
|
110
|
+
}
|
|
111
|
+
const clone = { ...target };
|
|
112
|
+
let cursor = clone;
|
|
113
|
+
for (let i = 0; i < segments.length; i++) {
|
|
114
|
+
const key = segments[i];
|
|
115
|
+
const isLast = i === segments.length - 1;
|
|
116
|
+
if (isLast) {
|
|
117
|
+
cursor[key] = nextValue;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
const existing = cursor[key];
|
|
121
|
+
const next = existing && typeof existing === "object" && !Array.isArray(existing) ? { ...existing } : {};
|
|
122
|
+
cursor[key] = next;
|
|
123
|
+
cursor = next;
|
|
124
|
+
}
|
|
125
|
+
return clone;
|
|
126
|
+
};
|
|
127
|
+
setFormValues((prevValues) => {
|
|
128
|
+
const newValues = setValueByPath(prevValues, fieldName, value);
|
|
129
|
+
onChange?.(newValues);
|
|
130
|
+
return newValues;
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
[onChange]
|
|
134
|
+
);
|
|
135
|
+
const handleSubmit = React.useCallback(
|
|
136
|
+
async (event) => {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
const effectiveRules = getEffectiveRules();
|
|
139
|
+
if (!effectiveRules) {
|
|
140
|
+
setErrors([]);
|
|
141
|
+
onSubmit?.({ valid: true, values: formValues, errors: [] });
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const result = await tigercatCore.validateForm(formValues, effectiveRules);
|
|
145
|
+
setErrors(result.errors);
|
|
146
|
+
onSubmit?.({
|
|
147
|
+
valid: result.valid,
|
|
148
|
+
values: formValues,
|
|
149
|
+
errors: result.errors
|
|
150
|
+
});
|
|
151
|
+
},
|
|
152
|
+
[getEffectiveRules, formValues, onSubmit]
|
|
153
|
+
);
|
|
154
|
+
React.useImperativeHandle(
|
|
155
|
+
ref,
|
|
156
|
+
() => ({
|
|
157
|
+
validate,
|
|
158
|
+
validateField,
|
|
159
|
+
clearValidate,
|
|
160
|
+
resetFields
|
|
161
|
+
}),
|
|
162
|
+
[validate, validateField, clearValidate, resetFields]
|
|
163
|
+
);
|
|
164
|
+
const contextValue = React.useMemo(
|
|
165
|
+
() => ({
|
|
166
|
+
model: formValues,
|
|
167
|
+
rules,
|
|
168
|
+
labelWidth,
|
|
169
|
+
labelPosition,
|
|
170
|
+
labelAlign,
|
|
171
|
+
size,
|
|
172
|
+
inlineMessage,
|
|
173
|
+
showRequiredAsterisk,
|
|
174
|
+
disabled,
|
|
175
|
+
errors,
|
|
176
|
+
registerFieldRules,
|
|
177
|
+
validateField,
|
|
178
|
+
clearValidate,
|
|
179
|
+
updateValue
|
|
180
|
+
}),
|
|
181
|
+
[
|
|
182
|
+
formValues,
|
|
183
|
+
rules,
|
|
184
|
+
labelWidth,
|
|
185
|
+
labelPosition,
|
|
186
|
+
labelAlign,
|
|
187
|
+
size,
|
|
188
|
+
inlineMessage,
|
|
189
|
+
showRequiredAsterisk,
|
|
190
|
+
disabled,
|
|
191
|
+
errors,
|
|
192
|
+
registerFieldRules,
|
|
193
|
+
validateField,
|
|
194
|
+
clearValidate,
|
|
195
|
+
updateValue
|
|
196
|
+
]
|
|
197
|
+
);
|
|
198
|
+
const formClasses = tigercatCore.classNames(
|
|
199
|
+
"tiger-form",
|
|
200
|
+
`tiger-form--label-${labelPosition}`,
|
|
201
|
+
disabled && "tiger-form--disabled",
|
|
202
|
+
className
|
|
203
|
+
);
|
|
204
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx("form", { className: formClasses, onSubmit: handleSubmit, ...props, children }) });
|
|
205
|
+
}
|
|
206
|
+
);
|
|
207
|
+
Form.displayName = "TigerForm";
|
|
208
|
+
|
|
209
|
+
exports.Form = Form;
|
|
210
|
+
exports.useFormContext = useFormContext;
|