@yuhuanowo/yunui 0.2.17 → 0.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/README.zh-CN.md +5 -1
- package/README.zh-TW.md +5 -1
- package/dist/ai.d.ts +99 -3
- package/dist/ai.js +212 -104
- package/dist/ai.js.map +1 -1
- package/dist/chat.d.ts +10 -3
- package/dist/chat.js +12 -7
- package/dist/chat.js.map +1 -1
- package/dist/{chunk-HH3JBHRP.js → chunk-AFVENY4D.js} +286 -31
- package/dist/chunk-AFVENY4D.js.map +1 -0
- package/dist/{chunk-F2HG4TOQ.js → chunk-GAXVET76.js} +13 -19
- package/dist/chunk-GAXVET76.js.map +1 -0
- package/dist/{chunk-DDUP7GAX.js → chunk-LEBQPP4B.js} +69 -3
- package/dist/chunk-LEBQPP4B.js.map +1 -0
- package/dist/chunk-ST6TSBVQ.js +208 -0
- package/dist/chunk-ST6TSBVQ.js.map +1 -0
- package/dist/chunk-V7VJKZ5Q.js +254 -0
- package/dist/chunk-V7VJKZ5Q.js.map +1 -0
- package/dist/{chunk-BCOKFWXC.js → chunk-YKWRCA2S.js} +80 -156
- package/dist/chunk-YKWRCA2S.js.map +1 -0
- package/dist/content.d.ts +10 -2
- package/dist/content.js +50 -40
- package/dist/content.js.map +1 -1
- package/dist/index.d.ts +266 -16
- package/dist/index.js +4 -4
- package/dist/patterns.d.ts +471 -22
- package/dist/patterns.js +783 -131
- package/dist/patterns.js.map +1 -1
- package/icons/providers/gmi.svg +5 -0
- package/package.json +3 -4
- package/styles/content.css +3 -1
- package/styles/yunui.css +197 -84
- package/dist/chunk-BCOKFWXC.js.map +0 -1
- package/dist/chunk-DDUP7GAX.js.map +0 -1
- package/dist/chunk-F2HG4TOQ.js.map +0 -1
- package/dist/chunk-HH3JBHRP.js.map +0 -1
- package/dist/chunk-N4QO7RN5.js +0 -98
- package/dist/chunk-N4QO7RN5.js.map +0 -1
- package/dist/chunk-QEIBYOG2.js +0 -188
- package/dist/chunk-QEIBYOG2.js.map +0 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { Spinner } from './chunk-YKWRCA2S.js';
|
|
3
|
+
import { cn, useAnchoredPosition, useDismissOnOutside } from './chunk-V7VJKZ5Q.js';
|
|
3
4
|
import { useYunUI } from './chunk-3RT24MSH.js';
|
|
4
5
|
import * as React3 from 'react';
|
|
5
|
-
import { forwardRef, useState, useEffect, useRef, useId, useMemo } from 'react';
|
|
6
|
+
import { forwardRef, useState, useEffect, useRef, useId, useMemo, useCallback } from 'react';
|
|
6
7
|
import { ChevronDown, Search, Loader2, X, ArrowRight, AlertTriangle, Info, AlertCircle, CheckCircle2 } from 'lucide-react';
|
|
7
8
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
9
|
import * as Primitive from '@radix-ui/react-collapsible';
|
|
@@ -10,6 +11,7 @@ import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
|
10
11
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
11
12
|
import { useSpring, useTransform, motion } from 'framer-motion';
|
|
12
13
|
import { Toaster as Toaster$1, toast as toast$1 } from 'sonner';
|
|
14
|
+
import { createPortal } from 'react-dom';
|
|
13
15
|
|
|
14
16
|
function CustomSelect({
|
|
15
17
|
options,
|
|
@@ -57,16 +59,15 @@ function CustomSelect({
|
|
|
57
59
|
const id = setTimeout(() => onSearchRef.current?.(searchQuery), searchDebounceMs);
|
|
58
60
|
return () => clearTimeout(id);
|
|
59
61
|
}, [searchQuery, remote, searchDebounceMs]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}, []);
|
|
62
|
+
useDismissOnOutside(
|
|
63
|
+
isOpen,
|
|
64
|
+
() => {
|
|
65
|
+
setIsOpen(false);
|
|
66
|
+
setSearchQuery("");
|
|
67
|
+
},
|
|
68
|
+
containerRef,
|
|
69
|
+
{ escape: false }
|
|
70
|
+
);
|
|
70
71
|
useEffect(() => {
|
|
71
72
|
if (!isOpen) return;
|
|
72
73
|
if (showSearch && inputRef.current) inputRef.current.focus();
|
|
@@ -220,7 +221,7 @@ function CustomSelect({
|
|
|
220
221
|
onChange: (e) => setSearchQuery(e.target.value),
|
|
221
222
|
placeholder: t("search"),
|
|
222
223
|
"aria-label": t("search"),
|
|
223
|
-
className: "w-full pl-9 pr-8 py-1.5 text-sm rounded-lg\n bg-(--bg-muted) border border-transparent\n focus:border-primary focus:outline-none focus:bg-(--bg-elevated) transition-colors"
|
|
224
|
+
className: "w-full pl-9 pr-8 py-1.5 text-base md:text-sm rounded-lg\n bg-(--bg-muted) border border-transparent\n focus:border-primary focus:outline-none focus:bg-(--bg-elevated) transition-colors"
|
|
224
225
|
}
|
|
225
226
|
),
|
|
226
227
|
loading ? /* @__PURE__ */ jsx(
|
|
@@ -303,7 +304,7 @@ function SegmentedSelect({
|
|
|
303
304
|
"aria-pressed": value === opt.value,
|
|
304
305
|
title: opt.desc,
|
|
305
306
|
className: cn(
|
|
306
|
-
"inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-medium border rounded-lg whitespace-nowrap transition-all duration-150 ease cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
307
|
+
"inline-flex items-center justify-center gap-2 px-3 py-1.5 text-xs font-medium border border-border rounded-lg whitespace-nowrap transition-all duration-150 ease cursor-pointer outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background",
|
|
307
308
|
value === opt.value ? "text-foreground border-(--border-strong) bg-accent-subtle hover:bg-accent-muted hover:shadow-xs" : "text-muted-foreground border-(--border-default) bg-muted/50 hover:text-foreground hover:border-(--border-strong) hover:bg-muted",
|
|
308
309
|
disabled && "opacity-50 cursor-not-allowed pointer-events-none"
|
|
309
310
|
),
|
|
@@ -353,7 +354,7 @@ function ShinyButton({
|
|
|
353
354
|
children,
|
|
354
355
|
/* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4 transition-transform group-hover:translate-x-1" })
|
|
355
356
|
] }),
|
|
356
|
-
/* @__PURE__ */ jsx("div", { className: "absolute inset-0
|
|
357
|
+
/* @__PURE__ */ jsx("div", { className: "absolute inset-0 block animate-shimmer bg-linear-to-r from-transparent via-(--text-primary)/10 to-transparent bg-size-[200%_100%]" })
|
|
357
358
|
]
|
|
358
359
|
}
|
|
359
360
|
);
|
|
@@ -426,12 +427,27 @@ var BentoCard = ({
|
|
|
426
427
|
"div",
|
|
427
428
|
{
|
|
428
429
|
className: cn(
|
|
429
|
-
"row-span-1 glass-card p-6 flex flex-col justify-between space-y-4 group/bento overflow-hidden",
|
|
430
|
+
"row-span-1 glass-card relative p-6 flex flex-col justify-between space-y-4 group/bento overflow-hidden",
|
|
431
|
+
// The house hover, matching `.card-interactive`: a single-pixel
|
|
432
|
+
// lift and one step up the shadow ramp. Content stays put —
|
|
433
|
+
// sliding or scaling it (the stock bento-grid trick this card
|
|
434
|
+
// used to carry) reads as jitter and matches nothing else here.
|
|
435
|
+
// The richer glow treatment belongs to `FeatureCard`, which is a
|
|
436
|
+
// faithful extraction of Yunxin's marketing tile; keeping it out
|
|
437
|
+
// of here stops the two from competing.
|
|
438
|
+
"transition-all duration-150 hover:-translate-y-px hover:shadow-md",
|
|
430
439
|
className
|
|
431
440
|
),
|
|
432
441
|
children: [
|
|
442
|
+
/* @__PURE__ */ jsx(
|
|
443
|
+
"div",
|
|
444
|
+
{
|
|
445
|
+
"aria-hidden": true,
|
|
446
|
+
className: "pointer-events-none absolute inset-x-0 top-0 h-px bg-linear-to-r from-transparent via-foreground/15 to-transparent"
|
|
447
|
+
}
|
|
448
|
+
),
|
|
433
449
|
header,
|
|
434
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
450
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
435
451
|
/* @__PURE__ */ jsx("div", { className: "mb-2 text-[var(--text-primary)]", children: icon }),
|
|
436
452
|
/* @__PURE__ */ jsx("div", { className: "font-semibold text-[var(--text-primary)] text-lg mb-2 mt-2", children: title }),
|
|
437
453
|
/* @__PURE__ */ jsx("div", { className: "font-normal text-[var(--text-secondary)] text-sm leading-relaxed", children: description })
|
|
@@ -550,7 +566,7 @@ var variantClasses = {
|
|
|
550
566
|
}
|
|
551
567
|
};
|
|
552
568
|
var Switch = forwardRef(
|
|
553
|
-
({ checked, onCheckedChange, disabled = false, size = "sm", variant = "default", className = "", id, ...props }, ref) => {
|
|
569
|
+
({ checked, onCheckedChange, disabled = false, size = "sm", variant = "default", className = "", id, label, ...props }, ref) => {
|
|
554
570
|
const sizeClass = sizeClasses[size];
|
|
555
571
|
const variantClass = variantClasses[variant];
|
|
556
572
|
return /* @__PURE__ */ jsx(
|
|
@@ -561,6 +577,7 @@ var Switch = forwardRef(
|
|
|
561
577
|
type: "button",
|
|
562
578
|
role: "switch",
|
|
563
579
|
"aria-checked": checked,
|
|
580
|
+
...label ? { "aria-label": label } : {},
|
|
564
581
|
id,
|
|
565
582
|
onClick: () => !disabled && onCheckedChange(!checked),
|
|
566
583
|
disabled,
|
|
@@ -587,16 +604,39 @@ var Switch = forwardRef(
|
|
|
587
604
|
}
|
|
588
605
|
);
|
|
589
606
|
Switch.displayName = "Switch";
|
|
590
|
-
function
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
607
|
+
function format(value, decimals, suffix) {
|
|
608
|
+
const numStr = decimals > 0 ? value.toFixed(decimals) : Math.round(value).toString();
|
|
609
|
+
return Number(numStr).toString() + suffix;
|
|
610
|
+
}
|
|
611
|
+
function AnimatedNumber({
|
|
612
|
+
value,
|
|
613
|
+
suffix = "",
|
|
614
|
+
decimals = 0,
|
|
615
|
+
immediate
|
|
616
|
+
}) {
|
|
617
|
+
const [autoImmediate, setAutoImmediate] = useState(() => {
|
|
618
|
+
const env = globalThis.process;
|
|
619
|
+
return env?.env?.NODE_ENV === "test";
|
|
595
620
|
});
|
|
596
621
|
useEffect(() => {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
622
|
+
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
623
|
+
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
624
|
+
const sync = () => setAutoImmediate((was) => was || mq.matches);
|
|
625
|
+
sync();
|
|
626
|
+
mq.addEventListener("change", sync);
|
|
627
|
+
return () => mq.removeEventListener("change", sync);
|
|
628
|
+
}, []);
|
|
629
|
+
const skip = immediate ?? autoImmediate;
|
|
630
|
+
const animatedValue = useSpring(0, { stiffness: 50, damping: 15 });
|
|
631
|
+
const displayValue = useTransform(
|
|
632
|
+
animatedValue,
|
|
633
|
+
(latest) => format(latest, decimals, suffix)
|
|
634
|
+
);
|
|
635
|
+
useEffect(() => {
|
|
636
|
+
if (skip) animatedValue.jump(value);
|
|
637
|
+
else animatedValue.set(value);
|
|
638
|
+
}, [animatedValue, value, skip]);
|
|
639
|
+
return /* @__PURE__ */ jsx(motion.span, { children: skip ? format(value, decimals, suffix) : displayValue });
|
|
600
640
|
}
|
|
601
641
|
var TONE_VAR = {
|
|
602
642
|
accent: "var(--color-accent)",
|
|
@@ -616,6 +656,7 @@ function Sparkline({
|
|
|
616
656
|
area = false,
|
|
617
657
|
min,
|
|
618
658
|
max,
|
|
659
|
+
label,
|
|
619
660
|
className,
|
|
620
661
|
...props
|
|
621
662
|
}) {
|
|
@@ -645,7 +686,8 @@ function Sparkline({
|
|
|
645
686
|
height,
|
|
646
687
|
preserveAspectRatio: "none",
|
|
647
688
|
className: cn("overflow-visible", className),
|
|
648
|
-
role: "img",
|
|
689
|
+
role: label ? "img" : void 0,
|
|
690
|
+
"aria-label": label,
|
|
649
691
|
...props,
|
|
650
692
|
children: [
|
|
651
693
|
area && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -686,6 +728,7 @@ function Gauge({
|
|
|
686
728
|
tone = "accent",
|
|
687
729
|
color,
|
|
688
730
|
label,
|
|
731
|
+
ariaLabel,
|
|
689
732
|
counterClockwise = false,
|
|
690
733
|
className
|
|
691
734
|
}) {
|
|
@@ -700,6 +743,7 @@ function Gauge({
|
|
|
700
743
|
className: cn("relative inline-flex items-center justify-center", className),
|
|
701
744
|
style: { width: size, height: size },
|
|
702
745
|
role: "progressbar",
|
|
746
|
+
"aria-label": typeof label === "string" ? label : ariaLabel,
|
|
703
747
|
"aria-valuenow": Math.round(pct),
|
|
704
748
|
"aria-valuemin": 0,
|
|
705
749
|
"aria-valuemax": 100,
|
|
@@ -752,6 +796,7 @@ function SegmentedBar({
|
|
|
752
796
|
height = 8,
|
|
753
797
|
legend = false,
|
|
754
798
|
formatValue,
|
|
799
|
+
label,
|
|
755
800
|
className
|
|
756
801
|
}) {
|
|
757
802
|
const sum = segments.reduce((a, s) => a + Math.max(0, s.value), 0);
|
|
@@ -762,7 +807,8 @@ function SegmentedBar({
|
|
|
762
807
|
{
|
|
763
808
|
className: "flex w-full overflow-hidden rounded-full bg-muted",
|
|
764
809
|
style: { height },
|
|
765
|
-
role: "img",
|
|
810
|
+
role: label ? "img" : void 0,
|
|
811
|
+
"aria-label": label,
|
|
766
812
|
children: segments.map((s, i) => {
|
|
767
813
|
const w = Math.max(0, s.value) / axis * 100;
|
|
768
814
|
if (w <= 0) return null;
|
|
@@ -1205,7 +1251,216 @@ function useYunUITheme(defaults = {}) {
|
|
|
1205
1251
|
}, []);
|
|
1206
1252
|
return [theme, update];
|
|
1207
1253
|
}
|
|
1254
|
+
function CommandPalette({
|
|
1255
|
+
open,
|
|
1256
|
+
onClose,
|
|
1257
|
+
query,
|
|
1258
|
+
onQueryChange,
|
|
1259
|
+
items = [],
|
|
1260
|
+
loading = false,
|
|
1261
|
+
empty,
|
|
1262
|
+
initial,
|
|
1263
|
+
footer,
|
|
1264
|
+
labels,
|
|
1265
|
+
className
|
|
1266
|
+
}) {
|
|
1267
|
+
const { Link } = useYunUI();
|
|
1268
|
+
const [cursor, setCursor] = useState(0);
|
|
1269
|
+
const inputRef = useRef(null);
|
|
1270
|
+
const listRef = useRef(null);
|
|
1271
|
+
const [mounted, setMounted] = useState(false);
|
|
1272
|
+
const listId = useId();
|
|
1273
|
+
useEffect(() => setMounted(true), []);
|
|
1274
|
+
useEffect(() => setCursor(0), [items]);
|
|
1275
|
+
useEffect(() => {
|
|
1276
|
+
if (open) inputRef.current?.focus();
|
|
1277
|
+
}, [open]);
|
|
1278
|
+
useEffect(() => {
|
|
1279
|
+
if (!open) return;
|
|
1280
|
+
const previous = document.body.style.overflow;
|
|
1281
|
+
document.body.style.overflow = "hidden";
|
|
1282
|
+
return () => {
|
|
1283
|
+
document.body.style.overflow = previous;
|
|
1284
|
+
};
|
|
1285
|
+
}, [open]);
|
|
1286
|
+
const select = useCallback(
|
|
1287
|
+
(item) => {
|
|
1288
|
+
if (!item) return;
|
|
1289
|
+
item.onSelect?.();
|
|
1290
|
+
onClose();
|
|
1291
|
+
},
|
|
1292
|
+
[onClose]
|
|
1293
|
+
);
|
|
1294
|
+
const onKeyDown = (event) => {
|
|
1295
|
+
if (event.key === "Escape") {
|
|
1296
|
+
event.preventDefault();
|
|
1297
|
+
onClose();
|
|
1298
|
+
return;
|
|
1299
|
+
}
|
|
1300
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
1301
|
+
event.preventDefault();
|
|
1302
|
+
if (items.length === 0) return;
|
|
1303
|
+
setCursor((c) => {
|
|
1304
|
+
const next = event.key === "ArrowDown" ? c + 1 : c - 1;
|
|
1305
|
+
const wrapped = (next + items.length) % items.length;
|
|
1306
|
+
listRef.current?.querySelectorAll("[data-command-item]")[wrapped]?.scrollIntoView({ block: "nearest" });
|
|
1307
|
+
return wrapped;
|
|
1308
|
+
});
|
|
1309
|
+
return;
|
|
1310
|
+
}
|
|
1311
|
+
if (event.key === "Enter") {
|
|
1312
|
+
const item = items[cursor];
|
|
1313
|
+
if (item?.href) {
|
|
1314
|
+
listRef.current?.querySelectorAll("[data-command-item]")[cursor]?.click();
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
event.preventDefault();
|
|
1318
|
+
select(item);
|
|
1319
|
+
}
|
|
1320
|
+
};
|
|
1321
|
+
const grouped = useMemo(() => {
|
|
1322
|
+
const out = [];
|
|
1323
|
+
for (const item of items) {
|
|
1324
|
+
const last = out[out.length - 1];
|
|
1325
|
+
if (last && last.group === item.group) last.items.push(item);
|
|
1326
|
+
else out.push({ group: item.group, items: [item] });
|
|
1327
|
+
}
|
|
1328
|
+
return out;
|
|
1329
|
+
}, [items]);
|
|
1330
|
+
if (!open || !mounted) return null;
|
|
1331
|
+
let index = -1;
|
|
1332
|
+
return createPortal(
|
|
1333
|
+
/* @__PURE__ */ jsx(
|
|
1334
|
+
"div",
|
|
1335
|
+
{
|
|
1336
|
+
role: "dialog",
|
|
1337
|
+
"aria-modal": "true",
|
|
1338
|
+
"aria-label": labels?.title ?? "Search",
|
|
1339
|
+
className: "fixed inset-0 z-100 flex items-start justify-center bg-black/40 px-4 pt-[12vh] backdrop-blur-sm",
|
|
1340
|
+
onMouseDown: (e) => {
|
|
1341
|
+
if (e.target === e.currentTarget) onClose();
|
|
1342
|
+
},
|
|
1343
|
+
children: /* @__PURE__ */ jsxs(
|
|
1344
|
+
"div",
|
|
1345
|
+
{
|
|
1346
|
+
onKeyDown,
|
|
1347
|
+
className: cn(
|
|
1348
|
+
"w-full max-w-xl overflow-hidden rounded-2xl border border-border bg-popover/95 shadow-lg shadow-black/5 backdrop-blur-2xl",
|
|
1349
|
+
className
|
|
1350
|
+
),
|
|
1351
|
+
children: [
|
|
1352
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2.5 border-b border-border px-4", children: [
|
|
1353
|
+
/* @__PURE__ */ jsx(Search, { "aria-hidden": true, className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
1354
|
+
/* @__PURE__ */ jsx(
|
|
1355
|
+
"input",
|
|
1356
|
+
{
|
|
1357
|
+
ref: inputRef,
|
|
1358
|
+
value: query,
|
|
1359
|
+
onChange: (e) => onQueryChange(e.target.value),
|
|
1360
|
+
placeholder: labels?.placeholder ?? "Search\u2026",
|
|
1361
|
+
className: "h-12 flex-1 bg-transparent text-[16px] outline-none placeholder:text-muted-foreground",
|
|
1362
|
+
autoComplete: "off",
|
|
1363
|
+
spellCheck: false,
|
|
1364
|
+
role: "combobox",
|
|
1365
|
+
"aria-expanded": items.length > 0,
|
|
1366
|
+
"aria-controls": listId,
|
|
1367
|
+
"aria-activedescendant": items.length ? `${listId}-${cursor}` : void 0
|
|
1368
|
+
}
|
|
1369
|
+
),
|
|
1370
|
+
loading && /* @__PURE__ */ jsx(Spinner, { className: "h-4 w-4 shrink-0" }),
|
|
1371
|
+
/* @__PURE__ */ jsx(
|
|
1372
|
+
"button",
|
|
1373
|
+
{
|
|
1374
|
+
type: "button",
|
|
1375
|
+
onClick: onClose,
|
|
1376
|
+
"aria-label": labels?.close ?? "Close",
|
|
1377
|
+
className: "rounded-lg p-1.5 text-muted-foreground transition-colors hover:bg-foreground/5 hover:text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
1378
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
1379
|
+
}
|
|
1380
|
+
)
|
|
1381
|
+
] }),
|
|
1382
|
+
/* @__PURE__ */ jsx(
|
|
1383
|
+
"div",
|
|
1384
|
+
{
|
|
1385
|
+
ref: listRef,
|
|
1386
|
+
id: listId,
|
|
1387
|
+
role: "listbox",
|
|
1388
|
+
"aria-label": labels?.title ?? "Search",
|
|
1389
|
+
className: "max-h-[55vh] overflow-y-auto p-1.5",
|
|
1390
|
+
tabIndex: -1,
|
|
1391
|
+
children: loading && items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-8 text-center text-sm text-muted-foreground", children: "\u2026" }) : items.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-6 text-center text-sm text-muted-foreground", children: query ? empty : initial }) : grouped.map((section, s) => /* @__PURE__ */ jsxs("div", { children: [
|
|
1392
|
+
section.group && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2 pb-1 text-[10px] font-semibold tracking-[0.08em] text-muted-foreground uppercase", children: section.group }),
|
|
1393
|
+
section.items.map((item) => {
|
|
1394
|
+
index += 1;
|
|
1395
|
+
const active = index === cursor;
|
|
1396
|
+
const myIndex = index;
|
|
1397
|
+
const rowClass = cn(
|
|
1398
|
+
"flex w-full items-start gap-2.5 rounded-xl px-3 py-2 text-left transition-colors outline-none",
|
|
1399
|
+
active ? "bg-foreground/5" : "hover:bg-foreground/5"
|
|
1400
|
+
);
|
|
1401
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1402
|
+
item.icon && /* @__PURE__ */ jsx("span", { className: "mt-0.5 shrink-0 text-muted-foreground", children: item.icon }),
|
|
1403
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
|
|
1404
|
+
/* @__PURE__ */ jsx("span", { className: "block truncate text-sm", children: item.title }),
|
|
1405
|
+
item.description && /* @__PURE__ */ jsx("span", { className: "text-caption block truncate", children: item.description })
|
|
1406
|
+
] })
|
|
1407
|
+
] });
|
|
1408
|
+
const shared = {
|
|
1409
|
+
id: `${listId}-${myIndex}`,
|
|
1410
|
+
role: "option",
|
|
1411
|
+
"aria-selected": active,
|
|
1412
|
+
"data-command-item": true,
|
|
1413
|
+
onMouseEnter: () => setCursor(myIndex),
|
|
1414
|
+
className: rowClass
|
|
1415
|
+
};
|
|
1416
|
+
return item.href ? /* @__PURE__ */ jsx(
|
|
1417
|
+
Link,
|
|
1418
|
+
{
|
|
1419
|
+
href: item.href,
|
|
1420
|
+
...shared,
|
|
1421
|
+
onClick: () => {
|
|
1422
|
+
item.onSelect?.();
|
|
1423
|
+
onClose();
|
|
1424
|
+
},
|
|
1425
|
+
children: body
|
|
1426
|
+
},
|
|
1427
|
+
item.id
|
|
1428
|
+
) : /* @__PURE__ */ jsx(
|
|
1429
|
+
"button",
|
|
1430
|
+
{
|
|
1431
|
+
type: "button",
|
|
1432
|
+
...shared,
|
|
1433
|
+
onClick: () => select(item),
|
|
1434
|
+
children: body
|
|
1435
|
+
},
|
|
1436
|
+
item.id
|
|
1437
|
+
);
|
|
1438
|
+
})
|
|
1439
|
+
] }, section.group ?? s))
|
|
1440
|
+
}
|
|
1441
|
+
),
|
|
1442
|
+
footer != null && /* @__PURE__ */ jsx("div", { className: "text-caption flex items-center justify-between gap-3 border-t border-border px-4 py-2.5", children: footer })
|
|
1443
|
+
]
|
|
1444
|
+
}
|
|
1445
|
+
)
|
|
1446
|
+
}
|
|
1447
|
+
),
|
|
1448
|
+
document.body
|
|
1449
|
+
);
|
|
1450
|
+
}
|
|
1451
|
+
function useCommandPaletteShortcut(onOpen) {
|
|
1452
|
+
useEffect(() => {
|
|
1453
|
+
const onKey = (event) => {
|
|
1454
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "k") {
|
|
1455
|
+
event.preventDefault();
|
|
1456
|
+
onOpen();
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
document.addEventListener("keydown", onKey);
|
|
1460
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
1461
|
+
}, [onOpen]);
|
|
1462
|
+
}
|
|
1208
1463
|
|
|
1209
|
-
export { AnimatedNumber, AreaChart, BentoCard, BentoGrid, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CustomSelect, FileDropzone, Gauge, Marquee, NavTabs, Popover, PopoverAnchor, PopoverClose2 as PopoverClose, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, SegmentedBar, SegmentedSelect, ShinyButton, Sparkline, Switch, Toaster, YUNUI_PALETTES, YUNUI_THEME_PRESETS, applyTheme, readTheme, toast, useYunUITheme };
|
|
1210
|
-
//# sourceMappingURL=chunk-
|
|
1211
|
-
//# sourceMappingURL=chunk-
|
|
1464
|
+
export { AnimatedNumber, AreaChart, BentoCard, BentoGrid, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, CommandPalette, CustomSelect, FileDropzone, Gauge, Marquee, NavTabs, Popover, PopoverAnchor, PopoverClose2 as PopoverClose, PopoverContent, PopoverTrigger, ScrollArea, ScrollBar, SegmentedBar, SegmentedSelect, ShinyButton, Sparkline, Switch, Toaster, YUNUI_PALETTES, YUNUI_THEME_PRESETS, applyTheme, readTheme, toast, useCommandPaletteShortcut, useYunUITheme };
|
|
1465
|
+
//# sourceMappingURL=chunk-AFVENY4D.js.map
|
|
1466
|
+
//# sourceMappingURL=chunk-AFVENY4D.js.map
|