@yuhuanowo/yunui 0.2.14 → 0.2.15
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 +17 -1
- package/README.zh-CN.md +17 -1
- package/README.zh-TW.md +17 -1
- package/dist/ai.js +130 -95
- package/dist/ai.js.map +1 -1
- package/dist/{chunk-VXFEANVX.js → chunk-6MZN3GOP.js} +218 -143
- package/dist/chunk-6MZN3GOP.js.map +1 -0
- package/dist/{chunk-GHO4RCDR.js → chunk-LLNTUA5K.js} +87 -17
- package/dist/chunk-LLNTUA5K.js.map +1 -0
- package/dist/index.d.ts +91 -2
- package/dist/index.js +2 -2
- package/dist/patterns.d.ts +21 -1
- package/dist/patterns.js +20 -5
- package/dist/patterns.js.map +1 -1
- package/package.json +1 -1
- package/styles/tokens.css +704 -352
- package/styles/yunui.css +102 -0
- package/dist/chunk-GHO4RCDR.js.map +0 -1
- package/dist/chunk-VXFEANVX.js.map +0 -1
|
@@ -3,6 +3,7 @@ import { useYunUI } from './chunk-U2LNRVMI.js';
|
|
|
3
3
|
import { clsx } from 'clsx';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import * as React from 'react';
|
|
6
|
+
import { useState, useRef, useLayoutEffect, useEffect } from 'react';
|
|
6
7
|
import { Sun, Moon, Droplet, Monitor } from 'lucide-react';
|
|
7
8
|
import { useTheme } from 'next-themes';
|
|
8
9
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
@@ -10,12 +11,56 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
10
11
|
function cn(...inputs) {
|
|
11
12
|
return twMerge(clsx(inputs));
|
|
12
13
|
}
|
|
14
|
+
var useIsoLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
15
|
+
function useAnchoredPosition(open, panelRef, opts) {
|
|
16
|
+
const gutter = opts?.gutter ?? 8;
|
|
17
|
+
const minHeight = opts?.minHeight ?? 160;
|
|
18
|
+
const [pos, setPos] = useState({ shift: 0, maxHeight: void 0 });
|
|
19
|
+
const shiftRef = useRef(0);
|
|
20
|
+
useIsoLayoutEffect(() => {
|
|
21
|
+
if (!open) {
|
|
22
|
+
shiftRef.current = 0;
|
|
23
|
+
setPos({ shift: 0, maxHeight: void 0 });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const compute = () => {
|
|
27
|
+
const el = panelRef.current;
|
|
28
|
+
const parent = el?.offsetParent;
|
|
29
|
+
if (!el || !parent) return;
|
|
30
|
+
const parentRect = parent.getBoundingClientRect();
|
|
31
|
+
const vw = window.innerWidth;
|
|
32
|
+
const vh = window.innerHeight;
|
|
33
|
+
const naturalLeft = parentRect.left + el.offsetLeft - shiftRef.current;
|
|
34
|
+
const naturalRight = naturalLeft + el.offsetWidth;
|
|
35
|
+
let dx = 0;
|
|
36
|
+
if (naturalRight > vw - gutter) dx = vw - gutter - naturalRight;
|
|
37
|
+
if (naturalLeft + dx < gutter) dx = gutter - naturalLeft;
|
|
38
|
+
dx = Math.round(dx);
|
|
39
|
+
const top = parentRect.top + el.offsetTop;
|
|
40
|
+
const space = Math.floor(vh - top - gutter);
|
|
41
|
+
const maxHeight = space < vh ? Math.max(space, minHeight) : void 0;
|
|
42
|
+
shiftRef.current = dx;
|
|
43
|
+
setPos({ shift: dx, maxHeight });
|
|
44
|
+
};
|
|
45
|
+
compute();
|
|
46
|
+
window.addEventListener("resize", compute);
|
|
47
|
+
window.addEventListener("scroll", compute, true);
|
|
48
|
+
return () => {
|
|
49
|
+
window.removeEventListener("resize", compute);
|
|
50
|
+
window.removeEventListener("scroll", compute, true);
|
|
51
|
+
};
|
|
52
|
+
}, [open, gutter, minHeight, panelRef]);
|
|
53
|
+
return pos;
|
|
54
|
+
}
|
|
13
55
|
function ThemeToggle({ variant = "icon", align = "right", className = "" }) {
|
|
14
56
|
const { theme, setTheme } = useTheme();
|
|
15
57
|
const t = useYunUI().useT("common.theme");
|
|
16
58
|
const [mounted, setMounted] = React.useState(false);
|
|
17
59
|
const [isOpen, setIsOpen] = React.useState(false);
|
|
18
60
|
const containerRef = React.useRef(null);
|
|
61
|
+
const triggerRef = React.useRef(null);
|
|
62
|
+
const panelRef = React.useRef(null);
|
|
63
|
+
const { shift, maxHeight } = useAnchoredPosition(isOpen, panelRef);
|
|
19
64
|
React.useEffect(() => {
|
|
20
65
|
setMounted(true);
|
|
21
66
|
}, []);
|
|
@@ -28,6 +73,17 @@ function ThemeToggle({ variant = "icon", align = "right", className = "" }) {
|
|
|
28
73
|
document.addEventListener("mousedown", handleClickOutside);
|
|
29
74
|
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
30
75
|
}, []);
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (!isOpen) return;
|
|
78
|
+
const onKey = (e) => {
|
|
79
|
+
if (e.key === "Escape") {
|
|
80
|
+
setIsOpen(false);
|
|
81
|
+
triggerRef.current?.focus();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
document.addEventListener("keydown", onKey);
|
|
85
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
86
|
+
}, [isOpen]);
|
|
31
87
|
const themes = [
|
|
32
88
|
{ value: "light", label: t("light"), icon: /* @__PURE__ */ jsx(Sun, { size: 14 }) },
|
|
33
89
|
{ value: "dark", label: t("zincDark"), icon: /* @__PURE__ */ jsx(Moon, { size: 14 }) },
|
|
@@ -41,9 +97,12 @@ function ThemeToggle({ variant = "icon", align = "right", className = "" }) {
|
|
|
41
97
|
variant === "pill" ? /* @__PURE__ */ jsxs(
|
|
42
98
|
"button",
|
|
43
99
|
{
|
|
100
|
+
ref: triggerRef,
|
|
44
101
|
onClick: () => setIsOpen(!isOpen),
|
|
45
102
|
className: "flex items-center gap-1.5 h-9 px-3 rounded-full text-sm font-medium transition-all bg-(--bg-elevated) hover:bg-(--bg-elevated)/80 border border-(--border-hairline) text-(--text-secondary) hover:text-(--text-primary) outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
46
103
|
"aria-label": t("toggle"),
|
|
104
|
+
"aria-expanded": isOpen,
|
|
105
|
+
"aria-haspopup": "listbox",
|
|
47
106
|
children: [
|
|
48
107
|
/* @__PURE__ */ jsx(Sun, { size: 14, className: "rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }),
|
|
49
108
|
/* @__PURE__ */ jsx(Moon, { size: 14, className: "absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" })
|
|
@@ -52,9 +111,12 @@ function ThemeToggle({ variant = "icon", align = "right", className = "" }) {
|
|
|
52
111
|
) : /* @__PURE__ */ jsxs(
|
|
53
112
|
"button",
|
|
54
113
|
{
|
|
114
|
+
ref: triggerRef,
|
|
55
115
|
onClick: () => setIsOpen(!isOpen),
|
|
56
116
|
className: "w-9 h-9 rounded-lg flex items-center justify-center hover:bg-foreground/5 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
|
|
57
117
|
"aria-label": t("toggle"),
|
|
118
|
+
"aria-expanded": isOpen,
|
|
119
|
+
"aria-haspopup": "listbox",
|
|
58
120
|
children: [
|
|
59
121
|
/* @__PURE__ */ jsx(Sun, { className: "h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 absolute" }),
|
|
60
122
|
/* @__PURE__ */ jsx(Moon, { className: "h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }),
|
|
@@ -62,24 +124,32 @@ function ThemeToggle({ variant = "icon", align = "right", className = "" }) {
|
|
|
62
124
|
]
|
|
63
125
|
}
|
|
64
126
|
),
|
|
65
|
-
isOpen && /* @__PURE__ */ jsx(
|
|
66
|
-
"
|
|
127
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
128
|
+
"div",
|
|
67
129
|
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
130
|
+
ref: panelRef,
|
|
131
|
+
style: { marginLeft: shift, maxHeight },
|
|
132
|
+
className: `absolute ${align === "left" ? "left-0" : "right-0"} top-full mt-2 z-50 flex flex-col overflow-hidden rounded-2xl border border-border bg-background/60 backdrop-blur-2xl text-popover-foreground shadow-lg shadow-black/5 animate-in fade-in-0 zoom-in-95 duration-200`,
|
|
133
|
+
children: /* @__PURE__ */ jsx("div", { className: "p-1 flex-1 min-h-0 overflow-y-auto", children: themes.map((themeItem) => /* @__PURE__ */ jsxs(
|
|
134
|
+
"button",
|
|
135
|
+
{
|
|
136
|
+
onClick: () => {
|
|
137
|
+
setTheme(themeItem.value);
|
|
138
|
+
setIsOpen(false);
|
|
139
|
+
},
|
|
140
|
+
className: `dropdown-item w-full text-left ${theme === themeItem.value ? "active" : ""}`,
|
|
141
|
+
children: [
|
|
142
|
+
themeItem.icon,
|
|
143
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: themeItem.label })
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
themeItem.value
|
|
147
|
+
)) })
|
|
148
|
+
}
|
|
149
|
+
)
|
|
80
150
|
] });
|
|
81
151
|
}
|
|
82
152
|
|
|
83
|
-
export { ThemeToggle, cn };
|
|
84
|
-
//# sourceMappingURL=chunk-
|
|
85
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
export { ThemeToggle, cn, useAnchoredPosition };
|
|
154
|
+
//# sourceMappingURL=chunk-LLNTUA5K.js.map
|
|
155
|
+
//# sourceMappingURL=chunk-LLNTUA5K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/cn.ts","../src/lib/use-anchored-position.ts","../src/primitives/theme-toggle.tsx"],"names":[],"mappings":";;;;;;;;;AAOO,SAAS,MAAM,MAAA,EAAsB;AAC1C,EAAA,OAAO,O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AAA,EAAO,SAAA,EAAU;AAAA,QACtC,SAAA,EAAW,CAAA,SAAA,EAAY,KAAA,KAAU,MAAA,GAAS,WAAW,SAAS,CAAA,mNAAA,CAAA;AAAA,QAE9D,8BAAC,KAAA,EAAA,EAAI,SAAA,EAAU,sCACV,QAAA,EAAA,MAAA,CAAO,GAAA,CAAI,CAAC,SAAA,qBACT,IAAA;AAAA,UAAC,QAAA;AAAA,UAAA;AAAA,YAEG,SAAS,MAAM;AACX,cAAA,QAAA,CAAS,UAAU,KAAK,CAAA;AACxB,cAAA,SAAA,CAAU,KAAK,CAAA;AAAA,YACnB,CAAA;AAAA,YACA,WAAW,CAAA,+BAAA,EACP,KAAA,KAAU,SAAA,CAAU,KAAA,GAAQ,WAAW,EAC3C,CAAA,CAAA;AAAA,YAEC,QAAA,EAAA;AAAA,cAAA,SAAA,CAAU,IAAA;AAAA,8BACX,GAAA,CAAC,MAAA,EAAA,EAAK,SAAA,EAAU,QAAA,EAAU,oBAAU,KAAA,EAAM;AAAA;AAAA,WAAA;AAAA,UAVrC,SAAA,CAAU;AAAA,SAYtB,CAAA,EACL;AAAA;AAAA;AACJ,GAAA,EAER,CAAA;AAER","file":"chunk-LLNTUA5K.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind-aware conflict resolution.\n * `cn(\"px-4\", \"px-8\")` → `\"px-8\"`.\n */\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { useEffect, useLayoutEffect, useRef, useState } from \"react\";\n\n// SSR-safe layout effect: useLayoutEffect on the client, no-op on the server\n// (effects don't run during SSR, and this avoids React's dev warning).\nconst useIsoLayoutEffect = typeof window !== \"undefined\" ? useLayoutEffect : useEffect;\n\nexport interface AnchoredPosition {\n /** Horizontal nudge (px) to keep the panel on-screen. Apply as `marginLeft`\n * — it never collides with `transform` (framer-motion / `animate-in`) or the\n * panel's left/right anchor. */\n shift: number;\n /** Cap (px) so the panel can't run off the bottom edge; pair with an\n * internal scroll region (`flex-1 min-h-0` / `overflow-y-auto`). */\n maxHeight?: number;\n}\n\n/**\n * Viewport-collision for HAND-ROLLED floating panels (the Radix ones flip/shift\n * on their own). Given the open state and a ref to the absolutely-positioned\n * panel, returns a horizontal `shift` and a `maxHeight` that keep it inside the\n * screen. Measures via untransformed `offset*` against the panel's\n * `offsetParent`, so an in-flight scale/translate animation doesn't skew it.\n */\nexport function useAnchoredPosition(\n open: boolean,\n panelRef: React.RefObject<HTMLElement | null>,\n opts?: { gutter?: number; minHeight?: number },\n): AnchoredPosition {\n const gutter = opts?.gutter ?? 8;\n const minHeight = opts?.minHeight ?? 160;\n const [pos, setPos] = useState<AnchoredPosition>({ shift: 0, maxHeight: undefined });\n // The shift currently baked into the panel's margin — subtract it to recover\n // the natural box on each recompute (otherwise it would drift).\n const shiftRef = useRef(0);\n\n useIsoLayoutEffect(() => {\n if (!open) {\n shiftRef.current = 0;\n setPos({ shift: 0, maxHeight: undefined });\n return;\n }\n const compute = () => {\n const el = panelRef.current;\n const parent = el?.offsetParent as HTMLElement | null;\n if (!el || !parent) return;\n const parentRect = parent.getBoundingClientRect();\n const vw = window.innerWidth;\n const vh = window.innerHeight;\n\n // Natural (un-shifted) box in viewport coords. offsetLeft includes the\n // applied marginLeft, so remove the current shift first.\n const naturalLeft = parentRect.left + el.offsetLeft - shiftRef.current;\n const naturalRight = naturalLeft + el.offsetWidth;\n let dx = 0;\n if (naturalRight > vw - gutter) dx = vw - gutter - naturalRight;\n if (naturalLeft + dx < gutter) dx = gutter - naturalLeft;\n dx = Math.round(dx);\n\n const top = parentRect.top + el.offsetTop;\n const space = Math.floor(vh - top - gutter);\n const maxHeight = space < vh ? Math.max(space, minHeight) : undefined;\n\n shiftRef.current = dx;\n setPos({ shift: dx, maxHeight });\n };\n\n compute();\n window.addEventListener(\"resize\", compute);\n window.addEventListener(\"scroll\", compute, true);\n return () => {\n window.removeEventListener(\"resize\", compute);\n window.removeEventListener(\"scroll\", compute, true);\n };\n }, [open, gutter, minHeight, panelRef]);\n\n return pos;\n}\n","\"use client\"\n\nimport * as React from \"react\"\nimport { Moon, Sun, Monitor, Droplet } from \"lucide-react\"\nimport { useTheme } from \"next-themes\"\nimport { useYunUI } from \"../adapters/context\"\nimport { useAnchoredPosition } from \"../lib/use-anchored-position\"\n\ninterface ThemeToggleProps {\n /** Visual variant: `icon` (default, icon-only) or `pill`. */\n variant?: \"icon\" | \"pill\";\n /** Dropdown alignment: `left` or `right` (default). */\n align?: \"left\" | \"right\";\n /** Additional className */\n className?: string;\n}\n\n/** Theme switcher dropdown (light / dark / true-black / system) backed by next-themes. */\nexport function ThemeToggle({ variant = \"icon\", align = \"right\", className = \"\" }: ThemeToggleProps) {\n const { theme, setTheme } = useTheme()\n const t = useYunUI().useT(\"common.theme\")\n const [mounted, setMounted] = React.useState(false)\n const [isOpen, setIsOpen] = React.useState(false)\n const containerRef = React.useRef<HTMLDivElement>(null)\n const triggerRef = React.useRef<HTMLButtonElement>(null)\n const panelRef = React.useRef<HTMLDivElement>(null)\n const { shift, maxHeight } = useAnchoredPosition(isOpen, panelRef)\n\n React.useEffect(() => {\n setMounted(true)\n }, [])\n\n // Close on outside click\n React.useEffect(() => {\n const handleClickOutside = (e: MouseEvent) => {\n if (containerRef.current && !containerRef.current.contains(e.target as Node)) {\n setIsOpen(false)\n }\n }\n document.addEventListener(\"mousedown\", handleClickOutside)\n return () => document.removeEventListener(\"mousedown\", handleClickOutside)\n }, [])\n\n // Close on Escape + restore focus to the trigger. Document-level (not a\n // container onKeyDown): WebKit/Safari on macOS doesn't focus a <button> on\n // click, so focus wouldn't be inside the container to bubble an Escape from.\n React.useEffect(() => {\n if (!isOpen) return\n const onKey = (e: KeyboardEvent) => {\n if (e.key === \"Escape\") {\n setIsOpen(false)\n triggerRef.current?.focus()\n }\n }\n document.addEventListener(\"keydown\", onKey)\n return () => document.removeEventListener(\"keydown\", onKey)\n }, [isOpen])\n\n const themes = [\n { value: \"light\", label: t(\"light\"), icon: <Sun size={14} /> },\n { value: \"dark\", label: t(\"zincDark\"), icon: <Moon size={14} /> },\n { value: \"true-black\", label: t(\"trueBlack\"), icon: <Droplet size={14} fill=\"currentColor\" /> },\n { value: \"system\", label: t(\"system\"), icon: <Monitor size={14} /> },\n ]\n\n if (!mounted) {\n return (\n <div className={className}>\n {variant === \"pill\" ? (\n <div className=\"h-8 w-16 rounded-full bg-(--bg-elevated) border border-(--border-hairline)\" />\n ) : (\n <div className=\"w-9 h-9 rounded-lg\" />\n )}\n </div>\n )\n }\n\n return (\n <div ref={containerRef} className={`relative ${className}`}>\n {/* Trigger */}\n {variant === \"pill\" ? (\n <button\n ref={triggerRef}\n onClick={() => setIsOpen(!isOpen)}\n className=\"flex items-center gap-1.5 h-9 px-3 rounded-full text-sm font-medium transition-all bg-(--bg-elevated) hover:bg-(--bg-elevated)/80 border border-(--border-hairline) text-(--text-secondary) hover:text-(--text-primary) outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n aria-label={t(\"toggle\")}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n >\n <Sun size={14} className=\"rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0\" />\n <Moon size={14} className=\"absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100\" />\n </button>\n ) : (\n <button\n ref={triggerRef}\n onClick={() => setIsOpen(!isOpen)}\n className=\"w-9 h-9 rounded-lg flex items-center justify-center hover:bg-foreground/5 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\"\n aria-label={t(\"toggle\")}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n >\n <Sun className=\"h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0 absolute\" />\n <Moon className=\"h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100\" />\n <span className=\"sr-only\">{t(\"toggle\")}</span>\n </button>\n )}\n\n {/* Dropdown */}\n {isOpen && (\n <div\n ref={panelRef}\n style={{ marginLeft: shift, maxHeight }}\n className={`absolute ${align === \"left\" ? \"left-0\" : \"right-0\"} top-full mt-2 z-50 flex flex-col overflow-hidden rounded-2xl border border-border bg-background/60 backdrop-blur-2xl text-popover-foreground shadow-lg shadow-black/5 animate-in fade-in-0 zoom-in-95 duration-200`}\n >\n <div className=\"p-1 flex-1 min-h-0 overflow-y-auto\">\n {themes.map((themeItem) => (\n <button\n key={themeItem.value}\n onClick={() => {\n setTheme(themeItem.value)\n setIsOpen(false)\n }}\n className={`dropdown-item w-full text-left ${\n theme === themeItem.value ? \"active\" : \"\"\n }`}\n >\n {themeItem.icon}\n <span className=\"flex-1\">{themeItem.label}</span>\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n )\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1049,7 +1049,7 @@ declare function useFocusTrap(containerRef: RefObject<HTMLElement | null>, enabl
|
|
|
1049
1049
|
* applyTheme({ brand: "emerald", accent: "violet" }); // imperative
|
|
1050
1050
|
* const [theme, setTheme] = useYunUITheme({ brand: "blue" }); // React, persisted
|
|
1051
1051
|
*/
|
|
1052
|
-
type YunUIPalette = "gray" | "sand" | "slate" | "mint" | "rose" | "dusk" | "red" | "orange" | "yellow" | "moss" | "green" | "emerald" | "aqua" | "cyan" | "blue" | "indigo" | "violet" | "magenta" | "pink";
|
|
1052
|
+
type YunUIPalette = "gray" | "sand" | "slate" | "mint" | "rose" | "dusk" | "red" | "orange" | "amber" | "yellow" | "lime" | "moss" | "green" | "emerald" | "teal" | "aqua" | "cyan" | "blue" | "indigo" | "violet" | "plum" | "magenta" | "fuchsia" | "pink";
|
|
1053
1053
|
/** How solid (filled) surfaces derive their color. */
|
|
1054
1054
|
type YunUISolid = "color" | "contrast" | "inverse";
|
|
1055
1055
|
/** Whether elevated surfaces are opaque or frosted. */
|
|
@@ -1077,6 +1077,95 @@ interface YunUITheme {
|
|
|
1077
1077
|
type YunUIAccentSource = "brand" | "mono";
|
|
1078
1078
|
/** All palettes available to the brand/accent/neutral roles (for building pickers). */
|
|
1079
1079
|
declare const YUNUI_PALETTES: YunUIPalette[];
|
|
1080
|
+
/**
|
|
1081
|
+
* Curated multi-color theme presets — beautiful {brand, accent, neutral}
|
|
1082
|
+
* combinations. Apply one with `applyTheme(YUNUI_THEME_PRESETS.aurora)` or feed
|
|
1083
|
+
* them into a theme picker. Each pairs a brand with a complementary accent and a
|
|
1084
|
+
* neutral tuned to the same temperature.
|
|
1085
|
+
*/
|
|
1086
|
+
interface YunUIThemePreset {
|
|
1087
|
+
/** Display name. */
|
|
1088
|
+
label: string;
|
|
1089
|
+
brand: YunUIPalette;
|
|
1090
|
+
accent: YunUIPalette;
|
|
1091
|
+
neutral: YunUIPalette;
|
|
1092
|
+
}
|
|
1093
|
+
declare const YUNUI_THEME_PRESETS: {
|
|
1094
|
+
aurora: {
|
|
1095
|
+
label: string;
|
|
1096
|
+
brand: "blue";
|
|
1097
|
+
accent: "violet";
|
|
1098
|
+
neutral: "slate";
|
|
1099
|
+
};
|
|
1100
|
+
sunset: {
|
|
1101
|
+
label: string;
|
|
1102
|
+
brand: "orange";
|
|
1103
|
+
accent: "pink";
|
|
1104
|
+
neutral: "sand";
|
|
1105
|
+
};
|
|
1106
|
+
forest: {
|
|
1107
|
+
label: string;
|
|
1108
|
+
brand: "green";
|
|
1109
|
+
accent: "lime";
|
|
1110
|
+
neutral: "gray";
|
|
1111
|
+
};
|
|
1112
|
+
ocean: {
|
|
1113
|
+
label: string;
|
|
1114
|
+
brand: "cyan";
|
|
1115
|
+
accent: "teal";
|
|
1116
|
+
neutral: "slate";
|
|
1117
|
+
};
|
|
1118
|
+
grape: {
|
|
1119
|
+
label: string;
|
|
1120
|
+
brand: "violet";
|
|
1121
|
+
accent: "magenta";
|
|
1122
|
+
neutral: "dusk";
|
|
1123
|
+
};
|
|
1124
|
+
ember: {
|
|
1125
|
+
label: string;
|
|
1126
|
+
brand: "red";
|
|
1127
|
+
accent: "amber";
|
|
1128
|
+
neutral: "sand";
|
|
1129
|
+
};
|
|
1130
|
+
lagoon: {
|
|
1131
|
+
label: string;
|
|
1132
|
+
brand: "teal";
|
|
1133
|
+
accent: "emerald";
|
|
1134
|
+
neutral: "mint";
|
|
1135
|
+
};
|
|
1136
|
+
blossom: {
|
|
1137
|
+
label: string;
|
|
1138
|
+
brand: "pink";
|
|
1139
|
+
accent: "fuchsia";
|
|
1140
|
+
neutral: "rose";
|
|
1141
|
+
};
|
|
1142
|
+
royal: {
|
|
1143
|
+
label: string;
|
|
1144
|
+
brand: "indigo";
|
|
1145
|
+
accent: "blue";
|
|
1146
|
+
neutral: "slate";
|
|
1147
|
+
};
|
|
1148
|
+
citrus: {
|
|
1149
|
+
label: string;
|
|
1150
|
+
brand: "lime";
|
|
1151
|
+
accent: "yellow";
|
|
1152
|
+
neutral: "sand";
|
|
1153
|
+
};
|
|
1154
|
+
orchid: {
|
|
1155
|
+
label: string;
|
|
1156
|
+
brand: "plum";
|
|
1157
|
+
accent: "violet";
|
|
1158
|
+
neutral: "dusk";
|
|
1159
|
+
};
|
|
1160
|
+
mono: {
|
|
1161
|
+
label: string;
|
|
1162
|
+
brand: "gray";
|
|
1163
|
+
accent: "gray";
|
|
1164
|
+
neutral: "gray";
|
|
1165
|
+
};
|
|
1166
|
+
};
|
|
1167
|
+
/** Preset keys, e.g. for iterating in a picker. */
|
|
1168
|
+
type YunUIThemePresetName = keyof typeof YUNUI_THEME_PRESETS;
|
|
1080
1169
|
/**
|
|
1081
1170
|
* Apply theme attributes to an element (defaults to <html>). Only the keys you
|
|
1082
1171
|
* pass are written; pass `null` for a key to clear it. Safe to call on the
|
|
@@ -1092,4 +1181,4 @@ declare function readTheme(el?: HTMLElement | null): YunUITheme;
|
|
|
1092
1181
|
*/
|
|
1093
1182
|
declare function useYunUITheme(defaults?: YunUITheme): [YunUITheme, (patch: YunUITheme) => void];
|
|
1094
1183
|
|
|
1095
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AnimatedNumber, type AnimatedNumberProps, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Column, Combobox, type ComboboxOption, ConfirmModal, type ConfirmModalVariant, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, type FlexProps, Grid, type GridCount, type GridProps, IconButton, InlineCode, InlineStatus, type InlineStatusKind, Input, Kbd, Label, Marquee, Modal, MotionDiv, MotionSpan, type NavTab, NavTabs, NumberInput, PageLoader, Pagination, type PaginationProps, PasswordInput, Popover, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SearchInput, type SegmentedOption, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, type SelectOption, SelectTrigger, SelectValue, Separator, Sheet, ShinyButton, Skeleton, Slider, type SpacingScale, Spinner, Stack, StatusIndicator, Steps, Switch, type SwitchProps, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TableBody as Tbody, TableCell as Td, Textarea, TableFooter as Tfoot, TableHead as Th, TableHeader as Thead, ThemeToggle, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TableRow as Tr, YUNUI_PALETTES, type YunUIAccentSource, type YunUIColorScheme, type YunUIPalette, type YunUISolid, type YunUISurface, type YunUITheme, applyTheme, cn, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme };
|
|
1184
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AnimatedNumber, type AnimatedNumberProps, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, type CheckboxProps, Collapsible, CollapsibleContent, type CollapsibleContentProps, type CollapsibleProps, CollapsibleTrigger, type CollapsibleTriggerProps, Column, Combobox, type ComboboxOption, ConfirmModal, type ConfirmModalVariant, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, type FlexProps, Grid, type GridCount, type GridProps, IconButton, InlineCode, InlineStatus, type InlineStatusKind, Input, Kbd, Label, Marquee, Modal, MotionDiv, MotionSpan, type NavTab, NavTabs, NumberInput, PageLoader, Pagination, type PaginationProps, PasswordInput, Popover, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SearchInput, type SegmentedOption, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, type SelectOption, SelectTrigger, SelectValue, Separator, Sheet, ShinyButton, Skeleton, Slider, type SpacingScale, Spinner, Stack, StatusIndicator, Steps, Switch, type SwitchProps, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TableBody as Tbody, TableCell as Td, Textarea, TableFooter as Tfoot, TableHead as Th, TableHeader as Thead, ThemeToggle, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TableRow as Tr, YUNUI_PALETTES, YUNUI_THEME_PRESETS, type YunUIAccentSource, type YunUIColorScheme, type YunUIPalette, type YunUISolid, type YunUISurface, type YunUITheme, type YunUIThemePreset, type YunUIThemePresetName, applyTheme, cn, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AnimatedNumber, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Column, Combobox, ConfirmModal, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, Grid, IconButton, InlineCode, InlineStatus, Input, Kbd, Label, Marquee, Modal, MotionDiv, MotionSpan, NavTabs, NumberInput, PageLoader, Pagination, PasswordInput, Popover, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SearchInput, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, ShinyButton, Skeleton, Slider, Spinner, Stack, StatusIndicator, Steps, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TableBody as Tbody, TableCell as Td, Textarea, TableFooter as Tfoot, TableHead as Th, TableHeader as Thead, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TableRow as Tr, YUNUI_PALETTES, applyTheme, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme } from './chunk-
|
|
3
|
-
export { ThemeToggle, cn } from './chunk-
|
|
2
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AnimatedNumber, Avatar, AvatarFallback, AvatarGroup, AvatarImage, Badge, BentoCard, BentoGrid, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Card, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Column, Combobox, ConfirmModal, CustomSelect, DeleteConfirmModal, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EmptyState, Flex, Grid, IconButton, InlineCode, InlineStatus, Input, Kbd, Label, Marquee, Modal, MotionDiv, MotionSpan, NavTabs, NumberInput, PageLoader, Pagination, PasswordInput, Popover, PopoverClose, PopoverContent, PopoverTrigger, Progress, RadioGroup, RadioGroupItem, RegenerateConfirmModal, Row, SearchInput, SegmentedSelect, Select, SelectContent, SelectGroup, SelectItem, SelectTrigger, SelectValue, Separator, Sheet, ShinyButton, Skeleton, Slider, Spinner, Stack, StatusIndicator, Steps, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Tag, TableBody as Tbody, TableCell as Td, Textarea, TableFooter as Tfoot, TableHead as Th, TableHeader as Thead, Toaster, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TableRow as Tr, YUNUI_PALETTES, YUNUI_THEME_PRESETS, applyTheme, fadeIn, readTheme, staggerContainer, staggerItem, toast, useBodyScrollLock, useEscapeKey, useFocusTrap, useModalBehavior, useYunUITheme } from './chunk-6MZN3GOP.js';
|
|
3
|
+
export { ThemeToggle, cn } from './chunk-LLNTUA5K.js';
|
|
4
4
|
import './chunk-U2LNRVMI.js';
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/dist/patterns.d.ts
CHANGED
|
@@ -209,6 +209,26 @@ interface PageHeaderProps {
|
|
|
209
209
|
}
|
|
210
210
|
declare function PageHeader({ title, description, actions, className }: PageHeaderProps): React$1.JSX.Element;
|
|
211
211
|
|
|
212
|
+
interface PageLayoutProps {
|
|
213
|
+
/** Page content, rendered inside `<main>`. */
|
|
214
|
+
children: ReactNode;
|
|
215
|
+
/** Top navigation slot — typically `<Navbar/>`. Rendered above `<main>`. */
|
|
216
|
+
navbar?: ReactNode;
|
|
217
|
+
/** Bottom slot — typically `<Footer/>`. Hidden when `hideFooter`. */
|
|
218
|
+
footer?: ReactNode;
|
|
219
|
+
/** Drop the footer (e.g. focused/app pages). */
|
|
220
|
+
hideFooter?: boolean;
|
|
221
|
+
/** Skip the default `bg-background` so a page can paint its own backdrop. */
|
|
222
|
+
transparentBg?: boolean;
|
|
223
|
+
/** Override the `<main>` classes — defaults to `flex-1 pt-28` (clears the
|
|
224
|
+
* fixed navbar). Pass your own offset for a taller/shorter bar. */
|
|
225
|
+
mainClassName?: string;
|
|
226
|
+
/** Extra classes on the outer wrapper. */
|
|
227
|
+
className?: string;
|
|
228
|
+
}
|
|
229
|
+
/** Full-height page shell: navbar slot · offset `<main>` · footer slot. */
|
|
230
|
+
declare function PageLayout({ children, navbar, footer, hideFooter, transparentBg, mainClassName, className, }: PageLayoutProps): React$1.JSX.Element;
|
|
231
|
+
|
|
212
232
|
interface PageLoadingStateProps {
|
|
213
233
|
/** Optional text shown beside the spinner. */
|
|
214
234
|
message?: string;
|
|
@@ -594,4 +614,4 @@ interface AvatarUploaderProps {
|
|
|
594
614
|
}
|
|
595
615
|
declare function AvatarUploader({ src, fallback, size, uploading, onSelectFile, label, className, }: AvatarUploaderProps): React$1.JSX.Element;
|
|
596
616
|
|
|
597
|
-
export { AccountLockedCard, type AccountLockedCardProps, ActiveBadge, AvatarUploader, type AvatarUploaderProps, BackgroundEffects, Banner, type BannerProps, type BannerTone, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, type ConnectedAccountRowProps, DeprecatedBadge, ErrorBoundary, type ErrorBoundaryLabels, FAQ, type FAQItem, type FAQProps, FeatureLockedState, type FeatureLockedStateProps, FellowBadge, FellowsBanner, type FellowsBannerProps, LLMCopyButton, LinkRow, type LinkRowProps, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, type MetricBarProps, NotificationBell, type NotificationBellProps, NotificationItem, type NotificationItemProps, NotificationPanel, type NotificationPanelProps, PageEmptyState, PageErrorState, PageHeader, PageLoadingState, SessionItem, type SessionItemProps, SettingRow, type SettingRowProps, Sidebar, type SidebarNavItem, type SidebarProps, type SidebarSection, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
|
|
617
|
+
export { AccountLockedCard, type AccountLockedCardProps, ActiveBadge, AvatarUploader, type AvatarUploaderProps, BackgroundEffects, Banner, type BannerProps, type BannerTone, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, type ConnectedAccountRowProps, DeprecatedBadge, ErrorBoundary, type ErrorBoundaryLabels, FAQ, type FAQItem, type FAQProps, FeatureLockedState, type FeatureLockedStateProps, FellowBadge, FellowsBanner, type FellowsBannerProps, LLMCopyButton, LinkRow, type LinkRowProps, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, type MetricBarProps, NotificationBell, type NotificationBellProps, NotificationItem, type NotificationItemProps, NotificationPanel, type NotificationPanelProps, PageEmptyState, PageErrorState, PageHeader, PageLayout, type PageLayoutProps, PageLoadingState, SessionItem, type SessionItemProps, SettingRow, type SettingRowProps, Sidebar, type SidebarNavItem, type SidebarProps, type SidebarSection, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
|
package/dist/patterns.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Button, Card, Badge, Avatar, AvatarImage, AvatarFallback, IconButton, Spinner } from './chunk-
|
|
2
|
+
import { Button, Card, Badge, Avatar, AvatarImage, AvatarFallback, IconButton, Spinner } from './chunk-6MZN3GOP.js';
|
|
3
3
|
import { copyToClipboard } from './chunk-N53PNMPJ.js';
|
|
4
4
|
export { Footer } from './chunk-N53PNMPJ.js';
|
|
5
|
-
import { cn } from './chunk-
|
|
5
|
+
import { cn } from './chunk-LLNTUA5K.js';
|
|
6
6
|
import { useYunUI } from './chunk-U2LNRVMI.js';
|
|
7
7
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
8
8
|
import React, { useState, useEffect, useCallback, useRef } from 'react';
|
|
@@ -734,6 +734,21 @@ function PageHeader({ title, description, actions, className }) {
|
|
|
734
734
|
actions && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 shrink-0", children: actions })
|
|
735
735
|
] });
|
|
736
736
|
}
|
|
737
|
+
function PageLayout({
|
|
738
|
+
children,
|
|
739
|
+
navbar,
|
|
740
|
+
footer,
|
|
741
|
+
hideFooter = false,
|
|
742
|
+
transparentBg = false,
|
|
743
|
+
mainClassName,
|
|
744
|
+
className
|
|
745
|
+
}) {
|
|
746
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("min-h-dvh flex flex-col relative", !transparentBg && "bg-background", className), children: [
|
|
747
|
+
navbar,
|
|
748
|
+
/* @__PURE__ */ jsx("main", { className: cn("flex-1 pt-28", mainClassName), children }),
|
|
749
|
+
!hideFooter && footer
|
|
750
|
+
] });
|
|
751
|
+
}
|
|
737
752
|
function PageLoadingState({ message }) {
|
|
738
753
|
return /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center py-16", children: [
|
|
739
754
|
/* @__PURE__ */ jsx(Spinner, { size: "lg" }),
|
|
@@ -1095,7 +1110,7 @@ function SessionItem({
|
|
|
1095
1110
|
current && /* @__PURE__ */ jsx("span", { className: "text-[10px] px-1.5 py-0.5 rounded-full badge-success shrink-0", children: currentLabel }),
|
|
1096
1111
|
inactive && /* @__PURE__ */ jsx("span", { className: "text-[10px] px-1.5 py-0.5 rounded-full badge-neutral shrink-0", children: inactiveLabel })
|
|
1097
1112
|
] }),
|
|
1098
|
-
detail && /* @__PURE__ */ jsx("div", { className: "text-[10px] text-(--text-tertiary) mt-0.5", children: detail }),
|
|
1113
|
+
detail && /* @__PURE__ */ jsx("div", { className: "text-[10px] text-(--text-tertiary) mt-0.5 truncate", children: detail }),
|
|
1099
1114
|
(ip != null || time != null) && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 mt-1 text-[10px] text-(--text-tertiary)", children: [
|
|
1100
1115
|
ip != null && /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-0.5", children: [
|
|
1101
1116
|
/* @__PURE__ */ jsx(Globe, { size: 8 }),
|
|
@@ -1332,7 +1347,7 @@ function LinkRow({ icon, title, description, href, external, className }) {
|
|
|
1332
1347
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1333
1348
|
icon != null && /* @__PURE__ */ jsx("span", { className: "text-(--text-tertiary) shrink-0", children: icon }),
|
|
1334
1349
|
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
1335
|
-
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium", children: title }),
|
|
1350
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm font-medium truncate", children: title }),
|
|
1336
1351
|
description && /* @__PURE__ */ jsx("div", { className: "text-xs text-(--text-tertiary) truncate", children: description })
|
|
1337
1352
|
] }),
|
|
1338
1353
|
/* @__PURE__ */ jsx(ChevronRight, { size: 16, className: "text-(--text-muted) shrink-0" })
|
|
@@ -1438,6 +1453,6 @@ function AvatarUploader({
|
|
|
1438
1453
|
);
|
|
1439
1454
|
}
|
|
1440
1455
|
|
|
1441
|
-
export { AccountLockedCard, ActiveBadge, AvatarUploader, BackgroundEffects, Banner, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, DeprecatedBadge, ErrorBoundary, FAQ, FeatureLockedState, FellowBadge, FellowsBanner, LLMCopyButton, LinkRow, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, NotificationBell, NotificationItem, NotificationPanel, PageEmptyState, PageErrorState, PageHeader, PageLoadingState, SessionItem, SettingRow, Sidebar, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
|
|
1456
|
+
export { AccountLockedCard, ActiveBadge, AvatarUploader, BackgroundEffects, Banner, BlogCard, BlogPagination, BlogPostHeader, CapabilityBadge, CategoryFilter, CodeBlock, CodeDemo, ConnectedAccountRow, DeprecatedBadge, ErrorBoundary, FAQ, FeatureLockedState, FellowBadge, FellowsBanner, LLMCopyButton, LinkRow, MediaEmptyState, MediaErrorState, MediaLoadingState, MediaPageHeader, MetricBar, NotificationBell, NotificationItem, NotificationPanel, PageEmptyState, PageErrorState, PageHeader, PageLayout, PageLoadingState, SessionItem, SettingRow, Sidebar, SimplePagination, SourceBadge, StatCard, StatusBadge, ViewOptions };
|
|
1442
1457
|
//# sourceMappingURL=patterns.js.map
|
|
1443
1458
|
//# sourceMappingURL=patterns.js.map
|