@expcat/tigercat-react 0.0.67 → 0.1.0
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/dist/chunk-2DOPHSZP.js +32 -0
- package/dist/chunk-2TS6X5RA.js +73 -0
- package/dist/chunk-2Y327ZU4.js +493 -0
- package/dist/chunk-3OF7XPIQ.js +90 -0
- package/dist/chunk-3WPKVV4N.js +140 -0
- package/dist/chunk-5FRENLDC.js +194 -0
- package/dist/chunk-5QKMQRCW.js +89 -0
- package/dist/chunk-5ZVSFIZD.js +50 -0
- package/dist/chunk-6MGEGOYJ.js +108 -0
- package/dist/chunk-6PUSRC6S.js +68 -0
- package/dist/chunk-72ZRDBXN.js +25 -0
- package/dist/chunk-77D7VQMG.js +43 -0
- package/dist/chunk-7P6PHSFM.js +548 -0
- package/dist/chunk-AG6GVQ5O.js +271 -0
- package/dist/chunk-AQ6DHCP6.js +53 -0
- package/dist/chunk-AQQRWISY.js +184 -0
- package/dist/chunk-C5EFBJBR.js +540 -0
- package/dist/chunk-D3I2SY7X.js +301 -0
- package/dist/chunk-DZJUFU55.js +300 -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-GX74TC62.js +54 -0
- package/dist/chunk-HDDBBZQH.js +321 -0
- package/dist/chunk-IFY46RWU.js +25 -0
- package/dist/chunk-IQINYCU6.js +99 -0
- package/dist/chunk-IY4LEJYF.js +78 -0
- package/dist/chunk-JW64IJP2.js +210 -0
- package/dist/chunk-KUCFT2OA.js +43 -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-NEULKOYJ.js +48 -0
- package/dist/chunk-NI2WNZRT.js +38 -0
- package/dist/chunk-OFCKGWTS.js +12 -0
- package/dist/chunk-OTRGVENC.js +305 -0
- package/dist/chunk-P273E6XE.js +219 -0
- package/dist/chunk-Q3DPJHNM.js +407 -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-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-TB2UHDOZ.js +19 -0
- package/dist/chunk-TBIEWDY5.js +175 -0
- package/dist/chunk-TJFS44SH.js +48 -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-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-WK5HN4OH.js +113 -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-ZREFCRX3.js +52 -0
- package/dist/components/Alert.d.ts +24 -0
- package/dist/components/Alert.js +10 -0
- package/dist/components/Avatar.d.ts +12 -0
- package/dist/components/Avatar.js +10 -0
- package/dist/components/Badge.d.ts +12 -0
- package/dist/components/Badge.js +10 -0
- package/dist/components/Breadcrumb.d.ts +13 -0
- package/dist/components/Breadcrumb.js +14 -0
- package/dist/components/BreadcrumbItem.d.ts +21 -0
- package/dist/components/BreadcrumbItem.js +11 -0
- package/dist/components/Button.d.ts +8 -0
- package/dist/components/Button.js +10 -0
- package/dist/components/Card.d.ts +33 -0
- package/dist/components/Card.js +10 -0
- package/dist/components/Checkbox.d.ts +48 -0
- package/dist/components/Checkbox.js +11 -0
- package/dist/components/CheckboxGroup.d.ts +39 -0
- package/dist/components/CheckboxGroup.js +14 -0
- package/dist/components/Code.d.ts +9 -0
- package/dist/components/Code.js +16 -0
- package/dist/components/Col.d.ts +7 -0
- package/dist/components/Col.js +11 -0
- package/dist/components/ConfigProvider.d.ts +14 -0
- package/dist/components/ConfigProvider.js +14 -0
- package/dist/components/Container.d.ts +13 -0
- package/dist/components/Container.js +10 -0
- package/dist/components/Content.d.ts +9 -0
- package/dist/components/Content.js +10 -0
- package/dist/components/DatePicker.d.ts +24 -0
- package/dist/components/DatePicker.js +10 -0
- package/dist/components/Descriptions.d.ts +53 -0
- package/dist/components/Descriptions.js +16 -0
- package/dist/components/Divider.d.ts +12 -0
- package/dist/components/Divider.js +10 -0
- package/dist/components/Drawer.d.ts +19 -0
- package/dist/components/Drawer.js +11 -0
- package/dist/components/Dropdown.d.ts +22 -0
- package/dist/components/Dropdown.js +16 -0
- package/dist/components/DropdownItem.d.ts +17 -0
- package/dist/components/DropdownItem.js +13 -0
- package/dist/components/DropdownMenu.d.ts +13 -0
- package/dist/components/DropdownMenu.js +10 -0
- package/dist/components/Footer.d.ts +9 -0
- package/dist/components/Footer.js +10 -0
- package/dist/components/Form.d.ts +56 -0
- package/dist/components/Form.js +14 -0
- package/dist/components/FormItem.d.ts +16 -0
- package/dist/components/FormItem.js +11 -0
- package/dist/components/Header.d.ts +9 -0
- package/dist/components/Header.js +10 -0
- package/dist/components/Icon.d.ts +9 -0
- package/dist/components/Icon.js +10 -0
- package/dist/components/Input.d.ts +28 -0
- package/dist/components/Input.js +10 -0
- package/dist/components/Layout.d.ts +9 -0
- package/dist/components/Layout.js +10 -0
- package/dist/components/Link.d.ts +10 -0
- package/dist/components/Link.js +10 -0
- package/dist/components/List.d.ts +94 -0
- package/dist/components/List.js +12 -0
- package/dist/components/Loading.d.ts +8 -0
- package/dist/components/Loading.js +10 -0
- package/dist/components/Menu.d.ts +35 -0
- package/dist/components/Menu.js +14 -0
- package/dist/components/MenuItem.d.ts +20 -0
- package/dist/components/MenuItem.js +11 -0
- package/dist/components/MenuItemGroup.d.ts +16 -0
- package/dist/components/MenuItemGroup.js +12 -0
- package/dist/components/Message.d.ts +44 -0
- package/dist/components/Message.js +20 -0
- package/dist/components/Modal.d.ts +41 -0
- package/dist/components/Modal.js +11 -0
- package/dist/components/Notification.d.ts +40 -0
- package/dist/components/Notification.js +20 -0
- package/dist/components/Pagination.d.ts +11 -0
- package/dist/components/Pagination.js +16 -0
- package/dist/components/Popconfirm.d.ts +34 -0
- package/dist/components/Popconfirm.js +10 -0
- package/dist/components/Popover.d.ts +14 -0
- package/dist/components/Popover.js +10 -0
- package/dist/components/Progress.d.ts +8 -0
- package/dist/components/Progress.js +10 -0
- package/dist/components/Radio.d.ts +20 -0
- package/dist/components/Radio.js +11 -0
- package/dist/components/RadioGroup.d.ts +28 -0
- package/dist/components/RadioGroup.js +14 -0
- package/dist/components/Row.d.ts +11 -0
- package/dist/components/Row.js +14 -0
- package/dist/components/Select.d.ts +23 -0
- package/dist/components/Select.js +10 -0
- package/dist/components/Sidebar.d.ts +9 -0
- package/dist/components/Sidebar.js +10 -0
- package/dist/components/Skeleton.d.ts +7 -0
- package/dist/components/Skeleton.js +10 -0
- package/dist/components/Slider.d.ts +12 -0
- package/dist/components/Slider.js +10 -0
- package/dist/components/Space.d.ts +11 -0
- package/dist/components/Space.js +10 -0
- package/dist/components/Steps.d.ts +31 -0
- package/dist/components/Steps.js +14 -0
- package/dist/components/StepsItem.d.ts +36 -0
- package/dist/components/StepsItem.js +10 -0
- package/dist/components/SubMenu.d.ts +20 -0
- package/dist/components/SubMenu.js +13 -0
- package/dist/components/Switch.d.ts +12 -0
- package/dist/components/Switch.js +10 -0
- package/dist/components/TabPane.d.ts +42 -0
- package/dist/components/TabPane.js +10 -0
- package/dist/components/Table.d.ts +46 -0
- package/dist/components/Table.js +10 -0
- package/dist/components/Tabs.d.ts +43 -0
- package/dist/components/Tabs.js +14 -0
- package/dist/components/Tag.d.ts +16 -0
- package/dist/components/Tag.js +10 -0
- package/dist/components/Text.d.ts +9 -0
- package/dist/components/Text.js +10 -0
- package/dist/components/Textarea.d.ts +13 -0
- package/dist/components/Textarea.js +10 -0
- package/dist/components/TimePicker.d.ts +28 -0
- package/dist/components/TimePicker.js +10 -0
- package/dist/components/Timeline.d.ts +47 -0
- package/dist/components/Timeline.js +10 -0
- package/dist/components/Tooltip.d.ts +15 -0
- package/dist/components/Tooltip.js +10 -0
- package/dist/components/Tree.d.ts +154 -0
- package/dist/components/Tree.js +16 -0
- package/dist/components/Upload.d.ts +16 -0
- package/dist/components/Upload.js +11 -0
- package/dist/index.d.ts +77 -0
- package/dist/index.js +364 -0
- package/package.json +3 -6
- package/dist/styles/index.css +0 -4
- package/dist/styles/index.d.mts +0 -2
|
@@ -0,0 +1,205 @@
|
|
|
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/Popconfirm.tsx
|
|
12
|
+
var popconfirmIdCounter = 0;
|
|
13
|
+
var createPopconfirmId = () => `tiger-popconfirm-${++popconfirmIdCounter}`;
|
|
14
|
+
var PopconfirmIcon = ({ type }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
15
|
+
"svg",
|
|
16
|
+
{
|
|
17
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
18
|
+
fill: "none",
|
|
19
|
+
viewBox: tigercatCore.popconfirmIconViewBox,
|
|
20
|
+
strokeWidth: tigercatCore.popconfirmIconStrokeWidth,
|
|
21
|
+
stroke: "currentColor",
|
|
22
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
23
|
+
"path",
|
|
24
|
+
{
|
|
25
|
+
strokeLinecap: tigercatCore.popconfirmIconPathStrokeLinecap,
|
|
26
|
+
strokeLinejoin: tigercatCore.popconfirmIconPathStrokeLinejoin,
|
|
27
|
+
d: tigercatCore.getPopconfirmIconPath(type)
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
var Popconfirm = ({
|
|
33
|
+
visible,
|
|
34
|
+
defaultVisible = false,
|
|
35
|
+
title = "\u786E\u5B9A\u8981\u6267\u884C\u6B64\u64CD\u4F5C\u5417\uFF1F",
|
|
36
|
+
description,
|
|
37
|
+
icon = "warning",
|
|
38
|
+
showIcon = true,
|
|
39
|
+
okText = "\u786E\u5B9A",
|
|
40
|
+
cancelText = "\u53D6\u6D88",
|
|
41
|
+
okType = "primary",
|
|
42
|
+
placement = "top",
|
|
43
|
+
disabled = false,
|
|
44
|
+
className,
|
|
45
|
+
style,
|
|
46
|
+
children,
|
|
47
|
+
titleContent,
|
|
48
|
+
descriptionContent,
|
|
49
|
+
onVisibleChange,
|
|
50
|
+
onConfirm,
|
|
51
|
+
onCancel,
|
|
52
|
+
...divProps
|
|
53
|
+
}) => {
|
|
54
|
+
const isControlled = visible !== void 0;
|
|
55
|
+
const [internalVisible, setInternalVisible] = React.useState(defaultVisible);
|
|
56
|
+
const currentVisible = isControlled ? visible : internalVisible;
|
|
57
|
+
const containerRef = React.useRef(null);
|
|
58
|
+
const popconfirmIdRef = React.useRef(null);
|
|
59
|
+
if (!popconfirmIdRef.current) {
|
|
60
|
+
popconfirmIdRef.current = createPopconfirmId();
|
|
61
|
+
}
|
|
62
|
+
const popconfirmId = popconfirmIdRef.current;
|
|
63
|
+
const titleId = `${popconfirmId}-title`;
|
|
64
|
+
const descriptionId = `${popconfirmId}-description`;
|
|
65
|
+
const describedBy = description || descriptionContent ? descriptionId : void 0;
|
|
66
|
+
const setVisible = (newVisible) => {
|
|
67
|
+
if (disabled && newVisible) return;
|
|
68
|
+
if (!isControlled) {
|
|
69
|
+
setInternalVisible(newVisible);
|
|
70
|
+
}
|
|
71
|
+
onVisibleChange?.(newVisible);
|
|
72
|
+
};
|
|
73
|
+
const handleConfirm = () => {
|
|
74
|
+
onConfirm?.();
|
|
75
|
+
setVisible(false);
|
|
76
|
+
};
|
|
77
|
+
const handleCancel = () => {
|
|
78
|
+
onCancel?.();
|
|
79
|
+
setVisible(false);
|
|
80
|
+
};
|
|
81
|
+
const handleTriggerClick = () => {
|
|
82
|
+
if (disabled) return;
|
|
83
|
+
setVisible(!currentVisible);
|
|
84
|
+
};
|
|
85
|
+
React.useEffect(() => {
|
|
86
|
+
if (!currentVisible) return;
|
|
87
|
+
const handleClickOutside = (event) => {
|
|
88
|
+
const target = event.target;
|
|
89
|
+
if (!target) return;
|
|
90
|
+
if (containerRef.current?.contains(target)) return;
|
|
91
|
+
setVisible(false);
|
|
92
|
+
};
|
|
93
|
+
const timeoutId = window.setTimeout(() => {
|
|
94
|
+
document.addEventListener("click", handleClickOutside);
|
|
95
|
+
}, 0);
|
|
96
|
+
return () => {
|
|
97
|
+
clearTimeout(timeoutId);
|
|
98
|
+
document.removeEventListener("click", handleClickOutside);
|
|
99
|
+
};
|
|
100
|
+
}, [currentVisible]);
|
|
101
|
+
React.useEffect(() => {
|
|
102
|
+
if (!currentVisible) return;
|
|
103
|
+
const handleKeyDown = (event) => {
|
|
104
|
+
if (event.key !== "Escape") return;
|
|
105
|
+
setVisible(false);
|
|
106
|
+
};
|
|
107
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
108
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
109
|
+
}, [currentVisible]);
|
|
110
|
+
const containerClasses = React.useMemo(
|
|
111
|
+
() => tigercatCore.classNames(tigercatCore.getPopconfirmContainerClasses(), className),
|
|
112
|
+
[className]
|
|
113
|
+
);
|
|
114
|
+
const triggerClasses = React.useMemo(() => tigercatCore.getPopconfirmTriggerClasses(disabled), [disabled]);
|
|
115
|
+
const contentWrapperClasses = React.useMemo(
|
|
116
|
+
() => tigercatCore.getDropdownMenuWrapperClasses(Boolean(currentVisible), placement),
|
|
117
|
+
[currentVisible, placement]
|
|
118
|
+
);
|
|
119
|
+
const arrowClasses = React.useMemo(() => tigercatCore.getPopconfirmArrowClasses(placement), [placement]);
|
|
120
|
+
const contentClasses = React.useMemo(() => tigercatCore.getPopconfirmContentClasses(), []);
|
|
121
|
+
const titleClasses = React.useMemo(() => tigercatCore.getPopconfirmTitleClasses(), []);
|
|
122
|
+
const descriptionClasses = React.useMemo(() => tigercatCore.getPopconfirmDescriptionClasses(), []);
|
|
123
|
+
const iconClasses = React.useMemo(() => tigercatCore.getPopconfirmIconClasses(icon), [icon]);
|
|
124
|
+
const buttonsClasses = React.useMemo(() => tigercatCore.getPopconfirmButtonsClasses(), []);
|
|
125
|
+
const cancelButtonClasses = React.useMemo(() => tigercatCore.getPopconfirmCancelButtonClasses(), []);
|
|
126
|
+
const okButtonClasses = React.useMemo(() => tigercatCore.getPopconfirmOkButtonClasses(okType), [okType]);
|
|
127
|
+
if (!children) {
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
const mergedStyle = tigercatCore.mergeStyleValues(style);
|
|
131
|
+
const triggerProps = {
|
|
132
|
+
className: triggerClasses,
|
|
133
|
+
onClick: (event) => {
|
|
134
|
+
const target = children;
|
|
135
|
+
if (React__default.default.isValidElement(target)) {
|
|
136
|
+
const onChildClick = target.props.onClick;
|
|
137
|
+
if (typeof onChildClick === "function") {
|
|
138
|
+
onChildClick(event);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (event.defaultPrevented) return;
|
|
142
|
+
handleTriggerClick();
|
|
143
|
+
},
|
|
144
|
+
"aria-haspopup": "dialog",
|
|
145
|
+
"aria-expanded": Boolean(currentVisible),
|
|
146
|
+
"aria-controls": currentVisible ? popconfirmId : void 0
|
|
147
|
+
};
|
|
148
|
+
const triggerNode = (() => {
|
|
149
|
+
if (React__default.default.isValidElement(children)) {
|
|
150
|
+
return React__default.default.cloneElement(children, {
|
|
151
|
+
...triggerProps,
|
|
152
|
+
className: tigercatCore.classNames(children.props.className, triggerProps.className)
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
...triggerProps,
|
|
159
|
+
role: "button",
|
|
160
|
+
tabIndex: disabled ? -1 : 0,
|
|
161
|
+
"aria-disabled": disabled,
|
|
162
|
+
onKeyDown: (event) => {
|
|
163
|
+
if (disabled) return;
|
|
164
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
165
|
+
event.preventDefault();
|
|
166
|
+
handleTriggerClick();
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
children
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
})();
|
|
173
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: containerClasses, style: mergedStyle, ...divProps, children: [
|
|
174
|
+
triggerNode,
|
|
175
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: contentWrapperClasses, hidden: !currentVisible, "aria-hidden": !currentVisible, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
176
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: arrowClasses, "aria-hidden": "true" }),
|
|
177
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
178
|
+
"div",
|
|
179
|
+
{
|
|
180
|
+
id: popconfirmId,
|
|
181
|
+
role: "dialog",
|
|
182
|
+
"aria-modal": "false",
|
|
183
|
+
"aria-labelledby": titleId,
|
|
184
|
+
"aria-describedby": describedBy,
|
|
185
|
+
className: contentClasses,
|
|
186
|
+
children: [
|
|
187
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start", children: [
|
|
188
|
+
showIcon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: iconClasses, "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(PopconfirmIcon, { type: icon }) }),
|
|
189
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
|
|
190
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { id: titleId, className: titleClasses, children: titleContent || title }),
|
|
191
|
+
(description || descriptionContent) && /* @__PURE__ */ jsxRuntime.jsx("div", { id: descriptionId, className: descriptionClasses, children: descriptionContent || description })
|
|
192
|
+
] })
|
|
193
|
+
] }),
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: buttonsClasses, children: [
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: cancelButtonClasses, onClick: handleCancel, children: cancelText }),
|
|
196
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: okButtonClasses, onClick: handleConfirm, children: okText })
|
|
197
|
+
] })
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
] }) })
|
|
202
|
+
] });
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
exports.Popconfirm = Popconfirm;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/DropdownMenu.tsx
|
|
7
|
+
var DropdownMenu = ({
|
|
8
|
+
className,
|
|
9
|
+
style,
|
|
10
|
+
children,
|
|
11
|
+
role,
|
|
12
|
+
...divProps
|
|
13
|
+
}) => {
|
|
14
|
+
const menuClasses = tigercatCore.classNames(tigercatCore.getDropdownMenuClasses(), className);
|
|
15
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: menuClasses, style, role: role ?? "menu", ...divProps, children });
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
exports.DropdownMenu = DropdownMenu;
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var client = require('react-dom/client');
|
|
5
|
+
var reactDom = require('react-dom');
|
|
6
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
|
|
9
|
+
// src/components/Message.tsx
|
|
10
|
+
var MESSAGE_CONTAINER_ID = "tiger-message-container";
|
|
11
|
+
var MESSAGE_CLOSE_ARIA_LABEL = "Close message";
|
|
12
|
+
var messageInstances = [];
|
|
13
|
+
var instanceIdCounter = 0;
|
|
14
|
+
var containerRoot = null;
|
|
15
|
+
var updateCallback = null;
|
|
16
|
+
function getNextInstanceId() {
|
|
17
|
+
return ++instanceIdCounter;
|
|
18
|
+
}
|
|
19
|
+
var Icon = ({ path, className, isLoading = false }) => {
|
|
20
|
+
const iconClass = tigercatCore.classNames(className, isLoading ? tigercatCore.messageLoadingSpinnerClasses : "");
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
22
|
+
"svg",
|
|
23
|
+
{
|
|
24
|
+
className: iconClass,
|
|
25
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
26
|
+
fill: "none",
|
|
27
|
+
viewBox: tigercatCore.icon24ViewBox,
|
|
28
|
+
stroke: "currentColor",
|
|
29
|
+
strokeWidth: tigercatCore.icon24StrokeWidth,
|
|
30
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
31
|
+
"path",
|
|
32
|
+
{
|
|
33
|
+
strokeLinecap: tigercatCore.icon24PathStrokeLinecap,
|
|
34
|
+
strokeLinejoin: tigercatCore.icon24PathStrokeLinejoin,
|
|
35
|
+
d: path
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
var MessageItem = ({ message: message2, onClose }) => {
|
|
42
|
+
const [isVisible, setIsVisible] = react.useState(false);
|
|
43
|
+
react.useEffect(() => {
|
|
44
|
+
setTimeout(() => setIsVisible(true), 10);
|
|
45
|
+
}, []);
|
|
46
|
+
const colorScheme = tigercatCore.getMessageTypeClasses(message2.type, tigercatCore.defaultMessageThemeColors);
|
|
47
|
+
const messageClasses = tigercatCore.classNames(
|
|
48
|
+
tigercatCore.messageBaseClasses,
|
|
49
|
+
colorScheme.bg,
|
|
50
|
+
colorScheme.border,
|
|
51
|
+
colorScheme.text,
|
|
52
|
+
message2.className,
|
|
53
|
+
isVisible ? "opacity-100 translate-y-0" : "opacity-0 -translate-y-2"
|
|
54
|
+
);
|
|
55
|
+
const iconPath = message2.icon || tigercatCore.getMessageIconPath(message2.type);
|
|
56
|
+
const iconClass = tigercatCore.classNames(tigercatCore.messageIconClasses, colorScheme.icon);
|
|
57
|
+
const handleClose = react.useCallback(() => {
|
|
58
|
+
setIsVisible(false);
|
|
59
|
+
setTimeout(() => onClose(message2.id), 300);
|
|
60
|
+
}, [message2.id, onClose]);
|
|
61
|
+
const a11yRole = message2.type === "error" ? "alert" : "status";
|
|
62
|
+
const ariaLive = message2.type === "error" ? "assertive" : "polite";
|
|
63
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: messageClasses,
|
|
67
|
+
role: a11yRole,
|
|
68
|
+
"aria-live": ariaLive,
|
|
69
|
+
"aria-atomic": "true",
|
|
70
|
+
"aria-busy": message2.type === "loading" || void 0,
|
|
71
|
+
"data-tiger-message": true,
|
|
72
|
+
"data-tiger-message-type": message2.type,
|
|
73
|
+
"data-tiger-message-id": String(message2.id),
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { path: iconPath, className: iconClass, isLoading: message2.type === "loading" }),
|
|
76
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: tigercatCore.messageContentClasses, children: message2.content }),
|
|
77
|
+
message2.closable && /* @__PURE__ */ jsxRuntime.jsx(
|
|
78
|
+
"button",
|
|
79
|
+
{
|
|
80
|
+
className: tigercatCore.messageCloseButtonClasses,
|
|
81
|
+
onClick: handleClose,
|
|
82
|
+
"aria-label": MESSAGE_CLOSE_ARIA_LABEL,
|
|
83
|
+
type: "button",
|
|
84
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { path: tigercatCore.messageCloseIconPath, className: "w-4 h-4" })
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
var MessageContainer = ({ position = "top" }) => {
|
|
92
|
+
const [messages, setMessages] = react.useState(() => [...messageInstances]);
|
|
93
|
+
react.useEffect(() => {
|
|
94
|
+
updateCallback = () => {
|
|
95
|
+
reactDom.flushSync(() => {
|
|
96
|
+
setMessages([...messageInstances]);
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
updateCallback();
|
|
100
|
+
return () => {
|
|
101
|
+
updateCallback = null;
|
|
102
|
+
};
|
|
103
|
+
}, []);
|
|
104
|
+
const containerClasses = tigercatCore.classNames(tigercatCore.messageContainerBaseClasses, tigercatCore.messagePositionClasses[position]);
|
|
105
|
+
const handleRemove = react.useCallback((id) => {
|
|
106
|
+
const index = messageInstances.findIndex((msg) => msg.id === id);
|
|
107
|
+
if (index !== -1) {
|
|
108
|
+
const instance = messageInstances[index];
|
|
109
|
+
messageInstances.splice(index, 1);
|
|
110
|
+
if (instance.onClose) {
|
|
111
|
+
instance.onClose();
|
|
112
|
+
}
|
|
113
|
+
if (updateCallback) {
|
|
114
|
+
updateCallback();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}, []);
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
119
|
+
"div",
|
|
120
|
+
{
|
|
121
|
+
className: containerClasses,
|
|
122
|
+
id: MESSAGE_CONTAINER_ID,
|
|
123
|
+
"aria-live": "polite",
|
|
124
|
+
"aria-relevant": "additions",
|
|
125
|
+
"data-tiger-message-container": true,
|
|
126
|
+
children: messages.map((message2) => /* @__PURE__ */ jsxRuntime.jsx(MessageItem, { message: message2, onClose: handleRemove }, message2.id))
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
function ensureContainer() {
|
|
131
|
+
if (!tigercatCore.isBrowser()) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
const rootId = `${MESSAGE_CONTAINER_ID}-root`;
|
|
135
|
+
const existingRootEl = document.getElementById(rootId);
|
|
136
|
+
if (containerRoot && !existingRootEl) {
|
|
137
|
+
containerRoot = null;
|
|
138
|
+
updateCallback = null;
|
|
139
|
+
}
|
|
140
|
+
if (containerRoot) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
let rootEl = existingRootEl;
|
|
144
|
+
if (!rootEl) {
|
|
145
|
+
rootEl = document.createElement("div");
|
|
146
|
+
rootEl.id = rootId;
|
|
147
|
+
document.body.appendChild(rootEl);
|
|
148
|
+
}
|
|
149
|
+
containerRoot = client.createRoot(rootEl);
|
|
150
|
+
reactDom.flushSync(() => {
|
|
151
|
+
containerRoot?.render(/* @__PURE__ */ jsxRuntime.jsx(MessageContainer, {}));
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function addMessage(config) {
|
|
155
|
+
const id = getNextInstanceId();
|
|
156
|
+
const instance = {
|
|
157
|
+
id,
|
|
158
|
+
type: config.type || "info",
|
|
159
|
+
content: config.content,
|
|
160
|
+
duration: config.duration !== void 0 ? config.duration : 3e3,
|
|
161
|
+
closable: config.closable || false,
|
|
162
|
+
onClose: config.onClose,
|
|
163
|
+
icon: config.icon,
|
|
164
|
+
className: config.className
|
|
165
|
+
};
|
|
166
|
+
messageInstances.push(instance);
|
|
167
|
+
ensureContainer();
|
|
168
|
+
if (updateCallback) {
|
|
169
|
+
updateCallback();
|
|
170
|
+
}
|
|
171
|
+
if (instance.duration > 0) {
|
|
172
|
+
setTimeout(() => {
|
|
173
|
+
removeMessage(id);
|
|
174
|
+
}, instance.duration);
|
|
175
|
+
}
|
|
176
|
+
return () => removeMessage(id);
|
|
177
|
+
}
|
|
178
|
+
function removeMessage(id) {
|
|
179
|
+
const index = messageInstances.findIndex((msg) => msg.id === id);
|
|
180
|
+
if (index !== -1) {
|
|
181
|
+
const instance = messageInstances[index];
|
|
182
|
+
messageInstances.splice(index, 1);
|
|
183
|
+
if (instance.onClose) {
|
|
184
|
+
instance.onClose();
|
|
185
|
+
}
|
|
186
|
+
if (updateCallback) {
|
|
187
|
+
updateCallback();
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
function clearAll() {
|
|
192
|
+
messageInstances.forEach((instance) => {
|
|
193
|
+
if (instance.onClose) {
|
|
194
|
+
instance.onClose();
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
messageInstances = [];
|
|
198
|
+
if (updateCallback) {
|
|
199
|
+
updateCallback();
|
|
200
|
+
}
|
|
201
|
+
if (containerRoot) {
|
|
202
|
+
containerRoot.unmount();
|
|
203
|
+
containerRoot = null;
|
|
204
|
+
}
|
|
205
|
+
updateCallback = null;
|
|
206
|
+
const rootId = `${MESSAGE_CONTAINER_ID}-root`;
|
|
207
|
+
if (tigercatCore.isBrowser()) {
|
|
208
|
+
const rootEl = document.getElementById(rootId);
|
|
209
|
+
if (rootEl?.parentNode) {
|
|
210
|
+
rootEl.parentNode.removeChild(rootEl);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function normalizeOptions(options) {
|
|
215
|
+
if (typeof options === "string") {
|
|
216
|
+
return { content: options };
|
|
217
|
+
}
|
|
218
|
+
return options;
|
|
219
|
+
}
|
|
220
|
+
var message = {
|
|
221
|
+
/**
|
|
222
|
+
* Show an info message
|
|
223
|
+
*/
|
|
224
|
+
info(options) {
|
|
225
|
+
const config = normalizeOptions(options);
|
|
226
|
+
return addMessage({ ...config, type: "info" });
|
|
227
|
+
},
|
|
228
|
+
/**
|
|
229
|
+
* Show a success message
|
|
230
|
+
*/
|
|
231
|
+
success(options) {
|
|
232
|
+
const config = normalizeOptions(options);
|
|
233
|
+
return addMessage({ ...config, type: "success" });
|
|
234
|
+
},
|
|
235
|
+
/**
|
|
236
|
+
* Show a warning message
|
|
237
|
+
*/
|
|
238
|
+
warning(options) {
|
|
239
|
+
const config = normalizeOptions(options);
|
|
240
|
+
return addMessage({ ...config, type: "warning" });
|
|
241
|
+
},
|
|
242
|
+
/**
|
|
243
|
+
* Show an error message
|
|
244
|
+
*/
|
|
245
|
+
error(options) {
|
|
246
|
+
const config = normalizeOptions(options);
|
|
247
|
+
return addMessage({ ...config, type: "error" });
|
|
248
|
+
},
|
|
249
|
+
/**
|
|
250
|
+
* Show a loading message
|
|
251
|
+
*/
|
|
252
|
+
loading(options) {
|
|
253
|
+
const config = normalizeOptions(options);
|
|
254
|
+
return addMessage({ ...config, type: "loading", duration: 0 });
|
|
255
|
+
},
|
|
256
|
+
/**
|
|
257
|
+
* Clear all messages
|
|
258
|
+
*/
|
|
259
|
+
clear() {
|
|
260
|
+
clearAll();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var Message_default = message;
|
|
264
|
+
|
|
265
|
+
exports.MessageContainer = MessageContainer;
|
|
266
|
+
exports.Message_default = Message_default;
|
|
267
|
+
exports.message = message;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
4
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
5
|
+
|
|
6
|
+
// src/components/Button.tsx
|
|
7
|
+
var spinnerSvg = tigercatCore.getSpinnerSVG("spinner");
|
|
8
|
+
var Button = ({
|
|
9
|
+
variant = "primary",
|
|
10
|
+
size = "md",
|
|
11
|
+
disabled = false,
|
|
12
|
+
loading = false,
|
|
13
|
+
block = false,
|
|
14
|
+
onClick,
|
|
15
|
+
children,
|
|
16
|
+
type = "button",
|
|
17
|
+
className,
|
|
18
|
+
...props
|
|
19
|
+
}) => {
|
|
20
|
+
const isDisabled = disabled || loading;
|
|
21
|
+
const ariaBusy = props["aria-busy"] ?? (loading ? true : void 0);
|
|
22
|
+
const ariaDisabled = props["aria-disabled"] ?? (isDisabled ? true : void 0);
|
|
23
|
+
const buttonClasses = tigercatCore.classNames(
|
|
24
|
+
tigercatCore.buttonBaseClasses,
|
|
25
|
+
tigercatCore.getButtonVariantClasses(variant),
|
|
26
|
+
tigercatCore.buttonSizeClasses[size],
|
|
27
|
+
isDisabled && tigercatCore.buttonDisabledClasses,
|
|
28
|
+
block && "w-full",
|
|
29
|
+
className
|
|
30
|
+
);
|
|
31
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
className: buttonClasses,
|
|
35
|
+
"aria-busy": ariaBusy,
|
|
36
|
+
"aria-disabled": ariaDisabled,
|
|
37
|
+
disabled: isDisabled,
|
|
38
|
+
onClick: (event) => {
|
|
39
|
+
if (isDisabled) return;
|
|
40
|
+
onClick?.(event);
|
|
41
|
+
},
|
|
42
|
+
type,
|
|
43
|
+
...props,
|
|
44
|
+
children: [
|
|
45
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mr-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
46
|
+
"svg",
|
|
47
|
+
{
|
|
48
|
+
className: "animate-spin h-4 w-4",
|
|
49
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
50
|
+
fill: "none",
|
|
51
|
+
viewBox: spinnerSvg.viewBox,
|
|
52
|
+
"aria-hidden": "true",
|
|
53
|
+
focusable: "false",
|
|
54
|
+
children: spinnerSvg.elements.map((el, index) => {
|
|
55
|
+
if (el.type === "circle") return /* @__PURE__ */ jsxRuntime.jsx("circle", { ...el.attrs }, index);
|
|
56
|
+
if (el.type === "path") return /* @__PURE__ */ jsxRuntime.jsx("path", { ...el.attrs }, index);
|
|
57
|
+
return null;
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
) }),
|
|
61
|
+
children
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
exports.Button = Button;
|