@taskon/widget-react 0.0.1-beta.2 → 0.0.1-beta.3
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/README.md +55 -16
- package/dist/CommunityTaskList.css +432 -628
- package/dist/EligibilityInfo.css +944 -431
- package/dist/PageBuilder.css +0 -2
- package/dist/Quest.css +460 -505
- package/dist/TaskOnProvider.css +15 -15
- package/dist/UserCenterWidget.css +0 -174
- package/dist/UserCenterWidget2.css +870 -102
- package/dist/chunks/{CommunityTaskList-BlH1Wdd5.js → CommunityTaskList-C9mPl_31.js} +913 -826
- package/dist/chunks/{EligibilityInfo-C7GZ2G5u.js → EligibilityInfo-DGBffKN8.js} +1137 -449
- package/dist/chunks/{LeaderboardWidget-CmYfDeHV.js → LeaderboardWidget-DPOQVXkT.js} +15 -10
- package/dist/chunks/{PageBuilder-Bw0zSkFh.js → PageBuilder-WCZvxL2j.js} +5 -5
- package/dist/chunks/{Quest-DKFZ-pPU.js → Quest-DjGH_8bx.js} +464 -314
- package/dist/chunks/{TaskOnProvider-BD6Vp2x8.js → TaskOnProvider-iannERG1.js} +2 -207
- package/dist/chunks/{ThemeProvider-wnSXrNQb.js → ThemeProvider-DNJqI2lD.js} +246 -54
- package/dist/chunks/UserCenterWidget-B0O-f_xl.js +8344 -0
- package/dist/chunks/{UserCenterWidget-Cw6h_5hT.js → UserCenterWidget-CAhgp46j.js} +204 -1001
- package/dist/chunks/{WidgetShell-D_5OjvNZ.js → dynamic-import-helper-B2j_dZ4V.js} +607 -40
- package/dist/chunks/useToast-CaRkylKe.js +304 -0
- package/dist/chunks/{usercenter-ja-uu-XfVF9.js → usercenter-ja-B2465c1O.js} +4 -10
- package/dist/chunks/{usercenter-ko-DYgUOVzd.js → usercenter-ko-xAEYxqLg.js} +4 -10
- package/dist/community-task.d.ts +34 -3
- package/dist/community-task.js +1 -1
- package/dist/core.d.ts +40 -3
- package/dist/core.js +9 -10
- package/dist/dynamic-import-helper.css +186 -0
- package/dist/index.d.ts +207 -10
- package/dist/index.js +21 -19
- package/dist/leaderboard.d.ts +8 -1
- package/dist/leaderboard.js +2 -2
- package/dist/page-builder.js +1 -1
- package/dist/quest.d.ts +8 -2
- package/dist/quest.js +1 -1
- package/dist/user-center.d.ts +20 -136
- package/dist/user-center.js +19 -236
- package/package.json +7 -2
- package/dist/TipPopover.css +0 -210
- package/dist/WidgetShell.css +0 -182
- package/dist/chunks/TipPopover-BrW8jo71.js +0 -2926
- package/dist/chunks/UserCenterWidget-BE329iS7.js +0 -3546
- package/dist/chunks/dynamic-import-helper-DxEFwm31.js +0 -537
- package/dist/chunks/useToast-B-wyO5zL.js +0 -93
- package/dist/chunks/useWidgetLocale-JDelxtt8.js +0 -74
|
@@ -1,537 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import * as React from "react";
|
|
3
|
-
import { forwardRef, useState, useMemo, useCallback } from "react";
|
|
4
|
-
import { c as composeRefs } from "./ThemeProvider-wnSXrNQb.js";
|
|
5
|
-
import '../dynamic-import-helper.css';var REACT_LAZY_TYPE = Symbol.for("react.lazy");
|
|
6
|
-
var use = React[" use ".trim().toString()];
|
|
7
|
-
function isPromiseLike(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && "then" in value;
|
|
9
|
-
}
|
|
10
|
-
function isLazyComponent(element) {
|
|
11
|
-
return element != null && typeof element === "object" && "$$typeof" in element && element.$$typeof === REACT_LAZY_TYPE && "_payload" in element && isPromiseLike(element._payload);
|
|
12
|
-
}
|
|
13
|
-
// @__NO_SIDE_EFFECTS__
|
|
14
|
-
function createSlot(ownerName) {
|
|
15
|
-
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
16
|
-
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
17
|
-
let { children, ...slotProps } = props;
|
|
18
|
-
if (isLazyComponent(children) && typeof use === "function") {
|
|
19
|
-
children = use(children._payload);
|
|
20
|
-
}
|
|
21
|
-
const childrenArray = React.Children.toArray(children);
|
|
22
|
-
const slottable = childrenArray.find(isSlottable);
|
|
23
|
-
if (slottable) {
|
|
24
|
-
const newElement = slottable.props.children;
|
|
25
|
-
const newChildren = childrenArray.map((child) => {
|
|
26
|
-
if (child === slottable) {
|
|
27
|
-
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
28
|
-
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
29
|
-
} else {
|
|
30
|
-
return child;
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
34
|
-
}
|
|
35
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
36
|
-
});
|
|
37
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
38
|
-
return Slot2;
|
|
39
|
-
}
|
|
40
|
-
var Slot = /* @__PURE__ */ createSlot("Slot");
|
|
41
|
-
// @__NO_SIDE_EFFECTS__
|
|
42
|
-
function createSlotClone(ownerName) {
|
|
43
|
-
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
44
|
-
let { children, ...slotProps } = props;
|
|
45
|
-
if (isLazyComponent(children) && typeof use === "function") {
|
|
46
|
-
children = use(children._payload);
|
|
47
|
-
}
|
|
48
|
-
if (React.isValidElement(children)) {
|
|
49
|
-
const childrenRef = getElementRef(children);
|
|
50
|
-
const props2 = mergeProps(slotProps, children.props);
|
|
51
|
-
if (children.type !== React.Fragment) {
|
|
52
|
-
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
53
|
-
}
|
|
54
|
-
return React.cloneElement(children, props2);
|
|
55
|
-
}
|
|
56
|
-
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
57
|
-
});
|
|
58
|
-
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
59
|
-
return SlotClone;
|
|
60
|
-
}
|
|
61
|
-
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
62
|
-
function isSlottable(child) {
|
|
63
|
-
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
64
|
-
}
|
|
65
|
-
function mergeProps(slotProps, childProps) {
|
|
66
|
-
const overrideProps = { ...childProps };
|
|
67
|
-
for (const propName in childProps) {
|
|
68
|
-
const slotPropValue = slotProps[propName];
|
|
69
|
-
const childPropValue = childProps[propName];
|
|
70
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
71
|
-
if (isHandler) {
|
|
72
|
-
if (slotPropValue && childPropValue) {
|
|
73
|
-
overrideProps[propName] = (...args) => {
|
|
74
|
-
const result = childPropValue(...args);
|
|
75
|
-
slotPropValue(...args);
|
|
76
|
-
return result;
|
|
77
|
-
};
|
|
78
|
-
} else if (slotPropValue) {
|
|
79
|
-
overrideProps[propName] = slotPropValue;
|
|
80
|
-
}
|
|
81
|
-
} else if (propName === "style") {
|
|
82
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
83
|
-
} else if (propName === "className") {
|
|
84
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return { ...slotProps, ...overrideProps };
|
|
88
|
-
}
|
|
89
|
-
function getElementRef(element) {
|
|
90
|
-
var _a, _b;
|
|
91
|
-
let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
|
|
92
|
-
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
93
|
-
if (mayWarn) {
|
|
94
|
-
return element.ref;
|
|
95
|
-
}
|
|
96
|
-
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
97
|
-
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
98
|
-
if (mayWarn) {
|
|
99
|
-
return element.props.ref;
|
|
100
|
-
}
|
|
101
|
-
return element.props.ref || element.ref;
|
|
102
|
-
}
|
|
103
|
-
const Button = forwardRef(
|
|
104
|
-
({
|
|
105
|
-
size = "medium",
|
|
106
|
-
variant = "primary",
|
|
107
|
-
loading = false,
|
|
108
|
-
iconPosition,
|
|
109
|
-
leftIcon,
|
|
110
|
-
rightIcon,
|
|
111
|
-
asChild = false,
|
|
112
|
-
disabled,
|
|
113
|
-
className = "",
|
|
114
|
-
style,
|
|
115
|
-
children,
|
|
116
|
-
...props
|
|
117
|
-
}, ref) => {
|
|
118
|
-
const Comp = asChild ? Slot : "button";
|
|
119
|
-
const actualIconPosition = iconPosition || (leftIcon ? "left" : rightIcon ? "right" : void 0);
|
|
120
|
-
const isIconOnly = actualIconPosition === "only" || !children && (leftIcon || rightIcon);
|
|
121
|
-
const baseStyles = {
|
|
122
|
-
display: "inline-flex",
|
|
123
|
-
alignItems: "center",
|
|
124
|
-
justifyContent: "center",
|
|
125
|
-
gap: "var(--taskon-spacing-xs, 4px)",
|
|
126
|
-
fontFamily: "inherit",
|
|
127
|
-
fontWeight: 500,
|
|
128
|
-
lineHeight: 1.5,
|
|
129
|
-
border: "none",
|
|
130
|
-
outline: "none",
|
|
131
|
-
cursor: disabled || loading ? "not-allowed" : "pointer",
|
|
132
|
-
transition: "all 0.2s ease-in-out",
|
|
133
|
-
position: "relative",
|
|
134
|
-
userSelect: "none",
|
|
135
|
-
whiteSpace: "nowrap",
|
|
136
|
-
opacity: disabled ? 0.5 : 1,
|
|
137
|
-
...style
|
|
138
|
-
};
|
|
139
|
-
const sizeStyles = {
|
|
140
|
-
small: {
|
|
141
|
-
fontSize: "var(--taskon-font-size-sm, 12px)",
|
|
142
|
-
padding: isIconOnly ? "var(--taskon-spacing-xs, 4px)" : "var(--taskon-spacing-xs, 4px) var(--taskon-spacing-sm, 8px)",
|
|
143
|
-
borderRadius: "var(--taskon-border-radius-sm, 4px)",
|
|
144
|
-
minWidth: isIconOnly ? "24px" : "64px",
|
|
145
|
-
height: "24px"
|
|
146
|
-
},
|
|
147
|
-
medium: {
|
|
148
|
-
fontSize: "var(--taskon-font-size, 14px)",
|
|
149
|
-
padding: isIconOnly ? "var(--taskon-spacing-xs, 4px)" : "var(--taskon-spacing-xs, 4px) var(--taskon-spacing-md, 16px)",
|
|
150
|
-
borderRadius: "var(--taskon-border-radius, 8px)",
|
|
151
|
-
minWidth: isIconOnly ? "32px" : "80px",
|
|
152
|
-
height: "32px"
|
|
153
|
-
},
|
|
154
|
-
large: {
|
|
155
|
-
fontSize: "var(--taskon-font-size-lg, 16px)",
|
|
156
|
-
padding: isIconOnly ? "var(--taskon-spacing-sm, 8px)" : "var(--taskon-spacing-sm, 8px) var(--taskon-spacing-lg, 24px)",
|
|
157
|
-
borderRadius: "var(--taskon-border-radius, 8px)",
|
|
158
|
-
minWidth: isIconOnly ? "40px" : "96px",
|
|
159
|
-
height: "40px"
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
const variantStyles = {
|
|
163
|
-
primary: {
|
|
164
|
-
backgroundColor: "var(--taskon-color-primary, #6366f1)",
|
|
165
|
-
color: "#ffffff"
|
|
166
|
-
},
|
|
167
|
-
secondary: {
|
|
168
|
-
backgroundColor: "var(--taskon-color-secondary, #64748b)",
|
|
169
|
-
color: "#ffffff"
|
|
170
|
-
},
|
|
171
|
-
outline: {
|
|
172
|
-
backgroundColor: "transparent",
|
|
173
|
-
color: "var(--taskon-color-text, #0f172a)",
|
|
174
|
-
border: "1px solid var(--taskon-color-border, #e2e8f0)"
|
|
175
|
-
},
|
|
176
|
-
ghost: {
|
|
177
|
-
backgroundColor: "transparent",
|
|
178
|
-
color: "var(--taskon-color-text, #0f172a)"
|
|
179
|
-
},
|
|
180
|
-
danger: {
|
|
181
|
-
backgroundColor: "var(--taskon-color-error, #ef4444)",
|
|
182
|
-
color: "#ffffff"
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
const hoverStyles = {
|
|
186
|
-
primary: "hover:bg-[var(--taskon-color-primary-hover,#9197fe)] active:bg-[var(--taskon-color-primary-active,#4b49cb)]",
|
|
187
|
-
secondary: "hover:opacity-90 active:opacity-80",
|
|
188
|
-
outline: "hover:bg-[var(--taskon-color-bg-spotlight,#f8fafc)] active:bg-[var(--taskon-color-bg-spotlight,#f8fafc)]",
|
|
189
|
-
ghost: "hover:bg-[var(--taskon-color-bg-spotlight,#f8fafc)] active:bg-[var(--taskon-color-bg-spotlight,#f8fafc)]",
|
|
190
|
-
danger: "hover:opacity-90 active:opacity-80"
|
|
191
|
-
};
|
|
192
|
-
const mergedStyle = {
|
|
193
|
-
...baseStyles,
|
|
194
|
-
...sizeStyles[size],
|
|
195
|
-
...variantStyles[variant]
|
|
196
|
-
};
|
|
197
|
-
const mergedClassName = `${className} ${hoverStyles[variant]}`.trim();
|
|
198
|
-
const renderLoadingIndicator = () => {
|
|
199
|
-
if (!loading) return null;
|
|
200
|
-
return /* @__PURE__ */ jsx(
|
|
201
|
-
"span",
|
|
202
|
-
{
|
|
203
|
-
style: {
|
|
204
|
-
display: "inline-block",
|
|
205
|
-
width: "1em",
|
|
206
|
-
height: "1em",
|
|
207
|
-
border: "2px solid currentColor",
|
|
208
|
-
borderTopColor: "transparent",
|
|
209
|
-
borderRadius: "50%",
|
|
210
|
-
animation: "taskon-button-spin 0.6s linear infinite"
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
};
|
|
215
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
216
|
-
/* @__PURE__ */ jsx("style", { children: `
|
|
217
|
-
@keyframes taskon-button-spin {
|
|
218
|
-
from {
|
|
219
|
-
transform: rotate(0deg);
|
|
220
|
-
}
|
|
221
|
-
to {
|
|
222
|
-
transform: rotate(360deg);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
` }),
|
|
226
|
-
/* @__PURE__ */ jsxs(
|
|
227
|
-
Comp,
|
|
228
|
-
{
|
|
229
|
-
ref,
|
|
230
|
-
disabled: disabled || loading,
|
|
231
|
-
className: mergedClassName,
|
|
232
|
-
style: mergedStyle,
|
|
233
|
-
...props,
|
|
234
|
-
children: [
|
|
235
|
-
loading && renderLoadingIndicator(),
|
|
236
|
-
!loading && leftIcon && actualIconPosition === "left" && /* @__PURE__ */ jsx("span", { style: { display: "inline-flex" }, children: leftIcon }),
|
|
237
|
-
!isIconOnly && children,
|
|
238
|
-
!loading && rightIcon && actualIconPosition === "right" && /* @__PURE__ */ jsx("span", { style: { display: "inline-flex" }, children: rightIcon })
|
|
239
|
-
]
|
|
240
|
-
}
|
|
241
|
-
)
|
|
242
|
-
] });
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
Button.displayName = "Button";
|
|
246
|
-
const defaultPaginationMessages = {
|
|
247
|
-
previous: "Previous",
|
|
248
|
-
next: "Next",
|
|
249
|
-
page: "Page",
|
|
250
|
-
of: "of",
|
|
251
|
-
showing: "Showing {start}-{end} of {total}"
|
|
252
|
-
};
|
|
253
|
-
function ChevronLeftIcon() {
|
|
254
|
-
return /* @__PURE__ */ jsx(
|
|
255
|
-
"svg",
|
|
256
|
-
{
|
|
257
|
-
className: "taskon-pagination-icon",
|
|
258
|
-
viewBox: "0 0 24 24",
|
|
259
|
-
fill: "none",
|
|
260
|
-
stroke: "currentColor",
|
|
261
|
-
strokeWidth: "2",
|
|
262
|
-
strokeLinecap: "round",
|
|
263
|
-
strokeLinejoin: "round",
|
|
264
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "15 18 9 12 15 6" })
|
|
265
|
-
}
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
function ChevronRightIcon() {
|
|
269
|
-
return /* @__PURE__ */ jsx(
|
|
270
|
-
"svg",
|
|
271
|
-
{
|
|
272
|
-
className: "taskon-pagination-icon",
|
|
273
|
-
viewBox: "0 0 24 24",
|
|
274
|
-
fill: "none",
|
|
275
|
-
stroke: "currentColor",
|
|
276
|
-
strokeWidth: "2",
|
|
277
|
-
strokeLinecap: "round",
|
|
278
|
-
strokeLinejoin: "round",
|
|
279
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
280
|
-
}
|
|
281
|
-
);
|
|
282
|
-
}
|
|
283
|
-
function Pagination({
|
|
284
|
-
page,
|
|
285
|
-
totalPages,
|
|
286
|
-
hasPrevious,
|
|
287
|
-
hasNext,
|
|
288
|
-
onPrevious,
|
|
289
|
-
onNext,
|
|
290
|
-
messages = defaultPaginationMessages,
|
|
291
|
-
className = "",
|
|
292
|
-
showRange,
|
|
293
|
-
showArrows = true,
|
|
294
|
-
showButtonText = false,
|
|
295
|
-
// 默认不显示按钮文字,只显示箭头图标
|
|
296
|
-
size = "medium"
|
|
297
|
-
}) {
|
|
298
|
-
if (totalPages <= 1) {
|
|
299
|
-
return null;
|
|
300
|
-
}
|
|
301
|
-
const rangeText = showRange && messages.showing ? messages.showing.replace("{start}", String(showRange.start)).replace("{end}", String(showRange.end)).replace("{total}", String(showRange.total)) : null;
|
|
302
|
-
return /* @__PURE__ */ jsxs("div", { className: `taskon-pagination taskon-pagination--${size} ${className}`, children: [
|
|
303
|
-
rangeText && /* @__PURE__ */ jsx("span", { className: "taskon-pagination-range", children: rangeText }),
|
|
304
|
-
/* @__PURE__ */ jsxs("div", { className: "taskon-pagination-controls", children: [
|
|
305
|
-
/* @__PURE__ */ jsx(
|
|
306
|
-
Button,
|
|
307
|
-
{
|
|
308
|
-
variant: "ghost",
|
|
309
|
-
size,
|
|
310
|
-
disabled: !hasPrevious,
|
|
311
|
-
onClick: onPrevious,
|
|
312
|
-
"aria-label": messages.previous,
|
|
313
|
-
leftIcon: showArrows ? /* @__PURE__ */ jsx(ChevronLeftIcon, {}) : void 0,
|
|
314
|
-
className: "taskon-pagination-btn taskon-pagination-btn--prev",
|
|
315
|
-
children: showButtonText && messages.previous
|
|
316
|
-
}
|
|
317
|
-
),
|
|
318
|
-
/* @__PURE__ */ jsxs("span", { className: "taskon-pagination-info", children: [
|
|
319
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-pagination-info-current", children: page + 1 }),
|
|
320
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-pagination-info-separator", children: " / " }),
|
|
321
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-pagination-info-total", children: totalPages })
|
|
322
|
-
] }),
|
|
323
|
-
/* @__PURE__ */ jsx(
|
|
324
|
-
Button,
|
|
325
|
-
{
|
|
326
|
-
variant: "ghost",
|
|
327
|
-
size,
|
|
328
|
-
disabled: !hasNext,
|
|
329
|
-
onClick: onNext,
|
|
330
|
-
"aria-label": messages.next,
|
|
331
|
-
rightIcon: showArrows ? /* @__PURE__ */ jsx(ChevronRightIcon, {}) : void 0,
|
|
332
|
-
className: "taskon-pagination-btn taskon-pagination-btn--next",
|
|
333
|
-
children: showButtonText && messages.next
|
|
334
|
-
}
|
|
335
|
-
)
|
|
336
|
-
] })
|
|
337
|
-
] });
|
|
338
|
-
}
|
|
339
|
-
function Table({
|
|
340
|
-
columns,
|
|
341
|
-
data,
|
|
342
|
-
rowConfig,
|
|
343
|
-
loading = false,
|
|
344
|
-
loadingText = "Loading...",
|
|
345
|
-
empty,
|
|
346
|
-
striped = false,
|
|
347
|
-
compact = false,
|
|
348
|
-
borderless = false,
|
|
349
|
-
className = "",
|
|
350
|
-
style
|
|
351
|
-
}) {
|
|
352
|
-
const tableClassName = [
|
|
353
|
-
"taskon-table",
|
|
354
|
-
striped && "taskon-table--striped",
|
|
355
|
-
compact && "taskon-table--compact",
|
|
356
|
-
borderless && "taskon-table--borderless"
|
|
357
|
-
].filter(Boolean).join(" ");
|
|
358
|
-
const getRowKey = (rowConfig == null ? void 0 : rowConfig.getRowKey) || ((_, index) => index);
|
|
359
|
-
const getColumnStyle = (column) => {
|
|
360
|
-
const style2 = {};
|
|
361
|
-
if (column.width) {
|
|
362
|
-
style2.width = typeof column.width === "number" ? `${column.width}px` : column.width;
|
|
363
|
-
}
|
|
364
|
-
if (column.minWidth) {
|
|
365
|
-
style2.minWidth = typeof column.minWidth === "number" ? `${column.minWidth}px` : column.minWidth;
|
|
366
|
-
}
|
|
367
|
-
return style2;
|
|
368
|
-
};
|
|
369
|
-
const getAlignClassName = (align) => {
|
|
370
|
-
if (!align || align === "left") return "";
|
|
371
|
-
return `taskon-table__header--${align}`;
|
|
372
|
-
};
|
|
373
|
-
const getCellAlignClassName = (align) => {
|
|
374
|
-
if (!align || align === "left") return "";
|
|
375
|
-
return `taskon-table__cell--${align}`;
|
|
376
|
-
};
|
|
377
|
-
const renderHeader = () => /* @__PURE__ */ jsx("thead", { className: "taskon-table__head", children: /* @__PURE__ */ jsx("tr", { children: columns.map((column) => /* @__PURE__ */ jsx(
|
|
378
|
-
"th",
|
|
379
|
-
{
|
|
380
|
-
className: `taskon-table__header ${getAlignClassName(column.align)} ${column.headerClassName || ""}`,
|
|
381
|
-
style: getColumnStyle(column),
|
|
382
|
-
children: column.title
|
|
383
|
-
},
|
|
384
|
-
column.key
|
|
385
|
-
)) }) });
|
|
386
|
-
const renderLoading = () => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", { colSpan: columns.length, className: "taskon-table__loading", children: [
|
|
387
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-table__loading-spinner" }),
|
|
388
|
-
/* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: loadingText })
|
|
389
|
-
] }) });
|
|
390
|
-
const renderEmpty = () => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: columns.length, className: "taskon-table__empty", children: /* @__PURE__ */ jsxs("div", { className: "taskon-table__empty-content", children: [
|
|
391
|
-
(empty == null ? void 0 : empty.icon) && /* @__PURE__ */ jsx("div", { className: "taskon-table__empty-icon", children: empty.icon }),
|
|
392
|
-
(empty == null ? void 0 : empty.title) && /* @__PURE__ */ jsx("p", { className: "taskon-table__empty-title", children: empty.title }),
|
|
393
|
-
(empty == null ? void 0 : empty.description) && /* @__PURE__ */ jsx("p", { className: "taskon-table__empty-desc", children: empty.description }),
|
|
394
|
-
!(empty == null ? void 0 : empty.title) && !(empty == null ? void 0 : empty.description) && /* @__PURE__ */ jsx("p", { className: "taskon-table__empty-title", children: "No data" })
|
|
395
|
-
] }) }) });
|
|
396
|
-
const renderRows = () => data.map((row, rowIndex) => {
|
|
397
|
-
var _a, _b, _c;
|
|
398
|
-
const rowKey = getRowKey(row, rowIndex);
|
|
399
|
-
const isHighlighted = ((_a = rowConfig == null ? void 0 : rowConfig.isHighlighted) == null ? void 0 : _a.call(rowConfig, row, rowIndex)) || false;
|
|
400
|
-
const isDisabled = ((_b = rowConfig == null ? void 0 : rowConfig.isDisabled) == null ? void 0 : _b.call(rowConfig, row, rowIndex)) || false;
|
|
401
|
-
const isClickable = !!(rowConfig == null ? void 0 : rowConfig.onRowClick);
|
|
402
|
-
const customRowClassName = ((_c = rowConfig == null ? void 0 : rowConfig.rowClassName) == null ? void 0 : _c.call(rowConfig, row, rowIndex)) || "";
|
|
403
|
-
const rowClassName = [
|
|
404
|
-
"taskon-table__row",
|
|
405
|
-
isHighlighted && "taskon-table__row--highlighted",
|
|
406
|
-
isDisabled && "taskon-table__row--disabled",
|
|
407
|
-
isClickable && "taskon-table__row--clickable",
|
|
408
|
-
customRowClassName
|
|
409
|
-
].filter(Boolean).join(" ");
|
|
410
|
-
const handleRowClick = () => {
|
|
411
|
-
var _a2;
|
|
412
|
-
if (isClickable && !isDisabled) {
|
|
413
|
-
(_a2 = rowConfig == null ? void 0 : rowConfig.onRowClick) == null ? void 0 : _a2.call(rowConfig, row, rowIndex);
|
|
414
|
-
}
|
|
415
|
-
};
|
|
416
|
-
return /* @__PURE__ */ jsx("tr", { className: rowClassName, onClick: handleRowClick, children: columns.map((column) => {
|
|
417
|
-
const value = row[column.key];
|
|
418
|
-
const cellContent = column.render ? column.render(value, row, rowIndex) : value;
|
|
419
|
-
const cellClassName = [
|
|
420
|
-
"taskon-table__cell",
|
|
421
|
-
getCellAlignClassName(column.align),
|
|
422
|
-
column.ellipsis && "taskon-table__cell--ellipsis",
|
|
423
|
-
column.cellClassName
|
|
424
|
-
].filter(Boolean).join(" ");
|
|
425
|
-
return /* @__PURE__ */ jsx("td", { className: cellClassName, style: getColumnStyle(column), children: cellContent }, column.key);
|
|
426
|
-
}) }, rowKey);
|
|
427
|
-
});
|
|
428
|
-
const renderBody = () => {
|
|
429
|
-
if (!data || data.length === 0) {
|
|
430
|
-
if (loading) {
|
|
431
|
-
return renderLoading();
|
|
432
|
-
}
|
|
433
|
-
return renderEmpty();
|
|
434
|
-
}
|
|
435
|
-
return renderRows();
|
|
436
|
-
};
|
|
437
|
-
return /* @__PURE__ */ jsxs("div", { className: `taskon-table-container ${className}`, style, children: [
|
|
438
|
-
/* @__PURE__ */ jsxs("table", { className: tableClassName, children: [
|
|
439
|
-
renderHeader(),
|
|
440
|
-
/* @__PURE__ */ jsx("tbody", { className: "taskon-table__body", children: renderBody() })
|
|
441
|
-
] }),
|
|
442
|
-
loading && data && data.length > 0 && /* @__PURE__ */ jsx("div", { className: "taskon-table__loading-overlay", children: /* @__PURE__ */ jsx("div", { className: "taskon-table__loading-spinner" }) })
|
|
443
|
-
] });
|
|
444
|
-
}
|
|
445
|
-
function usePagination(options) {
|
|
446
|
-
const { total, pageSize, initialPage = 0, mode = "pagination" } = options;
|
|
447
|
-
const [page, setPage] = useState(initialPage);
|
|
448
|
-
const totalPages = useMemo(() => {
|
|
449
|
-
return Math.max(1, Math.ceil(total / pageSize));
|
|
450
|
-
}, [total, pageSize]);
|
|
451
|
-
const safePage = useMemo(() => {
|
|
452
|
-
return Math.min(page, totalPages - 1);
|
|
453
|
-
}, [page, totalPages]);
|
|
454
|
-
if (safePage !== page) {
|
|
455
|
-
setPage(safePage);
|
|
456
|
-
}
|
|
457
|
-
const hasPrevious = safePage > 0;
|
|
458
|
-
const hasNext = safePage < totalPages - 1;
|
|
459
|
-
const goToPage = useCallback(
|
|
460
|
-
(targetPage) => {
|
|
461
|
-
const validPage = Math.max(0, Math.min(targetPage, totalPages - 1));
|
|
462
|
-
setPage(validPage);
|
|
463
|
-
},
|
|
464
|
-
[totalPages]
|
|
465
|
-
);
|
|
466
|
-
const goToPrevious = useCallback(() => {
|
|
467
|
-
if (hasPrevious) {
|
|
468
|
-
setPage((p) => p - 1);
|
|
469
|
-
}
|
|
470
|
-
}, [hasPrevious]);
|
|
471
|
-
const goToNext = useCallback(() => {
|
|
472
|
-
if (hasNext) {
|
|
473
|
-
setPage((p) => p + 1);
|
|
474
|
-
}
|
|
475
|
-
}, [hasNext]);
|
|
476
|
-
const reset = useCallback(() => {
|
|
477
|
-
setPage(0);
|
|
478
|
-
}, []);
|
|
479
|
-
const startIndex = safePage * pageSize + 1;
|
|
480
|
-
const endIndex = Math.min((safePage + 1) * pageSize, total);
|
|
481
|
-
const hasMore = useMemo(() => {
|
|
482
|
-
if (mode === "infinite") {
|
|
483
|
-
return safePage < totalPages - 1;
|
|
484
|
-
}
|
|
485
|
-
return hasNext;
|
|
486
|
-
}, [mode, safePage, totalPages, hasNext]);
|
|
487
|
-
const loadedCount = useMemo(() => {
|
|
488
|
-
if (mode === "infinite") {
|
|
489
|
-
return Math.min((safePage + 1) * pageSize, total);
|
|
490
|
-
}
|
|
491
|
-
return endIndex - startIndex + 1;
|
|
492
|
-
}, [mode, safePage, pageSize, total, startIndex, endIndex]);
|
|
493
|
-
const loadMore = useCallback(() => {
|
|
494
|
-
if (mode === "infinite" && hasMore) {
|
|
495
|
-
setPage((p) => p + 1);
|
|
496
|
-
}
|
|
497
|
-
}, [mode, hasMore]);
|
|
498
|
-
return {
|
|
499
|
-
page: safePage,
|
|
500
|
-
totalPages,
|
|
501
|
-
hasPrevious,
|
|
502
|
-
hasNext,
|
|
503
|
-
goToPage,
|
|
504
|
-
goToPrevious,
|
|
505
|
-
goToNext,
|
|
506
|
-
reset,
|
|
507
|
-
startIndex,
|
|
508
|
-
endIndex,
|
|
509
|
-
// Infinite 模式专用
|
|
510
|
-
loadMore,
|
|
511
|
-
hasMore,
|
|
512
|
-
loadedCount
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
516
|
-
const v = glob[path];
|
|
517
|
-
if (v) {
|
|
518
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
519
|
-
}
|
|
520
|
-
return new Promise((_, reject) => {
|
|
521
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
522
|
-
reject.bind(
|
|
523
|
-
null,
|
|
524
|
-
new Error(
|
|
525
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
526
|
-
)
|
|
527
|
-
)
|
|
528
|
-
);
|
|
529
|
-
});
|
|
530
|
-
};
|
|
531
|
-
export {
|
|
532
|
-
Button as B,
|
|
533
|
-
Pagination as P,
|
|
534
|
-
Table as T,
|
|
535
|
-
__variableDynamicImportRuntimeHelper as _,
|
|
536
|
-
usePagination as u
|
|
537
|
-
};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { useContext, createContext, useMemo, useState, useCallback } from "react";
|
|
2
|
-
const defaultWalletContext = {
|
|
3
|
-
// EVM state
|
|
4
|
-
evmAdapter: null,
|
|
5
|
-
evmAddress: null,
|
|
6
|
-
evmChainId: null,
|
|
7
|
-
isEvmConnected: false,
|
|
8
|
-
// Detection status
|
|
9
|
-
isDetecting: true,
|
|
10
|
-
// Actions (no-op by default)
|
|
11
|
-
connectEvm: async () => null,
|
|
12
|
-
disconnectEvm: async () => {
|
|
13
|
-
},
|
|
14
|
-
signEvmMessage: async () => null
|
|
15
|
-
};
|
|
16
|
-
const WalletContext = createContext(defaultWalletContext);
|
|
17
|
-
function useWallet() {
|
|
18
|
-
const context = useContext(WalletContext);
|
|
19
|
-
return context;
|
|
20
|
-
}
|
|
21
|
-
function useEvmWallet() {
|
|
22
|
-
const context = useWallet();
|
|
23
|
-
return useMemo(
|
|
24
|
-
() => ({
|
|
25
|
-
adapter: context.evmAdapter,
|
|
26
|
-
address: context.evmAddress,
|
|
27
|
-
chainId: context.evmChainId,
|
|
28
|
-
isConnected: context.isEvmConnected,
|
|
29
|
-
connect: context.connectEvm,
|
|
30
|
-
disconnect: context.disconnectEvm,
|
|
31
|
-
signMessage: context.signEvmMessage
|
|
32
|
-
}),
|
|
33
|
-
[
|
|
34
|
-
context.evmAdapter,
|
|
35
|
-
context.evmAddress,
|
|
36
|
-
context.evmChainId,
|
|
37
|
-
context.isEvmConnected,
|
|
38
|
-
context.connectEvm,
|
|
39
|
-
context.disconnectEvm,
|
|
40
|
-
context.signEvmMessage
|
|
41
|
-
]
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
const ToastContext = createContext(null);
|
|
45
|
-
function useToast() {
|
|
46
|
-
const context = useContext(ToastContext);
|
|
47
|
-
if (!context) {
|
|
48
|
-
throw new Error("useToast must be used within TaskOnProvider");
|
|
49
|
-
}
|
|
50
|
-
return context;
|
|
51
|
-
}
|
|
52
|
-
let toastId = 0;
|
|
53
|
-
function generateId() {
|
|
54
|
-
return `toast-${++toastId}-${Date.now()}`;
|
|
55
|
-
}
|
|
56
|
-
function useToastState() {
|
|
57
|
-
const [toasts, setToasts] = useState([]);
|
|
58
|
-
const showToast = useCallback(
|
|
59
|
-
(message, type = "info", duration) => {
|
|
60
|
-
const newToast = {
|
|
61
|
-
id: generateId(),
|
|
62
|
-
message,
|
|
63
|
-
type,
|
|
64
|
-
duration
|
|
65
|
-
};
|
|
66
|
-
setToasts((prev) => [...prev, newToast]);
|
|
67
|
-
},
|
|
68
|
-
[]
|
|
69
|
-
);
|
|
70
|
-
const removeToast = useCallback((id) => {
|
|
71
|
-
setToasts((prev) => prev.filter((t) => t.id !== id));
|
|
72
|
-
}, []);
|
|
73
|
-
const toast = {
|
|
74
|
-
success: (message, duration) => showToast(message, "success", duration),
|
|
75
|
-
error: (message, duration) => showToast(message, "error", duration),
|
|
76
|
-
warning: (message, duration) => showToast(message, "warning", duration),
|
|
77
|
-
info: (message, duration) => showToast(message, "info", duration)
|
|
78
|
-
};
|
|
79
|
-
return {
|
|
80
|
-
toasts,
|
|
81
|
-
showToast,
|
|
82
|
-
removeToast,
|
|
83
|
-
toast
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
export {
|
|
87
|
-
ToastContext as T,
|
|
88
|
-
WalletContext as W,
|
|
89
|
-
useEvmWallet as a,
|
|
90
|
-
useToast as b,
|
|
91
|
-
useToastState as c,
|
|
92
|
-
useWallet as u
|
|
93
|
-
};
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { useState, useRef, useEffect } from "react";
|
|
2
|
-
import { b as useTaskOnContext } from "./ThemeProvider-wnSXrNQb.js";
|
|
3
|
-
function isSupportedLocale(locale) {
|
|
4
|
-
return locale === "en" || locale === "ko" || locale === "ja";
|
|
5
|
-
}
|
|
6
|
-
function warnUnsupportedLocale(locale, widgetId) {
|
|
7
|
-
if (process.env.NODE_ENV !== "production" && !isSupportedLocale(locale)) {
|
|
8
|
-
console.warn(
|
|
9
|
-
`[widget-react] Locale "${locale}" is not fully supported in ${widgetId}. Falling back to English. Supported locales: en, ko, ja`
|
|
10
|
-
);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
const localeCache = /* @__PURE__ */ new Map();
|
|
14
|
-
const DEFAULT_LOCALE = "en";
|
|
15
|
-
function useWidgetLocale(options) {
|
|
16
|
-
const { widgetId, defaultMessages, loadMessages } = options;
|
|
17
|
-
const { locale } = useTaskOnContext();
|
|
18
|
-
const getInitialState = () => {
|
|
19
|
-
if (locale === DEFAULT_LOCALE) {
|
|
20
|
-
return { messages: defaultMessages, isLoading: false };
|
|
21
|
-
}
|
|
22
|
-
const cacheKey = `${widgetId}-${locale}`;
|
|
23
|
-
if (localeCache.has(cacheKey)) {
|
|
24
|
-
return { messages: localeCache.get(cacheKey), isLoading: false };
|
|
25
|
-
}
|
|
26
|
-
return { messages: defaultMessages, isLoading: true };
|
|
27
|
-
};
|
|
28
|
-
const [state, setState] = useState(getInitialState);
|
|
29
|
-
const loadMessagesRef = useRef(loadMessages);
|
|
30
|
-
loadMessagesRef.current = loadMessages;
|
|
31
|
-
const defaultMessagesRef = useRef(defaultMessages);
|
|
32
|
-
defaultMessagesRef.current = defaultMessages;
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
if (locale === DEFAULT_LOCALE) {
|
|
35
|
-
setState({ messages: defaultMessagesRef.current, isLoading: false });
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
warnUnsupportedLocale(locale, widgetId);
|
|
39
|
-
const cacheKey = `${widgetId}-${locale}`;
|
|
40
|
-
if (localeCache.has(cacheKey)) {
|
|
41
|
-
setState({ messages: localeCache.get(cacheKey), isLoading: false });
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
let isMounted = true;
|
|
45
|
-
setState((prev) => ({ ...prev, isLoading: true }));
|
|
46
|
-
loadMessagesRef.current(locale).then((module) => {
|
|
47
|
-
if (isMounted) {
|
|
48
|
-
const loadedMessages = module.default;
|
|
49
|
-
localeCache.set(cacheKey, loadedMessages);
|
|
50
|
-
setState({ messages: loadedMessages, isLoading: false });
|
|
51
|
-
}
|
|
52
|
-
}).catch((error) => {
|
|
53
|
-
console.warn(
|
|
54
|
-
`[widget-react] Failed to load locale "${locale}" for ${widgetId}, falling back to English:`,
|
|
55
|
-
error
|
|
56
|
-
);
|
|
57
|
-
if (isMounted) {
|
|
58
|
-
setState({ messages: defaultMessagesRef.current, isLoading: false });
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return () => {
|
|
62
|
-
isMounted = false;
|
|
63
|
-
};
|
|
64
|
-
}, [locale, widgetId]);
|
|
65
|
-
return state;
|
|
66
|
-
}
|
|
67
|
-
function clearLocaleCache() {
|
|
68
|
-
localeCache.clear();
|
|
69
|
-
}
|
|
70
|
-
export {
|
|
71
|
-
clearLocaleCache as c,
|
|
72
|
-
isSupportedLocale as i,
|
|
73
|
-
useWidgetLocale as u
|
|
74
|
-
};
|