@sereno-ds/ui 0.38.0 → 0.40.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/dist/_internal/srOnly.d.ts +10 -0
- package/dist/_internal/srOnly.js +15 -0
- package/dist/_internal/srOnly.js.map +1 -0
- package/dist/core/ActionCard.d.ts +33 -0
- package/dist/core/ActionCard.js +91 -0
- package/dist/core/ActionCard.js.map +1 -0
- package/dist/core/Badge.d.ts +7 -1
- package/dist/core/Badge.js +9 -8
- package/dist/core/Badge.js.map +1 -1
- package/dist/core/Divider.d.ts +28 -0
- package/dist/core/Divider.js +28 -0
- package/dist/core/Divider.js.map +1 -0
- package/dist/core/StatCard.d.ts +40 -0
- package/dist/core/StatCard.js +79 -0
- package/dist/core/StatCard.js.map +1 -0
- package/dist/core/StatusDot.d.ts +36 -0
- package/dist/core/StatusDot.js +32 -0
- package/dist/core/StatusDot.js.map +1 -0
- package/dist/forms/CalendarLegend.d.ts +28 -0
- package/dist/forms/CalendarLegend.js +56 -0
- package/dist/forms/CalendarLegend.js.map +1 -0
- package/dist/forms/DatePicker.d.ts +21 -0
- package/dist/forms/DatePicker.js +8 -0
- package/dist/forms/DatePicker.js.map +1 -1
- package/dist/forms/DateTimePicker.d.ts +19 -3
- package/dist/forms/DateTimePicker.js +4 -0
- package/dist/forms/DateTimePicker.js.map +1 -1
- package/dist/forms/_internal/CalendarGrid.d.ts +13 -4
- package/dist/forms/_internal/CalendarGrid.js +25 -7
- package/dist/forms/_internal/CalendarGrid.js.map +1 -1
- package/dist/forms/_internal/calendarDots.d.ts +51 -0
- package/dist/forms/_internal/calendarDots.js +32 -0
- package/dist/forms/_internal/calendarDots.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +9 -0
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Visually hidden, still read by a screen reader. For text that names something the eye gets
|
|
5
|
+
* from a shape or a color (the dot under a calendar day). It is taken out of the flow and
|
|
6
|
+
* clipped to a 1px box where it stands, so it adds nothing to the layout.
|
|
7
|
+
*/
|
|
8
|
+
declare const srOnlyStyle: CSSProperties;
|
|
9
|
+
|
|
10
|
+
export { srOnlyStyle };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const srOnlyStyle = {
|
|
2
|
+
// Block, so it reads as its own word next to the visible text instead of running into it.
|
|
3
|
+
display: "block",
|
|
4
|
+
position: "absolute",
|
|
5
|
+
width: 1,
|
|
6
|
+
height: 1,
|
|
7
|
+
overflow: "hidden",
|
|
8
|
+
clip: "rect(0 0 0 0)",
|
|
9
|
+
clipPath: "inset(50%)",
|
|
10
|
+
whiteSpace: "nowrap"
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
srOnlyStyle
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=srOnly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/_internal/srOnly.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\n/**\n * Visually hidden, still read by a screen reader. For text that names something the eye gets\n * from a shape or a color (the dot under a calendar day). It is taken out of the flow and\n * clipped to a 1px box where it stands, so it adds nothing to the layout.\n */\nexport const srOnlyStyle: CSSProperties = {\n // Block, so it reads as its own word next to the visible text instead of running into it.\n display: 'block',\n position: 'absolute',\n width: 1,\n height: 1,\n overflow: 'hidden',\n clip: 'rect(0 0 0 0)',\n clipPath: 'inset(50%)',\n whiteSpace: 'nowrap',\n};\n"],"mappings":"AAOO,MAAM,cAA6B;AAAA;AAAA,EAExC,SAAS;AAAA,EACT,UAAU;AAAA,EACV,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,MAAM;AAAA,EACN,UAAU;AAAA,EACV,YAAY;AACd;","names":[]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type ActionCardVariant = 'default' | 'primary' | 'error';
|
|
4
|
+
/**
|
|
5
|
+
* A whole card you press: an icon, a title, a line of explanation and an arrow, in a real
|
|
6
|
+
* `<button>`. For the options of a decision ("Reschedule", "Cancel the booking") and for the
|
|
7
|
+
* entries of a settings flow. A `Card` with `interactive` is the bare surface; this is the
|
|
8
|
+
* finished control, with the keyboard, the focus ring and the disabled state taken care of.
|
|
9
|
+
*
|
|
10
|
+
* It is an action, not a radio: arrow keys do not move between cards. `selected` marks a card as
|
|
11
|
+
* a toggle (`aria-pressed`); for "choose exactly one of these" the semantics are a radio group's,
|
|
12
|
+
* which this is not.
|
|
13
|
+
*/
|
|
14
|
+
interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title' | 'children'> {
|
|
15
|
+
/** What the card does. Short: it is the name a screen reader says. */
|
|
16
|
+
title: React.ReactNode;
|
|
17
|
+
/** One line that says what happens. */
|
|
18
|
+
description?: React.ReactNode;
|
|
19
|
+
/** An icon (a `lucide-react` element), drawn in a tile on the left. Hidden from a screen reader: the title says it. */
|
|
20
|
+
icon?: React.ReactNode;
|
|
21
|
+
/** What sits on the right. An arrow by default; any node, or `null` for nothing. */
|
|
22
|
+
trailing?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Passing it (true or false) makes the card a toggle: it reports `aria-pressed` and, when true,
|
|
25
|
+
* wears the brand ring. Leave it out for a plain action.
|
|
26
|
+
*/
|
|
27
|
+
selected?: boolean;
|
|
28
|
+
/** `primary` is the option to steer toward, `error` a destructive one. */
|
|
29
|
+
variant?: ActionCardVariant;
|
|
30
|
+
}
|
|
31
|
+
declare function ActionCard({ title, description, icon, trailing, selected, variant, disabled, style, ...rest }: ActionCardProps): React.JSX.Element;
|
|
32
|
+
|
|
33
|
+
export { ActionCard, type ActionCardProps, type ActionCardVariant };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { ChevronRight } from "lucide-react";
|
|
4
|
+
import { sx } from "../_internal/style.js";
|
|
5
|
+
import { useInteract } from "./Button.js";
|
|
6
|
+
import { Typography } from "./Typography.js";
|
|
7
|
+
const VARIANTS = {
|
|
8
|
+
default: { tileBg: "var(--bg-subtle)", tileFg: "var(--text-secondary)", edge: "var(--border-brand)" },
|
|
9
|
+
primary: { tileBg: "var(--interactive-primary)", tileFg: "var(--interactive-primary-fg)", edge: "var(--border-brand)" },
|
|
10
|
+
error: { tileBg: "var(--status-error-bg)", tileFg: "var(--status-error-fg)", edge: "var(--status-error-dot)", title: "var(--status-error-fg)" }
|
|
11
|
+
};
|
|
12
|
+
const hoverFill = (edge) => "color-mix(in srgb, " + edge + " 6%, var(--bg-surface))";
|
|
13
|
+
function ActionCard({
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
icon,
|
|
17
|
+
trailing,
|
|
18
|
+
selected,
|
|
19
|
+
variant = "default",
|
|
20
|
+
disabled = false,
|
|
21
|
+
style,
|
|
22
|
+
...rest
|
|
23
|
+
}) {
|
|
24
|
+
const st = useInteract(disabled);
|
|
25
|
+
const v = VARIANTS[variant] || VARIANTS.default;
|
|
26
|
+
const on = selected === true;
|
|
27
|
+
const arrow = trailing === void 0 ? /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75, "aria-hidden": true }) : trailing;
|
|
28
|
+
const ring = on ? "0 0 0 1.5px " + v.edge : "0 0 0 1px " + (!disabled && st.hover ? v.edge : disabled ? "var(--border-subtle)" : "var(--border-default)");
|
|
29
|
+
const muted = disabled ? { color: "var(--text-disabled)" } : void 0;
|
|
30
|
+
const titleStyle = disabled ? muted : v.title ? { color: v.title } : void 0;
|
|
31
|
+
return /* @__PURE__ */ jsxs(
|
|
32
|
+
"button",
|
|
33
|
+
{
|
|
34
|
+
type: "button",
|
|
35
|
+
disabled,
|
|
36
|
+
"aria-pressed": selected,
|
|
37
|
+
...st.handlers,
|
|
38
|
+
...rest,
|
|
39
|
+
style: sx({
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "center",
|
|
42
|
+
gap: "var(--space-3)",
|
|
43
|
+
width: "100%",
|
|
44
|
+
minWidth: 0,
|
|
45
|
+
padding: "var(--space-3) var(--space-4)",
|
|
46
|
+
textAlign: "left",
|
|
47
|
+
fontFamily: "var(--font-body)",
|
|
48
|
+
color: "inherit",
|
|
49
|
+
border: "none",
|
|
50
|
+
borderRadius: "var(--radius-card)",
|
|
51
|
+
background: !disabled && st.hover ? hoverFill(v.edge) : "var(--bg-surface)",
|
|
52
|
+
boxShadow: [ring, st.focus ? "var(--focus-ring)" : null].filter(Boolean).join(", "),
|
|
53
|
+
transform: st.press && !disabled ? "scale(var(--press-scale))" : "none",
|
|
54
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
55
|
+
transition: "var(--transition-control)",
|
|
56
|
+
// The focus ring above is the box-shadow, the same substitute `Button` and `Card` use.
|
|
57
|
+
outline: "none",
|
|
58
|
+
...style
|
|
59
|
+
}),
|
|
60
|
+
children: [
|
|
61
|
+
icon ? /* @__PURE__ */ jsx(
|
|
62
|
+
"span",
|
|
63
|
+
{
|
|
64
|
+
"aria-hidden": true,
|
|
65
|
+
style: sx({
|
|
66
|
+
display: "inline-flex",
|
|
67
|
+
alignItems: "center",
|
|
68
|
+
justifyContent: "center",
|
|
69
|
+
flex: "0 0 auto",
|
|
70
|
+
width: 40,
|
|
71
|
+
height: 40,
|
|
72
|
+
borderRadius: "var(--radius-md)",
|
|
73
|
+
background: disabled ? "var(--interactive-disabled-bg)" : v.tileBg,
|
|
74
|
+
color: disabled ? "var(--interactive-disabled-fg)" : v.tileFg
|
|
75
|
+
}),
|
|
76
|
+
children: icon
|
|
77
|
+
}
|
|
78
|
+
) : null,
|
|
79
|
+
/* @__PURE__ */ jsxs("span", { style: sx({ display: "flex", flexDirection: "column", gap: 2, flex: "1 1 auto", minWidth: 0 }), children: [
|
|
80
|
+
/* @__PURE__ */ jsx(Typography, { as: "span", variant: "label", style: titleStyle, children: title }),
|
|
81
|
+
description ? /* @__PURE__ */ jsx(Typography, { as: "span", variant: "bodySm", style: muted, children: description }) : null
|
|
82
|
+
] }),
|
|
83
|
+
arrow ? /* @__PURE__ */ jsx("span", { style: sx({ display: "inline-flex", flex: "0 0 auto", color: disabled ? "var(--text-disabled)" : "var(--text-muted)" }), children: arrow }) : null
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
ActionCard
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=ActionCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/ActionCard.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { useInteract } from './Button';\nimport { Typography } from './Typography';\n\nexport type ActionCardVariant = 'default' | 'primary' | 'error';\n\n/**\n * A whole card you press: an icon, a title, a line of explanation and an arrow, in a real\n * `<button>`. For the options of a decision (\"Reschedule\", \"Cancel the booking\") and for the\n * entries of a settings flow. A `Card` with `interactive` is the bare surface; this is the\n * finished control, with the keyboard, the focus ring and the disabled state taken care of.\n *\n * It is an action, not a radio: arrow keys do not move between cards. `selected` marks a card as\n * a toggle (`aria-pressed`); for \"choose exactly one of these\" the semantics are a radio group's,\n * which this is not.\n */\nexport interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title' | 'children'> {\n /** What the card does. Short: it is the name a screen reader says. */\n title: React.ReactNode;\n /** One line that says what happens. */\n description?: React.ReactNode;\n /** An icon (a `lucide-react` element), drawn in a tile on the left. Hidden from a screen reader: the title says it. */\n icon?: React.ReactNode;\n /** What sits on the right. An arrow by default; any node, or `null` for nothing. */\n trailing?: React.ReactNode;\n /**\n * Passing it (true or false) makes the card a toggle: it reports `aria-pressed` and, when true,\n * wears the brand ring. Leave it out for a plain action.\n */\n selected?: boolean;\n /** `primary` is the option to steer toward, `error` a destructive one. */\n variant?: ActionCardVariant;\n}\n\n// `title` is the text color of the variant, when it has one. The error one is `--status-error-fg`, not\n// `--interactive-error`: on the hover fill the latter is 3.53:1 in the light theme (4.2:1 in the dark one),\n// under AA for text this size, where the status text color stays at 4.86:1 and 6.69:1.\nconst VARIANTS: Record<ActionCardVariant, { tileBg: string; tileFg: string; edge: string; title?: string }> = {\n default: { tileBg: 'var(--bg-subtle)', tileFg: 'var(--text-secondary)', edge: 'var(--border-brand)' },\n primary: { tileBg: 'var(--interactive-primary)', tileFg: 'var(--interactive-primary-fg)', edge: 'var(--border-brand)' },\n error: { tileBg: 'var(--status-error-bg)', tileFg: 'var(--status-error-fg)', edge: 'var(--status-error-dot)', title: 'var(--status-error-fg)' },\n};\n\n// The fill of a hovered card: a few percent of the variant's own ring color over the surface. Not\n// `--interactive-ghost-hover`: that grey is the very color of the icon tile (`--bg-subtle`), so on hover the\n// tile vanished into the card. This tint keeps the tile showing (1.20:1 against it in the light theme, 1.17:1\n// in the dark one, close to the 1.28:1 and 1.23:1 it has against the idle card) and keeps every text above AA.\nconst hoverFill = (edge: string) => 'color-mix(in srgb, ' + edge + ' 6%, var(--bg-surface))';\n\nexport function ActionCard({\n title,\n description,\n icon,\n trailing,\n selected,\n variant = 'default',\n disabled = false,\n style,\n ...rest\n}: ActionCardProps) {\n const st = useInteract(disabled);\n const v = VARIANTS[variant] || VARIANTS.default;\n const on = selected === true;\n const arrow = trailing === undefined ? <ChevronRight size={18} strokeWidth={1.75} aria-hidden /> : trailing;\n\n const ring = on ? '0 0 0 1.5px ' + v.edge : '0 0 0 1px ' + (!disabled && st.hover ? v.edge : disabled ? 'var(--border-subtle)' : 'var(--border-default)');\n // Only set when disabled: a `color: undefined` in a style would wipe the Typography's own.\n const muted = disabled ? { color: 'var(--text-disabled)' } : undefined;\n const titleStyle = disabled ? muted : v.title ? { color: v.title } : undefined;\n\n return (\n <button\n type=\"button\"\n disabled={disabled}\n aria-pressed={selected}\n {...st.handlers}\n {...rest}\n style={sx({\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n width: '100%',\n minWidth: 0,\n padding: 'var(--space-3) var(--space-4)',\n textAlign: 'left',\n fontFamily: 'var(--font-body)',\n color: 'inherit',\n border: 'none',\n borderRadius: 'var(--radius-card)',\n background: !disabled && st.hover ? hoverFill(v.edge) : 'var(--bg-surface)',\n boxShadow: [ring, st.focus ? 'var(--focus-ring)' : null].filter(Boolean).join(', '),\n transform: st.press && !disabled ? 'scale(var(--press-scale))' : 'none',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n // The focus ring above is the box-shadow, the same substitute `Button` and `Card` use.\n outline: 'none',\n ...style,\n })}\n >\n {icon ? (\n <span\n aria-hidden\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n flex: '0 0 auto',\n width: 40,\n height: 40,\n borderRadius: 'var(--radius-md)',\n background: disabled ? 'var(--interactive-disabled-bg)' : v.tileBg,\n color: disabled ? 'var(--interactive-disabled-fg)' : v.tileFg,\n })}\n >\n {icon}\n </span>\n ) : null}\n\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2, flex: '1 1 auto', minWidth: 0 })}>\n <Typography as=\"span\" variant=\"label\" style={titleStyle}>\n {title}\n </Typography>\n {description ? (\n <Typography as=\"span\" variant=\"bodySm\" style={muted}>\n {description}\n </Typography>\n ) : null}\n </span>\n\n {arrow ? (\n <span style={sx({ display: 'inline-flex', flex: '0 0 auto', color: disabled ? 'var(--text-disabled)' : 'var(--text-muted)' })}>\n {arrow}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":";AAmEyC,cAuDnC,YAvDmC;AAhEzC,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAmC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,UAAU,EAAE,IAAI,IAAI;AAAA,QACxD,WAAW,CAAC,MAAM,GAAG,QAAQ,sBAAsB,IAAI,EAAE,OAAO,OAAO,EAAE,KAAK,IAAI;AAAA,QAClF,WAAW,GAAG,SAAS,CAAC,WAAW,8BAA8B;AAAA,QACjE,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA;AAAA,QAEZ,SAAS;AAAA,QACT,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,eACC;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,YACX,OAAO,GAAG;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY,WAAW,mCAAmC,EAAE;AAAA,cAC5D,OAAO,WAAW,mCAAmC,EAAE;AAAA,YACzD,CAAC;AAAA,YAEA;AAAA;AAAA,QACH,IACE;AAAA,QAEJ,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,GAAG,MAAM,YAAY,UAAU,EAAE,CAAC,GACjG;AAAA,8BAAC,cAAW,IAAG,QAAO,SAAQ,SAAQ,OAAO,YAC1C,iBACH;AAAA,UACC,cACC,oBAAC,cAAW,IAAG,QAAO,SAAQ,UAAS,OAAO,OAC3C,uBACH,IACE;AAAA,WACN;AAAA,QAEC,QACC,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,eAAe,MAAM,YAAY,OAAO,WAAW,yBAAyB,oBAAoB,CAAC,GACzH,iBACH,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
package/dist/core/Badge.d.ts
CHANGED
|
@@ -9,8 +9,14 @@ interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
9
9
|
size?: 'sm' | 'md';
|
|
10
10
|
/** Leading status dot. Keep it on for lifecycle states. */
|
|
11
11
|
dot?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* A soft ring pulses out of the dot, for a state that is live ("Open now", "Online"). Only
|
|
14
|
+
* with `dot`. Off by default: use it on one or two badges, never on a list. It does not show
|
|
15
|
+
* when the user asks for reduced motion.
|
|
16
|
+
*/
|
|
17
|
+
pulse?: boolean;
|
|
12
18
|
children?: React.ReactNode;
|
|
13
19
|
}
|
|
14
|
-
declare function Badge({ tone, size, dot, children, style, ...rest }: BadgeProps): React.JSX.Element;
|
|
20
|
+
declare function Badge({ tone, size, dot, pulse, children, style, ...rest }: BadgeProps): React.JSX.Element;
|
|
15
21
|
|
|
16
22
|
export { Badge, type BadgeProps };
|
package/dist/core/Badge.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { sx } from "../_internal/style.js";
|
|
4
|
+
import { StatusDot, statusDotStyle } from "./StatusDot.js";
|
|
4
5
|
const TONES = {
|
|
5
|
-
success: ["--status-success-bg", "--status-success-fg"
|
|
6
|
-
warning: ["--status-warning-bg", "--status-warning-fg"
|
|
7
|
-
error: ["--status-error-bg", "--status-error-fg"
|
|
8
|
-
info: ["--status-info-bg", "--status-info-fg"
|
|
6
|
+
success: ["--status-success-bg", "--status-success-fg"],
|
|
7
|
+
warning: ["--status-warning-bg", "--status-warning-fg"],
|
|
8
|
+
error: ["--status-error-bg", "--status-error-fg"],
|
|
9
|
+
info: ["--status-info-bg", "--status-info-fg"],
|
|
9
10
|
// Neutral = an outlined chip (surface fill + hairline border, added below) so it
|
|
10
11
|
// reads on any background, including a tinted one.
|
|
11
|
-
neutral: ["--bg-surface", "--text-secondary"
|
|
12
|
+
neutral: ["--bg-surface", "--text-secondary"]
|
|
12
13
|
};
|
|
13
|
-
function Badge({ tone = "neutral", size = "md", dot = true, children, style, ...rest }) {
|
|
14
|
-
const [bg, fg
|
|
14
|
+
function Badge({ tone = "neutral", size = "md", dot = true, pulse = false, children, style, ...rest }) {
|
|
15
|
+
const [bg, fg] = TONES[tone] || TONES.neutral;
|
|
15
16
|
const sm = size === "sm";
|
|
16
17
|
return /* @__PURE__ */ jsxs(
|
|
17
18
|
"span",
|
|
@@ -37,7 +38,7 @@ function Badge({ tone = "neutral", size = "md", dot = true, children, style, ...
|
|
|
37
38
|
...style
|
|
38
39
|
}),
|
|
39
40
|
children: [
|
|
40
|
-
dot && /* @__PURE__ */ jsx(
|
|
41
|
+
dot && (pulse ? /* @__PURE__ */ jsx(StatusDot, { tone, size: sm ? "sm" : "md", pulse: true }) : /* @__PURE__ */ jsx("span", { style: statusDotStyle(tone, sm ? "sm" : "md") })),
|
|
41
42
|
children
|
|
42
43
|
]
|
|
43
44
|
}
|
package/dist/core/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/Badge.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Status pill for the booking lifecycle and other short labels.\n */\nexport interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Semantic tone. Same five tones across Badge, Alert and Toast. */\n tone?: 'success' | 'warning' | 'error' | 'info' | 'neutral';\n size?: 'sm' | 'md';\n /** Leading status dot. Keep it on for lifecycle states. */\n dot?: boolean;\n children?: React.ReactNode;\n}\n\nconst TONES: Record<NonNullable<BadgeProps['tone']>, [string, string
|
|
1
|
+
{"version":3,"sources":["../../src/core/Badge.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { StatusDot, statusDotStyle } from './StatusDot';\n\n/**\n * Status pill for the booking lifecycle and other short labels.\n */\nexport interface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n /** Semantic tone. Same five tones across Badge, Alert and Toast. */\n tone?: 'success' | 'warning' | 'error' | 'info' | 'neutral';\n size?: 'sm' | 'md';\n /** Leading status dot. Keep it on for lifecycle states. */\n dot?: boolean;\n /**\n * A soft ring pulses out of the dot, for a state that is live (\"Open now\", \"Online\"). Only\n * with `dot`. Off by default: use it on one or two badges, never on a list. It does not show\n * when the user asks for reduced motion.\n */\n pulse?: boolean;\n children?: React.ReactNode;\n}\n\n// The dot's own color comes from `StatusDot`, so the two cannot drift apart.\nconst TONES: Record<NonNullable<BadgeProps['tone']>, [string, string]> = {\n success: ['--status-success-bg', '--status-success-fg'],\n warning: ['--status-warning-bg', '--status-warning-fg'],\n error: ['--status-error-bg', '--status-error-fg'],\n info: ['--status-info-bg', '--status-info-fg'],\n // Neutral = an outlined chip (surface fill + hairline border, added below) so it\n // reads on any background, including a tinted one.\n neutral: ['--bg-surface', '--text-secondary'],\n};\n\nexport function Badge({ tone = 'neutral', size = 'md', dot = true, pulse = false, children, style, ...rest }: BadgeProps) {\n const [bg, fg] = TONES[tone] || TONES.neutral;\n const sm = size === 'sm';\n return (\n <span\n {...rest}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n gap: sm ? 5 : 6,\n padding: sm ? '2px 8px' : '4px 10px',\n borderRadius: 'var(--radius-chip)',\n background: 'var(' + bg + ')',\n // The neutral fill can match a tinted surface it sits on - a hairline\n // keeps the chip defined on any background. Tinted tones read on their own.\n border: 'var(--border-width-hairline) solid ' + (tone === 'neutral' ? 'var(--border-default)' : 'transparent'),\n color: 'var(' + fg + ')',\n fontFamily: 'var(--font-body)',\n fontSize: sm ? 'var(--text-2xs)' : 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n lineHeight: 1.4,\n whiteSpace: 'nowrap',\n ...style,\n })}\n >\n {dot &&\n (pulse ? (\n <StatusDot tone={tone} size={sm ? 'sm' : 'md'} pulse />\n ) : (\n <span style={statusDotStyle(tone, sm ? 'sm' : 'md')} />\n ))}\n {children}\n </span>\n );\n}"],"mappings":";AAuCI,SAwBM,KAxBN;AApCJ,SAAS,UAAU;AACnB,SAAS,WAAW,sBAAsB;AAqB1C,MAAM,QAAmE;AAAA,EACvE,SAAS,CAAC,uBAAuB,qBAAqB;AAAA,EACtD,SAAS,CAAC,uBAAuB,qBAAqB;AAAA,EACtD,OAAO,CAAC,qBAAqB,mBAAmB;AAAA,EAChD,MAAM,CAAC,oBAAoB,kBAAkB;AAAA;AAAA;AAAA,EAG7C,SAAS,CAAC,gBAAgB,kBAAkB;AAC9C;AAEO,SAAS,MAAM,EAAE,OAAO,WAAW,OAAO,MAAM,MAAM,MAAM,QAAQ,OAAO,UAAU,OAAO,GAAG,KAAK,GAAe;AACxH,QAAM,CAAC,IAAI,EAAE,IAAI,MAAM,IAAI,KAAK,MAAM;AACtC,QAAM,KAAK,SAAS;AACpB,SACE;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA,QACR,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,KAAK,KAAK,IAAI;AAAA,QACd,SAAS,KAAK,YAAY;AAAA,QAC1B,cAAc;AAAA,QACd,YAAY,SAAS,KAAK;AAAA;AAAA;AAAA,QAG1B,QAAQ,yCAAyC,SAAS,YAAY,0BAA0B;AAAA,QAChG,OAAO,SAAS,KAAK;AAAA,QACrB,YAAY;AAAA,QACZ,UAAU,KAAK,oBAAoB;AAAA,QACnC,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,gBACE,QACC,oBAAC,aAAU,MAAY,MAAM,KAAK,OAAO,MAAM,OAAK,MAAC,IAErD,oBAAC,UAAK,OAAO,eAAe,MAAM,KAAK,OAAO,IAAI,GAAG;AAAA,QAExD;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A horizontal line that separates two stretches of content. `default` is the subtle hairline of
|
|
5
|
+
* a list or a card; `strong` is a firmer one for a page background, where the subtle one nearly
|
|
6
|
+
* disappears.
|
|
7
|
+
*
|
|
8
|
+
* It has no margin of its own: the space around it is the caller's (a `gap` on the parent, or a
|
|
9
|
+
* `style` on the divider).
|
|
10
|
+
*/
|
|
11
|
+
interface DividerProps extends Omit<React.HTMLAttributes<HTMLHRElement>, 'children'> {
|
|
12
|
+
/**
|
|
13
|
+
* `strong` is `--border-strong`, firmer than the `--border-subtle` of `default`. Firmer, not
|
|
14
|
+
* high contrast: it is 1.63:1 against a card and 1.38:1 against the page in the light theme
|
|
15
|
+
* (1.83:1 and 2.03:1 in the dark one), which is right for a separator and short of what a
|
|
16
|
+
* control's edge would need.
|
|
17
|
+
*/
|
|
18
|
+
variant?: 'default' | 'strong';
|
|
19
|
+
/**
|
|
20
|
+
* Hides the line from a screen reader (`role="none"`). For lines between rows that repeat, so
|
|
21
|
+
* the reader does not announce a separator after every one. Without it the line is a
|
|
22
|
+
* separator, which is right between two sections.
|
|
23
|
+
*/
|
|
24
|
+
decorative?: boolean;
|
|
25
|
+
}
|
|
26
|
+
declare function Divider({ variant, decorative, style, ...rest }: DividerProps): React.JSX.Element;
|
|
27
|
+
|
|
28
|
+
export { Divider, type DividerProps };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { sx } from "../_internal/style.js";
|
|
4
|
+
const COLOR = { default: "--border-subtle", strong: "--border-strong" };
|
|
5
|
+
function Divider({ variant = "default", decorative = false, style, ...rest }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(
|
|
7
|
+
"hr",
|
|
8
|
+
{
|
|
9
|
+
role: decorative ? "none" : void 0,
|
|
10
|
+
...rest,
|
|
11
|
+
style: sx({
|
|
12
|
+
// Longhands only (no `border` shorthand), so a later render never mixes the two.
|
|
13
|
+
borderStyle: "solid",
|
|
14
|
+
borderColor: "var(" + (COLOR[variant] || COLOR.default) + ")",
|
|
15
|
+
borderWidth: "var(--border-width-hairline) 0 0 0",
|
|
16
|
+
height: 0,
|
|
17
|
+
width: "100%",
|
|
18
|
+
margin: 0,
|
|
19
|
+
flex: "0 0 auto",
|
|
20
|
+
...style
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
Divider
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=Divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/Divider.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * A horizontal line that separates two stretches of content. `default` is the subtle hairline of\n * a list or a card; `strong` is a firmer one for a page background, where the subtle one nearly\n * disappears.\n *\n * It has no margin of its own: the space around it is the caller's (a `gap` on the parent, or a\n * `style` on the divider).\n */\nexport interface DividerProps extends Omit<React.HTMLAttributes<HTMLHRElement>, 'children'> {\n /**\n * `strong` is `--border-strong`, firmer than the `--border-subtle` of `default`. Firmer, not\n * high contrast: it is 1.63:1 against a card and 1.38:1 against the page in the light theme\n * (1.83:1 and 2.03:1 in the dark one), which is right for a separator and short of what a\n * control's edge would need.\n */\n variant?: 'default' | 'strong';\n /**\n * Hides the line from a screen reader (`role=\"none\"`). For lines between rows that repeat, so\n * the reader does not announce a separator after every one. Without it the line is a\n * separator, which is right between two sections.\n */\n decorative?: boolean;\n}\n\nconst COLOR = { default: '--border-subtle', strong: '--border-strong' } as const;\n\nexport function Divider({ variant = 'default', decorative = false, style, ...rest }: DividerProps) {\n return (\n <hr\n role={decorative ? 'none' : undefined}\n {...rest}\n style={sx({\n // Longhands only (no `border` shorthand), so a later render never mixes the two.\n borderStyle: 'solid',\n borderColor: 'var(' + (COLOR[variant] || COLOR.default) + ')',\n borderWidth: 'var(--border-width-hairline) 0 0 0',\n height: 0,\n width: '100%',\n margin: 0,\n flex: '0 0 auto',\n ...style,\n })}\n />\n );\n}\n"],"mappings":";AAiCI;AA9BJ,SAAS,UAAU;AA0BnB,MAAM,QAAQ,EAAE,SAAS,mBAAmB,QAAQ,kBAAkB;AAE/D,SAAS,QAAQ,EAAE,UAAU,WAAW,aAAa,OAAO,OAAO,GAAG,KAAK,GAAiB;AACjG,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM,aAAa,SAAS;AAAA,MAC3B,GAAG;AAAA,MACJ,OAAO,GAAG;AAAA;AAAA,QAER,aAAa;AAAA,QACb,aAAa,UAAU,MAAM,OAAO,KAAK,MAAM,WAAW;AAAA,QAC1D,aAAa;AAAA,QACb,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,GAAG;AAAA,MACL,CAAC;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type StatCardTone = 'default' | 'neutral' | 'success' | 'warning' | 'error' | 'info';
|
|
4
|
+
/**
|
|
5
|
+
* A figure on a dashboard: a small label, the number big, one line of context under it, and
|
|
6
|
+
* optionally a thin bar for "how full" (the day's grid, a quota). Built on `Card`, `Typography`
|
|
7
|
+
* and `Skeleton`, so it looks like the rest and follows the theme with no color of its own.
|
|
8
|
+
*/
|
|
9
|
+
interface StatCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
10
|
+
/** The small line above the number: what is being counted. */
|
|
11
|
+
label: string;
|
|
12
|
+
/** The number, or a short text. Any node, so a formatted price or a `Badge` fits. Shown large, in tabular figures. */
|
|
13
|
+
value: React.ReactNode;
|
|
14
|
+
/** One line of context under the number ("3 confirmados"). */
|
|
15
|
+
hint?: string;
|
|
16
|
+
/**
|
|
17
|
+
* `default` is the plain card. `neutral` is a quieter one (a tinted fill, no shadow) for figures
|
|
18
|
+
* that are background. `success`, `warning`, `error` and `info` are the status tones (the same
|
|
19
|
+
* names `Badge`, `Alert` and `Toast` use): the card gets a ring in the tone's color and the
|
|
20
|
+
* label and number take its text color.
|
|
21
|
+
*/
|
|
22
|
+
tone?: StatCardTone;
|
|
23
|
+
/**
|
|
24
|
+
* A thin bar under the number. `percent` is 0 to 100 (anything outside is held to it).
|
|
25
|
+
* `label` names the bar for a screen reader; without it the bar takes the card's `label`.
|
|
26
|
+
*/
|
|
27
|
+
progress?: {
|
|
28
|
+
percent: number;
|
|
29
|
+
label?: string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The data has not arrived: the label, the number and the hint become placeholders that take
|
|
33
|
+
* the same room as the real text, so nothing jumps when it arrives. It mirrors the props you
|
|
34
|
+
* pass, so give `hint` and `progress` while loading too if the loaded card will have them.
|
|
35
|
+
*/
|
|
36
|
+
loading?: boolean;
|
|
37
|
+
}
|
|
38
|
+
declare function StatCard({ label, value, hint, tone, progress, loading, style, ...rest }: StatCardProps): React.JSX.Element;
|
|
39
|
+
|
|
40
|
+
export { StatCard, type StatCardProps, type StatCardTone };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { sx } from "../_internal/style.js";
|
|
4
|
+
import { Skeleton } from "../feedback/Skeleton.js";
|
|
5
|
+
import { Card } from "./Card.js";
|
|
6
|
+
import { Typography } from "./Typography.js";
|
|
7
|
+
const STATUS = {
|
|
8
|
+
success: { fg: "--status-success-fg", edge: "--status-success-dot" },
|
|
9
|
+
warning: { fg: "--status-warning-fg", edge: "--status-warning-dot" },
|
|
10
|
+
error: { fg: "--status-error-fg", edge: "--status-error-dot" },
|
|
11
|
+
info: { fg: "--status-info-fg", edge: "--status-info-dot" }
|
|
12
|
+
};
|
|
13
|
+
const LABEL_H = "calc(var(--text-2xs) * var(--leading-normal))";
|
|
14
|
+
const VALUE_H = "calc(var(--text-3xl) * 1.1)";
|
|
15
|
+
const HINT_H = "calc(var(--text-xs) * var(--leading-normal))";
|
|
16
|
+
const row = (minHeight) => ({ display: "flex", alignItems: "center", minWidth: 0, minHeight });
|
|
17
|
+
function StatCard({ label, value, hint, tone = "default", progress, loading = false, style, ...rest }) {
|
|
18
|
+
const status = tone in STATUS ? STATUS[tone] : null;
|
|
19
|
+
const neutral = tone === "neutral";
|
|
20
|
+
const toneColor = status ? { color: "var(" + status.fg + ")" } : void 0;
|
|
21
|
+
const pct = progress && Number.isFinite(progress.percent) ? Math.min(100, Math.max(0, progress.percent)) : 0;
|
|
22
|
+
return /* @__PURE__ */ jsxs(
|
|
23
|
+
Card,
|
|
24
|
+
{
|
|
25
|
+
padding: "md",
|
|
26
|
+
elevation: neutral ? "none" : "sm",
|
|
27
|
+
"aria-busy": loading || void 0,
|
|
28
|
+
...rest,
|
|
29
|
+
style: sx({
|
|
30
|
+
display: "flex",
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
gap: "var(--space-1)",
|
|
33
|
+
minWidth: 0,
|
|
34
|
+
...neutral ? { background: "var(--bg-subtle)", boxShadow: "0 0 0 1px var(--border-default)" } : null,
|
|
35
|
+
...status ? { boxShadow: "0 0 0 1px var(" + status.edge + "), var(--shadow-xs)" } : null,
|
|
36
|
+
...style
|
|
37
|
+
}),
|
|
38
|
+
children: [
|
|
39
|
+
/* @__PURE__ */ jsx("div", { style: row(LABEL_H), children: loading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block", height: 10, style: { width: "45%" } }) : /* @__PURE__ */ jsx(Typography, { as: "span", variant: "eyebrow", color: neutral ? "secondary" : void 0, style: toneColor, children: label }) }),
|
|
40
|
+
/* @__PURE__ */ jsx("div", { style: row(VALUE_H), children: loading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block", height: 26, style: { width: "40%" } }) : /* @__PURE__ */ jsx(Typography, { as: "span", variant: "h1", numeric: true, style: { fontWeight: "var(--weight-extrabold)", lineHeight: 1.1, ...toneColor }, children: value }) }),
|
|
41
|
+
progress ? loading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block", height: 6, style: { marginTop: "var(--space-1)" } }) : /* @__PURE__ */ jsx(
|
|
42
|
+
"div",
|
|
43
|
+
{
|
|
44
|
+
role: "progressbar",
|
|
45
|
+
"aria-valuemin": 0,
|
|
46
|
+
"aria-valuemax": 100,
|
|
47
|
+
"aria-valuenow": pct,
|
|
48
|
+
"aria-label": progress.label ?? label,
|
|
49
|
+
style: sx({
|
|
50
|
+
marginTop: "var(--space-1)",
|
|
51
|
+
height: 6,
|
|
52
|
+
width: "100%",
|
|
53
|
+
overflow: "hidden",
|
|
54
|
+
borderRadius: "var(--radius-pill)",
|
|
55
|
+
background: neutral ? "var(--bg-surface)" : "var(--border-subtle)"
|
|
56
|
+
}),
|
|
57
|
+
children: /* @__PURE__ */ jsx(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
style: sx({
|
|
61
|
+
height: "100%",
|
|
62
|
+
width: pct + "%",
|
|
63
|
+
borderRadius: "var(--radius-pill)",
|
|
64
|
+
background: status ? "var(" + status.fg + ")" : "var(--interactive-primary)",
|
|
65
|
+
transition: "width var(--duration-normal) var(--ease-standard)"
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
) : null,
|
|
71
|
+
hint ? /* @__PURE__ */ jsx("div", { style: row(HINT_H), children: loading ? /* @__PURE__ */ jsx(Skeleton, { variant: "block", height: 11, style: { width: "70%" } }) : /* @__PURE__ */ jsx(Typography, { as: "span", variant: "caption", color: "secondary", children: hint }) }) : null
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
StatCard
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=StatCard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/StatCard.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Skeleton } from '../feedback/Skeleton';\nimport { Card } from './Card';\nimport { Typography } from './Typography';\n\nexport type StatCardTone = 'default' | 'neutral' | 'success' | 'warning' | 'error' | 'info';\n\n/**\n * A figure on a dashboard: a small label, the number big, one line of context under it, and\n * optionally a thin bar for \"how full\" (the day's grid, a quota). Built on `Card`, `Typography`\n * and `Skeleton`, so it looks like the rest and follows the theme with no color of its own.\n */\nexport interface StatCardProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {\n /** The small line above the number: what is being counted. */\n label: string;\n /** The number, or a short text. Any node, so a formatted price or a `Badge` fits. Shown large, in tabular figures. */\n value: React.ReactNode;\n /** One line of context under the number (\"3 confirmados\"). */\n hint?: string;\n /**\n * `default` is the plain card. `neutral` is a quieter one (a tinted fill, no shadow) for figures\n * that are background. `success`, `warning`, `error` and `info` are the status tones (the same\n * names `Badge`, `Alert` and `Toast` use): the card gets a ring in the tone's color and the\n * label and number take its text color.\n */\n tone?: StatCardTone;\n /**\n * A thin bar under the number. `percent` is 0 to 100 (anything outside is held to it).\n * `label` names the bar for a screen reader; without it the bar takes the card's `label`.\n */\n progress?: { percent: number; label?: string };\n /**\n * The data has not arrived: the label, the number and the hint become placeholders that take\n * the same room as the real text, so nothing jumps when it arrives. It mirrors the props you\n * pass, so give `hint` and `progress` while loading too if the loaded card will have them.\n */\n loading?: boolean;\n}\n\ntype StatusTone = 'success' | 'warning' | 'error' | 'info';\n\n// `fg` is the text color of the tone and also the bar fill (the `dot` color is a hair under 3:1\n// against the track in the light theme); `edge` is the ring.\nconst STATUS: Record<StatusTone, { fg: string; edge: string }> = {\n success: { fg: '--status-success-fg', edge: '--status-success-dot' },\n warning: { fg: '--status-warning-fg', edge: '--status-warning-dot' },\n error: { fg: '--status-error-fg', edge: '--status-error-dot' },\n info: { fg: '--status-info-fg', edge: '--status-info-dot' },\n};\n\n// The height of each line, held by the loaded text and by its placeholder alike: the font size\n// times the line height, from the same tokens the text is set in, so the two are the same height\n// whatever the font's metrics (the number is `--text-3xl` at a 1.1 line height, set below).\nconst LABEL_H = 'calc(var(--text-2xs) * var(--leading-normal))';\nconst VALUE_H = 'calc(var(--text-3xl) * 1.1)';\nconst HINT_H = 'calc(var(--text-xs) * var(--leading-normal))';\n\nconst row = (minHeight: string): React.CSSProperties => ({ display: 'flex', alignItems: 'center', minWidth: 0, minHeight });\n\nexport function StatCard({ label, value, hint, tone = 'default', progress, loading = false, style, ...rest }: StatCardProps) {\n const status = tone in STATUS ? STATUS[tone as StatusTone] : null;\n const neutral = tone === 'neutral';\n const toneColor = status ? { color: 'var(' + status.fg + ')' } : undefined;\n const pct = progress && Number.isFinite(progress.percent) ? Math.min(100, Math.max(0, progress.percent)) : 0;\n\n return (\n <Card\n padding=\"md\"\n elevation={neutral ? 'none' : 'sm'}\n aria-busy={loading || undefined}\n {...rest}\n style={sx({\n display: 'flex',\n flexDirection: 'column',\n gap: 'var(--space-1)',\n minWidth: 0,\n ...(neutral ? { background: 'var(--bg-subtle)', boxShadow: '0 0 0 1px var(--border-default)' } : null),\n ...(status ? { boxShadow: '0 0 0 1px var(' + status.edge + '), var(--shadow-xs)' } : null),\n ...style,\n })}\n >\n <div style={row(LABEL_H)}>\n {loading ? (\n <Skeleton variant=\"block\" height={10} style={{ width: '45%' }} />\n ) : (\n <Typography as=\"span\" variant=\"eyebrow\" color={neutral ? 'secondary' : undefined} style={toneColor}>\n {label}\n </Typography>\n )}\n </div>\n\n <div style={row(VALUE_H)}>\n {loading ? (\n <Skeleton variant=\"block\" height={26} style={{ width: '40%' }} />\n ) : (\n <Typography as=\"span\" variant=\"h1\" numeric style={{ fontWeight: 'var(--weight-extrabold)', lineHeight: 1.1, ...toneColor }}>\n {value}\n </Typography>\n )}\n </div>\n\n {progress ? (\n loading ? (\n <Skeleton variant=\"block\" height={6} style={{ marginTop: 'var(--space-1)' }} />\n ) : (\n <div\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={pct}\n aria-label={progress.label ?? label}\n style={sx({\n marginTop: 'var(--space-1)',\n height: 6,\n width: '100%',\n overflow: 'hidden',\n borderRadius: 'var(--radius-pill)',\n background: neutral ? 'var(--bg-surface)' : 'var(--border-subtle)',\n })}\n >\n <div\n style={sx({\n height: '100%',\n width: pct + '%',\n borderRadius: 'var(--radius-pill)',\n background: status ? 'var(' + status.fg + ')' : 'var(--interactive-primary)',\n transition: 'width var(--duration-normal) var(--ease-standard)',\n })}\n />\n </div>\n )\n ) : null}\n\n {hint ? (\n <div style={row(HINT_H)}>\n {loading ? (\n <Skeleton variant=\"block\" height={11} style={{ width: '70%' }} />\n ) : (\n <Typography as=\"span\" variant=\"caption\" color=\"secondary\">\n {hint}\n </Typography>\n )}\n </div>\n ) : null}\n </Card>\n );\n}\n"],"mappings":";AAqEI,SAiBM,KAjBN;AAlEJ,SAAS,UAAU;AACnB,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAwC3B,MAAM,SAA2D;AAAA,EAC/D,SAAS,EAAE,IAAI,uBAAuB,MAAM,uBAAuB;AAAA,EACnE,SAAS,EAAE,IAAI,uBAAuB,MAAM,uBAAuB;AAAA,EACnE,OAAO,EAAE,IAAI,qBAAqB,MAAM,qBAAqB;AAAA,EAC7D,MAAM,EAAE,IAAI,oBAAoB,MAAM,oBAAoB;AAC5D;AAKA,MAAM,UAAU;AAChB,MAAM,UAAU;AAChB,MAAM,SAAS;AAEf,MAAM,MAAM,CAAC,eAA4C,EAAE,SAAS,QAAQ,YAAY,UAAU,UAAU,GAAG,UAAU;AAElH,SAAS,SAAS,EAAE,OAAO,OAAO,MAAM,OAAO,WAAW,UAAU,UAAU,OAAO,OAAO,GAAG,KAAK,GAAkB;AAC3H,QAAM,SAAS,QAAQ,SAAS,OAAO,IAAkB,IAAI;AAC7D,QAAM,UAAU,SAAS;AACzB,QAAM,YAAY,SAAS,EAAE,OAAO,SAAS,OAAO,KAAK,IAAI,IAAI;AACjE,QAAM,MAAM,YAAY,OAAO,SAAS,SAAS,OAAO,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,SAAS,O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sBAAsB;AAAA,YAC9C,CAAC;AAAA,YAED;AAAA,cAAC;AAAA;AAAA,gBACC,OAAO,GAAG;AAAA,kBACR,QAAQ;AAAA,kBACR,OAAO,MAAM;AAAA,kBACb,cAAc;AAAA,kBACd,YAAY,SAAS,SAAS,OAAO,KAAK,MAAM;AAAA,kBAChD,YAAY;AAAA,gBACd,CAAC;AAAA;AAAA,YACH;AAAA;AAAA,QACF,IAEA;AAAA,QAEH,OACC,oBAAC,SAAI,OAAO,IAAI,MAAM,GACnB,oBACC,oBAAC,YAAS,SAAQ,SAAQ,QAAQ,IAAI,OAAO,EAAE,OAAO,MAAM,GAAG,IAE/D,oBAAC,cAAW,IAAG,QAAO,SAAQ,WAAU,OAAM,aAC3C,gBACH,GAEJ,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CSSProperties } from 'react';
|
|
3
|
+
|
|
4
|
+
type StatusDotTone = 'success' | 'warning' | 'error' | 'info' | 'neutral';
|
|
5
|
+
type StatusDotSize = 'sm' | 'md';
|
|
6
|
+
/**
|
|
7
|
+
* A small colored dot for a state ("Open now", "Online"), optionally with a soft ring that
|
|
8
|
+
* pulses outward for a state that is live. The same dot `Badge` draws before its label, as its
|
|
9
|
+
* own piece for the places that have no pill around it (next to a name, on a list row).
|
|
10
|
+
*
|
|
11
|
+
* The dot says nothing to a screen reader by itself: put the meaning in the text next to it, or
|
|
12
|
+
* give it a `label` and it becomes an image with that name.
|
|
13
|
+
*/
|
|
14
|
+
interface StatusDotProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> {
|
|
15
|
+
/** The same words `Badge`, `Alert` and `Toast` use. */
|
|
16
|
+
tone?: StatusDotTone;
|
|
17
|
+
/** `sm` (5px) and `md` (6px) are the two dot sizes of `Badge`. */
|
|
18
|
+
size?: StatusDotSize;
|
|
19
|
+
/**
|
|
20
|
+
* A translucent ring that grows and fades around the dot, over and over. For a live state
|
|
21
|
+
* (open now, online), not for decoration: use it on one or two dots, never on a list. It does
|
|
22
|
+
* not show when the user asks for reduced motion.
|
|
23
|
+
*/
|
|
24
|
+
pulse?: boolean;
|
|
25
|
+
/** What a screen reader says for the dot. Without it the dot is decorative. */
|
|
26
|
+
label?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The look of a plain dot, in the form `Badge` has always drawn it. A function so `Badge` and
|
|
30
|
+
* `StatusDot` cannot drift apart. It sets no `display`: the dot is a flex item inside a `Badge`,
|
|
31
|
+
* and `StatusDot` adds its own.
|
|
32
|
+
*/
|
|
33
|
+
declare function statusDotStyle(tone?: StatusDotTone, size?: StatusDotSize): CSSProperties;
|
|
34
|
+
declare function StatusDot({ tone, size, pulse, label, style, ...rest }: StatusDotProps): React.JSX.Element;
|
|
35
|
+
|
|
36
|
+
export { StatusDot, type StatusDotProps, type StatusDotSize, type StatusDotTone, statusDotStyle };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { sx } from "../_internal/style.js";
|
|
4
|
+
const TONE_VAR = {
|
|
5
|
+
success: "--status-success-dot",
|
|
6
|
+
warning: "--status-warning-dot",
|
|
7
|
+
error: "--status-error-dot",
|
|
8
|
+
info: "--status-info-dot",
|
|
9
|
+
neutral: "--text-muted"
|
|
10
|
+
};
|
|
11
|
+
const SIZE_PX = { sm: 5, md: 6 };
|
|
12
|
+
function color(tone) {
|
|
13
|
+
return "var(" + (TONE_VAR[tone] || TONE_VAR.neutral) + ")";
|
|
14
|
+
}
|
|
15
|
+
function statusDotStyle(tone = "neutral", size = "md") {
|
|
16
|
+
const px = SIZE_PX[size] ?? SIZE_PX.md;
|
|
17
|
+
return { width: px, height: px, borderRadius: "999px", background: color(tone), flex: "0 0 auto" };
|
|
18
|
+
}
|
|
19
|
+
function StatusDot({ tone = "neutral", size = "md", pulse = false, label, style, ...rest }) {
|
|
20
|
+
const px = SIZE_PX[size] ?? SIZE_PX.md;
|
|
21
|
+
const named = label ? { role: "img", "aria-label": label } : null;
|
|
22
|
+
if (!pulse) return /* @__PURE__ */ jsx("span", { ...rest, ...named, style: sx({ ...statusDotStyle(tone, size), display: "inline-block", ...style }) });
|
|
23
|
+
return /* @__PURE__ */ jsxs("span", { ...rest, ...named, style: sx({ position: "relative", display: "inline-flex", width: px, height: px, flex: "0 0 auto", ...style }), children: [
|
|
24
|
+
/* @__PURE__ */ jsx("span", { className: "sereno-status-ping", style: sx({ position: "absolute", inset: 0, borderRadius: "999px", background: color(tone), opacity: 0 }) }),
|
|
25
|
+
/* @__PURE__ */ jsx("span", { style: sx({ position: "relative", width: px, height: px, borderRadius: "999px", background: color(tone) }) })
|
|
26
|
+
] });
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
StatusDot,
|
|
30
|
+
statusDotStyle
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=StatusDot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/StatusDot.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport type { CSSProperties } from 'react';\nimport { sx } from '../_internal/style';\n\nexport type StatusDotTone = 'success' | 'warning' | 'error' | 'info' | 'neutral';\nexport type StatusDotSize = 'sm' | 'md';\n\n/**\n * A small colored dot for a state (\"Open now\", \"Online\"), optionally with a soft ring that\n * pulses outward for a state that is live. The same dot `Badge` draws before its label, as its\n * own piece for the places that have no pill around it (next to a name, on a list row).\n *\n * The dot says nothing to a screen reader by itself: put the meaning in the text next to it, or\n * give it a `label` and it becomes an image with that name.\n */\nexport interface StatusDotProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'> {\n /** The same words `Badge`, `Alert` and `Toast` use. */\n tone?: StatusDotTone;\n /** `sm` (5px) and `md` (6px) are the two dot sizes of `Badge`. */\n size?: StatusDotSize;\n /**\n * A translucent ring that grows and fades around the dot, over and over. For a live state\n * (open now, online), not for decoration: use it on one or two dots, never on a list. It does\n * not show when the user asks for reduced motion.\n */\n pulse?: boolean;\n /** What a screen reader says for the dot. Without it the dot is decorative. */\n label?: string;\n}\n\nconst TONE_VAR: Record<StatusDotTone, string> = {\n success: '--status-success-dot',\n warning: '--status-warning-dot',\n error: '--status-error-dot',\n info: '--status-info-dot',\n neutral: '--text-muted',\n};\n\nconst SIZE_PX: Record<StatusDotSize, number> = { sm: 5, md: 6 };\n\nfunction color(tone: StatusDotTone): string {\n return 'var(' + (TONE_VAR[tone] || TONE_VAR.neutral) + ')';\n}\n\n/**\n * The look of a plain dot, in the form `Badge` has always drawn it. A function so `Badge` and\n * `StatusDot` cannot drift apart. It sets no `display`: the dot is a flex item inside a `Badge`,\n * and `StatusDot` adds its own.\n */\nexport function statusDotStyle(tone: StatusDotTone = 'neutral', size: StatusDotSize = 'md'): CSSProperties {\n const px = SIZE_PX[size] ?? SIZE_PX.md;\n return { width: px, height: px, borderRadius: '999px', background: color(tone), flex: '0 0 auto' };\n}\n\nexport function StatusDot({ tone = 'neutral', size = 'md', pulse = false, label, style, ...rest }: StatusDotProps) {\n const px = SIZE_PX[size] ?? SIZE_PX.md;\n const named = label ? ({ role: 'img', 'aria-label': label } as const) : null;\n\n if (!pulse) return <span {...rest} {...named} style={sx({ ...statusDotStyle(tone, size), display: 'inline-block', ...style })} />;\n\n return (\n <span {...rest} {...named} style={sx({ position: 'relative', display: 'inline-flex', width: px, height: px, flex: '0 0 auto', ...style })}>\n {/* the ring: invisible at rest, so nothing shows where the animation does not run */}\n <span className=\"sereno-status-ping\" style={sx({ position: 'absolute', inset: 0, borderRadius: '999px', background: color(tone), opacity: 0 })} />\n <span style={sx({ position: 'relative', width: px, height: px, borderRadius: '999px', background: color(tone) })} />\n </span>\n );\n}\n"],"mappings":";AA4DqB,cAGjB,YAHiB;AAxDrB,SAAS,UAAU;AA4BnB,MAAM,WAA0C;AAAA,EAC9C,SAAS;AAAA,E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';
|
|
2
|
+
import { CalendarDotTone } from './_internal/calendarDots.js';
|
|
3
|
+
|
|
4
|
+
interface CalendarLegendItem {
|
|
5
|
+
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* The filled dot the calendar draws under a day (`dayDots`). `true` is the primary color; a
|
|
8
|
+
* tone picks the status color the same way `dayDots` does.
|
|
9
|
+
*/
|
|
10
|
+
dot?: boolean | CalendarDotTone;
|
|
11
|
+
/** The thin ring the calendar draws around today. Together with `dot`, the dot sits inside the ring. */
|
|
12
|
+
outline?: boolean;
|
|
13
|
+
}
|
|
14
|
+
interface CalendarLegendProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'children'> {
|
|
15
|
+
/** One entry per thing the calendar marks. An item with neither `dot` nor `outline` is just its label. */
|
|
16
|
+
items: CalendarLegendItem[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The footer that explains what a calendar marks (`dayDots`, today's ring), so the screens that
|
|
20
|
+
* show one explain it the same way. Draws the same dot and ring the calendar does, from the
|
|
21
|
+
* same functions. Put it right under the `DateTimePicker`; it wraps on a narrow screen.
|
|
22
|
+
*/
|
|
23
|
+
declare function CalendarLegend({ items, style, ...rest }: CalendarLegendProps): React.JSX.Element;
|
|
24
|
+
declare namespace CalendarLegend {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export { CalendarLegend, type CalendarLegendItem, type CalendarLegendProps };
|