@taskon/widget-react 0.0.1-beta.6 → 0.0.1-beta.7
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 +48 -43
- package/dist/EligibilityInfo.css +2 -33
- package/dist/TaskOnProvider.css +287 -0
- package/dist/ThemeProvider.css +227 -0
- package/dist/UserCenterWidget2.css +32 -290
- package/dist/WidgetShell.css +0 -227
- package/dist/chunks/{CommunityTaskList-Hde2OKHH.js → CommunityTaskList-D0uVD8wD.js} +37 -58
- package/dist/chunks/{EligibilityInfo-BV0Z2TgY.js → EligibilityInfo-Cf6hx9-a.js} +17 -209
- package/dist/chunks/{LeaderboardWidget-BNGRD5Bu.js → LeaderboardWidget-DyoiiNS6.js} +10 -9
- package/dist/chunks/{PageBuilder-C5DSHiW9.js → PageBuilder-DoAFPm6-.js} +5 -5
- package/dist/chunks/{Quest-DG9zfXJo.js → Quest-ySZlYd4u.js} +6 -11
- package/dist/chunks/TaskOnProvider-CxtFIs3n.js +2072 -0
- package/dist/chunks/{WidgetShell-D7yC894Y.js → ThemeProvider-CulHkqqY.js} +1354 -617
- package/dist/chunks/UserCenterWidget-BJsc_GSZ.js +3246 -0
- package/dist/chunks/{UserCenterWidget-D5ttw4hO.js → UserCenterWidget-STq8kpV4.js} +162 -365
- package/dist/chunks/WidgetShell-8xn-Jivw.js +659 -0
- package/dist/chunks/useIsMobile-D6Ybur-6.js +30 -0
- package/dist/chunks/useToast-BGJhd3BX.js +93 -0
- package/dist/community-task.js +1 -1
- package/dist/core.d.ts +9 -15
- package/dist/core.js +3 -3
- package/dist/index.d.ts +64 -15
- package/dist/index.js +15 -10
- package/dist/leaderboard.js +1 -1
- package/dist/page-builder.js +1 -1
- package/dist/quest.js +1 -1
- package/dist/user-center.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/TaskOnProvider-BhamHIyY.js +0 -1260
- package/dist/chunks/ThemeProvider-mXLdLSkq.js +0 -1397
- package/dist/chunks/UserCenterWidget-jDO5zTN1.js +0 -3297
- package/dist/chunks/useToast-CaRkylKe.js +0 -304
|
@@ -1,175 +1,861 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { createWidgetApi, parseWidgetConfig } from "@taskon/core";
|
|
4
|
-
import { h as useTaskOnContext, s as useLayoutEffect2, q as useCallbackRef$1, k as useComposedRefs, P as Primitive, m as useControllableState, j as createContextScope, n as Presence, r as Portal$1, o as composeEventHandlers, l as createSlot$1, D as DismissableLayer, w as createContext2, x as useTaskOnPortalContainer, y as composeRefs, T as ThemeProvider } from "./ThemeProvider-mXLdLSkq.js";
|
|
2
|
+
import { createContext, useContext, useMemo, useState, useRef, useEffect } from "react";
|
|
5
3
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
4
|
+
import * as ReactDOM from "react-dom";
|
|
5
|
+
import ReactDOM__default from "react-dom";
|
|
6
|
+
import '../ThemeProvider.css';const ThemeContext = createContext(null);
|
|
7
|
+
const ThemePortalContainerContext = createContext(void 0);
|
|
8
|
+
function useTaskOnTheme() {
|
|
9
|
+
const theme = useContext(ThemeContext);
|
|
10
|
+
if (!theme) {
|
|
11
|
+
throw new Error("useTaskOnTheme must be used within a ThemeProvider");
|
|
12
|
+
}
|
|
13
|
+
return theme;
|
|
14
|
+
}
|
|
15
|
+
function useTaskOnPortalContainer() {
|
|
16
|
+
const container = useContext(ThemePortalContainerContext);
|
|
17
|
+
if (container !== void 0) {
|
|
18
|
+
return container;
|
|
19
|
+
}
|
|
20
|
+
if (typeof document !== "undefined") {
|
|
21
|
+
return document.body;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const TaskOnContext = createContext(null);
|
|
26
|
+
function useTaskOnContext() {
|
|
27
|
+
const context = useContext(TaskOnContext);
|
|
28
|
+
if (!context) {
|
|
29
|
+
throw new Error("useTaskOnContext must be used within a TaskOnProvider");
|
|
30
|
+
}
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
33
|
+
function useTaskOnAuth() {
|
|
34
|
+
const context = useTaskOnContext();
|
|
35
|
+
return useMemo(
|
|
36
|
+
() => ({
|
|
37
|
+
// User state
|
|
38
|
+
userId: context.userId,
|
|
39
|
+
isLoggedIn: context.isLoggedIn,
|
|
40
|
+
isInitializing: context.isInitializing,
|
|
41
|
+
isSessionReady: context.isSessionReady,
|
|
42
|
+
// Unified login
|
|
43
|
+
login: context.login,
|
|
44
|
+
// Logout
|
|
45
|
+
logout: context.logout,
|
|
46
|
+
// Request login (triggers config.onRequestLogin)
|
|
47
|
+
requestLogin: context.requestLogin
|
|
48
|
+
}),
|
|
49
|
+
[
|
|
50
|
+
context.userId,
|
|
51
|
+
context.isLoggedIn,
|
|
52
|
+
context.isInitializing,
|
|
53
|
+
context.isSessionReady,
|
|
54
|
+
context.login,
|
|
55
|
+
context.logout,
|
|
56
|
+
context.requestLogin
|
|
57
|
+
]
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
function isSupportedLocale(locale) {
|
|
61
|
+
return locale === "en" || locale === "ko" || locale === "ja" || locale === "ru" || locale === "es";
|
|
62
|
+
}
|
|
63
|
+
function warnUnsupportedLocale(locale, widgetId) {
|
|
64
|
+
if (process.env.NODE_ENV !== "production" && !isSupportedLocale(locale)) {
|
|
65
|
+
console.warn(
|
|
66
|
+
`[widget-react] Locale "${locale}" is not fully supported in ${widgetId}. Falling back to English. Supported locales: en, ko, ja, ru, es`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const localeCache = /* @__PURE__ */ new Map();
|
|
71
|
+
const DEFAULT_LOCALE = "en";
|
|
72
|
+
function useWidgetLocale(options) {
|
|
73
|
+
const { widgetId, defaultMessages, loadMessages } = options;
|
|
74
|
+
const { locale } = useTaskOnContext();
|
|
75
|
+
const getInitialState = () => {
|
|
76
|
+
if (locale === DEFAULT_LOCALE) {
|
|
77
|
+
return { messages: defaultMessages, isLoading: false };
|
|
78
|
+
}
|
|
79
|
+
const cacheKey = `${widgetId}-${locale}`;
|
|
80
|
+
if (localeCache.has(cacheKey)) {
|
|
81
|
+
return { messages: localeCache.get(cacheKey), isLoading: false };
|
|
82
|
+
}
|
|
83
|
+
return { messages: defaultMessages, isLoading: true };
|
|
84
|
+
};
|
|
85
|
+
const [state, setState] = useState(getInitialState);
|
|
86
|
+
const loadMessagesRef = useRef(loadMessages);
|
|
87
|
+
loadMessagesRef.current = loadMessages;
|
|
88
|
+
const defaultMessagesRef = useRef(defaultMessages);
|
|
89
|
+
defaultMessagesRef.current = defaultMessages;
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (locale === DEFAULT_LOCALE) {
|
|
92
|
+
setState({ messages: defaultMessagesRef.current, isLoading: false });
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
warnUnsupportedLocale(locale, widgetId);
|
|
96
|
+
const cacheKey = `${widgetId}-${locale}`;
|
|
97
|
+
if (localeCache.has(cacheKey)) {
|
|
98
|
+
setState({ messages: localeCache.get(cacheKey), isLoading: false });
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
let isMounted = true;
|
|
102
|
+
setState((prev) => ({ ...prev, isLoading: true }));
|
|
103
|
+
loadMessagesRef.current(locale).then((module) => {
|
|
104
|
+
if (isMounted) {
|
|
105
|
+
const loadedMessages = module.default;
|
|
106
|
+
localeCache.set(cacheKey, loadedMessages);
|
|
107
|
+
setState({ messages: loadedMessages, isLoading: false });
|
|
108
|
+
}
|
|
109
|
+
}).catch((error) => {
|
|
110
|
+
console.warn(
|
|
111
|
+
`[widget-react] Failed to load locale "${locale}" for ${widgetId}, falling back to English:`,
|
|
112
|
+
error
|
|
113
|
+
);
|
|
114
|
+
if (isMounted) {
|
|
115
|
+
setState({ messages: defaultMessagesRef.current, isLoading: false });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return () => {
|
|
119
|
+
isMounted = false;
|
|
32
120
|
};
|
|
121
|
+
}, [locale, widgetId]);
|
|
122
|
+
return state;
|
|
123
|
+
}
|
|
124
|
+
function clearLocaleCache() {
|
|
125
|
+
localeCache.clear();
|
|
126
|
+
}
|
|
127
|
+
async function preloadWidgetLocale(widgetId, locale, loadMessages) {
|
|
128
|
+
if (locale === DEFAULT_LOCALE) return;
|
|
129
|
+
const cacheKey = `${widgetId}-${locale}`;
|
|
130
|
+
if (localeCache.has(cacheKey)) return;
|
|
131
|
+
try {
|
|
132
|
+
const module = await loadMessages(locale);
|
|
133
|
+
localeCache.set(cacheKey, module.default);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.warn(
|
|
136
|
+
`[widget-react] Failed to preload locale "${locale}" for ${widgetId}:`,
|
|
137
|
+
error
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
function interpolate(template, params) {
|
|
142
|
+
if (!params) {
|
|
143
|
+
return template;
|
|
144
|
+
}
|
|
145
|
+
return template.replace(/\{(\w+)\}/g, (match, key) => {
|
|
146
|
+
const value = params[key];
|
|
147
|
+
if (value === void 0) {
|
|
148
|
+
return match;
|
|
149
|
+
}
|
|
150
|
+
return String(value);
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
function createT(messages) {
|
|
154
|
+
return (key, params) => {
|
|
155
|
+
const template = messages[key];
|
|
156
|
+
if (typeof template !== "string") {
|
|
157
|
+
if (process.env.NODE_ENV !== "production") {
|
|
158
|
+
console.warn(`[widget-react] Missing translation key: ${String(key)}`);
|
|
159
|
+
}
|
|
160
|
+
return String(key);
|
|
161
|
+
}
|
|
162
|
+
return interpolate(template, params);
|
|
33
163
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// Per-mode color overrides
|
|
44
|
-
light: {
|
|
45
|
-
seed: mapColorToSeed(cloud.light)
|
|
46
|
-
},
|
|
47
|
-
dark: {
|
|
48
|
-
seed: mapColorToSeed(cloud.dark)
|
|
164
|
+
}
|
|
165
|
+
function createTFunction(messages) {
|
|
166
|
+
return (key, params) => {
|
|
167
|
+
const template = messages[key];
|
|
168
|
+
if (typeof template !== "string") {
|
|
169
|
+
if (process.env.NODE_ENV !== "production") {
|
|
170
|
+
console.warn(`[widget-react] Missing translation key: ${String(key)}`);
|
|
171
|
+
}
|
|
172
|
+
return String(key);
|
|
49
173
|
}
|
|
174
|
+
return interpolate(template, params);
|
|
50
175
|
};
|
|
51
176
|
}
|
|
52
|
-
function
|
|
53
|
-
const {
|
|
54
|
-
const
|
|
55
|
-
const totalPages = useMemo(() => {
|
|
56
|
-
return Math.max(1, Math.ceil(total / pageSize));
|
|
57
|
-
}, [total, pageSize]);
|
|
58
|
-
const safePage = useMemo(() => {
|
|
59
|
-
return Math.min(page, totalPages - 1);
|
|
60
|
-
}, [page, totalPages]);
|
|
61
|
-
if (safePage !== page) {
|
|
62
|
-
setPage(safePage);
|
|
63
|
-
}
|
|
64
|
-
const hasPrevious = safePage > 0;
|
|
65
|
-
const hasNext = safePage < totalPages - 1;
|
|
66
|
-
const goToPage = useCallback(
|
|
67
|
-
(targetPage) => {
|
|
68
|
-
const validPage = Math.max(0, Math.min(targetPage, totalPages - 1));
|
|
69
|
-
setPage(validPage);
|
|
70
|
-
},
|
|
71
|
-
[totalPages]
|
|
72
|
-
);
|
|
73
|
-
const goToPrevious = useCallback(() => {
|
|
74
|
-
if (hasPrevious) {
|
|
75
|
-
setPage((p) => p - 1);
|
|
76
|
-
}
|
|
77
|
-
}, [hasPrevious]);
|
|
78
|
-
const goToNext = useCallback(() => {
|
|
79
|
-
if (hasNext) {
|
|
80
|
-
setPage((p) => p + 1);
|
|
81
|
-
}
|
|
82
|
-
}, [hasNext]);
|
|
83
|
-
const reset = useCallback(() => {
|
|
84
|
-
setPage(0);
|
|
85
|
-
}, []);
|
|
86
|
-
const startIndex = safePage * pageSize + 1;
|
|
87
|
-
const endIndex = Math.min((safePage + 1) * pageSize, total);
|
|
88
|
-
const hasMore = useMemo(() => {
|
|
89
|
-
if (mode === "infinite") {
|
|
90
|
-
return safePage < totalPages - 1;
|
|
91
|
-
}
|
|
92
|
-
return hasNext;
|
|
93
|
-
}, [mode, safePage, totalPages, hasNext]);
|
|
94
|
-
const loadedCount = useMemo(() => {
|
|
95
|
-
if (mode === "infinite") {
|
|
96
|
-
return Math.min((safePage + 1) * pageSize, total);
|
|
97
|
-
}
|
|
98
|
-
return endIndex - startIndex + 1;
|
|
99
|
-
}, [mode, safePage, pageSize, total, startIndex, endIndex]);
|
|
100
|
-
const loadMore = useCallback(() => {
|
|
101
|
-
if (mode === "infinite" && hasMore) {
|
|
102
|
-
setPage((p) => p + 1);
|
|
103
|
-
}
|
|
104
|
-
}, [mode, hasMore]);
|
|
177
|
+
function useTranslation(options) {
|
|
178
|
+
const { messages, isLoading } = useWidgetLocale(options);
|
|
179
|
+
const t = useMemo(() => createTFunction(messages), [messages]);
|
|
105
180
|
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
hasNext,
|
|
110
|
-
goToPage,
|
|
111
|
-
goToPrevious,
|
|
112
|
-
goToNext,
|
|
113
|
-
reset,
|
|
114
|
-
startIndex,
|
|
115
|
-
endIndex,
|
|
116
|
-
// Infinite 模式专用
|
|
117
|
-
loadMore,
|
|
118
|
-
hasMore,
|
|
119
|
-
loadedCount
|
|
181
|
+
t,
|
|
182
|
+
messages,
|
|
183
|
+
isLoading
|
|
120
184
|
};
|
|
121
185
|
}
|
|
122
|
-
function
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
setIsLoading(false);
|
|
131
|
-
setError(null);
|
|
132
|
-
return;
|
|
186
|
+
function createLocaleLoader(defaultMessages, imports) {
|
|
187
|
+
return (locale) => {
|
|
188
|
+
if (locale === "en") {
|
|
189
|
+
return Promise.resolve({ default: defaultMessages });
|
|
190
|
+
}
|
|
191
|
+
const importFn = imports[locale];
|
|
192
|
+
if (importFn) {
|
|
193
|
+
return importFn();
|
|
133
194
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
195
|
+
return Promise.resolve({ default: defaultMessages });
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
199
|
+
return function handleEvent(event) {
|
|
200
|
+
originalEventHandler == null ? void 0 : originalEventHandler(event);
|
|
201
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
202
|
+
return ourEventHandler == null ? void 0 : ourEventHandler(event);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
function setRef(ref, value) {
|
|
207
|
+
if (typeof ref === "function") {
|
|
208
|
+
return ref(value);
|
|
209
|
+
} else if (ref !== null && ref !== void 0) {
|
|
210
|
+
ref.current = value;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function composeRefs(...refs) {
|
|
214
|
+
return (node) => {
|
|
215
|
+
let hasCleanup = false;
|
|
216
|
+
const cleanups = refs.map((ref) => {
|
|
217
|
+
const cleanup = setRef(ref, node);
|
|
218
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
219
|
+
hasCleanup = true;
|
|
141
220
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
221
|
+
return cleanup;
|
|
222
|
+
});
|
|
223
|
+
if (hasCleanup) {
|
|
224
|
+
return () => {
|
|
225
|
+
for (let i = 0; i < cleanups.length; i++) {
|
|
226
|
+
const cleanup = cleanups[i];
|
|
227
|
+
if (typeof cleanup == "function") {
|
|
228
|
+
cleanup();
|
|
229
|
+
} else {
|
|
230
|
+
setRef(refs[i], null);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function useComposedRefs(...refs) {
|
|
238
|
+
return React.useCallback(composeRefs(...refs), refs);
|
|
239
|
+
}
|
|
240
|
+
function createContext2(rootComponentName, defaultContext) {
|
|
241
|
+
const Context = React.createContext(defaultContext);
|
|
242
|
+
const Provider = (props) => {
|
|
243
|
+
const { children, ...context } = props;
|
|
244
|
+
const value = React.useMemo(() => context, Object.values(context));
|
|
245
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
246
|
+
};
|
|
247
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
248
|
+
function useContext2(consumerName) {
|
|
249
|
+
const context = React.useContext(Context);
|
|
250
|
+
if (context) return context;
|
|
251
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
252
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
253
|
+
}
|
|
254
|
+
return [Provider, useContext2];
|
|
255
|
+
}
|
|
256
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
257
|
+
let defaultContexts = [];
|
|
258
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
259
|
+
const BaseContext = React.createContext(defaultContext);
|
|
260
|
+
const index = defaultContexts.length;
|
|
261
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
262
|
+
const Provider = (props) => {
|
|
263
|
+
var _a;
|
|
264
|
+
const { scope, children, ...context } = props;
|
|
265
|
+
const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
|
|
266
|
+
const value = React.useMemo(() => context, Object.values(context));
|
|
267
|
+
return /* @__PURE__ */ jsx(Context.Provider, { value, children });
|
|
268
|
+
};
|
|
269
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
270
|
+
function useContext2(consumerName, scope) {
|
|
271
|
+
var _a;
|
|
272
|
+
const Context = ((_a = scope == null ? void 0 : scope[scopeName]) == null ? void 0 : _a[index]) || BaseContext;
|
|
273
|
+
const context = React.useContext(Context);
|
|
274
|
+
if (context) return context;
|
|
275
|
+
if (defaultContext !== void 0) return defaultContext;
|
|
276
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
277
|
+
}
|
|
278
|
+
return [Provider, useContext2];
|
|
279
|
+
}
|
|
280
|
+
const createScope = () => {
|
|
281
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
282
|
+
return React.createContext(defaultContext);
|
|
283
|
+
});
|
|
284
|
+
return function useScope(scope) {
|
|
285
|
+
const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
|
|
286
|
+
return React.useMemo(
|
|
287
|
+
() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
|
|
288
|
+
[scope, contexts]
|
|
289
|
+
);
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
createScope.scopeName = scopeName;
|
|
293
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
294
|
+
}
|
|
295
|
+
function composeContextScopes(...scopes) {
|
|
296
|
+
const baseScope = scopes[0];
|
|
297
|
+
if (scopes.length === 1) return baseScope;
|
|
298
|
+
const createScope = () => {
|
|
299
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
300
|
+
useScope: createScope2(),
|
|
301
|
+
scopeName: createScope2.scopeName
|
|
302
|
+
}));
|
|
303
|
+
return function useComposedScopes(overrideScopes) {
|
|
304
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
305
|
+
const scopeProps = useScope(overrideScopes);
|
|
306
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
307
|
+
return { ...nextScopes2, ...currentScope };
|
|
308
|
+
}, {});
|
|
309
|
+
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
createScope.scopeName = baseScope.scopeName;
|
|
313
|
+
return createScope;
|
|
314
|
+
}
|
|
315
|
+
// @__NO_SIDE_EFFECTS__
|
|
316
|
+
function createSlot(ownerName) {
|
|
317
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
318
|
+
const Slot2 = React.forwardRef((props, forwardedRef) => {
|
|
319
|
+
const { children, ...slotProps } = props;
|
|
320
|
+
const childrenArray = React.Children.toArray(children);
|
|
321
|
+
const slottable = childrenArray.find(isSlottable);
|
|
322
|
+
if (slottable) {
|
|
323
|
+
const newElement = slottable.props.children;
|
|
324
|
+
const newChildren = childrenArray.map((child) => {
|
|
325
|
+
if (child === slottable) {
|
|
326
|
+
if (React.Children.count(newElement) > 1) return React.Children.only(null);
|
|
327
|
+
return React.isValidElement(newElement) ? newElement.props.children : null;
|
|
328
|
+
} else {
|
|
329
|
+
return child;
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
333
|
+
}
|
|
334
|
+
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
335
|
+
});
|
|
336
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
337
|
+
return Slot2;
|
|
338
|
+
}
|
|
339
|
+
// @__NO_SIDE_EFFECTS__
|
|
340
|
+
function createSlotClone(ownerName) {
|
|
341
|
+
const SlotClone = React.forwardRef((props, forwardedRef) => {
|
|
342
|
+
const { children, ...slotProps } = props;
|
|
343
|
+
if (React.isValidElement(children)) {
|
|
344
|
+
const childrenRef = getElementRef$1(children);
|
|
345
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
346
|
+
if (children.type !== React.Fragment) {
|
|
347
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
148
348
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
349
|
+
return React.cloneElement(children, props2);
|
|
350
|
+
}
|
|
351
|
+
return React.Children.count(children) > 1 ? React.Children.only(null) : null;
|
|
352
|
+
});
|
|
353
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
354
|
+
return SlotClone;
|
|
355
|
+
}
|
|
356
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
357
|
+
function isSlottable(child) {
|
|
358
|
+
return React.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
359
|
+
}
|
|
360
|
+
function mergeProps(slotProps, childProps) {
|
|
361
|
+
const overrideProps = { ...childProps };
|
|
362
|
+
for (const propName in childProps) {
|
|
363
|
+
const slotPropValue = slotProps[propName];
|
|
364
|
+
const childPropValue = childProps[propName];
|
|
365
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
366
|
+
if (isHandler) {
|
|
367
|
+
if (slotPropValue && childPropValue) {
|
|
368
|
+
overrideProps[propName] = (...args) => {
|
|
369
|
+
const result = childPropValue(...args);
|
|
370
|
+
slotPropValue(...args);
|
|
371
|
+
return result;
|
|
372
|
+
};
|
|
373
|
+
} else if (slotPropValue) {
|
|
374
|
+
overrideProps[propName] = slotPropValue;
|
|
152
375
|
}
|
|
153
|
-
})
|
|
376
|
+
} else if (propName === "style") {
|
|
377
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
378
|
+
} else if (propName === "className") {
|
|
379
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
return { ...slotProps, ...overrideProps };
|
|
383
|
+
}
|
|
384
|
+
function getElementRef$1(element) {
|
|
385
|
+
var _a, _b;
|
|
386
|
+
let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
|
|
387
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
388
|
+
if (mayWarn) {
|
|
389
|
+
return element.ref;
|
|
390
|
+
}
|
|
391
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
392
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
393
|
+
if (mayWarn) {
|
|
394
|
+
return element.props.ref;
|
|
395
|
+
}
|
|
396
|
+
return element.props.ref || element.ref;
|
|
397
|
+
}
|
|
398
|
+
var NODES = [
|
|
399
|
+
"a",
|
|
400
|
+
"button",
|
|
401
|
+
"div",
|
|
402
|
+
"form",
|
|
403
|
+
"h2",
|
|
404
|
+
"h3",
|
|
405
|
+
"img",
|
|
406
|
+
"input",
|
|
407
|
+
"label",
|
|
408
|
+
"li",
|
|
409
|
+
"nav",
|
|
410
|
+
"ol",
|
|
411
|
+
"p",
|
|
412
|
+
"select",
|
|
413
|
+
"span",
|
|
414
|
+
"svg",
|
|
415
|
+
"ul"
|
|
416
|
+
];
|
|
417
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
418
|
+
const Slot2 = /* @__PURE__ */ createSlot(`Primitive.${node}`);
|
|
419
|
+
const Node2 = React.forwardRef((props, forwardedRef) => {
|
|
420
|
+
const { asChild, ...primitiveProps } = props;
|
|
421
|
+
const Comp = asChild ? Slot2 : node;
|
|
422
|
+
if (typeof window !== "undefined") {
|
|
423
|
+
window[Symbol.for("radix-ui")] = true;
|
|
424
|
+
}
|
|
425
|
+
return /* @__PURE__ */ jsx(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
426
|
+
});
|
|
427
|
+
Node2.displayName = `Primitive.${node}`;
|
|
428
|
+
return { ...primitive, [node]: Node2 };
|
|
429
|
+
}, {});
|
|
430
|
+
function dispatchDiscreteCustomEvent(target, event) {
|
|
431
|
+
if (target) ReactDOM.flushSync(() => target.dispatchEvent(event));
|
|
432
|
+
}
|
|
433
|
+
function useCallbackRef$1(callback) {
|
|
434
|
+
const callbackRef = React.useRef(callback);
|
|
435
|
+
React.useEffect(() => {
|
|
436
|
+
callbackRef.current = callback;
|
|
437
|
+
});
|
|
438
|
+
return React.useMemo(() => (...args) => {
|
|
439
|
+
var _a;
|
|
440
|
+
return (_a = callbackRef.current) == null ? void 0 : _a.call(callbackRef, ...args);
|
|
441
|
+
}, []);
|
|
442
|
+
}
|
|
443
|
+
function useEscapeKeydown(onEscapeKeyDownProp, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
444
|
+
const onEscapeKeyDown = useCallbackRef$1(onEscapeKeyDownProp);
|
|
445
|
+
React.useEffect(() => {
|
|
446
|
+
const handleKeyDown = (event) => {
|
|
447
|
+
if (event.key === "Escape") {
|
|
448
|
+
onEscapeKeyDown(event);
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
ownerDocument.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
452
|
+
return () => ownerDocument.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
453
|
+
}, [onEscapeKeyDown, ownerDocument]);
|
|
454
|
+
}
|
|
455
|
+
var DISMISSABLE_LAYER_NAME = "DismissableLayer";
|
|
456
|
+
var CONTEXT_UPDATE = "dismissableLayer.update";
|
|
457
|
+
var POINTER_DOWN_OUTSIDE = "dismissableLayer.pointerDownOutside";
|
|
458
|
+
var FOCUS_OUTSIDE = "dismissableLayer.focusOutside";
|
|
459
|
+
var originalBodyPointerEvents;
|
|
460
|
+
var DismissableLayerContext = React.createContext({
|
|
461
|
+
layers: /* @__PURE__ */ new Set(),
|
|
462
|
+
layersWithOutsidePointerEventsDisabled: /* @__PURE__ */ new Set(),
|
|
463
|
+
branches: /* @__PURE__ */ new Set()
|
|
464
|
+
});
|
|
465
|
+
var DismissableLayer = React.forwardRef(
|
|
466
|
+
(props, forwardedRef) => {
|
|
467
|
+
const {
|
|
468
|
+
disableOutsidePointerEvents = false,
|
|
469
|
+
onEscapeKeyDown,
|
|
470
|
+
onPointerDownOutside,
|
|
471
|
+
onFocusOutside,
|
|
472
|
+
onInteractOutside,
|
|
473
|
+
onDismiss,
|
|
474
|
+
...layerProps
|
|
475
|
+
} = props;
|
|
476
|
+
const context = React.useContext(DismissableLayerContext);
|
|
477
|
+
const [node, setNode] = React.useState(null);
|
|
478
|
+
const ownerDocument = (node == null ? void 0 : node.ownerDocument) ?? (globalThis == null ? void 0 : globalThis.document);
|
|
479
|
+
const [, force] = React.useState({});
|
|
480
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
481
|
+
const layers = Array.from(context.layers);
|
|
482
|
+
const [highestLayerWithOutsidePointerEventsDisabled] = [...context.layersWithOutsidePointerEventsDisabled].slice(-1);
|
|
483
|
+
const highestLayerWithOutsidePointerEventsDisabledIndex = layers.indexOf(highestLayerWithOutsidePointerEventsDisabled);
|
|
484
|
+
const index = node ? layers.indexOf(node) : -1;
|
|
485
|
+
const isBodyPointerEventsDisabled = context.layersWithOutsidePointerEventsDisabled.size > 0;
|
|
486
|
+
const isPointerEventsEnabled = index >= highestLayerWithOutsidePointerEventsDisabledIndex;
|
|
487
|
+
const pointerDownOutside = usePointerDownOutside((event) => {
|
|
488
|
+
const target = event.target;
|
|
489
|
+
const isPointerDownOnBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
490
|
+
if (!isPointerEventsEnabled || isPointerDownOnBranch) return;
|
|
491
|
+
onPointerDownOutside == null ? void 0 : onPointerDownOutside(event);
|
|
492
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
493
|
+
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
494
|
+
}, ownerDocument);
|
|
495
|
+
const focusOutside = useFocusOutside((event) => {
|
|
496
|
+
const target = event.target;
|
|
497
|
+
const isFocusInBranch = [...context.branches].some((branch) => branch.contains(target));
|
|
498
|
+
if (isFocusInBranch) return;
|
|
499
|
+
onFocusOutside == null ? void 0 : onFocusOutside(event);
|
|
500
|
+
onInteractOutside == null ? void 0 : onInteractOutside(event);
|
|
501
|
+
if (!event.defaultPrevented) onDismiss == null ? void 0 : onDismiss();
|
|
502
|
+
}, ownerDocument);
|
|
503
|
+
useEscapeKeydown((event) => {
|
|
504
|
+
const isHighestLayer = index === context.layers.size - 1;
|
|
505
|
+
if (!isHighestLayer) return;
|
|
506
|
+
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event);
|
|
507
|
+
if (!event.defaultPrevented && onDismiss) {
|
|
508
|
+
event.preventDefault();
|
|
509
|
+
onDismiss();
|
|
510
|
+
}
|
|
511
|
+
}, ownerDocument);
|
|
512
|
+
React.useEffect(() => {
|
|
513
|
+
if (!node) return;
|
|
514
|
+
if (disableOutsidePointerEvents) {
|
|
515
|
+
if (context.layersWithOutsidePointerEventsDisabled.size === 0) {
|
|
516
|
+
originalBodyPointerEvents = ownerDocument.body.style.pointerEvents;
|
|
517
|
+
ownerDocument.body.style.pointerEvents = "none";
|
|
518
|
+
}
|
|
519
|
+
context.layersWithOutsidePointerEventsDisabled.add(node);
|
|
520
|
+
}
|
|
521
|
+
context.layers.add(node);
|
|
522
|
+
dispatchUpdate();
|
|
523
|
+
return () => {
|
|
524
|
+
if (disableOutsidePointerEvents && context.layersWithOutsidePointerEventsDisabled.size === 1) {
|
|
525
|
+
ownerDocument.body.style.pointerEvents = originalBodyPointerEvents;
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}, [node, ownerDocument, disableOutsidePointerEvents, context]);
|
|
529
|
+
React.useEffect(() => {
|
|
530
|
+
return () => {
|
|
531
|
+
if (!node) return;
|
|
532
|
+
context.layers.delete(node);
|
|
533
|
+
context.layersWithOutsidePointerEventsDisabled.delete(node);
|
|
534
|
+
dispatchUpdate();
|
|
535
|
+
};
|
|
536
|
+
}, [node, context]);
|
|
537
|
+
React.useEffect(() => {
|
|
538
|
+
const handleUpdate = () => force({});
|
|
539
|
+
document.addEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
540
|
+
return () => document.removeEventListener(CONTEXT_UPDATE, handleUpdate);
|
|
541
|
+
}, []);
|
|
542
|
+
return /* @__PURE__ */ jsx(
|
|
543
|
+
Primitive.div,
|
|
544
|
+
{
|
|
545
|
+
...layerProps,
|
|
546
|
+
ref: composedRefs,
|
|
547
|
+
style: {
|
|
548
|
+
pointerEvents: isBodyPointerEventsDisabled ? isPointerEventsEnabled ? "auto" : "none" : void 0,
|
|
549
|
+
...props.style
|
|
550
|
+
},
|
|
551
|
+
onFocusCapture: composeEventHandlers(props.onFocusCapture, focusOutside.onFocusCapture),
|
|
552
|
+
onBlurCapture: composeEventHandlers(props.onBlurCapture, focusOutside.onBlurCapture),
|
|
553
|
+
onPointerDownCapture: composeEventHandlers(
|
|
554
|
+
props.onPointerDownCapture,
|
|
555
|
+
pointerDownOutside.onPointerDownCapture
|
|
556
|
+
)
|
|
557
|
+
}
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
DismissableLayer.displayName = DISMISSABLE_LAYER_NAME;
|
|
562
|
+
var BRANCH_NAME = "DismissableLayerBranch";
|
|
563
|
+
var DismissableLayerBranch = React.forwardRef((props, forwardedRef) => {
|
|
564
|
+
const context = React.useContext(DismissableLayerContext);
|
|
565
|
+
const ref = React.useRef(null);
|
|
566
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
567
|
+
React.useEffect(() => {
|
|
568
|
+
const node = ref.current;
|
|
569
|
+
if (node) {
|
|
570
|
+
context.branches.add(node);
|
|
571
|
+
return () => {
|
|
572
|
+
context.branches.delete(node);
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}, [context.branches]);
|
|
576
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...props, ref: composedRefs });
|
|
577
|
+
});
|
|
578
|
+
DismissableLayerBranch.displayName = BRANCH_NAME;
|
|
579
|
+
function usePointerDownOutside(onPointerDownOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
580
|
+
const handlePointerDownOutside = useCallbackRef$1(onPointerDownOutside);
|
|
581
|
+
const isPointerInsideReactTreeRef = React.useRef(false);
|
|
582
|
+
const handleClickRef = React.useRef(() => {
|
|
583
|
+
});
|
|
584
|
+
React.useEffect(() => {
|
|
585
|
+
const handlePointerDown = (event) => {
|
|
586
|
+
if (event.target && !isPointerInsideReactTreeRef.current) {
|
|
587
|
+
let handleAndDispatchPointerDownOutsideEvent2 = function() {
|
|
588
|
+
handleAndDispatchCustomEvent(
|
|
589
|
+
POINTER_DOWN_OUTSIDE,
|
|
590
|
+
handlePointerDownOutside,
|
|
591
|
+
eventDetail,
|
|
592
|
+
{ discrete: true }
|
|
593
|
+
);
|
|
594
|
+
};
|
|
595
|
+
const eventDetail = { originalEvent: event };
|
|
596
|
+
if (event.pointerType === "touch") {
|
|
597
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
598
|
+
handleClickRef.current = handleAndDispatchPointerDownOutsideEvent2;
|
|
599
|
+
ownerDocument.addEventListener("click", handleClickRef.current, { once: true });
|
|
600
|
+
} else {
|
|
601
|
+
handleAndDispatchPointerDownOutsideEvent2();
|
|
602
|
+
}
|
|
603
|
+
} else {
|
|
604
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
605
|
+
}
|
|
606
|
+
isPointerInsideReactTreeRef.current = false;
|
|
607
|
+
};
|
|
608
|
+
const timerId = window.setTimeout(() => {
|
|
609
|
+
ownerDocument.addEventListener("pointerdown", handlePointerDown);
|
|
610
|
+
}, 0);
|
|
154
611
|
return () => {
|
|
155
|
-
|
|
612
|
+
window.clearTimeout(timerId);
|
|
613
|
+
ownerDocument.removeEventListener("pointerdown", handlePointerDown);
|
|
614
|
+
ownerDocument.removeEventListener("click", handleClickRef.current);
|
|
156
615
|
};
|
|
157
|
-
}, [
|
|
158
|
-
return {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
616
|
+
}, [ownerDocument, handlePointerDownOutside]);
|
|
617
|
+
return {
|
|
618
|
+
// ensures we check React component tree (not just DOM tree)
|
|
619
|
+
onPointerDownCapture: () => isPointerInsideReactTreeRef.current = true
|
|
620
|
+
};
|
|
621
|
+
}
|
|
622
|
+
function useFocusOutside(onFocusOutside, ownerDocument = globalThis == null ? void 0 : globalThis.document) {
|
|
623
|
+
const handleFocusOutside = useCallbackRef$1(onFocusOutside);
|
|
624
|
+
const isFocusInsideReactTreeRef = React.useRef(false);
|
|
625
|
+
React.useEffect(() => {
|
|
626
|
+
const handleFocus = (event) => {
|
|
627
|
+
if (event.target && !isFocusInsideReactTreeRef.current) {
|
|
628
|
+
const eventDetail = { originalEvent: event };
|
|
629
|
+
handleAndDispatchCustomEvent(FOCUS_OUTSIDE, handleFocusOutside, eventDetail, {
|
|
630
|
+
discrete: false
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
ownerDocument.addEventListener("focusin", handleFocus);
|
|
635
|
+
return () => ownerDocument.removeEventListener("focusin", handleFocus);
|
|
636
|
+
}, [ownerDocument, handleFocusOutside]);
|
|
637
|
+
return {
|
|
638
|
+
onFocusCapture: () => isFocusInsideReactTreeRef.current = true,
|
|
639
|
+
onBlurCapture: () => isFocusInsideReactTreeRef.current = false
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
function dispatchUpdate() {
|
|
643
|
+
const event = new CustomEvent(CONTEXT_UPDATE);
|
|
644
|
+
document.dispatchEvent(event);
|
|
645
|
+
}
|
|
646
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
647
|
+
const target = detail.originalEvent.target;
|
|
648
|
+
const event = new CustomEvent(name, { bubbles: false, cancelable: true, detail });
|
|
649
|
+
if (handler) target.addEventListener(name, handler, { once: true });
|
|
650
|
+
if (discrete) {
|
|
651
|
+
dispatchDiscreteCustomEvent(target, event);
|
|
652
|
+
} else {
|
|
653
|
+
target.dispatchEvent(event);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
var Root$1 = DismissableLayer;
|
|
657
|
+
var Branch = DismissableLayerBranch;
|
|
658
|
+
var useLayoutEffect2 = (globalThis == null ? void 0 : globalThis.document) ? React.useLayoutEffect : () => {
|
|
659
|
+
};
|
|
660
|
+
var PORTAL_NAME$1 = "Portal";
|
|
661
|
+
var Portal$1 = React.forwardRef((props, forwardedRef) => {
|
|
662
|
+
var _a;
|
|
663
|
+
const { container: containerProp, ...portalProps } = props;
|
|
664
|
+
const [mounted, setMounted] = React.useState(false);
|
|
665
|
+
useLayoutEffect2(() => setMounted(true), []);
|
|
666
|
+
const container = containerProp || mounted && ((_a = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : _a.body);
|
|
667
|
+
return container ? ReactDOM__default.createPortal(/* @__PURE__ */ jsx(Primitive.div, { ...portalProps, ref: forwardedRef }), container) : null;
|
|
668
|
+
});
|
|
669
|
+
Portal$1.displayName = PORTAL_NAME$1;
|
|
670
|
+
function useStateMachine(initialState, machine) {
|
|
671
|
+
return React.useReducer((state, event) => {
|
|
672
|
+
const nextState = machine[state][event];
|
|
673
|
+
return nextState ?? state;
|
|
674
|
+
}, initialState);
|
|
675
|
+
}
|
|
676
|
+
var Presence = (props) => {
|
|
677
|
+
const { present, children } = props;
|
|
678
|
+
const presence = usePresence(present);
|
|
679
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React.Children.only(children);
|
|
680
|
+
const ref = useComposedRefs(presence.ref, getElementRef(child));
|
|
681
|
+
const forceMount = typeof children === "function";
|
|
682
|
+
return forceMount || presence.isPresent ? React.cloneElement(child, { ref }) : null;
|
|
683
|
+
};
|
|
684
|
+
Presence.displayName = "Presence";
|
|
685
|
+
function usePresence(present) {
|
|
686
|
+
const [node, setNode] = React.useState();
|
|
687
|
+
const stylesRef = React.useRef(null);
|
|
688
|
+
const prevPresentRef = React.useRef(present);
|
|
689
|
+
const prevAnimationNameRef = React.useRef("none");
|
|
690
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
691
|
+
const [state, send] = useStateMachine(initialState, {
|
|
692
|
+
mounted: {
|
|
693
|
+
UNMOUNT: "unmounted",
|
|
694
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
695
|
+
},
|
|
696
|
+
unmountSuspended: {
|
|
697
|
+
MOUNT: "mounted",
|
|
698
|
+
ANIMATION_END: "unmounted"
|
|
699
|
+
},
|
|
700
|
+
unmounted: {
|
|
701
|
+
MOUNT: "mounted"
|
|
702
|
+
}
|
|
703
|
+
});
|
|
704
|
+
React.useEffect(() => {
|
|
705
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
706
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
707
|
+
}, [state]);
|
|
708
|
+
useLayoutEffect2(() => {
|
|
709
|
+
const styles = stylesRef.current;
|
|
710
|
+
const wasPresent = prevPresentRef.current;
|
|
711
|
+
const hasPresentChanged = wasPresent !== present;
|
|
712
|
+
if (hasPresentChanged) {
|
|
713
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
714
|
+
const currentAnimationName = getAnimationName(styles);
|
|
715
|
+
if (present) {
|
|
716
|
+
send("MOUNT");
|
|
717
|
+
} else if (currentAnimationName === "none" || (styles == null ? void 0 : styles.display) === "none") {
|
|
718
|
+
send("UNMOUNT");
|
|
719
|
+
} else {
|
|
720
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
721
|
+
if (wasPresent && isAnimating) {
|
|
722
|
+
send("ANIMATION_OUT");
|
|
723
|
+
} else {
|
|
724
|
+
send("UNMOUNT");
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
prevPresentRef.current = present;
|
|
728
|
+
}
|
|
729
|
+
}, [present, send]);
|
|
730
|
+
useLayoutEffect2(() => {
|
|
731
|
+
if (node) {
|
|
732
|
+
let timeoutId;
|
|
733
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
734
|
+
const handleAnimationEnd = (event) => {
|
|
735
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
736
|
+
const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
|
|
737
|
+
if (event.target === node && isCurrentAnimation) {
|
|
738
|
+
send("ANIMATION_END");
|
|
739
|
+
if (!prevPresentRef.current) {
|
|
740
|
+
const currentFillMode = node.style.animationFillMode;
|
|
741
|
+
node.style.animationFillMode = "forwards";
|
|
742
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
743
|
+
if (node.style.animationFillMode === "forwards") {
|
|
744
|
+
node.style.animationFillMode = currentFillMode;
|
|
745
|
+
}
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
};
|
|
750
|
+
const handleAnimationStart = (event) => {
|
|
751
|
+
if (event.target === node) {
|
|
752
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
756
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
757
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
758
|
+
return () => {
|
|
759
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
760
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
761
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
762
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
763
|
+
};
|
|
764
|
+
} else {
|
|
765
|
+
send("ANIMATION_END");
|
|
766
|
+
}
|
|
767
|
+
}, [node, send]);
|
|
166
768
|
return {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
769
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
770
|
+
ref: React.useCallback((node2) => {
|
|
771
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
772
|
+
setNode(node2);
|
|
773
|
+
}, [])
|
|
171
774
|
};
|
|
172
775
|
}
|
|
776
|
+
function getAnimationName(styles) {
|
|
777
|
+
return (styles == null ? void 0 : styles.animationName) || "none";
|
|
778
|
+
}
|
|
779
|
+
function getElementRef(element) {
|
|
780
|
+
var _a, _b;
|
|
781
|
+
let getter = (_a = Object.getOwnPropertyDescriptor(element.props, "ref")) == null ? void 0 : _a.get;
|
|
782
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
783
|
+
if (mayWarn) {
|
|
784
|
+
return element.ref;
|
|
785
|
+
}
|
|
786
|
+
getter = (_b = Object.getOwnPropertyDescriptor(element, "ref")) == null ? void 0 : _b.get;
|
|
787
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
788
|
+
if (mayWarn) {
|
|
789
|
+
return element.props.ref;
|
|
790
|
+
}
|
|
791
|
+
return element.props.ref || element.ref;
|
|
792
|
+
}
|
|
793
|
+
var useInsertionEffect = React[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
794
|
+
function useControllableState({
|
|
795
|
+
prop,
|
|
796
|
+
defaultProp,
|
|
797
|
+
onChange = () => {
|
|
798
|
+
},
|
|
799
|
+
caller
|
|
800
|
+
}) {
|
|
801
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
802
|
+
defaultProp,
|
|
803
|
+
onChange
|
|
804
|
+
});
|
|
805
|
+
const isControlled = prop !== void 0;
|
|
806
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
807
|
+
{
|
|
808
|
+
const isControlledRef = React.useRef(prop !== void 0);
|
|
809
|
+
React.useEffect(() => {
|
|
810
|
+
const wasControlled = isControlledRef.current;
|
|
811
|
+
if (wasControlled !== isControlled) {
|
|
812
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
813
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
814
|
+
console.warn(
|
|
815
|
+
`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
isControlledRef.current = isControlled;
|
|
819
|
+
}, [isControlled, caller]);
|
|
820
|
+
}
|
|
821
|
+
const setValue = React.useCallback(
|
|
822
|
+
(nextValue) => {
|
|
823
|
+
var _a;
|
|
824
|
+
if (isControlled) {
|
|
825
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
826
|
+
if (value2 !== prop) {
|
|
827
|
+
(_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, value2);
|
|
828
|
+
}
|
|
829
|
+
} else {
|
|
830
|
+
setUncontrolledProp(nextValue);
|
|
831
|
+
}
|
|
832
|
+
},
|
|
833
|
+
[isControlled, prop, setUncontrolledProp, onChangeRef]
|
|
834
|
+
);
|
|
835
|
+
return [value, setValue];
|
|
836
|
+
}
|
|
837
|
+
function useUncontrolledState({
|
|
838
|
+
defaultProp,
|
|
839
|
+
onChange
|
|
840
|
+
}) {
|
|
841
|
+
const [value, setValue] = React.useState(defaultProp);
|
|
842
|
+
const prevValueRef = React.useRef(value);
|
|
843
|
+
const onChangeRef = React.useRef(onChange);
|
|
844
|
+
useInsertionEffect(() => {
|
|
845
|
+
onChangeRef.current = onChange;
|
|
846
|
+
}, [onChange]);
|
|
847
|
+
React.useEffect(() => {
|
|
848
|
+
var _a;
|
|
849
|
+
if (prevValueRef.current !== value) {
|
|
850
|
+
(_a = onChangeRef.current) == null ? void 0 : _a.call(onChangeRef, value);
|
|
851
|
+
prevValueRef.current = value;
|
|
852
|
+
}
|
|
853
|
+
}, [value, prevValueRef]);
|
|
854
|
+
return [value, setValue, onChangeRef];
|
|
855
|
+
}
|
|
856
|
+
function isFunction(value) {
|
|
857
|
+
return typeof value === "function";
|
|
858
|
+
}
|
|
173
859
|
var useReactId = React[" useId ".trim().toString()] || (() => void 0);
|
|
174
860
|
var count$1 = 0;
|
|
175
861
|
function useId(deterministicId) {
|
|
@@ -1263,7 +1949,7 @@ var DialogOverlay = React.forwardRef(
|
|
|
1263
1949
|
}
|
|
1264
1950
|
);
|
|
1265
1951
|
DialogOverlay.displayName = OVERLAY_NAME;
|
|
1266
|
-
var Slot
|
|
1952
|
+
var Slot = /* @__PURE__ */ createSlot("DialogOverlay.RemoveScroll");
|
|
1267
1953
|
var DialogOverlayImpl = React.forwardRef(
|
|
1268
1954
|
(props, forwardedRef) => {
|
|
1269
1955
|
const { __scopeDialog, ...overlayProps } = props;
|
|
@@ -1271,7 +1957,7 @@ var DialogOverlayImpl = React.forwardRef(
|
|
|
1271
1957
|
return (
|
|
1272
1958
|
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
1273
1959
|
// ie. when `Overlay` and `Content` are siblings
|
|
1274
|
-
/* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot
|
|
1960
|
+
/* @__PURE__ */ jsx(ReactRemoveScroll, { as: Slot, allowPinchZoom: true, shards: [context.contentRef], children: /* @__PURE__ */ jsx(
|
|
1275
1961
|
Primitive.div,
|
|
1276
1962
|
{
|
|
1277
1963
|
"data-state": getState(context.open),
|
|
@@ -1579,496 +2265,547 @@ function Dialog({
|
|
|
1579
2265
|
)
|
|
1580
2266
|
] }) });
|
|
1581
2267
|
}
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
2268
|
+
const lightDefaultTokens = {
|
|
2269
|
+
// Primary colors
|
|
2270
|
+
colorPrimary: "#CBFF01",
|
|
2271
|
+
colorPrimaryHover: "#daff2a",
|
|
2272
|
+
colorPrimaryActive: "#a5d900",
|
|
2273
|
+
colorPrimaryBg: "#fdffcd",
|
|
2274
|
+
// Secondary color
|
|
2275
|
+
colorSecondary: "#00FFA3",
|
|
2276
|
+
// Status colors
|
|
2277
|
+
colorSuccess: "#1FCBAF",
|
|
2278
|
+
colorWarning: "#FFB800",
|
|
2279
|
+
colorError: "#FF4D4D",
|
|
2280
|
+
// Background colors (V2)
|
|
2281
|
+
colorBgCanvas: "#FFFFFF",
|
|
2282
|
+
colorBgSurface: "#fafafb",
|
|
2283
|
+
colorBgSurfaceSubtle: "rgba(26, 29, 31, 0.04)",
|
|
2284
|
+
colorBgSurfaceStrong: "rgba(26, 29, 31, 0.06)",
|
|
2285
|
+
colorBgFloating: "#f4f4f4",
|
|
2286
|
+
colorBgMask: "rgba(26, 29, 31, 0.45)",
|
|
2287
|
+
colorBgInset: "#eaebeb",
|
|
2288
|
+
colorSuccessBg: "#1fcbaf1a",
|
|
2289
|
+
colorWarningBg: "#ffb8001a",
|
|
2290
|
+
colorErrorBg: "#ff4d4d1a",
|
|
2291
|
+
colorSecondaryBg: "#00ffa31a",
|
|
2292
|
+
// Text colors
|
|
2293
|
+
colorText: "#1A1D1F",
|
|
2294
|
+
colorTextSecondary: "rgba(26, 29, 31, 0.72)",
|
|
2295
|
+
colorTextTertiary: "rgba(26, 29, 31, 0.6)",
|
|
2296
|
+
colorTextDisabled: "rgba(26, 29, 31, 0.4)",
|
|
2297
|
+
colorLink: "#58AFFF",
|
|
2298
|
+
colorTextOnPrimary: "#000000",
|
|
2299
|
+
// Border colors
|
|
2300
|
+
colorBorder: "rgba(26, 29, 31, 0.1)",
|
|
2301
|
+
colorBorderSecondary: "rgba(26, 29, 31, 0.06)",
|
|
2302
|
+
// Border radius
|
|
2303
|
+
borderRadius: 8,
|
|
2304
|
+
borderRadiusSm: 4,
|
|
2305
|
+
borderRadiusLg: 12,
|
|
2306
|
+
// Font
|
|
2307
|
+
fontSize: 14,
|
|
2308
|
+
fontSizeSm: 12,
|
|
2309
|
+
fontSizeLg: 16,
|
|
2310
|
+
fontSizeXl: 18,
|
|
2311
|
+
fontSizeXxl: 22,
|
|
2312
|
+
fontSizeXxxl: 24,
|
|
2313
|
+
// Spacing
|
|
2314
|
+
spacing: 8,
|
|
2315
|
+
spacingXs: 4,
|
|
2316
|
+
spacingSm: 8,
|
|
2317
|
+
spacingMd: 16,
|
|
2318
|
+
spacingLg: 24,
|
|
2319
|
+
spacingXl: 32
|
|
2320
|
+
};
|
|
2321
|
+
const darkDefaultTokens = {
|
|
2322
|
+
// Primary colors
|
|
2323
|
+
colorPrimary: "#CBFF01",
|
|
2324
|
+
colorPrimaryHover: "#daff2a",
|
|
2325
|
+
colorPrimaryActive: "#a5d900",
|
|
2326
|
+
colorPrimaryBg: "#1e2600",
|
|
2327
|
+
// Secondary color
|
|
2328
|
+
colorSecondary: "#00FFA3",
|
|
2329
|
+
// Status colors
|
|
2330
|
+
colorSuccess: "#1FCBAF",
|
|
2331
|
+
colorWarning: "#FFB800",
|
|
2332
|
+
colorError: "#FF4D4D",
|
|
2333
|
+
// Background colors (V2)
|
|
2334
|
+
colorBgCanvas: "#1A1D1F",
|
|
2335
|
+
colorBgSurface: "#282b2c",
|
|
2336
|
+
colorBgSurfaceSubtle: "rgba(255, 255, 255, 0.04)",
|
|
2337
|
+
colorBgSurfaceStrong: "rgba(255, 255, 255, 0.12)",
|
|
2338
|
+
colorBgFloating: "#313435",
|
|
2339
|
+
colorBgMask: "rgba(26, 29, 31, 0.6)",
|
|
2340
|
+
colorBgInset: "#3a3d3e",
|
|
2341
|
+
colorSuccessBg: "#1fcbaf26",
|
|
2342
|
+
colorWarningBg: "#ffb80026",
|
|
2343
|
+
colorErrorBg: "#ff4d4d26",
|
|
2344
|
+
colorSecondaryBg: "#00ffa326",
|
|
2345
|
+
// Text colors
|
|
2346
|
+
colorText: "#FFFFFF",
|
|
2347
|
+
colorTextSecondary: "rgba(255, 255, 255, 0.72)",
|
|
2348
|
+
colorTextTertiary: "rgba(255, 255, 255, 0.6)",
|
|
2349
|
+
colorTextDisabled: "rgba(255, 255, 255, 0.4)",
|
|
2350
|
+
colorLink: "#58AFFF",
|
|
2351
|
+
colorTextOnPrimary: "#000000",
|
|
2352
|
+
// Border colors
|
|
2353
|
+
colorBorder: "rgba(255, 255, 255, 0.1)",
|
|
2354
|
+
colorBorderSecondary: "rgba(255, 255, 255, 0.06)",
|
|
2355
|
+
// Border radius
|
|
2356
|
+
borderRadius: 8,
|
|
2357
|
+
borderRadiusSm: 4,
|
|
2358
|
+
borderRadiusLg: 12,
|
|
2359
|
+
// Font
|
|
2360
|
+
fontSize: 14,
|
|
2361
|
+
fontSizeSm: 12,
|
|
2362
|
+
fontSizeLg: 16,
|
|
2363
|
+
fontSizeXl: 18,
|
|
2364
|
+
fontSizeXxl: 22,
|
|
2365
|
+
fontSizeXxxl: 24,
|
|
2366
|
+
// Spacing
|
|
2367
|
+
spacing: 8,
|
|
2368
|
+
spacingXs: 4,
|
|
2369
|
+
spacingSm: 8,
|
|
2370
|
+
spacingMd: 16,
|
|
2371
|
+
spacingLg: 24,
|
|
2372
|
+
spacingXl: 32
|
|
2373
|
+
};
|
|
2374
|
+
const hueStep = 2;
|
|
2375
|
+
const saturationStep = 0.16;
|
|
2376
|
+
const saturationStep2 = 0.05;
|
|
2377
|
+
const brightnessStep1 = 0.05;
|
|
2378
|
+
const brightnessStep2 = 0.15;
|
|
2379
|
+
const lightColorCount = 5;
|
|
2380
|
+
const darkColorCount = 4;
|
|
2381
|
+
function hexToRgb(hex) {
|
|
2382
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
2383
|
+
if (!result || !result[1] || !result[2] || !result[3]) {
|
|
2384
|
+
return null;
|
|
2385
|
+
}
|
|
2386
|
+
return {
|
|
2387
|
+
r: parseInt(result[1], 16),
|
|
2388
|
+
g: parseInt(result[2], 16),
|
|
2389
|
+
b: parseInt(result[3], 16)
|
|
2390
|
+
};
|
|
1586
2391
|
}
|
|
1587
|
-
function
|
|
1588
|
-
|
|
2392
|
+
function rgbToHex(rgb) {
|
|
2393
|
+
const toHex = (n) => {
|
|
2394
|
+
const hex = Math.round(Math.max(0, Math.min(255, n))).toString(16);
|
|
2395
|
+
return hex.length === 1 ? "0" + hex : hex;
|
|
2396
|
+
};
|
|
2397
|
+
return "#" + toHex(rgb.r) + toHex(rgb.g) + toHex(rgb.b);
|
|
1589
2398
|
}
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
const
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
return child;
|
|
1608
|
-
}
|
|
1609
|
-
});
|
|
1610
|
-
return /* @__PURE__ */ jsx(SlotClone, { ...slotProps, ref: forwardedRef, children: React.isValidElement(newElement) ? React.cloneElement(newElement, void 0, newChildren) : null });
|
|
2399
|
+
function rgbToHsv(rgb) {
|
|
2400
|
+
const r = rgb.r / 255;
|
|
2401
|
+
const g = rgb.g / 255;
|
|
2402
|
+
const b = rgb.b / 255;
|
|
2403
|
+
const max = Math.max(r, g, b);
|
|
2404
|
+
const min = Math.min(r, g, b);
|
|
2405
|
+
const delta = max - min;
|
|
2406
|
+
let h = 0;
|
|
2407
|
+
const v = max;
|
|
2408
|
+
const s = max === 0 ? 0 : delta / max;
|
|
2409
|
+
if (delta !== 0) {
|
|
2410
|
+
if (max === r) {
|
|
2411
|
+
h = ((g - b) / delta + (g < b ? 6 : 0)) * 60;
|
|
2412
|
+
} else if (max === g) {
|
|
2413
|
+
h = ((b - r) / delta + 2) * 60;
|
|
2414
|
+
} else {
|
|
2415
|
+
h = ((r - g) / delta + 4) * 60;
|
|
1611
2416
|
}
|
|
1612
|
-
|
|
1613
|
-
}
|
|
1614
|
-
Slot2.displayName = `${ownerName}.Slot`;
|
|
1615
|
-
return Slot2;
|
|
2417
|
+
}
|
|
2418
|
+
return { h, s, v };
|
|
1616
2419
|
}
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
2420
|
+
function hsvToRgb(hsv) {
|
|
2421
|
+
const h = hsv.h / 60;
|
|
2422
|
+
const s = hsv.s;
|
|
2423
|
+
const v = hsv.v;
|
|
2424
|
+
const i = Math.floor(h) % 6;
|
|
2425
|
+
const f = h - Math.floor(h);
|
|
2426
|
+
const p = v * (1 - s);
|
|
2427
|
+
const q = v * (1 - f * s);
|
|
2428
|
+
const t = v * (1 - (1 - f) * s);
|
|
2429
|
+
let r = 0, g = 0, b = 0;
|
|
2430
|
+
switch (i) {
|
|
2431
|
+
case 0:
|
|
2432
|
+
r = v;
|
|
2433
|
+
g = t;
|
|
2434
|
+
b = p;
|
|
2435
|
+
break;
|
|
2436
|
+
case 1:
|
|
2437
|
+
r = q;
|
|
2438
|
+
g = v;
|
|
2439
|
+
b = p;
|
|
2440
|
+
break;
|
|
2441
|
+
case 2:
|
|
2442
|
+
r = p;
|
|
2443
|
+
g = v;
|
|
2444
|
+
b = t;
|
|
2445
|
+
break;
|
|
2446
|
+
case 3:
|
|
2447
|
+
r = p;
|
|
2448
|
+
g = q;
|
|
2449
|
+
b = v;
|
|
2450
|
+
break;
|
|
2451
|
+
case 4:
|
|
2452
|
+
r = t;
|
|
2453
|
+
g = p;
|
|
2454
|
+
b = v;
|
|
2455
|
+
break;
|
|
2456
|
+
case 5:
|
|
2457
|
+
r = v;
|
|
2458
|
+
g = p;
|
|
2459
|
+
b = q;
|
|
2460
|
+
break;
|
|
2461
|
+
}
|
|
2462
|
+
return {
|
|
2463
|
+
r: Math.round(r * 255),
|
|
2464
|
+
g: Math.round(g * 255),
|
|
2465
|
+
b: Math.round(b * 255)
|
|
2466
|
+
};
|
|
1637
2467
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
2468
|
+
function getHue(hsv, i, isLight) {
|
|
2469
|
+
let hue;
|
|
2470
|
+
if (hsv.h >= 60 && hsv.h <= 240) {
|
|
2471
|
+
hue = isLight ? hsv.h - hueStep * i : hsv.h + hueStep * i;
|
|
2472
|
+
} else {
|
|
2473
|
+
hue = isLight ? hsv.h + hueStep * i : hsv.h - hueStep * i;
|
|
2474
|
+
}
|
|
2475
|
+
if (hue < 0) {
|
|
2476
|
+
hue += 360;
|
|
2477
|
+
} else if (hue >= 360) {
|
|
2478
|
+
hue -= 360;
|
|
2479
|
+
}
|
|
2480
|
+
return hue;
|
|
1641
2481
|
}
|
|
1642
|
-
function
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
const slotPropValue = slotProps[propName];
|
|
1646
|
-
const childPropValue = childProps[propName];
|
|
1647
|
-
const isHandler = /^on[A-Z]/.test(propName);
|
|
1648
|
-
if (isHandler) {
|
|
1649
|
-
if (slotPropValue && childPropValue) {
|
|
1650
|
-
overrideProps[propName] = (...args) => {
|
|
1651
|
-
const result = childPropValue(...args);
|
|
1652
|
-
slotPropValue(...args);
|
|
1653
|
-
return result;
|
|
1654
|
-
};
|
|
1655
|
-
} else if (slotPropValue) {
|
|
1656
|
-
overrideProps[propName] = slotPropValue;
|
|
1657
|
-
}
|
|
1658
|
-
} else if (propName === "style") {
|
|
1659
|
-
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
1660
|
-
} else if (propName === "className") {
|
|
1661
|
-
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
1662
|
-
}
|
|
2482
|
+
function getSaturation(hsv, i, isLight) {
|
|
2483
|
+
if (hsv.s === 0) {
|
|
2484
|
+
return hsv.s;
|
|
1663
2485
|
}
|
|
1664
|
-
|
|
2486
|
+
let saturation;
|
|
2487
|
+
if (isLight) {
|
|
2488
|
+
saturation = hsv.s - saturationStep * i;
|
|
2489
|
+
} else {
|
|
2490
|
+
saturation = hsv.s + saturationStep2 * i;
|
|
2491
|
+
}
|
|
2492
|
+
if (saturation < 0.06) {
|
|
2493
|
+
saturation = 0.06;
|
|
2494
|
+
}
|
|
2495
|
+
if (saturation > 1) {
|
|
2496
|
+
saturation = 1;
|
|
2497
|
+
}
|
|
2498
|
+
return saturation;
|
|
1665
2499
|
}
|
|
1666
|
-
function
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
2500
|
+
function getValue(hsv, i, isLight) {
|
|
2501
|
+
let value;
|
|
2502
|
+
if (isLight) {
|
|
2503
|
+
value = hsv.v + brightnessStep1 * i;
|
|
2504
|
+
} else {
|
|
2505
|
+
value = hsv.v - brightnessStep2 * i;
|
|
1672
2506
|
}
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
if (mayWarn) {
|
|
1676
|
-
return element.props.ref;
|
|
2507
|
+
if (value < 0) {
|
|
2508
|
+
value = 0;
|
|
1677
2509
|
}
|
|
1678
|
-
|
|
2510
|
+
if (value > 1) {
|
|
2511
|
+
value = 1;
|
|
2512
|
+
}
|
|
2513
|
+
return value;
|
|
1679
2514
|
}
|
|
1680
|
-
|
|
1681
|
-
(
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
children,
|
|
1693
|
-
...props
|
|
1694
|
-
}, ref) => {
|
|
1695
|
-
const Comp = asChild ? Slot : "button";
|
|
1696
|
-
const actualIconPosition = iconPosition || (leftIcon ? "left" : rightIcon ? "right" : void 0);
|
|
1697
|
-
const isIconOnly = actualIconPosition === "only" || !children && (leftIcon || rightIcon);
|
|
1698
|
-
const baseStyles = {
|
|
1699
|
-
display: "inline-flex",
|
|
1700
|
-
alignItems: "center",
|
|
1701
|
-
justifyContent: "center",
|
|
1702
|
-
gap: "var(--taskon-spacing-xs)",
|
|
1703
|
-
fontFamily: "inherit",
|
|
1704
|
-
fontWeight: 500,
|
|
1705
|
-
lineHeight: 1.5,
|
|
1706
|
-
border: "none",
|
|
1707
|
-
outline: "none",
|
|
1708
|
-
cursor: disabled || loading ? "not-allowed" : "pointer",
|
|
1709
|
-
transition: "all 0.2s ease-in-out",
|
|
1710
|
-
position: "relative",
|
|
1711
|
-
userSelect: "none",
|
|
1712
|
-
whiteSpace: "nowrap",
|
|
1713
|
-
opacity: disabled ? 0.5 : 1,
|
|
1714
|
-
...style
|
|
1715
|
-
};
|
|
1716
|
-
const sizeStyles = {
|
|
1717
|
-
small: {
|
|
1718
|
-
fontSize: "var(--taskon-font-size-sm)",
|
|
1719
|
-
padding: isIconOnly ? "var(--taskon-spacing-xs)" : "var(--taskon-spacing-xs) var(--taskon-spacing-sm)",
|
|
1720
|
-
borderRadius: "var(--taskon-border-radius-sm)",
|
|
1721
|
-
minWidth: isIconOnly ? "24px" : "64px",
|
|
1722
|
-
height: "24px"
|
|
1723
|
-
},
|
|
1724
|
-
medium: {
|
|
1725
|
-
fontSize: "var(--taskon-font-size)",
|
|
1726
|
-
padding: isIconOnly ? "var(--taskon-spacing-xs)" : "var(--taskon-spacing-xs) var(--taskon-spacing-md)",
|
|
1727
|
-
borderRadius: "var(--taskon-border-radius)",
|
|
1728
|
-
minWidth: isIconOnly ? "32px" : "80px",
|
|
1729
|
-
height: "32px"
|
|
1730
|
-
},
|
|
1731
|
-
large: {
|
|
1732
|
-
fontSize: "var(--taskon-font-size-lg)",
|
|
1733
|
-
padding: isIconOnly ? "var(--taskon-spacing-sm)" : "var(--taskon-spacing-sm) var(--taskon-spacing-lg)",
|
|
1734
|
-
borderRadius: "var(--taskon-border-radius)",
|
|
1735
|
-
minWidth: isIconOnly ? "40px" : "96px",
|
|
1736
|
-
height: "40px"
|
|
1737
|
-
}
|
|
1738
|
-
};
|
|
1739
|
-
const variantStyles = {
|
|
1740
|
-
primary: {
|
|
1741
|
-
backgroundColor: "var(--taskon-color-primary)",
|
|
1742
|
-
color: "var(--taskon-color-text-on-primary)"
|
|
1743
|
-
},
|
|
1744
|
-
secondary: {
|
|
1745
|
-
backgroundColor: "var(--taskon-color-secondary)",
|
|
1746
|
-
color: "var(--taskon-color-text-on-primary)"
|
|
1747
|
-
},
|
|
1748
|
-
outline: {
|
|
1749
|
-
backgroundColor: "transparent",
|
|
1750
|
-
color: "var(--taskon-color-text)",
|
|
1751
|
-
border: "1px solid var(--taskon-color-border)"
|
|
1752
|
-
},
|
|
1753
|
-
ghost: {
|
|
1754
|
-
backgroundColor: "transparent",
|
|
1755
|
-
color: "var(--taskon-color-text)"
|
|
1756
|
-
},
|
|
1757
|
-
danger: {
|
|
1758
|
-
backgroundColor: "var(--taskon-color-error)",
|
|
1759
|
-
color: "var(--taskon-color-text-on-primary)"
|
|
1760
|
-
}
|
|
1761
|
-
};
|
|
1762
|
-
const hoverStyles = {
|
|
1763
|
-
primary: "hover:bg-[var(--taskon-color-primary-hover)] active:bg-[var(--taskon-color-primary-active)]",
|
|
1764
|
-
secondary: "hover:opacity-90 active:opacity-80",
|
|
1765
|
-
outline: "hover:bg-[var(--taskon-color-bg-surface-strong)] active:bg-[var(--taskon-color-bg-surface-strong)]",
|
|
1766
|
-
ghost: "hover:bg-[var(--taskon-color-bg-surface-strong)] active:bg-[var(--taskon-color-bg-surface-strong)]",
|
|
1767
|
-
danger: "hover:opacity-90 active:opacity-80"
|
|
2515
|
+
function generatePalette(primaryColor) {
|
|
2516
|
+
const rgb = hexToRgb(primaryColor);
|
|
2517
|
+
if (!rgb) {
|
|
2518
|
+
return Array(10).fill(primaryColor);
|
|
2519
|
+
}
|
|
2520
|
+
const hsv = rgbToHsv(rgb);
|
|
2521
|
+
const palette = [];
|
|
2522
|
+
for (let i = lightColorCount; i > 0; i--) {
|
|
2523
|
+
const newHsv = {
|
|
2524
|
+
h: getHue(hsv, i, true),
|
|
2525
|
+
s: getSaturation(hsv, i, true),
|
|
2526
|
+
v: getValue(hsv, i, true)
|
|
1768
2527
|
};
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
2528
|
+
palette.push(rgbToHex(hsvToRgb(newHsv)));
|
|
2529
|
+
}
|
|
2530
|
+
palette.push(primaryColor);
|
|
2531
|
+
for (let i = 1; i <= darkColorCount; i++) {
|
|
2532
|
+
const newHsv = {
|
|
2533
|
+
h: getHue(hsv, i, false),
|
|
2534
|
+
s: getSaturation(hsv, i, false),
|
|
2535
|
+
v: getValue(hsv, i, false)
|
|
1773
2536
|
};
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
2537
|
+
palette.push(rgbToHex(hsvToRgb(newHsv)));
|
|
2538
|
+
}
|
|
2539
|
+
return palette;
|
|
2540
|
+
}
|
|
2541
|
+
function mixColors(color1, color2, weight) {
|
|
2542
|
+
const rgb1 = hexToRgb(color1);
|
|
2543
|
+
const rgb2 = hexToRgb(color2);
|
|
2544
|
+
if (!rgb1 || !rgb2) return color1;
|
|
2545
|
+
return rgbToHex({
|
|
2546
|
+
r: rgb1.r + (rgb2.r - rgb1.r) * weight,
|
|
2547
|
+
g: rgb1.g + (rgb2.g - rgb1.g) * weight,
|
|
2548
|
+
b: rgb1.b + (rgb2.b - rgb1.b) * weight
|
|
2549
|
+
});
|
|
2550
|
+
}
|
|
2551
|
+
function withAlpha(color, alpha) {
|
|
2552
|
+
const rgb = hexToRgb(color);
|
|
2553
|
+
if (!rgb) return color;
|
|
2554
|
+
return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
|
|
2555
|
+
}
|
|
2556
|
+
function deriveTokens(seed, mode) {
|
|
2557
|
+
const derived = {};
|
|
2558
|
+
const isLight = mode === "light";
|
|
2559
|
+
if (seed.colorPrimary) {
|
|
2560
|
+
const palette = generatePalette(seed.colorPrimary);
|
|
2561
|
+
derived.colorPrimary = seed.colorPrimary;
|
|
2562
|
+
if (isLight) {
|
|
2563
|
+
derived.colorPrimaryHover = palette[4];
|
|
2564
|
+
derived.colorPrimaryActive = palette[6];
|
|
2565
|
+
derived.colorPrimaryBg = palette[0];
|
|
2566
|
+
} else {
|
|
2567
|
+
derived.colorPrimaryHover = palette[4];
|
|
2568
|
+
derived.colorPrimaryActive = palette[6];
|
|
2569
|
+
derived.colorPrimaryBg = mixColors(seed.colorPrimary, "#000000", 0.85);
|
|
2570
|
+
}
|
|
2571
|
+
}
|
|
2572
|
+
if (seed.colorSecondary) derived.colorSecondary = seed.colorSecondary;
|
|
2573
|
+
if (seed.colorSuccess) derived.colorSuccess = seed.colorSuccess;
|
|
2574
|
+
if (seed.colorWarning) derived.colorWarning = seed.colorWarning;
|
|
2575
|
+
if (seed.colorError) derived.colorError = seed.colorError;
|
|
2576
|
+
if (seed.colorLink) derived.colorLink = seed.colorLink;
|
|
2577
|
+
if (seed.colorText) derived.colorText = seed.colorText;
|
|
2578
|
+
if (seed.colorTextOnPrimary) {
|
|
2579
|
+
derived.colorTextOnPrimary = seed.colorTextOnPrimary;
|
|
2580
|
+
}
|
|
2581
|
+
if (seed.colorText) {
|
|
2582
|
+
derived.colorTextSecondary = withAlpha(seed.colorText, 0.72);
|
|
2583
|
+
derived.colorTextTertiary = withAlpha(seed.colorText, 0.6);
|
|
2584
|
+
derived.colorTextDisabled = withAlpha(seed.colorText, 0.4);
|
|
2585
|
+
derived.colorBorder = withAlpha(seed.colorText, 0.1);
|
|
2586
|
+
derived.colorBorderSecondary = withAlpha(seed.colorText, 0.06);
|
|
2587
|
+
}
|
|
2588
|
+
if (seed.colorBgBase) {
|
|
2589
|
+
derived.colorBgCanvas = seed.colorBgBase;
|
|
2590
|
+
if (seed.colorText) {
|
|
2591
|
+
derived.colorBgSurface = mixColors(
|
|
2592
|
+
seed.colorBgBase,
|
|
2593
|
+
seed.colorText,
|
|
2594
|
+
0.06
|
|
1790
2595
|
);
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
style: mergedStyle,
|
|
1810
|
-
...props,
|
|
1811
|
-
children: [
|
|
1812
|
-
loading && renderLoadingIndicator(),
|
|
1813
|
-
!loading && leftIcon && actualIconPosition === "left" && /* @__PURE__ */ jsx("span", { style: { display: "inline-flex" }, children: leftIcon }),
|
|
1814
|
-
!isIconOnly && children,
|
|
1815
|
-
!loading && rightIcon && actualIconPosition === "right" && /* @__PURE__ */ jsx("span", { style: { display: "inline-flex" }, children: rightIcon })
|
|
1816
|
-
]
|
|
1817
|
-
}
|
|
1818
|
-
)
|
|
1819
|
-
] });
|
|
2596
|
+
derived.colorBgSurfaceSubtle = withAlpha(seed.colorText, 0.04);
|
|
2597
|
+
derived.colorBgSurfaceStrong = withAlpha(seed.colorText, 0.12);
|
|
2598
|
+
derived.colorBgFloating = mixColors(
|
|
2599
|
+
seed.colorBgBase,
|
|
2600
|
+
seed.colorText,
|
|
2601
|
+
0.1
|
|
2602
|
+
);
|
|
2603
|
+
derived.colorBgInset = mixColors(
|
|
2604
|
+
seed.colorBgBase,
|
|
2605
|
+
seed.colorText,
|
|
2606
|
+
0.14
|
|
2607
|
+
);
|
|
2608
|
+
derived.colorBgMask = isLight ? withAlpha(seed.colorText, 0.45) : withAlpha(seed.colorBgBase, 0.6);
|
|
2609
|
+
} else {
|
|
2610
|
+
derived.colorBgSurface = seed.colorBgBase;
|
|
2611
|
+
derived.colorBgFloating = seed.colorBgBase;
|
|
2612
|
+
derived.colorBgInset = seed.colorBgBase;
|
|
2613
|
+
}
|
|
1820
2614
|
}
|
|
1821
|
-
)
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
2615
|
+
if (seed.colorSecondary) {
|
|
2616
|
+
derived.colorSecondaryBg = withAlpha(seed.colorSecondary, 0.15);
|
|
2617
|
+
}
|
|
2618
|
+
if (seed.colorSuccess) {
|
|
2619
|
+
derived.colorSuccessBg = withAlpha(seed.colorSuccess, 0.15);
|
|
2620
|
+
}
|
|
2621
|
+
if (seed.colorWarning) {
|
|
2622
|
+
derived.colorWarningBg = withAlpha(seed.colorWarning, 0.15);
|
|
2623
|
+
}
|
|
2624
|
+
if (seed.colorError) {
|
|
2625
|
+
derived.colorErrorBg = withAlpha(seed.colorError, 0.15);
|
|
2626
|
+
}
|
|
2627
|
+
if (seed.borderRadius !== void 0) {
|
|
2628
|
+
derived.borderRadius = seed.borderRadius;
|
|
2629
|
+
derived.borderRadiusSm = Math.max(0, seed.borderRadius - 4);
|
|
2630
|
+
derived.borderRadiusLg = seed.borderRadius + 4;
|
|
2631
|
+
}
|
|
2632
|
+
if (seed.fontSize !== void 0) {
|
|
2633
|
+
derived.fontSize = seed.fontSize;
|
|
2634
|
+
derived.fontSizeSm = seed.fontSize - 2;
|
|
2635
|
+
derived.fontSizeLg = seed.fontSize + 2;
|
|
2636
|
+
derived.fontSizeXl = seed.fontSize + 4;
|
|
2637
|
+
derived.fontSizeXxl = seed.fontSize + 8;
|
|
2638
|
+
derived.fontSizeXxxl = seed.fontSize + 10;
|
|
2639
|
+
}
|
|
2640
|
+
if (seed.spacingBaseStep !== void 0 || seed.spacingChangeUnit !== void 0) {
|
|
2641
|
+
const base = Math.max(1, Number(seed.spacingBaseStep) || 1);
|
|
2642
|
+
const unit = Math.max(1, Number(seed.spacingChangeUnit) || 1);
|
|
2643
|
+
const spacingXs = base;
|
|
2644
|
+
const spacingSm = base + unit;
|
|
2645
|
+
const spacingMd = base + unit * 3;
|
|
2646
|
+
const spacingLg = base + unit * 5;
|
|
2647
|
+
const spacingXl = base + unit * 7;
|
|
2648
|
+
derived.spacing = spacingSm;
|
|
2649
|
+
derived.spacingXs = spacingXs;
|
|
2650
|
+
derived.spacingSm = spacingSm;
|
|
2651
|
+
derived.spacingMd = spacingMd;
|
|
2652
|
+
derived.spacingLg = spacingLg;
|
|
2653
|
+
derived.spacingXl = spacingXl;
|
|
2654
|
+
}
|
|
2655
|
+
return derived;
|
|
2656
|
+
}
|
|
2657
|
+
function mergeTokens(defaults, derived, override) {
|
|
2658
|
+
return {
|
|
2659
|
+
...defaults,
|
|
2660
|
+
...derived,
|
|
2661
|
+
...override
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
function getSystemThemeMode() {
|
|
2665
|
+
if (typeof window === "undefined") {
|
|
2666
|
+
return "light";
|
|
2667
|
+
}
|
|
2668
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
2669
|
+
}
|
|
2670
|
+
const defaultTheme = {
|
|
2671
|
+
mode: "dark",
|
|
2672
|
+
compact: false,
|
|
2673
|
+
tokens: darkDefaultTokens
|
|
1829
2674
|
};
|
|
1830
|
-
function
|
|
1831
|
-
return
|
|
1832
|
-
"svg",
|
|
1833
|
-
{
|
|
1834
|
-
className: "taskon-pagination-icon",
|
|
1835
|
-
viewBox: "0 0 24 24",
|
|
1836
|
-
fill: "none",
|
|
1837
|
-
stroke: "currentColor",
|
|
1838
|
-
strokeWidth: "2",
|
|
1839
|
-
strokeLinecap: "round",
|
|
1840
|
-
strokeLinejoin: "round",
|
|
1841
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "15 18 9 12 15 6" })
|
|
1842
|
-
}
|
|
1843
|
-
);
|
|
2675
|
+
function toKebabCase(str) {
|
|
2676
|
+
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1844
2677
|
}
|
|
1845
|
-
function
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
{
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
strokeWidth: "2",
|
|
1854
|
-
strokeLinecap: "round",
|
|
1855
|
-
strokeLinejoin: "round",
|
|
1856
|
-
children: /* @__PURE__ */ jsx("polyline", { points: "9 18 15 12 9 6" })
|
|
2678
|
+
function tokensToCssVariables(tokens) {
|
|
2679
|
+
const cssVars = {};
|
|
2680
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
2681
|
+
const cssVarName = `--taskon-${toKebabCase(key)}`;
|
|
2682
|
+
if (typeof value === "number") {
|
|
2683
|
+
cssVars[cssVarName] = `${value}px`;
|
|
2684
|
+
} else {
|
|
2685
|
+
cssVars[cssVarName] = value;
|
|
1857
2686
|
}
|
|
1858
|
-
|
|
2687
|
+
}
|
|
2688
|
+
return cssVars;
|
|
1859
2689
|
}
|
|
1860
|
-
function
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
hasPrevious,
|
|
1864
|
-
hasNext,
|
|
1865
|
-
onPrevious,
|
|
1866
|
-
onNext,
|
|
1867
|
-
messages = defaultPaginationMessages,
|
|
1868
|
-
className = "",
|
|
1869
|
-
showRange,
|
|
1870
|
-
showArrows = true,
|
|
1871
|
-
showButtonText = false,
|
|
1872
|
-
// 默认不显示按钮文字,只显示箭头图标
|
|
1873
|
-
size = "medium"
|
|
1874
|
-
}) {
|
|
1875
|
-
if (totalPages <= 1) {
|
|
1876
|
-
return null;
|
|
2690
|
+
function resolveTheme(config, systemMode) {
|
|
2691
|
+
if (!config) {
|
|
2692
|
+
return defaultTheme;
|
|
1877
2693
|
}
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
className: "taskon-pagination-btn taskon-pagination-btn--prev",
|
|
1892
|
-
children: showButtonText && messages.previous
|
|
1893
|
-
}
|
|
1894
|
-
),
|
|
1895
|
-
/* @__PURE__ */ jsxs("span", { className: "taskon-pagination-info", children: [
|
|
1896
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-pagination-info-current", children: page + 1 }),
|
|
1897
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-pagination-info-separator", children: " / " }),
|
|
1898
|
-
/* @__PURE__ */ jsx("span", { className: "taskon-pagination-info-total", children: totalPages })
|
|
1899
|
-
] }),
|
|
1900
|
-
/* @__PURE__ */ jsx(
|
|
1901
|
-
Button,
|
|
1902
|
-
{
|
|
1903
|
-
variant: "ghost",
|
|
1904
|
-
size,
|
|
1905
|
-
disabled: !hasNext,
|
|
1906
|
-
onClick: onNext,
|
|
1907
|
-
"aria-label": messages.next,
|
|
1908
|
-
rightIcon: showArrows ? /* @__PURE__ */ jsx(ChevronRightIcon, {}) : void 0,
|
|
1909
|
-
className: "taskon-pagination-btn taskon-pagination-btn--next",
|
|
1910
|
-
children: showButtonText && messages.next
|
|
1911
|
-
}
|
|
1912
|
-
)
|
|
1913
|
-
] })
|
|
1914
|
-
] });
|
|
1915
|
-
}
|
|
1916
|
-
function Table({
|
|
1917
|
-
columns,
|
|
1918
|
-
data,
|
|
1919
|
-
rowConfig,
|
|
1920
|
-
loading = false,
|
|
1921
|
-
loadingText = "Loading...",
|
|
1922
|
-
empty,
|
|
1923
|
-
striped = false,
|
|
1924
|
-
compact = false,
|
|
1925
|
-
borderless = false,
|
|
1926
|
-
className = "",
|
|
1927
|
-
style
|
|
1928
|
-
}) {
|
|
1929
|
-
const tableClassName = [
|
|
1930
|
-
"taskon-table",
|
|
1931
|
-
striped && "taskon-table--striped",
|
|
1932
|
-
compact && "taskon-table--compact",
|
|
1933
|
-
borderless && "taskon-table--borderless"
|
|
1934
|
-
].filter(Boolean).join(" ");
|
|
1935
|
-
const getRowKey = (rowConfig == null ? void 0 : rowConfig.getRowKey) || ((_, index) => index);
|
|
1936
|
-
const getColumnStyle = (column) => {
|
|
1937
|
-
const style2 = {};
|
|
1938
|
-
if (column.width) {
|
|
1939
|
-
style2.width = typeof column.width === "number" ? `${column.width}px` : column.width;
|
|
1940
|
-
}
|
|
1941
|
-
if (column.minWidth) {
|
|
1942
|
-
style2.minWidth = typeof column.minWidth === "number" ? `${column.minWidth}px` : column.minWidth;
|
|
1943
|
-
}
|
|
1944
|
-
return style2;
|
|
1945
|
-
};
|
|
1946
|
-
const getAlignClassName = (align) => {
|
|
1947
|
-
if (!align || align === "left") return "";
|
|
1948
|
-
return `taskon-table__header--${align}`;
|
|
2694
|
+
let resolvedMode;
|
|
2695
|
+
if (config.mode === "auto") {
|
|
2696
|
+
resolvedMode = systemMode;
|
|
2697
|
+
} else if (config.mode) {
|
|
2698
|
+
resolvedMode = config.mode;
|
|
2699
|
+
} else {
|
|
2700
|
+
resolvedMode = "dark";
|
|
2701
|
+
}
|
|
2702
|
+
const defaultTokens = resolvedMode === "light" ? lightDefaultTokens : darkDefaultTokens;
|
|
2703
|
+
const modeConfig = resolvedMode === "light" ? config.light : config.dark;
|
|
2704
|
+
const mergedSeed = {
|
|
2705
|
+
...config.seed,
|
|
2706
|
+
...modeConfig == null ? void 0 : modeConfig.seed
|
|
1949
2707
|
};
|
|
1950
|
-
const
|
|
1951
|
-
|
|
1952
|
-
|
|
2708
|
+
const derivedTokens = deriveTokens(mergedSeed, resolvedMode);
|
|
2709
|
+
const mergedMap = {
|
|
2710
|
+
...config.map,
|
|
2711
|
+
...modeConfig == null ? void 0 : modeConfig.map
|
|
1953
2712
|
};
|
|
1954
|
-
const
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
children: column.title
|
|
1960
|
-
},
|
|
1961
|
-
column.key
|
|
1962
|
-
)) }) });
|
|
1963
|
-
const renderLoading = () => /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsxs("td", { colSpan: columns.length, className: "taskon-table__loading", children: [
|
|
1964
|
-
/* @__PURE__ */ jsx("div", { className: "taskon-table__loading-spinner" }),
|
|
1965
|
-
/* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: loadingText })
|
|
1966
|
-
] }) });
|
|
1967
|
-
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: [
|
|
1968
|
-
(empty == null ? void 0 : empty.icon) && /* @__PURE__ */ jsx("div", { className: "taskon-table__empty-icon", children: empty.icon }),
|
|
1969
|
-
(empty == null ? void 0 : empty.title) && /* @__PURE__ */ jsx("p", { className: "taskon-table__empty-title", children: empty.title }),
|
|
1970
|
-
(empty == null ? void 0 : empty.description) && /* @__PURE__ */ jsx("p", { className: "taskon-table__empty-desc", children: empty.description }),
|
|
1971
|
-
!(empty == null ? void 0 : empty.title) && !(empty == null ? void 0 : empty.description) && /* @__PURE__ */ jsx("p", { className: "taskon-table__empty-title", children: "No data" })
|
|
1972
|
-
] }) }) });
|
|
1973
|
-
const renderRows = () => data.map((row, rowIndex) => {
|
|
1974
|
-
var _a, _b, _c;
|
|
1975
|
-
const rowKey = getRowKey(row, rowIndex);
|
|
1976
|
-
const isHighlighted = ((_a = rowConfig == null ? void 0 : rowConfig.isHighlighted) == null ? void 0 : _a.call(rowConfig, row, rowIndex)) || false;
|
|
1977
|
-
const isDisabled = ((_b = rowConfig == null ? void 0 : rowConfig.isDisabled) == null ? void 0 : _b.call(rowConfig, row, rowIndex)) || false;
|
|
1978
|
-
const isClickable = !!(rowConfig == null ? void 0 : rowConfig.onRowClick);
|
|
1979
|
-
const customRowClassName = ((_c = rowConfig == null ? void 0 : rowConfig.rowClassName) == null ? void 0 : _c.call(rowConfig, row, rowIndex)) || "";
|
|
1980
|
-
const rowClassName = [
|
|
1981
|
-
"taskon-table__row",
|
|
1982
|
-
isHighlighted && "taskon-table__row--highlighted",
|
|
1983
|
-
isDisabled && "taskon-table__row--disabled",
|
|
1984
|
-
isClickable && "taskon-table__row--clickable",
|
|
1985
|
-
customRowClassName
|
|
1986
|
-
].filter(Boolean).join(" ");
|
|
1987
|
-
const handleRowClick = () => {
|
|
1988
|
-
var _a2;
|
|
1989
|
-
if (isClickable && !isDisabled) {
|
|
1990
|
-
(_a2 = rowConfig == null ? void 0 : rowConfig.onRowClick) == null ? void 0 : _a2.call(rowConfig, row, rowIndex);
|
|
1991
|
-
}
|
|
1992
|
-
};
|
|
1993
|
-
return /* @__PURE__ */ jsx("tr", { className: rowClassName, onClick: handleRowClick, children: columns.map((column) => {
|
|
1994
|
-
const value = row[column.key];
|
|
1995
|
-
const cellContent = column.render ? column.render(value, row, rowIndex) : value;
|
|
1996
|
-
const cellClassName = [
|
|
1997
|
-
"taskon-table__cell",
|
|
1998
|
-
getCellAlignClassName(column.align),
|
|
1999
|
-
column.ellipsis && "taskon-table__cell--ellipsis",
|
|
2000
|
-
column.cellClassName
|
|
2001
|
-
].filter(Boolean).join(" ");
|
|
2002
|
-
return /* @__PURE__ */ jsx("td", { className: cellClassName, style: getColumnStyle(column), children: cellContent }, column.key);
|
|
2003
|
-
}) }, rowKey);
|
|
2004
|
-
});
|
|
2005
|
-
const renderBody = () => {
|
|
2006
|
-
if (!data || data.length === 0) {
|
|
2007
|
-
if (loading) {
|
|
2008
|
-
return renderLoading();
|
|
2009
|
-
}
|
|
2010
|
-
return renderEmpty();
|
|
2011
|
-
}
|
|
2012
|
-
return renderRows();
|
|
2713
|
+
const finalTokens = mergeTokens(defaultTokens, derivedTokens, mergedMap);
|
|
2714
|
+
return {
|
|
2715
|
+
mode: resolvedMode,
|
|
2716
|
+
compact: config.compact ?? false,
|
|
2717
|
+
tokens: finalTokens
|
|
2013
2718
|
};
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
/* @__PURE__ */ jsx("tbody", { className: "taskon-table__body", children: renderBody() })
|
|
2018
|
-
] }),
|
|
2019
|
-
loading && data && data.length > 0 && /* @__PURE__ */ jsx("div", { className: "taskon-table__loading-overlay", children: /* @__PURE__ */ jsx("div", { className: "taskon-table__loading-spinner" }) })
|
|
2020
|
-
] });
|
|
2021
|
-
}
|
|
2022
|
-
function WidgetShell({
|
|
2023
|
-
widgetId,
|
|
2024
|
-
isConfigLoading,
|
|
2025
|
-
cloudTheme,
|
|
2026
|
-
themeMode,
|
|
2027
|
-
className,
|
|
2028
|
-
errorMessage,
|
|
2719
|
+
}
|
|
2720
|
+
function ThemeProvider({
|
|
2721
|
+
theme: themeConfig,
|
|
2029
2722
|
children
|
|
2030
2723
|
}) {
|
|
2031
|
-
const
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2724
|
+
const [portalContainer, setPortalContainer] = useState(
|
|
2725
|
+
null
|
|
2726
|
+
);
|
|
2727
|
+
const [systemMode, setSystemMode] = useState(
|
|
2728
|
+
() => getSystemThemeMode()
|
|
2729
|
+
);
|
|
2730
|
+
const effectiveMode = themeConfig == null ? void 0 : themeConfig.mode;
|
|
2731
|
+
useEffect(() => {
|
|
2732
|
+
if (effectiveMode !== "auto") {
|
|
2733
|
+
return;
|
|
2734
|
+
}
|
|
2735
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
2736
|
+
const handler = (e) => {
|
|
2737
|
+
setSystemMode(e.matches ? "dark" : "light");
|
|
2037
2738
|
};
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
]
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2739
|
+
mediaQuery.addEventListener("change", handler);
|
|
2740
|
+
return () => mediaQuery.removeEventListener("change", handler);
|
|
2741
|
+
}, [effectiveMode]);
|
|
2742
|
+
const resolvedTheme = useMemo(
|
|
2743
|
+
() => resolveTheme(themeConfig, systemMode),
|
|
2744
|
+
[themeConfig, systemMode]
|
|
2745
|
+
);
|
|
2746
|
+
const cssVariables = useMemo(
|
|
2747
|
+
() => tokensToCssVariables(resolvedTheme.tokens),
|
|
2748
|
+
[resolvedTheme.tokens]
|
|
2749
|
+
);
|
|
2750
|
+
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: resolvedTheme, children: /* @__PURE__ */ jsx(ThemePortalContainerContext.Provider, { value: portalContainer, children: /* @__PURE__ */ jsxs(
|
|
2751
|
+
"div",
|
|
2752
|
+
{
|
|
2753
|
+
style: cssVariables,
|
|
2754
|
+
"data-taskon-theme": resolvedTheme.mode,
|
|
2755
|
+
children: [
|
|
2756
|
+
/* @__PURE__ */ jsx(
|
|
2757
|
+
"div",
|
|
2758
|
+
{
|
|
2759
|
+
ref: setPortalContainer,
|
|
2760
|
+
"aria-hidden": "true",
|
|
2761
|
+
style: {
|
|
2762
|
+
position: "absolute",
|
|
2763
|
+
top: 0,
|
|
2764
|
+
left: 0,
|
|
2765
|
+
width: 0,
|
|
2766
|
+
height: 0
|
|
2767
|
+
}
|
|
2768
|
+
}
|
|
2769
|
+
),
|
|
2770
|
+
children
|
|
2771
|
+
]
|
|
2772
|
+
}
|
|
2773
|
+
) }) });
|
|
2059
2774
|
}
|
|
2060
2775
|
export {
|
|
2061
|
-
|
|
2776
|
+
useFocusGuards as A,
|
|
2777
|
+
Branch as B,
|
|
2778
|
+
DismissableLayer as C,
|
|
2062
2779
|
Dialog as D,
|
|
2780
|
+
useTaskOnPortalContainer as E,
|
|
2063
2781
|
FocusScope as F,
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2782
|
+
Primitive as P,
|
|
2783
|
+
Root$1 as R,
|
|
2784
|
+
ThemeProvider as T,
|
|
2785
|
+
useTaskOnTheme as a,
|
|
2786
|
+
useWidgetLocale as b,
|
|
2787
|
+
useTranslation as c,
|
|
2788
|
+
clearLocaleCache as d,
|
|
2789
|
+
createLocaleLoader as e,
|
|
2790
|
+
createT as f,
|
|
2791
|
+
isSupportedLocale as g,
|
|
2792
|
+
useTaskOnContext as h,
|
|
2793
|
+
interpolate as i,
|
|
2794
|
+
composeRefs as j,
|
|
2795
|
+
createContextScope as k,
|
|
2796
|
+
useComposedRefs as l,
|
|
2797
|
+
createSlot as m,
|
|
2798
|
+
useControllableState as n,
|
|
2799
|
+
Presence as o,
|
|
2800
|
+
preloadWidgetLocale as p,
|
|
2801
|
+
composeEventHandlers as q,
|
|
2802
|
+
useCallbackRef$1 as r,
|
|
2803
|
+
Portal$1 as s,
|
|
2804
|
+
dispatchDiscreteCustomEvent as t,
|
|
2805
|
+
useTaskOnAuth as u,
|
|
2806
|
+
useLayoutEffect2 as v,
|
|
2807
|
+
TaskOnContext as w,
|
|
2808
|
+
useId as x,
|
|
2809
|
+
hideOthers as y,
|
|
2810
|
+
ReactRemoveScroll as z
|
|
2074
2811
|
};
|