@expcat/tigercat-react 0.2.10 → 0.3.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-4IO2M3ZJ.js +110 -0
- package/dist/chunk-4MMT4EJJ.mjs +78 -0
- package/dist/chunk-67EK62HG.mjs +65 -0
- package/dist/chunk-6YKZAWNX.js +258 -0
- package/dist/chunk-73DMQ2SR.mjs +206 -0
- package/dist/chunk-FAZQT7YP.mjs +255 -0
- package/dist/{chunk-HRYBEBZC.js → chunk-GJKT2B56.js} +5 -1
- package/dist/{chunk-VXHBQTZS.js → chunk-GY6D4XS3.js} +13 -5
- package/dist/chunk-GZPMLPRW.js +107 -0
- package/dist/{chunk-7JQ7LURS.mjs → chunk-H36CWHUP.mjs} +9 -4
- package/dist/{chunk-5XKYWZZZ.mjs → chunk-HGTF6A46.mjs} +5 -1
- package/dist/chunk-HT2BXCEM.js +264 -0
- package/dist/chunk-HUZVBDHV.js +81 -0
- package/dist/{chunk-6ZC7H22S.mjs → chunk-IAF24RKI.mjs} +1 -1
- package/dist/chunk-IYFSM2GA.mjs +141 -0
- package/dist/chunk-JAVDNFJD.js +144 -0
- package/dist/chunk-JOHKSMJM.mjs +266 -0
- package/dist/{chunk-WEGU7O4J.mjs → chunk-KOLLAGRK.mjs} +1 -1
- package/dist/{chunk-P273E6XE.js → chunk-MQTHGPHF.js} +37 -21
- package/dist/{chunk-IS7YOBR7.mjs → chunk-NDOYQK2R.mjs} +13 -5
- package/dist/chunk-OVWCTDAL.js +209 -0
- package/dist/{chunk-2DOPHSZP.js → chunk-OWUGXP6K.js} +8 -3
- package/dist/{chunk-GIYBVWR4.mjs → chunk-OZLAGTZW.mjs} +38 -22
- package/dist/{chunk-OD2NNQD2.js → chunk-PBJ2J2B3.js} +2 -2
- package/dist/chunk-PVOQUXIB.mjs +189 -0
- package/dist/chunk-Q2GPRAF4.js +66 -0
- package/dist/chunk-R67R3TVA.mjs +261 -0
- package/dist/{chunk-6PUSRC6S.js → chunk-T3GSXTDU.js} +2 -2
- package/dist/chunk-WKGCUR7O.mjs +107 -0
- package/dist/chunk-X4F6NSI5.mjs +104 -0
- package/dist/chunk-Y6557RWE.mjs +62 -0
- package/dist/chunk-YIF5VX7K.mjs +158 -0
- package/dist/chunk-Z5DDULTA.js +72 -0
- package/dist/chunk-Z6G4HABF.js +272 -0
- package/dist/chunk-ZN2BZCTI.js +192 -0
- package/dist/chunk-ZPWDDAFE.js +162 -0
- package/dist/components/ActivityFeed.d.mts +10 -0
- package/dist/components/ActivityFeed.d.ts +10 -0
- package/dist/components/ActivityFeed.js +23 -0
- package/dist/components/ActivityFeed.mjs +8 -0
- package/dist/components/Anchor.d.mts +38 -0
- package/dist/components/Anchor.d.ts +38 -0
- package/dist/components/Anchor.js +20 -0
- package/dist/components/Anchor.mjs +1 -0
- package/dist/components/AnchorLink.d.mts +23 -0
- package/dist/components/AnchorLink.d.ts +23 -0
- package/dist/components/AnchorLink.js +17 -0
- package/dist/components/AnchorLink.mjs +2 -0
- package/dist/components/AreaChart.js +4 -4
- package/dist/components/AreaChart.mjs +2 -2
- package/dist/components/BackTop.d.mts +21 -0
- package/dist/components/BackTop.d.ts +21 -0
- package/dist/components/BackTop.js +16 -0
- package/dist/components/BackTop.mjs +1 -0
- package/dist/components/BarChart.js +4 -4
- package/dist/components/BarChart.mjs +2 -2
- package/dist/components/Breadcrumb.d.mts +4 -0
- package/dist/components/Breadcrumb.d.ts +4 -0
- package/dist/components/Breadcrumb.js +3 -3
- package/dist/components/Breadcrumb.mjs +1 -1
- package/dist/components/BreadcrumbItem.js +3 -3
- package/dist/components/BreadcrumbItem.mjs +2 -2
- package/dist/components/Carousel.d.mts +26 -0
- package/dist/components/Carousel.d.ts +26 -0
- package/dist/components/Carousel.js +10 -0
- package/dist/components/Carousel.mjs +1 -0
- package/dist/components/ChatWindow.d.mts +12 -0
- package/dist/components/ChatWindow.d.ts +12 -0
- package/dist/components/ChatWindow.js +20 -0
- package/dist/components/ChatWindow.mjs +5 -0
- package/dist/components/Collapse.d.mts +29 -0
- package/dist/components/Collapse.d.ts +29 -0
- package/dist/components/Collapse.js +20 -0
- package/dist/components/Collapse.mjs +1 -0
- package/dist/components/CollapsePanel.d.mts +24 -0
- package/dist/components/CollapsePanel.d.ts +24 -0
- package/dist/components/CollapsePanel.js +17 -0
- package/dist/components/CollapsePanel.mjs +2 -0
- package/dist/components/CommentThread.d.mts +8 -0
- package/dist/components/CommentThread.d.ts +8 -0
- package/dist/components/CommentThread.js +21 -0
- package/dist/components/CommentThread.mjs +6 -0
- package/dist/components/DataTableWithToolbar.d.mts +51 -0
- package/dist/components/DataTableWithToolbar.d.ts +51 -0
- package/dist/components/DataTableWithToolbar.js +24 -0
- package/dist/components/DataTableWithToolbar.mjs +9 -0
- package/dist/components/Dropdown.js +4 -4
- package/dist/components/Dropdown.mjs +2 -2
- package/dist/components/DropdownItem.js +4 -4
- package/dist/components/DropdownItem.mjs +3 -3
- package/dist/components/FormItem.js +2 -2
- package/dist/components/FormItem.mjs +1 -1
- package/dist/components/FormWizard.d.mts +10 -0
- package/dist/components/FormWizard.d.ts +10 -0
- package/dist/components/FormWizard.js +19 -0
- package/dist/components/FormWizard.mjs +4 -0
- package/dist/components/LineChart.js +4 -4
- package/dist/components/LineChart.mjs +2 -2
- package/dist/components/NotificationCenter.d.mts +8 -0
- package/dist/components/NotificationCenter.d.ts +8 -0
- package/dist/components/NotificationCenter.js +23 -0
- package/dist/components/NotificationCenter.mjs +8 -0
- package/dist/components/Pagination.js +3 -3
- package/dist/components/Pagination.mjs +1 -1
- package/dist/components/ScatterChart.js +4 -4
- package/dist/components/ScatterChart.mjs +2 -2
- package/dist/components/Table.d.mts +1 -1
- package/dist/components/Table.d.ts +1 -1
- package/dist/components/Table.js +2 -2
- package/dist/components/Table.mjs +1 -1
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +221 -153
- package/dist/index.mjs +51 -39
- package/package.json +2 -2
- package/dist/{chunk-42UKIFFQ.js → chunk-4PTI6ZUK.js} +1 -1
- package/dist/{chunk-LIJLFLYE.js → chunk-4TWHENPT.js} +1 -1
- package/dist/{chunk-OONM7FO7.js → chunk-6E5UKM6O.js} +1 -1
- package/dist/{chunk-KBGURVTD.mjs → chunk-AITVDDCE.mjs} +1 -1
- package/dist/{chunk-CBALIFPW.mjs → chunk-IL2Y5RCX.mjs} +1 -1
- package/dist/{chunk-QI6WAP6Y.js → chunk-L63N3LCG.js} +1 -1
- package/dist/{chunk-A2UW5OKX.mjs → chunk-PT4WLSTJ.mjs} +1 -1
- package/dist/{chunk-EJLJYOO7.js → chunk-SIB4EHB6.js} +1 -1
- package/dist/{chunk-VBSK4TGO.mjs → chunk-WYTHTJN3.mjs} +1 -1
- package/dist/{chunk-7IKJBQQV.mjs → chunk-YGOTPK2W.mjs} +1 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkR7MS42PL_js = require('./chunk-R7MS42PL.js');
|
|
4
|
+
var chunkA3DJSVTE_js = require('./chunk-A3DJSVTE.js');
|
|
5
|
+
var chunk2TS6X5RA_js = require('./chunk-2TS6X5RA.js');
|
|
6
|
+
var chunkYYGTJKP5_js = require('./chunk-YYGTJKP5.js');
|
|
7
|
+
var chunkTZ26HQAW_js = require('./chunk-TZ26HQAW.js');
|
|
8
|
+
var react = require('react');
|
|
9
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
|
|
12
|
+
var CommentThread = ({
|
|
13
|
+
nodes,
|
|
14
|
+
items,
|
|
15
|
+
maxDepth = 3,
|
|
16
|
+
maxReplies = 3,
|
|
17
|
+
defaultExpandedKeys = [],
|
|
18
|
+
expandedKeys,
|
|
19
|
+
emptyText = "\u6682\u65E0\u8BC4\u8BBA",
|
|
20
|
+
replyPlaceholder = "\u5199\u4E0B\u56DE\u590D...",
|
|
21
|
+
replyButtonText = "\u56DE\u590D",
|
|
22
|
+
cancelReplyText = "\u53D6\u6D88",
|
|
23
|
+
likeText = "\u70B9\u8D5E",
|
|
24
|
+
likedText = "\u5DF2\u8D5E",
|
|
25
|
+
replyText = "\u56DE\u590D",
|
|
26
|
+
moreText = "\u66F4\u591A",
|
|
27
|
+
loadMoreText = "\u52A0\u8F7D\u66F4\u591A",
|
|
28
|
+
showAvatar = true,
|
|
29
|
+
showDivider = true,
|
|
30
|
+
showLike = true,
|
|
31
|
+
showReply = true,
|
|
32
|
+
showMore = true,
|
|
33
|
+
onLike,
|
|
34
|
+
onReply,
|
|
35
|
+
onMore,
|
|
36
|
+
onAction,
|
|
37
|
+
onExpandedChange,
|
|
38
|
+
onLoadMore,
|
|
39
|
+
className,
|
|
40
|
+
...divProps
|
|
41
|
+
}) => {
|
|
42
|
+
const [innerExpandedKeys, setInnerExpandedKeys] = react.useState(defaultExpandedKeys);
|
|
43
|
+
const [expandedAllKeys, setExpandedAllKeys] = react.useState(/* @__PURE__ */ new Set());
|
|
44
|
+
const [replyingTo, setReplyingTo] = react.useState(null);
|
|
45
|
+
const [replyValue, setReplyValue] = react.useState("");
|
|
46
|
+
const mergedExpandedKeys = expandedKeys ?? innerExpandedKeys;
|
|
47
|
+
const expandedSet = react.useMemo(
|
|
48
|
+
() => new Set(mergedExpandedKeys),
|
|
49
|
+
[mergedExpandedKeys]
|
|
50
|
+
);
|
|
51
|
+
const resolvedNodes = react.useMemo(() => {
|
|
52
|
+
const tree = nodes && nodes.length > 0 ? nodes : tigercatCore.buildCommentTree(items ?? []);
|
|
53
|
+
return tigercatCore.clipCommentTreeDepth(tree, maxDepth);
|
|
54
|
+
}, [nodes, items, maxDepth]);
|
|
55
|
+
const updateExpandedKeys = (next) => {
|
|
56
|
+
if (!expandedKeys) {
|
|
57
|
+
setInnerExpandedKeys(next);
|
|
58
|
+
}
|
|
59
|
+
onExpandedChange?.(next);
|
|
60
|
+
};
|
|
61
|
+
const toggleExpanded = (id) => {
|
|
62
|
+
const next = expandedSet.has(id) ? mergedExpandedKeys.filter((key) => key !== id) : [...mergedExpandedKeys, id];
|
|
63
|
+
updateExpandedKeys(next);
|
|
64
|
+
};
|
|
65
|
+
const handleLoadMore = (node) => {
|
|
66
|
+
setExpandedAllKeys((prev) => {
|
|
67
|
+
const next = new Set(prev);
|
|
68
|
+
next.add(node.id);
|
|
69
|
+
return next;
|
|
70
|
+
});
|
|
71
|
+
onLoadMore?.(node);
|
|
72
|
+
};
|
|
73
|
+
const handleReplySubmit = (node) => {
|
|
74
|
+
const trimmed = replyValue.trim();
|
|
75
|
+
if (!trimmed) return;
|
|
76
|
+
onReply?.(node, replyValue);
|
|
77
|
+
setReplyValue("");
|
|
78
|
+
setReplyingTo(null);
|
|
79
|
+
if (!expandedSet.has(node.id)) {
|
|
80
|
+
const next = [...mergedExpandedKeys, node.id];
|
|
81
|
+
updateExpandedKeys(next);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const BTN_BASE = "px-1.5 py-0.5 h-auto min-h-0 text-xs rounded";
|
|
85
|
+
const ACTION_BTN = `${BTN_BASE} text-gray-400 hover:text-gray-600 font-normal hover:bg-gray-50`;
|
|
86
|
+
const PRIMARY_BTN = `${BTN_BASE} text-[var(--tiger-primary,#2563eb)] hover:text-[var(--tiger-primary-hover,#1d4ed8)] font-medium hover:bg-[var(--tiger-primary,#2563eb)]/5`;
|
|
87
|
+
const renderActionButton = (label, key, onClick, active) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
88
|
+
chunkA3DJSVTE_js.Button,
|
|
89
|
+
{
|
|
90
|
+
size: "sm",
|
|
91
|
+
variant: "ghost",
|
|
92
|
+
className: tigercatCore.classNames(
|
|
93
|
+
ACTION_BTN,
|
|
94
|
+
active && "text-[var(--tiger-primary,#2563eb)] hover:text-[var(--tiger-primary,#2563eb)] font-medium"
|
|
95
|
+
),
|
|
96
|
+
onClick,
|
|
97
|
+
children: label
|
|
98
|
+
},
|
|
99
|
+
key
|
|
100
|
+
);
|
|
101
|
+
const renderNode = (node, depth, isLast) => {
|
|
102
|
+
const hasChildren = !!node.children && node.children.length > 0;
|
|
103
|
+
const isExpanded = expandedSet.has(node.id);
|
|
104
|
+
const showReplies = hasChildren && isExpanded;
|
|
105
|
+
const showAllReplies = expandedAllKeys.has(node.id);
|
|
106
|
+
const repliesId = `tiger-comment-replies-${node.id}`;
|
|
107
|
+
const visibleChildren = showReplies ? maxReplies > 0 && !showAllReplies ? node.children.slice(0, maxReplies) : node.children : [];
|
|
108
|
+
const showLoadMoreBtn = showReplies && maxReplies > 0 && node.children.length > maxReplies && !showAllReplies;
|
|
109
|
+
const actions = [];
|
|
110
|
+
if (showLike) {
|
|
111
|
+
const likeLabel = node.liked ? likedText : likeText;
|
|
112
|
+
const likeCount = node.likes ? ` ${node.likes}` : "";
|
|
113
|
+
actions.push(
|
|
114
|
+
renderActionButton(
|
|
115
|
+
`${likeLabel}${likeCount}`,
|
|
116
|
+
"like",
|
|
117
|
+
() => onLike?.(node, !node.liked),
|
|
118
|
+
node.liked
|
|
119
|
+
)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
if (showReply) {
|
|
123
|
+
actions.push(
|
|
124
|
+
renderActionButton(replyText, "reply", () => {
|
|
125
|
+
setReplyingTo((prev) => prev === node.id ? null : node.id);
|
|
126
|
+
setReplyValue("");
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (showMore) {
|
|
131
|
+
actions.push(renderActionButton(moreText, "more", () => onMore?.(node)));
|
|
132
|
+
}
|
|
133
|
+
if (node.actions && node.actions.length > 0) {
|
|
134
|
+
node.actions.forEach((action, index) => {
|
|
135
|
+
const actionKey = action.key ?? `${node.id}-action-${index}`;
|
|
136
|
+
actions.push(
|
|
137
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
138
|
+
chunkA3DJSVTE_js.Button,
|
|
139
|
+
{
|
|
140
|
+
size: "sm",
|
|
141
|
+
variant: action.variant ?? "ghost",
|
|
142
|
+
className: ACTION_BTN,
|
|
143
|
+
disabled: action.disabled,
|
|
144
|
+
onClick: () => {
|
|
145
|
+
action.onClick?.(node, action);
|
|
146
|
+
onAction?.(node, action);
|
|
147
|
+
},
|
|
148
|
+
children: action.label
|
|
149
|
+
},
|
|
150
|
+
actionKey
|
|
151
|
+
)
|
|
152
|
+
);
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
className: tigercatCore.classNames(
|
|
159
|
+
"tiger-comment-thread-item",
|
|
160
|
+
depth === 1 && "py-4",
|
|
161
|
+
depth === 1 && !isLast && showDivider && "border-b border-[var(--tiger-border,#e5e7eb)]"
|
|
162
|
+
),
|
|
163
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-3", children: [
|
|
164
|
+
showAvatar && node.user ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
165
|
+
chunkTZ26HQAW_js.Avatar,
|
|
166
|
+
{
|
|
167
|
+
size: depth === 1 ? "md" : "sm",
|
|
168
|
+
src: node.user.avatar,
|
|
169
|
+
text: node.user.name,
|
|
170
|
+
className: "shrink-0 mt-0.5"
|
|
171
|
+
}
|
|
172
|
+
) : null,
|
|
173
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
174
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
|
|
175
|
+
node.user?.name ? /* @__PURE__ */ jsxRuntime.jsx(chunkYYGTJKP5_js.Text, { tag: "span", size: "sm", weight: "bold", children: node.user.name }) : null,
|
|
176
|
+
node.user?.title ? /* @__PURE__ */ jsxRuntime.jsx(chunkYYGTJKP5_js.Text, { tag: "span", size: "xs", color: "muted", children: node.user.title }) : null,
|
|
177
|
+
node.tag ? /* @__PURE__ */ jsxRuntime.jsx(chunk2TS6X5RA_js.Tag, { size: "sm", variant: node.tag.variant ?? "default", children: node.tag.label }) : null,
|
|
178
|
+
node.tags?.map((tag, index) => /* @__PURE__ */ jsxRuntime.jsx(chunk2TS6X5RA_js.Tag, { size: "sm", variant: tag.variant ?? "default", children: tag.label }, `${node.id}-tag-${index}`)),
|
|
179
|
+
node.time ? /* @__PURE__ */ jsxRuntime.jsx(chunkYYGTJKP5_js.Text, { tag: "span", size: "xs", color: "muted", className: "ml-auto", children: tigercatCore.formatCommentTime(node.time) }) : null
|
|
180
|
+
] }),
|
|
181
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-[var(--tiger-text-secondary,#4b5563)] leading-relaxed break-words mt-1.5 mb-2", children: node.content }),
|
|
182
|
+
actions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-1", children: actions }) : null,
|
|
183
|
+
replyingTo === node.id ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 space-y-2 bg-[var(--tiger-surface-muted,#f9fafb)] p-3 rounded-lg", children: [
|
|
184
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
185
|
+
chunkR7MS42PL_js.Textarea,
|
|
186
|
+
{
|
|
187
|
+
rows: 2,
|
|
188
|
+
value: replyValue,
|
|
189
|
+
placeholder: replyPlaceholder,
|
|
190
|
+
className: "bg-[var(--tiger-surface,#ffffff)]",
|
|
191
|
+
onChange: (event) => setReplyValue(event.target.value)
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 justify-end", children: [
|
|
195
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
196
|
+
chunkA3DJSVTE_js.Button,
|
|
197
|
+
{
|
|
198
|
+
size: "sm",
|
|
199
|
+
variant: "ghost",
|
|
200
|
+
onClick: () => {
|
|
201
|
+
setReplyingTo(null);
|
|
202
|
+
setReplyValue("");
|
|
203
|
+
},
|
|
204
|
+
children: cancelReplyText
|
|
205
|
+
}
|
|
206
|
+
),
|
|
207
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkA3DJSVTE_js.Button, { size: "sm", variant: "primary", onClick: () => handleReplySubmit(node), children: replyButtonText })
|
|
208
|
+
] })
|
|
209
|
+
] }) : null,
|
|
210
|
+
hasChildren ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
211
|
+
chunkA3DJSVTE_js.Button,
|
|
212
|
+
{
|
|
213
|
+
size: "sm",
|
|
214
|
+
variant: "ghost",
|
|
215
|
+
className: tigercatCore.classNames("mt-2", PRIMARY_BTN),
|
|
216
|
+
"aria-expanded": isExpanded,
|
|
217
|
+
"aria-controls": repliesId,
|
|
218
|
+
onClick: () => toggleExpanded(node.id),
|
|
219
|
+
children: isExpanded ? "\u25BE \u6536\u8D77\u56DE\u590D" : `\u25B8 \u5C55\u5F00 ${node.children.length} \u6761\u56DE\u590D`
|
|
220
|
+
}
|
|
221
|
+
) : null,
|
|
222
|
+
showReplies ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
id: repliesId,
|
|
226
|
+
className: "mt-3 ml-1 pl-4 border-l-2 border-[var(--tiger-border,#e5e7eb)] space-y-3",
|
|
227
|
+
children: [
|
|
228
|
+
visibleChildren.map(
|
|
229
|
+
(child, index) => renderNode(child, depth + 1, index === visibleChildren.length - 1)
|
|
230
|
+
),
|
|
231
|
+
showLoadMoreBtn ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
232
|
+
chunkA3DJSVTE_js.Button,
|
|
233
|
+
{
|
|
234
|
+
size: "sm",
|
|
235
|
+
variant: "ghost",
|
|
236
|
+
className: PRIMARY_BTN,
|
|
237
|
+
onClick: () => handleLoadMore(node),
|
|
238
|
+
children: loadMoreText
|
|
239
|
+
}
|
|
240
|
+
) : null
|
|
241
|
+
]
|
|
242
|
+
}
|
|
243
|
+
) : null
|
|
244
|
+
] })
|
|
245
|
+
] })
|
|
246
|
+
},
|
|
247
|
+
node.id
|
|
248
|
+
);
|
|
249
|
+
};
|
|
250
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
251
|
+
"div",
|
|
252
|
+
{
|
|
253
|
+
className: tigercatCore.classNames("tiger-comment-thread flex flex-col", className),
|
|
254
|
+
"data-tiger-comment-thread": true,
|
|
255
|
+
"aria-label": divProps["aria-label"] ?? (divProps["aria-labelledby"] ? void 0 : "\u8BC4\u8BBA\u7EBF\u7A0B"),
|
|
256
|
+
...divProps,
|
|
257
|
+
children: resolvedNodes.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(chunkYYGTJKP5_js.Text, { tag: "div", size: "sm", color: "muted", className: "text-center py-8", children: emptyText }) : resolvedNodes.map((node, index) => renderNode(node, 1, index === resolvedNodes.length - 1))
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
var CommentThread_default = CommentThread;
|
|
262
|
+
|
|
263
|
+
exports.CommentThread = CommentThread;
|
|
264
|
+
exports.CommentThread_default = CommentThread_default;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
// src/components/BackTop.tsx
|
|
8
|
+
var DefaultIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
9
|
+
"svg",
|
|
10
|
+
{
|
|
11
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
12
|
+
fill: "none",
|
|
13
|
+
viewBox: "0 0 24 24",
|
|
14
|
+
stroke: "currentColor",
|
|
15
|
+
strokeWidth: 2,
|
|
16
|
+
className: "h-5 w-5",
|
|
17
|
+
"aria-hidden": "true",
|
|
18
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: tigercatCore.backTopIconPath })
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
var BackTop = ({
|
|
22
|
+
visibilityHeight = 400,
|
|
23
|
+
target = () => window,
|
|
24
|
+
duration = 450,
|
|
25
|
+
onClick,
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
"aria-label": ariaLabel = "Back to top",
|
|
29
|
+
...props
|
|
30
|
+
}) => {
|
|
31
|
+
const [visible, setVisible] = react.useState(false);
|
|
32
|
+
const handleScroll = react.useCallback(() => {
|
|
33
|
+
const targetElement = target();
|
|
34
|
+
if (!targetElement) return;
|
|
35
|
+
const scrollTop = tigercatCore.getScrollTop(targetElement);
|
|
36
|
+
setVisible(scrollTop >= visibilityHeight);
|
|
37
|
+
}, [target, visibilityHeight]);
|
|
38
|
+
const handleClick = react.useCallback(
|
|
39
|
+
(event) => {
|
|
40
|
+
const targetElement = target();
|
|
41
|
+
if (targetElement) {
|
|
42
|
+
tigercatCore.scrollToTop(targetElement, duration);
|
|
43
|
+
}
|
|
44
|
+
onClick?.(event);
|
|
45
|
+
},
|
|
46
|
+
[target, duration, onClick]
|
|
47
|
+
);
|
|
48
|
+
react.useEffect(() => {
|
|
49
|
+
const targetElement = target();
|
|
50
|
+
if (!targetElement) return;
|
|
51
|
+
targetElement.addEventListener("scroll", handleScroll, { passive: true });
|
|
52
|
+
handleScroll();
|
|
53
|
+
return () => {
|
|
54
|
+
targetElement.removeEventListener("scroll", handleScroll);
|
|
55
|
+
};
|
|
56
|
+
}, [target, handleScroll]);
|
|
57
|
+
const buttonClasses = react.useMemo(() => {
|
|
58
|
+
const targetElement = target();
|
|
59
|
+
const positionClasses = !targetElement || targetElement === window ? tigercatCore.backTopButtonClasses : tigercatCore.backTopContainerClasses;
|
|
60
|
+
return tigercatCore.classNames(
|
|
61
|
+
positionClasses,
|
|
62
|
+
visible ? tigercatCore.backTopVisibleClasses : tigercatCore.backTopHiddenClasses,
|
|
63
|
+
className
|
|
64
|
+
);
|
|
65
|
+
}, [target, visible, className]);
|
|
66
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
67
|
+
"button",
|
|
68
|
+
{
|
|
69
|
+
type: "button",
|
|
70
|
+
className: buttonClasses,
|
|
71
|
+
"aria-label": ariaLabel,
|
|
72
|
+
onClick: handleClick,
|
|
73
|
+
...props,
|
|
74
|
+
children: children || /* @__PURE__ */ jsxRuntime.jsx(DefaultIcon, {})
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
var BackTop_default = BackTop;
|
|
79
|
+
|
|
80
|
+
exports.BackTop = BackTop;
|
|
81
|
+
exports.BackTop_default = BackTop_default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DropdownContext } from './chunk-
|
|
1
|
+
import { DropdownContext } from './chunk-YGOTPK2W.mjs';
|
|
2
2
|
import { useContext } from 'react';
|
|
3
3
|
import { classNames, getDropdownItemClasses } from '@expcat/tigercat-core';
|
|
4
4
|
import { jsx } from 'react/jsx-runtime';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { StepsItem, Steps } from './chunk-P4EFJIXU.mjs';
|
|
2
|
+
import { Button } from './chunk-STEIWBMF.mjs';
|
|
3
|
+
import { Alert } from './chunk-CR4QK2AB.mjs';
|
|
4
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
5
|
+
import { classNames } from '@expcat/tigercat-core';
|
|
6
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
var FormWizard = ({
|
|
9
|
+
steps = [],
|
|
10
|
+
current,
|
|
11
|
+
defaultCurrent = 0,
|
|
12
|
+
clickable = false,
|
|
13
|
+
direction = "horizontal",
|
|
14
|
+
size = "default",
|
|
15
|
+
simple = false,
|
|
16
|
+
showSteps = true,
|
|
17
|
+
showActions = true,
|
|
18
|
+
prevText = "Previous",
|
|
19
|
+
nextText = "Next",
|
|
20
|
+
finishText = "Finish",
|
|
21
|
+
beforeNext,
|
|
22
|
+
onChange,
|
|
23
|
+
onFinish,
|
|
24
|
+
renderStep,
|
|
25
|
+
className,
|
|
26
|
+
style,
|
|
27
|
+
...props
|
|
28
|
+
}) => {
|
|
29
|
+
const [innerCurrent, setInnerCurrent] = useState(defaultCurrent);
|
|
30
|
+
const [errorMessage, setErrorMessage] = useState(null);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (current !== void 0) setInnerCurrent(current);
|
|
33
|
+
}, [current]);
|
|
34
|
+
const totalCount = steps.length;
|
|
35
|
+
const currentIndex = current ?? innerCurrent;
|
|
36
|
+
const currentStep = steps[currentIndex];
|
|
37
|
+
const isFirst = currentIndex <= 0;
|
|
38
|
+
const isLast = currentIndex >= totalCount - 1;
|
|
39
|
+
const wrapperClasses = classNames("tiger-form-wizard flex flex-col gap-6 w-full", className);
|
|
40
|
+
const setCurrent = useCallback(
|
|
41
|
+
(next) => {
|
|
42
|
+
const max = Math.max(totalCount - 1, 0);
|
|
43
|
+
const clamped = Math.min(Math.max(next, 0), max);
|
|
44
|
+
if (current === void 0) {
|
|
45
|
+
setInnerCurrent(clamped);
|
|
46
|
+
}
|
|
47
|
+
onChange?.(clamped, currentIndex);
|
|
48
|
+
},
|
|
49
|
+
[current, currentIndex, onChange, totalCount]
|
|
50
|
+
);
|
|
51
|
+
const runBeforeNext = useCallback(async () => {
|
|
52
|
+
if (!beforeNext || !currentStep) {
|
|
53
|
+
setErrorMessage(null);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const result = await beforeNext(currentIndex, currentStep, steps);
|
|
57
|
+
if (result === true) {
|
|
58
|
+
setErrorMessage(null);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (typeof result === "string") {
|
|
62
|
+
setErrorMessage(result);
|
|
63
|
+
} else {
|
|
64
|
+
setErrorMessage(null);
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}, [beforeNext, currentIndex, currentStep, steps]);
|
|
68
|
+
const handlePrev = useCallback(() => {
|
|
69
|
+
if (currentIndex <= 0 || steps[currentIndex - 1]?.disabled) return;
|
|
70
|
+
setErrorMessage(null);
|
|
71
|
+
setCurrent(currentIndex - 1);
|
|
72
|
+
}, [currentIndex, setCurrent, steps]);
|
|
73
|
+
const handleNext = useCallback(async () => {
|
|
74
|
+
if (totalCount === 0) return;
|
|
75
|
+
const ok = await runBeforeNext();
|
|
76
|
+
if (!ok) return;
|
|
77
|
+
if (isLast) {
|
|
78
|
+
onFinish?.(currentIndex, steps);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (steps[currentIndex + 1]?.disabled) return;
|
|
82
|
+
setErrorMessage(null);
|
|
83
|
+
setCurrent(currentIndex + 1);
|
|
84
|
+
}, [currentIndex, totalCount, isLast, onFinish, runBeforeNext, setCurrent, steps]);
|
|
85
|
+
const handleStepChange = useCallback(
|
|
86
|
+
async (nextIndex) => {
|
|
87
|
+
if (nextIndex === currentIndex || steps[nextIndex]?.disabled) return;
|
|
88
|
+
if (nextIndex > currentIndex) {
|
|
89
|
+
const ok = await runBeforeNext();
|
|
90
|
+
if (!ok) return;
|
|
91
|
+
}
|
|
92
|
+
setErrorMessage(null);
|
|
93
|
+
setCurrent(nextIndex);
|
|
94
|
+
},
|
|
95
|
+
[currentIndex, runBeforeNext, setCurrent, steps]
|
|
96
|
+
);
|
|
97
|
+
const contentNode = useMemo(() => {
|
|
98
|
+
if (!currentStep) return null;
|
|
99
|
+
if (renderStep) return renderStep(currentStep, currentIndex);
|
|
100
|
+
return currentStep.content ?? null;
|
|
101
|
+
}, [currentIndex, currentStep, renderStep]);
|
|
102
|
+
const stepsNodes = useMemo(
|
|
103
|
+
() => steps.map((step, index) => /* @__PURE__ */ jsx(
|
|
104
|
+
StepsItem,
|
|
105
|
+
{
|
|
106
|
+
title: step.title,
|
|
107
|
+
description: step.description,
|
|
108
|
+
status: step.status,
|
|
109
|
+
icon: step.icon,
|
|
110
|
+
disabled: step.disabled
|
|
111
|
+
},
|
|
112
|
+
step.key ?? index
|
|
113
|
+
)),
|
|
114
|
+
[steps]
|
|
115
|
+
);
|
|
116
|
+
return /* @__PURE__ */ jsxs("div", { className: wrapperClasses, style, "data-tiger-form-wizard": true, ...props, children: [
|
|
117
|
+
showSteps && steps.length > 0 && /* @__PURE__ */ jsx(
|
|
118
|
+
Steps,
|
|
119
|
+
{
|
|
120
|
+
current: currentIndex,
|
|
121
|
+
direction,
|
|
122
|
+
size,
|
|
123
|
+
simple,
|
|
124
|
+
clickable,
|
|
125
|
+
onChange: handleStepChange,
|
|
126
|
+
children: stepsNodes
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
errorMessage && /* @__PURE__ */ jsx(Alert, { type: "error", description: errorMessage, className: "tiger-form-wizard-alert" }),
|
|
130
|
+
/* @__PURE__ */ jsxs("div", { className: "tiger-form-wizard-body rounded-lg border border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface,#ffffff)] p-6", children: [
|
|
131
|
+
contentNode,
|
|
132
|
+
showActions && /* @__PURE__ */ jsxs("div", { className: "tiger-form-wizard-actions flex items-center justify-between border-t border-[var(--tiger-border,#e5e7eb)] pt-4 mt-6", children: [
|
|
133
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "secondary", disabled: isFirst, onClick: handlePrev, children: prevText }),
|
|
134
|
+
/* @__PURE__ */ jsx(Button, { type: "button", variant: "primary", onClick: handleNext, children: isLast ? finishText : nextText })
|
|
135
|
+
] })
|
|
136
|
+
] })
|
|
137
|
+
] });
|
|
138
|
+
};
|
|
139
|
+
var FormWizard_default = FormWizard;
|
|
140
|
+
|
|
141
|
+
export { FormWizard, FormWizard_default };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkGXTBCX3M_js = require('./chunk-GXTBCX3M.js');
|
|
4
|
+
var chunkA3DJSVTE_js = require('./chunk-A3DJSVTE.js');
|
|
5
|
+
var chunk3OF7XPIQ_js = require('./chunk-3OF7XPIQ.js');
|
|
6
|
+
var react = require('react');
|
|
7
|
+
var tigercatCore = require('@expcat/tigercat-core');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
|
|
10
|
+
var FormWizard = ({
|
|
11
|
+
steps = [],
|
|
12
|
+
current,
|
|
13
|
+
defaultCurrent = 0,
|
|
14
|
+
clickable = false,
|
|
15
|
+
direction = "horizontal",
|
|
16
|
+
size = "default",
|
|
17
|
+
simple = false,
|
|
18
|
+
showSteps = true,
|
|
19
|
+
showActions = true,
|
|
20
|
+
prevText = "Previous",
|
|
21
|
+
nextText = "Next",
|
|
22
|
+
finishText = "Finish",
|
|
23
|
+
beforeNext,
|
|
24
|
+
onChange,
|
|
25
|
+
onFinish,
|
|
26
|
+
renderStep,
|
|
27
|
+
className,
|
|
28
|
+
style,
|
|
29
|
+
...props
|
|
30
|
+
}) => {
|
|
31
|
+
const [innerCurrent, setInnerCurrent] = react.useState(defaultCurrent);
|
|
32
|
+
const [errorMessage, setErrorMessage] = react.useState(null);
|
|
33
|
+
react.useEffect(() => {
|
|
34
|
+
if (current !== void 0) setInnerCurrent(current);
|
|
35
|
+
}, [current]);
|
|
36
|
+
const totalCount = steps.length;
|
|
37
|
+
const currentIndex = current ?? innerCurrent;
|
|
38
|
+
const currentStep = steps[currentIndex];
|
|
39
|
+
const isFirst = currentIndex <= 0;
|
|
40
|
+
const isLast = currentIndex >= totalCount - 1;
|
|
41
|
+
const wrapperClasses = tigercatCore.classNames("tiger-form-wizard flex flex-col gap-6 w-full", className);
|
|
42
|
+
const setCurrent = react.useCallback(
|
|
43
|
+
(next) => {
|
|
44
|
+
const max = Math.max(totalCount - 1, 0);
|
|
45
|
+
const clamped = Math.min(Math.max(next, 0), max);
|
|
46
|
+
if (current === void 0) {
|
|
47
|
+
setInnerCurrent(clamped);
|
|
48
|
+
}
|
|
49
|
+
onChange?.(clamped, currentIndex);
|
|
50
|
+
},
|
|
51
|
+
[current, currentIndex, onChange, totalCount]
|
|
52
|
+
);
|
|
53
|
+
const runBeforeNext = react.useCallback(async () => {
|
|
54
|
+
if (!beforeNext || !currentStep) {
|
|
55
|
+
setErrorMessage(null);
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
const result = await beforeNext(currentIndex, currentStep, steps);
|
|
59
|
+
if (result === true) {
|
|
60
|
+
setErrorMessage(null);
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
if (typeof result === "string") {
|
|
64
|
+
setErrorMessage(result);
|
|
65
|
+
} else {
|
|
66
|
+
setErrorMessage(null);
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}, [beforeNext, currentIndex, currentStep, steps]);
|
|
70
|
+
const handlePrev = react.useCallback(() => {
|
|
71
|
+
if (currentIndex <= 0 || steps[currentIndex - 1]?.disabled) return;
|
|
72
|
+
setErrorMessage(null);
|
|
73
|
+
setCurrent(currentIndex - 1);
|
|
74
|
+
}, [currentIndex, setCurrent, steps]);
|
|
75
|
+
const handleNext = react.useCallback(async () => {
|
|
76
|
+
if (totalCount === 0) return;
|
|
77
|
+
const ok = await runBeforeNext();
|
|
78
|
+
if (!ok) return;
|
|
79
|
+
if (isLast) {
|
|
80
|
+
onFinish?.(currentIndex, steps);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (steps[currentIndex + 1]?.disabled) return;
|
|
84
|
+
setErrorMessage(null);
|
|
85
|
+
setCurrent(currentIndex + 1);
|
|
86
|
+
}, [currentIndex, totalCount, isLast, onFinish, runBeforeNext, setCurrent, steps]);
|
|
87
|
+
const handleStepChange = react.useCallback(
|
|
88
|
+
async (nextIndex) => {
|
|
89
|
+
if (nextIndex === currentIndex || steps[nextIndex]?.disabled) return;
|
|
90
|
+
if (nextIndex > currentIndex) {
|
|
91
|
+
const ok = await runBeforeNext();
|
|
92
|
+
if (!ok) return;
|
|
93
|
+
}
|
|
94
|
+
setErrorMessage(null);
|
|
95
|
+
setCurrent(nextIndex);
|
|
96
|
+
},
|
|
97
|
+
[currentIndex, runBeforeNext, setCurrent, steps]
|
|
98
|
+
);
|
|
99
|
+
const contentNode = react.useMemo(() => {
|
|
100
|
+
if (!currentStep) return null;
|
|
101
|
+
if (renderStep) return renderStep(currentStep, currentIndex);
|
|
102
|
+
return currentStep.content ?? null;
|
|
103
|
+
}, [currentIndex, currentStep, renderStep]);
|
|
104
|
+
const stepsNodes = react.useMemo(
|
|
105
|
+
() => steps.map((step, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
106
|
+
chunkGXTBCX3M_js.StepsItem,
|
|
107
|
+
{
|
|
108
|
+
title: step.title,
|
|
109
|
+
description: step.description,
|
|
110
|
+
status: step.status,
|
|
111
|
+
icon: step.icon,
|
|
112
|
+
disabled: step.disabled
|
|
113
|
+
},
|
|
114
|
+
step.key ?? index
|
|
115
|
+
)),
|
|
116
|
+
[steps]
|
|
117
|
+
);
|
|
118
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: wrapperClasses, style, "data-tiger-form-wizard": true, ...props, children: [
|
|
119
|
+
showSteps && steps.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
120
|
+
chunkGXTBCX3M_js.Steps,
|
|
121
|
+
{
|
|
122
|
+
current: currentIndex,
|
|
123
|
+
direction,
|
|
124
|
+
size,
|
|
125
|
+
simple,
|
|
126
|
+
clickable,
|
|
127
|
+
onChange: handleStepChange,
|
|
128
|
+
children: stepsNodes
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
errorMessage && /* @__PURE__ */ jsxRuntime.jsx(chunk3OF7XPIQ_js.Alert, { type: "error", description: errorMessage, className: "tiger-form-wizard-alert" }),
|
|
132
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tiger-form-wizard-body rounded-lg border border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface,#ffffff)] p-6", children: [
|
|
133
|
+
contentNode,
|
|
134
|
+
showActions && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "tiger-form-wizard-actions flex items-center justify-between border-t border-[var(--tiger-border,#e5e7eb)] pt-4 mt-6", children: [
|
|
135
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkA3DJSVTE_js.Button, { type: "button", variant: "secondary", disabled: isFirst, onClick: handlePrev, children: prevText }),
|
|
136
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkA3DJSVTE_js.Button, { type: "button", variant: "primary", onClick: handleNext, children: isLast ? finishText : nextText })
|
|
137
|
+
] })
|
|
138
|
+
] })
|
|
139
|
+
] });
|
|
140
|
+
};
|
|
141
|
+
var FormWizard_default = FormWizard;
|
|
142
|
+
|
|
143
|
+
exports.FormWizard = FormWizard;
|
|
144
|
+
exports.FormWizard_default = FormWizard_default;
|