@theaiplatform/miniapp-sdk 0.0.1 → 0.0.2
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 +45 -1
- package/THIRD_PARTY_NOTICES.md +3 -1
- package/config-schema.json +543 -30
- package/dist/config.d.ts +4 -1
- package/dist/index.d.ts +103 -2
- package/dist/index.js +1 -0
- package/dist/mcp.d.ts +27 -0
- package/dist/mcp.js +4 -0
- package/dist/rspack/css-entry-loader.cjs +1 -1
- package/dist/rspack/html-loader.cjs +1 -1
- package/dist/rspack/index.js +133 -5
- package/dist/sdk.d.ts +84 -1
- package/dist/surface.d.ts +1 -1
- package/dist/ui/styles.css +67 -0
- package/dist/ui/tailwind.css +1 -0
- package/dist/ui/wasm.d.ts +660 -0
- package/dist/ui/wasm.js +2714 -0
- package/dist/ui.d.ts +160 -0
- package/dist/ui.js +200 -7
- package/dist/web.d.ts +84 -1
- package/examples/wasm-ui/Cargo.lock +248 -0
- package/examples/wasm-ui/Cargo.toml +18 -0
- package/examples/wasm-ui/README.md +19 -0
- package/examples/wasm-ui/src/lib.rs +190 -0
- package/package.json +17 -2
- package/ui-components.json +6 -1
package/dist/ui/wasm.js
ADDED
|
@@ -0,0 +1,2714 @@
|
|
|
1
|
+
import { flushSync } from "react-dom";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { Check, ChevronDown, ChevronUp, Circle, CircleHelp, Info, Plus, RefreshCw, Search, Settings, Trash2, X } from "lucide-react";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { clsx } from "clsx";
|
|
6
|
+
import { twMerge } from "tailwind-merge";
|
|
7
|
+
import { Slot as react_slot_Slot } from "@radix-ui/react-slot";
|
|
8
|
+
import "prism-react-renderer";
|
|
9
|
+
import { composeRefs } from "@radix-ui/react-compose-refs";
|
|
10
|
+
import { useCallback as external_react_useCallback, useEffect, useRef } from "react";
|
|
11
|
+
import "react-resizable-panels";
|
|
12
|
+
import "@radix-ui/react-scroll-area";
|
|
13
|
+
import { z } from "zod";
|
|
14
|
+
import * as __rspack_external_react from "react";
|
|
15
|
+
import * as __rspack_external__radix_ui_react_alert_dialog_df21c073 from "@radix-ui/react-alert-dialog";
|
|
16
|
+
import * as __rspack_external__radix_ui_react_avatar_44cfeec7 from "@radix-ui/react-avatar";
|
|
17
|
+
import * as __rspack_external__radix_ui_react_separator_c79cca86 from "@radix-ui/react-separator";
|
|
18
|
+
import * as __rspack_external__radix_ui_react_checkbox_76182ac8 from "@radix-ui/react-checkbox";
|
|
19
|
+
import * as __rspack_external__radix_ui_react_dialog_dabd8325 from "@radix-ui/react-dialog";
|
|
20
|
+
import * as __rspack_external__radix_ui_react_label_73c6aeea from "@radix-ui/react-label";
|
|
21
|
+
import * as __rspack_external__radix_ui_react_tooltip_b301f25d from "@radix-ui/react-tooltip";
|
|
22
|
+
import * as __rspack_external__radix_ui_react_progress_67feda0a from "@radix-ui/react-progress";
|
|
23
|
+
import * as __rspack_external__radix_ui_react_radio_group_295a43fb from "@radix-ui/react-radio-group";
|
|
24
|
+
import * as __rspack_external__radix_ui_react_select_4606f4d3 from "@radix-ui/react-select";
|
|
25
|
+
import * as __rspack_external__radix_ui_react_slider_302f41eb from "@radix-ui/react-slider";
|
|
26
|
+
import * as __rspack_external__radix_ui_react_tabs_62268d7a from "@radix-ui/react-tabs";
|
|
27
|
+
import * as __rspack_external__radix_ui_react_toggle_f6d72b6a from "@radix-ui/react-toggle";
|
|
28
|
+
import * as __rspack_external__radix_ui_react_toggle_group_1cb63752 from "@radix-ui/react-toggle-group";
|
|
29
|
+
function utils_cn(...inputs) {
|
|
30
|
+
return twMerge(clsx(inputs));
|
|
31
|
+
}
|
|
32
|
+
const headingVariants = cva('font-semibold', {
|
|
33
|
+
defaultVariants: {
|
|
34
|
+
level: 'h1'
|
|
35
|
+
},
|
|
36
|
+
variants: {
|
|
37
|
+
level: {
|
|
38
|
+
h1: 'text-4xl leading-11 font-bold tracking-[-0.025em]',
|
|
39
|
+
h2: 'text-3xl leading-11 font-bold tracking-[-0.025em]',
|
|
40
|
+
h3: 'text-2xl leading-8 font-semibold tracking-[-0.025em]',
|
|
41
|
+
h4: 'text-xl leading-7 font-semibold tracking-[-0.025em]',
|
|
42
|
+
h5: 'text-lg leading-7 font-semibold',
|
|
43
|
+
h6: 'text-base leading-6 font-semibold'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const headingSizeOverrides = {
|
|
48
|
+
sm: 'text-sm leading-tight font-semibold tracking-normal'
|
|
49
|
+
};
|
|
50
|
+
function H1({ asChild = false, className, ...props }) {
|
|
51
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
52
|
+
asChild: asChild,
|
|
53
|
+
className: className,
|
|
54
|
+
level: "h1",
|
|
55
|
+
...props
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function H2({ asChild = false, className, ...props }) {
|
|
59
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
60
|
+
asChild: asChild,
|
|
61
|
+
className: className,
|
|
62
|
+
level: "h2",
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function H3({ asChild = false, className, ...props }) {
|
|
67
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
68
|
+
asChild: asChild,
|
|
69
|
+
className: className,
|
|
70
|
+
level: "h3",
|
|
71
|
+
...props
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function H4({ asChild = false, className, ...props }) {
|
|
75
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
76
|
+
asChild: asChild,
|
|
77
|
+
className: className,
|
|
78
|
+
level: "h4",
|
|
79
|
+
...props
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const H5 = /*#__PURE__*/ __rspack_external_react.forwardRef(({ asChild = false, className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
83
|
+
ref: ref,
|
|
84
|
+
asChild: asChild,
|
|
85
|
+
className: className,
|
|
86
|
+
level: "h5",
|
|
87
|
+
...props
|
|
88
|
+
}));
|
|
89
|
+
H5.displayName = 'H5';
|
|
90
|
+
function H6({ asChild = false, className, ...props }) {
|
|
91
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
92
|
+
asChild: asChild,
|
|
93
|
+
className: className,
|
|
94
|
+
level: "h6",
|
|
95
|
+
...props
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
const Heading = /*#__PURE__*/ __rspack_external_react.forwardRef(({ asChild = false, className, level = 'h1', size, ...props }, ref)=>{
|
|
99
|
+
const Component = asChild ? react_slot_Slot : level ?? 'h1';
|
|
100
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Component, {
|
|
101
|
+
ref: ref,
|
|
102
|
+
className: utils_cn(headingVariants({
|
|
103
|
+
level
|
|
104
|
+
}), size && headingSizeOverrides[size], className),
|
|
105
|
+
...props
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
Heading.displayName = 'Heading';
|
|
109
|
+
const alertVariants = cva('relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground', {
|
|
110
|
+
variants: {
|
|
111
|
+
variant: {
|
|
112
|
+
default: 'bg-background text-foreground',
|
|
113
|
+
info: 'border-info/50 bg-info/10 text-info-accent-foreground [&>svg]:text-info',
|
|
114
|
+
destructive: 'border-destructive/50 bg-destructive/10 text-destructive [&>svg]:text-destructive',
|
|
115
|
+
warning: 'border-warning/50 bg-warning/10 text-warning-accent-foreground [&>svg]:text-warning',
|
|
116
|
+
success: 'border-success/50 bg-success/10 text-success-accent-foreground [&>svg]:text-success'
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
defaultVariants: {
|
|
120
|
+
variant: 'default'
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
function Alert({ className, variant, ref, ...props }) {
|
|
124
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
125
|
+
ref: ref,
|
|
126
|
+
role: "alert",
|
|
127
|
+
className: utils_cn(alertVariants({
|
|
128
|
+
variant
|
|
129
|
+
}), className),
|
|
130
|
+
...props
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
Alert.displayName = 'Alert';
|
|
134
|
+
const AlertTitle = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(Heading, {
|
|
135
|
+
ref: ref,
|
|
136
|
+
level: "h5",
|
|
137
|
+
className: utils_cn('mb-1 leading-none font-medium', className),
|
|
138
|
+
...props
|
|
139
|
+
}));
|
|
140
|
+
AlertTitle.displayName = 'AlertTitle';
|
|
141
|
+
function AlertDescription({ className, ref, ...props }) {
|
|
142
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
143
|
+
ref: ref,
|
|
144
|
+
className: utils_cn('text-sm [&_p]:leading-relaxed', className),
|
|
145
|
+
...props
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
AlertDescription.displayName = "AlertDescription";
|
|
149
|
+
const NativeViewOcclusionContext = /*#__PURE__*/ __rspack_external_react.createContext(null);
|
|
150
|
+
let nextClaimId = 0;
|
|
151
|
+
function native_view_occlusion_useNativeViewOcclusion({ enabled = true } = {}) {
|
|
152
|
+
const adapter = __rspack_external_react.useContext(NativeViewOcclusionContext);
|
|
153
|
+
const [element, setElement] = __rspack_external_react.useState(null);
|
|
154
|
+
const [ready, setReady] = __rspack_external_react.useState(!enabled || null === adapter);
|
|
155
|
+
const claimIdRef = __rspack_external_react.useRef(null);
|
|
156
|
+
if (null === claimIdRef.current) {
|
|
157
|
+
nextClaimId += 1;
|
|
158
|
+
claimIdRef.current = `native-view-occlusion-${nextClaimId}`;
|
|
159
|
+
}
|
|
160
|
+
const ref = __rspack_external_react.useCallback((node)=>{
|
|
161
|
+
setElement(node);
|
|
162
|
+
}, []);
|
|
163
|
+
__rspack_external_react.useEffect(()=>{
|
|
164
|
+
if (!enabled || null === adapter) return void setReady(true);
|
|
165
|
+
if (null === element) return void setReady(false);
|
|
166
|
+
setReady(false);
|
|
167
|
+
let cancelled = false;
|
|
168
|
+
let release = null;
|
|
169
|
+
const claimId = claimIdRef.current;
|
|
170
|
+
if (null === claimId) return;
|
|
171
|
+
const rafId = requestAnimationFrame(()=>{
|
|
172
|
+
Promise.resolve(adapter.acquire(element, claimId)).then((acquiredRelease)=>{
|
|
173
|
+
if (cancelled) return void acquiredRelease();
|
|
174
|
+
release = acquiredRelease;
|
|
175
|
+
setReady(true);
|
|
176
|
+
}, ()=>void 0);
|
|
177
|
+
});
|
|
178
|
+
return ()=>{
|
|
179
|
+
cancelled = true;
|
|
180
|
+
cancelAnimationFrame(rafId);
|
|
181
|
+
release?.();
|
|
182
|
+
};
|
|
183
|
+
}, [
|
|
184
|
+
adapter,
|
|
185
|
+
element,
|
|
186
|
+
enabled
|
|
187
|
+
]);
|
|
188
|
+
return {
|
|
189
|
+
ref,
|
|
190
|
+
ready
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const buttonVariants = cva('inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium outline-none transition-[box-shadow,background-color,border-color,color] duration-200 focus-visible:outline-none focus-visible:shadow-input-focus disabled:pointer-events-none disabled:opacity-50 cursor-pointer [&_svg]:pointer-events-none [&_svg:not([width])]:size-4 [&_svg]:shrink-0 [&_svg]:text-current', {
|
|
194
|
+
variants: {
|
|
195
|
+
variant: {
|
|
196
|
+
default: 'btn-primary-shine bg-primary text-primary-foreground shadow-(--shadow-button-primary) hover:bg-primary-hover active:bg-primary active:shadow-none',
|
|
197
|
+
destructive: 'bg-destructive text-destructive-foreground hover:bg-destructive-hover shadow-sm hover:shadow-md active:bg-destructive/90',
|
|
198
|
+
outline: 'shadow-(--shadow-button-outline) bg-background hover:shadow-(--shadow-button-outline-hover) hover:bg-accent hover:text-accent-foreground active:bg-accent/90',
|
|
199
|
+
secondary: 'bg-secondary text-secondary-foreground hover:bg-secondary-hover shadow-(--shadow-button-secondary) hover:shadow-(--shadow-button-secondary-hover) active:bg-secondary/90',
|
|
200
|
+
tertiary: 'bg-button-tertiary-default text-foreground hover:bg-button-tertiary-hover active:bg-button-tertiary-hover/90',
|
|
201
|
+
ghost: 'bg-button-borderless-default hover:bg-button-borderless-hover active:bg-button-borderless-hover',
|
|
202
|
+
link: 'text-primary underline-offset-4 hover:underline'
|
|
203
|
+
},
|
|
204
|
+
size: {
|
|
205
|
+
default: 'h-10 px-3 py-2.5 rounded-lg',
|
|
206
|
+
sm: 'h-9 px-3 rounded-lg',
|
|
207
|
+
compact: 'h-8 px-3 rounded-lg',
|
|
208
|
+
lg: 'h-11 px-8 rounded-lg',
|
|
209
|
+
icon: 'h-10 w-10 rounded-lg',
|
|
210
|
+
'icon-md': 'h-9 w-9 rounded-lg',
|
|
211
|
+
'icon-sm': 'h-8 w-8 rounded-lg',
|
|
212
|
+
'icon-xs': 'h-6 w-6 rounded-lg'
|
|
213
|
+
},
|
|
214
|
+
shape: {
|
|
215
|
+
default: '',
|
|
216
|
+
pill: 'rounded-full'
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
defaultVariants: {
|
|
220
|
+
variant: 'default',
|
|
221
|
+
size: 'default',
|
|
222
|
+
shape: 'default'
|
|
223
|
+
},
|
|
224
|
+
compoundVariants: [
|
|
225
|
+
{
|
|
226
|
+
variant: 'ghost',
|
|
227
|
+
size: [
|
|
228
|
+
'icon',
|
|
229
|
+
'icon-md'
|
|
230
|
+
],
|
|
231
|
+
className: 'text-foreground opacity-65 hover:opacity-100'
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
});
|
|
235
|
+
function button_Button({ className, variant, size, shape, asChild = false, ref, ...props }) {
|
|
236
|
+
const Comp = asChild ? react_slot_Slot : 'button';
|
|
237
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Comp, {
|
|
238
|
+
className: utils_cn(buttonVariants({
|
|
239
|
+
variant,
|
|
240
|
+
size,
|
|
241
|
+
shape
|
|
242
|
+
}), className),
|
|
243
|
+
ref: ref,
|
|
244
|
+
...props
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
button_Button.displayName = 'Button';
|
|
248
|
+
const DIALOG_FOOTER_ATTRIBUTE = 'data-dialog-footer';
|
|
249
|
+
const DIALOG_PRIMARY_ACTION_ATTRIBUTE = 'data-dialog-primary-action';
|
|
250
|
+
const DIALOG_CANCEL_ACTION_ATTRIBUTE = 'data-dialog-cancel-action';
|
|
251
|
+
const DIALOG_FIELD_SELECTOR = 'input:not([type="hidden"]):not([type="button"]):not([type="submit"]):not([type="reset"]),select,textarea,[contenteditable="true"],[role="textbox"]';
|
|
252
|
+
const DIALOG_PRIMARY_ACTION_SELECTOR = [
|
|
253
|
+
`[${DIALOG_PRIMARY_ACTION_ATTRIBUTE}]:not([${DIALOG_PRIMARY_ACTION_ATTRIBUTE}="false"])`
|
|
254
|
+
].join(',');
|
|
255
|
+
const DIALOG_SUBMIT_ACTION_SELECTOR = 'button[type="submit"],input[type="submit"]';
|
|
256
|
+
const DIALOG_FOOTER_ACTION_SELECTOR = 'button,a[href],input:not([type="hidden"]),select,textarea,[role="button"],[tabindex]:not([tabindex="-1"])';
|
|
257
|
+
function pickDialogDefaultFocusTarget({ footerActions, formFields, primaryActions, submitActions }) {
|
|
258
|
+
const firstFormField = formFields.find((candidate)=>!candidate.disabled);
|
|
259
|
+
if (firstFormField) return firstFormField.element;
|
|
260
|
+
if (primaryActions.length > 0) return primaryActions.find((candidate)=>!candidate.disabled)?.element ?? null;
|
|
261
|
+
if (submitActions.length > 0) return submitActions.find((candidate)=>!candidate.disabled)?.element ?? null;
|
|
262
|
+
const lastFooterAction = footerActions.at(-1);
|
|
263
|
+
if (!lastFooterAction || lastFooterAction.disabled || lastFooterAction.isCancel) return null;
|
|
264
|
+
return lastFooterAction.element;
|
|
265
|
+
}
|
|
266
|
+
function hasHiddenAncestor(element) {
|
|
267
|
+
let current = element;
|
|
268
|
+
while(current){
|
|
269
|
+
if (current.hidden || 'true' === current.getAttribute('aria-hidden')) return true;
|
|
270
|
+
current = current.parentElement;
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
function isElementVisible(element) {
|
|
275
|
+
if (hasHiddenAncestor(element)) return false;
|
|
276
|
+
const computedStyle = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
277
|
+
return computedStyle?.display !== 'none' && computedStyle?.visibility !== 'hidden' && computedStyle?.visibility !== 'collapse';
|
|
278
|
+
}
|
|
279
|
+
function isDisabledElement(element) {
|
|
280
|
+
return element.matches(':disabled') || 'true' === element.getAttribute('aria-disabled') || 'true' === element.getAttribute('data-disabled');
|
|
281
|
+
}
|
|
282
|
+
function toFocusCandidate(element) {
|
|
283
|
+
return {
|
|
284
|
+
disabled: isDisabledElement(element) || !isElementVisible(element),
|
|
285
|
+
element,
|
|
286
|
+
isCancel: element.matches(`[${DIALOG_CANCEL_ACTION_ATTRIBUTE}]`)
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function queryFocusCandidates(root, selector) {
|
|
290
|
+
return Array.from(root.querySelectorAll(selector)).map(toFocusCandidate);
|
|
291
|
+
}
|
|
292
|
+
function isHtmlElement(value) {
|
|
293
|
+
return "u" > typeof HTMLElement && value instanceof HTMLElement;
|
|
294
|
+
}
|
|
295
|
+
function getDialogDefaultFocusTarget(content) {
|
|
296
|
+
const footers = Array.from(content.querySelectorAll(`[${DIALOG_FOOTER_ATTRIBUTE}]`));
|
|
297
|
+
const lastFooter = footers.at(-1);
|
|
298
|
+
return pickDialogDefaultFocusTarget({
|
|
299
|
+
footerActions: lastFooter ? queryFocusCandidates(lastFooter, DIALOG_FOOTER_ACTION_SELECTOR) : [],
|
|
300
|
+
formFields: queryFocusCandidates(content, DIALOG_FIELD_SELECTOR),
|
|
301
|
+
primaryActions: queryFocusCandidates(content, DIALOG_PRIMARY_ACTION_SELECTOR),
|
|
302
|
+
submitActions: queryFocusCandidates(content, DIALOG_SUBMIT_ACTION_SELECTOR)
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
function focusDialogDefaultTarget(content) {
|
|
306
|
+
const focusTarget = getDialogDefaultFocusTarget(content);
|
|
307
|
+
if (!focusTarget) return false;
|
|
308
|
+
requestAnimationFrame(()=>{
|
|
309
|
+
if (focusTarget.isConnected) focusTarget.focus({
|
|
310
|
+
preventScroll: true
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
function shouldFlushQueuedDialogDefaultFocus({ contentAvailable, ready, shouldFocus }) {
|
|
316
|
+
return ready && shouldFocus && contentAvailable;
|
|
317
|
+
}
|
|
318
|
+
function flushQueuedDialogDefaultFocus({ content, ready, shouldFocus }) {
|
|
319
|
+
if (!shouldFlushQueuedDialogDefaultFocus({
|
|
320
|
+
contentAvailable: null !== content,
|
|
321
|
+
ready,
|
|
322
|
+
shouldFocus
|
|
323
|
+
}) || !content) return false;
|
|
324
|
+
focusDialogDefaultTarget(content);
|
|
325
|
+
return true;
|
|
326
|
+
}
|
|
327
|
+
function shouldQueueDialogDefaultFocus(event, onOpenAutoFocus) {
|
|
328
|
+
onOpenAutoFocus?.(event);
|
|
329
|
+
if (event.defaultPrevented) return false;
|
|
330
|
+
event.preventDefault();
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
function handleDialogOpenAutoFocus(event, onOpenAutoFocus) {
|
|
334
|
+
if (!shouldQueueDialogDefaultFocus(event, onOpenAutoFocus)) return;
|
|
335
|
+
const content = event.currentTarget;
|
|
336
|
+
if (isHtmlElement(content)) focusDialogDefaultTarget(content);
|
|
337
|
+
}
|
|
338
|
+
const AlertDialog = __rspack_external__radix_ui_react_alert_dialog_df21c073.Root;
|
|
339
|
+
__rspack_external__radix_ui_react_alert_dialog_df21c073.Trigger;
|
|
340
|
+
const AlertDialogPortal = __rspack_external__radix_ui_react_alert_dialog_df21c073.Portal;
|
|
341
|
+
function AlertDialogOverlay({ className, ref, ...props }) {
|
|
342
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_alert_dialog_df21c073.Overlay, {
|
|
343
|
+
ref: ref,
|
|
344
|
+
className: utils_cn('data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-(--z-modal) bg-black/50', className),
|
|
345
|
+
...props
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
AlertDialogOverlay.displayName = __rspack_external__radix_ui_react_alert_dialog_df21c073.Overlay.displayName;
|
|
349
|
+
function AlertDialogContent({ className, onOpenAutoFocus, ref, ...props }) {
|
|
350
|
+
const { ref: occlusionRef, ready } = native_view_occlusion_useNativeViewOcclusion();
|
|
351
|
+
const handleOpenAutoFocus = __rspack_external_react.useCallback((event)=>{
|
|
352
|
+
handleDialogOpenAutoFocus(event, onOpenAutoFocus);
|
|
353
|
+
}, [
|
|
354
|
+
onOpenAutoFocus
|
|
355
|
+
]);
|
|
356
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogPortal, null, /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogOverlay, {
|
|
357
|
+
ref: occlusionRef,
|
|
358
|
+
className: utils_cn(!ready && 'invisible')
|
|
359
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_alert_dialog_df21c073.Content, {
|
|
360
|
+
ref: ref,
|
|
361
|
+
className: utils_cn('bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed top-[50%] left-[50%] z-(--z-modal) grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg', !ready && 'invisible', className),
|
|
362
|
+
...props,
|
|
363
|
+
onOpenAutoFocus: handleOpenAutoFocus
|
|
364
|
+
}));
|
|
365
|
+
}
|
|
366
|
+
AlertDialogContent.displayName = __rspack_external__radix_ui_react_alert_dialog_df21c073.Content.displayName;
|
|
367
|
+
const AlertDialogHeader = ({ className, ...props })=>/*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
368
|
+
className: utils_cn('flex flex-col space-y-2 text-center sm:text-left', className),
|
|
369
|
+
...props
|
|
370
|
+
});
|
|
371
|
+
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
|
372
|
+
const AlertDialogFooter = ({ className, ...props })=>/*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
373
|
+
className: utils_cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2', className),
|
|
374
|
+
[DIALOG_FOOTER_ATTRIBUTE]: '',
|
|
375
|
+
...props
|
|
376
|
+
});
|
|
377
|
+
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
|
378
|
+
const AlertDialogTitle = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_alert_dialog_df21c073.Title, {
|
|
379
|
+
ref: ref,
|
|
380
|
+
className: utils_cn('text-lg font-semibold', className),
|
|
381
|
+
...props
|
|
382
|
+
}));
|
|
383
|
+
AlertDialogTitle.displayName = __rspack_external__radix_ui_react_alert_dialog_df21c073.Title.displayName;
|
|
384
|
+
const AlertDialogDescription = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_alert_dialog_df21c073.Description, {
|
|
385
|
+
ref: ref,
|
|
386
|
+
className: utils_cn('text-muted-foreground text-sm', className),
|
|
387
|
+
...props
|
|
388
|
+
}));
|
|
389
|
+
AlertDialogDescription.displayName = __rspack_external__radix_ui_react_alert_dialog_df21c073.Description.displayName;
|
|
390
|
+
const AlertDialogAction = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_alert_dialog_df21c073.Action, {
|
|
391
|
+
ref: ref,
|
|
392
|
+
className: utils_cn(buttonVariants(), className),
|
|
393
|
+
[DIALOG_PRIMARY_ACTION_ATTRIBUTE]: '',
|
|
394
|
+
...props
|
|
395
|
+
}));
|
|
396
|
+
AlertDialogAction.displayName = __rspack_external__radix_ui_react_alert_dialog_df21c073.Action.displayName;
|
|
397
|
+
const AlertDialogCancel = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_alert_dialog_df21c073.Cancel, {
|
|
398
|
+
ref: ref,
|
|
399
|
+
className: utils_cn(buttonVariants({
|
|
400
|
+
variant: 'outline'
|
|
401
|
+
}), 'mt-2 sm:mt-0', className),
|
|
402
|
+
[DIALOG_CANCEL_ACTION_ATTRIBUTE]: '',
|
|
403
|
+
...props
|
|
404
|
+
}));
|
|
405
|
+
AlertDialogCancel.displayName = __rspack_external__radix_ui_react_alert_dialog_df21c073.Cancel.displayName;
|
|
406
|
+
const badgeVariants = cva('inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors duration-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2', {
|
|
407
|
+
variants: {
|
|
408
|
+
variant: {
|
|
409
|
+
default: 'border-transparent bg-primary text-primary-foreground hover:bg-primary/80',
|
|
410
|
+
secondary: 'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
411
|
+
destructive: 'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
|
|
412
|
+
success: 'border-transparent bg-success text-success-foreground hover:bg-success/80',
|
|
413
|
+
warning: 'border-transparent bg-warning text-warning-foreground hover:bg-warning/80',
|
|
414
|
+
info: 'border-transparent bg-info text-info-foreground hover:bg-info/80',
|
|
415
|
+
outline: 'text-foreground',
|
|
416
|
+
draft: 'border-surface-border-1 bg-muted text-foreground gap-2 h-8 px-3 py-2 font-medium'
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
defaultVariants: {
|
|
420
|
+
variant: 'default'
|
|
421
|
+
}
|
|
422
|
+
});
|
|
423
|
+
function Badge({ className, variant, ...props }) {
|
|
424
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("span", {
|
|
425
|
+
className: utils_cn(badgeVariants({
|
|
426
|
+
variant
|
|
427
|
+
}), className),
|
|
428
|
+
...props
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
function Avatar({ className, ref, ...props }) {
|
|
432
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_avatar_44cfeec7.Root, {
|
|
433
|
+
ref: ref,
|
|
434
|
+
...props,
|
|
435
|
+
"data-component": "avatar",
|
|
436
|
+
className: utils_cn('relative flex size-10 shrink-0 overflow-hidden rounded-full', className)
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
Avatar.displayName = __rspack_external__radix_ui_react_avatar_44cfeec7.Root.displayName;
|
|
440
|
+
function AvatarImage({ className, ref, ...props }) {
|
|
441
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_avatar_44cfeec7.Image, {
|
|
442
|
+
ref: ref,
|
|
443
|
+
...props,
|
|
444
|
+
"data-component": "avatar-image",
|
|
445
|
+
className: utils_cn('aspect-square size-full', className)
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
AvatarImage.displayName = __rspack_external__radix_ui_react_avatar_44cfeec7.Image.displayName;
|
|
449
|
+
function AvatarFallback({ className, ref, ...props }) {
|
|
450
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_avatar_44cfeec7.Fallback, {
|
|
451
|
+
ref: ref,
|
|
452
|
+
...props,
|
|
453
|
+
"data-component": "avatar-fallback",
|
|
454
|
+
className: utils_cn('bg-muted flex size-full items-center justify-center rounded-full text-sm font-medium', className)
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
AvatarFallback.displayName = __rspack_external__radix_ui_react_avatar_44cfeec7.Fallback.displayName;
|
|
458
|
+
function separator_Separator({ className, orientation = 'horizontal', decorative = true, ref, ...props }) {
|
|
459
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_separator_c79cca86.Root, {
|
|
460
|
+
ref: ref,
|
|
461
|
+
decorative: decorative,
|
|
462
|
+
orientation: orientation,
|
|
463
|
+
className: utils_cn('bg-border shrink-0', 'horizontal' === orientation ? 'h-[1px] w-full' : 'h-full w-[1px]', className),
|
|
464
|
+
...props
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
separator_Separator.displayName = __rspack_external__radix_ui_react_separator_c79cca86.Root.displayName;
|
|
468
|
+
const buttonGroupVariants = cva("flex w-fit items-stretch has-[>[data-slot=button-group]]:gap-2 [&>*]:focus-visible:relative [&>*]:focus-visible:z-10 has-[select[aria-hidden=true]:last-child]:[&>[data-slot=select-trigger]:last-of-type]:rounded-r-md [&>[data-slot=select-trigger]:not([class*='w-'])]:w-fit [&>input]:flex-1", {
|
|
469
|
+
variants: {
|
|
470
|
+
orientation: {
|
|
471
|
+
horizontal: '[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none',
|
|
472
|
+
vertical: 'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0 [&>*:not(:last-child)]:rounded-b-none'
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
defaultVariants: {
|
|
476
|
+
orientation: 'horizontal'
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
function ButtonGroup({ className, orientation, ...props }) {
|
|
480
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
481
|
+
role: "group",
|
|
482
|
+
"data-slot": "button-group",
|
|
483
|
+
"data-orientation": orientation,
|
|
484
|
+
className: utils_cn(buttonGroupVariants({
|
|
485
|
+
orientation
|
|
486
|
+
}), className),
|
|
487
|
+
...props
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
const cardVariants = cva('text-card-foreground rounded-2xl', {
|
|
491
|
+
variants: {
|
|
492
|
+
variant: {
|
|
493
|
+
default: 'bg-card/40',
|
|
494
|
+
transparent: 'bg-transparent'
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
defaultVariants: {
|
|
498
|
+
variant: 'default'
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
function Card({ className, variant, ref, ...props }) {
|
|
502
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
503
|
+
ref: ref,
|
|
504
|
+
className: utils_cn(cardVariants({
|
|
505
|
+
variant
|
|
506
|
+
}), className),
|
|
507
|
+
...props
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
Card.displayName = 'Card';
|
|
511
|
+
function CardHeader({ className, ref, ...props }) {
|
|
512
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
513
|
+
ref: ref,
|
|
514
|
+
className: utils_cn('flex flex-col space-y-1.5 p-6', className),
|
|
515
|
+
...props
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
CardHeader.displayName = 'CardHeader';
|
|
519
|
+
function CardTitle({ className, ref, ...props }) {
|
|
520
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
521
|
+
ref: ref,
|
|
522
|
+
className: utils_cn('text-2xl leading-none font-semibold tracking-tight', className),
|
|
523
|
+
...props
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
CardTitle.displayName = 'CardTitle';
|
|
527
|
+
function CardDescription({ className, ref, ...props }) {
|
|
528
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
529
|
+
ref: ref,
|
|
530
|
+
className: utils_cn('text-muted-foreground text-sm', className),
|
|
531
|
+
...props
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
CardDescription.displayName = "CardDescription";
|
|
535
|
+
function CardContent({ className, ref, ...props }) {
|
|
536
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
537
|
+
ref: ref,
|
|
538
|
+
className: utils_cn('p-6 pt-0', className),
|
|
539
|
+
...props
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
CardContent.displayName = 'CardContent';
|
|
543
|
+
function CardFooter({ className, ref, ...props }) {
|
|
544
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
545
|
+
ref: ref,
|
|
546
|
+
className: utils_cn('flex items-center p-6 pt-0', className),
|
|
547
|
+
...props
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
CardFooter.displayName = 'CardFooter';
|
|
551
|
+
const Checkbox = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_checkbox_76182ac8.Root, {
|
|
552
|
+
ref: ref,
|
|
553
|
+
className: utils_cn('peer border-primary ring-offset-background focus-visible:ring-ring data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground h-4 w-4 shrink-0 rounded-sm border focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50', className),
|
|
554
|
+
...props
|
|
555
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_checkbox_76182ac8.Indicator, {
|
|
556
|
+
className: utils_cn('flex items-center justify-center text-current')
|
|
557
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(Check, {
|
|
558
|
+
className: "h-4 w-4"
|
|
559
|
+
}))));
|
|
560
|
+
Checkbox.displayName = __rspack_external__radix_ui_react_checkbox_76182ac8.Root.displayName;
|
|
561
|
+
const ICON_SIZES = {
|
|
562
|
+
xs: '0.75em',
|
|
563
|
+
sm: '1em',
|
|
564
|
+
default: '1em',
|
|
565
|
+
md: '1.25em',
|
|
566
|
+
lg: '1.5em',
|
|
567
|
+
xl: '2em'
|
|
568
|
+
};
|
|
569
|
+
const iconVariants = cva('', {
|
|
570
|
+
defaultVariants: {
|
|
571
|
+
size: 'default'
|
|
572
|
+
},
|
|
573
|
+
variants: {
|
|
574
|
+
color: {
|
|
575
|
+
default: 'text-foreground',
|
|
576
|
+
destructive: 'text-destructive',
|
|
577
|
+
inherit: 'text-current',
|
|
578
|
+
muted: 'text-muted-foreground',
|
|
579
|
+
primary: 'text-primary',
|
|
580
|
+
secondary: 'text-secondary-foreground',
|
|
581
|
+
success: 'text-green-500',
|
|
582
|
+
warning: 'text-yellow-500'
|
|
583
|
+
},
|
|
584
|
+
size: {
|
|
585
|
+
xs: '',
|
|
586
|
+
sm: '',
|
|
587
|
+
default: '',
|
|
588
|
+
md: '',
|
|
589
|
+
lg: '',
|
|
590
|
+
xl: ''
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
function icon_Icon({ className, color, icon: IconComponent, size, ...props }) {
|
|
595
|
+
const iconSize = ICON_SIZES[size ?? 'default'];
|
|
596
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(IconComponent, {
|
|
597
|
+
"aria-hidden": "true",
|
|
598
|
+
size: iconSize,
|
|
599
|
+
className: utils_cn(iconVariants({
|
|
600
|
+
color: color ?? void 0,
|
|
601
|
+
size
|
|
602
|
+
}), className),
|
|
603
|
+
...props
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
const Dialog = __rspack_external__radix_ui_react_dialog_dabd8325.Root;
|
|
607
|
+
__rspack_external__radix_ui_react_dialog_dabd8325.Trigger;
|
|
608
|
+
const DialogPortal = __rspack_external__radix_ui_react_dialog_dabd8325.Portal;
|
|
609
|
+
__rspack_external__radix_ui_react_dialog_dabd8325.Close;
|
|
610
|
+
function DialogOverlay({ className, ref, ...props }) {
|
|
611
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_dialog_dabd8325.Overlay, {
|
|
612
|
+
ref: ref,
|
|
613
|
+
className: utils_cn('fixed inset-0 z-(--z-modal) bg-black/50', className),
|
|
614
|
+
...props
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
DialogOverlay.displayName = __rspack_external__radix_ui_react_dialog_dabd8325.Overlay.displayName;
|
|
618
|
+
function DialogContentPrimitive({ className, ref, ...props }) {
|
|
619
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_dialog_dabd8325.Content, {
|
|
620
|
+
ref: ref,
|
|
621
|
+
className: utils_cn('focus-visible:border focus-visible:ring-0 focus-visible:outline-none', className),
|
|
622
|
+
...props
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
DialogContentPrimitive.displayName = __rspack_external__radix_ui_react_dialog_dabd8325.Content.displayName;
|
|
626
|
+
function DialogContent({ className, children, ref, container, hideCloseButton, onOpenAutoFocus, onEscapeKeyDown, ...props }) {
|
|
627
|
+
const { ref: occlusionRef, ready } = native_view_occlusion_useNativeViewOcclusion();
|
|
628
|
+
const contentRef = __rspack_external_react.useRef(null);
|
|
629
|
+
const closeButtonRef = __rspack_external_react.useRef(null);
|
|
630
|
+
const shouldFocusWhenReadyRef = __rspack_external_react.useRef(false);
|
|
631
|
+
const handleOpenAutoFocus = __rspack_external_react.useCallback((event)=>{
|
|
632
|
+
shouldFocusWhenReadyRef.current = shouldQueueDialogDefaultFocus(event, onOpenAutoFocus);
|
|
633
|
+
if (flushQueuedDialogDefaultFocus({
|
|
634
|
+
content: contentRef.current,
|
|
635
|
+
ready,
|
|
636
|
+
shouldFocus: shouldFocusWhenReadyRef.current
|
|
637
|
+
})) shouldFocusWhenReadyRef.current = false;
|
|
638
|
+
}, [
|
|
639
|
+
onOpenAutoFocus,
|
|
640
|
+
ready
|
|
641
|
+
]);
|
|
642
|
+
__rspack_external_react.useEffect(()=>{
|
|
643
|
+
if (flushQueuedDialogDefaultFocus({
|
|
644
|
+
content: contentRef.current,
|
|
645
|
+
ready,
|
|
646
|
+
shouldFocus: shouldFocusWhenReadyRef.current
|
|
647
|
+
})) shouldFocusWhenReadyRef.current = false;
|
|
648
|
+
}, [
|
|
649
|
+
ready
|
|
650
|
+
]);
|
|
651
|
+
const handleEscapeKeyDown = __rspack_external_react.useCallback((event)=>{
|
|
652
|
+
onEscapeKeyDown?.(event);
|
|
653
|
+
if (!event.defaultPrevented && void 0 !== container) closeButtonRef.current?.click();
|
|
654
|
+
}, [
|
|
655
|
+
container,
|
|
656
|
+
onEscapeKeyDown
|
|
657
|
+
]);
|
|
658
|
+
const overlay = container ? /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
659
|
+
ref: occlusionRef,
|
|
660
|
+
className: utils_cn('pointer-events-auto absolute inset-0 z-(--z-modal) bg-black/50', !ready && 'invisible')
|
|
661
|
+
}) : /*#__PURE__*/ __rspack_external_react.createElement(DialogOverlay, {
|
|
662
|
+
ref: occlusionRef,
|
|
663
|
+
className: utils_cn(!ready && 'invisible')
|
|
664
|
+
});
|
|
665
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(DialogPortal, {
|
|
666
|
+
container: container
|
|
667
|
+
}, overlay, /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
668
|
+
className: utils_cn('pointer-events-none z-(--z-modal) flex items-center justify-center', container ? 'absolute top-0 right-0 left-0 p-4 sm:p-6' : 'fixed inset-0 p-4 sm:p-10', !ready && 'invisible'),
|
|
669
|
+
style: container ? {
|
|
670
|
+
bottom: 'var(--chat-input-offset, 0px)'
|
|
671
|
+
} : void 0
|
|
672
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(DialogContentPrimitive, {
|
|
673
|
+
ref: composeRefs(ref, contentRef),
|
|
674
|
+
className: utils_cn('bg-surface-level-1 pointer-events-auto relative grid max-h-full w-full max-w-lg min-w-0 gap-4 overflow-auto rounded-3xl border p-8 break-words shadow-lg', className),
|
|
675
|
+
...container ? {
|
|
676
|
+
onInteractOutside: (e)=>{
|
|
677
|
+
const target = e.detail.originalEvent.target;
|
|
678
|
+
if (!container.contains(target)) e.preventDefault();
|
|
679
|
+
}
|
|
680
|
+
} : {},
|
|
681
|
+
...props,
|
|
682
|
+
onOpenAutoFocus: handleOpenAutoFocus,
|
|
683
|
+
onEscapeKeyDown: handleEscapeKeyDown
|
|
684
|
+
}, children, !hideCloseButton && /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_dialog_dabd8325.Close, {
|
|
685
|
+
asChild: true,
|
|
686
|
+
"data-testid": "dialog-close-button"
|
|
687
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(button_Button, {
|
|
688
|
+
ref: closeButtonRef,
|
|
689
|
+
variant: "ghost",
|
|
690
|
+
size: "icon-sm",
|
|
691
|
+
className: "absolute top-3 right-3"
|
|
692
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(icon_Icon, {
|
|
693
|
+
icon: X,
|
|
694
|
+
size: "sm"
|
|
695
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement("span", {
|
|
696
|
+
className: "sr-only"
|
|
697
|
+
}, "Close"))), hideCloseButton && /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_dialog_dabd8325.Close, {
|
|
698
|
+
ref: closeButtonRef,
|
|
699
|
+
className: "sr-only",
|
|
700
|
+
tabIndex: -1,
|
|
701
|
+
"aria-hidden": true
|
|
702
|
+
}))));
|
|
703
|
+
}
|
|
704
|
+
DialogContent.displayName = __rspack_external__radix_ui_react_dialog_dabd8325.Content.displayName;
|
|
705
|
+
const DialogHeader = ({ className, ...props })=>/*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
706
|
+
className: utils_cn('flex flex-col space-y-1.5 text-center sm:text-left', className),
|
|
707
|
+
...props
|
|
708
|
+
});
|
|
709
|
+
DialogHeader.displayName = 'DialogHeader';
|
|
710
|
+
const DialogFooter = ({ className, ...props })=>/*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
711
|
+
className: utils_cn('flex flex-wrap justify-end gap-2', className),
|
|
712
|
+
[DIALOG_FOOTER_ATTRIBUTE]: '',
|
|
713
|
+
...props
|
|
714
|
+
});
|
|
715
|
+
DialogFooter.displayName = 'DialogFooter';
|
|
716
|
+
const DialogTitle = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(H5, {
|
|
717
|
+
asChild: true,
|
|
718
|
+
className: utils_cn('leading-none', className)
|
|
719
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_dialog_dabd8325.Title, {
|
|
720
|
+
ref: ref,
|
|
721
|
+
...props
|
|
722
|
+
})));
|
|
723
|
+
DialogTitle.displayName = __rspack_external__radix_ui_react_dialog_dabd8325.Title.displayName;
|
|
724
|
+
function DialogDescription({ className, ref, ...props }) {
|
|
725
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_dialog_dabd8325.Description, {
|
|
726
|
+
ref: ref,
|
|
727
|
+
className: utils_cn('text-muted-foreground text-sm', className),
|
|
728
|
+
...props
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
DialogDescription.displayName = __rspack_external__radix_ui_react_dialog_dabd8325.Description.displayName;
|
|
732
|
+
const emptyVariants = cva('flex flex-col items-center justify-center text-center', {
|
|
733
|
+
variants: {
|
|
734
|
+
size: {
|
|
735
|
+
default: 'gap-6 p-8',
|
|
736
|
+
compact: 'gap-4 p-6'
|
|
737
|
+
},
|
|
738
|
+
variant: {
|
|
739
|
+
default: '',
|
|
740
|
+
outline: 'rounded-lg border border-dashed'
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
defaultVariants: {
|
|
744
|
+
size: 'default',
|
|
745
|
+
variant: 'default'
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
function Empty({ className, ref, size, variant, ...props }) {
|
|
749
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
750
|
+
ref: ref,
|
|
751
|
+
className: utils_cn(emptyVariants({
|
|
752
|
+
size,
|
|
753
|
+
variant
|
|
754
|
+
}), className),
|
|
755
|
+
...props
|
|
756
|
+
});
|
|
757
|
+
}
|
|
758
|
+
Empty.displayName = 'Empty';
|
|
759
|
+
function EmptyHeader({ className, ref, ...props }) {
|
|
760
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
761
|
+
ref: ref,
|
|
762
|
+
className: utils_cn('flex flex-col items-center gap-2', className),
|
|
763
|
+
...props
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
EmptyHeader.displayName = 'EmptyHeader';
|
|
767
|
+
const emptyMediaVariants = cva('flex items-center justify-center', {
|
|
768
|
+
variants: {
|
|
769
|
+
variant: {
|
|
770
|
+
default: '',
|
|
771
|
+
icon: 'text-muted-foreground rounded-lg bg-muted p-3'
|
|
772
|
+
}
|
|
773
|
+
},
|
|
774
|
+
defaultVariants: {
|
|
775
|
+
variant: 'default'
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
function EmptyMedia({ className, variant, ref, ...props }) {
|
|
779
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
780
|
+
ref: ref,
|
|
781
|
+
className: utils_cn(emptyMediaVariants({
|
|
782
|
+
variant
|
|
783
|
+
}), className),
|
|
784
|
+
...props
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
EmptyMedia.displayName = 'EmptyMedia';
|
|
788
|
+
const EmptyTitle = (props)=>/*#__PURE__*/ __rspack_external_react.createElement(H3, props);
|
|
789
|
+
EmptyTitle.displayName = 'EmptyTitle';
|
|
790
|
+
function EmptyDescription({ className, ref, ...props }) {
|
|
791
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
792
|
+
ref: ref,
|
|
793
|
+
className: utils_cn('text-muted-foreground text-sm', className),
|
|
794
|
+
...props
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
EmptyDescription.displayName = "EmptyDescription";
|
|
798
|
+
function EmptyContent({ className, ref, ...props }) {
|
|
799
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
800
|
+
ref: ref,
|
|
801
|
+
className: utils_cn('flex flex-col items-center gap-2', className),
|
|
802
|
+
...props
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
EmptyContent.displayName = 'EmptyContent';
|
|
806
|
+
function Label({ className, ...props }) {
|
|
807
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_label_73c6aeea.Root, {
|
|
808
|
+
"data-slot": "label",
|
|
809
|
+
className: utils_cn('flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50', className),
|
|
810
|
+
...props
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
const fieldVariants = cva('group/field data-[invalid=true]:text-destructive flex w-full gap-3', {
|
|
814
|
+
variants: {
|
|
815
|
+
orientation: {
|
|
816
|
+
vertical: 'flex-col [&>*]:w-full [&>.sr-only]:w-auto',
|
|
817
|
+
horizontal: [
|
|
818
|
+
'flex-row items-center',
|
|
819
|
+
'[&>[data-slot=field-label]]:flex-auto',
|
|
820
|
+
'has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px has-[>[data-slot=field-content]]:items-start'
|
|
821
|
+
],
|
|
822
|
+
responsive: [
|
|
823
|
+
'@md/field-group:flex-row @md/field-group:items-center @md/field-group:[&>*]:w-auto flex-col [&>*]:w-full [&>.sr-only]:w-auto',
|
|
824
|
+
'@md/field-group:[&>[data-slot=field-label]]:flex-auto',
|
|
825
|
+
'@md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px'
|
|
826
|
+
]
|
|
827
|
+
}
|
|
828
|
+
},
|
|
829
|
+
defaultVariants: {
|
|
830
|
+
orientation: 'vertical'
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
function Field({ className, orientation = 'vertical', ...props }) {
|
|
834
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
835
|
+
role: "group",
|
|
836
|
+
"data-slot": "field",
|
|
837
|
+
"data-orientation": orientation,
|
|
838
|
+
className: utils_cn(fieldVariants({
|
|
839
|
+
orientation
|
|
840
|
+
}), className),
|
|
841
|
+
...props
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
function FieldLabel({ className, ...props }) {
|
|
845
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Label, {
|
|
846
|
+
"data-slot": "field-label",
|
|
847
|
+
className: utils_cn('group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50', 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border [&>[data-slot=field]]:p-4', 'has-data-[state=checked]:border-primary has-data-[state=checked]:bg-primary/5 dark:has-data-[state=checked]:bg-primary/10', className),
|
|
848
|
+
...props
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
function FieldDescription({ className, ...props }) {
|
|
852
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
853
|
+
"data-slot": "field-description",
|
|
854
|
+
className: utils_cn('text-muted-foreground text-sm leading-normal font-normal group-has-[[data-orientation=horizontal]]/field:text-balance', 'nth-last-2:-mt-1 last:mt-0 [[data-variant=legend]+&]:-mt-1.5', '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4', className),
|
|
855
|
+
...props
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
function FieldError({ className, children, errors, ...props }) {
|
|
859
|
+
const content = __rspack_external_react.useMemo(()=>{
|
|
860
|
+
if (children) return children;
|
|
861
|
+
if (!errors) return null;
|
|
862
|
+
if (1 === errors.length && errors[0]?.message) return errors[0].message;
|
|
863
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("ul", {
|
|
864
|
+
className: "ml-4 flex list-disc flex-col gap-1"
|
|
865
|
+
}, errors.map((error, index)=>error?.message ? /*#__PURE__*/ __rspack_external_react.createElement("li", {
|
|
866
|
+
key: index
|
|
867
|
+
}, error.message) : null));
|
|
868
|
+
}, [
|
|
869
|
+
children,
|
|
870
|
+
errors
|
|
871
|
+
]);
|
|
872
|
+
if (!content) return null;
|
|
873
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
874
|
+
role: "alert",
|
|
875
|
+
"data-slot": "field-error",
|
|
876
|
+
className: utils_cn('text-destructive text-sm font-normal', className),
|
|
877
|
+
...props
|
|
878
|
+
}, content);
|
|
879
|
+
}
|
|
880
|
+
function useNativeInputSync(ref, onChange) {
|
|
881
|
+
const lastSeenRef = useRef(null);
|
|
882
|
+
const onChangeRef = useRef(onChange);
|
|
883
|
+
useEffect(()=>{
|
|
884
|
+
onChangeRef.current = onChange;
|
|
885
|
+
});
|
|
886
|
+
const wrappedOnChange = external_react_useCallback((event)=>{
|
|
887
|
+
lastSeenRef.current = event.target.value;
|
|
888
|
+
onChangeRef.current?.(event);
|
|
889
|
+
}, []);
|
|
890
|
+
useEffect(()=>{
|
|
891
|
+
const el = ref.current;
|
|
892
|
+
if (!el) return;
|
|
893
|
+
const handler = (nativeEvent)=>{
|
|
894
|
+
queueMicrotask(()=>{
|
|
895
|
+
const next = el.value;
|
|
896
|
+
if (next === lastSeenRef.current) return;
|
|
897
|
+
lastSeenRef.current = next;
|
|
898
|
+
const handlerFn = onChangeRef.current;
|
|
899
|
+
if (!handlerFn) return;
|
|
900
|
+
const syntheticEvent = {
|
|
901
|
+
bubbles: nativeEvent.bubbles,
|
|
902
|
+
cancelable: nativeEvent.cancelable,
|
|
903
|
+
currentTarget: el,
|
|
904
|
+
defaultPrevented: nativeEvent.defaultPrevented,
|
|
905
|
+
eventPhase: nativeEvent.eventPhase,
|
|
906
|
+
isDefaultPrevented: ()=>nativeEvent.defaultPrevented,
|
|
907
|
+
isPropagationStopped: ()=>false,
|
|
908
|
+
isTrusted: nativeEvent.isTrusted,
|
|
909
|
+
nativeEvent,
|
|
910
|
+
persist: ()=>{},
|
|
911
|
+
preventDefault: ()=>nativeEvent.preventDefault(),
|
|
912
|
+
stopPropagation: ()=>nativeEvent.stopPropagation(),
|
|
913
|
+
target: el,
|
|
914
|
+
timeStamp: nativeEvent.timeStamp,
|
|
915
|
+
type: 'change'
|
|
916
|
+
};
|
|
917
|
+
handlerFn(syntheticEvent);
|
|
918
|
+
});
|
|
919
|
+
};
|
|
920
|
+
el.addEventListener('input', handler);
|
|
921
|
+
return ()=>el.removeEventListener('input', handler);
|
|
922
|
+
}, [
|
|
923
|
+
ref
|
|
924
|
+
]);
|
|
925
|
+
return wrappedOnChange;
|
|
926
|
+
}
|
|
927
|
+
function input_Input({ className, density = 'default', type, error, ref, onChange, ...props }) {
|
|
928
|
+
const internalRef = __rspack_external_react.useRef(null);
|
|
929
|
+
__rspack_external_react.useImperativeHandle(ref, ()=>internalRef.current, []);
|
|
930
|
+
const wrappedOnChange = useNativeInputSync(internalRef, onChange);
|
|
931
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("input", {
|
|
932
|
+
type: type,
|
|
933
|
+
className: utils_cn('bg-input-background placeholder:text-muted-foreground shadow-input-rest focus-visible:border-input-border-focus focus-visible:shadow-input-focus aria-invalid:border-input-border-error aria-invalid:ring-destructive flex w-full border border-transparent transition-[box-shadow,border-color] duration-200 file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:outline-none aria-invalid:ring-1 disabled:cursor-not-allowed disabled:opacity-50', 'default' === density && 'h-10 rounded-lg px-3 py-2.5 text-base md:text-sm', 'compact' === density && 'h-8 rounded-md px-2 py-1 text-xs', error && 'border-input-border-error ring-destructive ring-1', className),
|
|
934
|
+
ref: internalRef,
|
|
935
|
+
onChange: wrappedOnChange,
|
|
936
|
+
...props
|
|
937
|
+
});
|
|
938
|
+
}
|
|
939
|
+
input_Input.displayName = 'Input';
|
|
940
|
+
function Textarea({ className, error, ref, onChange, ...props }) {
|
|
941
|
+
const internalRef = __rspack_external_react.useRef(null);
|
|
942
|
+
__rspack_external_react.useImperativeHandle(ref, ()=>internalRef.current, []);
|
|
943
|
+
const wrappedOnChange = useNativeInputSync(internalRef, onChange);
|
|
944
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("textarea", {
|
|
945
|
+
className: utils_cn('bg-input-background placeholder:text-muted-foreground shadow-input-rest focus-visible:border-input-border-focus focus-visible:shadow-input-focus textarea-scrollbar flex min-h-[80px] w-full rounded-lg border border-transparent px-3 py-2.5 text-base transition-[box-shadow,border-color] duration-200 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', error && 'border-input-border-error ring-destructive ring-1', className),
|
|
946
|
+
ref: internalRef,
|
|
947
|
+
onChange: wrappedOnChange,
|
|
948
|
+
...props
|
|
949
|
+
});
|
|
950
|
+
}
|
|
951
|
+
Textarea.displayName = 'Textarea';
|
|
952
|
+
cva("text-muted-foreground flex h-auto cursor-text select-none items-center justify-center gap-2 text-sm font-medium group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-']):not([width])]:size-4", {
|
|
953
|
+
variants: {
|
|
954
|
+
align: {
|
|
955
|
+
'inline-start': 'order-first has-[>button]:ml-[-0.45rem] has-[>kbd]:ml-[-0.35rem]',
|
|
956
|
+
'inline-end': 'order-last has-[>button]:mr-[-0.4rem] has-[>kbd]:mr-[-0.35rem]',
|
|
957
|
+
'block-start': 'order-first w-full justify-start',
|
|
958
|
+
'block-end': 'order-last w-full justify-start'
|
|
959
|
+
}
|
|
960
|
+
},
|
|
961
|
+
defaultVariants: {
|
|
962
|
+
align: 'inline-start'
|
|
963
|
+
}
|
|
964
|
+
});
|
|
965
|
+
cva('flex items-center gap-2 text-sm', {
|
|
966
|
+
variants: {
|
|
967
|
+
size: {
|
|
968
|
+
xs: "h-6 gap-1 rounded-[calc(var(--radius)-5px)] px-2 has-[>svg]:px-2 [&>svg:not([class*='size-']):not([width])]:size-3.5",
|
|
969
|
+
sm: 'h-8 gap-1.5 rounded-md px-2.5 has-[>svg]:px-2.5',
|
|
970
|
+
'icon-xs': 'size-6 rounded-[calc(var(--radius)-5px)] p-0 has-[>svg]:p-0',
|
|
971
|
+
'icon-sm': 'size-8 p-0 has-[>svg]:p-0'
|
|
972
|
+
}
|
|
973
|
+
},
|
|
974
|
+
defaultVariants: {
|
|
975
|
+
size: 'xs'
|
|
976
|
+
}
|
|
977
|
+
});
|
|
978
|
+
function InputGroupTextarea({ className, ref, ...props }) {
|
|
979
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Textarea, {
|
|
980
|
+
ref: ref,
|
|
981
|
+
"data-slot": "input-group-control",
|
|
982
|
+
className: utils_cn('flex-1 resize-none rounded-none border-0 bg-transparent py-2 shadow-none focus-visible:shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 focus-visible:outline-none', className),
|
|
983
|
+
...props
|
|
984
|
+
});
|
|
985
|
+
}
|
|
986
|
+
InputGroupTextarea.displayName = 'InputGroupTextarea';
|
|
987
|
+
const itemVariants = cva('group/item flex items-center border border-transparent text-sm rounded-md transition-colors [a]:hover:bg-accent/50 [a]:transition-colors [button]:cursor-pointer [button]:hover:bg-accent/50 [button]:transition-colors duration-100 flex-wrap outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]', {
|
|
988
|
+
variants: {
|
|
989
|
+
variant: {
|
|
990
|
+
default: 'bg-transparent',
|
|
991
|
+
outline: 'border-border',
|
|
992
|
+
muted: 'bg-muted/50'
|
|
993
|
+
},
|
|
994
|
+
size: {
|
|
995
|
+
default: 'p-4 gap-4 ',
|
|
996
|
+
sm: 'py-3 px-4 gap-2.5'
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
defaultVariants: {
|
|
1000
|
+
variant: 'default',
|
|
1001
|
+
size: 'default'
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
function Item({ className, variant = 'default', size = 'default', asChild = false, ...props }) {
|
|
1005
|
+
const Comp = asChild ? react_slot_Slot : 'div';
|
|
1006
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Comp, {
|
|
1007
|
+
"data-slot": "item",
|
|
1008
|
+
"data-variant": variant,
|
|
1009
|
+
"data-size": size,
|
|
1010
|
+
className: utils_cn(itemVariants({
|
|
1011
|
+
variant,
|
|
1012
|
+
size,
|
|
1013
|
+
className
|
|
1014
|
+
})),
|
|
1015
|
+
...props
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
cva("flex shrink-0 items-center justify-center gap-2 group-has-[[data-slot=item-description]]/item:self-start [&_svg]:pointer-events-none group-has-[[data-slot=item-description]]/item:translate-y-0.5", {
|
|
1019
|
+
variants: {
|
|
1020
|
+
variant: {
|
|
1021
|
+
default: 'bg-transparent',
|
|
1022
|
+
icon: "size-8 border rounded-sm bg-muted [&_svg:not([class*='size-'])]:size-4",
|
|
1023
|
+
image: 'size-10 rounded-sm overflow-hidden [&_img]:size-full [&_img]:object-cover'
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
defaultVariants: {
|
|
1027
|
+
variant: 'default'
|
|
1028
|
+
}
|
|
1029
|
+
});
|
|
1030
|
+
function ItemContent({ className, ...props }) {
|
|
1031
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1032
|
+
"data-slot": "item-content",
|
|
1033
|
+
className: utils_cn('flex flex-1 flex-col gap-1 [&+[data-slot=item-content]]:flex-none', className),
|
|
1034
|
+
...props
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
function ItemTitle({ className, ...props }) {
|
|
1038
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1039
|
+
"data-slot": "item-title",
|
|
1040
|
+
className: utils_cn('flex w-fit items-center gap-2 text-sm leading-snug font-medium', className),
|
|
1041
|
+
...props
|
|
1042
|
+
});
|
|
1043
|
+
}
|
|
1044
|
+
function ItemDescription({ className, ...props }) {
|
|
1045
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
1046
|
+
"data-slot": "item-description",
|
|
1047
|
+
className: utils_cn('text-muted-foreground line-clamp-2 text-sm leading-normal font-normal text-balance', '[&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4', className),
|
|
1048
|
+
...props
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
const TooltipProvider = __rspack_external__radix_ui_react_tooltip_b301f25d.Provider;
|
|
1052
|
+
const Tooltip = __rspack_external__radix_ui_react_tooltip_b301f25d.Root;
|
|
1053
|
+
const TooltipTrigger = __rspack_external__radix_ui_react_tooltip_b301f25d.Trigger;
|
|
1054
|
+
function TooltipContent({ className, sideOffset = 4, variant = 'default', ref, ...props }) {
|
|
1055
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_tooltip_b301f25d.Portal, null, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_tooltip_b301f25d.Content, {
|
|
1056
|
+
ref: ref,
|
|
1057
|
+
sideOffset: sideOffset,
|
|
1058
|
+
className: utils_cn('animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-(--z-tooltip) origin-[--radix-tooltip-content-transform-origin] overflow-hidden rounded-lg px-3 py-1.5 text-sm data-[state=instant-open]:animate-none', 'chrome' === variant ? 'border-border bg-tooltip-chrome text-tooltip-chrome-foreground border shadow-md' : 'bg-popover text-popover-foreground shadow-popover', className),
|
|
1059
|
+
...props
|
|
1060
|
+
}));
|
|
1061
|
+
}
|
|
1062
|
+
TooltipContent.displayName = __rspack_external__radix_ui_react_tooltip_b301f25d.Content.displayName;
|
|
1063
|
+
function MiniAppToolbar({ className, ref, ...props }) {
|
|
1064
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("header", {
|
|
1065
|
+
ref: ref,
|
|
1066
|
+
...props,
|
|
1067
|
+
"data-component": "mini-app-toolbar",
|
|
1068
|
+
"data-slot": "mini-app-toolbar",
|
|
1069
|
+
className: utils_cn('bg-sidebar/50 border-workspace-divider flex min-h-12 shrink-0 items-center gap-3 border-b px-4 py-2', className)
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
MiniAppToolbar.displayName = 'MiniAppToolbar';
|
|
1073
|
+
function MiniAppIconButton({ icon, label, size = 'icon-xs', tooltipSide = 'bottom', type = 'button', variant = 'ghost', ...props }) {
|
|
1074
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Tooltip, {
|
|
1075
|
+
disableHoverableContent: true
|
|
1076
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(TooltipTrigger, {
|
|
1077
|
+
asChild: true
|
|
1078
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(button_Button, {
|
|
1079
|
+
...props,
|
|
1080
|
+
type: type,
|
|
1081
|
+
variant: variant,
|
|
1082
|
+
size: size,
|
|
1083
|
+
"aria-label": label,
|
|
1084
|
+
"data-component": "mini-app-icon-button",
|
|
1085
|
+
"data-slot": "mini-app-icon-button"
|
|
1086
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(icon_Icon, {
|
|
1087
|
+
icon: icon,
|
|
1088
|
+
size: "sm",
|
|
1089
|
+
"data-icon": "icon"
|
|
1090
|
+
}))), /*#__PURE__*/ __rspack_external_react.createElement(TooltipContent, {
|
|
1091
|
+
side: tooltipSide
|
|
1092
|
+
}, label));
|
|
1093
|
+
}
|
|
1094
|
+
MiniAppIconButton.displayName = 'MiniAppIconButton';
|
|
1095
|
+
function MiniAppStatusBar({ children, className, tone = 'neutral', ...props }) {
|
|
1096
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Alert, {
|
|
1097
|
+
...props,
|
|
1098
|
+
role: "status",
|
|
1099
|
+
"aria-live": "polite",
|
|
1100
|
+
"data-component": "mini-app-status-bar",
|
|
1101
|
+
"data-slot": "mini-app-status-bar",
|
|
1102
|
+
variant: 'error' === tone ? 'destructive' : 'success' === tone ? 'success' : 'default',
|
|
1103
|
+
className: utils_cn('max-h-16 overflow-auto rounded-none border-x-0 border-b-0 px-3 py-1.5', className)
|
|
1104
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(AlertDescription, {
|
|
1105
|
+
className: "text-xs"
|
|
1106
|
+
}, children));
|
|
1107
|
+
}
|
|
1108
|
+
MiniAppStatusBar.displayName = 'MiniAppStatusBar';
|
|
1109
|
+
function MiniAppPageHeader({ className, ref, ...props }) {
|
|
1110
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("header", {
|
|
1111
|
+
ref: ref,
|
|
1112
|
+
...props,
|
|
1113
|
+
"data-component": "mini-app-page-header",
|
|
1114
|
+
className: utils_cn('flex flex-wrap items-start justify-between gap-4', className)
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
MiniAppPageHeader.displayName = 'MiniAppPageHeader';
|
|
1118
|
+
function MiniAppPageHeaderContent({ className, ...props }) {
|
|
1119
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1120
|
+
...props,
|
|
1121
|
+
"data-component": "mini-app-page-header-content",
|
|
1122
|
+
className: utils_cn('min-w-0 flex-1 space-y-1', className)
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
MiniAppPageHeaderContent.displayName = 'MiniAppPageHeaderContent';
|
|
1126
|
+
function MiniAppPageHeaderTitle({ className, ...props }) {
|
|
1127
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H1, {
|
|
1128
|
+
...props,
|
|
1129
|
+
"data-component": "mini-app-page-header-title",
|
|
1130
|
+
className: utils_cn('text-2xl leading-8', className)
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
MiniAppPageHeaderTitle.displayName = 'MiniAppPageHeaderTitle';
|
|
1134
|
+
function MiniAppPageHeaderDescription({ className, ...props }) {
|
|
1135
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
1136
|
+
...props,
|
|
1137
|
+
"data-component": "mini-app-page-header-description",
|
|
1138
|
+
className: utils_cn('text-muted-foreground text-sm', className)
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
MiniAppPageHeaderDescription.displayName = "MiniAppPageHeaderDescription";
|
|
1142
|
+
function MiniAppPageHeaderActions({ className, ...props }) {
|
|
1143
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1144
|
+
...props,
|
|
1145
|
+
"data-component": "mini-app-page-header-actions",
|
|
1146
|
+
className: utils_cn('flex shrink-0 flex-wrap items-center gap-2', className)
|
|
1147
|
+
});
|
|
1148
|
+
}
|
|
1149
|
+
MiniAppPageHeaderActions.displayName = 'MiniAppPageHeaderActions';
|
|
1150
|
+
function MiniAppSectionHeader({ className, ...props }) {
|
|
1151
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("header", {
|
|
1152
|
+
...props,
|
|
1153
|
+
"data-component": "mini-app-section-header",
|
|
1154
|
+
className: utils_cn('flex flex-wrap items-start justify-between gap-3', className)
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
MiniAppSectionHeader.displayName = 'MiniAppSectionHeader';
|
|
1158
|
+
function MiniAppSectionHeaderContent({ className, ...props }) {
|
|
1159
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1160
|
+
...props,
|
|
1161
|
+
"data-component": "mini-app-section-header-content",
|
|
1162
|
+
className: utils_cn('min-w-0 flex-1 space-y-1', className)
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
MiniAppSectionHeaderContent.displayName = 'MiniAppSectionHeaderContent';
|
|
1166
|
+
function MiniAppSectionHeaderTitle({ className, ...props }) {
|
|
1167
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H2, {
|
|
1168
|
+
...props,
|
|
1169
|
+
"data-component": "mini-app-section-header-title",
|
|
1170
|
+
className: utils_cn('text-lg leading-7', className)
|
|
1171
|
+
});
|
|
1172
|
+
}
|
|
1173
|
+
MiniAppSectionHeaderTitle.displayName = 'MiniAppSectionHeaderTitle';
|
|
1174
|
+
function MiniAppSectionHeaderDescription({ className, ...props }) {
|
|
1175
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
1176
|
+
...props,
|
|
1177
|
+
"data-component": "mini-app-section-header-description",
|
|
1178
|
+
className: utils_cn('text-muted-foreground text-sm', className)
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
MiniAppSectionHeaderDescription.displayName = "MiniAppSectionHeaderDescription";
|
|
1182
|
+
function MiniAppSectionHeaderActions({ className, ...props }) {
|
|
1183
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1184
|
+
...props,
|
|
1185
|
+
"data-component": "mini-app-section-header-actions",
|
|
1186
|
+
className: utils_cn('flex shrink-0 flex-wrap items-center gap-2', className)
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
MiniAppSectionHeaderActions.displayName = 'MiniAppSectionHeaderActions';
|
|
1190
|
+
function MiniAppMetric({ className, ...props }) {
|
|
1191
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Card, {
|
|
1192
|
+
...props,
|
|
1193
|
+
"data-component": "mini-app-metric",
|
|
1194
|
+
className: utils_cn('border p-0', className)
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
MiniAppMetric.displayName = 'MiniAppMetric';
|
|
1198
|
+
function MiniAppMetricHeader({ className, ...props }) {
|
|
1199
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(CardHeader, {
|
|
1200
|
+
...props,
|
|
1201
|
+
"data-component": "mini-app-metric-header",
|
|
1202
|
+
className: utils_cn('flex-row items-center justify-between gap-2 p-4 pb-0', className)
|
|
1203
|
+
});
|
|
1204
|
+
}
|
|
1205
|
+
MiniAppMetricHeader.displayName = 'MiniAppMetricHeader';
|
|
1206
|
+
function MiniAppMetricLabel({ className, ...props }) {
|
|
1207
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1208
|
+
...props,
|
|
1209
|
+
"data-component": "mini-app-metric-label",
|
|
1210
|
+
className: utils_cn('text-muted-foreground text-sm font-medium', className)
|
|
1211
|
+
});
|
|
1212
|
+
}
|
|
1213
|
+
MiniAppMetricLabel.displayName = 'MiniAppMetricLabel';
|
|
1214
|
+
function MiniAppMetricContent({ className, ...props }) {
|
|
1215
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(CardContent, {
|
|
1216
|
+
...props,
|
|
1217
|
+
"data-component": "mini-app-metric-content",
|
|
1218
|
+
className: utils_cn('space-y-1 p-4 pt-3', className)
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
MiniAppMetricContent.displayName = 'MiniAppMetricContent';
|
|
1222
|
+
function MiniAppMetricValue({ className, ...props }) {
|
|
1223
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1224
|
+
...props,
|
|
1225
|
+
"data-component": "mini-app-metric-value",
|
|
1226
|
+
className: utils_cn('text-foreground text-2xl font-semibold tabular-nums', className)
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
MiniAppMetricValue.displayName = 'MiniAppMetricValue';
|
|
1230
|
+
function MiniAppMetricDetail({ className, ...props }) {
|
|
1231
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
1232
|
+
...props,
|
|
1233
|
+
"data-component": "mini-app-metric-detail",
|
|
1234
|
+
className: utils_cn('text-muted-foreground text-xs', className)
|
|
1235
|
+
});
|
|
1236
|
+
}
|
|
1237
|
+
MiniAppMetricDetail.displayName = 'MiniAppMetricDetail';
|
|
1238
|
+
function NativeSelect({ className, density = 'default', ref, wrapperClassName, ...props }) {
|
|
1239
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1240
|
+
className: utils_cn('relative min-w-0 max-w-full', wrapperClassName)
|
|
1241
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("select", {
|
|
1242
|
+
className: utils_cn('bg-background ring-offset-background placeholder:text-muted-foreground shadow-input-rest focus-visible:ring-ring flex w-full appearance-none rounded-md border border-transparent text-sm focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50', 'default' === density && 'h-10 px-3 py-2 pr-10', 'compact' === density && 'h-8 py-1 pr-8 pl-2 text-xs', className),
|
|
1243
|
+
ref: ref,
|
|
1244
|
+
...props
|
|
1245
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement(ChevronDown, {
|
|
1246
|
+
className: utils_cn('pointer-events-none absolute top-1/2 -translate-y-1/2 opacity-50', 'default' === density && 'right-3 h-4 w-4', 'compact' === density && 'right-2 h-3.5 w-3.5')
|
|
1247
|
+
}));
|
|
1248
|
+
}
|
|
1249
|
+
NativeSelect.displayName = 'NativeSelect';
|
|
1250
|
+
function NativeSelectOption({ className, ref, ...props }) {
|
|
1251
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("option", {
|
|
1252
|
+
className: className,
|
|
1253
|
+
ref: ref,
|
|
1254
|
+
...props
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1257
|
+
NativeSelectOption.displayName = 'NativeSelectOption';
|
|
1258
|
+
function NativeSelectOptGroup({ className, ref, ...props }) {
|
|
1259
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("optgroup", {
|
|
1260
|
+
className: className,
|
|
1261
|
+
ref: ref,
|
|
1262
|
+
...props
|
|
1263
|
+
});
|
|
1264
|
+
}
|
|
1265
|
+
NativeSelectOptGroup.displayName = 'NativeSelectOptGroup';
|
|
1266
|
+
function Progress({ className, value, ref, ...props }) {
|
|
1267
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_progress_67feda0a.Root, {
|
|
1268
|
+
ref: ref,
|
|
1269
|
+
className: utils_cn('bg-secondary relative h-4 w-full overflow-hidden rounded-full', className),
|
|
1270
|
+
...props
|
|
1271
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_progress_67feda0a.Indicator, {
|
|
1272
|
+
className: "bg-primary h-full w-full flex-1 transition-all",
|
|
1273
|
+
style: {
|
|
1274
|
+
transform: `translateX(-${100 - (value || 0)}%)`
|
|
1275
|
+
}
|
|
1276
|
+
}));
|
|
1277
|
+
}
|
|
1278
|
+
Progress.displayName = __rspack_external__radix_ui_react_progress_67feda0a.Root.displayName;
|
|
1279
|
+
function RadioGroup({ className, ref, ...props }) {
|
|
1280
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_radio_group_295a43fb.Root, {
|
|
1281
|
+
className: utils_cn('grid gap-2', className),
|
|
1282
|
+
...props,
|
|
1283
|
+
ref: ref
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
RadioGroup.displayName = __rspack_external__radix_ui_react_radio_group_295a43fb.Root.displayName;
|
|
1287
|
+
function RadioGroupItem({ className, ref, ...props }) {
|
|
1288
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_radio_group_295a43fb.Item, {
|
|
1289
|
+
ref: ref,
|
|
1290
|
+
className: utils_cn('ring-offset-background focus-visible:ring-ring border-input bg-input-background data-[state=checked]:border-primary data-[state=checked]:bg-primary aspect-square h-4 w-4 rounded-full border transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50', className),
|
|
1291
|
+
...props
|
|
1292
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_radio_group_295a43fb.Indicator, {
|
|
1293
|
+
className: "flex items-center justify-center"
|
|
1294
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(Circle, {
|
|
1295
|
+
className: "h-2 w-2 fill-white text-white"
|
|
1296
|
+
})));
|
|
1297
|
+
}
|
|
1298
|
+
RadioGroupItem.displayName = __rspack_external__radix_ui_react_radio_group_295a43fb.Item.displayName;
|
|
1299
|
+
function RadioCard({ id, value, children, className, ref, ...props }) {
|
|
1300
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("label", {
|
|
1301
|
+
ref: ref,
|
|
1302
|
+
htmlFor: id,
|
|
1303
|
+
className: utils_cn('bg-surface-level-2 rounded-inset relative flex cursor-pointer items-start gap-3 px-3 py-2.5 shadow-sm transition-all duration-150', 'hover:bg-accent/50', 'has-[[data-state=checked]]:bg-interactive-focus has-[[data-state=checked]]:ring-ring has-[[data-state=checked]]:ring-1', className)
|
|
1304
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(RadioGroupItem, {
|
|
1305
|
+
id: id,
|
|
1306
|
+
value: value,
|
|
1307
|
+
className: "mt-0.5 shrink-0",
|
|
1308
|
+
...props
|
|
1309
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1310
|
+
className: "flex-1 space-y-1"
|
|
1311
|
+
}, children));
|
|
1312
|
+
}
|
|
1313
|
+
RadioCard.displayName = 'RadioCard';
|
|
1314
|
+
__rspack_external__radix_ui_react_select_4606f4d3.Root;
|
|
1315
|
+
__rspack_external__radix_ui_react_select_4606f4d3.Group;
|
|
1316
|
+
__rspack_external__radix_ui_react_select_4606f4d3.Value;
|
|
1317
|
+
function SelectTrigger({ className, children, density = 'default', ref, ...props }) {
|
|
1318
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Trigger, {
|
|
1319
|
+
ref: ref,
|
|
1320
|
+
className: utils_cn('bg-input-background data-[placeholder]:text-muted-foreground shadow-input-rest focus-visible:border-input-border-focus focus-visible:shadow-input-focus flex w-full min-w-0 items-center justify-between gap-2 rounded-lg border border-transparent transition-[box-shadow,border-color] duration-200 focus:outline-none disabled:cursor-not-allowed disabled:opacity-50 [&>span]:min-w-0 [&>span]:flex-1 [&>span]:truncate [&>span]:text-left', 'default' === density && 'h-9 px-3 py-2 text-base md:text-sm', 'compact' === density && 'h-8 px-2 py-1 text-xs', className),
|
|
1321
|
+
...props
|
|
1322
|
+
}, children, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Icon, {
|
|
1323
|
+
asChild: true
|
|
1324
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(ChevronDown, {
|
|
1325
|
+
className: "h-4 w-4 opacity-50"
|
|
1326
|
+
})));
|
|
1327
|
+
}
|
|
1328
|
+
SelectTrigger.displayName = __rspack_external__radix_ui_react_select_4606f4d3.Trigger.displayName;
|
|
1329
|
+
function SelectScrollUpButton({ className, ref, ...props }) {
|
|
1330
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.ScrollUpButton, {
|
|
1331
|
+
ref: ref,
|
|
1332
|
+
className: utils_cn('flex cursor-default items-center justify-center py-1', className),
|
|
1333
|
+
...props
|
|
1334
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(ChevronUp, {
|
|
1335
|
+
className: "h-4 w-4"
|
|
1336
|
+
}));
|
|
1337
|
+
}
|
|
1338
|
+
SelectScrollUpButton.displayName = __rspack_external__radix_ui_react_select_4606f4d3.ScrollUpButton.displayName;
|
|
1339
|
+
function SelectScrollDownButton({ className, ref, ...props }) {
|
|
1340
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.ScrollDownButton, {
|
|
1341
|
+
ref: ref,
|
|
1342
|
+
className: utils_cn('flex cursor-default items-center justify-center py-1', className),
|
|
1343
|
+
...props
|
|
1344
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(ChevronDown, {
|
|
1345
|
+
className: "h-4 w-4"
|
|
1346
|
+
}));
|
|
1347
|
+
}
|
|
1348
|
+
SelectScrollDownButton.displayName = __rspack_external__radix_ui_react_select_4606f4d3.ScrollDownButton.displayName;
|
|
1349
|
+
function SelectContent({ className, children, position = 'popper', ref, ...props }) {
|
|
1350
|
+
const { ref: occlusionRef, ready } = native_view_occlusion_useNativeViewOcclusion();
|
|
1351
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Portal, null, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Content, {
|
|
1352
|
+
ref: composeRefs(ref, occlusionRef),
|
|
1353
|
+
className: utils_cn('bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-(--z-popover) max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-x-hidden overflow-y-auto rounded-lg shadow-sm data-[side=bottom]:origin-top data-[side=left]:origin-right data-[side=right]:origin-left data-[side=top]:origin-bottom', 'popper' === position && 'data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1', !ready && 'invisible', className),
|
|
1354
|
+
position: position,
|
|
1355
|
+
...props
|
|
1356
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Viewport, {
|
|
1357
|
+
className: utils_cn('p-1', 'popper' === position && 'max-h-[min(var(--radix-select-content-available-height),24rem)] w-full min-w-[var(--radix-select-trigger-width)]')
|
|
1358
|
+
}, children)));
|
|
1359
|
+
}
|
|
1360
|
+
SelectContent.displayName = __rspack_external__radix_ui_react_select_4606f4d3.Content.displayName;
|
|
1361
|
+
function SelectLabel({ className, ref, ...props }) {
|
|
1362
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Label, {
|
|
1363
|
+
ref: ref,
|
|
1364
|
+
className: utils_cn('py-1.5 pr-2 pl-8 text-sm font-semibold', className),
|
|
1365
|
+
...props
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
SelectLabel.displayName = __rspack_external__radix_ui_react_select_4606f4d3.Label.displayName;
|
|
1369
|
+
function SelectItem({ className, children, ref, ...props }) {
|
|
1370
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Item, {
|
|
1371
|
+
ref: ref,
|
|
1372
|
+
className: utils_cn('data-[highlighted]:bg-sidebar-accent data-[highlighted]:text-sidebar-accent-foreground relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-none select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50', className),
|
|
1373
|
+
...props
|
|
1374
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("span", {
|
|
1375
|
+
className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center"
|
|
1376
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.ItemIndicator, null, /*#__PURE__*/ __rspack_external_react.createElement(Check, {
|
|
1377
|
+
className: "h-4 w-4"
|
|
1378
|
+
}))), /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.ItemText, null, children));
|
|
1379
|
+
}
|
|
1380
|
+
SelectItem.displayName = __rspack_external__radix_ui_react_select_4606f4d3.Item.displayName;
|
|
1381
|
+
function SelectSeparator({ className, ref, ...props }) {
|
|
1382
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_select_4606f4d3.Separator, {
|
|
1383
|
+
ref: ref,
|
|
1384
|
+
className: utils_cn('bg-muted -mx-1 my-1 h-px', className),
|
|
1385
|
+
...props
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
SelectSeparator.displayName = __rspack_external__radix_ui_react_select_4606f4d3.Separator.displayName;
|
|
1389
|
+
function Skeleton({ className, ...props }) {
|
|
1390
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1391
|
+
"data-slot": "skeleton",
|
|
1392
|
+
className: utils_cn('bg-accent animate-pulse rounded-md', className),
|
|
1393
|
+
...props
|
|
1394
|
+
});
|
|
1395
|
+
}
|
|
1396
|
+
function Slider({ className, ref, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledby, ...props }) {
|
|
1397
|
+
const thumbCount = __rspack_external_react.useMemo(()=>{
|
|
1398
|
+
if (props.value?.length) return props.value.length;
|
|
1399
|
+
if (props.defaultValue?.length) return props.defaultValue.length;
|
|
1400
|
+
return 1;
|
|
1401
|
+
}, [
|
|
1402
|
+
props.value,
|
|
1403
|
+
props.defaultValue
|
|
1404
|
+
]);
|
|
1405
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_slider_302f41eb.Root, {
|
|
1406
|
+
ref: ref,
|
|
1407
|
+
className: utils_cn('relative flex w-full touch-none items-center select-none', 'disabled:pointer-events-none disabled:opacity-50', className),
|
|
1408
|
+
...props
|
|
1409
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_slider_302f41eb.Track, {
|
|
1410
|
+
className: utils_cn('bg-muted relative h-2 w-full grow overflow-hidden rounded-full', 'data-[disabled]:opacity-50')
|
|
1411
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_slider_302f41eb.Range, {
|
|
1412
|
+
className: "bg-primary absolute h-full"
|
|
1413
|
+
})), Array.from({
|
|
1414
|
+
length: thumbCount
|
|
1415
|
+
}).map((_, index)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_slider_302f41eb.Thumb, {
|
|
1416
|
+
key: index,
|
|
1417
|
+
"aria-label": ariaLabel,
|
|
1418
|
+
"aria-labelledby": ariaLabelledby,
|
|
1419
|
+
className: utils_cn('border-primary bg-switch-thumb ring-offset-background block h-5 w-5 rounded-full border-2 shadow-sm transition-colors', 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none', 'disabled:pointer-events-none disabled:opacity-50')
|
|
1420
|
+
})));
|
|
1421
|
+
}
|
|
1422
|
+
Slider.displayName = 'Slider';
|
|
1423
|
+
const statusIndicatorVariants = cva('rounded-full', {
|
|
1424
|
+
variants: {
|
|
1425
|
+
tone: {
|
|
1426
|
+
success: 'bg-success',
|
|
1427
|
+
warning: 'bg-warning',
|
|
1428
|
+
destructive: 'bg-destructive',
|
|
1429
|
+
neutral: 'bg-muted-foreground'
|
|
1430
|
+
},
|
|
1431
|
+
size: {
|
|
1432
|
+
sm: 'size-2.5',
|
|
1433
|
+
md: 'size-3',
|
|
1434
|
+
lg: 'size-4'
|
|
1435
|
+
}
|
|
1436
|
+
},
|
|
1437
|
+
defaultVariants: {
|
|
1438
|
+
tone: 'neutral',
|
|
1439
|
+
size: 'md'
|
|
1440
|
+
}
|
|
1441
|
+
});
|
|
1442
|
+
function StatusIndicator({ className, label, ref, size, tone, ...props }) {
|
|
1443
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("span", {
|
|
1444
|
+
ref: ref,
|
|
1445
|
+
...props,
|
|
1446
|
+
"data-component": "status-indicator",
|
|
1447
|
+
className: utils_cn(statusIndicatorVariants({
|
|
1448
|
+
tone,
|
|
1449
|
+
size
|
|
1450
|
+
}), className),
|
|
1451
|
+
role: "status",
|
|
1452
|
+
"aria-label": label
|
|
1453
|
+
});
|
|
1454
|
+
}
|
|
1455
|
+
StatusIndicator.displayName = 'StatusIndicator';
|
|
1456
|
+
const Table = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, density = 'default', ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
1457
|
+
className: "relative w-full overflow-auto"
|
|
1458
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("table", {
|
|
1459
|
+
ref: ref,
|
|
1460
|
+
"data-density": density,
|
|
1461
|
+
className: utils_cn('w-full caption-bottom text-sm', 'compact' === density && '[&_th]:h-8 [&_th]:px-2 [&_th]:text-xs [&_td]:p-1', className),
|
|
1462
|
+
...props
|
|
1463
|
+
})));
|
|
1464
|
+
Table.displayName = 'Table';
|
|
1465
|
+
const TableHeader = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("thead", {
|
|
1466
|
+
ref: ref,
|
|
1467
|
+
className: utils_cn('[&_tr]:border-b', className),
|
|
1468
|
+
...props
|
|
1469
|
+
}));
|
|
1470
|
+
TableHeader.displayName = 'TableHeader';
|
|
1471
|
+
const TableBody = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("tbody", {
|
|
1472
|
+
ref: ref,
|
|
1473
|
+
className: utils_cn('[&_tr:last-child]:border-0', className),
|
|
1474
|
+
...props
|
|
1475
|
+
}));
|
|
1476
|
+
TableBody.displayName = 'TableBody';
|
|
1477
|
+
const TableFooter = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("tfoot", {
|
|
1478
|
+
ref: ref,
|
|
1479
|
+
className: utils_cn('bg-muted/50 border-t font-medium [&>tr]:last:border-b-0', className),
|
|
1480
|
+
...props
|
|
1481
|
+
}));
|
|
1482
|
+
TableFooter.displayName = 'TableFooter';
|
|
1483
|
+
const TableRow = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("tr", {
|
|
1484
|
+
ref: ref,
|
|
1485
|
+
className: utils_cn('hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors duration-100', className),
|
|
1486
|
+
...props
|
|
1487
|
+
}));
|
|
1488
|
+
TableRow.displayName = 'TableRow';
|
|
1489
|
+
const TableHead = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("th", {
|
|
1490
|
+
ref: ref,
|
|
1491
|
+
className: utils_cn('text-muted-foreground h-12 px-4 text-left align-middle font-medium [&:has([role=checkbox])]:pr-0', className),
|
|
1492
|
+
...props
|
|
1493
|
+
}));
|
|
1494
|
+
TableHead.displayName = 'TableHead';
|
|
1495
|
+
const TableCell = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("td", {
|
|
1496
|
+
ref: ref,
|
|
1497
|
+
className: utils_cn('p-4 align-middle [&:has([role=checkbox])]:pr-0', className),
|
|
1498
|
+
...props
|
|
1499
|
+
}));
|
|
1500
|
+
TableCell.displayName = 'TableCell';
|
|
1501
|
+
const TableCaption = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement("caption", {
|
|
1502
|
+
ref: ref,
|
|
1503
|
+
className: utils_cn('text-muted-foreground mt-4 text-sm', className),
|
|
1504
|
+
...props
|
|
1505
|
+
}));
|
|
1506
|
+
TableCaption.displayName = 'TableCaption';
|
|
1507
|
+
function Tabs({ className, orientation = 'horizontal', ...props }) {
|
|
1508
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_tabs_62268d7a.Root, {
|
|
1509
|
+
"data-slot": "tabs",
|
|
1510
|
+
"data-orientation": orientation,
|
|
1511
|
+
orientation: orientation,
|
|
1512
|
+
className: utils_cn('group/tabs flex gap-2 data-[orientation=horizontal]:flex-col', className),
|
|
1513
|
+
...props
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
const tabsListVariants = cva('group/tabs-list text-muted-foreground inline-flex w-fit items-center justify-center rounded-lg p-[3px] group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none', {
|
|
1517
|
+
variants: {
|
|
1518
|
+
variant: {
|
|
1519
|
+
default: 'bg-muted',
|
|
1520
|
+
line: 'gap-1 bg-transparent'
|
|
1521
|
+
}
|
|
1522
|
+
},
|
|
1523
|
+
defaultVariants: {
|
|
1524
|
+
variant: 'default'
|
|
1525
|
+
}
|
|
1526
|
+
});
|
|
1527
|
+
function TabsList({ className, variant = 'default', ...props }) {
|
|
1528
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_tabs_62268d7a.List, {
|
|
1529
|
+
"data-slot": "tabs-list",
|
|
1530
|
+
"data-variant": variant,
|
|
1531
|
+
className: utils_cn(tabsListVariants({
|
|
1532
|
+
variant
|
|
1533
|
+
}), className),
|
|
1534
|
+
...props
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
function TabsTrigger({ className, ...props }) {
|
|
1538
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_tabs_62268d7a.Trigger, {
|
|
1539
|
+
"data-slot": "tabs-trigger",
|
|
1540
|
+
className: utils_cn("text-foreground/60 hover:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:text-muted-foreground dark:hover:text-foreground relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", 'group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent', 'data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground', 'after:bg-foreground after:absolute after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100', className),
|
|
1541
|
+
...props
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
function TabsContent({ className, ...props }) {
|
|
1545
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_tabs_62268d7a.Content, {
|
|
1546
|
+
"data-slot": "tabs-content",
|
|
1547
|
+
className: utils_cn('focus-visible:ring-ring/50 flex-1 outline-none focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:outline-1', className),
|
|
1548
|
+
...props
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
const toggleVariants = cva('inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 gap-2', {
|
|
1552
|
+
variants: {
|
|
1553
|
+
variant: {
|
|
1554
|
+
default: 'bg-transparent',
|
|
1555
|
+
outline: 'border border-input bg-transparent hover:bg-accent hover:text-accent-foreground'
|
|
1556
|
+
},
|
|
1557
|
+
size: {
|
|
1558
|
+
default: 'h-10 px-3 min-w-10',
|
|
1559
|
+
sm: 'h-9 px-2.5 min-w-9',
|
|
1560
|
+
lg: 'h-11 px-5 min-w-11'
|
|
1561
|
+
}
|
|
1562
|
+
},
|
|
1563
|
+
defaultVariants: {
|
|
1564
|
+
variant: 'default',
|
|
1565
|
+
size: 'default'
|
|
1566
|
+
}
|
|
1567
|
+
});
|
|
1568
|
+
const Toggle = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, variant, size, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_toggle_f6d72b6a.Root, {
|
|
1569
|
+
ref: ref,
|
|
1570
|
+
className: utils_cn(toggleVariants({
|
|
1571
|
+
variant,
|
|
1572
|
+
size,
|
|
1573
|
+
className
|
|
1574
|
+
})),
|
|
1575
|
+
...props
|
|
1576
|
+
}));
|
|
1577
|
+
Toggle.displayName = __rspack_external__radix_ui_react_toggle_f6d72b6a.Root.displayName;
|
|
1578
|
+
const ToggleGroup = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_toggle_group_1cb63752.Root, {
|
|
1579
|
+
ref: ref,
|
|
1580
|
+
className: utils_cn('bg-muted inline-flex items-center justify-center rounded-md p-1', className),
|
|
1581
|
+
...props
|
|
1582
|
+
}));
|
|
1583
|
+
ToggleGroup.displayName = __rspack_external__radix_ui_react_toggle_group_1cb63752.Root.displayName;
|
|
1584
|
+
const ToggleGroupItem = /*#__PURE__*/ __rspack_external_react.forwardRef(({ className, children, ...props }, ref)=>/*#__PURE__*/ __rspack_external_react.createElement(__rspack_external__radix_ui_react_toggle_group_1cb63752.Item, {
|
|
1585
|
+
ref: ref,
|
|
1586
|
+
className: utils_cn('ring-offset-background inline-flex cursor-pointer items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all', 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none', 'disabled:pointer-events-none disabled:opacity-50', 'data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm', 'hover:bg-muted-foreground/10', className),
|
|
1587
|
+
...props
|
|
1588
|
+
}, children));
|
|
1589
|
+
ToggleGroupItem.displayName = __rspack_external__radix_ui_react_toggle_group_1cb63752.Item.displayName;
|
|
1590
|
+
const SDK_SLOT = Symbol.for('tap.internal.v1');
|
|
1591
|
+
const UNSUPPORTED_ENVIRONMENT_MESSAGE = 'Attempted to use The AI Platform MiniApp SDK outside a supported environment';
|
|
1592
|
+
function readMiniAppSdk() {
|
|
1593
|
+
const value = Reflect.get(globalThis, SDK_SLOT);
|
|
1594
|
+
if ('object' != typeof value || null === value) throw new Error(UNSUPPORTED_ENVIRONMENT_MESSAGE);
|
|
1595
|
+
return value;
|
|
1596
|
+
}
|
|
1597
|
+
new Proxy(Object.create(null), {
|
|
1598
|
+
get (_target, property) {
|
|
1599
|
+
return Reflect.get(readMiniAppSdk(), property);
|
|
1600
|
+
},
|
|
1601
|
+
has (_target, property) {
|
|
1602
|
+
return Reflect.has(readMiniAppSdk(), property);
|
|
1603
|
+
},
|
|
1604
|
+
ownKeys () {
|
|
1605
|
+
return Reflect.ownKeys(readMiniAppSdk());
|
|
1606
|
+
},
|
|
1607
|
+
getOwnPropertyDescriptor (_target, property) {
|
|
1608
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(readMiniAppSdk(), property);
|
|
1609
|
+
return descriptor ? {
|
|
1610
|
+
...descriptor,
|
|
1611
|
+
configurable: true
|
|
1612
|
+
} : void 0;
|
|
1613
|
+
}
|
|
1614
|
+
});
|
|
1615
|
+
function exactOrigin(value) {
|
|
1616
|
+
if (!value) return null;
|
|
1617
|
+
try {
|
|
1618
|
+
const url = new URL(value);
|
|
1619
|
+
return 'null' === url.origin || url.username || url.password ? null : url.origin;
|
|
1620
|
+
} catch {
|
|
1621
|
+
return null;
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
function getHostOrigin() {
|
|
1625
|
+
const params = new URLSearchParams(window.location.search);
|
|
1626
|
+
const referrer = "u" < typeof document ? '' : document.referrer;
|
|
1627
|
+
return exactOrigin(params.get('hostOrigin')) ?? exactOrigin(params.get('miniappHostOrigin')) ?? exactOrigin(referrer);
|
|
1628
|
+
}
|
|
1629
|
+
const MINIAPP_UI_SCALE_MIN = 12;
|
|
1630
|
+
const MINIAPP_UI_SCALE_MAX = 20;
|
|
1631
|
+
const MINIAPP_UI_SCALE_DEFAULT = 16;
|
|
1632
|
+
const MINIAPP_THEME_CHANGED_EVENTS = new Set([
|
|
1633
|
+
'zephyr-app-theme-changed',
|
|
1634
|
+
'tap-miniapp-theme-changed'
|
|
1635
|
+
]);
|
|
1636
|
+
const MINIAPP_UI_SCALE_CHANGED_EVENT = 'zephyr-app-ui-scale-changed';
|
|
1637
|
+
function isMiniAppTheme(value) {
|
|
1638
|
+
return 'light' === value || 'dark' === value;
|
|
1639
|
+
}
|
|
1640
|
+
function readThemeFromSearch(search) {
|
|
1641
|
+
const params = 'string' == typeof search ? new URLSearchParams(search.startsWith('?') ? search.slice(1) : search) : search;
|
|
1642
|
+
const appTheme = params.get('appTheme');
|
|
1643
|
+
return isMiniAppTheme(appTheme) ? appTheme : 'light';
|
|
1644
|
+
}
|
|
1645
|
+
function getMiniAppThemeFromSearch(search = "u" < typeof window ? '' : window.location.search) {
|
|
1646
|
+
return readThemeFromSearch(search);
|
|
1647
|
+
}
|
|
1648
|
+
function applyMiniAppTheme(theme) {
|
|
1649
|
+
if ("u" < typeof document) return;
|
|
1650
|
+
document.documentElement.dataset.appTheme = theme;
|
|
1651
|
+
document.documentElement.classList.toggle('dark', 'dark' === theme);
|
|
1652
|
+
document.documentElement.classList.toggle('light', 'light' === theme);
|
|
1653
|
+
document.documentElement.style.colorScheme = theme;
|
|
1654
|
+
}
|
|
1655
|
+
function isMiniAppUiScale(value) {
|
|
1656
|
+
return 'number' == typeof value && Number.isInteger(value) && value >= MINIAPP_UI_SCALE_MIN && value <= MINIAPP_UI_SCALE_MAX;
|
|
1657
|
+
}
|
|
1658
|
+
function getMiniAppUiScaleFromSearch(search = "u" < typeof window ? '' : window.location.search) {
|
|
1659
|
+
const params = 'string' == typeof search ? new URLSearchParams(search.startsWith('?') ? search.slice(1) : search) : search;
|
|
1660
|
+
const rawScale = params.get('appUiScale');
|
|
1661
|
+
if (null === rawScale || '' === rawScale.trim()) return MINIAPP_UI_SCALE_DEFAULT;
|
|
1662
|
+
const scale = Number(rawScale);
|
|
1663
|
+
return isMiniAppUiScale(scale) ? scale : MINIAPP_UI_SCALE_DEFAULT;
|
|
1664
|
+
}
|
|
1665
|
+
function applyMiniAppUiScale(scale) {
|
|
1666
|
+
if ("u" < typeof document || !isMiniAppUiScale(scale)) return;
|
|
1667
|
+
document.documentElement.dataset.uiScale = String(scale);
|
|
1668
|
+
document.documentElement.style.setProperty('--app-font-size', `${scale}px`);
|
|
1669
|
+
}
|
|
1670
|
+
function installMiniAppAppearanceSync({ applyTheme = applyMiniAppTheme, applyUiScale = applyMiniAppUiScale, search } = {}) {
|
|
1671
|
+
applyTheme(getMiniAppThemeFromSearch(search));
|
|
1672
|
+
applyUiScale(getMiniAppUiScaleFromSearch(search));
|
|
1673
|
+
if ("u" < typeof window) return ()=>void 0;
|
|
1674
|
+
const hostOrigin = getHostOrigin();
|
|
1675
|
+
const parent = window.parent;
|
|
1676
|
+
if (!hostOrigin || !parent || parent === window) return ()=>void 0;
|
|
1677
|
+
const handleMessage = (event)=>{
|
|
1678
|
+
if (event.source !== parent || event.origin !== hostOrigin) return;
|
|
1679
|
+
if ('object' != typeof event.data || null === event.data) return;
|
|
1680
|
+
const record = event.data;
|
|
1681
|
+
if ('string' == typeof record.type && MINIAPP_THEME_CHANGED_EVENTS.has(record.type) && isMiniAppTheme(record.appTheme)) return void applyTheme(record.appTheme);
|
|
1682
|
+
if (record.type === MINIAPP_UI_SCALE_CHANGED_EVENT && isMiniAppUiScale(record.appUiScale)) applyUiScale(record.appUiScale);
|
|
1683
|
+
};
|
|
1684
|
+
window.addEventListener('message', handleMessage);
|
|
1685
|
+
return ()=>window.removeEventListener('message', handleMessage);
|
|
1686
|
+
}
|
|
1687
|
+
const identifierSchema = z.string().min(1).max(128).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/);
|
|
1688
|
+
const displayTextSchema = z.string().max(4096);
|
|
1689
|
+
const childReferencesSchema = z.array(identifierSchema).max(100);
|
|
1690
|
+
const actionSchema = z.string().min(1).max(128);
|
|
1691
|
+
const entityIdSchema = identifierSchema.optional();
|
|
1692
|
+
const controlStateShape = {
|
|
1693
|
+
disabled: z.boolean().default(false),
|
|
1694
|
+
busy: z.boolean().default(false)
|
|
1695
|
+
};
|
|
1696
|
+
const actionShape = {
|
|
1697
|
+
action: actionSchema,
|
|
1698
|
+
entityId: entityIdSchema
|
|
1699
|
+
};
|
|
1700
|
+
const fieldShape = {
|
|
1701
|
+
description: displayTextSchema.optional(),
|
|
1702
|
+
error: displayTextSchema.optional(),
|
|
1703
|
+
label: displayTextSchema,
|
|
1704
|
+
required: z.boolean().default(false)
|
|
1705
|
+
};
|
|
1706
|
+
const stackNodeSchema = z.object({
|
|
1707
|
+
type: z.literal('stack'),
|
|
1708
|
+
id: identifierSchema,
|
|
1709
|
+
children: childReferencesSchema,
|
|
1710
|
+
gap: z["enum"]([
|
|
1711
|
+
'none',
|
|
1712
|
+
'sm',
|
|
1713
|
+
'md',
|
|
1714
|
+
'lg'
|
|
1715
|
+
]).default('md')
|
|
1716
|
+
}).strict();
|
|
1717
|
+
const rowNodeSchema = z.object({
|
|
1718
|
+
type: z.literal('row'),
|
|
1719
|
+
id: identifierSchema,
|
|
1720
|
+
children: childReferencesSchema,
|
|
1721
|
+
gap: z["enum"]([
|
|
1722
|
+
'none',
|
|
1723
|
+
'sm',
|
|
1724
|
+
'md',
|
|
1725
|
+
'lg'
|
|
1726
|
+
]).default('md'),
|
|
1727
|
+
wrap: z.boolean().default(true)
|
|
1728
|
+
}).strict();
|
|
1729
|
+
const toolbarNodeSchema = z.object({
|
|
1730
|
+
type: z.literal('toolbar'),
|
|
1731
|
+
id: identifierSchema,
|
|
1732
|
+
label: displayTextSchema,
|
|
1733
|
+
children: childReferencesSchema
|
|
1734
|
+
}).strict();
|
|
1735
|
+
const statusBarNodeSchema = z.object({
|
|
1736
|
+
type: z.literal('status-bar'),
|
|
1737
|
+
id: identifierSchema,
|
|
1738
|
+
text: displayTextSchema,
|
|
1739
|
+
tone: z["enum"]([
|
|
1740
|
+
'error',
|
|
1741
|
+
'neutral',
|
|
1742
|
+
'success'
|
|
1743
|
+
]).default('neutral')
|
|
1744
|
+
}).strict();
|
|
1745
|
+
const headingNodeSchema = z.object({
|
|
1746
|
+
type: z.literal('heading'),
|
|
1747
|
+
id: identifierSchema,
|
|
1748
|
+
level: z.number().int().min(1).max(6),
|
|
1749
|
+
text: displayTextSchema
|
|
1750
|
+
}).strict();
|
|
1751
|
+
const textNodeSchema = z.object({
|
|
1752
|
+
type: z.literal('text'),
|
|
1753
|
+
id: identifierSchema,
|
|
1754
|
+
text: displayTextSchema,
|
|
1755
|
+
tone: z["enum"]([
|
|
1756
|
+
'default',
|
|
1757
|
+
'muted'
|
|
1758
|
+
]).default('default')
|
|
1759
|
+
}).strict();
|
|
1760
|
+
const buttonNodeSchema = z.object({
|
|
1761
|
+
type: z.literal('button'),
|
|
1762
|
+
id: identifierSchema,
|
|
1763
|
+
label: displayTextSchema,
|
|
1764
|
+
...actionShape,
|
|
1765
|
+
...controlStateShape,
|
|
1766
|
+
variant: z["enum"]([
|
|
1767
|
+
'default',
|
|
1768
|
+
'destructive',
|
|
1769
|
+
'outline',
|
|
1770
|
+
'secondary',
|
|
1771
|
+
'tertiary',
|
|
1772
|
+
'ghost',
|
|
1773
|
+
'link'
|
|
1774
|
+
]).default('default')
|
|
1775
|
+
}).strict();
|
|
1776
|
+
const iconButtonNodeSchema = z.object({
|
|
1777
|
+
type: z.literal('icon-button'),
|
|
1778
|
+
id: identifierSchema,
|
|
1779
|
+
label: displayTextSchema,
|
|
1780
|
+
icon: z["enum"]([
|
|
1781
|
+
'add',
|
|
1782
|
+
'check',
|
|
1783
|
+
'close',
|
|
1784
|
+
'delete',
|
|
1785
|
+
'help',
|
|
1786
|
+
'info',
|
|
1787
|
+
'refresh',
|
|
1788
|
+
'search',
|
|
1789
|
+
'settings'
|
|
1790
|
+
]),
|
|
1791
|
+
...actionShape,
|
|
1792
|
+
...controlStateShape,
|
|
1793
|
+
variant: z["enum"]([
|
|
1794
|
+
'default',
|
|
1795
|
+
'destructive',
|
|
1796
|
+
'outline',
|
|
1797
|
+
'secondary',
|
|
1798
|
+
'ghost'
|
|
1799
|
+
]).default('ghost')
|
|
1800
|
+
}).strict();
|
|
1801
|
+
const buttonGroupNodeSchema = z.object({
|
|
1802
|
+
type: z.literal('button-group'),
|
|
1803
|
+
id: identifierSchema,
|
|
1804
|
+
label: displayTextSchema,
|
|
1805
|
+
children: childReferencesSchema
|
|
1806
|
+
}).strict();
|
|
1807
|
+
const badgeNodeSchema = z.object({
|
|
1808
|
+
type: z.literal('badge'),
|
|
1809
|
+
id: identifierSchema,
|
|
1810
|
+
text: displayTextSchema,
|
|
1811
|
+
variant: z["enum"]([
|
|
1812
|
+
'default',
|
|
1813
|
+
'secondary',
|
|
1814
|
+
'destructive',
|
|
1815
|
+
'outline'
|
|
1816
|
+
]).default('default')
|
|
1817
|
+
}).strict();
|
|
1818
|
+
const cardNodeSchema = z.object({
|
|
1819
|
+
type: z.literal('card'),
|
|
1820
|
+
id: identifierSchema,
|
|
1821
|
+
title: displayTextSchema.optional(),
|
|
1822
|
+
description: displayTextSchema.optional(),
|
|
1823
|
+
children: childReferencesSchema
|
|
1824
|
+
}).strict();
|
|
1825
|
+
const itemNodeSchema = z.object({
|
|
1826
|
+
type: z.literal('item'),
|
|
1827
|
+
id: identifierSchema,
|
|
1828
|
+
title: displayTextSchema,
|
|
1829
|
+
description: displayTextSchema.optional(),
|
|
1830
|
+
children: childReferencesSchema
|
|
1831
|
+
}).strict();
|
|
1832
|
+
const tabsNodeSchema = z.object({
|
|
1833
|
+
type: z.literal('tabs'),
|
|
1834
|
+
id: identifierSchema,
|
|
1835
|
+
value: identifierSchema,
|
|
1836
|
+
action: actionSchema,
|
|
1837
|
+
entityId: entityIdSchema,
|
|
1838
|
+
disabled: z.boolean().default(false),
|
|
1839
|
+
tabs: z.array(z.object({
|
|
1840
|
+
id: identifierSchema,
|
|
1841
|
+
label: displayTextSchema,
|
|
1842
|
+
children: childReferencesSchema,
|
|
1843
|
+
disabled: z.boolean().default(false)
|
|
1844
|
+
}).strict()).min(1).max(20)
|
|
1845
|
+
}).strict();
|
|
1846
|
+
const alertNodeSchema = z.object({
|
|
1847
|
+
type: z.literal('alert'),
|
|
1848
|
+
id: identifierSchema,
|
|
1849
|
+
title: displayTextSchema,
|
|
1850
|
+
description: displayTextSchema.optional(),
|
|
1851
|
+
tone: z["enum"]([
|
|
1852
|
+
'default',
|
|
1853
|
+
'info',
|
|
1854
|
+
'destructive',
|
|
1855
|
+
'warning',
|
|
1856
|
+
'success'
|
|
1857
|
+
]).default('default')
|
|
1858
|
+
}).strict();
|
|
1859
|
+
const emptyNodeSchema = z.object({
|
|
1860
|
+
type: z.literal('empty'),
|
|
1861
|
+
id: identifierSchema,
|
|
1862
|
+
title: displayTextSchema,
|
|
1863
|
+
description: displayTextSchema.optional(),
|
|
1864
|
+
children: childReferencesSchema
|
|
1865
|
+
}).strict();
|
|
1866
|
+
const loadingNodeSchema = z.object({
|
|
1867
|
+
type: z.literal('loading'),
|
|
1868
|
+
id: identifierSchema,
|
|
1869
|
+
label: displayTextSchema,
|
|
1870
|
+
rows: z.number().int().min(1).max(12).default(3)
|
|
1871
|
+
}).strict();
|
|
1872
|
+
const inputNodeSchema = z.object({
|
|
1873
|
+
type: z.literal('input'),
|
|
1874
|
+
id: identifierSchema,
|
|
1875
|
+
...fieldShape,
|
|
1876
|
+
...actionShape,
|
|
1877
|
+
...controlStateShape,
|
|
1878
|
+
value: z.string().max(16384),
|
|
1879
|
+
inputType: z["enum"]([
|
|
1880
|
+
'text',
|
|
1881
|
+
'email',
|
|
1882
|
+
'password',
|
|
1883
|
+
'search'
|
|
1884
|
+
]).default('text'),
|
|
1885
|
+
placeholder: displayTextSchema.optional()
|
|
1886
|
+
}).strict();
|
|
1887
|
+
const textareaNodeSchema = z.object({
|
|
1888
|
+
type: z.literal('textarea'),
|
|
1889
|
+
id: identifierSchema,
|
|
1890
|
+
...fieldShape,
|
|
1891
|
+
...actionShape,
|
|
1892
|
+
...controlStateShape,
|
|
1893
|
+
value: z.string().max(65536),
|
|
1894
|
+
placeholder: displayTextSchema.optional(),
|
|
1895
|
+
rows: z.number().int().min(2).max(20).default(4)
|
|
1896
|
+
}).strict();
|
|
1897
|
+
const selectNodeSchema = z.object({
|
|
1898
|
+
type: z.literal('select'),
|
|
1899
|
+
id: identifierSchema,
|
|
1900
|
+
...fieldShape,
|
|
1901
|
+
...actionShape,
|
|
1902
|
+
...controlStateShape,
|
|
1903
|
+
value: z.string().max(4096),
|
|
1904
|
+
options: z.array(z.object({
|
|
1905
|
+
value: z.string().max(4096),
|
|
1906
|
+
label: displayTextSchema,
|
|
1907
|
+
disabled: z.boolean().default(false)
|
|
1908
|
+
}).strict()).max(100)
|
|
1909
|
+
}).strict();
|
|
1910
|
+
const checkboxNodeSchema = z.object({
|
|
1911
|
+
type: z.literal('checkbox'),
|
|
1912
|
+
id: identifierSchema,
|
|
1913
|
+
...fieldShape,
|
|
1914
|
+
...actionShape,
|
|
1915
|
+
...controlStateShape,
|
|
1916
|
+
checked: z.boolean()
|
|
1917
|
+
}).strict();
|
|
1918
|
+
const progressNodeSchema = z.object({
|
|
1919
|
+
type: z.literal('progress'),
|
|
1920
|
+
id: identifierSchema,
|
|
1921
|
+
label: displayTextSchema,
|
|
1922
|
+
value: z.number().finite().min(0).max(100)
|
|
1923
|
+
}).strict();
|
|
1924
|
+
const tooltipNodeSchema = z.object({
|
|
1925
|
+
type: z.literal('tooltip'),
|
|
1926
|
+
id: identifierSchema,
|
|
1927
|
+
label: displayTextSchema,
|
|
1928
|
+
child: identifierSchema
|
|
1929
|
+
}).strict();
|
|
1930
|
+
const dialogActionSchema = z.object({
|
|
1931
|
+
id: identifierSchema,
|
|
1932
|
+
label: displayTextSchema,
|
|
1933
|
+
action: actionSchema,
|
|
1934
|
+
variant: z["enum"]([
|
|
1935
|
+
'default',
|
|
1936
|
+
'destructive',
|
|
1937
|
+
'outline',
|
|
1938
|
+
'secondary',
|
|
1939
|
+
'ghost'
|
|
1940
|
+
]).default('default'),
|
|
1941
|
+
disabled: z.boolean().default(false)
|
|
1942
|
+
}).strict();
|
|
1943
|
+
const dialogNodeSchema = z.object({
|
|
1944
|
+
type: z.literal('dialog'),
|
|
1945
|
+
id: identifierSchema,
|
|
1946
|
+
entityId: entityIdSchema,
|
|
1947
|
+
open: z.boolean(),
|
|
1948
|
+
openChangeAction: actionSchema,
|
|
1949
|
+
title: displayTextSchema,
|
|
1950
|
+
description: displayTextSchema.optional(),
|
|
1951
|
+
children: childReferencesSchema,
|
|
1952
|
+
actions: z.array(dialogActionSchema).max(10)
|
|
1953
|
+
}).strict();
|
|
1954
|
+
const confirmationNodeSchema = z.object({
|
|
1955
|
+
type: z.literal('confirmation'),
|
|
1956
|
+
id: identifierSchema,
|
|
1957
|
+
entityId: entityIdSchema,
|
|
1958
|
+
open: z.boolean(),
|
|
1959
|
+
openChangeAction: actionSchema,
|
|
1960
|
+
title: displayTextSchema,
|
|
1961
|
+
description: displayTextSchema,
|
|
1962
|
+
confirm: dialogActionSchema,
|
|
1963
|
+
cancelLabel: displayTextSchema.default('Cancel')
|
|
1964
|
+
}).strict();
|
|
1965
|
+
const separatorNodeSchema = z.object({
|
|
1966
|
+
type: z.literal('separator'),
|
|
1967
|
+
id: identifierSchema
|
|
1968
|
+
}).strict();
|
|
1969
|
+
const metricNodeSchema = z.object({
|
|
1970
|
+
type: z.literal('metric'),
|
|
1971
|
+
id: identifierSchema,
|
|
1972
|
+
label: displayTextSchema,
|
|
1973
|
+
value: displayTextSchema,
|
|
1974
|
+
detail: displayTextSchema.optional(),
|
|
1975
|
+
badge: displayTextSchema.optional()
|
|
1976
|
+
}).strict();
|
|
1977
|
+
const miniAppUiNodeSchema = z.discriminatedUnion('type', [
|
|
1978
|
+
stackNodeSchema,
|
|
1979
|
+
rowNodeSchema,
|
|
1980
|
+
toolbarNodeSchema,
|
|
1981
|
+
statusBarNodeSchema,
|
|
1982
|
+
headingNodeSchema,
|
|
1983
|
+
textNodeSchema,
|
|
1984
|
+
buttonNodeSchema,
|
|
1985
|
+
iconButtonNodeSchema,
|
|
1986
|
+
buttonGroupNodeSchema,
|
|
1987
|
+
badgeNodeSchema,
|
|
1988
|
+
cardNodeSchema,
|
|
1989
|
+
itemNodeSchema,
|
|
1990
|
+
tabsNodeSchema,
|
|
1991
|
+
alertNodeSchema,
|
|
1992
|
+
emptyNodeSchema,
|
|
1993
|
+
loadingNodeSchema,
|
|
1994
|
+
inputNodeSchema,
|
|
1995
|
+
textareaNodeSchema,
|
|
1996
|
+
selectNodeSchema,
|
|
1997
|
+
checkboxNodeSchema,
|
|
1998
|
+
progressNodeSchema,
|
|
1999
|
+
tooltipNodeSchema,
|
|
2000
|
+
dialogNodeSchema,
|
|
2001
|
+
confirmationNodeSchema,
|
|
2002
|
+
separatorNodeSchema,
|
|
2003
|
+
metricNodeSchema
|
|
2004
|
+
]);
|
|
2005
|
+
function childReferences(node) {
|
|
2006
|
+
switch(node.type){
|
|
2007
|
+
case 'stack':
|
|
2008
|
+
case 'row':
|
|
2009
|
+
case 'toolbar':
|
|
2010
|
+
case 'button-group':
|
|
2011
|
+
case 'card':
|
|
2012
|
+
case 'item':
|
|
2013
|
+
case 'empty':
|
|
2014
|
+
case 'dialog':
|
|
2015
|
+
return node.children;
|
|
2016
|
+
case 'tabs':
|
|
2017
|
+
return node.tabs.flatMap((tab)=>tab.children);
|
|
2018
|
+
case 'tooltip':
|
|
2019
|
+
return [
|
|
2020
|
+
node.child
|
|
2021
|
+
];
|
|
2022
|
+
default:
|
|
2023
|
+
return [];
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
const baseModelSchema = z.object({
|
|
2027
|
+
revision: z.number().int().nonnegative(),
|
|
2028
|
+
state: z["enum"]([
|
|
2029
|
+
'idle',
|
|
2030
|
+
'loading',
|
|
2031
|
+
'empty',
|
|
2032
|
+
'success',
|
|
2033
|
+
'conflict',
|
|
2034
|
+
'failure'
|
|
2035
|
+
]).default('idle'),
|
|
2036
|
+
rootIds: z.array(identifierSchema).min(1).max(100),
|
|
2037
|
+
nodes: z.array(miniAppUiNodeSchema).min(1).max(500)
|
|
2038
|
+
}).strict();
|
|
2039
|
+
const miniAppUiModelSchema = baseModelSchema.superRefine((model, context)=>{
|
|
2040
|
+
const nodes = new Map();
|
|
2041
|
+
for (const [index, node] of model.nodes.entries()){
|
|
2042
|
+
if (nodes.has(node.id)) context.addIssue({
|
|
2043
|
+
code: 'custom',
|
|
2044
|
+
message: `Duplicate node id: ${node.id}`,
|
|
2045
|
+
path: [
|
|
2046
|
+
'nodes',
|
|
2047
|
+
index,
|
|
2048
|
+
'id'
|
|
2049
|
+
]
|
|
2050
|
+
});
|
|
2051
|
+
nodes.set(node.id, node);
|
|
2052
|
+
}
|
|
2053
|
+
const ownership = new Map();
|
|
2054
|
+
const own = (id, path)=>{
|
|
2055
|
+
if (!nodes.has(id)) return void context.addIssue({
|
|
2056
|
+
code: 'custom',
|
|
2057
|
+
message: `Unknown node reference: ${id}`,
|
|
2058
|
+
path
|
|
2059
|
+
});
|
|
2060
|
+
ownership.set(id, (ownership.get(id) ?? 0) + 1);
|
|
2061
|
+
};
|
|
2062
|
+
model.rootIds.forEach((id, index)=>own(id, [
|
|
2063
|
+
'rootIds',
|
|
2064
|
+
index
|
|
2065
|
+
]));
|
|
2066
|
+
model.nodes.forEach((node, index)=>{
|
|
2067
|
+
childReferences(node).forEach((id, childIndex)=>own(id, [
|
|
2068
|
+
'nodes',
|
|
2069
|
+
index,
|
|
2070
|
+
'children',
|
|
2071
|
+
childIndex
|
|
2072
|
+
]));
|
|
2073
|
+
});
|
|
2074
|
+
for (const node of model.nodes){
|
|
2075
|
+
const owners = ownership.get(node.id) ?? 0;
|
|
2076
|
+
if (1 !== owners) context.addIssue({
|
|
2077
|
+
code: 'custom',
|
|
2078
|
+
message: 0 === owners ? `Unreachable node: ${node.id}` : `Node must have exactly one owner: ${node.id}`,
|
|
2079
|
+
path: [
|
|
2080
|
+
'nodes'
|
|
2081
|
+
]
|
|
2082
|
+
});
|
|
2083
|
+
}
|
|
2084
|
+
const active = new Set();
|
|
2085
|
+
const visited = new Set();
|
|
2086
|
+
const visit = (id, depth)=>{
|
|
2087
|
+
if (active.has(id)) return void context.addIssue({
|
|
2088
|
+
code: 'custom',
|
|
2089
|
+
message: `Cycle detected at node: ${id}`,
|
|
2090
|
+
path: [
|
|
2091
|
+
'nodes'
|
|
2092
|
+
]
|
|
2093
|
+
});
|
|
2094
|
+
if (visited.has(id) || depth > 32) {
|
|
2095
|
+
if (depth > 32) context.addIssue({
|
|
2096
|
+
code: 'custom',
|
|
2097
|
+
message: 'UI model exceeds the maximum depth of 32',
|
|
2098
|
+
path: [
|
|
2099
|
+
'nodes'
|
|
2100
|
+
]
|
|
2101
|
+
});
|
|
2102
|
+
return;
|
|
2103
|
+
}
|
|
2104
|
+
const node = nodes.get(id);
|
|
2105
|
+
if (!node) return;
|
|
2106
|
+
active.add(id);
|
|
2107
|
+
childReferences(node).forEach((childId)=>visit(childId, depth + 1));
|
|
2108
|
+
active.delete(id);
|
|
2109
|
+
visited.add(id);
|
|
2110
|
+
};
|
|
2111
|
+
model.rootIds.forEach((id)=>visit(id, 1));
|
|
2112
|
+
for (const node of model.nodes){
|
|
2113
|
+
if ('tabs' === node.type && !node.tabs.some((tab)=>tab.id === node.value)) context.addIssue({
|
|
2114
|
+
code: 'custom',
|
|
2115
|
+
message: `Tabs value does not identify a tab: ${node.value}`,
|
|
2116
|
+
path: [
|
|
2117
|
+
'nodes'
|
|
2118
|
+
]
|
|
2119
|
+
});
|
|
2120
|
+
if ('tooltip' === node.type) {
|
|
2121
|
+
const target = nodes.get(node.child);
|
|
2122
|
+
if (target && 'button' !== target.type && 'icon-button' !== target.type) context.addIssue({
|
|
2123
|
+
code: 'custom',
|
|
2124
|
+
message: 'Tooltip child must be a button or icon-button',
|
|
2125
|
+
path: [
|
|
2126
|
+
'nodes'
|
|
2127
|
+
]
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
const openOverlays = model.nodes.filter((node)=>('dialog' === node.type || 'confirmation' === node.type) && node.open);
|
|
2132
|
+
if (openOverlays.length > 1) context.addIssue({
|
|
2133
|
+
code: 'custom',
|
|
2134
|
+
message: 'Only one controlled dialog may be open at a time',
|
|
2135
|
+
path: [
|
|
2136
|
+
'nodes'
|
|
2137
|
+
]
|
|
2138
|
+
});
|
|
2139
|
+
});
|
|
2140
|
+
const miniAppUiEventKindSchema = z["enum"]([
|
|
2141
|
+
'activate',
|
|
2142
|
+
'value-change',
|
|
2143
|
+
'selection-change',
|
|
2144
|
+
'open-change'
|
|
2145
|
+
]);
|
|
2146
|
+
const miniAppUiActionSchema = z.object({
|
|
2147
|
+
eventId: identifierSchema,
|
|
2148
|
+
revision: z.number().int().nonnegative(),
|
|
2149
|
+
controlId: identifierSchema,
|
|
2150
|
+
entityId: identifierSchema.optional(),
|
|
2151
|
+
action: actionSchema,
|
|
2152
|
+
event: miniAppUiEventKindSchema,
|
|
2153
|
+
value: z.union([
|
|
2154
|
+
z.string(),
|
|
2155
|
+
z.number(),
|
|
2156
|
+
z.boolean(),
|
|
2157
|
+
z["null"]()
|
|
2158
|
+
]).optional()
|
|
2159
|
+
}).strict();
|
|
2160
|
+
class MiniAppUiError extends Error {
|
|
2161
|
+
code;
|
|
2162
|
+
cause;
|
|
2163
|
+
constructor(code, message, cause){
|
|
2164
|
+
super(message);
|
|
2165
|
+
this.name = 'MiniAppUiError';
|
|
2166
|
+
this.code = code;
|
|
2167
|
+
this.cause = cause;
|
|
2168
|
+
}
|
|
2169
|
+
}
|
|
2170
|
+
const ICONS = {
|
|
2171
|
+
add: Plus,
|
|
2172
|
+
check: Check,
|
|
2173
|
+
close: X,
|
|
2174
|
+
delete: Trash2,
|
|
2175
|
+
help: CircleHelp,
|
|
2176
|
+
info: Info,
|
|
2177
|
+
refresh: RefreshCw,
|
|
2178
|
+
search: Search,
|
|
2179
|
+
settings: Settings
|
|
2180
|
+
};
|
|
2181
|
+
const GAP_CLASSES = {
|
|
2182
|
+
none: 'gap-0',
|
|
2183
|
+
sm: 'gap-2',
|
|
2184
|
+
md: 'gap-4',
|
|
2185
|
+
lg: 'gap-6'
|
|
2186
|
+
};
|
|
2187
|
+
let nextMiniAppUiRootId = 0;
|
|
2188
|
+
function modelError(cause) {
|
|
2189
|
+
return new MiniAppUiError('invalid-model', 'The mini-app UI model is invalid.', cause);
|
|
2190
|
+
}
|
|
2191
|
+
function parseModel(value) {
|
|
2192
|
+
const result = miniAppUiModelSchema.safeParse(value);
|
|
2193
|
+
if (!result.success) throw modelError(result.error);
|
|
2194
|
+
return result.data;
|
|
2195
|
+
}
|
|
2196
|
+
function eventValue(target) {
|
|
2197
|
+
return target instanceof HTMLInputElement || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement ? target.value : '';
|
|
2198
|
+
}
|
|
2199
|
+
function emitAction(context, control, event, value) {
|
|
2200
|
+
if (context.revision !== context.getCurrentRevision()) return void context.reportError(new MiniAppUiError('stale-action', `Rejected an action from stale revision ${context.revision}.`));
|
|
2201
|
+
const action = miniAppUiActionSchema.parse({
|
|
2202
|
+
eventId: context.nextEventId(context.revision),
|
|
2203
|
+
revision: context.revision,
|
|
2204
|
+
controlId: control.id,
|
|
2205
|
+
entityId: control.entityId,
|
|
2206
|
+
action: control.action,
|
|
2207
|
+
event,
|
|
2208
|
+
value
|
|
2209
|
+
});
|
|
2210
|
+
try {
|
|
2211
|
+
const result = context.dispatch(action);
|
|
2212
|
+
Promise.resolve(result).catch((cause)=>{
|
|
2213
|
+
context.reportError(new MiniAppUiError('dispatch-failed', `Action dispatch failed for ${control.id}.`, cause));
|
|
2214
|
+
});
|
|
2215
|
+
} catch (cause) {
|
|
2216
|
+
context.reportError(new MiniAppUiError('dispatch-failed', `Action dispatch failed for ${control.id}.`, cause));
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
function fieldContent(node) {
|
|
2220
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(__rspack_external_react.Fragment, null, node.description ? /*#__PURE__*/ __rspack_external_react.createElement(FieldDescription, null, node.description) : null, node.error ? /*#__PURE__*/ __rspack_external_react.createElement(FieldError, null, node.error) : null);
|
|
2221
|
+
}
|
|
2222
|
+
function heading(level, text, id) {
|
|
2223
|
+
const props = {
|
|
2224
|
+
children: text,
|
|
2225
|
+
'data-component': 'mini-app-wasm-heading',
|
|
2226
|
+
key: id
|
|
2227
|
+
};
|
|
2228
|
+
switch(level){
|
|
2229
|
+
case 1:
|
|
2230
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H1, props);
|
|
2231
|
+
case 2:
|
|
2232
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H2, props);
|
|
2233
|
+
case 3:
|
|
2234
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H3, props);
|
|
2235
|
+
case 4:
|
|
2236
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H4, props);
|
|
2237
|
+
case 5:
|
|
2238
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H5, props);
|
|
2239
|
+
default:
|
|
2240
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(H6, props);
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
function renderReferences(ids, context) {
|
|
2244
|
+
return ids.map((id)=>renderReference(id, context));
|
|
2245
|
+
}
|
|
2246
|
+
function renderReference(id, context) {
|
|
2247
|
+
const node = context.nodes.get(id);
|
|
2248
|
+
if (!node) throw new MiniAppUiError('render-failed', `Validated node ${id} is unavailable during render.`);
|
|
2249
|
+
const control = {
|
|
2250
|
+
id: node.id,
|
|
2251
|
+
entityId: 'entityId' in node ? node.entityId : void 0
|
|
2252
|
+
};
|
|
2253
|
+
const controlProps = {
|
|
2254
|
+
'data-miniapp-control-id': node.id,
|
|
2255
|
+
'data-miniapp-root-id': context.rootId
|
|
2256
|
+
};
|
|
2257
|
+
switch(node.type){
|
|
2258
|
+
case 'stack':
|
|
2259
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2260
|
+
key: node.id,
|
|
2261
|
+
"data-component": "mini-app-wasm-stack",
|
|
2262
|
+
className: utils_cn('flex min-w-0 flex-col', GAP_CLASSES[node.gap])
|
|
2263
|
+
}, renderReferences(node.children, context));
|
|
2264
|
+
case 'row':
|
|
2265
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2266
|
+
key: node.id,
|
|
2267
|
+
"data-component": "mini-app-wasm-row",
|
|
2268
|
+
className: utils_cn('flex min-w-0 items-center', node.wrap && 'flex-wrap', GAP_CLASSES[node.gap])
|
|
2269
|
+
}, renderReferences(node.children, context));
|
|
2270
|
+
case 'toolbar':
|
|
2271
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(MiniAppToolbar, {
|
|
2272
|
+
key: node.id,
|
|
2273
|
+
"aria-label": node.label
|
|
2274
|
+
}, renderReferences(node.children, context));
|
|
2275
|
+
case 'status-bar':
|
|
2276
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(MiniAppStatusBar, {
|
|
2277
|
+
key: node.id,
|
|
2278
|
+
tone: node.tone
|
|
2279
|
+
}, node.text);
|
|
2280
|
+
case 'heading':
|
|
2281
|
+
return heading(node.level, node.text, node.id);
|
|
2282
|
+
case 'text':
|
|
2283
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("p", {
|
|
2284
|
+
key: node.id,
|
|
2285
|
+
"data-component": "mini-app-wasm-text",
|
|
2286
|
+
className: utils_cn('text-sm', 'muted' === node.tone && 'text-muted-foreground')
|
|
2287
|
+
}, node.text);
|
|
2288
|
+
case 'button':
|
|
2289
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(button_Button, {
|
|
2290
|
+
key: node.id,
|
|
2291
|
+
...controlProps,
|
|
2292
|
+
type: "button",
|
|
2293
|
+
variant: node.variant,
|
|
2294
|
+
disabled: node.disabled || node.busy,
|
|
2295
|
+
"aria-busy": node.busy,
|
|
2296
|
+
onClick: ()=>emitAction(context, {
|
|
2297
|
+
...control,
|
|
2298
|
+
action: node.action
|
|
2299
|
+
}, 'activate')
|
|
2300
|
+
}, node.label);
|
|
2301
|
+
case 'icon-button':
|
|
2302
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(MiniAppIconButton, {
|
|
2303
|
+
key: node.id,
|
|
2304
|
+
...controlProps,
|
|
2305
|
+
icon: ICONS[node.icon],
|
|
2306
|
+
label: node.label,
|
|
2307
|
+
variant: node.variant,
|
|
2308
|
+
disabled: node.disabled || node.busy,
|
|
2309
|
+
"aria-busy": node.busy,
|
|
2310
|
+
onClick: ()=>emitAction(context, {
|
|
2311
|
+
...control,
|
|
2312
|
+
action: node.action
|
|
2313
|
+
}, 'activate')
|
|
2314
|
+
});
|
|
2315
|
+
case 'button-group':
|
|
2316
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(ButtonGroup, {
|
|
2317
|
+
key: node.id,
|
|
2318
|
+
"aria-label": node.label
|
|
2319
|
+
}, renderReferences(node.children, context));
|
|
2320
|
+
case 'badge':
|
|
2321
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Badge, {
|
|
2322
|
+
key: node.id,
|
|
2323
|
+
variant: node.variant
|
|
2324
|
+
}, node.text);
|
|
2325
|
+
case 'card':
|
|
2326
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Card, {
|
|
2327
|
+
key: node.id,
|
|
2328
|
+
"data-component": "mini-app-wasm-card",
|
|
2329
|
+
className: "border"
|
|
2330
|
+
}, node.title || node.description ? /*#__PURE__*/ __rspack_external_react.createElement(CardHeader, null, node.title ? /*#__PURE__*/ __rspack_external_react.createElement(CardTitle, null, node.title) : null, node.description ? /*#__PURE__*/ __rspack_external_react.createElement(CardDescription, null, node.description) : null) : null, /*#__PURE__*/ __rspack_external_react.createElement(CardContent, {
|
|
2331
|
+
className: utils_cn(!node.title && !node.description && 'pt-6')
|
|
2332
|
+
}, renderReferences(node.children, context)));
|
|
2333
|
+
case 'item':
|
|
2334
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Item, {
|
|
2335
|
+
key: node.id,
|
|
2336
|
+
"data-component": "mini-app-wasm-item",
|
|
2337
|
+
variant: "outline"
|
|
2338
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(ItemContent, null, /*#__PURE__*/ __rspack_external_react.createElement(ItemTitle, null, node.title), node.description ? /*#__PURE__*/ __rspack_external_react.createElement(ItemDescription, null, node.description) : null), renderReferences(node.children, context));
|
|
2339
|
+
case 'tabs':
|
|
2340
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Tabs, {
|
|
2341
|
+
key: node.id,
|
|
2342
|
+
...controlProps,
|
|
2343
|
+
value: node.value,
|
|
2344
|
+
onValueChange: (value)=>emitAction(context, {
|
|
2345
|
+
...control,
|
|
2346
|
+
action: node.action
|
|
2347
|
+
}, 'selection-change', value)
|
|
2348
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(TabsList, {
|
|
2349
|
+
"aria-disabled": node.disabled
|
|
2350
|
+
}, node.tabs.map((tab)=>/*#__PURE__*/ __rspack_external_react.createElement(TabsTrigger, {
|
|
2351
|
+
key: tab.id,
|
|
2352
|
+
value: tab.id,
|
|
2353
|
+
disabled: node.disabled || tab.disabled
|
|
2354
|
+
}, tab.label))), node.tabs.map((tab)=>/*#__PURE__*/ __rspack_external_react.createElement(TabsContent, {
|
|
2355
|
+
key: tab.id,
|
|
2356
|
+
value: tab.id
|
|
2357
|
+
}, renderReferences(tab.children, context))));
|
|
2358
|
+
case 'alert':
|
|
2359
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Alert, {
|
|
2360
|
+
key: node.id,
|
|
2361
|
+
variant: node.tone
|
|
2362
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(AlertTitle, null, node.title), node.description ? /*#__PURE__*/ __rspack_external_react.createElement(AlertDescription, null, node.description) : null);
|
|
2363
|
+
case 'empty':
|
|
2364
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Empty, {
|
|
2365
|
+
key: node.id,
|
|
2366
|
+
variant: "outline"
|
|
2367
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(EmptyHeader, null, /*#__PURE__*/ __rspack_external_react.createElement(EmptyTitle, null, node.title), node.description ? /*#__PURE__*/ __rspack_external_react.createElement(EmptyDescription, null, node.description) : null), /*#__PURE__*/ __rspack_external_react.createElement(EmptyContent, null, renderReferences(node.children, context)));
|
|
2368
|
+
case 'loading':
|
|
2369
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2370
|
+
key: node.id,
|
|
2371
|
+
role: "status",
|
|
2372
|
+
"aria-label": node.label,
|
|
2373
|
+
className: "space-y-3"
|
|
2374
|
+
}, Array.from({
|
|
2375
|
+
length: node.rows
|
|
2376
|
+
}, (_, index)=>/*#__PURE__*/ __rspack_external_react.createElement(Skeleton, {
|
|
2377
|
+
key: `${node.id}-${index}`,
|
|
2378
|
+
className: "h-8 w-full motion-reduce:animate-none"
|
|
2379
|
+
})));
|
|
2380
|
+
case 'input':
|
|
2381
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Field, {
|
|
2382
|
+
key: node.id,
|
|
2383
|
+
"data-invalid": Boolean(node.error),
|
|
2384
|
+
"data-disabled": node.disabled
|
|
2385
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(FieldLabel, {
|
|
2386
|
+
htmlFor: node.id
|
|
2387
|
+
}, node.label), /*#__PURE__*/ __rspack_external_react.createElement(input_Input, {
|
|
2388
|
+
...controlProps,
|
|
2389
|
+
id: node.id,
|
|
2390
|
+
type: node.inputType,
|
|
2391
|
+
value: node.value,
|
|
2392
|
+
required: node.required,
|
|
2393
|
+
disabled: node.disabled || node.busy,
|
|
2394
|
+
"aria-invalid": Boolean(node.error),
|
|
2395
|
+
"aria-busy": node.busy,
|
|
2396
|
+
placeholder: node.placeholder,
|
|
2397
|
+
onChange: (event)=>emitAction(context, {
|
|
2398
|
+
...control,
|
|
2399
|
+
action: node.action
|
|
2400
|
+
}, 'value-change', eventValue(event.currentTarget))
|
|
2401
|
+
}), fieldContent(node));
|
|
2402
|
+
case 'textarea':
|
|
2403
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Field, {
|
|
2404
|
+
key: node.id,
|
|
2405
|
+
"data-invalid": Boolean(node.error),
|
|
2406
|
+
"data-disabled": node.disabled
|
|
2407
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(FieldLabel, {
|
|
2408
|
+
htmlFor: node.id
|
|
2409
|
+
}, node.label), /*#__PURE__*/ __rspack_external_react.createElement(Textarea, {
|
|
2410
|
+
...controlProps,
|
|
2411
|
+
id: node.id,
|
|
2412
|
+
value: node.value,
|
|
2413
|
+
rows: node.rows,
|
|
2414
|
+
required: node.required,
|
|
2415
|
+
disabled: node.disabled || node.busy,
|
|
2416
|
+
"aria-invalid": Boolean(node.error),
|
|
2417
|
+
"aria-busy": node.busy,
|
|
2418
|
+
placeholder: node.placeholder,
|
|
2419
|
+
onChange: (event)=>emitAction(context, {
|
|
2420
|
+
...control,
|
|
2421
|
+
action: node.action
|
|
2422
|
+
}, 'value-change', eventValue(event.currentTarget))
|
|
2423
|
+
}), fieldContent(node));
|
|
2424
|
+
case 'select':
|
|
2425
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Field, {
|
|
2426
|
+
key: node.id,
|
|
2427
|
+
"data-invalid": Boolean(node.error),
|
|
2428
|
+
"data-disabled": node.disabled
|
|
2429
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(FieldLabel, {
|
|
2430
|
+
htmlFor: node.id
|
|
2431
|
+
}, node.label), /*#__PURE__*/ __rspack_external_react.createElement(NativeSelect, {
|
|
2432
|
+
...controlProps,
|
|
2433
|
+
id: node.id,
|
|
2434
|
+
value: node.value,
|
|
2435
|
+
required: node.required,
|
|
2436
|
+
disabled: node.disabled || node.busy,
|
|
2437
|
+
"aria-invalid": Boolean(node.error),
|
|
2438
|
+
"aria-busy": node.busy,
|
|
2439
|
+
onChange: (event)=>emitAction(context, {
|
|
2440
|
+
...control,
|
|
2441
|
+
action: node.action
|
|
2442
|
+
}, 'selection-change', eventValue(event.currentTarget))
|
|
2443
|
+
}, node.options.map((option)=>/*#__PURE__*/ __rspack_external_react.createElement(NativeSelectOption, {
|
|
2444
|
+
key: option.value,
|
|
2445
|
+
value: option.value,
|
|
2446
|
+
disabled: option.disabled
|
|
2447
|
+
}, option.label))), fieldContent(node));
|
|
2448
|
+
case 'checkbox':
|
|
2449
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Field, {
|
|
2450
|
+
key: node.id,
|
|
2451
|
+
orientation: "horizontal",
|
|
2452
|
+
"data-invalid": Boolean(node.error)
|
|
2453
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(Checkbox, {
|
|
2454
|
+
...controlProps,
|
|
2455
|
+
id: node.id,
|
|
2456
|
+
checked: node.checked,
|
|
2457
|
+
required: node.required,
|
|
2458
|
+
disabled: node.disabled || node.busy,
|
|
2459
|
+
"aria-invalid": Boolean(node.error),
|
|
2460
|
+
"aria-busy": node.busy,
|
|
2461
|
+
onCheckedChange: (checked)=>emitAction(context, {
|
|
2462
|
+
...control,
|
|
2463
|
+
action: node.action
|
|
2464
|
+
}, 'value-change', true === checked)
|
|
2465
|
+
}), /*#__PURE__*/ __rspack_external_react.createElement("div", null, /*#__PURE__*/ __rspack_external_react.createElement(FieldLabel, {
|
|
2466
|
+
htmlFor: node.id
|
|
2467
|
+
}, node.label), fieldContent(node)));
|
|
2468
|
+
case 'progress':
|
|
2469
|
+
return /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2470
|
+
key: node.id,
|
|
2471
|
+
"data-component": "mini-app-wasm-progress",
|
|
2472
|
+
className: "space-y-2"
|
|
2473
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2474
|
+
className: "flex items-center justify-between gap-2 text-sm"
|
|
2475
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement("span", null, node.label), /*#__PURE__*/ __rspack_external_react.createElement("span", {
|
|
2476
|
+
className: "text-muted-foreground tabular-nums"
|
|
2477
|
+
}, node.value, "%")), /*#__PURE__*/ __rspack_external_react.createElement(Progress, {
|
|
2478
|
+
value: node.value,
|
|
2479
|
+
"aria-label": node.label
|
|
2480
|
+
}));
|
|
2481
|
+
case 'tooltip':
|
|
2482
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Tooltip, {
|
|
2483
|
+
key: node.id,
|
|
2484
|
+
disableHoverableContent: true
|
|
2485
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(TooltipTrigger, {
|
|
2486
|
+
asChild: true
|
|
2487
|
+
}, renderReference(node.child, context)), /*#__PURE__*/ __rspack_external_react.createElement(TooltipContent, null, node.label));
|
|
2488
|
+
case 'dialog':
|
|
2489
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(Dialog, {
|
|
2490
|
+
key: node.id,
|
|
2491
|
+
open: node.open,
|
|
2492
|
+
onOpenChange: (open)=>emitAction(context, {
|
|
2493
|
+
...control,
|
|
2494
|
+
action: node.openChangeAction
|
|
2495
|
+
}, 'open-change', open)
|
|
2496
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(DialogContent, {
|
|
2497
|
+
"data-miniapp-control-id": node.id,
|
|
2498
|
+
"data-miniapp-root-id": context.rootId
|
|
2499
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(DialogHeader, null, /*#__PURE__*/ __rspack_external_react.createElement(DialogTitle, null, node.title), node.description ? /*#__PURE__*/ __rspack_external_react.createElement(DialogDescription, null, node.description) : null), renderReferences(node.children, context), node.actions.length > 0 ? /*#__PURE__*/ __rspack_external_react.createElement(DialogFooter, null, node.actions.map((action)=>/*#__PURE__*/ __rspack_external_react.createElement(button_Button, {
|
|
2500
|
+
key: action.id,
|
|
2501
|
+
"data-miniapp-control-id": action.id,
|
|
2502
|
+
"data-miniapp-root-id": context.rootId,
|
|
2503
|
+
type: "button",
|
|
2504
|
+
variant: action.variant,
|
|
2505
|
+
disabled: action.disabled,
|
|
2506
|
+
onClick: ()=>emitAction(context, {
|
|
2507
|
+
id: action.id,
|
|
2508
|
+
entityId: node.entityId,
|
|
2509
|
+
action: action.action
|
|
2510
|
+
}, 'activate')
|
|
2511
|
+
}, action.label))) : null));
|
|
2512
|
+
case 'confirmation':
|
|
2513
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(AlertDialog, {
|
|
2514
|
+
key: node.id,
|
|
2515
|
+
open: node.open,
|
|
2516
|
+
onOpenChange: (open)=>emitAction(context, {
|
|
2517
|
+
...control,
|
|
2518
|
+
action: node.openChangeAction
|
|
2519
|
+
}, 'open-change', open)
|
|
2520
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogContent, {
|
|
2521
|
+
"data-miniapp-control-id": node.id,
|
|
2522
|
+
"data-miniapp-root-id": context.rootId
|
|
2523
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogHeader, null, /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogTitle, null, node.title), /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogDescription, null, node.description)), /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogFooter, null, /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogCancel, null, node.cancelLabel), /*#__PURE__*/ __rspack_external_react.createElement(AlertDialogAction, {
|
|
2524
|
+
"data-miniapp-control-id": node.confirm.id,
|
|
2525
|
+
"data-miniapp-root-id": context.rootId,
|
|
2526
|
+
className: utils_cn('destructive' === node.confirm.variant && 'bg-destructive'),
|
|
2527
|
+
disabled: node.confirm.disabled,
|
|
2528
|
+
onClick: ()=>emitAction(context, {
|
|
2529
|
+
id: node.confirm.id,
|
|
2530
|
+
entityId: node.entityId,
|
|
2531
|
+
action: node.confirm.action
|
|
2532
|
+
}, 'activate')
|
|
2533
|
+
}, node.confirm.label))));
|
|
2534
|
+
case 'separator':
|
|
2535
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(separator_Separator, {
|
|
2536
|
+
key: node.id
|
|
2537
|
+
});
|
|
2538
|
+
case 'metric':
|
|
2539
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(MiniAppMetric, {
|
|
2540
|
+
key: node.id
|
|
2541
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(MiniAppMetricHeader, null, /*#__PURE__*/ __rspack_external_react.createElement(MiniAppMetricLabel, null, node.label), node.badge ? /*#__PURE__*/ __rspack_external_react.createElement(Badge, {
|
|
2542
|
+
variant: "outline"
|
|
2543
|
+
}, node.badge) : null), /*#__PURE__*/ __rspack_external_react.createElement(MiniAppMetricContent, null, /*#__PURE__*/ __rspack_external_react.createElement(MiniAppMetricValue, null, node.value), node.detail ? /*#__PURE__*/ __rspack_external_react.createElement(MiniAppMetricDetail, null, node.detail) : null));
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
class MiniAppUiErrorBoundary extends __rspack_external_react.Component {
|
|
2547
|
+
state = {
|
|
2548
|
+
failed: false
|
|
2549
|
+
};
|
|
2550
|
+
static getDerivedStateFromError() {
|
|
2551
|
+
return {
|
|
2552
|
+
failed: true
|
|
2553
|
+
};
|
|
2554
|
+
}
|
|
2555
|
+
componentDidCatch(cause) {
|
|
2556
|
+
this.props.reportError(new MiniAppUiError('render-failed', 'The mini-app UI failed to render.', cause));
|
|
2557
|
+
}
|
|
2558
|
+
render() {
|
|
2559
|
+
return this.state.failed ? null : this.props.children;
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
function MiniAppUiView({ announcement, context, model }) {
|
|
2563
|
+
return /*#__PURE__*/ __rspack_external_react.createElement(MiniAppUiErrorBoundary, {
|
|
2564
|
+
key: model.revision,
|
|
2565
|
+
reportError: context.reportError
|
|
2566
|
+
}, /*#__PURE__*/ __rspack_external_react.createElement(TooltipProvider, null, /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2567
|
+
"data-component": "mini-app-wasm-root",
|
|
2568
|
+
"data-miniapp-state": model.state,
|
|
2569
|
+
"data-miniapp-revision": model.revision,
|
|
2570
|
+
"data-miniapp-root-id": context.rootId,
|
|
2571
|
+
className: "text-foreground min-w-0"
|
|
2572
|
+
}, renderReferences(model.rootIds, context), announcement ? /*#__PURE__*/ __rspack_external_react.createElement("div", {
|
|
2573
|
+
key: announcement.nonce,
|
|
2574
|
+
className: "sr-only",
|
|
2575
|
+
role: 'assertive' === announcement.priority ? 'alert' : 'status',
|
|
2576
|
+
"aria-live": announcement.priority
|
|
2577
|
+
}, announcement.message) : null)));
|
|
2578
|
+
}
|
|
2579
|
+
function defaultErrorReporter(error) {
|
|
2580
|
+
if ('function' == typeof globalThis.reportError) return void globalThis.reportError(error);
|
|
2581
|
+
queueMicrotask(()=>{
|
|
2582
|
+
throw error;
|
|
2583
|
+
});
|
|
2584
|
+
}
|
|
2585
|
+
function openOverlayId(model) {
|
|
2586
|
+
return model.nodes.find((node)=>('dialog' === node.type || 'confirmation' === node.type) && node.open)?.id ?? null;
|
|
2587
|
+
}
|
|
2588
|
+
function focusControl(container, rootId, controlId) {
|
|
2589
|
+
const target = [
|
|
2590
|
+
...container.ownerDocument.querySelectorAll('[data-miniapp-control-id]')
|
|
2591
|
+
].find((element)=>element.dataset.miniappRootId === rootId && element.dataset.miniappControlId === controlId);
|
|
2592
|
+
target?.focus();
|
|
2593
|
+
return void 0 !== target;
|
|
2594
|
+
}
|
|
2595
|
+
function focusOverlay(container, rootId, overlayId) {
|
|
2596
|
+
const overlay = [
|
|
2597
|
+
...container.ownerDocument.querySelectorAll('[data-miniapp-control-id]')
|
|
2598
|
+
].find((element)=>element.dataset.miniappRootId === rootId && element.dataset.miniappControlId === overlayId);
|
|
2599
|
+
const target = overlay?.querySelector('button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
|
|
2600
|
+
(target ?? overlay)?.focus();
|
|
2601
|
+
}
|
|
2602
|
+
function createMiniAppUiRoot(container, initialModel, dispatch, options = {}) {
|
|
2603
|
+
if ("u" < typeof Element || !(container instanceof Element)) throw new MiniAppUiError('render-failed', 'A DOM Element is required to mount the mini-app UI.');
|
|
2604
|
+
if ('function' != typeof dispatch) throw new MiniAppUiError('render-failed', 'An action dispatch function is required to mount the mini-app UI.');
|
|
2605
|
+
let model = parseModel(initialModel);
|
|
2606
|
+
let serializedModel = JSON.stringify(model);
|
|
2607
|
+
let mounted = true;
|
|
2608
|
+
let eventSequence = 0;
|
|
2609
|
+
let announcementSequence = 0;
|
|
2610
|
+
let announcement = null;
|
|
2611
|
+
nextMiniAppUiRootId += 1;
|
|
2612
|
+
const rootId = `root-${nextMiniAppUiRootId}`;
|
|
2613
|
+
let currentOpenOverlayId = openOverlayId(model);
|
|
2614
|
+
let focusRestoreTarget = currentOpenOverlayId && container.ownerDocument.activeElement instanceof HTMLElement ? container.ownerDocument.activeElement : null;
|
|
2615
|
+
const reportError = options.onError ?? defaultErrorReporter;
|
|
2616
|
+
const reactRoot = createRoot(container);
|
|
2617
|
+
const stopAppearanceSync = installMiniAppAppearanceSync({
|
|
2618
|
+
search: options.appearanceSearch
|
|
2619
|
+
});
|
|
2620
|
+
const contextFor = (currentModel)=>({
|
|
2621
|
+
dispatch,
|
|
2622
|
+
getCurrentRevision: ()=>model.revision,
|
|
2623
|
+
nextEventId: (revision)=>{
|
|
2624
|
+
eventSequence += 1;
|
|
2625
|
+
return `ui-${rootId}-${revision}-${eventSequence}`;
|
|
2626
|
+
},
|
|
2627
|
+
nodes: new Map(currentModel.nodes.map((node)=>[
|
|
2628
|
+
node.id,
|
|
2629
|
+
node
|
|
2630
|
+
])),
|
|
2631
|
+
reportError,
|
|
2632
|
+
revision: currentModel.revision,
|
|
2633
|
+
rootId
|
|
2634
|
+
});
|
|
2635
|
+
const render = ()=>{
|
|
2636
|
+
try {
|
|
2637
|
+
flushSync(()=>{
|
|
2638
|
+
reactRoot.render(/*#__PURE__*/ __rspack_external_react.createElement(MiniAppUiView, {
|
|
2639
|
+
announcement: announcement,
|
|
2640
|
+
context: contextFor(model),
|
|
2641
|
+
model: model
|
|
2642
|
+
}));
|
|
2643
|
+
});
|
|
2644
|
+
} catch (cause) {
|
|
2645
|
+
const error = cause instanceof MiniAppUiError ? cause : new MiniAppUiError('render-failed', 'The mini-app UI failed to render.', cause);
|
|
2646
|
+
reportError(error);
|
|
2647
|
+
throw error;
|
|
2648
|
+
}
|
|
2649
|
+
};
|
|
2650
|
+
const assertMounted = ()=>{
|
|
2651
|
+
if (!mounted) throw new MiniAppUiError('root-unmounted', 'The mini-app UI root has already been unmounted.');
|
|
2652
|
+
};
|
|
2653
|
+
render();
|
|
2654
|
+
if (currentOpenOverlayId) focusOverlay(container, rootId, currentOpenOverlayId);
|
|
2655
|
+
return {
|
|
2656
|
+
get revision () {
|
|
2657
|
+
return model.revision;
|
|
2658
|
+
},
|
|
2659
|
+
update (value) {
|
|
2660
|
+
assertMounted();
|
|
2661
|
+
const nextModel = parseModel(value);
|
|
2662
|
+
const nextSerializedModel = JSON.stringify(nextModel);
|
|
2663
|
+
if (nextModel.revision < model.revision) throw new MiniAppUiError('stale-model', `Revision ${nextModel.revision} is older than ${model.revision}.`);
|
|
2664
|
+
if (nextModel.revision === model.revision && nextSerializedModel !== serializedModel) throw new MiniAppUiError('stale-model', `Revision ${nextModel.revision} was reused with different state.`);
|
|
2665
|
+
const nextOpenOverlayId = openOverlayId(nextModel);
|
|
2666
|
+
if (null === currentOpenOverlayId && null !== nextOpenOverlayId && container.ownerDocument.activeElement instanceof HTMLElement) focusRestoreTarget = container.ownerDocument.activeElement;
|
|
2667
|
+
model = nextModel;
|
|
2668
|
+
serializedModel = nextSerializedModel;
|
|
2669
|
+
render();
|
|
2670
|
+
if (null !== nextOpenOverlayId) focusOverlay(container, rootId, nextOpenOverlayId);
|
|
2671
|
+
else if (null !== currentOpenOverlayId) {
|
|
2672
|
+
focusRestoreTarget?.focus();
|
|
2673
|
+
focusRestoreTarget = null;
|
|
2674
|
+
}
|
|
2675
|
+
currentOpenOverlayId = nextOpenOverlayId;
|
|
2676
|
+
},
|
|
2677
|
+
focus (controlId) {
|
|
2678
|
+
assertMounted();
|
|
2679
|
+
if (!focusControl(container, rootId, controlId)) throw new MiniAppUiError('focus-target-missing', `No focusable control has id ${controlId}.`);
|
|
2680
|
+
},
|
|
2681
|
+
announce (message, priority = 'polite') {
|
|
2682
|
+
assertMounted();
|
|
2683
|
+
if ('string' != typeof message || 0 === message.length || message.length > 4096) throw new MiniAppUiError('render-failed', 'Announcements must contain between 1 and 4096 characters.');
|
|
2684
|
+
announcementSequence += 1;
|
|
2685
|
+
announcement = {
|
|
2686
|
+
message,
|
|
2687
|
+
nonce: announcementSequence,
|
|
2688
|
+
priority
|
|
2689
|
+
};
|
|
2690
|
+
render();
|
|
2691
|
+
},
|
|
2692
|
+
unmount () {
|
|
2693
|
+
if (!mounted) return;
|
|
2694
|
+
mounted = false;
|
|
2695
|
+
const failures = [];
|
|
2696
|
+
try {
|
|
2697
|
+
stopAppearanceSync();
|
|
2698
|
+
} catch (cause) {
|
|
2699
|
+
failures.push(cause);
|
|
2700
|
+
}
|
|
2701
|
+
try {
|
|
2702
|
+
flushSync(()=>reactRoot.unmount());
|
|
2703
|
+
} catch (cause) {
|
|
2704
|
+
failures.push(cause);
|
|
2705
|
+
}
|
|
2706
|
+
if (failures.length > 0) {
|
|
2707
|
+
const error = new MiniAppUiError('cleanup-failed', 'The mini-app UI root did not clean up completely.', failures);
|
|
2708
|
+
reportError(error);
|
|
2709
|
+
throw error;
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
};
|
|
2713
|
+
}
|
|
2714
|
+
export { MiniAppUiError, createMiniAppUiRoot, miniAppUiActionSchema, miniAppUiEventKindSchema, miniAppUiModelSchema, miniAppUiNodeSchema };
|