orbital-ds 0.17.0 → 0.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/components.manifest.json +2067 -1984
- package/dist/hooks/use-ds-messages.d.ts +4 -0
- package/dist/lib/i18n.d.ts +4 -0
- package/dist/lib/i18n.js +15 -3
- package/dist/motion.css +1 -1
- package/dist/styles.css +1148 -1108
- package/dist/themes/lagoon.css +348 -0
- package/dist/themes/lagoon.fonts.css +2 -0
- package/dist/themes/lagoon.guide.md +47 -0
- package/dist/themes/lagoon.meta.json +84 -0
- package/dist/themes/lagoon.scoped.css +348 -0
- package/dist/themes/lagoon.tokens.json +49 -0
- package/dist/ui/animated-number.d.ts +9 -0
- package/dist/ui/animated-number.js +46 -0
- package/dist/ui/avatar.js +1 -1
- package/dist/ui/button.d.ts +1 -1
- package/dist/ui/button.js +1 -0
- package/dist/ui/card-stack.d.ts +9 -0
- package/dist/ui/card-stack.js +47 -0
- package/dist/ui/chart.js +1 -1
- package/dist/ui/command.js +3 -3
- package/dist/ui/dock.d.ts +13 -0
- package/dist/ui/dock.js +103 -0
- package/dist/ui/gauge.js +6 -6
- package/dist/ui/level-meter.js +2 -2
- package/dist/ui/media-card.d.ts +13 -0
- package/dist/ui/media-card.js +44 -0
- package/dist/ui/select.js +1 -1
- package/dist/ui/shield.js +1 -1
- package/dist/ui/sidebar.js +1 -1
- package/dist/ui/stat.js +4 -4
- package/dist/ui/week-strip.d.ts +12 -0
- package/dist/ui/week-strip.js +82 -0
- package/package.json +186 -186
- package/scripts/cli.mjs +1 -1
package/dist/ui/dock.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { mergeProps } from "@base-ui/react/merge-props";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { useDsMessages } from "../hooks/use-ds-messages.js";
|
|
7
|
+
import { cn } from "../lib/utils.js";
|
|
8
|
+
const DockContext = React.createContext("vertical");
|
|
9
|
+
function readNumber(el, name, fallback) {
|
|
10
|
+
const n = Number.parseFloat(getComputedStyle(el).getPropertyValue(name));
|
|
11
|
+
return Number.isFinite(n) ? n : fallback;
|
|
12
|
+
}
|
|
13
|
+
function Dock({
|
|
14
|
+
orientation = "vertical",
|
|
15
|
+
className,
|
|
16
|
+
onPointerMove,
|
|
17
|
+
onPointerLeave,
|
|
18
|
+
...props
|
|
19
|
+
}) {
|
|
20
|
+
const t = useDsMessages();
|
|
21
|
+
const ref = React.useRef(null);
|
|
22
|
+
const vertical = orientation === "vertical";
|
|
23
|
+
const reset = React.useCallback(() => {
|
|
24
|
+
ref.current?.querySelectorAll("[data-slot='dock-item']").forEach((el) => {
|
|
25
|
+
el.style.removeProperty("--dock-s");
|
|
26
|
+
el.style.removeProperty("--dock-push");
|
|
27
|
+
});
|
|
28
|
+
}, []);
|
|
29
|
+
const magnify = (e) => {
|
|
30
|
+
const root = ref.current;
|
|
31
|
+
if (!root || !window.matchMedia("(hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)").matches) return;
|
|
32
|
+
const items = [...root.querySelectorAll("[data-slot='dock-item']")];
|
|
33
|
+
if (items.length < 2) return;
|
|
34
|
+
const max = readNumber(root, "--ds-dock-max-scale", 1);
|
|
35
|
+
const pitch = vertical ? items[1].offsetTop - items[0].offsetTop : items[1].offsetLeft - items[0].offsetLeft;
|
|
36
|
+
const reach = Math.abs(pitch) * readNumber(root, "--ds-dock-reach", 2.3);
|
|
37
|
+
const box = root.getBoundingClientRect();
|
|
38
|
+
const pointer = vertical ? e.clientY - box.top : e.clientX - box.left;
|
|
39
|
+
for (const el of items) {
|
|
40
|
+
const centre = vertical ? el.offsetTop + el.offsetHeight / 2 : el.offsetLeft + el.offsetWidth / 2;
|
|
41
|
+
const gap = pointer - centre;
|
|
42
|
+
const away = Math.abs(gap);
|
|
43
|
+
const s = away < reach ? 1 + (max - 1) * ((Math.cos(Math.PI * away / reach) + 1) / 2) : 1;
|
|
44
|
+
const push = -Math.sign(gap) * (vertical ? el.offsetHeight : el.offsetWidth) * 0.14 * Math.sin(Math.PI * Math.min(away / (reach * 1.35), 1));
|
|
45
|
+
el.style.setProperty("--dock-s", String(s));
|
|
46
|
+
el.style.setProperty("--dock-push", `${push}px`);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return /* @__PURE__ */ jsx(DockContext.Provider, { value: orientation, children: /* @__PURE__ */ jsx(
|
|
50
|
+
"nav",
|
|
51
|
+
{
|
|
52
|
+
ref,
|
|
53
|
+
"aria-label": t.dockLabel,
|
|
54
|
+
"data-slot": "dock",
|
|
55
|
+
"data-orientation": orientation,
|
|
56
|
+
className: cn(
|
|
57
|
+
"relative inline-flex items-center gap-(--ds-dock-gap) rounded-(--ds-dock-radius) bg-(--ds-dock-bg) p-(--ds-dock-pad) text-(--ds-dock-fg) shadow-(--ds-dock-shadow)",
|
|
58
|
+
vertical ? "flex-col" : "flex-row",
|
|
59
|
+
className
|
|
60
|
+
),
|
|
61
|
+
onPointerMove: (e) => {
|
|
62
|
+
onPointerMove?.(e);
|
|
63
|
+
magnify(e);
|
|
64
|
+
},
|
|
65
|
+
onPointerLeave: (e) => {
|
|
66
|
+
onPointerLeave?.(e);
|
|
67
|
+
reset();
|
|
68
|
+
},
|
|
69
|
+
...props
|
|
70
|
+
}
|
|
71
|
+
) });
|
|
72
|
+
}
|
|
73
|
+
function DockItem({
|
|
74
|
+
label,
|
|
75
|
+
active,
|
|
76
|
+
className,
|
|
77
|
+
render,
|
|
78
|
+
...props
|
|
79
|
+
}) {
|
|
80
|
+
const orientation = React.useContext(DockContext);
|
|
81
|
+
return useRender({
|
|
82
|
+
defaultTagName: "button",
|
|
83
|
+
props: mergeProps(
|
|
84
|
+
{
|
|
85
|
+
"aria-label": label,
|
|
86
|
+
title: label,
|
|
87
|
+
"aria-current": active ? "page" : void 0,
|
|
88
|
+
className: cn(
|
|
89
|
+
"grid size-(--ds-dock-item) shrink-0 place-items-center rounded-(--ds-dock-item-radius) text-inherit outline-none transition-[scale,translate,background-color,color] duration-(--ds-motion-fast) ease-(--ds-ease-standard) [scale:var(--dock-s,1)] hover:bg-[color-mix(in_oklch,currentColor_12%,transparent)] focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) data-active:bg-(--ds-dock-active-bg) data-active:text-(--ds-dock-active-fg) motion-reduce:transition-none [&_svg]:size-5",
|
|
90
|
+
orientation === "vertical" ? "[translate:0_var(--dock-push,0px)]" : "[translate:var(--dock-push,0px)_0]",
|
|
91
|
+
className
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
props
|
|
95
|
+
),
|
|
96
|
+
render,
|
|
97
|
+
state: { slot: "dock-item", active: Boolean(active) }
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
Dock,
|
|
102
|
+
DockItem
|
|
103
|
+
};
|
package/dist/ui/gauge.js
CHANGED
|
@@ -55,7 +55,7 @@ function Gauge({
|
|
|
55
55
|
"aria-valuenow": now ?? void 0,
|
|
56
56
|
"aria-valuetext": text,
|
|
57
57
|
"data-slot": "gauge-chart",
|
|
58
|
-
className: cn("relative shrink-0 w-(--ds-gauge-size)", semi ? "h-[calc(var(--ds-gauge-size)/2)]" : "h-(--ds-gauge-size)"),
|
|
58
|
+
className: cn("@container relative shrink-0 w-(--ds-gauge-size)", semi ? "h-[calc(var(--ds-gauge-size)/2)]" : "h-(--ds-gauge-size)"),
|
|
59
59
|
children: [
|
|
60
60
|
/* @__PURE__ */ jsxs("svg", { viewBox: geometry.viewBox, "aria-hidden": "true", className: "size-full overflow-visible rtl:-scale-x-100", children: [
|
|
61
61
|
/* @__PURE__ */ jsx(
|
|
@@ -86,7 +86,7 @@ function Gauge({
|
|
|
86
86
|
{
|
|
87
87
|
"data-slot": "gauge-center",
|
|
88
88
|
className: cn(
|
|
89
|
-
"absolute flex flex-col items-center justify-center gap-1 text-center",
|
|
89
|
+
"absolute flex min-w-0 flex-col items-center justify-center gap-1 text-center",
|
|
90
90
|
semi ? "inset-x-0 bottom-0" : "inset-[15%]"
|
|
91
91
|
),
|
|
92
92
|
children
|
|
@@ -103,13 +103,13 @@ function GaugeValue({ className, ...props }) {
|
|
|
103
103
|
"span",
|
|
104
104
|
{
|
|
105
105
|
"data-slot": "gauge-value",
|
|
106
|
-
className: cn("font-display text-(
|
|
106
|
+
className: cn("inline-flex max-w-full flex-col items-center gap-0.5 font-display text-[length:min(var(--ds-gauge-value-size),var(--ds-gauge-value-fit))] leading-none font-(--ds-heading-weight) tabular-nums", className),
|
|
107
107
|
...props
|
|
108
108
|
}
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
function GaugeSuffix({ className, ...props }) {
|
|
112
|
-
return /* @__PURE__ */ jsx("span", { "data-slot": "gauge-value-suffix", className: cn("text-(
|
|
112
|
+
return /* @__PURE__ */ jsx("span", { "data-slot": "gauge-value-suffix", className: cn("max-w-full truncate text-[length:min(var(--ds-gauge-suffix-size),var(--ds-gauge-suffix-fit))]", className), ...props });
|
|
113
113
|
}
|
|
114
114
|
function GaugeTag({ className, style, tone, ...props }) {
|
|
115
115
|
const ctx = React.useContext(GaugeContext);
|
|
@@ -117,7 +117,7 @@ function GaugeTag({ className, style, tone, ...props }) {
|
|
|
117
117
|
"span",
|
|
118
118
|
{
|
|
119
119
|
"data-slot": "gauge-tag",
|
|
120
|
-
className: cn("inline-flex rounded-badge px-(--ds-badge-px) py-(--ds-badge-py) text-xs text-foreground", className),
|
|
120
|
+
className: cn("inline-flex max-w-full justify-center rounded-badge px-(--ds-badge-px) py-(--ds-badge-py) text-xs text-foreground", className),
|
|
121
121
|
style: { backgroundColor: dataToneSoftVar[tone ?? ctx.tone], ...style },
|
|
122
122
|
...props
|
|
123
123
|
}
|
|
@@ -138,7 +138,7 @@ function GaugeScale({
|
|
|
138
138
|
"div",
|
|
139
139
|
{
|
|
140
140
|
"data-slot": "gauge-scale",
|
|
141
|
-
className: cn("flex w-(--ds-gauge-size) justify-between text-xs font-(--ds-strong-weight)", className),
|
|
141
|
+
className: cn("flex w-(--ds-gauge-size) justify-between gap-2 text-xs font-(--ds-strong-weight)", className),
|
|
142
142
|
...props,
|
|
143
143
|
children: [
|
|
144
144
|
/* @__PURE__ */ jsx("span", { "data-slot": "gauge-scale-min", style: { color: dataToneVar[minTone] }, children: min }),
|
package/dist/ui/level-meter.js
CHANGED
|
@@ -30,12 +30,12 @@ function LevelMeter({
|
|
|
30
30
|
className: cn("flex flex-col gap-1 text-foreground", className),
|
|
31
31
|
...props,
|
|
32
32
|
children: [
|
|
33
|
-
/* @__PURE__ */ jsxs("div", { "data-slot": "level-meter-header", className: "flex items-center gap-2", children: [
|
|
33
|
+
/* @__PURE__ */ jsxs("div", { "data-slot": "level-meter-header", className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
34
34
|
level && /* @__PURE__ */ jsx(
|
|
35
35
|
"span",
|
|
36
36
|
{
|
|
37
37
|
"data-slot": "level-meter-tag",
|
|
38
|
-
className: "inline-flex rounded-badge px-(--ds-badge-px) py-(--ds-badge-py) text-xs",
|
|
38
|
+
className: "inline-flex max-w-full rounded-badge px-(--ds-badge-px) py-(--ds-badge-py) text-xs",
|
|
39
39
|
style: { backgroundColor: dataToneSoftVar[tone] },
|
|
40
40
|
children: level
|
|
41
41
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function MediaCard({ src, alt, title, meta, badge, action, className, children, ...props }: Omit<React.ComponentProps<"article">, "title"> & {
|
|
4
|
+
src?: string;
|
|
5
|
+
/** Texto alternativo de la imagen; vacío si es decorativa (por defecto). */
|
|
6
|
+
alt?: string;
|
|
7
|
+
title: React.ReactNode;
|
|
8
|
+
meta?: React.ReactNode;
|
|
9
|
+
badge?: React.ReactNode;
|
|
10
|
+
action?: React.ReactNode;
|
|
11
|
+
}): React.JSX.Element;
|
|
12
|
+
|
|
13
|
+
export { MediaCard };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
function MediaCard({
|
|
4
|
+
src,
|
|
5
|
+
alt = "",
|
|
6
|
+
title,
|
|
7
|
+
meta,
|
|
8
|
+
badge,
|
|
9
|
+
action,
|
|
10
|
+
className,
|
|
11
|
+
children,
|
|
12
|
+
...props
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsxs(
|
|
15
|
+
"article",
|
|
16
|
+
{
|
|
17
|
+
"data-slot": "media-card",
|
|
18
|
+
className: cn("group/media flex flex-col overflow-hidden rounded-card border border-border bg-card text-card-foreground shadow-card", className),
|
|
19
|
+
...props,
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsxs("div", { "data-slot": "media-card-media", className: "relative aspect-(--ds-media-aspect) overflow-hidden bg-(--ds-track-bg)", children: [
|
|
22
|
+
src && /* @__PURE__ */ jsx(
|
|
23
|
+
"img",
|
|
24
|
+
{
|
|
25
|
+
src,
|
|
26
|
+
alt,
|
|
27
|
+
className: "size-full object-cover transition-transform duration-(--ds-motion-slow) ease-(--ds-ease-standard) group-hover/media:scale-(--ds-media-zoom) motion-reduce:transition-none"
|
|
28
|
+
}
|
|
29
|
+
),
|
|
30
|
+
badge && /* @__PURE__ */ jsx("span", { "data-slot": "media-card-badge", className: "absolute start-2 bottom-2 rounded-badge bg-background/80 px-(--ds-badge-px) py-(--ds-badge-py) text-xs text-foreground tabular-nums", children: badge }),
|
|
31
|
+
action && /* @__PURE__ */ jsx("span", { "data-slot": "media-card-action", className: "absolute inset-0 grid place-items-center", children: action })
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsxs("div", { "data-slot": "media-card-body", className: "flex flex-col gap-1 p-(--ds-card-spacing-sm)", children: [
|
|
34
|
+
/* @__PURE__ */ jsx("h3", { "data-slot": "media-card-title", className: "font-display text-base leading-snug font-(--ds-heading-weight)", children: title }),
|
|
35
|
+
meta && /* @__PURE__ */ jsx("p", { "data-slot": "media-card-meta", className: "text-sm text-muted-foreground", children: meta }),
|
|
36
|
+
children
|
|
37
|
+
] })
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
MediaCard
|
|
44
|
+
};
|
package/dist/ui/select.js
CHANGED
|
@@ -28,7 +28,7 @@ function SelectTrigger({
|
|
|
28
28
|
"data-slot": "select-trigger",
|
|
29
29
|
"data-size": size,
|
|
30
30
|
className: cn(
|
|
31
|
-
"flex w-fit items-center justify-between gap-1.5 rounded-control shadow-control border border-input bg-(--ds-field-bg) px-(--ds-field-px) py-2 text-sm whitespace-nowrap transition-colors duration-(--ds-motion-snap) outline-none focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) disabled:cursor-not-allowed disabled:opacity-(--ds-disabled-opacity) aria-invalid:border-(--ds-invalid-border) aria-invalid:ring-(length:--ds-ring-width) aria-invalid:ring-(--ds-invalid-ring) data-placeholder:text-muted-foreground data-[size=default]:h-(--ds-control-h-md) data-[size=sm]:h-(--ds-control-h-sm) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 cursor-pointer hover:bg-(--ds-field-bg-hover) data-popup-open:bg-(--ds-field-bg-hover) [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
31
|
+
"flex w-fit cursor-pointer items-center justify-between gap-1.5 rounded-control hover:border-ring/60 shadow-control border border-input bg-(--ds-field-bg) px-(--ds-field-px) py-2 text-sm whitespace-nowrap transition-colors duration-(--ds-motion-snap) outline-none focus-visible:border-ring focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) disabled:cursor-not-allowed disabled:opacity-(--ds-disabled-opacity) aria-invalid:border-(--ds-invalid-border) aria-invalid:ring-(length:--ds-ring-width) aria-invalid:ring-(--ds-invalid-ring) data-placeholder:text-muted-foreground data-[size=default]:h-(--ds-control-h-md) data-[size=sm]:h-(--ds-control-h-sm) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 cursor-pointer hover:bg-(--ds-field-bg-hover) data-popup-open:bg-(--ds-field-bg-hover) [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
32
32
|
className
|
|
33
33
|
),
|
|
34
34
|
...props,
|
package/dist/ui/shield.js
CHANGED
|
@@ -80,7 +80,7 @@ function Shield({
|
|
|
80
80
|
{
|
|
81
81
|
"data-slot": "shield-value",
|
|
82
82
|
"aria-hidden": "true",
|
|
83
|
-
className: "relative font-display text-(length:--ds-shield-value-size) leading-none font-(--ds-shield-value-weight) tabular-nums",
|
|
83
|
+
className: "relative max-w-full truncate font-display text-(length:--ds-shield-value-size) leading-none font-(--ds-shield-value-weight) tabular-nums",
|
|
84
84
|
children: percent
|
|
85
85
|
}
|
|
86
86
|
)
|
package/dist/ui/sidebar.js
CHANGED
|
@@ -429,7 +429,7 @@ function SidebarMenuItem({ className, ...props }) {
|
|
|
429
429
|
);
|
|
430
430
|
}
|
|
431
431
|
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] duration-(--ds-motion-snap) 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",
|
|
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",
|
|
433
433
|
{
|
|
434
434
|
variants: {
|
|
435
435
|
variant: {
|
package/dist/ui/stat.js
CHANGED
|
@@ -81,7 +81,7 @@ function StatPart({
|
|
|
81
81
|
}
|
|
82
82
|
function StatLabel({ className, ...props }) {
|
|
83
83
|
const { labelId } = React.useContext(StatContext);
|
|
84
|
-
return /* @__PURE__ */ jsx(StatPart, { term: true, id: labelId, "data-slot": "stat-label", className: cn(eyebrowClassName, className), ...props });
|
|
84
|
+
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
85
|
}
|
|
86
86
|
function StatValue({
|
|
87
87
|
value,
|
|
@@ -105,7 +105,7 @@ function StatValue({
|
|
|
105
105
|
}, [value, format, fractionDigits, locale]);
|
|
106
106
|
const state = loading ? "loading" : formatted == null ? "empty" : "filled";
|
|
107
107
|
const base = cn(
|
|
108
|
-
"flex items-baseline gap-1 leading-none font-(--ds-stat-value-weight) text-foreground tabular-nums",
|
|
108
|
+
"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",
|
|
109
109
|
stat.variant === "inline" ? "text-base" : statValueSize[stat.size],
|
|
110
110
|
className
|
|
111
111
|
);
|
|
@@ -143,7 +143,7 @@ function StatValue({
|
|
|
143
143
|
}
|
|
144
144
|
return /* @__PURE__ */ jsxs(StatPart, { "data-slot": "stat-value", "data-state": state, className: base, ...props, children: [
|
|
145
145
|
prefix != null && /* @__PURE__ */ jsx("span", { "data-slot": "stat-value-prefix", className: "text-sm text-muted-foreground", children: prefix }),
|
|
146
|
-
/* @__PURE__ */ jsx("span", { "data-slot": "stat-value-number", children: formatted }),
|
|
146
|
+
/* @__PURE__ */ jsx("span", { "data-slot": "stat-value-number", className: "min-w-0 break-all", children: formatted }),
|
|
147
147
|
unit != null && /* @__PURE__ */ jsx("span", { "data-slot": "stat-value-unit", className: "text-sm font-(--ds-label-weight) text-muted-foreground", children: unit })
|
|
148
148
|
] });
|
|
149
149
|
}
|
|
@@ -176,7 +176,7 @@ function StatDelta({
|
|
|
176
176
|
"data-state": direction,
|
|
177
177
|
"data-tone": tone,
|
|
178
178
|
className: cn(
|
|
179
|
-
"inline-flex w-fit items-center gap-0.5 rounded-badge px-(--ds-badge-px) py-(--ds-badge-py) text-xs font-(--ds-label-weight) tabular-nums [&>svg]:size-3 [&>svg]:shrink-0",
|
|
179
|
+
"inline-flex w-fit max-w-full items-center gap-0.5 rounded-badge px-(--ds-badge-px) py-(--ds-badge-py) text-xs font-(--ds-label-weight) tabular-nums [&>svg]:size-3 [&>svg]:shrink-0",
|
|
180
180
|
tone === "success" && "bg-success-soft text-success",
|
|
181
181
|
tone === "danger" && "bg-danger-soft text-danger",
|
|
182
182
|
tone === "neutral" && "bg-neutral-soft text-neutral",
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
declare function WeekStrip({ value, defaultValue, onValueChange, weekStartsOn, marked, className, ...props }: Omit<React.ComponentProps<"div">, "defaultValue" | "onChange"> & {
|
|
4
|
+
value?: Date;
|
|
5
|
+
defaultValue?: Date;
|
|
6
|
+
onValueChange?: (date: Date) => void;
|
|
7
|
+
weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
8
|
+
/** Devuelve true para los días que llevan un punto (con eventos, por ejemplo). */
|
|
9
|
+
marked?: (date: Date) => boolean;
|
|
10
|
+
}): React.JSX.Element;
|
|
11
|
+
|
|
12
|
+
export { WeekStrip };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
|
|
5
|
+
import { useDsLocale, useDsMessages } from "../hooks/use-ds-messages.js";
|
|
6
|
+
import { cn } from "../lib/utils.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
function startOfDay(d) {
|
|
9
|
+
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
|
10
|
+
}
|
|
11
|
+
function addDays(d, n) {
|
|
12
|
+
const r = new Date(d);
|
|
13
|
+
r.setDate(r.getDate() + n);
|
|
14
|
+
return startOfDay(r);
|
|
15
|
+
}
|
|
16
|
+
function sameDay(a, b) {
|
|
17
|
+
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
18
|
+
}
|
|
19
|
+
function WeekStrip({
|
|
20
|
+
value,
|
|
21
|
+
defaultValue,
|
|
22
|
+
onValueChange,
|
|
23
|
+
weekStartsOn = 1,
|
|
24
|
+
marked,
|
|
25
|
+
className,
|
|
26
|
+
...props
|
|
27
|
+
}) {
|
|
28
|
+
const t = useDsMessages();
|
|
29
|
+
const locale = useDsLocale();
|
|
30
|
+
const [inner, setInner] = React.useState(() => startOfDay(defaultValue ?? /* @__PURE__ */ new Date()));
|
|
31
|
+
const selected = startOfDay(value ?? inner);
|
|
32
|
+
const [shift, setShift] = React.useState(0);
|
|
33
|
+
const first = addDays(selected, -((selected.getDay() - weekStartsOn + 7) % 7) + shift * 7);
|
|
34
|
+
const days = Array.from({ length: 7 }, (_, i) => addDays(first, i));
|
|
35
|
+
const today = startOfDay(/* @__PURE__ */ new Date());
|
|
36
|
+
const weekday = new Intl.DateTimeFormat(locale, { weekday: "short" });
|
|
37
|
+
const full = new Intl.DateTimeFormat(locale, { weekday: "long", day: "numeric", month: "long" });
|
|
38
|
+
const choose = (d) => {
|
|
39
|
+
setInner(d);
|
|
40
|
+
setShift(0);
|
|
41
|
+
onValueChange?.(d);
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
role: "group",
|
|
47
|
+
"aria-label": t.weekLabel,
|
|
48
|
+
"data-slot": "week-strip",
|
|
49
|
+
className: cn("flex items-center gap-(--ds-week-gap)", className),
|
|
50
|
+
...props,
|
|
51
|
+
children: [
|
|
52
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": t.weekPrevious, onClick: () => setShift((s) => s - 1), children: /* @__PURE__ */ jsx(ChevronLeftIcon, {}) }),
|
|
53
|
+
/* @__PURE__ */ jsx("div", { className: "grid flex-1 grid-cols-7 gap-(--ds-week-gap)", children: days.map((d) => {
|
|
54
|
+
const active = sameDay(d, selected);
|
|
55
|
+
return /* @__PURE__ */ jsxs(
|
|
56
|
+
"button",
|
|
57
|
+
{
|
|
58
|
+
type: "button",
|
|
59
|
+
"data-slot": "week-strip-day",
|
|
60
|
+
"data-active": active || void 0,
|
|
61
|
+
"data-today": sameDay(d, today) || void 0,
|
|
62
|
+
"aria-pressed": active,
|
|
63
|
+
"aria-label": full.format(d),
|
|
64
|
+
onClick: () => choose(d),
|
|
65
|
+
className: "relative flex flex-col items-center gap-0.5 rounded-(--ds-week-day-radius) border border-transparent px-1 py-2 text-sm outline-none transition-colors duration-(--ds-motion-fast) ease-(--ds-ease-standard) hover:bg-muted focus-visible:ring-(length:--ds-ring-width) focus-visible:ring-(--ds-ring-color) data-today:border-border data-active:bg-primary data-active:text-primary-foreground motion-reduce:transition-none",
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx("small", { className: "text-xs opacity-70", children: weekday.format(d) }),
|
|
68
|
+
/* @__PURE__ */ jsx("b", { className: "font-display tabular-nums", children: d.getDate() }),
|
|
69
|
+
marked?.(d) && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", "data-slot": "week-strip-mark", className: "absolute bottom-1 size-1 rounded-full bg-current" })
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
d.toISOString()
|
|
73
|
+
);
|
|
74
|
+
}) }),
|
|
75
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": t.weekNext, onClick: () => setShift((s) => s + 1), children: /* @__PURE__ */ jsx(ChevronRightIcon, {}) })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
WeekStrip
|
|
82
|
+
};
|