@splenddev/kreativ-ui 0.3.14 → 0.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-LVB43ORJ.js → chunk-K47M7SWS.js} +2429 -394
- package/dist/chunk-K47M7SWS.js.map +1 -0
- package/dist/{chunk-NXNJRGTT.js → chunk-UCZ22R5N.js} +404 -20
- package/dist/chunk-UCZ22R5N.js.map +1 -0
- package/dist/{chunk-7LFX4MER.cjs → chunk-YOHCWN65.cjs} +407 -19
- package/dist/chunk-YOHCWN65.cjs.map +1 -0
- package/dist/{chunk-CQHQCYT5.cjs → chunk-ZQUTXKFO.cjs} +2607 -540
- package/dist/chunk-ZQUTXKFO.cjs.map +1 -0
- package/dist/components.cjs +183 -59
- package/dist/components.d.cts +701 -213
- package/dist/components.d.ts +701 -213
- package/dist/components.js +1 -1
- package/dist/core.cjs +20 -16
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/hooks.d.cts +4 -4
- package/dist/hooks.d.ts +4 -4
- package/dist/index.cjs +19 -298
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -10
- package/dist/index.d.ts +5 -10
- package/dist/index.js +18 -10
- package/dist/index.js.map +1 -1
- package/dist/styles/index.css +1 -1
- package/dist/types.d.cts +9 -1
- package/dist/types.d.ts +9 -1
- package/package.json +5 -3
- package/dist/chunk-7LFX4MER.cjs.map +0 -1
- package/dist/chunk-CQHQCYT5.cjs.map +0 -1
- package/dist/chunk-LVB43ORJ.js.map +0 -1
- package/dist/chunk-NXNJRGTT.js.map +0 -1
|
@@ -1,74 +1,2138 @@
|
|
|
1
1
|
import { useStatusTransition, useControllableState, useResponsiveStyles as useResponsiveStyles$1, useMergedResponsiveStyles, useClearableField, useKeyboardShortcuts, useFloatingSide } from './chunk-EZIFSNRD.js';
|
|
2
2
|
import { cn, isMotionGated as isMotionGated$1, composeRefs as composeRefs$1, resolveResponsiveValue, resolveSpace, isResponsiveValue, resolveColor, resolveRadius } from './chunk-TGYV2M2L.js';
|
|
3
3
|
import { __name, __export, __publicField } from './chunk-CXR2HHQQ.js';
|
|
4
|
-
import * as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useTheme, createComponent, isMotionGated, composeRefs, hasKuiMeta, useValidateChildren, resolveStyle, warnOnFlatCompoundConflict } from '@splenddev/kreativ-core';
|
|
8
|
-
import {
|
|
4
|
+
import * as React11 from 'react';
|
|
5
|
+
import { createContext, useState, useEffect, useMemo, useId, useRef, forwardRef, useCallback, useLayoutEffect, Children, isValidElement, Fragment as Fragment$1, useImperativeHandle, useSyncExternalStore, useContext, useReducer } from 'react';
|
|
6
|
+
import { createPortal } from 'react-dom';
|
|
7
|
+
import { useTheme, createComponent as createComponent$1, isMotionGated, composeRefs, hasKuiMeta, useValidateChildren, resolveStyle, createFromProps, warnOnFlatCompoundConflict } from '@splenddev/kreativ-core';
|
|
8
|
+
import { createComponent, composeRefs as composeRefs$2 } from '@splenddev/kreativ-core/utils';
|
|
9
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
10
|
+
import { FloatingDelayGroup, useFloating, autoUpdate, offset, flip, shift, arrow, useDelayGroup, useHover, safePolygon, useFocus, useDismiss, useRole, useInteractions, FloatingFocusManager, size, useFloatingTree, useFloatingNodeId, useFloatingParentNodeId, useClick, useListNavigation, useTypeahead, FloatingNode, FloatingTree, FloatingList, useListItem } from '@floating-ui/react';
|
|
11
|
+
import { useSizeToken, useTypography, useSizeStyle, useResponsiveStyles, useControllableState as useControllableState$1 } from '@splenddev/kreativ-core/hooks';
|
|
9
12
|
import { motion } from 'framer-motion';
|
|
10
13
|
import { ChevronDown, X, Minus, Check, Plus, Heading as Heading$1, Bold, Italic, Strikethrough, Quote, ListOrdered, ClipboardList, Code, Link, Sun, Moon, Monitor, ChevronUp, Trash2, Hash, Search, Link2, Phone, Mail } from 'lucide-react';
|
|
11
|
-
import { createComponent as createComponent$1 } from '@splenddev/kreativ-core/utils';
|
|
12
14
|
import { cva } from 'class-variance-authority';
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
+
function matchesConditions(conditions, props) {
|
|
17
|
+
return Object.entries(conditions).every(
|
|
18
|
+
([key, expected]) => props[key] === expected
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
__name(matchesConditions, "matchesConditions");
|
|
22
|
+
function resolveRecipe(recipe, props = {}, className) {
|
|
23
|
+
if (!recipe) return className ?? "";
|
|
24
|
+
const resolvedProps = {
|
|
25
|
+
...recipe.defaultVariants,
|
|
26
|
+
...props
|
|
27
|
+
};
|
|
28
|
+
const classes = [];
|
|
29
|
+
if (recipe.base) {
|
|
30
|
+
classes.push(resolveStyle(recipe.base));
|
|
31
|
+
}
|
|
32
|
+
if (recipe.variants) {
|
|
33
|
+
for (const [variantName, variantValues] of Object.entries(
|
|
34
|
+
recipe.variants
|
|
35
|
+
)) {
|
|
36
|
+
const value = resolvedProps[variantName];
|
|
37
|
+
if (value === void 0) continue;
|
|
38
|
+
const variantClass = variantValues[String(value)];
|
|
39
|
+
if (variantClass) {
|
|
40
|
+
classes.push(resolveStyle(variantClass));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (recipe.compoundVariants) {
|
|
45
|
+
for (const compound of recipe.compoundVariants) {
|
|
46
|
+
if (matchesConditions(compound.conditions, resolvedProps)) {
|
|
47
|
+
classes.push(resolveStyle(compound.className));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (className) {
|
|
52
|
+
classes.push(className);
|
|
53
|
+
}
|
|
54
|
+
return cn(...classes);
|
|
55
|
+
}
|
|
56
|
+
__name(resolveRecipe, "resolveRecipe");
|
|
57
|
+
|
|
58
|
+
// src/utils/env.ts
|
|
59
|
+
function readProcessEnv() {
|
|
60
|
+
try {
|
|
61
|
+
return typeof process !== "undefined" ? process.env?.NODE_ENV : void 0;
|
|
62
|
+
} catch {
|
|
63
|
+
return void 0;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
__name(readProcessEnv, "readProcessEnv");
|
|
67
|
+
function readImportMetaEnv() {
|
|
68
|
+
try {
|
|
69
|
+
return typeof import.meta !== "undefined" ? import.meta.env?.MODE : void 0;
|
|
70
|
+
} catch {
|
|
71
|
+
return void 0;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
__name(readImportMetaEnv, "readImportMetaEnv");
|
|
75
|
+
function isDev() {
|
|
76
|
+
const mode = readProcessEnv() ?? readImportMetaEnv();
|
|
77
|
+
return mode !== void 0 && mode !== "production";
|
|
78
|
+
}
|
|
79
|
+
__name(isDev, "isDev");
|
|
80
|
+
|
|
81
|
+
// src/components/feedback/Toast/Toast.store.ts
|
|
82
|
+
var viewportCount = 0;
|
|
83
|
+
var warned = false;
|
|
84
|
+
function registerViewport() {
|
|
85
|
+
viewportCount++;
|
|
86
|
+
return () => {
|
|
87
|
+
viewportCount--;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
__name(registerViewport, "registerViewport");
|
|
91
|
+
function warnIfNoViewport() {
|
|
92
|
+
if (!isDev() || warned || viewportCount > 0) return;
|
|
93
|
+
setTimeout(() => {
|
|
94
|
+
if (viewportCount > 0 || warned) return;
|
|
95
|
+
warned = true;
|
|
96
|
+
console.warn(
|
|
97
|
+
"[kreativ-ui/Toast] toast() was called but no <Toast.Viewport> is mounted, so nothing will be displayed. Render <Toast.Viewport /> inside <Toast.Provider> (included by default in UIProvider)."
|
|
98
|
+
);
|
|
99
|
+
}, 0);
|
|
100
|
+
}
|
|
101
|
+
__name(warnIfNoViewport, "warnIfNoViewport");
|
|
102
|
+
var TOAST_FALLBACK_DURATION = 5e3;
|
|
103
|
+
var DEFAULT_MAX_VISIBLE = 5;
|
|
104
|
+
var EMPTY = [];
|
|
105
|
+
var entries = EMPTY;
|
|
106
|
+
var config = {
|
|
107
|
+
maxVisible: DEFAULT_MAX_VISIBLE,
|
|
108
|
+
duration: TOAST_FALLBACK_DURATION
|
|
109
|
+
};
|
|
110
|
+
var counter = 0;
|
|
111
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
112
|
+
function commit(next) {
|
|
113
|
+
entries = next;
|
|
114
|
+
listeners.forEach((l) => l());
|
|
115
|
+
}
|
|
116
|
+
__name(commit, "commit");
|
|
117
|
+
function enforceMax(list) {
|
|
118
|
+
const overflow = list.length - config.maxVisible;
|
|
119
|
+
if (overflow <= 0) return list;
|
|
120
|
+
const evicted = list.slice(0, overflow);
|
|
121
|
+
queueMicrotask(() => evicted.forEach((e) => e.onDismiss?.(e.id)));
|
|
122
|
+
return list.slice(overflow);
|
|
123
|
+
}
|
|
124
|
+
__name(enforceMax, "enforceMax");
|
|
125
|
+
var toastStore = {
|
|
126
|
+
subscribe(listener) {
|
|
127
|
+
listeners.add(listener);
|
|
128
|
+
return () => {
|
|
129
|
+
listeners.delete(listener);
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
getSnapshot: /* @__PURE__ */ __name(() => entries, "getSnapshot"),
|
|
133
|
+
getServerSnapshot: /* @__PURE__ */ __name(() => EMPTY, "getServerSnapshot"),
|
|
134
|
+
getConfig: /* @__PURE__ */ __name(() => config, "getConfig"),
|
|
135
|
+
configure(next) {
|
|
136
|
+
config = { ...config, ...next };
|
|
137
|
+
commit(enforceMax([...entries]));
|
|
138
|
+
},
|
|
139
|
+
upsert(id, fields, opts = {}) {
|
|
140
|
+
const i = entries.findIndex((e) => e.id === id);
|
|
141
|
+
if (i === -1) {
|
|
142
|
+
commit(
|
|
143
|
+
enforceMax([...entries, { status: "neutral", rev: 0, ...fields, id }])
|
|
144
|
+
);
|
|
145
|
+
return id;
|
|
146
|
+
}
|
|
147
|
+
const prev = entries[i];
|
|
148
|
+
if (prev.closing) {
|
|
149
|
+
const without = entries.filter((e) => e.id !== id);
|
|
150
|
+
commit(
|
|
151
|
+
enforceMax([
|
|
152
|
+
...without,
|
|
153
|
+
{ status: "neutral", rev: prev.rev + 1, ...fields, id }
|
|
154
|
+
])
|
|
155
|
+
);
|
|
156
|
+
return id;
|
|
157
|
+
}
|
|
158
|
+
commit(
|
|
159
|
+
entries.map(
|
|
160
|
+
(e, idx) => idx === i ? merge(prev, fields, opts.restartTimer) : e
|
|
161
|
+
)
|
|
162
|
+
);
|
|
163
|
+
return id;
|
|
164
|
+
},
|
|
165
|
+
patch(id, fields) {
|
|
166
|
+
const i = entries.findIndex((e) => e.id === id);
|
|
167
|
+
if (i === -1 || entries[i].closing) return;
|
|
168
|
+
commit(entries.map((e, idx) => idx === i ? merge(e, fields) : e));
|
|
169
|
+
},
|
|
170
|
+
dismiss(id) {
|
|
171
|
+
const targets = entries.filter(
|
|
172
|
+
(e) => (id == null || e.id === id) && !e.closing
|
|
173
|
+
);
|
|
174
|
+
if (!targets.length) return;
|
|
175
|
+
commit(
|
|
176
|
+
entries.map((e) => targets.includes(e) ? { ...e, closing: true } : e)
|
|
177
|
+
);
|
|
178
|
+
targets.forEach((e) => e.onDismiss?.(e.id));
|
|
179
|
+
},
|
|
180
|
+
remove(id) {
|
|
181
|
+
if (!entries.some((e) => e.id === id)) return;
|
|
182
|
+
commit(entries.filter((e) => e.id !== id));
|
|
183
|
+
},
|
|
184
|
+
deregister(id) {
|
|
185
|
+
const e = entries.find((x) => x.id === id);
|
|
186
|
+
if (e && !e.closing) toastStore.remove(id);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
function merge(prev, fields, restart = false) {
|
|
190
|
+
const next = { ...prev, ...fields };
|
|
191
|
+
const changed = restart || prev.status !== next.status || prev.duration !== next.duration || prev.loading !== next.loading;
|
|
192
|
+
return { ...next, rev: changed ? prev.rev + 1 : prev.rev };
|
|
193
|
+
}
|
|
194
|
+
__name(merge, "merge");
|
|
195
|
+
var nextId = /* @__PURE__ */ __name(() => `kui-toast-${++counter}`, "nextId");
|
|
196
|
+
function create(status, message, options = {}) {
|
|
197
|
+
const id = options.id ?? nextId();
|
|
198
|
+
warnIfNoViewport();
|
|
199
|
+
return toastStore.upsert(
|
|
200
|
+
id,
|
|
201
|
+
{
|
|
202
|
+
status,
|
|
203
|
+
loading: false,
|
|
204
|
+
title: options.title ?? message,
|
|
205
|
+
description: options.description,
|
|
206
|
+
icon: options.icon,
|
|
207
|
+
action: options.action,
|
|
208
|
+
duration: options.duration,
|
|
209
|
+
dismissible: options.dismissible,
|
|
210
|
+
onDismiss: options.onDismiss
|
|
211
|
+
},
|
|
212
|
+
{ restartTimer: true }
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
__name(create, "create");
|
|
216
|
+
function promise(source, messages, options = {}) {
|
|
217
|
+
const id = options.id ?? nextId();
|
|
218
|
+
toastStore.upsert(
|
|
219
|
+
id,
|
|
220
|
+
{
|
|
221
|
+
status: "neutral",
|
|
222
|
+
loading: true,
|
|
223
|
+
title: messages.loading,
|
|
224
|
+
description: options.description,
|
|
225
|
+
icon: options.icon,
|
|
226
|
+
action: options.action,
|
|
227
|
+
duration: options.duration,
|
|
228
|
+
dismissible: options.dismissible,
|
|
229
|
+
onDismiss: options.onDismiss
|
|
230
|
+
},
|
|
231
|
+
{ restartTimer: true }
|
|
232
|
+
);
|
|
233
|
+
const p = typeof source === "function" ? source() : source;
|
|
234
|
+
p.then(
|
|
235
|
+
(data) => toastStore.patch(id, {
|
|
236
|
+
status: "success",
|
|
237
|
+
loading: false,
|
|
238
|
+
title: typeof messages.success === "function" ? messages.success(data) : messages.success
|
|
239
|
+
}),
|
|
240
|
+
(error62) => toastStore.patch(id, {
|
|
241
|
+
status: "error",
|
|
242
|
+
loading: false,
|
|
243
|
+
title: typeof messages.error === "function" ? messages.error(error62) : messages.error
|
|
244
|
+
})
|
|
245
|
+
);
|
|
246
|
+
return id;
|
|
247
|
+
}
|
|
248
|
+
__name(promise, "promise");
|
|
249
|
+
function update(id, options) {
|
|
250
|
+
const { message, ...rest } = options;
|
|
251
|
+
const fields = { ...rest };
|
|
252
|
+
if (message !== void 0 && rest.title === void 0) fields.title = message;
|
|
253
|
+
toastStore.patch(id, fields);
|
|
254
|
+
}
|
|
255
|
+
__name(update, "update");
|
|
256
|
+
var toast = Object.assign(
|
|
257
|
+
(message, options) => create("neutral", message, options),
|
|
258
|
+
{
|
|
259
|
+
success: /* @__PURE__ */ __name((message, options) => create("success", message, options), "success"),
|
|
260
|
+
error: /* @__PURE__ */ __name((message, options) => create("error", message, options), "error"),
|
|
261
|
+
warning: /* @__PURE__ */ __name((message, options) => create("warning", message, options), "warning"),
|
|
262
|
+
info: /* @__PURE__ */ __name((message, options) => create("info", message, options), "info"),
|
|
263
|
+
brand: /* @__PURE__ */ __name((message, options) => create("brand", message, options), "brand"),
|
|
264
|
+
promise,
|
|
265
|
+
update,
|
|
266
|
+
dismiss: /* @__PURE__ */ __name((id) => toastStore.dismiss(id), "dismiss")
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
// src/components/feedback/Toast/Toast.hooks.ts
|
|
271
|
+
function useToasts() {
|
|
272
|
+
return useSyncExternalStore(
|
|
273
|
+
toastStore.subscribe,
|
|
274
|
+
toastStore.getSnapshot,
|
|
275
|
+
toastStore.getServerSnapshot
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
__name(useToasts, "useToasts");
|
|
279
|
+
function prefersReducedMotion() {
|
|
280
|
+
return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
281
|
+
}
|
|
282
|
+
__name(prefersReducedMotion, "prefersReducedMotion");
|
|
283
|
+
function useToastTimer({
|
|
284
|
+
duration: duration3,
|
|
285
|
+
paused,
|
|
286
|
+
resetKey,
|
|
287
|
+
onExpire
|
|
288
|
+
}) {
|
|
289
|
+
const remainingRef = useRef(duration3);
|
|
290
|
+
const expireRef = useRef(onExpire);
|
|
291
|
+
const [remaining, setRemaining] = useState(duration3);
|
|
292
|
+
expireRef.current = onExpire;
|
|
293
|
+
useEffect(() => {
|
|
294
|
+
remainingRef.current = duration3;
|
|
295
|
+
setRemaining(duration3);
|
|
296
|
+
}, [duration3, resetKey]);
|
|
297
|
+
useEffect(() => {
|
|
298
|
+
if (!Number.isFinite(duration3) || paused) return;
|
|
299
|
+
const initialRemaining = Math.max(remainingRef.current, 0);
|
|
300
|
+
const startedAt = performance.now();
|
|
301
|
+
let frame = 0;
|
|
302
|
+
const updateProgress = /* @__PURE__ */ __name(() => {
|
|
303
|
+
const elapsed = performance.now() - startedAt;
|
|
304
|
+
const nextRemaining = Math.max(initialRemaining - elapsed, 0);
|
|
305
|
+
setRemaining(nextRemaining);
|
|
306
|
+
if (nextRemaining > 0) {
|
|
307
|
+
frame = requestAnimationFrame(updateProgress);
|
|
308
|
+
}
|
|
309
|
+
}, "updateProgress");
|
|
310
|
+
frame = requestAnimationFrame(updateProgress);
|
|
311
|
+
const timer = window.setTimeout(
|
|
312
|
+
() => expireRef.current(),
|
|
313
|
+
initialRemaining
|
|
314
|
+
);
|
|
315
|
+
return () => {
|
|
316
|
+
window.clearTimeout(timer);
|
|
317
|
+
cancelAnimationFrame(frame);
|
|
318
|
+
const elapsed = performance.now() - startedAt;
|
|
319
|
+
remainingRef.current = Math.max(initialRemaining - elapsed, 0);
|
|
320
|
+
};
|
|
321
|
+
}, [duration3, paused, resetKey]);
|
|
322
|
+
const progress = Number.isFinite(duration3) && duration3 > 0 ? Math.min(100, Math.max(0, remaining / duration3 * 100)) : 0;
|
|
323
|
+
return { remaining, progress };
|
|
324
|
+
}
|
|
325
|
+
__name(useToastTimer, "useToastTimer");
|
|
326
|
+
var EXIT_MS = 160;
|
|
327
|
+
var ViewportContext = createContext({
|
|
328
|
+
paused: false,
|
|
329
|
+
placement: "bottom-end"
|
|
330
|
+
});
|
|
331
|
+
var ToastItemContext = createContext(null);
|
|
332
|
+
function useToastItem(part) {
|
|
333
|
+
const ctx = useContext(ToastItemContext);
|
|
334
|
+
if (!ctx) throw new Error(`<${part}> must be rendered inside a Toast.`);
|
|
335
|
+
return ctx;
|
|
336
|
+
}
|
|
337
|
+
__name(useToastItem, "useToastItem");
|
|
338
|
+
function Svg({
|
|
339
|
+
children,
|
|
340
|
+
className
|
|
341
|
+
}) {
|
|
342
|
+
return /* @__PURE__ */ jsx(
|
|
343
|
+
"svg",
|
|
344
|
+
{
|
|
345
|
+
viewBox: "0 0 24 24",
|
|
346
|
+
width: "20",
|
|
347
|
+
height: "20",
|
|
348
|
+
fill: "none",
|
|
349
|
+
stroke: "currentColor",
|
|
350
|
+
strokeWidth: "2",
|
|
351
|
+
strokeLinecap: "round",
|
|
352
|
+
strokeLinejoin: "round",
|
|
353
|
+
"aria-hidden": "true",
|
|
354
|
+
className,
|
|
355
|
+
children
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
__name(Svg, "Svg");
|
|
360
|
+
function DefaultIcon({
|
|
361
|
+
status,
|
|
362
|
+
loading
|
|
363
|
+
}) {
|
|
364
|
+
if (loading) {
|
|
365
|
+
return /* @__PURE__ */ jsx(Svg, { className: "animate-spin", children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" }) });
|
|
366
|
+
}
|
|
367
|
+
switch (status) {
|
|
368
|
+
case "success":
|
|
369
|
+
return /* @__PURE__ */ jsxs(Svg, { children: [
|
|
370
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
371
|
+
/* @__PURE__ */ jsx("path", { d: "m9 12 2 2 4-4" })
|
|
372
|
+
] });
|
|
373
|
+
case "error":
|
|
374
|
+
return /* @__PURE__ */ jsxs(Svg, { children: [
|
|
375
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
376
|
+
/* @__PURE__ */ jsx("path", { d: "m15 9-6 6M9 9l6 6" })
|
|
377
|
+
] });
|
|
378
|
+
case "warning":
|
|
379
|
+
return /* @__PURE__ */ jsxs(Svg, { children: [
|
|
380
|
+
/* @__PURE__ */ jsx("path", { d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3" }),
|
|
381
|
+
/* @__PURE__ */ jsx("path", { d: "M12 9v4M12 17h.01" })
|
|
382
|
+
] });
|
|
383
|
+
default:
|
|
384
|
+
return /* @__PURE__ */ jsxs(Svg, { children: [
|
|
385
|
+
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "10" }),
|
|
386
|
+
/* @__PURE__ */ jsx("path", { d: "M12 16v-4M12 8h.01" })
|
|
387
|
+
] });
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
__name(DefaultIcon, "DefaultIcon");
|
|
391
|
+
var ToastIcon = createComponent({
|
|
392
|
+
displayName: "Toast.Icon",
|
|
393
|
+
__kui: { groupSlot: "Toast" },
|
|
394
|
+
render: /* @__PURE__ */ __name(({ className, children, ...rest }, ref) => {
|
|
395
|
+
const { theme } = useTheme();
|
|
396
|
+
const { status, loading } = useToastItem("Toast.Icon");
|
|
397
|
+
return /* @__PURE__ */ jsx(
|
|
398
|
+
"div",
|
|
399
|
+
{
|
|
400
|
+
ref,
|
|
401
|
+
"aria-hidden": "true",
|
|
402
|
+
className: cn(
|
|
403
|
+
resolveRecipe(theme.recipes.ToastIcon, { status }),
|
|
404
|
+
className
|
|
405
|
+
),
|
|
406
|
+
...rest,
|
|
407
|
+
children: children ?? /* @__PURE__ */ jsx(DefaultIcon, { status, loading })
|
|
408
|
+
}
|
|
409
|
+
);
|
|
410
|
+
}, "render")
|
|
411
|
+
});
|
|
412
|
+
var ToastContent = createComponent({
|
|
413
|
+
displayName: "Toast.Content",
|
|
414
|
+
__kui: { groupSlot: "Toast" },
|
|
415
|
+
render: /* @__PURE__ */ __name(({ className, ...rest }, ref) => {
|
|
416
|
+
const { theme } = useTheme();
|
|
417
|
+
return /* @__PURE__ */ jsx(
|
|
418
|
+
"div",
|
|
419
|
+
{
|
|
420
|
+
ref,
|
|
421
|
+
className: cn(resolveRecipe(theme.recipes.ToastContent, {}), className),
|
|
422
|
+
...rest
|
|
423
|
+
}
|
|
424
|
+
);
|
|
425
|
+
}, "render")
|
|
426
|
+
});
|
|
427
|
+
var ToastTitle = createComponent({
|
|
428
|
+
displayName: "Toast.Title",
|
|
429
|
+
__kui: { groupSlot: "Toast" },
|
|
430
|
+
render: /* @__PURE__ */ __name(({ className, ...rest }, ref) => {
|
|
431
|
+
const { theme } = useTheme();
|
|
432
|
+
return /* @__PURE__ */ jsx(
|
|
433
|
+
"div",
|
|
434
|
+
{
|
|
435
|
+
ref,
|
|
436
|
+
className: cn(resolveRecipe(theme.recipes.ToastTitle, {}), className),
|
|
437
|
+
...rest
|
|
438
|
+
}
|
|
439
|
+
);
|
|
440
|
+
}, "render")
|
|
441
|
+
});
|
|
442
|
+
var ToastDescription = createComponent({
|
|
443
|
+
displayName: "Toast.Description",
|
|
444
|
+
__kui: { groupSlot: "Toast" },
|
|
445
|
+
render: /* @__PURE__ */ __name(({ className, ...rest }, ref) => {
|
|
446
|
+
const { theme } = useTheme();
|
|
447
|
+
return /* @__PURE__ */ jsx(
|
|
448
|
+
"div",
|
|
449
|
+
{
|
|
450
|
+
ref,
|
|
451
|
+
className: cn(
|
|
452
|
+
resolveRecipe(theme.recipes.ToastDescription, {}),
|
|
453
|
+
className
|
|
454
|
+
),
|
|
455
|
+
...rest
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
}, "render")
|
|
459
|
+
});
|
|
460
|
+
var ToastAction = createComponent(
|
|
461
|
+
{
|
|
462
|
+
displayName: "Toast.Action",
|
|
463
|
+
__kui: { groupSlot: "Toast" },
|
|
464
|
+
render: /* @__PURE__ */ __name(({ className, dismissOnAction = true, onClick, ...rest }, ref) => {
|
|
465
|
+
const { theme } = useTheme();
|
|
466
|
+
const { dismiss } = useToastItem("Toast.Action");
|
|
467
|
+
return /* @__PURE__ */ jsx(
|
|
468
|
+
"button",
|
|
469
|
+
{
|
|
470
|
+
ref,
|
|
471
|
+
type: "button",
|
|
472
|
+
className: cn(
|
|
473
|
+
resolveRecipe(theme.recipes.ToastAction, {}),
|
|
474
|
+
className
|
|
475
|
+
),
|
|
476
|
+
...rest,
|
|
477
|
+
onClick: (e) => {
|
|
478
|
+
onClick?.(e);
|
|
479
|
+
if (dismissOnAction && !e.defaultPrevented) dismiss();
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
}, "render")
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
var ToastClose = createComponent({
|
|
487
|
+
displayName: "Toast.Close",
|
|
488
|
+
__kui: { groupSlot: "Toast" },
|
|
489
|
+
render: /* @__PURE__ */ __name(({ className, children, onClick, ...rest }, ref) => {
|
|
490
|
+
const { theme } = useTheme();
|
|
491
|
+
const { dismiss } = useToastItem("Toast.Close");
|
|
492
|
+
return /* @__PURE__ */ jsx(
|
|
493
|
+
"button",
|
|
494
|
+
{
|
|
495
|
+
ref,
|
|
496
|
+
type: "button",
|
|
497
|
+
"aria-label": "Dismiss notification",
|
|
498
|
+
className: cn(resolveRecipe(theme.recipes.ToastClose, {}), className),
|
|
499
|
+
...rest,
|
|
500
|
+
onClick: (e) => {
|
|
501
|
+
onClick?.(e);
|
|
502
|
+
if (!e.defaultPrevented) dismiss();
|
|
503
|
+
},
|
|
504
|
+
children: children ?? /* @__PURE__ */ jsx(Svg, { className: "size-4", children: /* @__PURE__ */ jsx("path", { d: "M18 6 6 18M6 6l12 12" }) })
|
|
505
|
+
}
|
|
506
|
+
);
|
|
507
|
+
}, "render")
|
|
508
|
+
});
|
|
509
|
+
var progressColors = {
|
|
510
|
+
neutral: "bg-kui-border",
|
|
511
|
+
success: "bg-kui-success",
|
|
512
|
+
error: "bg-kui-destructive",
|
|
513
|
+
warning: "bg-kui-warning",
|
|
514
|
+
info: "bg-kui-info",
|
|
515
|
+
brand: "bg-kui-brand"
|
|
516
|
+
};
|
|
517
|
+
var SWIPE_DISTANCE = 80;
|
|
518
|
+
var SWIPE_VELOCITY = 0.5;
|
|
519
|
+
var STACK_PEEK_HEIGHT = 12;
|
|
520
|
+
function ToastItem({
|
|
521
|
+
entry,
|
|
522
|
+
placement,
|
|
523
|
+
stackIndex,
|
|
524
|
+
expanded
|
|
525
|
+
}) {
|
|
526
|
+
const { theme } = useTheme();
|
|
527
|
+
const viewport = useContext(ViewportContext);
|
|
528
|
+
const [localPaused, setLocalPaused] = useState(false);
|
|
529
|
+
const swipeRef = useRef(null);
|
|
530
|
+
const [swipeX, setSwipeX] = useState(0);
|
|
531
|
+
const [swiping, setSwiping] = useState(false);
|
|
532
|
+
const isStacked = stackIndex > 0 && !expanded;
|
|
533
|
+
const closing = !!entry.closing;
|
|
534
|
+
const loading = !!entry.loading;
|
|
535
|
+
const duration3 = loading ? Infinity : entry.duration ?? toastStore.getConfig().duration;
|
|
536
|
+
const dismiss = useCallback(() => toastStore.dismiss(entry.id), [entry.id]);
|
|
537
|
+
const { progress } = useToastTimer({
|
|
538
|
+
duration: duration3,
|
|
539
|
+
paused: viewport.paused || localPaused || closing,
|
|
540
|
+
resetKey: entry.rev,
|
|
541
|
+
onExpire: dismiss
|
|
542
|
+
});
|
|
543
|
+
const handlePointerDown = /* @__PURE__ */ __name((e) => {
|
|
544
|
+
if (closing || e.button !== 0) return;
|
|
545
|
+
if (e.target instanceof Element && e.target.closest(
|
|
546
|
+
'button, a, input, textarea, select, [role="button"], [data-no-swipe]'
|
|
547
|
+
)) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
swipeRef.current = {
|
|
551
|
+
startX: e.clientX,
|
|
552
|
+
startY: e.clientY,
|
|
553
|
+
startedAt: performance.now()
|
|
554
|
+
};
|
|
555
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
556
|
+
}, "handlePointerDown");
|
|
557
|
+
const handlePointerMove = /* @__PURE__ */ __name((e) => {
|
|
558
|
+
const start = swipeRef.current;
|
|
559
|
+
if (!start) return;
|
|
560
|
+
const deltaX = e.clientX - start.startX;
|
|
561
|
+
const deltaY = e.clientY - start.startY;
|
|
562
|
+
if (Math.abs(deltaY) > Math.abs(deltaX) && !swiping) return;
|
|
563
|
+
if (Math.abs(deltaX) > 6) {
|
|
564
|
+
setSwiping(true);
|
|
565
|
+
setSwipeX(deltaX);
|
|
566
|
+
}
|
|
567
|
+
}, "handlePointerMove");
|
|
568
|
+
const handlePointerUp = /* @__PURE__ */ __name((e) => {
|
|
569
|
+
const start = swipeRef.current;
|
|
570
|
+
if (!start) return;
|
|
571
|
+
const deltaX = e.clientX - start.startX;
|
|
572
|
+
const elapsed = Math.max(performance.now() - start.startedAt, 1);
|
|
573
|
+
const velocity = Math.abs(deltaX) / elapsed;
|
|
574
|
+
swipeRef.current = null;
|
|
575
|
+
setSwiping(false);
|
|
576
|
+
if (Math.abs(deltaX) >= SWIPE_DISTANCE || Math.abs(deltaX) >= 30 && velocity >= SWIPE_VELOCITY) {
|
|
577
|
+
dismiss();
|
|
578
|
+
return;
|
|
579
|
+
}
|
|
580
|
+
setSwipeX(0);
|
|
581
|
+
}, "handlePointerUp");
|
|
582
|
+
const handlePointerCancel = /* @__PURE__ */ __name(() => {
|
|
583
|
+
swipeRef.current = null;
|
|
584
|
+
setSwiping(false);
|
|
585
|
+
setSwipeX(0);
|
|
586
|
+
}, "handlePointerCancel");
|
|
587
|
+
useEffect(() => {
|
|
588
|
+
if (!closing) return;
|
|
589
|
+
const t = setTimeout(
|
|
590
|
+
() => toastStore.remove(entry.id),
|
|
591
|
+
prefersReducedMotion() ? 0 : EXIT_MS
|
|
592
|
+
);
|
|
593
|
+
return () => clearTimeout(t);
|
|
594
|
+
}, [closing, entry.id]);
|
|
595
|
+
useValidateChildren("Toast", entry.children);
|
|
596
|
+
const ctx = useMemo(
|
|
597
|
+
() => ({
|
|
598
|
+
id: entry.id,
|
|
599
|
+
status: entry.status,
|
|
600
|
+
loading,
|
|
601
|
+
dismiss,
|
|
602
|
+
pause: /* @__PURE__ */ __name(() => setLocalPaused(true), "pause"),
|
|
603
|
+
resume: /* @__PURE__ */ __name(() => setLocalPaused(false), "resume")
|
|
604
|
+
}),
|
|
605
|
+
[entry.id, entry.status, loading, dismiss]
|
|
606
|
+
);
|
|
607
|
+
const onKeyDown = /* @__PURE__ */ __name((e) => {
|
|
608
|
+
if (e.key === "Escape") dismiss();
|
|
609
|
+
}, "onKeyDown");
|
|
610
|
+
const compound = entry.children != null;
|
|
611
|
+
return /* @__PURE__ */ jsx(ToastItemContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
|
|
612
|
+
"div",
|
|
613
|
+
{
|
|
614
|
+
role: entry.status === "error" ? "alert" : "status",
|
|
615
|
+
"aria-atomic": "true",
|
|
616
|
+
"data-kui-toast": "",
|
|
617
|
+
"data-status": entry.status,
|
|
618
|
+
"data-state": closing ? "closed" : "open",
|
|
619
|
+
"data-placement": placement,
|
|
620
|
+
"data-stacked": isStacked ? "" : void 0,
|
|
621
|
+
"data-swiping": swiping ? "" : void 0,
|
|
622
|
+
className: resolveRecipe(theme.recipes.Toast, { status: entry.status }),
|
|
623
|
+
style: {
|
|
624
|
+
translate: `${swipeX}px 0`,
|
|
625
|
+
transition: swiping ? "none" : "translate 180ms ease-out",
|
|
626
|
+
maxHeight: isStacked ? STACK_PEEK_HEIGHT : 500,
|
|
627
|
+
overflow: isStacked ? "hidden" : void 0,
|
|
628
|
+
touchAction: "pan-y",
|
|
629
|
+
zIndex: 100 - stackIndex
|
|
630
|
+
},
|
|
631
|
+
onPointerDown: handlePointerDown,
|
|
632
|
+
onPointerMove: handlePointerMove,
|
|
633
|
+
onPointerUp: handlePointerUp,
|
|
634
|
+
onPointerCancel: handlePointerCancel,
|
|
635
|
+
onKeyDown,
|
|
636
|
+
children: [
|
|
637
|
+
compound ? entry.children : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
638
|
+
/* @__PURE__ */ jsx(ToastIcon, { children: entry.icon }),
|
|
639
|
+
/* @__PURE__ */ jsxs(ToastContent, { children: [
|
|
640
|
+
entry.title != null && /* @__PURE__ */ jsx(ToastTitle, { children: entry.title }),
|
|
641
|
+
entry.description != null && /* @__PURE__ */ jsx(ToastDescription, { children: entry.description })
|
|
642
|
+
] }),
|
|
643
|
+
entry.action && /* @__PURE__ */ jsx(
|
|
644
|
+
ToastAction,
|
|
645
|
+
{
|
|
646
|
+
dismissOnAction: entry.action.dismissOnAction,
|
|
647
|
+
onClick: entry.action.onClick,
|
|
648
|
+
children: entry.action.label
|
|
649
|
+
}
|
|
650
|
+
),
|
|
651
|
+
entry.dismissible !== false && /* @__PURE__ */ jsx(ToastClose, {})
|
|
652
|
+
] }),
|
|
653
|
+
entry.showProgress !== false && !loading && Number.isFinite(duration3) && duration3 > 0 && /* @__PURE__ */ jsx(
|
|
654
|
+
"div",
|
|
655
|
+
{
|
|
656
|
+
"aria-hidden": "true",
|
|
657
|
+
className: "pointer-events-none absolute inset-x-0 bottom-0 h-0.5 overflow-hidden rounded-b-xl bg-kui-border/40",
|
|
658
|
+
children: /* @__PURE__ */ jsx(
|
|
659
|
+
"div",
|
|
660
|
+
{
|
|
661
|
+
className: cn(
|
|
662
|
+
"h-full origin-left rtl:origin-right",
|
|
663
|
+
progressColors[entry.status]
|
|
664
|
+
),
|
|
665
|
+
style: {
|
|
666
|
+
transform: `scaleX(${progress / 100})`
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
)
|
|
670
|
+
}
|
|
671
|
+
)
|
|
672
|
+
]
|
|
673
|
+
}
|
|
674
|
+
) });
|
|
675
|
+
}
|
|
676
|
+
__name(ToastItem, "ToastItem");
|
|
677
|
+
var ToastViewport = createComponent({
|
|
678
|
+
displayName: "Toast.Viewport",
|
|
679
|
+
__kui: { role: "display" },
|
|
680
|
+
render: /* @__PURE__ */ __name(({
|
|
681
|
+
placement = "bottom-end",
|
|
682
|
+
offset: offset3 = 16,
|
|
683
|
+
gap = 8,
|
|
684
|
+
label = "Notifications",
|
|
685
|
+
container,
|
|
686
|
+
className,
|
|
687
|
+
style,
|
|
688
|
+
...rest
|
|
689
|
+
}, ref) => {
|
|
690
|
+
const { theme } = useTheme();
|
|
691
|
+
const entries2 = useToasts();
|
|
692
|
+
const [mounted, setMounted] = useState(false);
|
|
693
|
+
const [hovered, setHovered] = useState(false);
|
|
694
|
+
const [focused, setFocused] = useState(false);
|
|
695
|
+
const [hidden, setHidden] = useState(false);
|
|
696
|
+
useEffect(() => setMounted(true), []);
|
|
697
|
+
useEffect(() => {
|
|
698
|
+
const sync = /* @__PURE__ */ __name(() => setHidden(document.hidden), "sync");
|
|
699
|
+
sync();
|
|
700
|
+
document.addEventListener("visibilitychange", sync);
|
|
701
|
+
return () => document.removeEventListener("visibilitychange", sync);
|
|
702
|
+
}, []);
|
|
703
|
+
useEffect(() => registerViewport(), []);
|
|
704
|
+
const empty = entries2.length === 0;
|
|
705
|
+
const expanded = hovered || focused;
|
|
706
|
+
useEffect(() => {
|
|
707
|
+
if (empty) {
|
|
708
|
+
setHovered(false);
|
|
709
|
+
setFocused(false);
|
|
710
|
+
}
|
|
711
|
+
}, [empty]);
|
|
712
|
+
const ctx = useMemo(
|
|
713
|
+
() => ({ paused: hovered || focused || hidden, placement }),
|
|
714
|
+
[hovered, focused, hidden, placement]
|
|
715
|
+
);
|
|
716
|
+
if (!mounted || empty) return null;
|
|
717
|
+
const pad = /* @__PURE__ */ __name((side) => `calc(${offset3}px + env(safe-area-inset-${side}, 0px))`, "pad");
|
|
718
|
+
return createPortal(
|
|
719
|
+
/* @__PURE__ */ jsx(ViewportContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
720
|
+
"div",
|
|
721
|
+
{
|
|
722
|
+
ref,
|
|
723
|
+
role: "region",
|
|
724
|
+
"aria-label": label,
|
|
725
|
+
tabIndex: -1,
|
|
726
|
+
"data-kui-toast-viewport": "",
|
|
727
|
+
className: cn(
|
|
728
|
+
resolveRecipe(theme.recipes.ToastViewport, { placement }),
|
|
729
|
+
className
|
|
730
|
+
),
|
|
731
|
+
style: {
|
|
732
|
+
paddingTop: pad("top"),
|
|
733
|
+
paddingRight: pad("right"),
|
|
734
|
+
paddingBottom: pad("bottom"),
|
|
735
|
+
paddingLeft: pad("left"),
|
|
736
|
+
gap: expanded ? gap : 0,
|
|
737
|
+
...style
|
|
738
|
+
},
|
|
739
|
+
onMouseEnter: () => setHovered(true),
|
|
740
|
+
onMouseLeave: () => setHovered(false),
|
|
741
|
+
onFocus: () => setFocused(true),
|
|
742
|
+
onBlur: (e) => {
|
|
743
|
+
if (!e.currentTarget.contains(e.relatedTarget))
|
|
744
|
+
setFocused(false);
|
|
745
|
+
},
|
|
746
|
+
...rest,
|
|
747
|
+
children: entries2.map((entry, index) => {
|
|
748
|
+
const stackIndex = entries2.length - index - 1;
|
|
749
|
+
return /* @__PURE__ */ jsx(
|
|
750
|
+
ToastItem,
|
|
751
|
+
{
|
|
752
|
+
entry,
|
|
753
|
+
placement,
|
|
754
|
+
stackIndex,
|
|
755
|
+
expanded
|
|
756
|
+
},
|
|
757
|
+
entry.id
|
|
758
|
+
);
|
|
759
|
+
})
|
|
760
|
+
}
|
|
761
|
+
) }),
|
|
762
|
+
container ?? document.body
|
|
763
|
+
);
|
|
764
|
+
}, "render")
|
|
765
|
+
});
|
|
766
|
+
var ToastProvider = createComponent({
|
|
767
|
+
displayName: "Toast.Provider",
|
|
768
|
+
__kui: { role: "display" },
|
|
769
|
+
render: /* @__PURE__ */ __name(({ children, maxVisible, duration: duration3 }, _ref) => {
|
|
770
|
+
useEffect(() => {
|
|
771
|
+
toastStore.configure({
|
|
772
|
+
...maxVisible != null && { maxVisible },
|
|
773
|
+
...duration3 != null && { duration: duration3 }
|
|
774
|
+
});
|
|
775
|
+
}, [maxVisible, duration3]);
|
|
776
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
777
|
+
}, "render")
|
|
778
|
+
});
|
|
779
|
+
var ToastRoot = createComponent({
|
|
780
|
+
displayName: "Toast.Root",
|
|
781
|
+
__kui: {
|
|
782
|
+
role: "display",
|
|
783
|
+
video: { id: "toast", safe: false }
|
|
784
|
+
},
|
|
785
|
+
render: /* @__PURE__ */ __name(({
|
|
786
|
+
open: openProp,
|
|
787
|
+
defaultOpen = false,
|
|
788
|
+
onOpenChange,
|
|
789
|
+
onDismiss,
|
|
790
|
+
children,
|
|
791
|
+
id: idProp,
|
|
792
|
+
status = "neutral",
|
|
793
|
+
title,
|
|
794
|
+
description,
|
|
795
|
+
icon,
|
|
796
|
+
action,
|
|
797
|
+
duration: duration3,
|
|
798
|
+
dismissible,
|
|
799
|
+
showProgress = true
|
|
800
|
+
}, _ref) => {
|
|
801
|
+
const autoId = useId();
|
|
802
|
+
const id = idProp ?? `kui-toast-${autoId}`;
|
|
803
|
+
const [inner, setInner] = useState(defaultOpen);
|
|
804
|
+
const controlled = openProp !== void 0;
|
|
805
|
+
const open2 = controlled ? openProp : inner;
|
|
806
|
+
const latest = useRef({ onOpenChange, onDismiss, controlled });
|
|
807
|
+
latest.current = { onOpenChange, onDismiss, controlled };
|
|
808
|
+
const fields = {
|
|
809
|
+
status,
|
|
810
|
+
title,
|
|
811
|
+
description,
|
|
812
|
+
icon,
|
|
813
|
+
action,
|
|
814
|
+
duration: duration3,
|
|
815
|
+
dismissible,
|
|
816
|
+
children,
|
|
817
|
+
showProgress
|
|
818
|
+
};
|
|
819
|
+
const fieldsRef = useRef(fields);
|
|
820
|
+
fieldsRef.current = fields;
|
|
821
|
+
useEffect(() => {
|
|
822
|
+
if (!open2) return;
|
|
823
|
+
toastStore.upsert(id, {
|
|
824
|
+
...fieldsRef.current,
|
|
825
|
+
onDismiss: /* @__PURE__ */ __name(() => {
|
|
826
|
+
latest.current.onDismiss?.(id);
|
|
827
|
+
if (!latest.current.controlled) setInner(false);
|
|
828
|
+
latest.current.onOpenChange?.(false);
|
|
829
|
+
}, "onDismiss")
|
|
830
|
+
});
|
|
831
|
+
return () => toastStore.deregister(id);
|
|
832
|
+
}, [open2, id]);
|
|
833
|
+
useEffect(() => {
|
|
834
|
+
if (open2) toastStore.patch(id, fields);
|
|
835
|
+
});
|
|
836
|
+
return null;
|
|
837
|
+
}, "render")
|
|
838
|
+
});
|
|
839
|
+
var Toast = {
|
|
840
|
+
Provider: ToastProvider,
|
|
841
|
+
Viewport: ToastViewport,
|
|
842
|
+
Root: ToastRoot,
|
|
843
|
+
Icon: ToastIcon,
|
|
844
|
+
Content: ToastContent,
|
|
845
|
+
Title: ToastTitle,
|
|
846
|
+
Description: ToastDescription,
|
|
847
|
+
Action: ToastAction,
|
|
848
|
+
Close: ToastClose
|
|
849
|
+
};
|
|
850
|
+
var OverlayRootContext = createContext(null);
|
|
851
|
+
function useOverlayRoot() {
|
|
852
|
+
return useContext(OverlayRootContext);
|
|
853
|
+
}
|
|
854
|
+
__name(useOverlayRoot, "useOverlayRoot");
|
|
855
|
+
|
|
856
|
+
// src/components/overlays/overlay/OverlayPortal.tsx
|
|
857
|
+
function OverlayPortal({ children }) {
|
|
858
|
+
const root = useOverlayRoot();
|
|
859
|
+
if (typeof document === "undefined") return null;
|
|
860
|
+
return createPortal(children, root ?? document.body);
|
|
861
|
+
}
|
|
862
|
+
__name(OverlayPortal, "OverlayPortal");
|
|
863
|
+
var TooltipContext = React11.createContext(null);
|
|
864
|
+
function useTooltipContext(part) {
|
|
865
|
+
const ctx = React11.useContext(TooltipContext);
|
|
866
|
+
if (!ctx)
|
|
867
|
+
throw new Error(`<${part}> must be rendered inside <Tooltip.Root>.`);
|
|
868
|
+
return ctx;
|
|
869
|
+
}
|
|
870
|
+
__name(useTooltipContext, "useTooltipContext");
|
|
871
|
+
var TooltipProviderContext = React11.createContext(null);
|
|
872
|
+
var DEFAULT_DELAY = { open: 500, close: 0 };
|
|
873
|
+
function TooltipProvider({
|
|
874
|
+
delay = 500,
|
|
875
|
+
skipDelayDuration = 300,
|
|
876
|
+
children
|
|
877
|
+
}) {
|
|
878
|
+
const value = React11.useMemo(() => ({ delay }), [delay]);
|
|
879
|
+
return /* @__PURE__ */ jsx(TooltipProviderContext.Provider, { value, children: /* @__PURE__ */ jsx(FloatingDelayGroup, { delay, timeoutMs: skipDelayDuration, children }) });
|
|
880
|
+
}
|
|
881
|
+
__name(TooltipProvider, "TooltipProvider");
|
|
882
|
+
function TooltipRoot({
|
|
883
|
+
open: openProp,
|
|
884
|
+
defaultOpen,
|
|
885
|
+
onOpenChange,
|
|
886
|
+
placement: placementProp = "top",
|
|
887
|
+
offset: offsetProp = 8,
|
|
888
|
+
delay,
|
|
889
|
+
children
|
|
890
|
+
}) {
|
|
891
|
+
const [open2, setOpen] = useControllableState$1({
|
|
892
|
+
value: openProp,
|
|
893
|
+
defaultValue: defaultOpen ?? false,
|
|
894
|
+
onChange: onOpenChange
|
|
895
|
+
});
|
|
896
|
+
const arrowRef = React11.useRef(null);
|
|
897
|
+
const id = React11.useId();
|
|
898
|
+
const provider = React11.useContext(TooltipProviderContext);
|
|
899
|
+
const { refs, floatingStyles, context, placement, middlewareData } = useFloating({
|
|
900
|
+
open: open2,
|
|
901
|
+
onOpenChange: setOpen,
|
|
902
|
+
placement: placementProp,
|
|
903
|
+
middleware: [
|
|
904
|
+
offset(offsetProp),
|
|
905
|
+
flip(),
|
|
906
|
+
shift({ padding: 8 }),
|
|
907
|
+
arrow({ element: arrowRef })
|
|
908
|
+
],
|
|
909
|
+
whileElementsMounted: autoUpdate
|
|
910
|
+
});
|
|
911
|
+
const group = useDelayGroup(context, { id });
|
|
912
|
+
const hoverDelay = delay ?? (provider ? group.delay : DEFAULT_DELAY);
|
|
913
|
+
const hover = useHover(context, {
|
|
914
|
+
move: false,
|
|
915
|
+
delay: hoverDelay,
|
|
916
|
+
handleClose: safePolygon()
|
|
917
|
+
});
|
|
918
|
+
const focus = useFocus(context);
|
|
919
|
+
const dismiss = useDismiss(context, { outsidePress: false });
|
|
920
|
+
const role = useRole(context, { role: "tooltip" });
|
|
921
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
922
|
+
hover,
|
|
923
|
+
focus,
|
|
924
|
+
dismiss,
|
|
925
|
+
role
|
|
926
|
+
]);
|
|
927
|
+
const value = {
|
|
928
|
+
open: open2,
|
|
929
|
+
setOpen,
|
|
930
|
+
refs,
|
|
931
|
+
floatingStyles,
|
|
932
|
+
floatingContext: context,
|
|
933
|
+
getReferenceProps,
|
|
934
|
+
getFloatingProps,
|
|
935
|
+
placement,
|
|
936
|
+
arrowRef,
|
|
937
|
+
arrow: { x: middlewareData.arrow?.x, y: middlewareData.arrow?.y }
|
|
938
|
+
};
|
|
939
|
+
return /* @__PURE__ */ jsx(TooltipContext.Provider, { value, children });
|
|
940
|
+
}
|
|
941
|
+
__name(TooltipRoot, "TooltipRoot");
|
|
942
|
+
function TooltipTriggerView({
|
|
943
|
+
asChild,
|
|
944
|
+
children,
|
|
945
|
+
forwardedRef,
|
|
946
|
+
...rest
|
|
947
|
+
}) {
|
|
948
|
+
const ctx = useTooltipContext("Tooltip.Trigger");
|
|
949
|
+
const generated = ctx.getReferenceProps();
|
|
950
|
+
const dataState = ctx.open ? "open" : "closed";
|
|
951
|
+
if (asChild && React11.isValidElement(children)) {
|
|
952
|
+
const child = children;
|
|
953
|
+
const { ref: childRef, ...childProps } = child.props;
|
|
954
|
+
const merged2 = createFromProps({
|
|
955
|
+
generatedProps: generated,
|
|
956
|
+
consumerProps: { ...rest, ...childProps }
|
|
957
|
+
});
|
|
958
|
+
return React11.cloneElement(child, {
|
|
959
|
+
...merged2,
|
|
960
|
+
"data-state": dataState,
|
|
961
|
+
ref: composeRefs(
|
|
962
|
+
ctx.refs.setReference,
|
|
963
|
+
forwardedRef,
|
|
964
|
+
childRef
|
|
965
|
+
)
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
const merged = createFromProps({
|
|
969
|
+
generatedProps: generated,
|
|
970
|
+
consumerProps: rest
|
|
971
|
+
});
|
|
972
|
+
return /* @__PURE__ */ jsx(
|
|
973
|
+
"button",
|
|
974
|
+
{
|
|
975
|
+
type: "button",
|
|
976
|
+
...merged,
|
|
977
|
+
"data-state": dataState,
|
|
978
|
+
ref: composeRefs(
|
|
979
|
+
ctx.refs.setReference,
|
|
980
|
+
forwardedRef
|
|
981
|
+
),
|
|
982
|
+
children
|
|
983
|
+
}
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
__name(TooltipTriggerView, "TooltipTriggerView");
|
|
987
|
+
var TooltipTrigger = createComponent$1({
|
|
988
|
+
__kui: { role: "overlay", groupSlot: "Tooltip" },
|
|
989
|
+
displayName: "Tooltip.Trigger",
|
|
990
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(TooltipTriggerView, { ...props, forwardedRef: ref }), "render")
|
|
991
|
+
});
|
|
992
|
+
function TooltipPortal({ children }) {
|
|
993
|
+
const ctx = useTooltipContext("Tooltip.Portal");
|
|
994
|
+
if (!ctx.open) return null;
|
|
995
|
+
return /* @__PURE__ */ jsx(OverlayPortal, { children });
|
|
996
|
+
}
|
|
997
|
+
__name(TooltipPortal, "TooltipPortal");
|
|
998
|
+
var sideOf = /* @__PURE__ */ __name((placement) => placement.split("-")[0], "sideOf");
|
|
999
|
+
function TooltipContentView({
|
|
1000
|
+
forwardedRef,
|
|
1001
|
+
children,
|
|
1002
|
+
className,
|
|
1003
|
+
style,
|
|
1004
|
+
...rest
|
|
1005
|
+
}) {
|
|
1006
|
+
const ctx = useTooltipContext("Tooltip.Content");
|
|
1007
|
+
const ref = React11.useMemo(
|
|
1008
|
+
() => composeRefs(
|
|
1009
|
+
forwardedRef,
|
|
1010
|
+
ctx.refs.setFloating
|
|
1011
|
+
),
|
|
1012
|
+
[forwardedRef, ctx.refs.setFloating]
|
|
1013
|
+
);
|
|
1014
|
+
const { theme } = useTheme();
|
|
1015
|
+
if (!ctx.open) return null;
|
|
1016
|
+
return /* @__PURE__ */ jsx(
|
|
1017
|
+
"div",
|
|
1018
|
+
{
|
|
1019
|
+
...ctx.getFloatingProps(rest),
|
|
1020
|
+
ref,
|
|
1021
|
+
style: { ...ctx.floatingStyles, ...style },
|
|
1022
|
+
className: resolveRecipe(theme.recipes.TooltipContent, {}, className),
|
|
1023
|
+
"data-state": "open",
|
|
1024
|
+
"data-side": sideOf(ctx.placement),
|
|
1025
|
+
children
|
|
1026
|
+
}
|
|
1027
|
+
);
|
|
1028
|
+
}
|
|
1029
|
+
__name(TooltipContentView, "TooltipContentView");
|
|
1030
|
+
var TooltipContent = createComponent$1({
|
|
1031
|
+
__kui: { role: "overlay", groupSlot: "Tooltip" },
|
|
1032
|
+
displayName: "Tooltip.Content",
|
|
1033
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(TooltipContentView, { ...props, forwardedRef: ref }), "render")
|
|
1034
|
+
});
|
|
1035
|
+
function TooltipArrowView({
|
|
1036
|
+
forwardedRef,
|
|
1037
|
+
className,
|
|
1038
|
+
style,
|
|
1039
|
+
...rest
|
|
1040
|
+
}) {
|
|
1041
|
+
const ctx = useTooltipContext("Tooltip.Arrow");
|
|
1042
|
+
const side = sideOf(ctx.placement);
|
|
1043
|
+
const ref = React11.useMemo(
|
|
1044
|
+
() => composeRefs(
|
|
1045
|
+
forwardedRef,
|
|
1046
|
+
ctx.arrowRef
|
|
1047
|
+
),
|
|
1048
|
+
[forwardedRef, ctx.arrowRef]
|
|
1049
|
+
);
|
|
1050
|
+
const vars = {};
|
|
1051
|
+
if (ctx.arrow.x != null) vars["--kui-tooltip-arrow-x"] = `${ctx.arrow.x}px`;
|
|
1052
|
+
if (ctx.arrow.y != null) vars["--kui-tooltip-arrow-y"] = `${ctx.arrow.y}px`;
|
|
1053
|
+
const { theme } = useTheme();
|
|
1054
|
+
return /* @__PURE__ */ jsx(
|
|
1055
|
+
"div",
|
|
1056
|
+
{
|
|
1057
|
+
...rest,
|
|
1058
|
+
ref,
|
|
1059
|
+
"aria-hidden": true,
|
|
1060
|
+
"data-side": side,
|
|
1061
|
+
style: { ...vars, ...style },
|
|
1062
|
+
className: resolveRecipe(theme.recipes.TooltipArrow, { side }, className)
|
|
1063
|
+
}
|
|
1064
|
+
);
|
|
1065
|
+
}
|
|
1066
|
+
__name(TooltipArrowView, "TooltipArrowView");
|
|
1067
|
+
var TooltipArrow = createComponent$1({
|
|
1068
|
+
__kui: { role: "display", groupSlot: "Tooltip" },
|
|
1069
|
+
displayName: "Tooltip.Arrow",
|
|
1070
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(TooltipArrowView, { ...props, forwardedRef: ref }), "render")
|
|
1071
|
+
});
|
|
1072
|
+
var Tooltip = {
|
|
1073
|
+
Root: TooltipRoot,
|
|
1074
|
+
Trigger: TooltipTrigger,
|
|
1075
|
+
Portal: TooltipPortal,
|
|
1076
|
+
Content: TooltipContent,
|
|
1077
|
+
Arrow: TooltipArrow
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
// src/components/overlays/Confirm/Confirm.types.ts
|
|
1081
|
+
var _ConfirmConflictError = class _ConfirmConflictError extends Error {
|
|
1082
|
+
constructor(pendingKey, requestedKey) {
|
|
1083
|
+
super(
|
|
1084
|
+
`confirmAction("${requestedKey}") rejected: a confirm ("${pendingKey}") is already pending. Confirms do not stack or queue.`
|
|
1085
|
+
);
|
|
1086
|
+
this.pendingKey = pendingKey;
|
|
1087
|
+
this.requestedKey = requestedKey;
|
|
1088
|
+
__publicField(this, "name", "ConfirmConflictError");
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
__name(_ConfirmConflictError, "ConfirmConflictError");
|
|
1092
|
+
var ConfirmConflictError = _ConfirmConflictError;
|
|
1093
|
+
|
|
1094
|
+
// src/components/overlays/Confirm/ConfirmRequestManager.ts
|
|
1095
|
+
var _ConfirmRequestManager = class _ConfirmRequestManager {
|
|
1096
|
+
constructor() {
|
|
1097
|
+
__publicField(this, "entry", null);
|
|
1098
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
1099
|
+
__publicField(this, "snapshot", null);
|
|
1100
|
+
__publicField(this, "seq", 0);
|
|
1101
|
+
__publicField(this, "request", /* @__PURE__ */ __name((options, owner) => {
|
|
1102
|
+
const current = this.entry;
|
|
1103
|
+
if (current) {
|
|
1104
|
+
const sameKey = current.options.key === options.key;
|
|
1105
|
+
const sameMessage = current.options.message === options.message;
|
|
1106
|
+
if (sameKey && sameMessage) {
|
|
1107
|
+
if (owner) current.owners.add(owner);
|
|
1108
|
+
else current.ownerless = true;
|
|
1109
|
+
return current.promise;
|
|
1110
|
+
}
|
|
1111
|
+
return Promise.reject(
|
|
1112
|
+
new ConfirmConflictError(current.options.key, options.key)
|
|
1113
|
+
);
|
|
1114
|
+
}
|
|
1115
|
+
let settle2;
|
|
1116
|
+
const promise3 = new Promise((res) => settle2 = res);
|
|
1117
|
+
this.entry = {
|
|
1118
|
+
id: `kui-confirm-${++this.seq}`,
|
|
1119
|
+
options,
|
|
1120
|
+
promise: promise3,
|
|
1121
|
+
settle: settle2,
|
|
1122
|
+
owners: new Set(owner ? [owner] : []),
|
|
1123
|
+
ownerless: !owner
|
|
1124
|
+
};
|
|
1125
|
+
this.publish();
|
|
1126
|
+
return promise3;
|
|
1127
|
+
}, "request"));
|
|
1128
|
+
/** Called by the dialog when the user acts. No-op if `id` is no longer the pending request. */
|
|
1129
|
+
__publicField(this, "resolve", /* @__PURE__ */ __name((id, result) => {
|
|
1130
|
+
const current = this.entry;
|
|
1131
|
+
if (!current || current.id !== id) return;
|
|
1132
|
+
this.entry = null;
|
|
1133
|
+
current.settle(result);
|
|
1134
|
+
this.publish();
|
|
1135
|
+
}, "resolve"));
|
|
1136
|
+
/** Termination (unmount / navigation) resolves `false`, never rejects. */
|
|
1137
|
+
__publicField(this, "cancelAll", /* @__PURE__ */ __name(() => {
|
|
1138
|
+
const current = this.entry;
|
|
1139
|
+
if (!current) return;
|
|
1140
|
+
this.entry = null;
|
|
1141
|
+
current.settle(false);
|
|
1142
|
+
this.publish();
|
|
1143
|
+
}, "cancelAll"));
|
|
1144
|
+
/** Drop one caller. Cancels only if nobody else (incl. ownerless callers) still wants it. */
|
|
1145
|
+
__publicField(this, "cancelOwner", /* @__PURE__ */ __name((owner) => {
|
|
1146
|
+
const current = this.entry;
|
|
1147
|
+
if (!current || !current.owners.delete(owner)) return;
|
|
1148
|
+
if (current.owners.size === 0 && !current.ownerless) this.cancelAll();
|
|
1149
|
+
}, "cancelOwner"));
|
|
1150
|
+
__publicField(this, "getPending", /* @__PURE__ */ __name(() => this.snapshot, "getPending"));
|
|
1151
|
+
__publicField(this, "subscribe", /* @__PURE__ */ __name((listener) => {
|
|
1152
|
+
this.listeners.add(listener);
|
|
1153
|
+
return () => this.listeners.delete(listener);
|
|
1154
|
+
}, "subscribe"));
|
|
1155
|
+
}
|
|
1156
|
+
publish() {
|
|
1157
|
+
const e = this.entry;
|
|
1158
|
+
this.snapshot = e ? { id: e.id, options: e.options, promise: e.promise } : null;
|
|
1159
|
+
this.listeners.forEach((l) => l());
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
__name(_ConfirmRequestManager, "ConfirmRequestManager");
|
|
1163
|
+
var ConfirmRequestManager = _ConfirmRequestManager;
|
|
1164
|
+
var createConfirmRequestManager = /* @__PURE__ */ __name(() => new ConfirmRequestManager(), "createConfirmRequestManager");
|
|
1165
|
+
var defaultConfirmManager = createConfirmRequestManager();
|
|
1166
|
+
|
|
1167
|
+
// src/components/overlays/Confirm/confirmAction.ts
|
|
1168
|
+
function createConfirmAction(manager) {
|
|
1169
|
+
return (options) => manager.request(options);
|
|
1170
|
+
}
|
|
1171
|
+
__name(createConfirmAction, "createConfirmAction");
|
|
1172
|
+
var confirmAction = createConfirmAction(defaultConfirmManager);
|
|
1173
|
+
function useConfirmAction(manager = defaultConfirmManager) {
|
|
1174
|
+
const [owner] = React11.useState(() => /* @__PURE__ */ Symbol("confirm-owner"));
|
|
1175
|
+
React11.useEffect(() => () => manager.cancelOwner(owner), [manager, owner]);
|
|
1176
|
+
return React11.useCallback((options) => manager.request(options, owner), [manager, owner]);
|
|
1177
|
+
}
|
|
1178
|
+
__name(useConfirmAction, "useConfirmAction");
|
|
1179
|
+
|
|
1180
|
+
// src/components/overlays/Dialog/DialogStack.ts
|
|
1181
|
+
var _DialogStack = class _DialogStack {
|
|
1182
|
+
constructor() {
|
|
1183
|
+
__publicField(this, "order", []);
|
|
1184
|
+
__publicField(this, "listeners", /* @__PURE__ */ new Set());
|
|
1185
|
+
__publicField(this, "version", 0);
|
|
1186
|
+
__publicField(this, "register", /* @__PURE__ */ __name((id) => {
|
|
1187
|
+
if (this.order.includes(id)) return;
|
|
1188
|
+
this.order = [...this.order, id];
|
|
1189
|
+
this.emit();
|
|
1190
|
+
}, "register"));
|
|
1191
|
+
__publicField(this, "unregister", /* @__PURE__ */ __name((id) => {
|
|
1192
|
+
if (!this.order.includes(id)) return;
|
|
1193
|
+
this.order = this.order.filter((x) => x !== id);
|
|
1194
|
+
this.emit();
|
|
1195
|
+
}, "unregister"));
|
|
1196
|
+
__publicField(this, "isRegistered", /* @__PURE__ */ __name((id) => this.order.includes(id), "isRegistered"));
|
|
1197
|
+
__publicField(this, "isTopmost", /* @__PURE__ */ __name((id) => this.order[this.order.length - 1] === id, "isTopmost"));
|
|
1198
|
+
__publicField(this, "isSuspended", /* @__PURE__ */ __name((id) => this.isRegistered(id) && !this.isTopmost(id), "isSuspended"));
|
|
1199
|
+
__publicField(this, "subscribe", /* @__PURE__ */ __name((listener) => {
|
|
1200
|
+
this.listeners.add(listener);
|
|
1201
|
+
return () => this.listeners.delete(listener);
|
|
1202
|
+
}, "subscribe"));
|
|
1203
|
+
/** Changes on every mutation — for useSyncExternalStore. */
|
|
1204
|
+
__publicField(this, "getSnapshot", /* @__PURE__ */ __name(() => this.version, "getSnapshot"));
|
|
1205
|
+
}
|
|
1206
|
+
emit() {
|
|
1207
|
+
this.version++;
|
|
1208
|
+
this.listeners.forEach((l) => l());
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
__name(_DialogStack, "DialogStack");
|
|
1212
|
+
var DialogStack = _DialogStack;
|
|
1213
|
+
var DialogStackContext = createContext(null);
|
|
1214
|
+
var fallbackStack = new DialogStack();
|
|
1215
|
+
function DialogProvider({ children }) {
|
|
1216
|
+
const stack = useMemo(() => new DialogStack(), []);
|
|
1217
|
+
return /* @__PURE__ */ jsx(DialogStackContext.Provider, { value: stack, children });
|
|
1218
|
+
}
|
|
1219
|
+
__name(DialogProvider, "DialogProvider");
|
|
1220
|
+
function useDialogStack() {
|
|
1221
|
+
return useContext(DialogStackContext) ?? fallbackStack;
|
|
1222
|
+
}
|
|
1223
|
+
__name(useDialogStack, "useDialogStack");
|
|
1224
|
+
function useDialogState(id) {
|
|
1225
|
+
const stack = useDialogStack();
|
|
1226
|
+
useSyncExternalStore(stack.subscribe, stack.getSnapshot, stack.getSnapshot);
|
|
1227
|
+
return {
|
|
1228
|
+
stack,
|
|
1229
|
+
isRegistered: stack.isRegistered(id),
|
|
1230
|
+
isTopmost: stack.isTopmost(id),
|
|
1231
|
+
isSuspended: stack.isSuspended(id)
|
|
1232
|
+
};
|
|
1233
|
+
}
|
|
1234
|
+
__name(useDialogState, "useDialogState");
|
|
1235
|
+
var CONFIRM_DEFAULTS = {
|
|
1236
|
+
confirmLabel: "Confirm",
|
|
1237
|
+
cancelLabel: "Cancel",
|
|
1238
|
+
status: "neutral"
|
|
1239
|
+
};
|
|
1240
|
+
function ConfirmDialogView({ contentRef, ...raw }) {
|
|
1241
|
+
const props = createFromProps({
|
|
1242
|
+
defaultProps: CONFIRM_DEFAULTS,
|
|
1243
|
+
consumerProps: raw
|
|
1244
|
+
});
|
|
1245
|
+
const {
|
|
1246
|
+
id,
|
|
1247
|
+
title,
|
|
1248
|
+
message,
|
|
1249
|
+
confirmLabel,
|
|
1250
|
+
cancelLabel,
|
|
1251
|
+
status,
|
|
1252
|
+
onResolve,
|
|
1253
|
+
className,
|
|
1254
|
+
icon,
|
|
1255
|
+
...rest
|
|
1256
|
+
} = props;
|
|
1257
|
+
const { stack, isTopmost, isSuspended } = useDialogState(id);
|
|
1258
|
+
const uid = React11.useId();
|
|
1259
|
+
const titleId = `${uid}-title`;
|
|
1260
|
+
const messageId = `${uid}-message`;
|
|
1261
|
+
const cautious = status === "warning" || status === "error";
|
|
1262
|
+
const resolvedRef = React11.useRef(false);
|
|
1263
|
+
const resolve = React11.useCallback(
|
|
1264
|
+
(result) => {
|
|
1265
|
+
if (resolvedRef.current) return;
|
|
1266
|
+
resolvedRef.current = true;
|
|
1267
|
+
onResolve(result);
|
|
1268
|
+
},
|
|
1269
|
+
[onResolve]
|
|
1270
|
+
);
|
|
1271
|
+
React11.useEffect(() => {
|
|
1272
|
+
stack.register(id);
|
|
1273
|
+
return () => stack.unregister(id);
|
|
1274
|
+
}, [stack, id]);
|
|
1275
|
+
React11.useEffect(() => {
|
|
1276
|
+
if (!isTopmost || isSuspended) return;
|
|
1277
|
+
const onKeyDown = /* @__PURE__ */ __name((event) => {
|
|
1278
|
+
if (event.key !== "Escape" || event.repeat) return;
|
|
1279
|
+
event.preventDefault();
|
|
1280
|
+
event.stopPropagation();
|
|
1281
|
+
resolve(false);
|
|
1282
|
+
}, "onKeyDown");
|
|
1283
|
+
document.addEventListener("keydown", onKeyDown);
|
|
1284
|
+
return () => {
|
|
1285
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
1286
|
+
};
|
|
1287
|
+
}, [isTopmost, isSuspended, resolve]);
|
|
1288
|
+
const { refs, context } = useFloating({
|
|
1289
|
+
open: true
|
|
1290
|
+
});
|
|
1291
|
+
const mergedRef = React11.useMemo(
|
|
1292
|
+
() => composeRefs(
|
|
1293
|
+
contentRef,
|
|
1294
|
+
refs.setFloating
|
|
1295
|
+
),
|
|
1296
|
+
[contentRef, refs.setFloating]
|
|
1297
|
+
);
|
|
1298
|
+
const confirmRef = React11.useRef(null);
|
|
1299
|
+
const cancelRef = React11.useRef(null);
|
|
1300
|
+
const { theme } = useTheme();
|
|
1301
|
+
return /* @__PURE__ */ jsx(OverlayPortal, { children: /* @__PURE__ */ jsxs(
|
|
1302
|
+
"div",
|
|
1303
|
+
{
|
|
1304
|
+
className: resolveRecipe(theme.recipes.ConfirmLayer),
|
|
1305
|
+
"data-kui-part": "confirm-layer",
|
|
1306
|
+
"data-state": isSuspended ? "suspended" : "open",
|
|
1307
|
+
inert: isSuspended,
|
|
1308
|
+
"aria-hidden": isSuspended || void 0,
|
|
1309
|
+
children: [
|
|
1310
|
+
/* @__PURE__ */ jsx(
|
|
1311
|
+
"div",
|
|
1312
|
+
{
|
|
1313
|
+
className: resolveRecipe(theme.recipes.ConfirmOverlay),
|
|
1314
|
+
"data-kui-part": "confirm-overlay",
|
|
1315
|
+
"aria-hidden": "true"
|
|
1316
|
+
}
|
|
1317
|
+
),
|
|
1318
|
+
/* @__PURE__ */ jsx(
|
|
1319
|
+
FloatingFocusManager,
|
|
1320
|
+
{
|
|
1321
|
+
context,
|
|
1322
|
+
modal: true,
|
|
1323
|
+
disabled: isSuspended,
|
|
1324
|
+
initialFocus: cautious ? cancelRef : confirmRef,
|
|
1325
|
+
returnFocus: true,
|
|
1326
|
+
children: /* @__PURE__ */ jsxs(
|
|
1327
|
+
"div",
|
|
1328
|
+
{
|
|
1329
|
+
...rest,
|
|
1330
|
+
ref: mergedRef,
|
|
1331
|
+
role: cautious ? "alertdialog" : "dialog",
|
|
1332
|
+
"aria-modal": "true",
|
|
1333
|
+
"aria-labelledby": titleId,
|
|
1334
|
+
"aria-describedby": message ? messageId : void 0,
|
|
1335
|
+
tabIndex: -1,
|
|
1336
|
+
"data-kui-part": "confirm-content",
|
|
1337
|
+
"data-status": status,
|
|
1338
|
+
className: resolveRecipe(
|
|
1339
|
+
theme.recipes.ConfirmContent,
|
|
1340
|
+
{},
|
|
1341
|
+
className
|
|
1342
|
+
),
|
|
1343
|
+
children: [
|
|
1344
|
+
/* @__PURE__ */ jsxs(
|
|
1345
|
+
"div",
|
|
1346
|
+
{
|
|
1347
|
+
className: resolveRecipe(theme.recipes.ConfirmHeader),
|
|
1348
|
+
"data-kui-part": "confirm-header",
|
|
1349
|
+
children: [
|
|
1350
|
+
icon && /* @__PURE__ */ jsx(
|
|
1351
|
+
"div",
|
|
1352
|
+
{
|
|
1353
|
+
className: resolveRecipe(theme.recipes.ConfirmIcon, {
|
|
1354
|
+
status
|
|
1355
|
+
}),
|
|
1356
|
+
"data-kui-part": "confirm-icon",
|
|
1357
|
+
"aria-hidden": "true",
|
|
1358
|
+
children: icon
|
|
1359
|
+
}
|
|
1360
|
+
),
|
|
1361
|
+
/* @__PURE__ */ jsx(
|
|
1362
|
+
"h2",
|
|
1363
|
+
{
|
|
1364
|
+
id: titleId,
|
|
1365
|
+
className: resolveRecipe(theme.recipes.ConfirmTitle),
|
|
1366
|
+
"data-kui-part": "confirm-title",
|
|
1367
|
+
children: title
|
|
1368
|
+
}
|
|
1369
|
+
),
|
|
1370
|
+
message && /* @__PURE__ */ jsx(
|
|
1371
|
+
"p",
|
|
1372
|
+
{
|
|
1373
|
+
id: messageId,
|
|
1374
|
+
className: resolveRecipe(theme.recipes.ConfirmMessage),
|
|
1375
|
+
"data-kui-part": "confirm-message",
|
|
1376
|
+
children: message
|
|
1377
|
+
}
|
|
1378
|
+
)
|
|
1379
|
+
]
|
|
1380
|
+
}
|
|
1381
|
+
),
|
|
1382
|
+
/* @__PURE__ */ jsxs(
|
|
1383
|
+
"div",
|
|
1384
|
+
{
|
|
1385
|
+
className: resolveRecipe(theme.recipes.ConfirmActions),
|
|
1386
|
+
"data-kui-part": "confirm-actions",
|
|
1387
|
+
children: [
|
|
1388
|
+
/* @__PURE__ */ jsx(
|
|
1389
|
+
"button",
|
|
1390
|
+
{
|
|
1391
|
+
ref: cancelRef,
|
|
1392
|
+
type: "button",
|
|
1393
|
+
"data-kui-part": "confirm-cancel",
|
|
1394
|
+
className: resolveRecipe(theme.recipes.ConfirmButton, {
|
|
1395
|
+
intent: "cancel"
|
|
1396
|
+
}),
|
|
1397
|
+
onClick: () => resolve(false),
|
|
1398
|
+
children: cancelLabel
|
|
1399
|
+
}
|
|
1400
|
+
),
|
|
1401
|
+
/* @__PURE__ */ jsx(
|
|
1402
|
+
"button",
|
|
1403
|
+
{
|
|
1404
|
+
ref: confirmRef,
|
|
1405
|
+
type: "button",
|
|
1406
|
+
"data-kui-part": "confirm-submit",
|
|
1407
|
+
className: resolveRecipe(theme.recipes.ConfirmButton, {
|
|
1408
|
+
intent: "confirm",
|
|
1409
|
+
status
|
|
1410
|
+
}),
|
|
1411
|
+
onClick: () => resolve(true),
|
|
1412
|
+
children: confirmLabel
|
|
1413
|
+
}
|
|
1414
|
+
)
|
|
1415
|
+
]
|
|
1416
|
+
}
|
|
1417
|
+
)
|
|
1418
|
+
]
|
|
1419
|
+
}
|
|
1420
|
+
)
|
|
1421
|
+
}
|
|
1422
|
+
)
|
|
1423
|
+
]
|
|
1424
|
+
}
|
|
1425
|
+
) });
|
|
1426
|
+
}
|
|
1427
|
+
__name(ConfirmDialogView, "ConfirmDialogView");
|
|
1428
|
+
var ConfirmDialog = createComponent$1({
|
|
1429
|
+
__kui: {
|
|
1430
|
+
role: "overlay",
|
|
1431
|
+
skeleton: "preserve"
|
|
1432
|
+
},
|
|
1433
|
+
displayName: "ConfirmDialog",
|
|
1434
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(ConfirmDialogView, { ...props, contentRef: ref }), "render")
|
|
1435
|
+
});
|
|
1436
|
+
function ConfirmHost({ manager = defaultConfirmManager, cancelOnNavigation = true }) {
|
|
1437
|
+
const pending = React11.useSyncExternalStore(manager.subscribe, manager.getPending, manager.getPending);
|
|
1438
|
+
React11.useEffect(() => () => manager.cancelAll(), [manager]);
|
|
1439
|
+
React11.useEffect(() => {
|
|
1440
|
+
if (!cancelOnNavigation) return;
|
|
1441
|
+
window.addEventListener("popstate", manager.cancelAll);
|
|
1442
|
+
return () => window.removeEventListener("popstate", manager.cancelAll);
|
|
1443
|
+
}, [manager, cancelOnNavigation]);
|
|
1444
|
+
if (!pending) return null;
|
|
1445
|
+
const { key: _key, ...dialogOptions } = pending.options;
|
|
1446
|
+
return /* @__PURE__ */ jsx(
|
|
1447
|
+
ConfirmDialog,
|
|
1448
|
+
{
|
|
1449
|
+
id: pending.id,
|
|
1450
|
+
...dialogOptions,
|
|
1451
|
+
onResolve: (result) => manager.resolve(pending.id, result)
|
|
1452
|
+
},
|
|
1453
|
+
pending.id
|
|
1454
|
+
);
|
|
1455
|
+
}
|
|
1456
|
+
__name(ConfirmHost, "ConfirmHost");
|
|
1457
|
+
var MenuContext = React11.createContext(null);
|
|
1458
|
+
function useMenuContext(part) {
|
|
1459
|
+
const ctx = React11.useContext(MenuContext);
|
|
1460
|
+
if (!ctx) throw new Error(`<${part}> must be rendered inside <Menu.Root>.`);
|
|
1461
|
+
return ctx;
|
|
1462
|
+
}
|
|
1463
|
+
__name(useMenuContext, "useMenuContext");
|
|
1464
|
+
var MenuPortalContext = React11.createContext(false);
|
|
1465
|
+
var MenuRadioGroupContext = React11.createContext(null);
|
|
1466
|
+
function useMenuSize() {
|
|
1467
|
+
return useMemo(
|
|
1468
|
+
() => size({
|
|
1469
|
+
padding: 8,
|
|
1470
|
+
apply({ availableHeight, elements }) {
|
|
1471
|
+
const configuredHeight = elements.floating.dataset.maxHeight;
|
|
1472
|
+
const available = `${Math.max(0, availableHeight)}px`;
|
|
1473
|
+
elements.floating.style.maxHeight = configuredHeight ? `min(${configuredHeight}, ${available})` : available;
|
|
1474
|
+
elements.floating.style.overflowY = "auto";
|
|
1475
|
+
elements.floating.style.overflowX = "hidden";
|
|
1476
|
+
}
|
|
1477
|
+
}),
|
|
1478
|
+
[]
|
|
1479
|
+
);
|
|
1480
|
+
}
|
|
1481
|
+
__name(useMenuSize, "useMenuSize");
|
|
1482
|
+
|
|
1483
|
+
// src/components/overlays/Menu/useMenuLevel.ts
|
|
1484
|
+
function useMenuLevel(opts) {
|
|
1485
|
+
const { nested } = opts;
|
|
1486
|
+
const enclosing = React11.useContext(MenuContext);
|
|
1487
|
+
const [open2, setOpen] = useControllableState$1({
|
|
1488
|
+
value: opts.open,
|
|
1489
|
+
defaultValue: opts.defaultOpen ?? false,
|
|
1490
|
+
onChange: opts.onOpenChange
|
|
1491
|
+
});
|
|
1492
|
+
const menuSize = useMenuSize();
|
|
1493
|
+
const [activeIndex, setActiveIndex] = React11.useState(null);
|
|
1494
|
+
const elementsRef = React11.useRef([]);
|
|
1495
|
+
const labelsRef = React11.useRef([]);
|
|
1496
|
+
const tree = useFloatingTree();
|
|
1497
|
+
const nodeId = useFloatingNodeId();
|
|
1498
|
+
const parentId = useFloatingParentNodeId();
|
|
1499
|
+
const { refs, floatingStyles, context } = useFloating({
|
|
1500
|
+
nodeId,
|
|
1501
|
+
open: open2,
|
|
1502
|
+
onOpenChange: setOpen,
|
|
1503
|
+
placement: nested ? "right-start" : opts.placement ?? "bottom-start",
|
|
1504
|
+
middleware: [
|
|
1505
|
+
offset(
|
|
1506
|
+
nested ? { mainAxis: 0, alignmentAxis: -4 } : { mainAxis: opts.offset ?? 4 }
|
|
1507
|
+
),
|
|
1508
|
+
flip(),
|
|
1509
|
+
shift({ padding: 8 }),
|
|
1510
|
+
menuSize
|
|
1511
|
+
],
|
|
1512
|
+
whileElementsMounted: autoUpdate
|
|
1513
|
+
});
|
|
1514
|
+
const hover = useHover(context, {
|
|
1515
|
+
enabled: nested,
|
|
1516
|
+
delay: { open: 75 },
|
|
1517
|
+
handleClose: safePolygon({ blockPointerEvents: true })
|
|
1518
|
+
});
|
|
1519
|
+
const click = useClick(context, {
|
|
1520
|
+
event: nested ? "click" : "mousedown",
|
|
1521
|
+
toggle: !nested
|
|
1522
|
+
});
|
|
1523
|
+
const role = useRole(context, { role: "menu" });
|
|
1524
|
+
const dismiss = useDismiss(context, { bubbles: true });
|
|
1525
|
+
const listNavigation = useListNavigation(context, {
|
|
1526
|
+
listRef: elementsRef,
|
|
1527
|
+
activeIndex,
|
|
1528
|
+
nested,
|
|
1529
|
+
onNavigate: setActiveIndex
|
|
1530
|
+
});
|
|
1531
|
+
const typeahead = useTypeahead(context, {
|
|
1532
|
+
listRef: labelsRef,
|
|
1533
|
+
activeIndex,
|
|
1534
|
+
onMatch: open2 ? setActiveIndex : void 0
|
|
1535
|
+
});
|
|
1536
|
+
const { getReferenceProps, getFloatingProps, getItemProps } = useInteractions(
|
|
1537
|
+
[hover, click, role, dismiss, listNavigation, typeahead]
|
|
1538
|
+
);
|
|
1539
|
+
React11.useEffect(() => {
|
|
1540
|
+
if (!tree) return;
|
|
1541
|
+
const onItemClick = /* @__PURE__ */ __name(() => setOpen(false), "onItemClick");
|
|
1542
|
+
const onMenuOpen = /* @__PURE__ */ __name((e) => {
|
|
1543
|
+
if (e.nodeId !== nodeId && e.parentId === parentId) setOpen(false);
|
|
1544
|
+
}, "onMenuOpen");
|
|
1545
|
+
tree.events.on("click", onItemClick);
|
|
1546
|
+
tree.events.on("menuopen", onMenuOpen);
|
|
1547
|
+
return () => {
|
|
1548
|
+
tree.events.off("click", onItemClick);
|
|
1549
|
+
tree.events.off("menuopen", onMenuOpen);
|
|
1550
|
+
};
|
|
1551
|
+
}, [tree, nodeId, parentId, setOpen]);
|
|
1552
|
+
React11.useEffect(() => {
|
|
1553
|
+
if (open2 && tree) tree.events.emit("menuopen", { parentId, nodeId });
|
|
1554
|
+
}, [tree, open2, nodeId, parentId]);
|
|
1555
|
+
React11.useEffect(() => {
|
|
1556
|
+
if (!open2) setActiveIndex(null);
|
|
1557
|
+
}, [open2]);
|
|
1558
|
+
return {
|
|
1559
|
+
open: open2,
|
|
1560
|
+
setOpen,
|
|
1561
|
+
nested,
|
|
1562
|
+
refs,
|
|
1563
|
+
floatingStyles,
|
|
1564
|
+
floatingContext: context,
|
|
1565
|
+
getReferenceProps,
|
|
1566
|
+
getFloatingProps,
|
|
1567
|
+
getItemProps,
|
|
1568
|
+
activeIndex,
|
|
1569
|
+
elementsRef,
|
|
1570
|
+
labelsRef,
|
|
1571
|
+
tree,
|
|
1572
|
+
nodeId,
|
|
1573
|
+
parent: nested ? enclosing : null
|
|
1574
|
+
};
|
|
1575
|
+
}
|
|
1576
|
+
__name(useMenuLevel, "useMenuLevel");
|
|
1577
|
+
function LevelProvider({
|
|
1578
|
+
level,
|
|
1579
|
+
children
|
|
1580
|
+
}) {
|
|
1581
|
+
return /* @__PURE__ */ jsx(MenuContext.Provider, { value: level, children: /* @__PURE__ */ jsx(FloatingNode, { id: level.nodeId, children }) });
|
|
1582
|
+
}
|
|
1583
|
+
__name(LevelProvider, "LevelProvider");
|
|
1584
|
+
function MenuRootInner({ children, ...opts }) {
|
|
1585
|
+
const level = useMenuLevel({ nested: false, ...opts });
|
|
1586
|
+
return /* @__PURE__ */ jsx(LevelProvider, { level, children });
|
|
1587
|
+
}
|
|
1588
|
+
__name(MenuRootInner, "MenuRootInner");
|
|
1589
|
+
function MenuRoot(props) {
|
|
1590
|
+
const parentId = useFloatingParentNodeId();
|
|
1591
|
+
const inner = /* @__PURE__ */ jsx(MenuRootInner, { ...props });
|
|
1592
|
+
return parentId === null ? /* @__PURE__ */ jsx(FloatingTree, { children: inner }) : inner;
|
|
1593
|
+
}
|
|
1594
|
+
__name(MenuRoot, "MenuRoot");
|
|
1595
|
+
function MenuSub({ children, ...opts }) {
|
|
1596
|
+
useMenuContext("Menu.Sub");
|
|
1597
|
+
const level = useMenuLevel({ nested: true, ...opts });
|
|
1598
|
+
return /* @__PURE__ */ jsx(LevelProvider, { level, children });
|
|
1599
|
+
}
|
|
1600
|
+
__name(MenuSub, "MenuSub");
|
|
1601
|
+
function MenuPortal({ children }) {
|
|
1602
|
+
const ctx = useMenuContext("Menu.Portal");
|
|
1603
|
+
if (!ctx.open) return null;
|
|
1604
|
+
return /* @__PURE__ */ jsx(OverlayPortal, { children: /* @__PURE__ */ jsx(MenuPortalContext.Provider, { value: true, children }) });
|
|
1605
|
+
}
|
|
1606
|
+
__name(MenuPortal, "MenuPortal");
|
|
1607
|
+
function MenuTriggerView({
|
|
1608
|
+
asChild,
|
|
1609
|
+
children,
|
|
1610
|
+
forwardedRef,
|
|
1611
|
+
...rest
|
|
1612
|
+
}) {
|
|
1613
|
+
const ctx = useMenuContext("Menu.Trigger");
|
|
1614
|
+
const generated = ctx.getReferenceProps();
|
|
1615
|
+
const dataState = ctx.open ? "open" : "closed";
|
|
1616
|
+
if (asChild && React11.isValidElement(children)) {
|
|
1617
|
+
const child = children;
|
|
1618
|
+
const { ref: childRef, ...childProps } = child.props;
|
|
1619
|
+
const merged2 = createFromProps({
|
|
1620
|
+
generatedProps: generated,
|
|
1621
|
+
consumerProps: { ...rest, ...childProps }
|
|
1622
|
+
});
|
|
1623
|
+
return React11.cloneElement(child, {
|
|
1624
|
+
...merged2,
|
|
1625
|
+
"data-state": dataState,
|
|
1626
|
+
ref: composeRefs(
|
|
1627
|
+
ctx.refs.setReference,
|
|
1628
|
+
forwardedRef,
|
|
1629
|
+
childRef
|
|
1630
|
+
)
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1633
|
+
const merged = createFromProps({
|
|
1634
|
+
generatedProps: generated,
|
|
1635
|
+
consumerProps: rest
|
|
1636
|
+
});
|
|
1637
|
+
return /* @__PURE__ */ jsx(
|
|
1638
|
+
"button",
|
|
1639
|
+
{
|
|
1640
|
+
type: "button",
|
|
1641
|
+
...merged,
|
|
1642
|
+
"data-state": dataState,
|
|
1643
|
+
ref: composeRefs(
|
|
1644
|
+
ctx.refs.setReference,
|
|
1645
|
+
forwardedRef
|
|
1646
|
+
),
|
|
1647
|
+
children
|
|
1648
|
+
}
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
__name(MenuTriggerView, "MenuTriggerView");
|
|
1652
|
+
var MenuTrigger = createComponent$1({
|
|
1653
|
+
__kui: { role: "overlay", groupSlot: "Menu" },
|
|
1654
|
+
displayName: "Menu.Trigger",
|
|
1655
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuTriggerView, { ...props, forwardedRef: ref }), "render")
|
|
1656
|
+
});
|
|
1657
|
+
function MenuPanel({
|
|
1658
|
+
forwardedRef,
|
|
1659
|
+
portal,
|
|
1660
|
+
children,
|
|
1661
|
+
className,
|
|
1662
|
+
style,
|
|
1663
|
+
maxHeight,
|
|
1664
|
+
...rest
|
|
1665
|
+
}) {
|
|
1666
|
+
const ctx = useMenuContext("Menu.Content");
|
|
1667
|
+
const { theme } = useTheme();
|
|
1668
|
+
const ref = React11.useMemo(
|
|
1669
|
+
() => composeRefs(
|
|
1670
|
+
forwardedRef,
|
|
1671
|
+
ctx.refs.setFloating
|
|
1672
|
+
),
|
|
1673
|
+
[forwardedRef, ctx.refs.setFloating]
|
|
1674
|
+
);
|
|
1675
|
+
if (!ctx.open) return null;
|
|
1676
|
+
const node2 = /* @__PURE__ */ jsx(
|
|
1677
|
+
FloatingFocusManager,
|
|
1678
|
+
{
|
|
1679
|
+
context: ctx.floatingContext,
|
|
1680
|
+
modal: false,
|
|
1681
|
+
initialFocus: ctx.nested ? -1 : 0,
|
|
1682
|
+
returnFocus: !ctx.nested,
|
|
1683
|
+
children: /* @__PURE__ */ jsx(
|
|
1684
|
+
"div",
|
|
1685
|
+
{
|
|
1686
|
+
...ctx.getFloatingProps(rest),
|
|
1687
|
+
ref,
|
|
1688
|
+
style: { ...ctx.floatingStyles, ...style },
|
|
1689
|
+
className: resolveRecipe(theme.recipes.MenuContent, {}, className),
|
|
1690
|
+
"data-state": "open",
|
|
1691
|
+
"data-menu-content": "",
|
|
1692
|
+
"data-max-height": maxHeight == null ? void 0 : typeof maxHeight === "number" ? `${maxHeight}px` : maxHeight,
|
|
1693
|
+
"aria-orientation": "vertical",
|
|
1694
|
+
children: /* @__PURE__ */ jsx(FloatingList, { elementsRef: ctx.elementsRef, labelsRef: ctx.labelsRef, children })
|
|
1695
|
+
}
|
|
1696
|
+
)
|
|
1697
|
+
}
|
|
1698
|
+
);
|
|
1699
|
+
return portal ? /* @__PURE__ */ jsx(OverlayPortal, { children: node2 }) : node2;
|
|
1700
|
+
}
|
|
1701
|
+
__name(MenuPanel, "MenuPanel");
|
|
1702
|
+
var MenuLabel = createComponent$1({
|
|
1703
|
+
__kui: { role: "display", groupSlot: "Menu" },
|
|
1704
|
+
displayName: "Menu.Label",
|
|
1705
|
+
render: /* @__PURE__ */ __name(({ className, ...rest }, ref) => {
|
|
1706
|
+
const { theme } = useTheme();
|
|
16
1707
|
return /* @__PURE__ */ jsx(
|
|
17
|
-
"
|
|
1708
|
+
"div",
|
|
18
1709
|
{
|
|
1710
|
+
...rest,
|
|
19
1711
|
ref,
|
|
20
|
-
|
|
21
|
-
"data-kui-adornment-position": position,
|
|
22
|
-
className: cn(
|
|
23
|
-
"flex shrink-0 items-center justify-center",
|
|
24
|
-
position === "end" && "gap-1.5",
|
|
25
|
-
className
|
|
26
|
-
),
|
|
27
|
-
...props,
|
|
28
|
-
children
|
|
1712
|
+
className: resolveRecipe(theme.recipes.MenuLabel, {}, className)
|
|
29
1713
|
}
|
|
30
1714
|
);
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return
|
|
36
|
-
|
|
1715
|
+
}, "render")
|
|
1716
|
+
});
|
|
1717
|
+
function MenuContentView(props) {
|
|
1718
|
+
const inPortal = React11.useContext(MenuPortalContext);
|
|
1719
|
+
return /* @__PURE__ */ jsx(MenuPanel, { ...props, portal: !inPortal });
|
|
1720
|
+
}
|
|
1721
|
+
__name(MenuContentView, "MenuContentView");
|
|
1722
|
+
var MenuContent = createComponent$1({
|
|
1723
|
+
__kui: { role: "overlay", groupSlot: "Menu" },
|
|
1724
|
+
displayName: "Menu.Content",
|
|
1725
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuContentView, { ...props, forwardedRef: ref }), "render")
|
|
1726
|
+
});
|
|
1727
|
+
var MenuSubContent = createComponent$1({
|
|
1728
|
+
__kui: { role: "overlay", groupSlot: "Menu" },
|
|
1729
|
+
displayName: "Menu.SubContent",
|
|
1730
|
+
// Sub levels always portal themselves: they render inside the parent's React tree
|
|
1731
|
+
// but must not be positioned relative to its DOM.
|
|
1732
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuPanel, { ...props, forwardedRef: ref, portal: true }), "render")
|
|
1733
|
+
});
|
|
1734
|
+
var labelOf = /* @__PURE__ */ __name((textValue, children) => textValue ?? (typeof children === "string" ? children : null), "labelOf");
|
|
1735
|
+
function activate(ctx, onSelect, close) {
|
|
1736
|
+
const event = new Event("kui.menu.select", { cancelable: true });
|
|
1737
|
+
onSelect?.(event);
|
|
1738
|
+
if (close && !event.defaultPrevented) {
|
|
1739
|
+
if (ctx.tree) ctx.tree.events.emit("click");
|
|
1740
|
+
else ctx.setOpen(false);
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
__name(activate, "activate");
|
|
1744
|
+
function useItemProps(part, { disabled, textValue, children, onSelect, onClick, ...rest }, forwardedRef, opts) {
|
|
1745
|
+
const ctx = useMenuContext(part);
|
|
1746
|
+
const item = useListItem({
|
|
1747
|
+
label: disabled ? null : labelOf(textValue, children)
|
|
1748
|
+
});
|
|
1749
|
+
const isActive = ctx.activeIndex === item.index;
|
|
1750
|
+
const ref = React11.useMemo(
|
|
1751
|
+
() => composeRefs(item.ref, forwardedRef),
|
|
1752
|
+
[item.ref, forwardedRef]
|
|
37
1753
|
);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1754
|
+
const props = ctx.getItemProps({
|
|
1755
|
+
...rest,
|
|
1756
|
+
onClick(e) {
|
|
1757
|
+
onClick?.(e);
|
|
1758
|
+
if (disabled) return;
|
|
1759
|
+
opts.onActivate?.();
|
|
1760
|
+
activate(ctx, onSelect, opts.close);
|
|
1761
|
+
}
|
|
1762
|
+
});
|
|
1763
|
+
return {
|
|
1764
|
+
ctx,
|
|
1765
|
+
domProps: {
|
|
1766
|
+
...props,
|
|
1767
|
+
ref,
|
|
1768
|
+
role: opts.role,
|
|
1769
|
+
type: "button",
|
|
1770
|
+
disabled,
|
|
1771
|
+
tabIndex: isActive ? 0 : -1,
|
|
1772
|
+
"data-active": isActive || void 0,
|
|
1773
|
+
"data-disabled": disabled || void 0
|
|
1774
|
+
}
|
|
45
1775
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1776
|
+
}
|
|
1777
|
+
__name(useItemProps, "useItemProps");
|
|
1778
|
+
function MenuItemView({
|
|
1779
|
+
forwardedRef,
|
|
1780
|
+
tone = "default",
|
|
1781
|
+
inset = false,
|
|
1782
|
+
...props
|
|
1783
|
+
}) {
|
|
1784
|
+
const { domProps } = useItemProps("Menu.Item", props, forwardedRef, {
|
|
1785
|
+
role: "menuitem",
|
|
1786
|
+
close: true
|
|
1787
|
+
});
|
|
1788
|
+
const { theme } = useTheme();
|
|
1789
|
+
return /* @__PURE__ */ jsx(
|
|
1790
|
+
"button",
|
|
1791
|
+
{
|
|
1792
|
+
...domProps,
|
|
1793
|
+
className: resolveRecipe(
|
|
1794
|
+
theme.recipes.MenuItem,
|
|
1795
|
+
{
|
|
1796
|
+
kind: "item",
|
|
1797
|
+
tone,
|
|
1798
|
+
inset
|
|
1799
|
+
},
|
|
1800
|
+
props.className
|
|
1801
|
+
),
|
|
1802
|
+
children: props.children
|
|
60
1803
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
1804
|
+
);
|
|
1805
|
+
}
|
|
1806
|
+
__name(MenuItemView, "MenuItemView");
|
|
1807
|
+
var MenuItem = createComponent$1({
|
|
1808
|
+
__kui: { role: "action", groupSlot: "Menu" },
|
|
1809
|
+
displayName: "Menu.Item",
|
|
1810
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuItemView, { ...props, forwardedRef: ref }), "render")
|
|
1811
|
+
});
|
|
1812
|
+
function MenuCheckboxItemView({
|
|
1813
|
+
forwardedRef,
|
|
1814
|
+
checked: checkedProp,
|
|
1815
|
+
defaultChecked,
|
|
1816
|
+
onCheckedChange,
|
|
1817
|
+
...props
|
|
1818
|
+
}) {
|
|
1819
|
+
const [checked, setChecked] = useControllableState$1({
|
|
1820
|
+
value: checkedProp,
|
|
1821
|
+
defaultValue: defaultChecked ?? false,
|
|
1822
|
+
onChange: onCheckedChange
|
|
1823
|
+
});
|
|
1824
|
+
const { domProps } = useItemProps("Menu.CheckboxItem", props, forwardedRef, {
|
|
1825
|
+
role: "menuitemcheckbox",
|
|
1826
|
+
close: false,
|
|
1827
|
+
onActivate: /* @__PURE__ */ __name(() => setChecked(!checked), "onActivate")
|
|
1828
|
+
});
|
|
1829
|
+
const { theme } = useTheme();
|
|
1830
|
+
return /* @__PURE__ */ jsx(
|
|
1831
|
+
"button",
|
|
1832
|
+
{
|
|
1833
|
+
...domProps,
|
|
1834
|
+
"aria-checked": checked,
|
|
1835
|
+
"data-state": checked ? "checked" : "unchecked",
|
|
1836
|
+
className: resolveRecipe(
|
|
1837
|
+
theme.recipes.MenuItem,
|
|
1838
|
+
{ kind: "checkbox" },
|
|
1839
|
+
props.className
|
|
1840
|
+
),
|
|
1841
|
+
children: props.children
|
|
1842
|
+
}
|
|
1843
|
+
);
|
|
1844
|
+
}
|
|
1845
|
+
__name(MenuCheckboxItemView, "MenuCheckboxItemView");
|
|
1846
|
+
var MenuCheckboxItem = createComponent$1({
|
|
1847
|
+
__kui: { role: "action", groupSlot: "Menu" },
|
|
1848
|
+
displayName: "Menu.CheckboxItem",
|
|
1849
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuCheckboxItemView, { ...props, forwardedRef: ref }), "render")
|
|
1850
|
+
});
|
|
1851
|
+
function MenuRadioGroupView({
|
|
1852
|
+
forwardedRef,
|
|
1853
|
+
value: valueProp,
|
|
1854
|
+
defaultValue,
|
|
1855
|
+
onValueChange,
|
|
1856
|
+
...rest
|
|
1857
|
+
}) {
|
|
1858
|
+
const [value, setValue] = useControllableState$1({
|
|
1859
|
+
value: valueProp,
|
|
1860
|
+
defaultValue,
|
|
1861
|
+
onChange: /* @__PURE__ */ __name((v) => v !== void 0 && onValueChange?.(v), "onChange")
|
|
1862
|
+
});
|
|
1863
|
+
const ctxValue = React11.useMemo(
|
|
1864
|
+
() => ({ value, setValue: /* @__PURE__ */ __name((v) => setValue(v), "setValue") }),
|
|
1865
|
+
[value, setValue]
|
|
1866
|
+
);
|
|
1867
|
+
return /* @__PURE__ */ jsx(MenuRadioGroupContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsx("div", { ...rest, ref: forwardedRef, role: "group" }) });
|
|
1868
|
+
}
|
|
1869
|
+
__name(MenuRadioGroupView, "MenuRadioGroupView");
|
|
1870
|
+
var MenuRadioGroup = createComponent$1({
|
|
1871
|
+
__kui: { role: "layout", groupSlot: "Menu" },
|
|
1872
|
+
displayName: "Menu.RadioGroup",
|
|
1873
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuRadioGroupView, { ...props, forwardedRef: ref }), "render")
|
|
1874
|
+
});
|
|
1875
|
+
function MenuRadioItemView({
|
|
1876
|
+
forwardedRef,
|
|
1877
|
+
value,
|
|
1878
|
+
...props
|
|
1879
|
+
}) {
|
|
1880
|
+
const group = React11.useContext(MenuRadioGroupContext);
|
|
1881
|
+
if (!group)
|
|
1882
|
+
throw new Error(
|
|
1883
|
+
"<Menu.RadioItem> must be rendered inside <Menu.RadioGroup>."
|
|
1884
|
+
);
|
|
1885
|
+
const checked = group.value === value;
|
|
1886
|
+
const { domProps } = useItemProps("Menu.RadioItem", props, forwardedRef, {
|
|
1887
|
+
role: "menuitemradio",
|
|
1888
|
+
close: false,
|
|
1889
|
+
onActivate: /* @__PURE__ */ __name(() => group.setValue(value), "onActivate")
|
|
1890
|
+
});
|
|
1891
|
+
const { theme } = useTheme();
|
|
1892
|
+
return /* @__PURE__ */ jsx(
|
|
1893
|
+
"button",
|
|
1894
|
+
{
|
|
1895
|
+
...domProps,
|
|
1896
|
+
"aria-checked": checked,
|
|
1897
|
+
"data-state": checked ? "checked" : "unchecked",
|
|
1898
|
+
className: resolveRecipe(
|
|
1899
|
+
theme.recipes.MenuItem,
|
|
1900
|
+
{ kind: "radio" },
|
|
1901
|
+
props.className
|
|
1902
|
+
),
|
|
1903
|
+
children: props.children
|
|
1904
|
+
}
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
__name(MenuRadioItemView, "MenuRadioItemView");
|
|
1908
|
+
var MenuRadioItem = createComponent$1({
|
|
1909
|
+
__kui: { role: "action", groupSlot: "Menu" },
|
|
1910
|
+
displayName: "Menu.RadioItem",
|
|
1911
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuRadioItemView, { ...props, forwardedRef: ref }), "render")
|
|
1912
|
+
});
|
|
1913
|
+
var MenuSeparator = createComponent$1({
|
|
1914
|
+
__kui: { role: "display", groupSlot: "Menu" },
|
|
1915
|
+
displayName: "Menu.Separator",
|
|
1916
|
+
render: /* @__PURE__ */ __name(({ className, ...rest }, ref) => {
|
|
1917
|
+
const { theme } = useTheme();
|
|
1918
|
+
return /* @__PURE__ */ jsx(
|
|
1919
|
+
"div",
|
|
1920
|
+
{
|
|
1921
|
+
...rest,
|
|
1922
|
+
ref,
|
|
1923
|
+
role: "separator",
|
|
1924
|
+
"aria-orientation": "horizontal",
|
|
1925
|
+
className: resolveRecipe(theme.recipes.MenuSeparator, {}, className)
|
|
66
1926
|
}
|
|
1927
|
+
);
|
|
1928
|
+
}, "render")
|
|
1929
|
+
});
|
|
1930
|
+
function MenuSubTriggerView({
|
|
1931
|
+
forwardedRef,
|
|
1932
|
+
disabled,
|
|
1933
|
+
textValue,
|
|
1934
|
+
children,
|
|
1935
|
+
className,
|
|
1936
|
+
onClick,
|
|
1937
|
+
...rest
|
|
1938
|
+
}) {
|
|
1939
|
+
const sub = useMenuContext("Menu.SubTrigger");
|
|
1940
|
+
const parent = sub.parent;
|
|
1941
|
+
if (!parent)
|
|
1942
|
+
throw new Error("<Menu.SubTrigger> must be rendered inside <Menu.Sub>.");
|
|
1943
|
+
const item = useListItem({
|
|
1944
|
+
label: disabled ? null : labelOf(textValue, children)
|
|
1945
|
+
});
|
|
1946
|
+
const isActive = parent.activeIndex === item.index;
|
|
1947
|
+
const ref = React11.useMemo(
|
|
1948
|
+
() => composeRefs(
|
|
1949
|
+
sub.refs.setReference,
|
|
1950
|
+
item.ref,
|
|
1951
|
+
forwardedRef
|
|
1952
|
+
),
|
|
1953
|
+
[sub.refs.setReference, item.ref, forwardedRef]
|
|
1954
|
+
);
|
|
1955
|
+
const props = sub.getReferenceProps(
|
|
1956
|
+
parent.getItemProps({ ...rest, onClick })
|
|
1957
|
+
);
|
|
1958
|
+
const { theme } = useTheme();
|
|
1959
|
+
return /* @__PURE__ */ jsx(
|
|
1960
|
+
"button",
|
|
1961
|
+
{
|
|
1962
|
+
...props,
|
|
1963
|
+
ref,
|
|
1964
|
+
type: "button",
|
|
1965
|
+
role: "menuitem",
|
|
1966
|
+
disabled,
|
|
1967
|
+
tabIndex: isActive ? 0 : -1,
|
|
1968
|
+
"data-active": isActive || void 0,
|
|
1969
|
+
"data-disabled": disabled || void 0,
|
|
1970
|
+
"data-state": sub.open ? "open" : "closed",
|
|
1971
|
+
className: resolveRecipe(
|
|
1972
|
+
theme.recipes.MenuItem,
|
|
1973
|
+
{ kind: "sub" },
|
|
1974
|
+
className
|
|
1975
|
+
),
|
|
1976
|
+
children
|
|
1977
|
+
}
|
|
1978
|
+
);
|
|
1979
|
+
}
|
|
1980
|
+
__name(MenuSubTriggerView, "MenuSubTriggerView");
|
|
1981
|
+
var MenuSubTrigger = createComponent$1({
|
|
1982
|
+
__kui: { role: "action", groupSlot: "Menu" },
|
|
1983
|
+
displayName: "Menu.SubTrigger",
|
|
1984
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(MenuSubTriggerView, { ...props, forwardedRef: ref }), "render")
|
|
1985
|
+
});
|
|
1986
|
+
var Menu = {
|
|
1987
|
+
Root: MenuRoot,
|
|
1988
|
+
Trigger: MenuTrigger,
|
|
1989
|
+
Portal: MenuPortal,
|
|
1990
|
+
Label: MenuLabel,
|
|
1991
|
+
Content: MenuContent,
|
|
1992
|
+
Item: MenuItem,
|
|
1993
|
+
CheckboxItem: MenuCheckboxItem,
|
|
1994
|
+
RadioGroup: MenuRadioGroup,
|
|
1995
|
+
RadioItem: MenuRadioItem,
|
|
1996
|
+
Separator: MenuSeparator,
|
|
1997
|
+
Sub: MenuSub,
|
|
1998
|
+
SubTrigger: MenuSubTrigger,
|
|
1999
|
+
SubContent: MenuSubContent
|
|
2000
|
+
};
|
|
2001
|
+
var devWarn = /* @__PURE__ */ __name((msg) => {
|
|
2002
|
+
if (isDev()) console.warn(`[kreativ-ui/ActionGuard] ${msg}`);
|
|
2003
|
+
}, "devWarn");
|
|
2004
|
+
var REVEAL_MS = 3e3;
|
|
2005
|
+
function ActionGuardView({
|
|
2006
|
+
blocked,
|
|
2007
|
+
message,
|
|
2008
|
+
reaction = "tooltip",
|
|
2009
|
+
status = "warning",
|
|
2010
|
+
confirm,
|
|
2011
|
+
onBlocked,
|
|
2012
|
+
children,
|
|
2013
|
+
forwardedRef
|
|
2014
|
+
}) {
|
|
2015
|
+
const id = React11.useId();
|
|
2016
|
+
const [tipOpen, setTipOpen] = React11.useState(false);
|
|
2017
|
+
const revealTimer = React11.useRef(
|
|
2018
|
+
void 0
|
|
2019
|
+
);
|
|
2020
|
+
const confirming = React11.useRef(false);
|
|
2021
|
+
const mounted = React11.useRef(true);
|
|
2022
|
+
const child = React11.isValidElement(children) ? children : null;
|
|
2023
|
+
const childRef = child?.props.ref;
|
|
2024
|
+
const mergedRef = React11.useMemo(
|
|
2025
|
+
() => composeRefs$2(forwardedRef, childRef),
|
|
2026
|
+
[forwardedRef, childRef]
|
|
2027
|
+
);
|
|
2028
|
+
const latest = React11.useRef({
|
|
2029
|
+
message,
|
|
2030
|
+
status,
|
|
2031
|
+
confirm,
|
|
2032
|
+
onBlocked,
|
|
2033
|
+
onClick: child?.props.onClick
|
|
2034
|
+
});
|
|
2035
|
+
latest.current = {
|
|
2036
|
+
message,
|
|
2037
|
+
status,
|
|
2038
|
+
confirm,
|
|
2039
|
+
onBlocked,
|
|
2040
|
+
onClick: child?.props.onClick
|
|
2041
|
+
};
|
|
2042
|
+
React11.useEffect(() => {
|
|
2043
|
+
mounted.current = true;
|
|
2044
|
+
return () => {
|
|
2045
|
+
mounted.current = false;
|
|
2046
|
+
clearTimeout(revealTimer.current);
|
|
2047
|
+
};
|
|
2048
|
+
}, []);
|
|
2049
|
+
React11.useEffect(() => {
|
|
2050
|
+
if (!blocked) {
|
|
2051
|
+
clearTimeout(revealTimer.current);
|
|
2052
|
+
setTipOpen(false);
|
|
2053
|
+
}
|
|
2054
|
+
}, [blocked]);
|
|
2055
|
+
const reveal = /* @__PURE__ */ __name(() => {
|
|
2056
|
+
setTipOpen(true);
|
|
2057
|
+
clearTimeout(revealTimer.current);
|
|
2058
|
+
revealTimer.current = setTimeout(() => setTipOpen(false), REVEAL_MS);
|
|
2059
|
+
}, "reveal");
|
|
2060
|
+
const showToast = /* @__PURE__ */ __name(() => {
|
|
2061
|
+
const { message: m, status: s } = latest.current;
|
|
2062
|
+
const opts = { id: `action-guard:${id}` };
|
|
2063
|
+
if (s === "neutral") toast(m, opts);
|
|
2064
|
+
else toast[s](m, opts);
|
|
2065
|
+
}, "showToast");
|
|
2066
|
+
const ask = /* @__PURE__ */ __name(async (event) => {
|
|
2067
|
+
if (confirming.current) return;
|
|
2068
|
+
confirming.current = true;
|
|
2069
|
+
try {
|
|
2070
|
+
const ok = await confirmAction({
|
|
2071
|
+
...latest.current.confirm,
|
|
2072
|
+
key: `action-guard:${id}`,
|
|
2073
|
+
message: latest.current.message
|
|
2074
|
+
});
|
|
2075
|
+
if (!mounted.current) return;
|
|
2076
|
+
if (ok) latest.current.onClick?.(event);
|
|
2077
|
+
else latest.current.onBlocked?.();
|
|
2078
|
+
} catch (error62) {
|
|
2079
|
+
devWarn(`confirmAction rejected: ${String(error62)}`);
|
|
2080
|
+
if (mounted.current) latest.current.onBlocked?.();
|
|
2081
|
+
} finally {
|
|
2082
|
+
confirming.current = false;
|
|
2083
|
+
}
|
|
2084
|
+
}, "ask");
|
|
2085
|
+
const handleClick = /* @__PURE__ */ __name((event) => {
|
|
2086
|
+
event.preventDefault();
|
|
2087
|
+
if (reaction === "confirm") {
|
|
2088
|
+
void ask(event);
|
|
2089
|
+
return;
|
|
67
2090
|
}
|
|
2091
|
+
if (reaction === "toast") showToast();
|
|
2092
|
+
else reveal();
|
|
2093
|
+
latest.current.onBlocked?.();
|
|
2094
|
+
}, "handleClick");
|
|
2095
|
+
if (!child) {
|
|
2096
|
+
devWarn("expects exactly one React element as its child.");
|
|
2097
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
2098
|
+
}
|
|
2099
|
+
if (blocked && child.props.disabled) {
|
|
2100
|
+
devWarn(
|
|
2101
|
+
"the child has a native `disabled` prop, so it never fires click and the guard can't react. Remove `disabled` and let `blocked` drive it."
|
|
2102
|
+
);
|
|
68
2103
|
}
|
|
69
|
-
|
|
2104
|
+
const guarded = blocked ? React11.cloneElement(child, {
|
|
2105
|
+
ref: mergedRef,
|
|
2106
|
+
"aria-disabled": true,
|
|
2107
|
+
"data-blocked": "",
|
|
2108
|
+
onClick: handleClick
|
|
2109
|
+
}) : forwardedRef ? React11.cloneElement(child, { ref: mergedRef }) : child;
|
|
2110
|
+
if (reaction !== "tooltip") return guarded;
|
|
2111
|
+
return /* @__PURE__ */ jsxs(
|
|
2112
|
+
Tooltip.Root,
|
|
2113
|
+
{
|
|
2114
|
+
open: blocked && tipOpen,
|
|
2115
|
+
onOpenChange: (open2) => {
|
|
2116
|
+
if (!blocked) return;
|
|
2117
|
+
if (!open2) clearTimeout(revealTimer.current);
|
|
2118
|
+
setTipOpen(open2);
|
|
2119
|
+
},
|
|
2120
|
+
children: [
|
|
2121
|
+
/* @__PURE__ */ jsx(Tooltip.Trigger, { asChild: true, children: guarded }),
|
|
2122
|
+
/* @__PURE__ */ jsx(Tooltip.Portal, { children: /* @__PURE__ */ jsxs(Tooltip.Content, { children: [
|
|
2123
|
+
/* @__PURE__ */ jsx(Tooltip.Arrow, {}),
|
|
2124
|
+
message
|
|
2125
|
+
] }) })
|
|
2126
|
+
]
|
|
2127
|
+
}
|
|
2128
|
+
);
|
|
70
2129
|
}
|
|
71
|
-
__name(
|
|
2130
|
+
__name(ActionGuardView, "ActionGuardView");
|
|
2131
|
+
var ActionGuard = createComponent({
|
|
2132
|
+
__kui: { role: "action", video: { id: "action-guard", safe: false } },
|
|
2133
|
+
displayName: "ActionGuard",
|
|
2134
|
+
render: /* @__PURE__ */ __name((props, ref) => /* @__PURE__ */ jsx(ActionGuardView, { ...props, forwardedRef: ref }), "render")
|
|
2135
|
+
});
|
|
72
2136
|
function ResponsiveStyle({ css }) {
|
|
73
2137
|
if (!css) return null;
|
|
74
2138
|
return /* @__PURE__ */ jsx("style", { "data-kui-responsive-style": true, children: css });
|
|
@@ -185,7 +2249,7 @@ var ButtonGroupRoot = forwardRef(
|
|
|
185
2249
|
spacing = "md",
|
|
186
2250
|
className,
|
|
187
2251
|
children,
|
|
188
|
-
size,
|
|
2252
|
+
size: size2,
|
|
189
2253
|
...rest
|
|
190
2254
|
}, ref) => {
|
|
191
2255
|
const { theme } = useTheme();
|
|
@@ -199,11 +2263,11 @@ var ButtonGroupRoot = forwardRef(
|
|
|
199
2263
|
orientation,
|
|
200
2264
|
attached,
|
|
201
2265
|
spacing,
|
|
202
|
-
size
|
|
2266
|
+
size: size2
|
|
203
2267
|
}),
|
|
204
|
-
[orientation, attached, spacing,
|
|
2268
|
+
[orientation, attached, spacing, size2]
|
|
205
2269
|
);
|
|
206
|
-
const separatorSizeToken = useSizeToken(
|
|
2270
|
+
const separatorSizeToken = useSizeToken(size2, "separatorSize");
|
|
207
2271
|
return /* @__PURE__ */ jsx(ButtonGroupContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(
|
|
208
2272
|
"div",
|
|
209
2273
|
{
|
|
@@ -234,7 +2298,7 @@ var Button = forwardRef(
|
|
|
234
2298
|
({
|
|
235
2299
|
variant = "solid",
|
|
236
2300
|
color = "brand",
|
|
237
|
-
size,
|
|
2301
|
+
size: size2,
|
|
238
2302
|
isLoading = false,
|
|
239
2303
|
leftIcon,
|
|
240
2304
|
rightIcon,
|
|
@@ -251,7 +2315,7 @@ var Button = forwardRef(
|
|
|
251
2315
|
const { theme } = useTheme();
|
|
252
2316
|
const typography = useTypography(typographyName);
|
|
253
2317
|
const group = useOptionalButtonGroupContext();
|
|
254
|
-
const resolvedSize =
|
|
2318
|
+
const resolvedSize = size2 ?? group?.size ?? "md";
|
|
255
2319
|
const { style: sizeStyle, responsiveStyles } = useSizeStyle(
|
|
256
2320
|
resolvedSize,
|
|
257
2321
|
iconOnly,
|
|
@@ -408,7 +2472,7 @@ var getIconVariants = /* @__PURE__ */ __name((type) => {
|
|
|
408
2472
|
}
|
|
409
2473
|
}, "getIconVariants");
|
|
410
2474
|
var CycleMode = /* @__PURE__ */ __name(({
|
|
411
|
-
size,
|
|
2475
|
+
size: size2,
|
|
412
2476
|
variant,
|
|
413
2477
|
color,
|
|
414
2478
|
iconOnly,
|
|
@@ -429,12 +2493,16 @@ var CycleMode = /* @__PURE__ */ __name(({
|
|
|
429
2493
|
return /* @__PURE__ */ jsxs(
|
|
430
2494
|
Button,
|
|
431
2495
|
{
|
|
432
|
-
size,
|
|
2496
|
+
size: size2,
|
|
433
2497
|
variant,
|
|
434
2498
|
color,
|
|
435
2499
|
onClick: onCycle,
|
|
436
2500
|
"aria-label": `Current theme: ${currentMode.label}`,
|
|
437
|
-
className: cn(
|
|
2501
|
+
className: cn(
|
|
2502
|
+
rounded && "rounded-full",
|
|
2503
|
+
"py-5 overflow-hidden",
|
|
2504
|
+
buttonProps?.className
|
|
2505
|
+
),
|
|
438
2506
|
...buttonProps,
|
|
439
2507
|
children: [
|
|
440
2508
|
/* @__PURE__ */ jsx(
|
|
@@ -492,7 +2560,7 @@ var useIndicator = /* @__PURE__ */ __name((activeKey, deps = []) => {
|
|
|
492
2560
|
};
|
|
493
2561
|
}, "useIndicator");
|
|
494
2562
|
var ButtonsMode = /* @__PURE__ */ __name(({
|
|
495
|
-
size,
|
|
2563
|
+
size: size2,
|
|
496
2564
|
color,
|
|
497
2565
|
iconOnly,
|
|
498
2566
|
buttonProps,
|
|
@@ -511,7 +2579,7 @@ var ButtonsMode = /* @__PURE__ */ __name(({
|
|
|
511
2579
|
indicatorTransition
|
|
512
2580
|
}) => {
|
|
513
2581
|
const { groupRef, buttonRefs, indicatorRect } = useIndicator(activeMode, [
|
|
514
|
-
|
|
2582
|
+
size2,
|
|
515
2583
|
orientation,
|
|
516
2584
|
iconOnly,
|
|
517
2585
|
unstyled,
|
|
@@ -548,7 +2616,7 @@ var ButtonsMode = /* @__PURE__ */ __name(({
|
|
|
548
2616
|
children: /* @__PURE__ */ jsx(
|
|
549
2617
|
Button,
|
|
550
2618
|
{
|
|
551
|
-
size,
|
|
2619
|
+
size: size2,
|
|
552
2620
|
variant: "ghost",
|
|
553
2621
|
color,
|
|
554
2622
|
onClick: () => onSelect(key),
|
|
@@ -630,7 +2698,7 @@ var getModeIcons = /* @__PURE__ */ __name((allowSystem, labels, icons) => {
|
|
|
630
2698
|
}
|
|
631
2699
|
return modes;
|
|
632
2700
|
}, "getModeIcons");
|
|
633
|
-
var ThemeToggler = createComponent({
|
|
2701
|
+
var ThemeToggler = createComponent$1({
|
|
634
2702
|
displayName: "ThemeToggler",
|
|
635
2703
|
__kui: {
|
|
636
2704
|
role: "action",
|
|
@@ -648,7 +2716,7 @@ var ThemeToggler = createComponent({
|
|
|
648
2716
|
color = "neutral",
|
|
649
2717
|
activeVariant = "solid",
|
|
650
2718
|
activeColor = "brand",
|
|
651
|
-
size = "sm",
|
|
2719
|
+
size: size2 = "sm",
|
|
652
2720
|
iconOnly = false,
|
|
653
2721
|
allowSystem = false,
|
|
654
2722
|
orientation = "horizontal",
|
|
@@ -665,7 +2733,7 @@ var ThemeToggler = createComponent({
|
|
|
665
2733
|
}, _ref) => {
|
|
666
2734
|
const { mode, setMode, resolvedMode, theme } = useTheme();
|
|
667
2735
|
const motionGated = isMotionGated(rest);
|
|
668
|
-
const resolvedSize =
|
|
2736
|
+
const resolvedSize = size2;
|
|
669
2737
|
const wrapperRadius = useSizeToken(resolvedSize, "radius");
|
|
670
2738
|
const indicatorRadius = useSizeToken(resolvedSize, "radius", "4px");
|
|
671
2739
|
const buttonWidth = useSizeToken(resolvedSize, "width");
|
|
@@ -818,17 +2886,37 @@ var inputKindIcons = {
|
|
|
818
2886
|
search: Search,
|
|
819
2887
|
numeric: Hash
|
|
820
2888
|
};
|
|
821
|
-
function Spinner({ size = 14 }) {
|
|
2889
|
+
function Spinner({ size: size2 = 14 }) {
|
|
822
2890
|
return /* @__PURE__ */ jsx(
|
|
823
2891
|
"span",
|
|
824
2892
|
{
|
|
825
2893
|
className: "animate-kui-spin rounded-full border-2 border-inherit border-t-transparent shrink-0",
|
|
826
|
-
style: { width:
|
|
2894
|
+
style: { width: size2, height: size2 },
|
|
827
2895
|
"aria-hidden": "true"
|
|
828
2896
|
}
|
|
829
2897
|
);
|
|
830
2898
|
}
|
|
831
2899
|
__name(Spinner, "Spinner");
|
|
2900
|
+
var Adornment = forwardRef(
|
|
2901
|
+
({ children, position, className, ...props }, ref) => {
|
|
2902
|
+
return /* @__PURE__ */ jsx(
|
|
2903
|
+
"span",
|
|
2904
|
+
{
|
|
2905
|
+
ref,
|
|
2906
|
+
"data-kui-adornment": true,
|
|
2907
|
+
"data-kui-adornment-position": position,
|
|
2908
|
+
className: cn(
|
|
2909
|
+
"flex shrink-0 items-center justify-center",
|
|
2910
|
+
position === "end" && "gap-1.5",
|
|
2911
|
+
className
|
|
2912
|
+
),
|
|
2913
|
+
...props,
|
|
2914
|
+
children
|
|
2915
|
+
}
|
|
2916
|
+
);
|
|
2917
|
+
}
|
|
2918
|
+
);
|
|
2919
|
+
Adornment.displayName = "Adornment";
|
|
832
2920
|
var FormFieldContext = createContext(
|
|
833
2921
|
null
|
|
834
2922
|
);
|
|
@@ -847,19 +2935,19 @@ function useOptionalFormField() {
|
|
|
847
2935
|
return useContext(FormFieldContext);
|
|
848
2936
|
}
|
|
849
2937
|
__name(useOptionalFormField, "useOptionalFormField");
|
|
850
|
-
function StaticSpinnerMark({ size }) {
|
|
2938
|
+
function StaticSpinnerMark({ size: size2 }) {
|
|
851
2939
|
return /* @__PURE__ */ jsx(
|
|
852
2940
|
"span",
|
|
853
2941
|
{
|
|
854
2942
|
"aria-hidden": "true",
|
|
855
2943
|
className: "inline-block rounded-full border-2 border-current opacity-70",
|
|
856
|
-
style: { width:
|
|
2944
|
+
style: { width: size2, height: size2 }
|
|
857
2945
|
}
|
|
858
2946
|
);
|
|
859
2947
|
}
|
|
860
2948
|
__name(StaticSpinnerMark, "StaticSpinnerMark");
|
|
861
2949
|
function ClearButton({
|
|
862
|
-
size,
|
|
2950
|
+
size: size2,
|
|
863
2951
|
className,
|
|
864
2952
|
onClear
|
|
865
2953
|
}) {
|
|
@@ -870,7 +2958,7 @@ function ClearButton({
|
|
|
870
2958
|
onClick: onClear,
|
|
871
2959
|
"aria-label": "Clear input",
|
|
872
2960
|
className,
|
|
873
|
-
children: /* @__PURE__ */ jsx(X, { style: { width:
|
|
2961
|
+
children: /* @__PURE__ */ jsx(X, { style: { width: size2, height: size2 } })
|
|
874
2962
|
}
|
|
875
2963
|
);
|
|
876
2964
|
}
|
|
@@ -887,7 +2975,7 @@ function renderBaseInput({
|
|
|
887
2975
|
className,
|
|
888
2976
|
inputClassName,
|
|
889
2977
|
variant = "outline",
|
|
890
|
-
size = "md",
|
|
2978
|
+
size: size2 = "md",
|
|
891
2979
|
error: error62,
|
|
892
2980
|
success: success2,
|
|
893
2981
|
warning,
|
|
@@ -944,7 +3032,7 @@ function renderBaseInput({
|
|
|
944
3032
|
const isInvalid = state === "error";
|
|
945
3033
|
const isDisabled = disabled || isLoading;
|
|
946
3034
|
const statusTransition = useStatusTransition(state, { enabled: motion3 });
|
|
947
|
-
const { style: sizeStyle, iconSize } = useSizeStyle(
|
|
3035
|
+
const { style: sizeStyle, iconSize } = useSizeStyle(size2, false, "input");
|
|
948
3036
|
const resolvedIconSize = iconSize || 14;
|
|
949
3037
|
const composedInputRef = useMemo(
|
|
950
3038
|
() => composeRefs(internalRef, ref, shortcutRef),
|
|
@@ -979,9 +3067,18 @@ function renderBaseInput({
|
|
|
979
3067
|
className
|
|
980
3068
|
]
|
|
981
3069
|
);
|
|
3070
|
+
const hasLeftAdornment = Boolean(startIcon);
|
|
3071
|
+
const hasRightAdornment = Boolean(endIcon) || Boolean(extraEndAdornment) || isLoading || clearable && hasValue && !isDisabled;
|
|
982
3072
|
const inputClasses = useMemo(
|
|
983
|
-
() => cn(
|
|
984
|
-
|
|
3073
|
+
() => cn(
|
|
3074
|
+
resolveRecipe(theme.recipes.Input, {
|
|
3075
|
+
variant,
|
|
3076
|
+
hasRightAdornment,
|
|
3077
|
+
hasLeftAdornment
|
|
3078
|
+
}),
|
|
3079
|
+
inputClassName
|
|
3080
|
+
),
|
|
3081
|
+
[theme, variant, inputClassName, hasRightAdornment, hasLeftAdornment]
|
|
985
3082
|
);
|
|
986
3083
|
const resolvedStyle = useMemo(
|
|
987
3084
|
() => ({ ...typography, ...sizeStyle, ...style }),
|
|
@@ -1115,7 +3212,7 @@ function renderBaseInput({
|
|
|
1115
3212
|
className: inputClasses,
|
|
1116
3213
|
"data-disabled": disabled || void 0,
|
|
1117
3214
|
"data-loading": isLoading || void 0,
|
|
1118
|
-
"data-size":
|
|
3215
|
+
"data-size": size2,
|
|
1119
3216
|
"data-state": state,
|
|
1120
3217
|
"data-variant": variant
|
|
1121
3218
|
}
|
|
@@ -1126,7 +3223,7 @@ function renderBaseInput({
|
|
|
1126
3223
|
);
|
|
1127
3224
|
}
|
|
1128
3225
|
__name(renderBaseInput, "renderBaseInput");
|
|
1129
|
-
var
|
|
3226
|
+
var InputBase = createComponent({
|
|
1130
3227
|
displayName: "Input",
|
|
1131
3228
|
__kui: {
|
|
1132
3229
|
role: "formControl",
|
|
@@ -1170,6 +3267,7 @@ var Input = createComponent$1({
|
|
|
1170
3267
|
autoComplete: autoCompleteProp,
|
|
1171
3268
|
placeholder: placeholderProp,
|
|
1172
3269
|
startIcon,
|
|
3270
|
+
value,
|
|
1173
3271
|
...rest
|
|
1174
3272
|
}, ref) => {
|
|
1175
3273
|
const kindDefaults = inputKindDefaults[kind];
|
|
@@ -1180,6 +3278,7 @@ var Input = createComponent$1({
|
|
|
1180
3278
|
...rest,
|
|
1181
3279
|
type: typeProp ?? kindDefaults.type,
|
|
1182
3280
|
inputMode: inputModeProp ?? kindDefaults.inputMode,
|
|
3281
|
+
value: value ?? "",
|
|
1183
3282
|
autoComplete: autoCompleteProp ?? kindDefaults.autoComplete,
|
|
1184
3283
|
placeholder: placeholderProp ?? kindDefaults.placeholder,
|
|
1185
3284
|
startIcon: resolvedStartIcon
|
|
@@ -1188,12 +3287,13 @@ var Input = createComponent$1({
|
|
|
1188
3287
|
);
|
|
1189
3288
|
}, "render")
|
|
1190
3289
|
});
|
|
3290
|
+
var Input = InputBase;
|
|
1191
3291
|
var statusClasses = {
|
|
1192
3292
|
error: "text-kui-destructive animate-kui-shake [animation-delay:500ms]",
|
|
1193
3293
|
success: "text-kui-success",
|
|
1194
3294
|
warning: "text-kui-warning"
|
|
1195
3295
|
};
|
|
1196
|
-
var FormFieldMessage = createComponent({
|
|
3296
|
+
var FormFieldMessage = createComponent$1({
|
|
1197
3297
|
displayName: "FormField.Message",
|
|
1198
3298
|
__kui: {
|
|
1199
3299
|
role: "display",
|
|
@@ -1239,35 +3339,12 @@ var FormFieldMessage = createComponent({
|
|
|
1239
3339
|
);
|
|
1240
3340
|
}, "render")
|
|
1241
3341
|
});
|
|
1242
|
-
|
|
1243
|
-
// src/utils/env.ts
|
|
1244
|
-
function readProcessEnv() {
|
|
1245
|
-
try {
|
|
1246
|
-
return typeof process !== "undefined" ? process.env?.NODE_ENV : void 0;
|
|
1247
|
-
} catch {
|
|
1248
|
-
return void 0;
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
__name(readProcessEnv, "readProcessEnv");
|
|
1252
|
-
function readImportMetaEnv() {
|
|
1253
|
-
try {
|
|
1254
|
-
return typeof import.meta !== "undefined" ? import.meta.env?.MODE : void 0;
|
|
1255
|
-
} catch {
|
|
1256
|
-
return void 0;
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
__name(readImportMetaEnv, "readImportMetaEnv");
|
|
1260
|
-
function isDev() {
|
|
1261
|
-
const mode = readProcessEnv() ?? readImportMetaEnv();
|
|
1262
|
-
return mode !== void 0 && mode !== "production";
|
|
1263
|
-
}
|
|
1264
|
-
__name(isDev, "isDev");
|
|
1265
|
-
var FormContext = React2.createContext(null);
|
|
3342
|
+
var FormContext = React11.createContext(null);
|
|
1266
3343
|
function useFormContext() {
|
|
1267
|
-
return
|
|
3344
|
+
return React11.useContext(FormContext);
|
|
1268
3345
|
}
|
|
1269
3346
|
__name(useFormContext, "useFormContext");
|
|
1270
|
-
var FormRoot = createComponent({
|
|
3347
|
+
var FormRoot = createComponent$1({
|
|
1271
3348
|
displayName: "Form",
|
|
1272
3349
|
__kui: {
|
|
1273
3350
|
role: "formControl",
|
|
@@ -1290,13 +3367,13 @@ var FormRoot = createComponent({
|
|
|
1290
3367
|
className,
|
|
1291
3368
|
scrollToFirstOnError = true
|
|
1292
3369
|
}, ref) => {
|
|
1293
|
-
const [values, setValues] =
|
|
1294
|
-
const [isSubmitting, setIsSubmitting] =
|
|
1295
|
-
const [isDirty, setIsDirty] =
|
|
1296
|
-
const [schemaErrors, setSchemaErrors] =
|
|
1297
|
-
const [liveErrors, setLiveErrors] =
|
|
1298
|
-
const fieldElements =
|
|
1299
|
-
const registerField =
|
|
3370
|
+
const [values, setValues] = React11.useState(defaultValues ?? {});
|
|
3371
|
+
const [isSubmitting, setIsSubmitting] = React11.useState(false);
|
|
3372
|
+
const [isDirty, setIsDirty] = React11.useState(false);
|
|
3373
|
+
const [schemaErrors, setSchemaErrors] = React11.useState({});
|
|
3374
|
+
const [liveErrors, setLiveErrors] = React11.useState({});
|
|
3375
|
+
const fieldElements = React11.useRef(/* @__PURE__ */ new Map());
|
|
3376
|
+
const registerField = React11.useCallback(
|
|
1300
3377
|
(name, element) => {
|
|
1301
3378
|
if (element) {
|
|
1302
3379
|
fieldElements.current.set(name, element);
|
|
@@ -1306,15 +3383,15 @@ var FormRoot = createComponent({
|
|
|
1306
3383
|
},
|
|
1307
3384
|
[]
|
|
1308
3385
|
);
|
|
1309
|
-
const errors =
|
|
3386
|
+
const errors = React11.useMemo(
|
|
1310
3387
|
() => ({ ...schemaErrors, ...liveErrors }),
|
|
1311
3388
|
[schemaErrors, liveErrors]
|
|
1312
3389
|
);
|
|
1313
|
-
const errorList =
|
|
3390
|
+
const errorList = React11.useMemo(
|
|
1314
3391
|
() => Object.entries(errors).map(([name, message]) => ({ name, message })),
|
|
1315
3392
|
[errors]
|
|
1316
3393
|
);
|
|
1317
|
-
const setValue =
|
|
3394
|
+
const setValue = React11.useCallback(
|
|
1318
3395
|
(name, value) => {
|
|
1319
3396
|
setValues((prev) => {
|
|
1320
3397
|
const next = { ...prev, [name]: value };
|
|
@@ -1337,11 +3414,11 @@ var FormRoot = createComponent({
|
|
|
1337
3414
|
},
|
|
1338
3415
|
[schema, schemaErrors]
|
|
1339
3416
|
);
|
|
1340
|
-
const getValue =
|
|
3417
|
+
const getValue = React11.useCallback(
|
|
1341
3418
|
(name) => values[name],
|
|
1342
3419
|
[values]
|
|
1343
3420
|
);
|
|
1344
|
-
const setFieldError =
|
|
3421
|
+
const setFieldError = React11.useCallback(
|
|
1345
3422
|
(name, message) => {
|
|
1346
3423
|
setLiveErrors((prev) => {
|
|
1347
3424
|
if (prev[name] === message) return prev;
|
|
@@ -1356,7 +3433,7 @@ var FormRoot = createComponent({
|
|
|
1356
3433
|
},
|
|
1357
3434
|
[]
|
|
1358
3435
|
);
|
|
1359
|
-
const runValidation =
|
|
3436
|
+
const runValidation = React11.useCallback(
|
|
1360
3437
|
async (currentValues) => {
|
|
1361
3438
|
let collected = {};
|
|
1362
3439
|
if (schema) {
|
|
@@ -1380,7 +3457,7 @@ var FormRoot = createComponent({
|
|
|
1380
3457
|
},
|
|
1381
3458
|
[schema, validate2]
|
|
1382
3459
|
);
|
|
1383
|
-
const submit =
|
|
3460
|
+
const submit = React11.useCallback(() => {
|
|
1384
3461
|
void (async () => {
|
|
1385
3462
|
setIsSubmitting(true);
|
|
1386
3463
|
try {
|
|
@@ -1402,13 +3479,13 @@ var FormRoot = createComponent({
|
|
|
1402
3479
|
}
|
|
1403
3480
|
})();
|
|
1404
3481
|
}, [runValidation, values, onSubmit, liveErrors]);
|
|
1405
|
-
const reset =
|
|
3482
|
+
const reset = React11.useCallback(() => {
|
|
1406
3483
|
setValues(defaultValues ?? {});
|
|
1407
3484
|
setSchemaErrors({});
|
|
1408
3485
|
setLiveErrors({});
|
|
1409
3486
|
setIsDirty(false);
|
|
1410
3487
|
}, [defaultValues]);
|
|
1411
|
-
const handleSubmit =
|
|
3488
|
+
const handleSubmit = React11.useCallback(
|
|
1412
3489
|
(event) => {
|
|
1413
3490
|
onSubmitCapture?.(event);
|
|
1414
3491
|
event.preventDefault();
|
|
@@ -1416,14 +3493,14 @@ var FormRoot = createComponent({
|
|
|
1416
3493
|
},
|
|
1417
3494
|
[onSubmitCapture, submit]
|
|
1418
3495
|
);
|
|
1419
|
-
const handleReset =
|
|
3496
|
+
const handleReset = React11.useCallback(
|
|
1420
3497
|
(event) => {
|
|
1421
3498
|
event.preventDefault();
|
|
1422
3499
|
reset();
|
|
1423
3500
|
},
|
|
1424
3501
|
[reset]
|
|
1425
3502
|
);
|
|
1426
|
-
const contextValue =
|
|
3503
|
+
const contextValue = React11.useMemo(
|
|
1427
3504
|
() => ({
|
|
1428
3505
|
values,
|
|
1429
3506
|
errors,
|
|
@@ -1466,21 +3543,21 @@ var FormRoot = createComponent({
|
|
|
1466
3543
|
) });
|
|
1467
3544
|
}, "render")
|
|
1468
3545
|
});
|
|
1469
|
-
var FormSubmitButton =
|
|
3546
|
+
var FormSubmitButton = React11.forwardRef(/* @__PURE__ */ __name(function FormSubmitButton2({ children }, ref) {
|
|
1470
3547
|
const form = useFormContext();
|
|
1471
3548
|
if (!form) {
|
|
1472
3549
|
throw new Error(
|
|
1473
3550
|
"[kreativ-ui/Form.SubmitButton]: must be rendered inside <Form>."
|
|
1474
3551
|
);
|
|
1475
3552
|
}
|
|
1476
|
-
if (!
|
|
3553
|
+
if (!React11.isValidElement(children)) {
|
|
1477
3554
|
throw new Error(
|
|
1478
3555
|
"[kreativ-ui/Form.SubmitButton]: requires exactly one React element child."
|
|
1479
3556
|
);
|
|
1480
3557
|
}
|
|
1481
3558
|
const child = children;
|
|
1482
3559
|
const hasErrors = Object.keys(form.errors).length > 0;
|
|
1483
|
-
return
|
|
3560
|
+
return React11.cloneElement(child, {
|
|
1484
3561
|
type: "submit",
|
|
1485
3562
|
disabled: hasErrors || form.isSubmitting,
|
|
1486
3563
|
"aria-busy": form.isSubmitting || void 0,
|
|
@@ -1490,7 +3567,7 @@ var FormSubmitButton = React2.forwardRef(/* @__PURE__ */ __name(function FormSub
|
|
|
1490
3567
|
)
|
|
1491
3568
|
});
|
|
1492
3569
|
}, "FormSubmitButton"));
|
|
1493
|
-
var FormResetButton =
|
|
3570
|
+
var FormResetButton = React11.forwardRef(
|
|
1494
3571
|
/* @__PURE__ */ __name(function FormResetButton2({ children }, ref) {
|
|
1495
3572
|
const form = useFormContext();
|
|
1496
3573
|
if (!form) {
|
|
@@ -1498,14 +3575,14 @@ var FormResetButton = React2.forwardRef(
|
|
|
1498
3575
|
"[kreativ-ui/Form.ResetButton]: must be rendered inside <Form>."
|
|
1499
3576
|
);
|
|
1500
3577
|
}
|
|
1501
|
-
if (!
|
|
3578
|
+
if (!React11.isValidElement(children)) {
|
|
1502
3579
|
throw new Error(
|
|
1503
3580
|
"[kreativ-ui/Form.ResetButton]: requires exactly one React element child."
|
|
1504
3581
|
);
|
|
1505
3582
|
}
|
|
1506
3583
|
const child = children;
|
|
1507
3584
|
const existingOnClick = child.props.onClick;
|
|
1508
|
-
return
|
|
3585
|
+
return React11.cloneElement(child, {
|
|
1509
3586
|
type: "button",
|
|
1510
3587
|
disabled: !form.isDirty,
|
|
1511
3588
|
onClick: /* @__PURE__ */ __name((event) => {
|
|
@@ -1628,7 +3705,7 @@ __export(external_exports, {
|
|
|
1628
3705
|
codec: () => codec,
|
|
1629
3706
|
coerce: () => coerce_exports,
|
|
1630
3707
|
compile: () => compile,
|
|
1631
|
-
config: () =>
|
|
3708
|
+
config: () => config2,
|
|
1632
3709
|
core: () => core_exports2,
|
|
1633
3710
|
creditCard: () => creditCard2,
|
|
1634
3711
|
cuid: () => cuid3,
|
|
@@ -1726,7 +3803,7 @@ __export(external_exports, {
|
|
|
1726
3803
|
prefault: () => prefault,
|
|
1727
3804
|
preprocess: () => preprocess,
|
|
1728
3805
|
prettifyError: () => prettifyError,
|
|
1729
|
-
promise: () =>
|
|
3806
|
+
promise: () => promise2,
|
|
1730
3807
|
properties: () => _properties,
|
|
1731
3808
|
property: () => _property,
|
|
1732
3809
|
readonly: () => readonly,
|
|
@@ -2040,7 +4117,7 @@ __export(core_exports2, {
|
|
|
2040
4117
|
clone: () => clone,
|
|
2041
4118
|
compile: () => compile,
|
|
2042
4119
|
compileFn: () => compileFn,
|
|
2043
|
-
config: () =>
|
|
4120
|
+
config: () => config2,
|
|
2044
4121
|
createStandardJSONSchemaMethod: () => createStandardJSONSchemaMethod,
|
|
2045
4122
|
createToJSONSchemaMethod: () => createToJSONSchemaMethod,
|
|
2046
4123
|
decode: () => decode,
|
|
@@ -2150,7 +4227,7 @@ __export(util_exports, {
|
|
|
2150
4227
|
joinValues: () => joinValues,
|
|
2151
4228
|
jsonStringifyReplacer: () => jsonStringifyReplacer,
|
|
2152
4229
|
members: () => members,
|
|
2153
|
-
merge: () =>
|
|
4230
|
+
merge: () => merge2,
|
|
2154
4231
|
mergeDefs: () => mergeDefs,
|
|
2155
4232
|
normalizeParams: () => normalizeParams,
|
|
2156
4233
|
nullish: () => nullish,
|
|
@@ -2202,9 +4279,9 @@ __name(assertNever, "assertNever");
|
|
|
2202
4279
|
function assert(_) {
|
|
2203
4280
|
}
|
|
2204
4281
|
__name(assert, "assert");
|
|
2205
|
-
function getEnumValues(
|
|
2206
|
-
const numericValues = Object.values(
|
|
2207
|
-
const values = Object.entries(
|
|
4282
|
+
function getEnumValues(entries2) {
|
|
4283
|
+
const numericValues = Object.values(entries2).filter((v) => typeof v === "number");
|
|
4284
|
+
const values = Object.entries(entries2).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
|
|
2208
4285
|
return values;
|
|
2209
4286
|
}
|
|
2210
4287
|
__name(getEnumValues, "getEnumValues");
|
|
@@ -2667,7 +4744,7 @@ function safeExtend(schema, shape) {
|
|
|
2667
4744
|
return clone(schema, mergeDefs(schema._zod.def, { shape: extended(schema, shape) }));
|
|
2668
4745
|
}
|
|
2669
4746
|
__name(safeExtend, "safeExtend");
|
|
2670
|
-
function
|
|
4747
|
+
function merge2(a, b) {
|
|
2671
4748
|
if (!b?._zod?.def) {
|
|
2672
4749
|
throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");
|
|
2673
4750
|
}
|
|
@@ -2686,7 +4763,7 @@ function merge(a, b) {
|
|
|
2686
4763
|
});
|
|
2687
4764
|
return clone(a, def);
|
|
2688
4765
|
}
|
|
2689
|
-
__name(
|
|
4766
|
+
__name(merge2, "merge");
|
|
2690
4767
|
function partial(Class2, schema, mask, name = "partial") {
|
|
2691
4768
|
const currDef = schema._zod.def;
|
|
2692
4769
|
const checks = currDef.checks;
|
|
@@ -2765,7 +4842,7 @@ function attachSchema(issues, start, inst) {
|
|
|
2765
4842
|
}
|
|
2766
4843
|
}
|
|
2767
4844
|
__name(attachSchema, "attachSchema");
|
|
2768
|
-
function finalizeIssue(iss, ctx,
|
|
4845
|
+
function finalizeIssue(iss, ctx, config3) {
|
|
2769
4846
|
var _a3;
|
|
2770
4847
|
const traits = iss.inst?._zod?.traits;
|
|
2771
4848
|
if (traits?.has("$ZodType")) {
|
|
@@ -2775,7 +4852,7 @@ function finalizeIssue(iss, ctx, config2) {
|
|
|
2775
4852
|
iss.schema = iss.inst;
|
|
2776
4853
|
}
|
|
2777
4854
|
const schemaError = iss.schema !== iss.inst ? iss.schema?._zod.def?.error : void 0;
|
|
2778
|
-
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(
|
|
4855
|
+
const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(schemaError?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config3.customError?.(iss)) ?? unwrapMessage(config3.localeError?.(iss)) ?? "Invalid input";
|
|
2779
4856
|
const full = {};
|
|
2780
4857
|
for (const k of Object.keys(iss)) {
|
|
2781
4858
|
if (k === "inst" || k === "schema" || k === "continue" || k === "input" || k === "__proto__")
|
|
@@ -3163,12 +5240,12 @@ __name(_$ZodEncodeError, "$ZodEncodeError");
|
|
|
3163
5240
|
var $ZodEncodeError = _$ZodEncodeError;
|
|
3164
5241
|
(_a = globalThis).__zod_globalConfig ?? (_a.__zod_globalConfig = {});
|
|
3165
5242
|
var globalConfig = globalThis.__zod_globalConfig;
|
|
3166
|
-
function
|
|
5243
|
+
function config2(newConfig) {
|
|
3167
5244
|
if (newConfig)
|
|
3168
5245
|
Object.assign(globalConfig, newConfig);
|
|
3169
5246
|
return globalConfig;
|
|
3170
5247
|
}
|
|
3171
|
-
__name(
|
|
5248
|
+
__name(config2, "config");
|
|
3172
5249
|
|
|
3173
5250
|
// node_modules/zod/v4/core/errors.js
|
|
3174
5251
|
function _getMessage() {
|
|
@@ -3383,7 +5460,7 @@ var _parse = /* @__PURE__ */ __name((_Err) => {
|
|
|
3383
5460
|
throw new $ZodAsyncError();
|
|
3384
5461
|
}
|
|
3385
5462
|
if (result.issues.length) {
|
|
3386
|
-
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
5463
|
+
const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config2())));
|
|
3387
5464
|
captureStackTrace(e, _params?.callee ?? fn);
|
|
3388
5465
|
throw e;
|
|
3389
5466
|
}
|
|
@@ -3399,7 +5476,7 @@ var _parseAsync = /* @__PURE__ */ __name((_Err) => {
|
|
|
3399
5476
|
if (result instanceof Promise)
|
|
3400
5477
|
result = await result;
|
|
3401
5478
|
if (result.issues.length) {
|
|
3402
|
-
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
5479
|
+
const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config2())));
|
|
3403
5480
|
captureStackTrace(e, params?.callee ?? fn);
|
|
3404
5481
|
throw e;
|
|
3405
5482
|
}
|
|
@@ -3423,7 +5500,7 @@ function failure(Err, issues, ctx) {
|
|
|
3423
5500
|
success: false,
|
|
3424
5501
|
get error() {
|
|
3425
5502
|
if (!error62) {
|
|
3426
|
-
error62 = new Err(issues.map((iss) => finalizeIssue(iss, ctx,
|
|
5503
|
+
error62 = new Err(issues.map((iss) => finalizeIssue(iss, ctx, config2())));
|
|
3427
5504
|
issues = void 0;
|
|
3428
5505
|
ctx = void 0;
|
|
3429
5506
|
}
|
|
@@ -3896,8 +5973,8 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
|
|
|
3896
5973
|
(_a3 = inst._zod.def).when ?? (_a3.when = _whenHasSize);
|
|
3897
5974
|
inst._zod.check = (payload) => {
|
|
3898
5975
|
const input2 = payload.value;
|
|
3899
|
-
const
|
|
3900
|
-
if (
|
|
5976
|
+
const size2 = input2.size;
|
|
5977
|
+
if (size2 <= def.maximum)
|
|
3901
5978
|
return;
|
|
3902
5979
|
payload.issues.push({
|
|
3903
5980
|
origin: getSizableOrigin(input2),
|
|
@@ -3916,8 +5993,8 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
|
|
|
3916
5993
|
(_a3 = inst._zod.def).when ?? (_a3.when = _whenHasSize);
|
|
3917
5994
|
inst._zod.check = (payload) => {
|
|
3918
5995
|
const input2 = payload.value;
|
|
3919
|
-
const
|
|
3920
|
-
if (
|
|
5996
|
+
const size2 = input2.size;
|
|
5997
|
+
if (size2 >= def.minimum)
|
|
3921
5998
|
return;
|
|
3922
5999
|
payload.issues.push({
|
|
3923
6000
|
origin: getSizableOrigin(input2),
|
|
@@ -3936,10 +6013,10 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
|
|
|
3936
6013
|
(_a3 = inst._zod.def).when ?? (_a3.when = _whenHasSize);
|
|
3937
6014
|
inst._zod.check = (payload) => {
|
|
3938
6015
|
const input2 = payload.value;
|
|
3939
|
-
const
|
|
3940
|
-
if (
|
|
6016
|
+
const size2 = input2.size;
|
|
6017
|
+
if (size2 === def.size)
|
|
3941
6018
|
return;
|
|
3942
|
-
const tooBig =
|
|
6019
|
+
const tooBig = size2 > def.size;
|
|
3943
6020
|
payload.issues.push({
|
|
3944
6021
|
origin: getSizableOrigin(input2),
|
|
3945
6022
|
...tooBig ? { code: "too_big", maximum: def.size } : { code: "too_small", minimum: def.size },
|
|
@@ -4145,16 +6222,16 @@ var $ZodCheckProperties = /* @__PURE__ */ $constructor("$ZodCheckProperties", (i
|
|
|
4145
6222
|
hide(inst, Symbol.iterator, function* () {
|
|
4146
6223
|
yield inst;
|
|
4147
6224
|
});
|
|
4148
|
-
let
|
|
6225
|
+
let entries2;
|
|
4149
6226
|
inst._zod.check = (payload) => {
|
|
4150
6227
|
if (payload.value == null) {
|
|
4151
6228
|
payload.issues.push({ expected: "object", code: "invalid_type", input: payload.value, inst });
|
|
4152
6229
|
return void 0;
|
|
4153
6230
|
}
|
|
4154
|
-
|
|
6231
|
+
entries2 ?? (entries2 = Reflect.ownKeys(def.shape).map((key) => [key, def.shape[key]]));
|
|
4155
6232
|
const input2 = payload.value;
|
|
4156
6233
|
let proms;
|
|
4157
|
-
for (const [key, schema] of
|
|
6234
|
+
for (const [key, schema] of entries2) {
|
|
4158
6235
|
const result = schema._zod.run({ value: input2[key], issues: [] }, {});
|
|
4159
6236
|
if (result instanceof Promise) {
|
|
4160
6237
|
proms ?? (proms = []);
|
|
@@ -4350,7 +6427,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
4350
6427
|
own(this, "~standard", value);
|
|
4351
6428
|
}
|
|
4352
6429
|
});
|
|
4353
|
-
var toStandardResult = /* @__PURE__ */ __name((r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
6430
|
+
var toStandardResult = /* @__PURE__ */ __name((r, ctx) => r.issues.length ? { issues: r.issues.map((iss) => finalizeIssue(iss, ctx, config2())) } : { value: r.value }, "toStandardResult");
|
|
4354
6431
|
async function validateAsync2(inst, value) {
|
|
4355
6432
|
const ctx = { async: true };
|
|
4356
6433
|
return toStandardResult(await inst._zod.run({ value, issues: [] }, ctx), ctx);
|
|
@@ -5010,14 +7087,14 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
5010
7087
|
return payload;
|
|
5011
7088
|
};
|
|
5012
7089
|
});
|
|
5013
|
-
function capSize(inst,
|
|
7090
|
+
function capSize(inst, size2) {
|
|
5014
7091
|
const caps = sizeCaps(inst._zod.def.checks);
|
|
5015
7092
|
if (!caps.length)
|
|
5016
7093
|
return;
|
|
5017
7094
|
const cap = Math.min(...caps.map((c) => c[0]));
|
|
5018
7095
|
const parse3 = inst._zod.parse;
|
|
5019
7096
|
inst._zod.parse = (payload, ctx) => {
|
|
5020
|
-
const n =
|
|
7097
|
+
const n = size2(payload.value);
|
|
5021
7098
|
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
5022
7099
|
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
5023
7100
|
if (n > max && ch._zod.def.when(payload)) {
|
|
@@ -5288,9 +7365,9 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
5288
7365
|
}`, "prefixStr");
|
|
5289
7366
|
doc.write(`const input = payload.value;`);
|
|
5290
7367
|
const ids = /* @__PURE__ */ Object.create(null);
|
|
5291
|
-
let
|
|
7368
|
+
let counter3 = 0;
|
|
5292
7369
|
for (const key of normalized.allKeys) {
|
|
5293
|
-
ids[key] = `key_${
|
|
7370
|
+
ids[key] = `key_${counter3++}`;
|
|
5294
7371
|
}
|
|
5295
7372
|
doc.write(memo2 ? `const newResult = memo.alloc(inst, payload, {}, ctx);` : `const newResult = {};`);
|
|
5296
7373
|
for (const key of normalized.allKeys) {
|
|
@@ -5407,7 +7484,7 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
5407
7484
|
code: "invalid_union",
|
|
5408
7485
|
input: final.value,
|
|
5409
7486
|
inst,
|
|
5410
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
7487
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config2())))
|
|
5411
7488
|
});
|
|
5412
7489
|
return final;
|
|
5413
7490
|
}
|
|
@@ -5472,7 +7549,7 @@ function handleExclusiveUnionResults(results, final, inst, ctx) {
|
|
|
5472
7549
|
code: "invalid_union",
|
|
5473
7550
|
input: final.value,
|
|
5474
7551
|
inst,
|
|
5475
|
-
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
7552
|
+
errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config2())))
|
|
5476
7553
|
});
|
|
5477
7554
|
} else {
|
|
5478
7555
|
final.issues.push({
|
|
@@ -5888,7 +7965,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
5888
7965
|
payload.issues.push({
|
|
5889
7966
|
code: "invalid_key",
|
|
5890
7967
|
origin: "record",
|
|
5891
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
7968
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config2())),
|
|
5892
7969
|
input: key,
|
|
5893
7970
|
path: [key],
|
|
5894
7971
|
inst
|
|
@@ -5968,7 +8045,7 @@ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
5968
8045
|
payload.issues.push({
|
|
5969
8046
|
code: "invalid_key",
|
|
5970
8047
|
origin: "record",
|
|
5971
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
8048
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config2())),
|
|
5972
8049
|
input: key,
|
|
5973
8050
|
path: [key],
|
|
5974
8051
|
inst
|
|
@@ -6061,7 +8138,7 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
|
|
|
6061
8138
|
origin: "map",
|
|
6062
8139
|
input: input2,
|
|
6063
8140
|
inst,
|
|
6064
|
-
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
8141
|
+
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config2()))
|
|
6065
8142
|
});
|
|
6066
8143
|
}
|
|
6067
8144
|
}
|
|
@@ -6075,7 +8152,7 @@ function handleMapResult(keyResult, valueResult, final, key, input2, inst, ctx)
|
|
|
6075
8152
|
input: input2,
|
|
6076
8153
|
inst,
|
|
6077
8154
|
key,
|
|
6078
|
-
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
8155
|
+
issues: valueResult.issues.map((iss) => finalizeIssue(iss, ctx, config2()))
|
|
6079
8156
|
});
|
|
6080
8157
|
}
|
|
6081
8158
|
}
|
|
@@ -6357,7 +8434,7 @@ function handleCatchResult(payload, result, def, ctx) {
|
|
|
6357
8434
|
...result,
|
|
6358
8435
|
value: payload.value,
|
|
6359
8436
|
error: {
|
|
6360
|
-
issues: result.issues.map((iss) => finalizeIssue(iss, ctx,
|
|
8437
|
+
issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config2()))
|
|
6361
8438
|
},
|
|
6362
8439
|
input: payload.value
|
|
6363
8440
|
});
|
|
@@ -6776,7 +8853,7 @@ function isRecursive(inst, stack, resolve) {
|
|
|
6776
8853
|
}
|
|
6777
8854
|
return answer;
|
|
6778
8855
|
}, "shape");
|
|
6779
|
-
const
|
|
8856
|
+
const merge3 = /* @__PURE__ */ __name((answer) => {
|
|
6780
8857
|
if (answer > result)
|
|
6781
8858
|
result = answer;
|
|
6782
8859
|
}, "merge");
|
|
@@ -6785,7 +8862,7 @@ function isRecursive(inst, stack, resolve) {
|
|
|
6785
8862
|
switch (kind) {
|
|
6786
8863
|
case "object": {
|
|
6787
8864
|
const raw = rawShape(def);
|
|
6788
|
-
|
|
8865
|
+
merge3(raw ? shape(raw, true) : ASSUMED);
|
|
6789
8866
|
check2(def.catchall);
|
|
6790
8867
|
break;
|
|
6791
8868
|
}
|
|
@@ -6835,7 +8912,7 @@ function isRecursive(inst, stack, resolve) {
|
|
|
6835
8912
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
6836
8913
|
case "lazy": {
|
|
6837
8914
|
const inner = def._cachedInner ?? (resolve ? inst._zod.innerType : void 0);
|
|
6838
|
-
|
|
8915
|
+
merge3(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
6839
8916
|
break;
|
|
6840
8917
|
}
|
|
6841
8918
|
// a leaf by choice: `parts` are regex fragments, not data positions
|
|
@@ -15850,9 +17927,9 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
15850
17927
|
return outputVar;
|
|
15851
17928
|
}
|
|
15852
17929
|
__name(generateNullableCheck, "generateNullableCheck");
|
|
15853
|
-
function generateSizeGate(doc, schema,
|
|
17930
|
+
function generateSizeGate(doc, schema, size2) {
|
|
15854
17931
|
for (const [max, check2] of sizeCaps(schema._zod.def.checks)) {
|
|
15855
|
-
doc.write(`if (${
|
|
17932
|
+
doc.write(`if (${size2} > ${numericOperand(max, check2._zod.def.check)}) return INVALID;`);
|
|
15856
17933
|
}
|
|
15857
17934
|
}
|
|
15858
17935
|
__name(generateSizeGate, "generateSizeGate");
|
|
@@ -17081,11 +19158,11 @@ function _minSize(minimum, params) {
|
|
|
17081
19158
|
}
|
|
17082
19159
|
__name(_minSize, "_minSize");
|
|
17083
19160
|
// @__NO_SIDE_EFFECTS__
|
|
17084
|
-
function _size(
|
|
19161
|
+
function _size(size2, params) {
|
|
17085
19162
|
return new $ZodCheckSizeEquals({
|
|
17086
19163
|
check: "size_equals",
|
|
17087
19164
|
...normalizeParams(params),
|
|
17088
|
-
size
|
|
19165
|
+
size: size2
|
|
17089
19166
|
});
|
|
17090
19167
|
}
|
|
17091
19168
|
__name(_size, "_size");
|
|
@@ -17329,19 +19406,19 @@ function _set(Class2, valueType, params) {
|
|
|
17329
19406
|
__name(_set, "_set");
|
|
17330
19407
|
// @__NO_SIDE_EFFECTS__
|
|
17331
19408
|
function _enum(Class2, values, params) {
|
|
17332
|
-
const
|
|
19409
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
17333
19410
|
return new Class2({
|
|
17334
19411
|
type: "enum",
|
|
17335
|
-
entries,
|
|
19412
|
+
entries: entries2,
|
|
17336
19413
|
...normalizeParams(params)
|
|
17337
19414
|
});
|
|
17338
19415
|
}
|
|
17339
19416
|
__name(_enum, "_enum");
|
|
17340
19417
|
// @__NO_SIDE_EFFECTS__
|
|
17341
|
-
function _nativeEnum(Class2,
|
|
19418
|
+
function _nativeEnum(Class2, entries2, params) {
|
|
17342
19419
|
return new Class2({
|
|
17343
19420
|
type: "enum",
|
|
17344
|
-
entries,
|
|
19421
|
+
entries: entries2,
|
|
17345
19422
|
...normalizeParams(params)
|
|
17346
19423
|
});
|
|
17347
19424
|
}
|
|
@@ -19149,7 +21226,7 @@ __export(schemas_exports2, {
|
|
|
19149
21226
|
pipe: () => pipe,
|
|
19150
21227
|
prefault: () => prefault,
|
|
19151
21228
|
preprocess: () => preprocess,
|
|
19152
|
-
promise: () =>
|
|
21229
|
+
promise: () => promise2,
|
|
19153
21230
|
readonly: () => readonly,
|
|
19154
21231
|
record: () => record,
|
|
19155
21232
|
refine: () => refine,
|
|
@@ -19279,12 +21356,12 @@ var safeDecodeAsync2 = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
|
19279
21356
|
// node_modules/zod/v4/classic/schemas.js
|
|
19280
21357
|
function _ensureDefaultLocale() {
|
|
19281
21358
|
if (!globalConfig.localeError)
|
|
19282
|
-
|
|
21359
|
+
config2(en_default());
|
|
19283
21360
|
}
|
|
19284
21361
|
__name(_ensureDefaultLocale, "_ensureDefaultLocale");
|
|
19285
21362
|
function _ensureDefaultMemoizer() {
|
|
19286
21363
|
if (!globalConfig.memoizer)
|
|
19287
|
-
|
|
21364
|
+
config2({ memoizer: memoizer() });
|
|
19288
21365
|
}
|
|
19289
21366
|
__name(_ensureDefaultMemoizer, "_ensureDefaultMemoizer");
|
|
19290
21367
|
var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
@@ -20431,18 +22508,18 @@ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
|
20431
22508
|
};
|
|
20432
22509
|
});
|
|
20433
22510
|
function _enum2(values, params) {
|
|
20434
|
-
const
|
|
22511
|
+
const entries2 = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
|
|
20435
22512
|
return new ZodEnum({
|
|
20436
22513
|
type: "enum",
|
|
20437
|
-
entries,
|
|
22514
|
+
entries: entries2,
|
|
20438
22515
|
...util_exports.normalizeParams(params)
|
|
20439
22516
|
});
|
|
20440
22517
|
}
|
|
20441
22518
|
__name(_enum2, "_enum");
|
|
20442
|
-
function nativeEnum(
|
|
22519
|
+
function nativeEnum(entries2, params) {
|
|
20443
22520
|
return new ZodEnum({
|
|
20444
22521
|
type: "enum",
|
|
20445
|
-
entries,
|
|
22522
|
+
entries: entries2,
|
|
20446
22523
|
...util_exports.normalizeParams(params)
|
|
20447
22524
|
});
|
|
20448
22525
|
}
|
|
@@ -20473,8 +22550,8 @@ var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
|
20473
22550
|
$ZodFile.init(inst, def);
|
|
20474
22551
|
ZodType.init(inst, def);
|
|
20475
22552
|
inst._zod.processJSONSchema = (ctx, json2, params) => fileProcessor(inst, ctx, json2, params);
|
|
20476
|
-
inst.min = (
|
|
20477
|
-
inst.max = (
|
|
22553
|
+
inst.min = (size2, params) => inst.check(_minSize(size2, params));
|
|
22554
|
+
inst.max = (size2, params) => inst.check(_maxSize(size2, params));
|
|
20478
22555
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
20479
22556
|
});
|
|
20480
22557
|
function file(params) {
|
|
@@ -20739,13 +22816,13 @@ var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
|
20739
22816
|
inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
|
|
20740
22817
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
20741
22818
|
});
|
|
20742
|
-
function
|
|
22819
|
+
function promise2(innerType) {
|
|
20743
22820
|
return new ZodPromise({
|
|
20744
22821
|
type: "promise",
|
|
20745
22822
|
innerType
|
|
20746
22823
|
});
|
|
20747
22824
|
}
|
|
20748
|
-
__name(
|
|
22825
|
+
__name(promise2, "promise");
|
|
20749
22826
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
20750
22827
|
$ZodFunction.init(inst, def);
|
|
20751
22828
|
ZodType.init(inst, def);
|
|
@@ -20853,13 +22930,13 @@ var ZodIssueCode = {
|
|
|
20853
22930
|
custom: "custom"
|
|
20854
22931
|
};
|
|
20855
22932
|
function setErrorMap(map2) {
|
|
20856
|
-
|
|
22933
|
+
config2({
|
|
20857
22934
|
customError: map2
|
|
20858
22935
|
});
|
|
20859
22936
|
}
|
|
20860
22937
|
__name(setErrorMap, "setErrorMap");
|
|
20861
22938
|
function getErrorMap() {
|
|
20862
|
-
return
|
|
22939
|
+
return config2().customError;
|
|
20863
22940
|
}
|
|
20864
22941
|
__name(getErrorMap, "getErrorMap");
|
|
20865
22942
|
var ZodFirstPartyTypeKind;
|
|
@@ -21985,7 +24062,7 @@ function useSelectContext(componentName) {
|
|
|
21985
24062
|
}
|
|
21986
24063
|
__name(useSelectContext, "useSelectContext");
|
|
21987
24064
|
var SelectGroupContext = createContext(null);
|
|
21988
|
-
var SelectRoot = createComponent({
|
|
24065
|
+
var SelectRoot = createComponent$1({
|
|
21989
24066
|
displayName: "Select.Root",
|
|
21990
24067
|
__kui: {
|
|
21991
24068
|
role: "formControl",
|
|
@@ -22008,7 +24085,7 @@ var SelectRoot = createComponent({
|
|
|
22008
24085
|
required: required2,
|
|
22009
24086
|
name,
|
|
22010
24087
|
variant = "outline",
|
|
22011
|
-
size = "md",
|
|
24088
|
+
size: size2 = "md",
|
|
22012
24089
|
className,
|
|
22013
24090
|
placeholder,
|
|
22014
24091
|
"aria-describedby": ariaDescribedBy,
|
|
@@ -22099,7 +24176,7 @@ var SelectRoot = createComponent({
|
|
|
22099
24176
|
onValueChange: handleValueChange,
|
|
22100
24177
|
disabled: isDisabled,
|
|
22101
24178
|
variant,
|
|
22102
|
-
size,
|
|
24179
|
+
size: size2,
|
|
22103
24180
|
open: open2,
|
|
22104
24181
|
setOpen,
|
|
22105
24182
|
triggerId,
|
|
@@ -22128,7 +24205,7 @@ var SelectRoot = createComponent({
|
|
|
22128
24205
|
handleValueChange,
|
|
22129
24206
|
isDisabled,
|
|
22130
24207
|
variant,
|
|
22131
|
-
|
|
24208
|
+
size2,
|
|
22132
24209
|
open2,
|
|
22133
24210
|
triggerId,
|
|
22134
24211
|
contentId,
|
|
@@ -22466,7 +24543,7 @@ function SelectLabel({ children, className }) {
|
|
|
22466
24543
|
}
|
|
22467
24544
|
__name(SelectLabel, "SelectLabel");
|
|
22468
24545
|
function SelectImpl({ options, children, label, ...rootProps }, ref) {
|
|
22469
|
-
const childArray =
|
|
24546
|
+
const childArray = React11.Children.toArray(children);
|
|
22470
24547
|
const compound = childArray.length > 0;
|
|
22471
24548
|
if (isDev() && compound && options?.length) {
|
|
22472
24549
|
console.warn(
|
|
@@ -22488,7 +24565,7 @@ function SelectImpl({ options, children, label, ...rootProps }, ref) {
|
|
|
22488
24565
|
] }) });
|
|
22489
24566
|
}
|
|
22490
24567
|
__name(SelectImpl, "SelectImpl");
|
|
22491
|
-
var SelectForwardRef =
|
|
24568
|
+
var SelectForwardRef = React11.forwardRef(SelectImpl);
|
|
22492
24569
|
var Select = Object.assign(SelectForwardRef, {
|
|
22493
24570
|
Root: SelectRoot,
|
|
22494
24571
|
Trigger: SelectTrigger,
|
|
@@ -22507,7 +24584,7 @@ var switchThumbConfig = {
|
|
|
22507
24584
|
md: { thumb: "h-4 w-4", translate: "translate-x-4" },
|
|
22508
24585
|
lg: { thumb: "h-5 w-5", translate: "translate-x-5" }
|
|
22509
24586
|
};
|
|
22510
|
-
var Switch = createComponent({
|
|
24587
|
+
var Switch = createComponent$1({
|
|
22511
24588
|
displayName: "Switch",
|
|
22512
24589
|
__kui: {
|
|
22513
24590
|
role: "formControl",
|
|
@@ -22527,7 +24604,7 @@ var Switch = createComponent({
|
|
|
22527
24604
|
checked: checkedProp,
|
|
22528
24605
|
defaultChecked = false,
|
|
22529
24606
|
onCheckedChange,
|
|
22530
|
-
size = "md",
|
|
24607
|
+
size: size2 = "md",
|
|
22531
24608
|
disabled = false,
|
|
22532
24609
|
label,
|
|
22533
24610
|
description,
|
|
@@ -22551,16 +24628,16 @@ var Switch = createComponent({
|
|
|
22551
24628
|
const [internalChecked, setInternalChecked] = useState(defaultChecked);
|
|
22552
24629
|
const checked = checkedProp !== void 0 ? checkedProp : internalChecked;
|
|
22553
24630
|
const descriptionId = description ? `${id}-description` : void 0;
|
|
22554
|
-
const { thumb, translate } = switchThumbConfig[
|
|
24631
|
+
const { thumb, translate } = switchThumbConfig[size2];
|
|
22555
24632
|
const state = isInvalid ? "error" : success2 ? "success" : "none";
|
|
22556
24633
|
const switchClasses = resolveRecipe(theme.recipes.Switch, {
|
|
22557
24634
|
checked,
|
|
22558
24635
|
disabled: isDisabled,
|
|
22559
24636
|
state
|
|
22560
24637
|
});
|
|
22561
|
-
const fontSize = useSizeToken(
|
|
22562
|
-
const width = useSizeToken(
|
|
22563
|
-
const height = useSizeToken(
|
|
24638
|
+
const fontSize = useSizeToken(size2, "fontSize");
|
|
24639
|
+
const width = useSizeToken(size2, "width", "-2px");
|
|
24640
|
+
const height = useSizeToken(size2, "height", "12px");
|
|
22564
24641
|
const describedBy = [field?.describedBy, descriptionId].filter(Boolean).join(" ") || void 0;
|
|
22565
24642
|
function handleChange(event) {
|
|
22566
24643
|
const next = event.target.checked;
|
|
@@ -22608,7 +24685,7 @@ var Switch = createComponent({
|
|
|
22608
24685
|
"div",
|
|
22609
24686
|
{
|
|
22610
24687
|
className: cn(
|
|
22611
|
-
"absolute left-1 rounded-full bg-white shadow top-1/2 -translate-y-1/2",
|
|
24688
|
+
"absolute left-1 rounded-full bg-kui-white shadow top-1/2 -translate-y-1/2",
|
|
22612
24689
|
!motionGated && "transition-transform duration-(--kui-duration-fast)",
|
|
22613
24690
|
thumb,
|
|
22614
24691
|
checked && translate
|
|
@@ -22682,7 +24759,7 @@ var TextareaCore = forwardRef(
|
|
|
22682
24759
|
className,
|
|
22683
24760
|
style: customStyle,
|
|
22684
24761
|
typography: typographyName = "body",
|
|
22685
|
-
size = "md",
|
|
24762
|
+
size: size2 = "md",
|
|
22686
24763
|
variant = "outline",
|
|
22687
24764
|
resize = "vertical",
|
|
22688
24765
|
fullWidth = true,
|
|
@@ -22714,7 +24791,7 @@ var TextareaCore = forwardRef(
|
|
|
22714
24791
|
const internalRef = useRef(null);
|
|
22715
24792
|
const debounceTimer = useRef(null);
|
|
22716
24793
|
const typography = useTypography(typographyName);
|
|
22717
|
-
const { style: sizeStyle } = useSizeStyle(
|
|
24794
|
+
const { style: sizeStyle } = useSizeStyle(size2, false, "textarea", {
|
|
22718
24795
|
includeHeight: false
|
|
22719
24796
|
});
|
|
22720
24797
|
const [draft, setDraft] = useState(() => valueProp ?? defaultValue ?? "");
|
|
@@ -22916,7 +24993,7 @@ var TextareaCore = forwardRef(
|
|
|
22916
24993
|
required: required2,
|
|
22917
24994
|
style: textareaStyle,
|
|
22918
24995
|
className: cn(textareaClasses, className),
|
|
22919
|
-
"data-size":
|
|
24996
|
+
"data-size": size2,
|
|
22920
24997
|
"data-invalid": isInvalid || void 0,
|
|
22921
24998
|
"data-success": isSuccess || void 0,
|
|
22922
24999
|
"data-warning": isWarning || void 0,
|
|
@@ -22959,7 +25036,7 @@ var TextareaCore = forwardRef(
|
|
|
22959
25036
|
}
|
|
22960
25037
|
);
|
|
22961
25038
|
TextareaCore.displayName = "TextareaCore";
|
|
22962
|
-
var Textarea = createComponent({
|
|
25039
|
+
var Textarea = createComponent$1({
|
|
22963
25040
|
displayName: "Textarea",
|
|
22964
25041
|
__kui: {
|
|
22965
25042
|
role: "formControl",
|
|
@@ -22979,7 +25056,7 @@ var Textarea = createComponent({
|
|
|
22979
25056
|
return /* @__PURE__ */ jsx(TextareaCore, { ref, ...props });
|
|
22980
25057
|
}, "render")
|
|
22981
25058
|
});
|
|
22982
|
-
var Checkbox = createComponent({
|
|
25059
|
+
var Checkbox = createComponent$1({
|
|
22983
25060
|
displayName: "Checkbox",
|
|
22984
25061
|
__kui: {
|
|
22985
25062
|
role: "formControl",
|
|
@@ -23001,7 +25078,7 @@ var Checkbox = createComponent({
|
|
|
23001
25078
|
defaultChecked,
|
|
23002
25079
|
onCheckedChange,
|
|
23003
25080
|
indeterminate = false,
|
|
23004
|
-
size = "sm",
|
|
25081
|
+
size: size2 = "sm",
|
|
23005
25082
|
error: error62,
|
|
23006
25083
|
success: success2,
|
|
23007
25084
|
status,
|
|
@@ -23047,7 +25124,7 @@ var Checkbox = createComponent({
|
|
|
23047
25124
|
style: sizeStyle,
|
|
23048
25125
|
iconSize,
|
|
23049
25126
|
fontSize
|
|
23050
|
-
} = useSizeStyle(
|
|
25127
|
+
} = useSizeStyle(size2, !hasLabels, "checkbox", {
|
|
23051
25128
|
widthFromHeight: true,
|
|
23052
25129
|
sizeOffset: "7px",
|
|
23053
25130
|
includeWidth: true
|
|
@@ -23201,7 +25278,7 @@ function formatValue(value, precision) {
|
|
|
23201
25278
|
return precision !== void 0 ? value.toFixed(precision) : String(value);
|
|
23202
25279
|
}
|
|
23203
25280
|
__name(formatValue, "formatValue");
|
|
23204
|
-
var NumberStepper = createComponent({
|
|
25281
|
+
var NumberStepper = createComponent$1({
|
|
23205
25282
|
__kui: {
|
|
23206
25283
|
formControl: "single",
|
|
23207
25284
|
role: "formControl",
|
|
@@ -23224,7 +25301,7 @@ var NumberStepper = createComponent({
|
|
|
23224
25301
|
disabled = false,
|
|
23225
25302
|
required: required2 = false,
|
|
23226
25303
|
name,
|
|
23227
|
-
size = "md",
|
|
25304
|
+
size: size2 = "md",
|
|
23228
25305
|
className,
|
|
23229
25306
|
style,
|
|
23230
25307
|
"aria-label": ariaLabel,
|
|
@@ -23240,11 +25317,11 @@ var NumberStepper = createComponent({
|
|
|
23240
25317
|
defaultValue: defaultValue ?? min,
|
|
23241
25318
|
onChange: onValueChange
|
|
23242
25319
|
});
|
|
23243
|
-
const [text, setText] =
|
|
25320
|
+
const [text, setText] = React11.useState(
|
|
23244
25321
|
() => formatValue(committedValue, precision)
|
|
23245
25322
|
);
|
|
23246
|
-
const lastCommittedRef =
|
|
23247
|
-
|
|
25323
|
+
const lastCommittedRef = React11.useRef(committedValue);
|
|
25324
|
+
React11.useEffect(() => {
|
|
23248
25325
|
if (committedValue !== lastCommittedRef.current) {
|
|
23249
25326
|
lastCommittedRef.current = committedValue;
|
|
23250
25327
|
setText(formatValue(committedValue, precision));
|
|
@@ -23255,7 +25332,7 @@ var NumberStepper = createComponent({
|
|
|
23255
25332
|
const isInvalid = error62 ?? field?.invalid ?? false;
|
|
23256
25333
|
const isDisabled = disabled || Boolean(field?.disabled);
|
|
23257
25334
|
const isRequired = required2 || Boolean(field?.required);
|
|
23258
|
-
const reportToFormField =
|
|
25335
|
+
const reportToFormField = React11.useCallback(
|
|
23259
25336
|
(result) => {
|
|
23260
25337
|
if (!field) return;
|
|
23261
25338
|
if (!result.valid) {
|
|
@@ -23267,7 +25344,7 @@ var NumberStepper = createComponent({
|
|
|
23267
25344
|
},
|
|
23268
25345
|
[field, min, max, step]
|
|
23269
25346
|
);
|
|
23270
|
-
const runValidation =
|
|
25347
|
+
const runValidation = React11.useCallback(
|
|
23271
25348
|
(raw) => {
|
|
23272
25349
|
const result = validateNumberStepper({
|
|
23273
25350
|
raw,
|
|
@@ -23283,7 +25360,7 @@ var NumberStepper = createComponent({
|
|
|
23283
25360
|
},
|
|
23284
25361
|
[min, max, step, precision, onValidate, reportToFormField, isRequired]
|
|
23285
25362
|
);
|
|
23286
|
-
const applyResolvedValue =
|
|
25363
|
+
const applyResolvedValue = React11.useCallback(
|
|
23287
25364
|
(result, shouldClamp) => {
|
|
23288
25365
|
if (result.value === null) return;
|
|
23289
25366
|
const finalValue = shouldClamp && (result.errors.includes("min") || result.errors.includes("max") || result.errors.includes("step")) ? clampNumberStepper(result.value, min, max, step) : result.value;
|
|
@@ -23306,7 +25383,7 @@ var NumberStepper = createComponent({
|
|
|
23306
25383
|
applyResolvedValue(result, true);
|
|
23307
25384
|
}
|
|
23308
25385
|
}, "handleBlur");
|
|
23309
|
-
const
|
|
25386
|
+
const commit2 = /* @__PURE__ */ __name(() => {
|
|
23310
25387
|
if (clampOn === "commit") {
|
|
23311
25388
|
const result = runValidation(text);
|
|
23312
25389
|
applyResolvedValue(result, true);
|
|
@@ -23323,7 +25400,7 @@ var NumberStepper = createComponent({
|
|
|
23323
25400
|
}, "step_");
|
|
23324
25401
|
const handleKeyDown = /* @__PURE__ */ __name((e) => {
|
|
23325
25402
|
if (e.key === "Enter") {
|
|
23326
|
-
|
|
25403
|
+
commit2();
|
|
23327
25404
|
} else if (e.key === "ArrowUp") {
|
|
23328
25405
|
e.preventDefault();
|
|
23329
25406
|
step_(1);
|
|
@@ -23383,7 +25460,7 @@ var NumberStepper = createComponent({
|
|
|
23383
25460
|
onBlur: handleBlur,
|
|
23384
25461
|
onKeyDown: handleKeyDown,
|
|
23385
25462
|
disabled: isDisabled,
|
|
23386
|
-
size,
|
|
25463
|
+
size: size2,
|
|
23387
25464
|
variant,
|
|
23388
25465
|
"aria-label": ariaLabel,
|
|
23389
25466
|
"aria-valuemin": min,
|
|
@@ -23447,8 +25524,8 @@ var WIDGET_REGISTRY = {
|
|
|
23447
25524
|
function getEnumOptions(zodType) {
|
|
23448
25525
|
const asEnum = zodType;
|
|
23449
25526
|
const values = Array.isArray(asEnum.options) ? asEnum.options : (() => {
|
|
23450
|
-
const
|
|
23451
|
-
return
|
|
25527
|
+
const entries2 = zodType._def?.entries;
|
|
25528
|
+
return entries2 ? Object.values(entries2) : void 0;
|
|
23452
25529
|
})();
|
|
23453
25530
|
if (!values) return void 0;
|
|
23454
25531
|
return values.map((value) => ({ label: humanizeFieldName(value), value }));
|
|
@@ -23582,7 +25659,7 @@ function BoundLeafField({
|
|
|
23582
25659
|
description
|
|
23583
25660
|
}) {
|
|
23584
25661
|
const form = useFormContext();
|
|
23585
|
-
const boundProps =
|
|
25662
|
+
const boundProps = React11.useMemo(() => {
|
|
23586
25663
|
if (!form) return props;
|
|
23587
25664
|
const value = form.getValue(fullName);
|
|
23588
25665
|
const onChangeHandler = /* @__PURE__ */ __name((next) => form.setValue(fullName, next), "onChangeHandler");
|
|
@@ -23674,20 +25751,20 @@ function RenderField({
|
|
|
23674
25751
|
return /* @__PURE__ */ jsx(Fragment, { children: render({ field, fieldState, controlProps }) });
|
|
23675
25752
|
}
|
|
23676
25753
|
__name(RenderField, "RenderField");
|
|
23677
|
-
var RepeaterRootContext =
|
|
25754
|
+
var RepeaterRootContext = React11.createContext(
|
|
23678
25755
|
null
|
|
23679
25756
|
);
|
|
23680
25757
|
function useRequiredRepeaterRootContext(partName) {
|
|
23681
|
-
const ctx =
|
|
25758
|
+
const ctx = React11.useContext(RepeaterRootContext);
|
|
23682
25759
|
if (!ctx) {
|
|
23683
25760
|
throw new Error(`<${partName} /> must be rendered inside <Repeater> or <Repeater.Root>.`);
|
|
23684
25761
|
}
|
|
23685
25762
|
return ctx;
|
|
23686
25763
|
}
|
|
23687
25764
|
__name(useRequiredRepeaterRootContext, "useRequiredRepeaterRootContext");
|
|
23688
|
-
var RepeaterItemContext =
|
|
25765
|
+
var RepeaterItemContext = React11.createContext(null);
|
|
23689
25766
|
function useRequiredRepeaterItemContext(partName) {
|
|
23690
|
-
const ctx =
|
|
25767
|
+
const ctx = React11.useContext(RepeaterItemContext);
|
|
23691
25768
|
if (!ctx) {
|
|
23692
25769
|
throw new Error(`<${partName} /> must be rendered inside <Repeater.Item>.`);
|
|
23693
25770
|
}
|
|
@@ -23721,13 +25798,13 @@ function RepeaterRoot({
|
|
|
23721
25798
|
defaultValue: defaultValue ?? [],
|
|
23722
25799
|
onChange: onValueChange
|
|
23723
25800
|
});
|
|
23724
|
-
const remove =
|
|
25801
|
+
const remove = React11.useCallback(
|
|
23725
25802
|
(index) => {
|
|
23726
25803
|
setValue(value.filter((_, i) => i !== index));
|
|
23727
25804
|
},
|
|
23728
25805
|
[value, setValue]
|
|
23729
25806
|
);
|
|
23730
|
-
const moveUp =
|
|
25807
|
+
const moveUp = React11.useCallback(
|
|
23731
25808
|
(index) => {
|
|
23732
25809
|
if (index <= 0) return;
|
|
23733
25810
|
const next = value.slice();
|
|
@@ -23736,7 +25813,7 @@ function RepeaterRoot({
|
|
|
23736
25813
|
},
|
|
23737
25814
|
[value, setValue]
|
|
23738
25815
|
);
|
|
23739
|
-
const moveDown =
|
|
25816
|
+
const moveDown = React11.useCallback(
|
|
23740
25817
|
(index) => {
|
|
23741
25818
|
if (index >= value.length - 1) return;
|
|
23742
25819
|
const next = value.slice();
|
|
@@ -23745,7 +25822,7 @@ function RepeaterRoot({
|
|
|
23745
25822
|
},
|
|
23746
25823
|
[value, setValue]
|
|
23747
25824
|
);
|
|
23748
|
-
const insert =
|
|
25825
|
+
const insert = React11.useCallback(
|
|
23749
25826
|
(item, position) => {
|
|
23750
25827
|
if (position === "append") {
|
|
23751
25828
|
setValue([...value, item]);
|
|
@@ -23761,7 +25838,7 @@ function RepeaterRoot({
|
|
|
23761
25838
|
},
|
|
23762
25839
|
[value, setValue]
|
|
23763
25840
|
);
|
|
23764
|
-
const contextValue =
|
|
25841
|
+
const contextValue = React11.useMemo(
|
|
23765
25842
|
() => ({
|
|
23766
25843
|
value,
|
|
23767
25844
|
getKey,
|
|
@@ -23775,7 +25852,7 @@ function RepeaterRoot({
|
|
|
23775
25852
|
return /* @__PURE__ */ jsx(RepeaterRootContext.Provider, { value: contextValue, children });
|
|
23776
25853
|
}
|
|
23777
25854
|
__name(RepeaterRoot, "RepeaterRoot");
|
|
23778
|
-
var RepeaterItems = createComponent({
|
|
25855
|
+
var RepeaterItems = createComponent$1({
|
|
23779
25856
|
displayName: "Repeater.Items",
|
|
23780
25857
|
__kui: {
|
|
23781
25858
|
role: "layout",
|
|
@@ -23791,13 +25868,13 @@ var RepeaterItems = createComponent({
|
|
|
23791
25868
|
},
|
|
23792
25869
|
render: /* @__PURE__ */ __name(function RepeaterItems2({ children }, _ref) {
|
|
23793
25870
|
const ctx = useRequiredRepeaterRootContext("Repeater.Items");
|
|
23794
|
-
return /* @__PURE__ */ jsx(
|
|
25871
|
+
return /* @__PURE__ */ jsx(React11.Fragment, { children: ctx.value.map((item, index) => /* @__PURE__ */ jsx(React11.Fragment, { children: children(item, index) }, ctx.getKey(item, index))) });
|
|
23795
25872
|
}, "RepeaterItems")
|
|
23796
25873
|
});
|
|
23797
25874
|
function useFlipAnimation(ref, deps) {
|
|
23798
|
-
const previousRect =
|
|
23799
|
-
const animation =
|
|
23800
|
-
|
|
25875
|
+
const previousRect = React11.useRef(null);
|
|
25876
|
+
const animation = React11.useRef(null);
|
|
25877
|
+
React11.useLayoutEffect(() => {
|
|
23801
25878
|
const el = ref.current;
|
|
23802
25879
|
if (!el) return;
|
|
23803
25880
|
const nextRect = el.getBoundingClientRect();
|
|
@@ -23829,14 +25906,14 @@ function useFlipAnimation(ref, deps) {
|
|
|
23829
25906
|
animation.current = null;
|
|
23830
25907
|
};
|
|
23831
25908
|
}, deps);
|
|
23832
|
-
|
|
25909
|
+
React11.useEffect(() => {
|
|
23833
25910
|
return () => {
|
|
23834
25911
|
animation.current?.cancel();
|
|
23835
25912
|
};
|
|
23836
25913
|
}, []);
|
|
23837
25914
|
}
|
|
23838
25915
|
__name(useFlipAnimation, "useFlipAnimation");
|
|
23839
|
-
var RepeaterItem = createComponent({
|
|
25916
|
+
var RepeaterItem = createComponent$1({
|
|
23840
25917
|
displayName: "Repeater.Item",
|
|
23841
25918
|
__kui: {
|
|
23842
25919
|
role: "layout",
|
|
@@ -23851,20 +25928,20 @@ var RepeaterItem = createComponent({
|
|
|
23851
25928
|
}
|
|
23852
25929
|
},
|
|
23853
25930
|
render: /* @__PURE__ */ __name(function RepeaterItem2({ index, children, className, ...rest }, ref) {
|
|
23854
|
-
const internalRef =
|
|
23855
|
-
const composedRef =
|
|
25931
|
+
const internalRef = React11.useRef(null);
|
|
25932
|
+
const composedRef = React11.useMemo(
|
|
23856
25933
|
() => composeRefs(ref, internalRef),
|
|
23857
25934
|
[ref]
|
|
23858
25935
|
);
|
|
23859
25936
|
useFlipAnimation(internalRef, [index]);
|
|
23860
|
-
const contextValue =
|
|
25937
|
+
const contextValue = React11.useMemo(() => ({ index }), [index]);
|
|
23861
25938
|
const { theme } = useTheme();
|
|
23862
25939
|
const resolvedRecipe = resolveRecipe(theme.recipes.RepeaterItem);
|
|
23863
25940
|
const classes = cn(resolvedRecipe, className);
|
|
23864
25941
|
return /* @__PURE__ */ jsx(RepeaterItemContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx("div", { ref: composedRef, className: classes, ...rest, children }) });
|
|
23865
25942
|
}, "RepeaterItem")
|
|
23866
25943
|
});
|
|
23867
|
-
var RepeaterRemove = createComponent({
|
|
25944
|
+
var RepeaterRemove = createComponent$1({
|
|
23868
25945
|
displayName: "Repeater.Remove",
|
|
23869
25946
|
__kui: {
|
|
23870
25947
|
role: "action",
|
|
@@ -23901,7 +25978,7 @@ var RepeaterRemove = createComponent({
|
|
|
23901
25978
|
);
|
|
23902
25979
|
}, "RepeaterRemove")
|
|
23903
25980
|
});
|
|
23904
|
-
var RepeaterMoveUp = createComponent({
|
|
25981
|
+
var RepeaterMoveUp = createComponent$1({
|
|
23905
25982
|
displayName: "Repeater.MoveUp",
|
|
23906
25983
|
__kui: {
|
|
23907
25984
|
role: "action",
|
|
@@ -23940,7 +26017,7 @@ var RepeaterMoveUp = createComponent({
|
|
|
23940
26017
|
);
|
|
23941
26018
|
}, "RepeaterMoveUp")
|
|
23942
26019
|
});
|
|
23943
|
-
var RepeaterMoveDown = createComponent({
|
|
26020
|
+
var RepeaterMoveDown = createComponent$1({
|
|
23944
26021
|
displayName: "Repeater.MoveDown",
|
|
23945
26022
|
__kui: {
|
|
23946
26023
|
role: "action",
|
|
@@ -23979,7 +26056,7 @@ var RepeaterMoveDown = createComponent({
|
|
|
23979
26056
|
);
|
|
23980
26057
|
}, "RepeaterMoveDown")
|
|
23981
26058
|
});
|
|
23982
|
-
var RepeaterAdd = createComponent({
|
|
26059
|
+
var RepeaterAdd = createComponent$1({
|
|
23983
26060
|
displayName: "Repeater.Add",
|
|
23984
26061
|
__kui: {
|
|
23985
26062
|
role: "action",
|
|
@@ -24029,10 +26106,10 @@ var Repeater = Object.assign(RepeaterRoot, {
|
|
|
24029
26106
|
});
|
|
24030
26107
|
|
|
24031
26108
|
// src/components/forms/form/FromSchema/generatedKeys.ts
|
|
24032
|
-
var
|
|
26109
|
+
var counter2 = 0;
|
|
24033
26110
|
function nextGeneratedKey() {
|
|
24034
|
-
|
|
24035
|
-
return `kui-repeater-${
|
|
26111
|
+
counter2 += 1;
|
|
26112
|
+
return `kui-repeater-${counter2}`;
|
|
24036
26113
|
}
|
|
24037
26114
|
__name(nextGeneratedKey, "nextGeneratedKey");
|
|
24038
26115
|
var REPEATER_KEY = "__repeaterKey";
|
|
@@ -24063,7 +26140,7 @@ function ArrayItemFormProvider({
|
|
|
24063
26140
|
throw new Error("ArrayItemFormProvider requires an enclosing <Form>.");
|
|
24064
26141
|
}
|
|
24065
26142
|
const itemPrefix = `${arrayName}.${index}.`;
|
|
24066
|
-
const setValue =
|
|
26143
|
+
const setValue = React11.useCallback(
|
|
24067
26144
|
(fieldName, value) => {
|
|
24068
26145
|
if (!fieldName.startsWith(itemPrefix)) {
|
|
24069
26146
|
parentForm.setValue(fieldName, value);
|
|
@@ -24078,7 +26155,7 @@ function ArrayItemFormProvider({
|
|
|
24078
26155
|
},
|
|
24079
26156
|
[parentForm, arrayName, index, itemPrefix]
|
|
24080
26157
|
);
|
|
24081
|
-
const getValue =
|
|
26158
|
+
const getValue = React11.useCallback(
|
|
24082
26159
|
(fieldName) => {
|
|
24083
26160
|
if (!fieldName.startsWith(itemPrefix)) {
|
|
24084
26161
|
return parentForm.getValue(fieldName);
|
|
@@ -24091,7 +26168,7 @@ function ArrayItemFormProvider({
|
|
|
24091
26168
|
},
|
|
24092
26169
|
[parentForm, arrayName, index, itemPrefix]
|
|
24093
26170
|
);
|
|
24094
|
-
const contextValue =
|
|
26171
|
+
const contextValue = React11.useMemo(
|
|
24095
26172
|
() => ({ ...parentForm, setValue, getValue }),
|
|
24096
26173
|
[parentForm, setValue, getValue]
|
|
24097
26174
|
);
|
|
@@ -24117,7 +26194,7 @@ function ArrayField({
|
|
|
24117
26194
|
}
|
|
24118
26195
|
const rawValue = form.getValue(name);
|
|
24119
26196
|
const value = Array.isArray(rawValue) ? rawValue : [];
|
|
24120
|
-
const setValue =
|
|
26197
|
+
const setValue = React11.useCallback(
|
|
24121
26198
|
(next) => {
|
|
24122
26199
|
form.setValue(name, next);
|
|
24123
26200
|
},
|
|
@@ -24304,16 +26381,16 @@ __name(renderLeaf, "renderLeaf");
|
|
|
24304
26381
|
function generateFieldsInternal(shape, uiSchema, options = {}) {
|
|
24305
26382
|
const pathPrefix = options.pathPrefix;
|
|
24306
26383
|
const fieldNames = Object.keys(shape);
|
|
24307
|
-
const
|
|
26384
|
+
const entries2 = fieldNames.map((fieldName) => {
|
|
24308
26385
|
const uiEntry = uiSchema?.[fieldName];
|
|
24309
26386
|
const order = uiEntry && isUIFieldSchema(uiEntry) ? uiEntry.order : void 0;
|
|
24310
26387
|
return { fieldName, uiEntry, order };
|
|
24311
26388
|
});
|
|
24312
|
-
|
|
26389
|
+
entries2.sort(
|
|
24313
26390
|
(a, b) => (a.order ?? Number.MAX_SAFE_INTEGER) - (b.order ?? Number.MAX_SAFE_INTEGER)
|
|
24314
26391
|
);
|
|
24315
26392
|
const built = /* @__PURE__ */ new Map();
|
|
24316
|
-
for (const { fieldName, uiEntry } of
|
|
26393
|
+
for (const { fieldName, uiEntry } of entries2) {
|
|
24317
26394
|
const fullName = pathPrefix ? `${pathPrefix}.${fieldName}` : fieldName;
|
|
24318
26395
|
const zodType = shape[fieldName];
|
|
24319
26396
|
const unwrapped = unwrap(zodType);
|
|
@@ -24401,7 +26478,7 @@ function generateFieldsInternal(shape, uiSchema, options = {}) {
|
|
|
24401
26478
|
}
|
|
24402
26479
|
)
|
|
24403
26480
|
] }, `section-${i}`));
|
|
24404
|
-
const unclaimedNodes =
|
|
26481
|
+
const unclaimedNodes = entries2.map((e) => e.fieldName).filter((name) => !claimed.has(name)).map((name) => built.get(name));
|
|
24405
26482
|
return [...sectionNodes, ...unclaimedNodes];
|
|
24406
26483
|
}
|
|
24407
26484
|
__name(generateFieldsInternal, "generateFieldsInternal");
|
|
@@ -24443,7 +26520,7 @@ function FormFromSchema({ uiSchema, schema: standaloneSchema }) {
|
|
|
24443
26520
|
shape,
|
|
24444
26521
|
uiSchema
|
|
24445
26522
|
);
|
|
24446
|
-
return /* @__PURE__ */ jsx(
|
|
26523
|
+
return /* @__PURE__ */ jsx(React11.Fragment, { children: fields });
|
|
24447
26524
|
}
|
|
24448
26525
|
__name(FormFromSchema, "FormFromSchema");
|
|
24449
26526
|
|
|
@@ -24461,8 +26538,8 @@ var Form = Object.assign(FormRoot, {
|
|
|
24461
26538
|
});
|
|
24462
26539
|
function countMessageComponents(children) {
|
|
24463
26540
|
let count = 0;
|
|
24464
|
-
|
|
24465
|
-
if (!
|
|
26541
|
+
React11.Children.forEach(children, (child) => {
|
|
26542
|
+
if (!React11.isValidElement(child)) {
|
|
24466
26543
|
return;
|
|
24467
26544
|
}
|
|
24468
26545
|
if (child.type === FormFieldMessage) {
|
|
@@ -24476,7 +26553,7 @@ function countMessageComponents(children) {
|
|
|
24476
26553
|
return count;
|
|
24477
26554
|
}
|
|
24478
26555
|
__name(countMessageComponents, "countMessageComponents");
|
|
24479
|
-
var FormFieldRoot = createComponent({
|
|
26556
|
+
var FormFieldRoot = createComponent$1({
|
|
24480
26557
|
displayName: "FormField.Root",
|
|
24481
26558
|
__kui: {
|
|
24482
26559
|
role: "formControl",
|
|
@@ -24505,14 +26582,14 @@ var FormFieldRoot = createComponent({
|
|
|
24505
26582
|
valuePropConvention
|
|
24506
26583
|
} = props;
|
|
24507
26584
|
const form = useFormContext();
|
|
24508
|
-
const fieldRef =
|
|
24509
|
-
const generatedId =
|
|
26585
|
+
const fieldRef = React11.useRef(null);
|
|
26586
|
+
const generatedId = React11.useId();
|
|
24510
26587
|
const id = externalId ?? generatedId;
|
|
24511
26588
|
const labelId = `${id}-label`;
|
|
24512
26589
|
const descriptionId = `${id}-description`;
|
|
24513
26590
|
const messageId = `${id}-message`;
|
|
24514
|
-
const [reportedValidity, setReportedValidity] =
|
|
24515
|
-
const reportValidity =
|
|
26591
|
+
const [reportedValidity, setReportedValidity] = React11.useState(null);
|
|
26592
|
+
const reportValidity = React11.useCallback(
|
|
24516
26593
|
(result) => {
|
|
24517
26594
|
setReportedValidity(result);
|
|
24518
26595
|
if (name) {
|
|
@@ -24522,12 +26599,12 @@ var FormFieldRoot = createComponent({
|
|
|
24522
26599
|
[name, form]
|
|
24523
26600
|
);
|
|
24524
26601
|
const reportedMessage = reportedValidity?.invalid ? reportedValidity.message : void 0;
|
|
24525
|
-
const [labelCount, setLabelCount] =
|
|
24526
|
-
const [descriptionCount, setDescriptionCount] =
|
|
24527
|
-
const registerLabel =
|
|
26602
|
+
const [labelCount, setLabelCount] = React11.useState(0);
|
|
26603
|
+
const [descriptionCount, setDescriptionCount] = React11.useState(0);
|
|
26604
|
+
const registerLabel = React11.useCallback((present) => {
|
|
24528
26605
|
setLabelCount((count) => count + (present ? 1 : -1));
|
|
24529
26606
|
}, []);
|
|
24530
|
-
const registerDescription =
|
|
26607
|
+
const registerDescription = React11.useCallback((present) => {
|
|
24531
26608
|
setDescriptionCount((count) => count + (present ? 1 : -1));
|
|
24532
26609
|
}, []);
|
|
24533
26610
|
const hasExternalLabel = labelCount > 0;
|
|
@@ -24540,7 +26617,7 @@ var FormFieldRoot = createComponent({
|
|
|
24540
26617
|
descriptionCount > 0 ? descriptionId : void 0,
|
|
24541
26618
|
message || hasCustomMessage ? messageId : void 0
|
|
24542
26619
|
].filter(Boolean).join(" ") || void 0;
|
|
24543
|
-
|
|
26620
|
+
React11.useEffect(() => {
|
|
24544
26621
|
if (!isDev()) {
|
|
24545
26622
|
return;
|
|
24546
26623
|
}
|
|
@@ -24550,12 +26627,12 @@ var FormFieldRoot = createComponent({
|
|
|
24550
26627
|
);
|
|
24551
26628
|
}
|
|
24552
26629
|
}, [children]);
|
|
24553
|
-
|
|
26630
|
+
React11.useEffect(() => {
|
|
24554
26631
|
if (!name) return;
|
|
24555
26632
|
form?.registerField(name, fieldRef.current);
|
|
24556
26633
|
return () => form?.registerField(name, null);
|
|
24557
26634
|
}, [name, form]);
|
|
24558
|
-
const contextValue =
|
|
26635
|
+
const contextValue = React11.useMemo(
|
|
24559
26636
|
() => ({
|
|
24560
26637
|
id,
|
|
24561
26638
|
name,
|
|
@@ -24601,7 +26678,7 @@ var FormFieldRoot = createComponent({
|
|
|
24601
26678
|
] }) });
|
|
24602
26679
|
}, "render")
|
|
24603
26680
|
});
|
|
24604
|
-
var FormFieldLabel = createComponent({
|
|
26681
|
+
var FormFieldLabel = createComponent$1({
|
|
24605
26682
|
displayName: "FormField.Label",
|
|
24606
26683
|
__kui: {
|
|
24607
26684
|
role: "display",
|
|
@@ -24644,7 +26721,7 @@ var FormFieldLabel = createComponent({
|
|
|
24644
26721
|
);
|
|
24645
26722
|
}, "render")
|
|
24646
26723
|
});
|
|
24647
|
-
var FormFieldDescription = createComponent({
|
|
26724
|
+
var FormFieldDescription = createComponent$1({
|
|
24648
26725
|
displayName: "FormField.Description",
|
|
24649
26726
|
__kui: {
|
|
24650
26727
|
role: "display",
|
|
@@ -24687,7 +26764,7 @@ function sameValidity(prev, next) {
|
|
|
24687
26764
|
return prev === null && next === null || prev?.invalid === next?.invalid && prev?.message === next?.message;
|
|
24688
26765
|
}
|
|
24689
26766
|
__name(sameValidity, "sameValidity");
|
|
24690
|
-
var FormFieldControl = createComponent(
|
|
26767
|
+
var FormFieldControl = createComponent$1(
|
|
24691
26768
|
{
|
|
24692
26769
|
displayName: "FormField.Control",
|
|
24693
26770
|
__kui: {
|
|
@@ -24695,22 +26772,22 @@ var FormFieldControl = createComponent(
|
|
|
24695
26772
|
groupSlot: "FormField",
|
|
24696
26773
|
skeleton: "preserve"
|
|
24697
26774
|
},
|
|
24698
|
-
render({ children }, forwardedRef) {
|
|
26775
|
+
render({ children, suppressKuiWarning = false }, forwardedRef) {
|
|
24699
26776
|
const ctx = useFormField("FormField.Control");
|
|
24700
26777
|
const form = useFormContext();
|
|
24701
|
-
const controlRef =
|
|
24702
|
-
const [node2, setNode] =
|
|
24703
|
-
const lastReportedRef =
|
|
26778
|
+
const controlRef = React11.useRef(null);
|
|
26779
|
+
const [node2, setNode] = React11.useState(null);
|
|
26780
|
+
const lastReportedRef = React11.useRef(
|
|
24704
26781
|
void 0
|
|
24705
26782
|
);
|
|
24706
|
-
if (!
|
|
26783
|
+
if (!React11.isValidElement(children)) {
|
|
24707
26784
|
throw new Error(
|
|
24708
26785
|
"[kreativ-ui/FormField.Control]: requires exactly one React element child."
|
|
24709
26786
|
);
|
|
24710
26787
|
}
|
|
24711
26788
|
const child = children;
|
|
24712
26789
|
const childType = child.type;
|
|
24713
|
-
if (isDev() && !hasKuiMeta(childType)) {
|
|
26790
|
+
if (isDev() && !hasKuiMeta(childType) && !suppressKuiWarning) {
|
|
24714
26791
|
console.warn(
|
|
24715
26792
|
"[kreativ-ui/FormField.Control]: child component doesn't carry Kreativ UI's __kui metadata. Make sure it forwards both the injected form-control props (id, aria-invalid, aria-required, aria-describedby, disabled) AND its ref to its own actual interactive element, or it may not wire up to the field correctly."
|
|
24716
26793
|
);
|
|
@@ -24719,7 +26796,7 @@ var FormFieldControl = createComponent(
|
|
|
24719
26796
|
const mergedDescribedBy = [existingDescribedBy, ctx.describedBy].filter(Boolean).join(" ") || void 0;
|
|
24720
26797
|
const shouldValidateOnChange = ctx.validateOn === "change" || ctx.validateOn === "both";
|
|
24721
26798
|
const existingOnChange = child.props.onChange;
|
|
24722
|
-
const reportIfChanged =
|
|
26799
|
+
const reportIfChanged = React11.useCallback(
|
|
24723
26800
|
(next, defer) => {
|
|
24724
26801
|
if (sameValidity(lastReportedRef.current, next)) return;
|
|
24725
26802
|
lastReportedRef.current = next;
|
|
@@ -24765,11 +26842,11 @@ var FormFieldControl = createComponent(
|
|
|
24765
26842
|
};
|
|
24766
26843
|
}
|
|
24767
26844
|
}
|
|
24768
|
-
const nodeRef =
|
|
26845
|
+
const nodeRef = React11.useCallback((n) => {
|
|
24769
26846
|
controlRef.current = n;
|
|
24770
26847
|
setNode((prev) => prev === n ? prev : n);
|
|
24771
26848
|
}, []);
|
|
24772
|
-
|
|
26849
|
+
React11.useEffect(() => {
|
|
24773
26850
|
if (!node2) return;
|
|
24774
26851
|
if (readNativeValidity(node2) === void 0) return;
|
|
24775
26852
|
const handle = /* @__PURE__ */ __name(() => {
|
|
@@ -24787,11 +26864,11 @@ var FormFieldControl = createComponent(
|
|
|
24787
26864
|
};
|
|
24788
26865
|
}, [node2, ctx.validateOn, reportIfChanged]);
|
|
24789
26866
|
const childRef = child.ref;
|
|
24790
|
-
const composedRef =
|
|
26867
|
+
const composedRef = React11.useMemo(
|
|
24791
26868
|
() => composeRefs(childRef, forwardedRef, nodeRef),
|
|
24792
26869
|
[childRef, forwardedRef, nodeRef]
|
|
24793
26870
|
);
|
|
24794
|
-
return
|
|
26871
|
+
return React11.cloneElement(child, {
|
|
24795
26872
|
...formValueProps,
|
|
24796
26873
|
...injectedProps,
|
|
24797
26874
|
ref: composedRef
|
|
@@ -24808,7 +26885,7 @@ function FormFieldImpl({
|
|
|
24808
26885
|
children,
|
|
24809
26886
|
...rootProps
|
|
24810
26887
|
}, ref) {
|
|
24811
|
-
const childArray =
|
|
26888
|
+
const childArray = React11.Children.toArray(children);
|
|
24812
26889
|
const form = useFormContext();
|
|
24813
26890
|
const { name, valuePropConvention = "value" } = rootProps;
|
|
24814
26891
|
const labelChildPresent = warnOnFlatCompoundConflict({
|
|
@@ -24838,7 +26915,7 @@ function FormFieldImpl({
|
|
|
24838
26915
|
const labelNode = !labelChildPresent && label ? /* @__PURE__ */ jsx(FormFieldLabel, { children: label }) : null;
|
|
24839
26916
|
const descriptionNode = !descriptionChildPresent && description ? /* @__PURE__ */ jsx(FormFieldDescription, { children: description }) : null;
|
|
24840
26917
|
const messageNode = !messageChildPresent && message ? /* @__PURE__ */ jsx(FormFieldMessage, { children: message }) : null;
|
|
24841
|
-
const boundControlProps =
|
|
26918
|
+
const boundControlProps = React11.useMemo(() => {
|
|
24842
26919
|
if (!form || !name) return controlProps;
|
|
24843
26920
|
const value = form.getValue(name);
|
|
24844
26921
|
const onChangeHandler = /* @__PURE__ */ __name((next) => form.setValue(name, next), "onChangeHandler");
|
|
@@ -24866,7 +26943,7 @@ function FormFieldImpl({
|
|
|
24866
26943
|
return /* @__PURE__ */ jsxs(FormFieldRoot, { ...rootProps, message, children: [
|
|
24867
26944
|
labelNode,
|
|
24868
26945
|
descriptionNode,
|
|
24869
|
-
/* @__PURE__ */ jsx(FormFieldControl, { ref, children: As ?
|
|
26946
|
+
/* @__PURE__ */ jsx(FormFieldControl, { ref, children: As ? React11.createElement(
|
|
24870
26947
|
As,
|
|
24871
26948
|
boundControlProps
|
|
24872
26949
|
) : /* @__PURE__ */ jsx(Fragment, {}) }),
|
|
@@ -24874,7 +26951,7 @@ function FormFieldImpl({
|
|
|
24874
26951
|
] });
|
|
24875
26952
|
}
|
|
24876
26953
|
__name(FormFieldImpl, "FormFieldImpl");
|
|
24877
|
-
var FormFieldForwardRef =
|
|
26954
|
+
var FormFieldForwardRef = React11.forwardRef(FormFieldImpl);
|
|
24878
26955
|
var FormField = Object.assign(FormFieldForwardRef, {
|
|
24879
26956
|
Root: FormFieldRoot,
|
|
24880
26957
|
Label: FormFieldLabel,
|
|
@@ -25020,7 +27097,7 @@ function shortcutHint(item) {
|
|
|
25020
27097
|
return `${item.label} (${modLabel}+${item.shortcutKey.toUpperCase()})`;
|
|
25021
27098
|
}
|
|
25022
27099
|
__name(shortcutHint, "shortcutHint");
|
|
25023
|
-
var MarkdownEditor = createComponent({
|
|
27100
|
+
var MarkdownEditor = createComponent$1({
|
|
25024
27101
|
displayName: "MarkdownEditor",
|
|
25025
27102
|
__kui: {
|
|
25026
27103
|
role: "formControl",
|
|
@@ -25084,11 +27161,11 @@ var MarkdownEditor = createComponent({
|
|
|
25084
27161
|
onTabChange?.(next);
|
|
25085
27162
|
}
|
|
25086
27163
|
__name(setTab, "setTab");
|
|
25087
|
-
function
|
|
27164
|
+
function commit2(next) {
|
|
25088
27165
|
setDraft(next);
|
|
25089
27166
|
onValueChange?.(next);
|
|
25090
27167
|
}
|
|
25091
|
-
__name(
|
|
27168
|
+
__name(commit2, "commit");
|
|
25092
27169
|
function runAction(action) {
|
|
25093
27170
|
if (isDisabled) return;
|
|
25094
27171
|
const el = textareaRef.current;
|
|
@@ -25099,7 +27176,7 @@ var MarkdownEditor = createComponent({
|
|
|
25099
27176
|
selectionStart ?? value.length,
|
|
25100
27177
|
selectionEnd ?? value.length
|
|
25101
27178
|
);
|
|
25102
|
-
|
|
27179
|
+
commit2(edit.value);
|
|
25103
27180
|
el.focus();
|
|
25104
27181
|
const place = /* @__PURE__ */ __name(() => {
|
|
25105
27182
|
el.setSelectionRange(edit.selectionStart, edit.selectionEnd);
|
|
@@ -25195,7 +27272,7 @@ var MarkdownEditor = createComponent({
|
|
|
25195
27272
|
{
|
|
25196
27273
|
ref: composeRefs(textareaRef, ref),
|
|
25197
27274
|
value,
|
|
25198
|
-
onValueChange:
|
|
27275
|
+
onValueChange: commit2,
|
|
25199
27276
|
embedded: true,
|
|
25200
27277
|
resize: "vertical",
|
|
25201
27278
|
disabled: isDisabled,
|
|
@@ -25237,7 +27314,7 @@ function RadioGroup({
|
|
|
25237
27314
|
disabled = false,
|
|
25238
27315
|
required: required2 = false,
|
|
25239
27316
|
orientation = "vertical",
|
|
25240
|
-
size = "md",
|
|
27317
|
+
size: size2 = "md",
|
|
25241
27318
|
error: error62,
|
|
25242
27319
|
success: success2,
|
|
25243
27320
|
className,
|
|
@@ -25267,7 +27344,7 @@ function RadioGroup({
|
|
|
25267
27344
|
value,
|
|
25268
27345
|
onValueChange: handleValueChange,
|
|
25269
27346
|
disabled,
|
|
25270
|
-
size,
|
|
27347
|
+
size: size2,
|
|
25271
27348
|
state,
|
|
25272
27349
|
groupRequired
|
|
25273
27350
|
},
|
|
@@ -25397,7 +27474,7 @@ __name(orderedFilteredValues, "orderedFilteredValues");
|
|
|
25397
27474
|
var ComboboxInput = forwardRef(
|
|
25398
27475
|
({
|
|
25399
27476
|
variant = "outline",
|
|
25400
|
-
size = "md",
|
|
27477
|
+
size: size2 = "md",
|
|
25401
27478
|
placeholder,
|
|
25402
27479
|
clearable = false,
|
|
25403
27480
|
allowFreeText = false,
|
|
@@ -25480,7 +27557,7 @@ var ComboboxInput = forwardRef(
|
|
|
25480
27557
|
"aria-controls": ctx.contentId,
|
|
25481
27558
|
"aria-activedescendant": ctx.open && ctx.activeValue ? ctx.optionId(ctx.activeValue) : void 0,
|
|
25482
27559
|
variant,
|
|
25483
|
-
size,
|
|
27560
|
+
size: size2,
|
|
25484
27561
|
className,
|
|
25485
27562
|
"aria-invalid": ctx.isInvalid || void 0,
|
|
25486
27563
|
"aria-describedby": ctx.describedBy,
|
|
@@ -26091,7 +28168,7 @@ function MultiSelect({
|
|
|
26091
28168
|
required: required2,
|
|
26092
28169
|
name,
|
|
26093
28170
|
variant = "outline",
|
|
26094
|
-
size = "md",
|
|
28171
|
+
size: size2 = "md",
|
|
26095
28172
|
placeholder,
|
|
26096
28173
|
maxVisibleChips,
|
|
26097
28174
|
className,
|
|
@@ -26119,7 +28196,7 @@ function MultiSelect({
|
|
|
26119
28196
|
forceUpdate();
|
|
26120
28197
|
};
|
|
26121
28198
|
}, []);
|
|
26122
|
-
const
|
|
28199
|
+
const commit2 = useCallback(
|
|
26123
28200
|
(next) => {
|
|
26124
28201
|
if (valueProp === void 0) setInternalValue(next);
|
|
26125
28202
|
onValueChange?.(next);
|
|
@@ -26127,16 +28204,16 @@ function MultiSelect({
|
|
|
26127
28204
|
[valueProp, onValueChange]
|
|
26128
28205
|
);
|
|
26129
28206
|
const toggleValue = useCallback(
|
|
26130
|
-
(v) =>
|
|
26131
|
-
[value,
|
|
28207
|
+
(v) => commit2(value.includes(v) ? value.filter((x) => x !== v) : [...value, v]),
|
|
28208
|
+
[value, commit2]
|
|
26132
28209
|
);
|
|
26133
28210
|
const removeValue = useCallback(
|
|
26134
|
-
(v) =>
|
|
26135
|
-
[value,
|
|
28211
|
+
(v) => commit2(value.filter((x) => x !== v)),
|
|
28212
|
+
[value, commit2]
|
|
26136
28213
|
);
|
|
26137
28214
|
const handleClear = useCallback(() => {
|
|
26138
|
-
|
|
26139
|
-
}, [
|
|
28215
|
+
commit2([]);
|
|
28216
|
+
}, [commit2]);
|
|
26140
28217
|
const triggerRef = useRef(null);
|
|
26141
28218
|
const rootRef = useRef(null);
|
|
26142
28219
|
useEffect(() => {
|
|
@@ -26160,7 +28237,7 @@ function MultiSelect({
|
|
|
26160
28237
|
removeValue,
|
|
26161
28238
|
disabled,
|
|
26162
28239
|
variant,
|
|
26163
|
-
size,
|
|
28240
|
+
size: size2,
|
|
26164
28241
|
open: open2,
|
|
26165
28242
|
setOpen,
|
|
26166
28243
|
triggerId,
|
|
@@ -26187,7 +28264,7 @@ function MultiSelect({
|
|
|
26187
28264
|
removeValue,
|
|
26188
28265
|
disabled,
|
|
26189
28266
|
variant,
|
|
26190
|
-
|
|
28267
|
+
size2,
|
|
26191
28268
|
open2,
|
|
26192
28269
|
triggerId,
|
|
26193
28270
|
contentId,
|
|
@@ -26267,7 +28344,7 @@ var Container = forwardRef(
|
|
|
26267
28344
|
}
|
|
26268
28345
|
);
|
|
26269
28346
|
Container.displayName = "Container";
|
|
26270
|
-
var Flex = createComponent({
|
|
28347
|
+
var Flex = createComponent$1({
|
|
26271
28348
|
displayName: "Flex",
|
|
26272
28349
|
__kui: {
|
|
26273
28350
|
role: "layout",
|
|
@@ -26353,7 +28430,7 @@ function spanValue(value) {
|
|
|
26353
28430
|
return value === "full" ? "1 / -1" : `span ${value}`;
|
|
26354
28431
|
}
|
|
26355
28432
|
__name(spanValue, "spanValue");
|
|
26356
|
-
var GridItem = createComponent({
|
|
28433
|
+
var GridItem = createComponent$1({
|
|
26357
28434
|
displayName: "Grid.Item",
|
|
26358
28435
|
__kui: {
|
|
26359
28436
|
role: "layout",
|
|
@@ -26404,7 +28481,7 @@ function resolveTrackSize(value) {
|
|
|
26404
28481
|
return resolveSpace(value);
|
|
26405
28482
|
}
|
|
26406
28483
|
__name(resolveTrackSize, "resolveTrackSize");
|
|
26407
|
-
var GridRoot = createComponent({
|
|
28484
|
+
var GridRoot = createComponent$1({
|
|
26408
28485
|
displayName: "Grid",
|
|
26409
28486
|
__kui: {
|
|
26410
28487
|
role: "layout",
|
|
@@ -26506,7 +28583,7 @@ function resolveOverlayBackground(color, opacity, gradient) {
|
|
|
26506
28583
|
return `linear-gradient(${directionMap[gradient]}, ${startColor} 0%, transparent 100%)`;
|
|
26507
28584
|
}
|
|
26508
28585
|
__name(resolveOverlayBackground, "resolveOverlayBackground");
|
|
26509
|
-
var CardOverlay = createComponent({
|
|
28586
|
+
var CardOverlay = createComponent$1({
|
|
26510
28587
|
__kui: {
|
|
26511
28588
|
groupSlot: "Card"
|
|
26512
28589
|
},
|
|
@@ -26533,7 +28610,7 @@ var CardOverlay = createComponent({
|
|
|
26533
28610
|
);
|
|
26534
28611
|
}, "render")
|
|
26535
28612
|
});
|
|
26536
|
-
var CardMedia = createComponent({
|
|
28613
|
+
var CardMedia = createComponent$1({
|
|
26537
28614
|
__kui: {
|
|
26538
28615
|
groupSlot: "Card"
|
|
26539
28616
|
},
|
|
@@ -26575,7 +28652,7 @@ var CardMedia = createComponent({
|
|
|
26575
28652
|
);
|
|
26576
28653
|
}, "render")
|
|
26577
28654
|
});
|
|
26578
|
-
var CardRoot = createComponent({
|
|
28655
|
+
var CardRoot = createComponent$1({
|
|
26579
28656
|
__kui: {
|
|
26580
28657
|
role: "display",
|
|
26581
28658
|
skeleton: "preserve"
|
|
@@ -26583,7 +28660,7 @@ var CardRoot = createComponent({
|
|
|
26583
28660
|
displayName: "Card",
|
|
26584
28661
|
render: /* @__PURE__ */ __name(({
|
|
26585
28662
|
variant = "outline",
|
|
26586
|
-
size = "md",
|
|
28663
|
+
size: size2 = "md",
|
|
26587
28664
|
fullWidth = false,
|
|
26588
28665
|
className,
|
|
26589
28666
|
style,
|
|
@@ -26597,7 +28674,7 @@ var CardRoot = createComponent({
|
|
|
26597
28674
|
{
|
|
26598
28675
|
ref,
|
|
26599
28676
|
className: cn(
|
|
26600
|
-
resolveRecipe(theme.recipes.Card, { variant, size, fullWidth }),
|
|
28677
|
+
resolveRecipe(theme.recipes.Card, { variant, size: size2, fullWidth }),
|
|
26601
28678
|
className
|
|
26602
28679
|
),
|
|
26603
28680
|
...props,
|
|
@@ -26606,19 +28683,19 @@ var CardRoot = createComponent({
|
|
|
26606
28683
|
);
|
|
26607
28684
|
}, "render")
|
|
26608
28685
|
});
|
|
26609
|
-
var CardHeader = createComponent({
|
|
28686
|
+
var CardHeader = createComponent$1({
|
|
26610
28687
|
__kui: {
|
|
26611
28688
|
groupSlot: "Card"
|
|
26612
28689
|
},
|
|
26613
28690
|
displayName: "Card.Header",
|
|
26614
|
-
render: /* @__PURE__ */ __name(({ className, children, noPadding = false, size = "md", ...props }, ref) => {
|
|
28691
|
+
render: /* @__PURE__ */ __name(({ className, children, noPadding = false, size: size2 = "md", ...props }, ref) => {
|
|
26615
28692
|
const { theme } = useTheme();
|
|
26616
28693
|
return /* @__PURE__ */ jsx(
|
|
26617
28694
|
"div",
|
|
26618
28695
|
{
|
|
26619
28696
|
ref,
|
|
26620
28697
|
className: cn(
|
|
26621
|
-
resolveRecipe(theme.recipes.CardHeader, { size, noPadding }),
|
|
28698
|
+
resolveRecipe(theme.recipes.CardHeader, { size: size2, noPadding }),
|
|
26622
28699
|
className
|
|
26623
28700
|
),
|
|
26624
28701
|
...props,
|
|
@@ -26627,19 +28704,19 @@ var CardHeader = createComponent({
|
|
|
26627
28704
|
);
|
|
26628
28705
|
}, "render")
|
|
26629
28706
|
});
|
|
26630
|
-
var CardBody = createComponent({
|
|
28707
|
+
var CardBody = createComponent$1({
|
|
26631
28708
|
__kui: {
|
|
26632
28709
|
groupSlot: "Card"
|
|
26633
28710
|
},
|
|
26634
28711
|
displayName: "Card.Body",
|
|
26635
|
-
render: /* @__PURE__ */ __name(({ size = "md", noPadding = false, className, children, ...props }, ref) => {
|
|
28712
|
+
render: /* @__PURE__ */ __name(({ size: size2 = "md", noPadding = false, className, children, ...props }, ref) => {
|
|
26636
28713
|
const { theme } = useTheme();
|
|
26637
28714
|
return /* @__PURE__ */ jsx(
|
|
26638
28715
|
"div",
|
|
26639
28716
|
{
|
|
26640
28717
|
ref,
|
|
26641
28718
|
className: cn(
|
|
26642
|
-
resolveRecipe(theme.recipes.CardBody, { size, noPadding }),
|
|
28719
|
+
resolveRecipe(theme.recipes.CardBody, { size: size2, noPadding }),
|
|
26643
28720
|
className
|
|
26644
28721
|
),
|
|
26645
28722
|
...props,
|
|
@@ -26648,19 +28725,19 @@ var CardBody = createComponent({
|
|
|
26648
28725
|
);
|
|
26649
28726
|
}, "render")
|
|
26650
28727
|
});
|
|
26651
|
-
var CardFooter = createComponent({
|
|
28728
|
+
var CardFooter = createComponent$1({
|
|
26652
28729
|
__kui: {
|
|
26653
28730
|
groupSlot: "Card"
|
|
26654
28731
|
},
|
|
26655
28732
|
displayName: "Card.Footer",
|
|
26656
|
-
render: /* @__PURE__ */ __name(({ size = "md", noPadding = false, className, children, ...props }, ref) => {
|
|
28733
|
+
render: /* @__PURE__ */ __name(({ size: size2 = "md", noPadding = false, className, children, ...props }, ref) => {
|
|
26657
28734
|
const { theme } = useTheme();
|
|
26658
28735
|
return /* @__PURE__ */ jsx(
|
|
26659
28736
|
"div",
|
|
26660
28737
|
{
|
|
26661
28738
|
ref,
|
|
26662
28739
|
className: cn(
|
|
26663
|
-
resolveRecipe(theme.recipes.CardFooter, { size, noPadding }),
|
|
28740
|
+
resolveRecipe(theme.recipes.CardFooter, { size: size2, noPadding }),
|
|
26664
28741
|
className
|
|
26665
28742
|
),
|
|
26666
28743
|
...props,
|
|
@@ -26862,35 +28939,35 @@ function sceneProgress(scene, container, axis, range) {
|
|
|
26862
28939
|
const s = scene.getBoundingClientRect();
|
|
26863
28940
|
const vertical = axis === "y";
|
|
26864
28941
|
const view = vertical ? container.clientHeight : container.clientWidth;
|
|
26865
|
-
const
|
|
26866
|
-
const
|
|
28942
|
+
const size2 = vertical ? s.height : s.width;
|
|
28943
|
+
const offset3 = vertical ? s.top - c.top - container.clientTop : s.left - c.left - container.clientLeft;
|
|
26867
28944
|
if (range === "through") {
|
|
26868
|
-
const total = view +
|
|
26869
|
-
return total > 0 ? clamp01((view -
|
|
28945
|
+
const total = view + size2;
|
|
28946
|
+
return total > 0 ? clamp01((view - offset3) / total) : 0;
|
|
26870
28947
|
}
|
|
26871
|
-
const travel =
|
|
26872
|
-
return travel > 0 ? clamp01(-
|
|
28948
|
+
const travel = size2 - view;
|
|
28949
|
+
return travel > 0 ? clamp01(-offset3 / travel) : 0;
|
|
26873
28950
|
}
|
|
26874
28951
|
__name(sceneProgress, "sceneProgress");
|
|
26875
28952
|
function createStore(initial, equals = Object.is) {
|
|
26876
28953
|
let value = initial;
|
|
26877
|
-
const
|
|
28954
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
26878
28955
|
return {
|
|
26879
28956
|
get: /* @__PURE__ */ __name(() => value, "get"),
|
|
26880
28957
|
set(next) {
|
|
26881
28958
|
if (equals(value, next)) return false;
|
|
26882
28959
|
value = next;
|
|
26883
|
-
|
|
28960
|
+
listeners2.forEach((l) => l(next));
|
|
26884
28961
|
return true;
|
|
26885
28962
|
},
|
|
26886
28963
|
subscribe(fn) {
|
|
26887
|
-
|
|
28964
|
+
listeners2.add(fn);
|
|
26888
28965
|
return () => {
|
|
26889
|
-
|
|
28966
|
+
listeners2.delete(fn);
|
|
26890
28967
|
};
|
|
26891
28968
|
},
|
|
26892
28969
|
get size() {
|
|
26893
|
-
return
|
|
28970
|
+
return listeners2.size;
|
|
26894
28971
|
}
|
|
26895
28972
|
};
|
|
26896
28973
|
}
|
|
@@ -27118,15 +29195,15 @@ __name(useElementScrollProgress, "useElementScrollProgress");
|
|
|
27118
29195
|
|
|
27119
29196
|
// src/components/layout/ScrollArea/scrollTargets.ts
|
|
27120
29197
|
var axesFor = /* @__PURE__ */ __name((d) => d === "both" ? ["x", "y"] : d === "horizontal" ? ["x"] : ["y"], "axesFor");
|
|
27121
|
-
var
|
|
27122
|
-
var resolveBehavior = /* @__PURE__ */ __name((b) => b ?? (
|
|
29198
|
+
var prefersReducedMotion2 = /* @__PURE__ */ __name(() => typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, "prefersReducedMotion");
|
|
29199
|
+
var resolveBehavior = /* @__PURE__ */ __name((b) => b ?? (prefersReducedMotion2() ? "auto" : "smooth"), "resolveBehavior");
|
|
27123
29200
|
function childTarget(container, child, axis, align) {
|
|
27124
29201
|
const h = axis === "x";
|
|
27125
29202
|
const c = container.getBoundingClientRect();
|
|
27126
29203
|
const r = child.getBoundingClientRect();
|
|
27127
29204
|
const cs = getComputedStyle(container);
|
|
27128
29205
|
const view = h ? container.clientWidth : container.clientHeight;
|
|
27129
|
-
const
|
|
29206
|
+
const size2 = h ? r.width : r.height;
|
|
27130
29207
|
const rel = h ? r.left - c.left - container.clientLeft : r.top - c.top - container.clientTop;
|
|
27131
29208
|
const current = h ? container.scrollLeft : container.scrollTop;
|
|
27132
29209
|
const max = h ? container.scrollWidth - view : container.scrollHeight - view;
|
|
@@ -27134,8 +29211,8 @@ function childTarget(container, child, axis, align) {
|
|
|
27134
29211
|
const padEnd = parseFloat(h ? cs.scrollPaddingRight : cs.scrollPaddingBottom) || 0;
|
|
27135
29212
|
let offsetInView;
|
|
27136
29213
|
if (align === "start") offsetInView = padStart;
|
|
27137
|
-
else if (align === "end") offsetInView = view - padEnd -
|
|
27138
|
-
else offsetInView = padStart + (view - padStart - padEnd -
|
|
29214
|
+
else if (align === "end") offsetInView = view - padEnd - size2;
|
|
29215
|
+
else offsetInView = padStart + (view - padStart - padEnd - size2) / 2;
|
|
27139
29216
|
return Math.min(Math.max(current + rel - offsetInView, 0), Math.max(max, 0));
|
|
27140
29217
|
}
|
|
27141
29218
|
__name(childTarget, "childTarget");
|
|
@@ -27163,7 +29240,7 @@ function snapToNearest(el, direction, align) {
|
|
|
27163
29240
|
el.scrollTo(opts);
|
|
27164
29241
|
}
|
|
27165
29242
|
__name(snapToNearest, "snapToNearest");
|
|
27166
|
-
var ScrollAreaScene = createComponent({
|
|
29243
|
+
var ScrollAreaScene = createComponent$1({
|
|
27167
29244
|
displayName: "ScrollArea.Scene",
|
|
27168
29245
|
__kui: {
|
|
27169
29246
|
role: "layout",
|
|
@@ -27196,7 +29273,7 @@ function warnIfClipped(el, container) {
|
|
|
27196
29273
|
}
|
|
27197
29274
|
}
|
|
27198
29275
|
__name(warnIfClipped, "warnIfClipped");
|
|
27199
|
-
var ScrollAreaSticky = createComponent({
|
|
29276
|
+
var ScrollAreaSticky = createComponent$1({
|
|
27200
29277
|
displayName: "ScrollArea.Sticky",
|
|
27201
29278
|
__kui: {
|
|
27202
29279
|
role: "layout",
|
|
@@ -27275,7 +29352,7 @@ function shouldFade(fadeEdges, edge) {
|
|
|
27275
29352
|
return !!fadeEdges[edge];
|
|
27276
29353
|
}
|
|
27277
29354
|
__name(shouldFade, "shouldFade");
|
|
27278
|
-
var ScrollAreaRoot = createComponent({
|
|
29355
|
+
var ScrollAreaRoot = createComponent$1({
|
|
27279
29356
|
displayName: "ScrollArea",
|
|
27280
29357
|
__kui: {
|
|
27281
29358
|
role: "layout",
|
|
@@ -27511,7 +29588,7 @@ function resolveSize(value) {
|
|
|
27511
29588
|
return resolveSpace(value);
|
|
27512
29589
|
}
|
|
27513
29590
|
__name(resolveSize, "resolveSize");
|
|
27514
|
-
var Box = createComponent({
|
|
29591
|
+
var Box = createComponent$1({
|
|
27515
29592
|
displayName: "Box",
|
|
27516
29593
|
__kui: {
|
|
27517
29594
|
role: "layout",
|
|
@@ -27579,48 +29656,6 @@ var Box = createComponent({
|
|
|
27579
29656
|
] });
|
|
27580
29657
|
}, "render")
|
|
27581
29658
|
});
|
|
27582
|
-
var InputField = forwardRef(
|
|
27583
|
-
({
|
|
27584
|
-
id,
|
|
27585
|
-
label,
|
|
27586
|
-
description,
|
|
27587
|
-
message,
|
|
27588
|
-
required: required2,
|
|
27589
|
-
optional: optional2,
|
|
27590
|
-
labelStart,
|
|
27591
|
-
labelEnd,
|
|
27592
|
-
labelClassName,
|
|
27593
|
-
status = "none",
|
|
27594
|
-
...inputProps
|
|
27595
|
-
}, ref) => {
|
|
27596
|
-
const error62 = status === "error";
|
|
27597
|
-
const success2 = status === "success";
|
|
27598
|
-
const warning = status === "warning";
|
|
27599
|
-
return /* @__PURE__ */ jsxs(FormField, { id, message, required: required2, children: [
|
|
27600
|
-
label && /* @__PURE__ */ jsxs(FormField.Label, { className: labelClassName, children: [
|
|
27601
|
-
labelStart,
|
|
27602
|
-
label,
|
|
27603
|
-
optional2 && /* @__PURE__ */ jsx("span", { className: "text-kui-text-muted", children: " (optional)" }),
|
|
27604
|
-
labelEnd
|
|
27605
|
-
] }),
|
|
27606
|
-
/* @__PURE__ */ jsx(FormField.Control, { children: /* @__PURE__ */ jsx(
|
|
27607
|
-
Input,
|
|
27608
|
-
{
|
|
27609
|
-
...inputProps,
|
|
27610
|
-
ref,
|
|
27611
|
-
id,
|
|
27612
|
-
error: error62,
|
|
27613
|
-
success: success2,
|
|
27614
|
-
warning,
|
|
27615
|
-
required: required2
|
|
27616
|
-
}
|
|
27617
|
-
) }),
|
|
27618
|
-
description && /* @__PURE__ */ jsx(FormField.Description, { children: description }),
|
|
27619
|
-
/* @__PURE__ */ jsx(FormField.Message, { children: message })
|
|
27620
|
-
] });
|
|
27621
|
-
}
|
|
27622
|
-
);
|
|
27623
|
-
InputField.displayName = "InputField";
|
|
27624
29659
|
var Text = forwardRef(
|
|
27625
29660
|
({
|
|
27626
29661
|
as: Tag = "p",
|
|
@@ -27706,6 +29741,6 @@ var Heading = forwardRef(
|
|
|
27706
29741
|
);
|
|
27707
29742
|
Heading.displayName = "Heading";
|
|
27708
29743
|
|
|
27709
|
-
export {
|
|
27710
|
-
//# sourceMappingURL=chunk-
|
|
27711
|
-
//# sourceMappingURL=chunk-
|
|
29744
|
+
export { ActionGuard, Box, Button, ButtonGroup, ButtonGroupContext, ButtonGroupItemContext, Card, CardOverlay, Checkbox, Combobox, ComboboxContent, ComboboxInput, ComboboxItem, ConfirmConflictError, ConfirmDialog, ConfirmHost, ConfirmRequestManager, Container, DialogProvider, DialogStack, Flex, Form, FormField, FormFieldControl, FormFieldDescription, FormFieldLabel, FormFieldMessage, FormResetButton, FormSubmitButton, Grid, Heading, Input, MarkdownEditor, Menu, MultiSelect, MultiSelectContent, MultiSelectItem, MultiSelectTrigger, NumberStepper, OverlayPortal, OverlayRootContext, Radio, RadioGroup, Repeater, ScrollArea, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectRoot, SelectTrigger, SelectValue, Stack, Switch, Textarea, ThemeToggler, Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastIcon, ToastProvider, ToastRoot, ToastTitle, ToastViewport, Tooltip, TooltipProvider, confirmAction, createConfirmAction, createConfirmRequestManager, defaultConfirmManager, defineUIField, isDev, toast, useButtonGroupContext, useButtonGroupItemContext, useConfirmAction, useDialogStack, useDialogState, useElementScrollProgress, useFormContext, useOptionalButtonGroupContext, useOptionalButtonGroupItemContext, useOverlayRoot, useScrollProgress, useToasts };
|
|
29745
|
+
//# sourceMappingURL=chunk-K47M7SWS.js.map
|
|
29746
|
+
//# sourceMappingURL=chunk-K47M7SWS.js.map
|