@taskon/widget-react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1064 -0
- package/dist/CommunityTaskList.css +5010 -0
- package/dist/EligibilityInfo.css +1966 -0
- package/dist/LeaderboardWidget.css +815 -0
- package/dist/Quest.css +4584 -0
- package/dist/Table.css +389 -0
- package/dist/TaskOnProvider.css +163 -0
- package/dist/WidgetShell.css +182 -0
- package/dist/chunks/CommunityTaskList-CrH6r4Av.js +6886 -0
- package/dist/chunks/EligibilityInfo-DesW9-k9.js +24900 -0
- package/dist/chunks/LeaderboardWidget-BSGpHKTk.js +1156 -0
- package/dist/chunks/Quest-uSIVq78I.js +8581 -0
- package/dist/chunks/Table-CWGf2FKV.js +449 -0
- package/dist/chunks/TaskOnProvider-QMwxGL44.js +1435 -0
- package/dist/chunks/ThemeProvider-Cs8IUVQj.js +1118 -0
- package/dist/chunks/WidgetShell-NlOgn1x5.js +1517 -0
- package/dist/chunks/common-ja-DWhTaFHb.js +23 -0
- package/dist/chunks/common-ko-80ezXsMG.js +23 -0
- package/dist/chunks/index-CwMvO_wZ.js +777 -0
- package/dist/chunks/leaderboardwidget-ja-Bj6gz6y1.js +119 -0
- package/dist/chunks/leaderboardwidget-ko-f1cLO9ic.js +119 -0
- package/dist/chunks/useToast-BGJhd3BX.js +93 -0
- package/dist/chunks/useWidgetLocale-BVcopbZS.js +74 -0
- package/dist/chunks/usercenter-ja-DBj_dtuz.js +329 -0
- package/dist/chunks/usercenter-ko-DYTkHAld.js +329 -0
- package/dist/community-task.d.ts +451 -0
- package/dist/community-task.js +9 -0
- package/dist/core.d.ts +803 -0
- package/dist/core.js +22 -0
- package/dist/index.css +3662 -0
- package/dist/index.d.ts +1627 -0
- package/dist/index.js +7372 -0
- package/dist/leaderboard.d.ts +547 -0
- package/dist/leaderboard.js +17 -0
- package/dist/quest.d.ts +389 -0
- package/dist/quest.js +8 -0
- package/package.json +97 -0
|
@@ -0,0 +1,449 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { c as composeRefs } from "./ThemeProvider-Cs8IUVQj.js";
|
|
5
|
+
import '../Table.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
|
+
export {
|
|
446
|
+
Button as B,
|
|
447
|
+
Pagination as P,
|
|
448
|
+
Table as T
|
|
449
|
+
};
|