orbital-ds 0.28.0 → 0.30.0
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/AGENTS.md +303 -273
- package/components.manifest.json +526 -12
- package/dist/hooks/use-ds-messages.d.ts +205 -0
- package/dist/lib/auth-better-auth.d.ts +29 -0
- package/dist/lib/auth-better-auth.js +60 -0
- package/dist/lib/auth-flow.d.ts +83 -0
- package/dist/lib/auth-flow.js +152 -0
- package/dist/lib/auth-providers.d.ts +194 -0
- package/dist/lib/auth-providers.js +64 -0
- package/dist/lib/auth.d.ts +68 -0
- package/dist/lib/auth.js +110 -0
- package/dist/lib/header-control.d.ts +4 -0
- package/dist/lib/header-control.js +14 -0
- package/dist/lib/i18n.d.ts +205 -0
- package/dist/lib/i18n.js +624 -3
- package/dist/ui/app-bar.d.ts +10 -0
- package/dist/ui/app-bar.js +51 -0
- package/dist/ui/attachment.js +1 -1
- package/dist/ui/auth-backdrop.d.ts +20 -0
- package/dist/ui/auth-backdrop.js +137 -0
- package/dist/ui/auth-form.d.ts +111 -0
- package/dist/ui/auth-form.js +531 -0
- package/dist/ui/auth-layout.d.ts +70 -0
- package/dist/ui/auth-layout.js +283 -0
- package/dist/ui/auth-parts.d.ts +43 -0
- package/dist/ui/auth-parts.js +159 -0
- package/dist/ui/auth-status.d.ts +23 -0
- package/dist/ui/auth-status.js +99 -0
- package/dist/ui/badge.js +2 -2
- package/dist/ui/button.js +1 -1
- package/dist/ui/connected-accounts.d.ts +25 -0
- package/dist/ui/connected-accounts.js +89 -0
- package/dist/ui/content-card.d.ts +6 -2
- package/dist/ui/content-card.js +27 -3
- package/dist/ui/dropzone.js +1 -1
- package/dist/ui/empty-state.d.ts +10 -1
- package/dist/ui/empty-state.js +28 -7
- package/dist/ui/error-page.d.ts +10 -1
- package/dist/ui/error-page.js +74 -28
- package/dist/ui/icon-tile.d.ts +1 -1
- package/dist/ui/input-otp.js +2 -1
- package/dist/ui/item.js +1 -1
- package/dist/ui/legend.js +1 -1
- package/dist/ui/locale-switcher.d.ts +19 -0
- package/dist/ui/locale-switcher.js +54 -0
- package/dist/ui/menubar.js +1 -1
- package/dist/ui/message-scroller.js +1 -1
- package/dist/ui/mfa-challenge.d.ts +33 -0
- package/dist/ui/mfa-challenge.js +214 -0
- package/dist/ui/mfa-setup.d.ts +29 -0
- package/dist/ui/mfa-setup.js +196 -0
- package/dist/ui/navigation-menu.js +2 -2
- package/dist/ui/notice-review.d.ts +1 -0
- package/dist/ui/notifications.d.ts +12 -2
- package/dist/ui/notifications.js +28 -5
- package/dist/ui/oauth-consent.d.ts +54 -0
- package/dist/ui/oauth-consent.js +208 -0
- package/dist/ui/passkey-list.d.ts +17 -0
- package/dist/ui/passkey-list.js +112 -0
- package/dist/ui/password-input.d.ts +5 -0
- package/dist/ui/password-input.js +77 -0
- package/dist/ui/session-list.d.ts +19 -0
- package/dist/ui/session-list.js +70 -0
- package/dist/ui/session-timeout.d.ts +13 -0
- package/dist/ui/session-timeout.js +87 -0
- package/dist/ui/sidebar.d.ts +27 -5
- package/dist/ui/sidebar.js +56 -11
- package/dist/ui/sign-out-dialog.d.ts +17 -0
- package/dist/ui/sign-out-dialog.js +82 -0
- package/dist/ui/stat-group.d.ts +1 -1
- package/dist/ui/stat-group.js +6 -2
- package/dist/ui/stat.d.ts +24 -5
- package/dist/ui/stat.js +124 -19
- package/dist/ui/status-badge.d.ts +1 -1
- package/dist/ui/theme-toggle.d.ts +14 -0
- package/dist/ui/theme-toggle.js +112 -0
- package/dist/ui/toggle.js +2 -2
- package/dist/ui/week-strip.js +1 -1
- package/docs/CONTRACT.md +1 -1
- package/docs/designer/patrones.md +27 -0
- package/docs/designer/revision.md +8 -0
- package/package.json +3 -2
- package/scripts/brand-core.d.mts +2 -0
- package/scripts/brand-core.mjs +21 -1
- package/scripts/cli.mjs +452 -452
- package/scripts/doctor.mjs +3 -0
- package/scripts/init.mjs +7 -3
- package/dist/motion.css +0 -146
- package/dist/styles.css +0 -1240
- package/dist/themes/fractalia.css +0 -549
- package/dist/themes/fractalia.fonts.css +0 -3
- package/dist/themes/fractalia.guide.md +0 -86
- package/dist/themes/fractalia.meta.json +0 -112
- package/dist/themes/fractalia.scoped.css +0 -549
- package/dist/themes/fractalia.tokens.json +0 -39
- package/dist/themes/friendly.css +0 -367
- package/dist/themes/friendly.fonts.css +0 -2
- package/dist/themes/friendly.guide.md +0 -38
- package/dist/themes/friendly.meta.json +0 -82
- package/dist/themes/friendly.scoped.css +0 -367
- package/dist/themes/friendly.tokens.json +0 -45
- package/dist/themes/lagoon.css +0 -348
- package/dist/themes/lagoon.fonts.css +0 -2
- package/dist/themes/lagoon.guide.md +0 -47
- package/dist/themes/lagoon.meta.json +0 -84
- package/dist/themes/lagoon.scoped.css +0 -348
- package/dist/themes/lagoon.tokens.json +0 -49
- package/dist/themes/liquid.css +0 -502
- package/dist/themes/liquid.fonts.css +0 -7
- package/dist/themes/liquid.guide.md +0 -82
- package/dist/themes/liquid.meta.json +0 -134
- package/dist/themes/liquid.scoped.css +0 -502
- package/dist/themes/liquid.tokens.json +0 -47
- package/dist/themes/qratia.css +0 -260
- package/dist/themes/qratia.fonts.css +0 -2
- package/dist/themes/qratia.guide.md +0 -34
- package/dist/themes/qratia.meta.json +0 -49
- package/dist/themes/qratia.scoped.css +0 -260
- package/dist/themes/qratia.tokens.json +0 -49
- package/dist/themes/tactile.css +0 -588
- package/dist/themes/tactile.fonts.css +0 -3
- package/dist/themes/tactile.guide.md +0 -82
- package/dist/themes/tactile.meta.json +0 -182
- package/dist/themes/tactile.scoped.css +0 -588
- package/dist/themes/tactile.tokens.json +0 -42
- package/dist/themes/twitter.css +0 -357
- package/dist/themes/twitter.fonts.css +0 -6
- package/dist/themes/twitter.guide.md +0 -35
- package/dist/themes/twitter.meta.json +0 -90
- package/dist/themes/twitter.scoped.css +0 -357
- package/dist/themes/twitter.tokens.json +0 -45
- package/dist/themes/zyro.css +0 -434
- package/dist/themes/zyro.fonts.css +0 -2
- package/dist/themes/zyro.guide.md +0 -33
- package/dist/themes/zyro.meta.json +0 -74
- package/dist/themes/zyro.scoped.css +0 -434
- package/dist/themes/zyro.tokens.json +0 -46
package/dist/ui/sidebar.d.ts
CHANGED
|
@@ -6,9 +6,15 @@ import { Button } from './button.js';
|
|
|
6
6
|
import { Input } from './input.js';
|
|
7
7
|
import { Separator } from './separator.js';
|
|
8
8
|
import { TooltipContent } from './tooltip.js';
|
|
9
|
+
import { DsDensity } from '../lib/presets.js';
|
|
9
10
|
import '@base-ui/react/separator';
|
|
10
11
|
import '@base-ui/react/tooltip';
|
|
11
12
|
|
|
13
|
+
type SidebarPreset = "app" | "workspace" | "admin" | "focus";
|
|
14
|
+
type SidebarVariant = "sidebar" | "floating" | "inset";
|
|
15
|
+
type SidebarCollapsible = "offcanvas" | "icon" | "none";
|
|
16
|
+
type SidebarTone = "default" | "brand" | "contrast";
|
|
17
|
+
type SidebarIndicator = "fill" | "bar";
|
|
12
18
|
type SidebarContextProps = {
|
|
13
19
|
state: "expanded" | "collapsed";
|
|
14
20
|
open: boolean;
|
|
@@ -24,14 +30,30 @@ declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: se
|
|
|
24
30
|
open?: boolean;
|
|
25
31
|
onOpenChange?: (open: boolean) => void;
|
|
26
32
|
}): React.JSX.Element;
|
|
27
|
-
declare function Sidebar({ side, variant, collapsible, className, children, dir, ...props }: React.ComponentProps<"div"> & {
|
|
33
|
+
declare function Sidebar({ side, preset, variant: variantProp, collapsible: collapsibleProp, density: densityProp, tone, indicator, className, children, dir, ...props }: React.ComponentProps<"div"> & {
|
|
28
34
|
side?: "left" | "right";
|
|
29
|
-
variant
|
|
30
|
-
|
|
35
|
+
/** Intención: fija variant, collapsible y density por defecto (las props explícitas mandan). */
|
|
36
|
+
preset?: SidebarPreset;
|
|
37
|
+
variant?: SidebarVariant;
|
|
38
|
+
collapsible?: SidebarCollapsible;
|
|
39
|
+
/** Altura de las filas: compact (backoffice), default o comfortable. */
|
|
40
|
+
density?: DsDensity;
|
|
41
|
+
/** Color del lateral: el del tema, el de la marca o invertido. */
|
|
42
|
+
tone?: SidebarTone;
|
|
43
|
+
/** Cómo se marca el destino activo: fondo o fondo y barra al inicio. */
|
|
44
|
+
indicator?: SidebarIndicator;
|
|
31
45
|
}): React.JSX.Element;
|
|
32
46
|
declare function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
33
47
|
declare function SidebarRail({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
34
|
-
|
|
48
|
+
type SidebarSurface = "floating" | "flat" | "glass";
|
|
49
|
+
/**
|
|
50
|
+
* Lienzo del contenido junto al lateral. Con `variant="inset"` flota con margen, radio y sombra.
|
|
51
|
+
* `surface`: floating (por defecto) · flat (sin sombra, con filete) · glass (translúcido con desenfoque).
|
|
52
|
+
* @note `glass` solo luce si hay algo detrás (fondo de la app o imagen); en el resto, `floating` o `flat`.
|
|
53
|
+
*/
|
|
54
|
+
declare function SidebarInset({ className, surface, ...props }: React.ComponentProps<"main"> & {
|
|
55
|
+
surface?: SidebarSurface;
|
|
56
|
+
}): React.JSX.Element;
|
|
35
57
|
declare function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>): React.JSX.Element;
|
|
36
58
|
declare function SidebarHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
37
59
|
declare function SidebarFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
@@ -65,4 +87,4 @@ declare function SidebarMenuSubButton({ size, isActive, className, render, ...pr
|
|
|
65
87
|
isActive?: boolean;
|
|
66
88
|
}): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
67
89
|
|
|
68
|
-
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|
|
90
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, type SidebarIndicator, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, type SidebarPreset, SidebarProvider, SidebarRail, SidebarSeparator, type SidebarSurface, type SidebarTone, SidebarTrigger, useSidebar };
|
package/dist/ui/sidebar.js
CHANGED
|
@@ -24,12 +24,30 @@ import {
|
|
|
24
24
|
} from "./tooltip.js";
|
|
25
25
|
import { PanelLeftIcon } from "lucide-react";
|
|
26
26
|
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
27
|
+
import { dsWarn } from "../lib/presets.js";
|
|
27
28
|
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
28
29
|
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
29
30
|
const SIDEBAR_WIDTH = "var(--ds-sidebar-w)";
|
|
30
31
|
const SIDEBAR_WIDTH_MOBILE = "var(--ds-sidebar-w-mobile)";
|
|
31
32
|
const SIDEBAR_WIDTH_ICON = "var(--ds-sidebar-rail-w, 4rem)";
|
|
32
33
|
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
34
|
+
const SIDEBAR_TONE = {
|
|
35
|
+
default: "",
|
|
36
|
+
brand: "[--sidebar:var(--ds-sidebar-brand-bg)] [--sidebar-foreground:var(--ds-sidebar-brand-fg)] [--sidebar-accent:var(--ds-sidebar-brand-accent)] [--sidebar-accent-foreground:var(--ds-sidebar-brand-fg)] [--sidebar-border:var(--ds-sidebar-brand-border)] [--sidebar-primary:var(--ds-sidebar-brand-fg)] [--sidebar-primary-foreground:var(--ds-sidebar-brand-bg)] [--ds-sidebar-label:var(--ds-sidebar-brand-label)]",
|
|
37
|
+
contrast: "[--sidebar:var(--ds-sidebar-contrast-bg)] [--sidebar-foreground:var(--ds-sidebar-contrast-fg)] [--sidebar-accent:var(--ds-sidebar-contrast-accent)] [--sidebar-accent-foreground:var(--ds-sidebar-contrast-fg)] [--sidebar-border:var(--ds-sidebar-contrast-border)] [--sidebar-primary:var(--ds-sidebar-contrast-fg)] [--sidebar-primary-foreground:var(--ds-sidebar-contrast-bg)] [--ds-sidebar-label:var(--ds-sidebar-contrast-label)]"
|
|
38
|
+
};
|
|
39
|
+
const SIDEBAR_PRESETS = {
|
|
40
|
+
app: { variant: "floating", collapsible: "icon", density: "default" },
|
|
41
|
+
workspace: { variant: "inset", collapsible: "icon", density: "default" },
|
|
42
|
+
admin: { variant: "sidebar", collapsible: "icon", density: "compact" },
|
|
43
|
+
focus: { variant: "sidebar", collapsible: "offcanvas", density: "default" }
|
|
44
|
+
};
|
|
45
|
+
const SIDEBAR_BASE = { variant: "sidebar", collapsible: "offcanvas", density: "default" };
|
|
46
|
+
const SIDEBAR_DENSITY = {
|
|
47
|
+
compact: "[--ds-sidebar-item-h:var(--ds-sidebar-item-h-compact)] [--ds-sidebar-sub-item-h:var(--ds-sidebar-sub-item-h-compact)]",
|
|
48
|
+
default: "",
|
|
49
|
+
comfortable: "[--ds-sidebar-item-h:var(--ds-sidebar-item-h-comfortable)]"
|
|
50
|
+
};
|
|
33
51
|
const SidebarContext = React.createContext(null);
|
|
34
52
|
function useSidebar() {
|
|
35
53
|
const context = React.useContext(SidebarContext);
|
|
@@ -109,8 +127,12 @@ function SidebarProvider({
|
|
|
109
127
|
}
|
|
110
128
|
function Sidebar({
|
|
111
129
|
side = "left",
|
|
112
|
-
|
|
113
|
-
|
|
130
|
+
preset,
|
|
131
|
+
variant: variantProp,
|
|
132
|
+
collapsible: collapsibleProp,
|
|
133
|
+
density: densityProp,
|
|
134
|
+
tone = "default",
|
|
135
|
+
indicator = "fill",
|
|
114
136
|
className,
|
|
115
137
|
children,
|
|
116
138
|
dir,
|
|
@@ -118,13 +140,27 @@ function Sidebar({
|
|
|
118
140
|
}) {
|
|
119
141
|
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
120
142
|
const t = useDsMessages();
|
|
143
|
+
const base = preset ? SIDEBAR_PRESETS[preset] : SIDEBAR_BASE;
|
|
144
|
+
const variant = variantProp ?? base.variant;
|
|
145
|
+
const collapsible = collapsibleProp ?? base.collapsible;
|
|
146
|
+
const density = densityProp ?? base.density;
|
|
147
|
+
const hooks = { "data-preset": preset, "data-density": density, "data-tone": tone, "data-indicator": indicator };
|
|
148
|
+
const look = cn(SIDEBAR_DENSITY[density], SIDEBAR_TONE[tone]);
|
|
149
|
+
React.useEffect(() => {
|
|
150
|
+
if (collapsible === "none" && variant !== "sidebar")
|
|
151
|
+
dsWarn("Sidebar", `variant="${variant}" has no effect with collapsible="none" (a fixed panel is always flat).`);
|
|
152
|
+
if (preset === "focus" && collapsible === "icon")
|
|
153
|
+
dsWarn("Sidebar", 'preset="focus" hides the sidebar to make room; collapsible="icon" keeps a rail, use preset="workspace" instead.');
|
|
154
|
+
}, [collapsible, variant, preset]);
|
|
121
155
|
if (collapsible === "none") {
|
|
122
156
|
return /* @__PURE__ */ jsx(
|
|
123
157
|
"div",
|
|
124
158
|
{
|
|
125
159
|
"data-slot": "sidebar",
|
|
160
|
+
...hooks,
|
|
126
161
|
className: cn(
|
|
127
|
-
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
|
162
|
+
"group flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
|
163
|
+
look,
|
|
128
164
|
className
|
|
129
165
|
),
|
|
130
166
|
...props,
|
|
@@ -141,7 +177,8 @@ function Sidebar({
|
|
|
141
177
|
"data-sidebar": "sidebar",
|
|
142
178
|
"data-slot": "sidebar",
|
|
143
179
|
"data-mobile": "true",
|
|
144
|
-
|
|
180
|
+
...hooks,
|
|
181
|
+
className: cn("group w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", look),
|
|
145
182
|
style: {
|
|
146
183
|
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
147
184
|
},
|
|
@@ -159,7 +196,8 @@ function Sidebar({
|
|
|
159
196
|
return /* @__PURE__ */ jsxs(
|
|
160
197
|
"div",
|
|
161
198
|
{
|
|
162
|
-
className: "group peer hidden text-sidebar-foreground md:block",
|
|
199
|
+
className: cn("group peer hidden text-sidebar-foreground md:block", look),
|
|
200
|
+
...hooks,
|
|
163
201
|
"data-state": state,
|
|
164
202
|
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
165
203
|
"data-variant": variant,
|
|
@@ -257,13 +295,20 @@ function SidebarRail({ className, ...props }) {
|
|
|
257
295
|
}
|
|
258
296
|
);
|
|
259
297
|
}
|
|
260
|
-
|
|
298
|
+
const SIDEBAR_SURFACE = {
|
|
299
|
+
floating: "",
|
|
300
|
+
flat: "[--ds-canvas-shadow:var(--ds-canvas-flat-shadow)]",
|
|
301
|
+
glass: "[--ds-canvas-bg:var(--ds-canvas-glass-bg)] [--ds-canvas-blur:var(--ds-canvas-glass-blur)]"
|
|
302
|
+
};
|
|
303
|
+
function SidebarInset({ className, surface = "floating", ...props }) {
|
|
261
304
|
return /* @__PURE__ */ jsx(
|
|
262
305
|
"main",
|
|
263
306
|
{
|
|
264
307
|
"data-slot": "sidebar-inset",
|
|
308
|
+
"data-surface": surface,
|
|
265
309
|
className: cn(
|
|
266
|
-
"relative flex w-full flex-1 flex-col bg-
|
|
310
|
+
"relative flex w-full flex-1 flex-col bg-(--ds-canvas-bg) backdrop-blur-(--ds-canvas-blur) md:peer-data-[variant=inset]:m-(--ds-sidebar-pad) md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-(--ds-canvas-radius) md:peer-data-[variant=inset]:shadow-(--ds-canvas-shadow) md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-(--ds-sidebar-pad)",
|
|
311
|
+
SIDEBAR_SURFACE[surface],
|
|
267
312
|
className
|
|
268
313
|
),
|
|
269
314
|
...props
|
|
@@ -279,7 +324,7 @@ function SidebarInput({
|
|
|
279
324
|
{
|
|
280
325
|
"data-slot": "sidebar-input",
|
|
281
326
|
"data-sidebar": "input",
|
|
282
|
-
className: cn("h-(--ds-control-h-sm) w-full bg-background shadow-none", className),
|
|
327
|
+
className: cn("h-(--ds-control-h-sm) w-full bg-background shadow-none group-data-[collapsible=icon]:hidden", className),
|
|
283
328
|
...props
|
|
284
329
|
}
|
|
285
330
|
);
|
|
@@ -291,7 +336,7 @@ function SidebarHeader({ className, ...props }) {
|
|
|
291
336
|
"data-slot": "sidebar-header",
|
|
292
337
|
"data-sidebar": "header",
|
|
293
338
|
className: cn(
|
|
294
|
-
"flex flex-col gap-2 p-2",
|
|
339
|
+
"flex flex-col gap-2 p-2 group-data-[collapsible=icon]:items-center",
|
|
295
340
|
className
|
|
296
341
|
),
|
|
297
342
|
...props
|
|
@@ -304,7 +349,7 @@ function SidebarFooter({ className, ...props }) {
|
|
|
304
349
|
{
|
|
305
350
|
"data-slot": "sidebar-footer",
|
|
306
351
|
"data-sidebar": "footer",
|
|
307
|
-
className: cn("flex flex-col gap-2 p-2", className),
|
|
352
|
+
className: cn("flex flex-col gap-2 p-2 group-data-[collapsible=icon]:items-center", className),
|
|
308
353
|
...props
|
|
309
354
|
}
|
|
310
355
|
);
|
|
@@ -429,7 +474,7 @@ function SidebarMenuItem({ className, ...props }) {
|
|
|
429
474
|
);
|
|
430
475
|
}
|
|
431
476
|
const sidebarMenuButtonVariants = cva(
|
|
432
|
-
"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-(--ds-sidebar-item-radius) px-3 py-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,background-color,color] duration-(--ds-motion-snap) ease-(--ds-ease-standard) group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:mx-auto hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-(length:--ds-ring-width) active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-(--ds-disabled-opacity) aria-disabled:pointer-events-none aria-disabled:opacity-(--ds-disabled-opacity) data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:font-(--ds-nav-active-weight) data-[active=true]:text-sidebar-accent-foreground [&_svg]:shrink-0 [&>span:last-child]:truncate",
|
|
477
|
+
"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-(--ds-sidebar-item-radius) px-3 py-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding,background-color,color] duration-(--ds-motion-snap) ease-(--ds-ease-standard) group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:mx-auto group-data-[collapsible=icon]:justify-center group-data-[collapsible=icon]:gap-0 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:group-has-data-[sidebar=menu-action]/menu-item:pr-0 group-data-[collapsible=icon]:[&>div]:hidden group-data-[collapsible=icon]:[&>span:last-child:not([data-slot=avatar]):not([data-slot=icon-tile])]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-(length:--ds-ring-width) active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-(--ds-disabled-opacity) aria-disabled:pointer-events-none aria-disabled:opacity-(--ds-disabled-opacity) data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-[active=true]:bg-sidebar-accent data-[active=true]:font-(--ds-nav-active-weight) data-[active=true]:text-sidebar-accent-foreground group-data-[indicator=bar]:data-[active=true]:shadow-[inset_var(--ds-sidebar-bar-w)_0_0_0_var(--sidebar-primary)] [&_svg]:shrink-0 [&>span:last-child]:truncate",
|
|
433
478
|
{
|
|
434
479
|
variants: {
|
|
435
480
|
variant: {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function SignOutDialog({ trigger, open, onOpenChange, onSignOut, allDevices, title, description, }: {
|
|
4
|
+
/** Elemento que abre el diálogo (un botón o un elemento de menú). */
|
|
5
|
+
trigger?: React.ReactElement;
|
|
6
|
+
open?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
onSignOut: (options: {
|
|
9
|
+
everywhere: boolean;
|
|
10
|
+
}) => void | Promise<void>;
|
|
11
|
+
/** Casilla «en todos los dispositivos». */
|
|
12
|
+
allDevices?: boolean;
|
|
13
|
+
title?: React.ReactNode;
|
|
14
|
+
description?: React.ReactNode;
|
|
15
|
+
}): React.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { SignOutDialog };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { LogOutIcon } from "lucide-react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import {
|
|
7
|
+
AlertDialog,
|
|
8
|
+
AlertDialogAction,
|
|
9
|
+
AlertDialogCancel,
|
|
10
|
+
AlertDialogContent,
|
|
11
|
+
AlertDialogDescription,
|
|
12
|
+
AlertDialogFooter,
|
|
13
|
+
AlertDialogHeader,
|
|
14
|
+
AlertDialogMedia,
|
|
15
|
+
AlertDialogTitle,
|
|
16
|
+
AlertDialogTrigger
|
|
17
|
+
} from "./alert-dialog.js";
|
|
18
|
+
import { Checkbox } from "./checkbox.js";
|
|
19
|
+
import { Label } from "./label.js";
|
|
20
|
+
import { Spinner } from "./spinner.js";
|
|
21
|
+
function SignOutDialog({
|
|
22
|
+
trigger,
|
|
23
|
+
open,
|
|
24
|
+
onOpenChange,
|
|
25
|
+
onSignOut,
|
|
26
|
+
allDevices = false,
|
|
27
|
+
title,
|
|
28
|
+
description
|
|
29
|
+
}) {
|
|
30
|
+
const t = useDsMessages();
|
|
31
|
+
const uid = React.useId();
|
|
32
|
+
const [inner, setInner] = React.useState(false);
|
|
33
|
+
const [everywhere, setEverywhere] = React.useState(false);
|
|
34
|
+
const [pending, setPending] = React.useState(false);
|
|
35
|
+
const isOpen = open ?? inner;
|
|
36
|
+
const setOpen = (v) => {
|
|
37
|
+
if (pending) return;
|
|
38
|
+
setInner(v);
|
|
39
|
+
onOpenChange?.(v);
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ jsxs(AlertDialog, { open: isOpen, onOpenChange: setOpen, children: [
|
|
42
|
+
trigger ? /* @__PURE__ */ jsx(AlertDialogTrigger, { render: trigger }) : null,
|
|
43
|
+
/* @__PURE__ */ jsxs(AlertDialogContent, { "data-slot": "sign-out-dialog", size: "sm", children: [
|
|
44
|
+
/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
|
|
45
|
+
/* @__PURE__ */ jsx(AlertDialogMedia, { children: /* @__PURE__ */ jsx(LogOutIcon, {}) }),
|
|
46
|
+
/* @__PURE__ */ jsx(AlertDialogTitle, { children: title ?? t.authSignOutTitle }),
|
|
47
|
+
/* @__PURE__ */ jsx(AlertDialogDescription, { children: description ?? t.authSignOutBody })
|
|
48
|
+
] }),
|
|
49
|
+
allDevices ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-2.5", children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Checkbox, { id: `${uid}-all`, checked: everywhere, onCheckedChange: (v) => setEverywhere(v === true) }),
|
|
51
|
+
/* @__PURE__ */ jsx(Label, { htmlFor: `${uid}-all`, className: "text-sm font-normal", children: t.authSignOutAllDevices })
|
|
52
|
+
] }) : null,
|
|
53
|
+
/* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
|
|
54
|
+
/* @__PURE__ */ jsx(AlertDialogCancel, { disabled: pending, children: t.authCancel }),
|
|
55
|
+
/* @__PURE__ */ jsxs(
|
|
56
|
+
AlertDialogAction,
|
|
57
|
+
{
|
|
58
|
+
"aria-busy": pending || void 0,
|
|
59
|
+
disabled: pending,
|
|
60
|
+
onClick: async () => {
|
|
61
|
+
setPending(true);
|
|
62
|
+
try {
|
|
63
|
+
await onSignOut({ everywhere });
|
|
64
|
+
setInner(false);
|
|
65
|
+
onOpenChange?.(false);
|
|
66
|
+
} finally {
|
|
67
|
+
setPending(false);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
children: [
|
|
71
|
+
pending ? /* @__PURE__ */ jsx(Spinner, {}) : null,
|
|
72
|
+
t.authSignOut
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
)
|
|
76
|
+
] })
|
|
77
|
+
] })
|
|
78
|
+
] });
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
SignOutDialog
|
|
82
|
+
};
|
package/dist/ui/stat-group.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
type StatGroupPreset = "overview" | "compact" | "comparison";
|
|
3
|
+
type StatGroupPreset = "overview" | "compact" | "comparison" | "strip";
|
|
4
4
|
declare function StatGroup({ preset, className, ...props }: React.ComponentProps<"div"> & {
|
|
5
5
|
preset?: StatGroupPreset;
|
|
6
6
|
}): React.JSX.Element;
|
package/dist/ui/stat-group.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Panel } from "./panel.js";
|
|
3
4
|
const LAYOUT = {
|
|
4
5
|
overview: "gap-(--ds-section-gap) grid-cols-1 @[30rem]:grid-cols-2 @[56.25rem]:grid-cols-4",
|
|
5
6
|
compact: "gap-3 grid-cols-2 @[40rem]:grid-cols-4",
|
|
6
|
-
comparison: "gap-(--ds-section-gap) grid-cols-1 @[32.5rem]:grid-cols-2"
|
|
7
|
+
comparison: "gap-(--ds-section-gap) grid-cols-1 @[32.5rem]:grid-cols-2",
|
|
8
|
+
// Filetes: horizontales en estrecho; verticales cuando caben en fila (auto-cols reparte el ancho).
|
|
9
|
+
strip: "grid-cols-1 divide-y divide-border @[40rem]:grid-flow-col @[40rem]:auto-cols-fr @[40rem]:divide-y-0 @[40rem]:divide-x rtl:@[40rem]:divide-x-reverse *:p-(--ds-panel-p)"
|
|
7
10
|
};
|
|
8
11
|
function StatGroup({
|
|
9
12
|
preset = "overview",
|
|
10
13
|
className,
|
|
11
14
|
...props
|
|
12
15
|
}) {
|
|
13
|
-
|
|
16
|
+
const grid = /* @__PURE__ */ jsx("div", { className: cn("grid min-w-0", LAYOUT[preset], className), ...props });
|
|
17
|
+
return /* @__PURE__ */ jsx("div", { "data-slot": "stat-group", "data-preset": preset, className: "@container min-w-0", children: preset === "strip" ? /* @__PURE__ */ jsx(Panel, { className: "overflow-hidden p-0", children: grid }) : grid });
|
|
14
18
|
}
|
|
15
19
|
export {
|
|
16
20
|
StatGroup
|
package/dist/ui/stat.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as class_variance_authority_types from 'class-variance-authority/types';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
import { IconTile } from './icon-tile.js';
|
|
3
4
|
import { Panel } from './panel.js';
|
|
4
|
-
import '@base-ui/react/use-render';
|
|
5
5
|
import 'class-variance-authority';
|
|
6
|
+
import '@base-ui/react/use-render';
|
|
6
7
|
|
|
7
|
-
type StatVariant = "card" | "inline";
|
|
8
|
+
type StatVariant = "card" | "plain" | "inline";
|
|
8
9
|
type StatSize = "sm" | "md" | "lg";
|
|
9
10
|
type StatTone = "neutral" | "good" | "warn" | "bad";
|
|
10
11
|
declare const statVariants: (props?: ({
|
|
11
|
-
variant?: "inline" | "card" | null | undefined;
|
|
12
|
+
variant?: "inline" | "plain" | "card" | null | undefined;
|
|
12
13
|
tone?: "neutral" | "good" | "warn" | "bad" | null | undefined;
|
|
13
14
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
14
15
|
type StatProps = Omit<React.ComponentProps<"div">, "ref"> & {
|
|
@@ -43,8 +44,10 @@ type StatValueProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
|
43
44
|
loading?: boolean;
|
|
44
45
|
/** Signo que sustituye a la cifra cuando no hay dato. */
|
|
45
46
|
placeholder?: React.ReactNode;
|
|
47
|
+
/** La cifra cuenta desde 0 (o desde el valor anterior) con el ritmo del tema. Solo números. */
|
|
48
|
+
animate?: boolean;
|
|
46
49
|
};
|
|
47
|
-
declare function StatValue({ value, unit, prefix, format, fractionDigits, reason, loading, placeholder, className, ...props }: StatValueProps): React.JSX.Element;
|
|
50
|
+
declare function StatValue({ value, unit, prefix, format, fractionDigits, reason, loading, placeholder, animate, className, ...props }: StatValueProps): React.JSX.Element;
|
|
48
51
|
type StatDeltaPolarity = "higher-is-better" | "lower-is-better" | "neutral";
|
|
49
52
|
type StatDeltaProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
50
53
|
/** Variación en PUNTOS PORCENTUALES (4.2 = +4,2 %). null = sin dato (nunca 0). */
|
|
@@ -59,6 +62,22 @@ declare function StatDelta({ value, polarity, fractionDigits, className, childre
|
|
|
59
62
|
declare function StatDescription({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
60
63
|
/** Hueco para una Sparkline u otro gráfico mínimo bajo la cifra. */
|
|
61
64
|
declare function StatChart({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
65
|
+
/** Fila superior: la etiqueta a un lado y un StatIcon, un menú o un enlace al otro. */
|
|
66
|
+
declare function StatHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
67
|
+
/** Icono del KPI en una baldosa; toma el color del tono del Stat salvo que se indique otro. Decorativo. */
|
|
68
|
+
declare function StatIcon({ tone, className, ...props }: Omit<React.ComponentProps<typeof IconTile>, "tone" | "size"> & {
|
|
69
|
+
tone?: React.ComponentProps<typeof IconTile>["tone"];
|
|
70
|
+
}): React.JSX.Element;
|
|
71
|
+
type StatProgressProps = Omit<React.ComponentProps<"div">, "children"> & {
|
|
72
|
+
/** Valor actual (misma unidad que `target`). */
|
|
73
|
+
value: number | null | undefined;
|
|
74
|
+
/** Objetivo o máximo. */
|
|
75
|
+
target: number;
|
|
76
|
+
/** Texto propio en lugar de «N % del objetivo». */
|
|
77
|
+
children?: React.ReactNode;
|
|
78
|
+
};
|
|
79
|
+
/** Avance hacia un objetivo: barra con el color del tono y el porcentaje en texto (no solo color). */
|
|
80
|
+
declare function StatProgress({ value, target, className, children, ...props }: StatProgressProps): React.JSX.Element;
|
|
62
81
|
type StatSwatchProps = React.ComponentProps<"span"> & {
|
|
63
82
|
/** Color de serie del tema (--chart-1..5). */
|
|
64
83
|
series?: 1 | 2 | 3 | 4 | 5;
|
|
@@ -68,4 +87,4 @@ type StatSwatchProps = React.ComponentProps<"span"> & {
|
|
|
68
87
|
/** Muestra de color que liga el KPI con su serie en un gráfico. Decorativa. */
|
|
69
88
|
declare function StatSwatch({ series, tone, className, ...props }: StatSwatchProps): React.JSX.Element;
|
|
70
89
|
|
|
71
|
-
export { Stat, StatChart, StatDelta, type StatDeltaPolarity, type StatDeltaProps, StatDescription, StatLabel, type StatProps, type StatSize, StatSwatch, type StatSwatchProps, type StatTone, StatValue, type StatValueProps, type StatVariant, statVariants };
|
|
90
|
+
export { Stat, StatChart, StatDelta, type StatDeltaPolarity, type StatDeltaProps, StatDescription, StatHeader, StatIcon, StatLabel, StatProgress, type StatProgressProps, type StatProps, type StatSize, StatSwatch, type StatSwatchProps, type StatTone, StatValue, type StatValueProps, type StatVariant, statVariants };
|
package/dist/ui/stat.js
CHANGED
|
@@ -5,15 +5,18 @@ import { cva } from "class-variance-authority";
|
|
|
5
5
|
import { ArrowDownIcon, ArrowUpIcon, MinusIcon } from "lucide-react";
|
|
6
6
|
import { useDsLocale, useDsMessages } from "../hooks/use-ds-messages.js";
|
|
7
7
|
import { cn } from "../lib/utils.js";
|
|
8
|
+
import { readDsTransition } from "../lib/motion.js";
|
|
8
9
|
import { eyebrowClassName } from "./eyebrow.js";
|
|
10
|
+
import { IconTile } from "./icon-tile.js";
|
|
9
11
|
import { Panel } from "./panel.js";
|
|
10
12
|
import { Skeleton } from "./skeleton.js";
|
|
11
13
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
12
|
-
const StatContext = React.createContext({ variant: "card", size: "auto", labelId: "" });
|
|
13
|
-
const statVariants = cva("group/stat
|
|
14
|
+
const StatContext = React.createContext({ variant: "card", size: "auto", labelId: "", tone: "neutral" });
|
|
15
|
+
const statVariants = cva("group/stat min-w-0", {
|
|
14
16
|
variants: {
|
|
15
17
|
variant: {
|
|
16
|
-
card: "flex flex-col gap-1.5",
|
|
18
|
+
card: "@container/stat relative flex flex-col gap-1.5 overflow-hidden",
|
|
19
|
+
plain: "@container/stat flex flex-col gap-1.5",
|
|
17
20
|
inline: "inline-flex flex-wrap items-baseline gap-x-2 gap-y-1"
|
|
18
21
|
},
|
|
19
22
|
tone: {
|
|
@@ -24,19 +27,20 @@ const statVariants = cva("group/stat @container/stat min-w-0", {
|
|
|
24
27
|
}
|
|
25
28
|
},
|
|
26
29
|
compoundVariants: [
|
|
27
|
-
// Tarjeta:
|
|
30
|
+
// Tarjeta: barra de tono en el borde de inicio. Es una capa propia (no el borde), así se ve
|
|
31
|
+
// igual en los temas que quitan el borde a las tarjetas.
|
|
28
32
|
{
|
|
29
33
|
variant: "card",
|
|
30
34
|
tone: ["good", "warn", "bad"],
|
|
31
|
-
className: "
|
|
35
|
+
className: "before:pointer-events-none before:absolute before:inset-y-0 before:start-0 before:w-(--ds-stat-accent-w) before:content-['']"
|
|
32
36
|
},
|
|
33
|
-
{ variant: "card", tone: "good", className: "border-success/40
|
|
34
|
-
{ variant: "card", tone: "warn", className: "border-warning/40
|
|
35
|
-
{ variant: "card", tone: "bad", className: "border-danger/40
|
|
36
|
-
//
|
|
37
|
-
{ variant: "inline", tone: "good", className: "**:data-[slot=stat-value]:text-success" },
|
|
38
|
-
{ variant: "inline", tone: "warn", className: "**:data-[slot=stat-value]:text-warning" },
|
|
39
|
-
{ variant: "inline", tone: "bad", className: "**:data-[slot=stat-value]:text-danger" }
|
|
37
|
+
{ variant: "card", tone: "good", className: "border-success/40 before:bg-success" },
|
|
38
|
+
{ variant: "card", tone: "warn", className: "border-warning/40 before:bg-warning" },
|
|
39
|
+
{ variant: "card", tone: "bad", className: "border-danger/40 before:bg-danger" },
|
|
40
|
+
// Sin superficie o en línea: el estado colorea la cifra (pares de texto AA comprobados por check:ds).
|
|
41
|
+
{ variant: ["inline", "plain"], tone: "good", className: "**:data-[slot=stat-value-number]:text-success" },
|
|
42
|
+
{ variant: ["inline", "plain"], tone: "warn", className: "**:data-[slot=stat-value-number]:text-warning" },
|
|
43
|
+
{ variant: ["inline", "plain"], tone: "bad", className: "**:data-[slot=stat-value-number]:text-danger" }
|
|
40
44
|
],
|
|
41
45
|
defaultVariants: { variant: "card", tone: "neutral" }
|
|
42
46
|
});
|
|
@@ -49,7 +53,7 @@ const statValueSize = {
|
|
|
49
53
|
const statPressable = "cursor-pointer text-start outline-offset-2 transition-shadow duration-(--ds-motion-fast) ease-(--ds-ease-standard) hover:shadow-card-hover focus-visible:outline-solid focus-visible:outline-(length:--ds-ring-width) focus-visible:outline-(--ds-ring-color) data-active:outline-solid data-active:outline-(length:--ds-ring-width) data-active:outline-primary motion-reduce:transition-none";
|
|
50
54
|
function Stat({ className, variant = "card", size, tone = "neutral", render, pressed, children, ...props }) {
|
|
51
55
|
const labelId = React.useId();
|
|
52
|
-
const ctx = React.useMemo(() => ({ variant, size: size ?? "auto", labelId }), [variant, size, labelId]);
|
|
56
|
+
const ctx = React.useMemo(() => ({ variant, size: size ?? "auto", labelId, tone }), [variant, size, labelId, tone]);
|
|
53
57
|
const pulsable = variant === "card" && render != null;
|
|
54
58
|
const shared = {
|
|
55
59
|
"data-slot": "stat",
|
|
@@ -58,7 +62,7 @@ function Stat({ className, variant = "card", size, tone = "neutral", render, pre
|
|
|
58
62
|
"data-tone": tone,
|
|
59
63
|
className: cn(statVariants({ variant, tone }), pulsable && statPressable, className)
|
|
60
64
|
};
|
|
61
|
-
return /* @__PURE__ */ jsx(StatContext.Provider, { value: ctx, children: variant === "card" ? /* @__PURE__ */ jsx(
|
|
65
|
+
return /* @__PURE__ */ jsx(StatContext.Provider, { value: ctx, children: variant === "plain" ? /* @__PURE__ */ jsx("div", { role: "group", "aria-labelledby": labelId, ...shared, ...props, children }) : variant === "card" ? /* @__PURE__ */ jsx(
|
|
62
66
|
Panel,
|
|
63
67
|
{
|
|
64
68
|
...pulsable ? { render, "aria-pressed": pressed, "data-active": pressed ? "" : void 0 } : { role: "group", "aria-labelledby": labelId },
|
|
@@ -83,6 +87,37 @@ function StatLabel({ className, ...props }) {
|
|
|
83
87
|
const { labelId } = React.useContext(StatContext);
|
|
84
88
|
return /* @__PURE__ */ jsx(StatPart, { term: true, id: labelId, "data-slot": "stat-label", className: cn(eyebrowClassName, "min-w-0 text-balance break-words", className), ...props });
|
|
85
89
|
}
|
|
90
|
+
function useCountUp(target, enabled) {
|
|
91
|
+
const [shown, setShown] = React.useState(enabled && target != null ? 0 : target);
|
|
92
|
+
const from = React.useRef(enabled ? 0 : target);
|
|
93
|
+
React.useEffect(() => {
|
|
94
|
+
if (!enabled || target == null) {
|
|
95
|
+
setShown(target);
|
|
96
|
+
from.current = target;
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const { duration } = readDsTransition("slow");
|
|
100
|
+
const start = from.current ?? 0;
|
|
101
|
+
if (duration <= 0 || start === target) {
|
|
102
|
+
setShown(target);
|
|
103
|
+
from.current = target;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
let frame = 0;
|
|
107
|
+
const t0 = performance.now();
|
|
108
|
+
const tick = (now) => {
|
|
109
|
+
const k = Math.min(1, (now - t0) / (duration * 1e3));
|
|
110
|
+
const eased = 1 - (1 - k) ** 3;
|
|
111
|
+
const v = start + (target - start) * eased;
|
|
112
|
+
setShown(v);
|
|
113
|
+
from.current = v;
|
|
114
|
+
if (k < 1) frame = requestAnimationFrame(tick);
|
|
115
|
+
};
|
|
116
|
+
frame = requestAnimationFrame(tick);
|
|
117
|
+
return () => cancelAnimationFrame(frame);
|
|
118
|
+
}, [target, enabled]);
|
|
119
|
+
return shown;
|
|
120
|
+
}
|
|
86
121
|
function StatValue({
|
|
87
122
|
value,
|
|
88
123
|
unit,
|
|
@@ -92,17 +127,22 @@ function StatValue({
|
|
|
92
127
|
reason,
|
|
93
128
|
loading = false,
|
|
94
129
|
placeholder = "\u2014",
|
|
130
|
+
animate = false,
|
|
95
131
|
className,
|
|
96
132
|
...props
|
|
97
133
|
}) {
|
|
98
134
|
const t = useDsMessages();
|
|
99
135
|
const locale = useDsLocale();
|
|
100
136
|
const stat = React.useContext(StatContext);
|
|
101
|
-
const
|
|
102
|
-
|
|
137
|
+
const numeric = typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
138
|
+
const counting = animate && !loading && numeric != null;
|
|
139
|
+
const shown = useCountUp(numeric, counting);
|
|
140
|
+
const formatter = React.useMemo(() => {
|
|
103
141
|
const digits = fractionDigits == null ? {} : { minimumFractionDigits: fractionDigits, maximumFractionDigits: fractionDigits };
|
|
104
|
-
return new Intl.NumberFormat(locale, { ...format, ...digits })
|
|
105
|
-
}, [
|
|
142
|
+
return new Intl.NumberFormat(locale, { ...format, ...digits });
|
|
143
|
+
}, [format, fractionDigits, locale]);
|
|
144
|
+
const formatted = numeric != null ? formatter.format(numeric) : typeof value === "string" ? value : null;
|
|
145
|
+
const visible = counting && shown != null && shown !== numeric ? formatter.format(shown) : formatted;
|
|
106
146
|
const state = loading ? "loading" : formatted == null ? "empty" : "filled";
|
|
107
147
|
const base = cn(
|
|
108
148
|
"flex min-w-0 flex-wrap items-baseline gap-x-1 gap-y-0.5 leading-none font-(--ds-stat-value-weight) text-foreground tabular-nums",
|
|
@@ -143,7 +183,10 @@ function StatValue({
|
|
|
143
183
|
}
|
|
144
184
|
return /* @__PURE__ */ jsxs(StatPart, { "data-slot": "stat-value", "data-state": state, className: base, ...props, children: [
|
|
145
185
|
prefix != null && /* @__PURE__ */ jsx("span", { "data-slot": "stat-value-prefix", className: "text-sm text-muted-foreground", children: prefix }),
|
|
146
|
-
/* @__PURE__ */
|
|
186
|
+
visible !== formatted ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
187
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "stat-value-number", "aria-hidden": "true", className: "min-w-0 break-all", children: visible }),
|
|
188
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: formatted })
|
|
189
|
+
] }) : /* @__PURE__ */ jsx("span", { "data-slot": "stat-value-number", className: "min-w-0 break-all", children: formatted }),
|
|
147
190
|
unit != null && /* @__PURE__ */ jsx("span", { "data-slot": "stat-value-unit", className: "text-sm font-(--ds-label-weight) text-muted-foreground", children: unit })
|
|
148
191
|
] });
|
|
149
192
|
}
|
|
@@ -207,6 +250,65 @@ function StatDescription({ className, ...props }) {
|
|
|
207
250
|
function StatChart({ className, ...props }) {
|
|
208
251
|
return /* @__PURE__ */ jsx(StatPart, { "data-slot": "stat-chart", className: cn("mt-1 min-w-0", className), ...props });
|
|
209
252
|
}
|
|
253
|
+
function StatHeader({ className, ...props }) {
|
|
254
|
+
return /* @__PURE__ */ jsx(
|
|
255
|
+
"div",
|
|
256
|
+
{
|
|
257
|
+
"data-slot": "stat-header",
|
|
258
|
+
className: cn("flex min-w-0 items-start justify-between gap-2 [&>[data-slot=stat-label]]:pt-1", className),
|
|
259
|
+
...props
|
|
260
|
+
}
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
const iconTone = { neutral: "accent", good: "success", warn: "warning", bad: "danger" };
|
|
264
|
+
function StatIcon({
|
|
265
|
+
tone,
|
|
266
|
+
className,
|
|
267
|
+
...props
|
|
268
|
+
}) {
|
|
269
|
+
const stat = React.useContext(StatContext);
|
|
270
|
+
return /* @__PURE__ */ jsx(
|
|
271
|
+
IconTile,
|
|
272
|
+
{
|
|
273
|
+
"data-slot": "stat-icon",
|
|
274
|
+
"aria-hidden": "true",
|
|
275
|
+
size: "sm",
|
|
276
|
+
tone: tone ?? iconTone[stat.tone],
|
|
277
|
+
className: cn("shrink-0", className),
|
|
278
|
+
...props
|
|
279
|
+
}
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function StatProgress({ value, target, className, children, ...props }) {
|
|
283
|
+
const t = useDsMessages();
|
|
284
|
+
const locale = useDsLocale();
|
|
285
|
+
const stat = React.useContext(StatContext);
|
|
286
|
+
const ratio = value == null || !Number.isFinite(value) || target <= 0 ? null : value / target;
|
|
287
|
+
const pct = ratio == null ? null : new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 0 }).format(ratio);
|
|
288
|
+
const fill = stat.tone === "good" ? "bg-success" : stat.tone === "warn" ? "bg-warning" : stat.tone === "bad" ? "bg-danger" : "bg-primary";
|
|
289
|
+
return /* @__PURE__ */ jsxs(
|
|
290
|
+
StatPart,
|
|
291
|
+
{
|
|
292
|
+
"data-slot": "stat-progress",
|
|
293
|
+
"data-state": ratio == null ? "empty" : ratio >= 1 ? "complete" : "partial",
|
|
294
|
+
className: cn("mt-1 flex min-w-0 flex-col gap-1", className),
|
|
295
|
+
...props,
|
|
296
|
+
children: [
|
|
297
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "block h-(--ds-stat-progress-h) w-full overflow-hidden rounded-full bg-(--ds-track-bg)", children: /* @__PURE__ */ jsx(
|
|
298
|
+
"span",
|
|
299
|
+
{
|
|
300
|
+
className: cn(
|
|
301
|
+
"block h-full rounded-full transition-[width] duration-(--ds-motion-slow) ease-(--ds-ease-standard) motion-reduce:transition-none",
|
|
302
|
+
fill
|
|
303
|
+
),
|
|
304
|
+
style: { width: `${Math.min(1, Math.max(0, ratio ?? 0)) * 100}%` }
|
|
305
|
+
}
|
|
306
|
+
) }),
|
|
307
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground tabular-nums", children: children ?? (pct == null ? t.statNoData : t.statOfTarget.replace("{pct}", pct)) })
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
);
|
|
311
|
+
}
|
|
210
312
|
const swatchColor = {
|
|
211
313
|
1: "bg-chart-1",
|
|
212
314
|
2: "bg-chart-2",
|
|
@@ -241,7 +343,10 @@ export {
|
|
|
241
343
|
StatChart,
|
|
242
344
|
StatDelta,
|
|
243
345
|
StatDescription,
|
|
346
|
+
StatHeader,
|
|
347
|
+
StatIcon,
|
|
244
348
|
StatLabel,
|
|
349
|
+
StatProgress,
|
|
245
350
|
StatSwatch,
|
|
246
351
|
StatValue,
|
|
247
352
|
statVariants
|
|
@@ -16,7 +16,7 @@ type StatusDotProps = Omit<React.ComponentProps<"span">, "children"> & {
|
|
|
16
16
|
};
|
|
17
17
|
declare function StatusDot({ level, pulse, size, label, className, ...props }: StatusDotProps): React.JSX.Element;
|
|
18
18
|
declare const statusBadgeVariants: (props?: ({
|
|
19
|
-
variant?: "outline" | "
|
|
19
|
+
variant?: "outline" | "soft" | "dot" | null | undefined;
|
|
20
20
|
level?: "none" | "info" | "warning" | "neutral" | "critical" | "ok" | null | undefined;
|
|
21
21
|
} & class_variance_authority_types.ClassProp) | undefined) => string;
|
|
22
22
|
type StatusBadgeProps = Omit<React.ComponentProps<"span">, "children"> & {
|