@sereno-ds/ui 0.38.0 → 0.39.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/StatCard.d.ts +40 -0
- package/dist/core/StatCard.js +79 -0
- package/dist/core/StatCard.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 +3 -0
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- 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,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,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,YAAY,2BAA2B,YAAY,KAAK,GAAG,UAAU,GACtH,iBACH,GAEJ;AAAA,QAEC,WACC,UACE,oBAAC,YAAS,SAAQ,SAAQ,QAAQ,GAAG,OAAO,EAAE,WAAW,iBAAiB,GAAG,IAE7E;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,iBAAe;AAAA,YACf,iBAAe;AAAA,YACf,iBAAe;AAAA,YACf,cAAY,SAAS,SAAS;AAAA,YAC9B,OAAO,GAAG;AAAA,cACR,WAAW;AAAA,cACX,QAAQ;AAAA,cACR,OAAO;AAAA,cACP,UAAU;AAAA,cACV,cAAc;AAAA,cACd,YAAY,UAAU,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,28 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
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 };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { sx } from "../_internal/style.js";
|
|
4
|
+
import { Typography } from "../core/Typography.js";
|
|
5
|
+
import { dotStyle, TODAY_RING } from "./_internal/calendarDots.js";
|
|
6
|
+
const RING = 12;
|
|
7
|
+
function Swatch({ dot, outline }) {
|
|
8
|
+
const tone = typeof dot === "string" ? dot : "brand";
|
|
9
|
+
const dotEl = dot ? /* @__PURE__ */ jsx("span", { style: dotStyle(tone) }) : null;
|
|
10
|
+
if (!outline) return dotEl;
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
style: sx({
|
|
15
|
+
display: "inline-flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
width: RING,
|
|
19
|
+
height: RING,
|
|
20
|
+
flex: "0 0 auto",
|
|
21
|
+
borderRadius: "var(--radius-xs)",
|
|
22
|
+
boxShadow: TODAY_RING
|
|
23
|
+
}),
|
|
24
|
+
children: dotEl
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function CalendarLegend({ items, style, ...rest }) {
|
|
29
|
+
return /* @__PURE__ */ jsx(
|
|
30
|
+
"ul",
|
|
31
|
+
{
|
|
32
|
+
role: "list",
|
|
33
|
+
...rest,
|
|
34
|
+
style: sx({
|
|
35
|
+
display: "flex",
|
|
36
|
+
flexWrap: "wrap",
|
|
37
|
+
alignItems: "center",
|
|
38
|
+
justifyContent: "center",
|
|
39
|
+
gap: "var(--space-1) var(--space-4)",
|
|
40
|
+
listStyle: "none",
|
|
41
|
+
margin: 0,
|
|
42
|
+
padding: "var(--space-1) var(--space-2)",
|
|
43
|
+
...style
|
|
44
|
+
}),
|
|
45
|
+
children: items.map((item, i) => /* @__PURE__ */ jsxs("li", { style: sx({ display: "inline-flex", alignItems: "center", gap: 6 }), children: [
|
|
46
|
+
item.dot || item.outline ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: sx({ display: "inline-flex" }), children: /* @__PURE__ */ jsx(Swatch, { dot: item.dot, outline: item.outline }) }) : null,
|
|
47
|
+
/* @__PURE__ */ jsx(Typography, { as: "span", variant: "caption", color: "secondary", children: item.label })
|
|
48
|
+
] }, i))
|
|
49
|
+
}
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
CalendarLegend.displayName = "CalendarLegend";
|
|
53
|
+
export {
|
|
54
|
+
CalendarLegend
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=CalendarLegend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/forms/CalendarLegend.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { Typography } from '../core/Typography';\nimport { dotStyle, TODAY_RING, type CalendarDotTone } from './_internal/calendarDots';\n\nexport interface CalendarLegendItem {\n label: string;\n /**\n * The filled dot the calendar draws under a day (`dayDots`). `true` is the primary color; a\n * tone picks the status color the same way `dayDots` does.\n */\n dot?: boolean | CalendarDotTone;\n /** The thin ring the calendar draws around today. Together with `dot`, the dot sits inside the ring. */\n outline?: boolean;\n}\n\nexport interface CalendarLegendProps extends Omit<React.HTMLAttributes<HTMLUListElement>, 'children'> {\n /** One entry per thing the calendar marks. An item with neither `dot` nor `outline` is just its label. */\n items: CalendarLegendItem[];\n}\n\nconst RING = 12;\n\nfunction Swatch({ dot, outline }: Pick<CalendarLegendItem, 'dot' | 'outline'>) {\n const tone: CalendarDotTone = typeof dot === 'string' ? dot : 'brand';\n const dotEl = dot ? <span style={dotStyle(tone)} /> : null;\n if (!outline) return dotEl;\n return (\n <span\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: RING,\n height: RING,\n flex: '0 0 auto',\n borderRadius: 'var(--radius-xs)',\n boxShadow: TODAY_RING,\n })}\n >\n {dotEl}\n </span>\n );\n}\n\n/**\n * The footer that explains what a calendar marks (`dayDots`, today's ring), so the screens that\n * show one explain it the same way. Draws the same dot and ring the calendar does, from the\n * same functions. Put it right under the `DateTimePicker`; it wraps on a narrow screen.\n */\nexport function CalendarLegend({ items, style, ...rest }: CalendarLegendProps) {\n return (\n <ul\n // `list-style: none` makes Safari drop the list semantics; the role keeps them.\n role=\"list\"\n {...rest}\n style={sx({\n display: 'flex',\n flexWrap: 'wrap',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 'var(--space-1) var(--space-4)',\n listStyle: 'none',\n margin: 0,\n padding: 'var(--space-1) var(--space-2)',\n ...style,\n })}\n >\n {items.map((item, i) => (\n <li key={i} style={sx({ display: 'inline-flex', alignItems: 'center', gap: 6 })}>\n {item.dot || item.outline ? (\n <span aria-hidden style={sx({ display: 'inline-flex' })}>\n <Swatch dot={item.dot} outline={item.outline} />\n </span>\n ) : null}\n <Typography as=\"span\" variant=\"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AAK,SAAS,GAChD,IACE;AAAA,QACJ,oBAAC,cAAW,IAAG,QAAO,SAAQ,WAAU,OAAM,aAC3C,eAAK,OACR;AAAA,WARO,CAST,CACD;AAAA;AAAA,EACH;AAEJ;AAEA,eAAe,cAAc;","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Imperative handle exposed via `ref` - there's no single native element
|
|
@@ -35,6 +36,26 @@ interface DatePickerProps {
|
|
|
35
36
|
min?: string;
|
|
36
37
|
/** Latest selectable date, ISO "YYYY-MM-DD". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */
|
|
37
38
|
max?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Fires when the month on screen changes (the arrows, or the month / year popover), with the
|
|
41
|
+
* new year and the 0-indexed month. Not when the popover opens: it opens on the month of the
|
|
42
|
+
* value, or on the current one. Refresh `dayDots` / `renderDay` here.
|
|
43
|
+
*/
|
|
44
|
+
onMonthChange?: (year: number, month: number) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second
|
|
47
|
+
* argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells
|
|
48
|
+
* grow taller to hold it.
|
|
49
|
+
*/
|
|
50
|
+
renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;
|
|
51
|
+
/**
|
|
52
|
+
* The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers
|
|
53
|
+
* (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of
|
|
54
|
+
* the month on screen, so refresh them in `onMonthChange`.
|
|
55
|
+
*/
|
|
56
|
+
dayDots?: CalendarDayDots;
|
|
57
|
+
/** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */
|
|
58
|
+
dayDotLabel?: string;
|
|
38
59
|
id?: string;
|
|
39
60
|
containerStyle?: React.CSSProperties;
|
|
40
61
|
/** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */
|
package/dist/forms/DatePicker.js
CHANGED
|
@@ -32,6 +32,10 @@ const DatePicker = React.forwardRef(function DatePicker2({
|
|
|
32
32
|
onChange,
|
|
33
33
|
min,
|
|
34
34
|
max,
|
|
35
|
+
onMonthChange,
|
|
36
|
+
renderDay,
|
|
37
|
+
dayDots,
|
|
38
|
+
dayDotLabel,
|
|
35
39
|
id,
|
|
36
40
|
containerStyle,
|
|
37
41
|
clearLabel,
|
|
@@ -196,7 +200,11 @@ const DatePicker = React.forwardRef(function DatePicker2({
|
|
|
196
200
|
onMonthChange: (y, m) => {
|
|
197
201
|
setViewYear(y);
|
|
198
202
|
setViewMonth(m);
|
|
203
|
+
onMonthChange?.(y, m);
|
|
199
204
|
},
|
|
205
|
+
renderDay,
|
|
206
|
+
dayDots,
|
|
207
|
+
dayDotLabel,
|
|
200
208
|
onSelectDate: commit,
|
|
201
209
|
squareCells: true,
|
|
202
210
|
trimEmptyRows: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // A plain `position: absolute` child of `rootRef` (itself `position:\n // relative`) - the same \"inline\" strategy Select's panel uses for its\n // common case, and the same one DateTimePicker's own month/year popover\n // already uses. The browser glues it to the trigger through *any* scroll\n // (page or a nested overflow container) for free - no JS measuring\n // position, no listening for scroll/resize, and critically, it never has\n // to close on scroll the way a `position: fixed` popover computed once\n // would (that was tried first here and didn't hold up - see PR history).\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && (\n <div\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: 0,\n right: 0,\n // The 7-column grid needs some floor width to stay readable -\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\n zIndex: 20,\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n }}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AA6LU,SAyBE,KAzBF;AA3LV,YAAY,WAAW;AACvB,SAAS,YAAY,cA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\n\nimport * as React from 'react';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // A plain `position: absolute` child of `rootRef` (itself `position:\n // relative`) - the same \"inline\" strategy Select's panel uses for its\n // common case, and the same one DateTimePicker's own month/year popover\n // already uses. The browser glues it to the trigger through *any* scroll\n // (page or a nested overflow container) for free - no JS measuring\n // position, no listening for scroll/resize, and critically, it never has\n // to close on scroll the way a `position: fixed` popover computed once\n // would (that was tried first here and didn't hold up - see PR history).\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && (\n <div\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: 0,\n right: 0,\n // The 7-column grid needs some floor width to stay readable -\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\n zIndex: 20,\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AAsNU,SAyBE,KAzBF;AApNV,YAAY,WAAW;AACvB,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAE7B,SAAS,g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CalendarDayContext, CalendarDayDots } from './_internal/calendarDots.js';
|
|
3
|
+
export { CalendarDayDot, CalendarDotTone } from './_internal/calendarDots.js';
|
|
2
4
|
|
|
3
5
|
interface TimeSlot {
|
|
4
6
|
value: string;
|
|
@@ -67,11 +69,25 @@ interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
67
69
|
/** Fires whenever the visible month changes (arrows or the month/year popover). */
|
|
68
70
|
onMonthChange?: (year: number, month: number) => void;
|
|
69
71
|
/**
|
|
70
|
-
* Extra content under each day number - a count badge, a
|
|
72
|
+
* Extra content under each day number - a count badge, a note, etc. Return
|
|
71
73
|
* `null` for days with nothing to show. When set, every cell grows to keep the
|
|
72
74
|
* grid even. It's the caller's job to scope this (e.g. future days only).
|
|
75
|
+
* The second argument says what the calendar already knows about the day: whether it is
|
|
76
|
+
* `selected` (painted with the primary color, so content there needs `--interactive-primary-fg`),
|
|
77
|
+
* `today`, or `unavailable`.
|
|
73
78
|
*/
|
|
74
|
-
renderDay?: (day: number) => React.ReactNode;
|
|
79
|
+
renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;
|
|
80
|
+
/**
|
|
81
|
+
* The days that get a dot under their number, for "something happens this day": a list of day
|
|
82
|
+
* numbers (`[3, 17]`), or an object keyed by day number when a dot needs its own `tone` or
|
|
83
|
+
* `label` (`{ 3: { tone: 'warning' } }`). The calendar places the dot and turns it to
|
|
84
|
+
* `--interactive-primary-fg` on the selected day, so nothing has to be redone in `renderDay`.
|
|
85
|
+
* Day numbers of the month on screen, like `unavailable`: refresh them in `onMonthChange`.
|
|
86
|
+
* Shares the slot under the number with `renderDay`, and grows the cells the same way.
|
|
87
|
+
*/
|
|
88
|
+
dayDots?: CalendarDayDots;
|
|
89
|
+
/** What a screen reader says for a dot with no `label` of its own, after the day number. Defaults to the `locale`-appropriate text ("com marcador" / "marked"). */
|
|
90
|
+
dayDotLabel?: string;
|
|
75
91
|
/** Defaults to the `locale`-appropriate label ("Horários disponíveis" / "Available times"). */
|
|
76
92
|
timeLabel?: string;
|
|
77
93
|
/**
|
|
@@ -92,4 +108,4 @@ interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
|
|
|
92
108
|
*/
|
|
93
109
|
declare const DateTimePicker: React.ForwardRefExoticComponent<DateTimePickerProps & React.RefAttributes<HTMLDivElement>>;
|
|
94
110
|
|
|
95
|
-
export { DateTimePicker, type DateTimePickerProps, type TimeSlot };
|
|
111
|
+
export { CalendarDayContext, CalendarDayDots, DateTimePicker, type DateTimePickerProps, type TimeSlot };
|
|
@@ -32,6 +32,8 @@ const DateTimePicker = React.forwardRef(function DateTimePicker2({
|
|
|
32
32
|
onSelectTime,
|
|
33
33
|
onMonthChange,
|
|
34
34
|
renderDay,
|
|
35
|
+
dayDots,
|
|
36
|
+
dayDotLabel,
|
|
35
37
|
timeLabel,
|
|
36
38
|
locale = "pt-BR",
|
|
37
39
|
style,
|
|
@@ -67,6 +69,8 @@ const DateTimePicker = React.forwardRef(function DateTimePicker2({
|
|
|
67
69
|
onSelectDate,
|
|
68
70
|
onMonthChange,
|
|
69
71
|
renderDay,
|
|
72
|
+
dayDots,
|
|
73
|
+
dayDotLabel,
|
|
70
74
|
locale
|
|
71
75
|
}
|
|
72
76
|
),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { CalendarGrid } from './_internal/CalendarGrid';\n\nconst TEXT = {\n 'pt-BR': {\n timeLabel: 'Horários disponíveis',\n full: 'Lotado',\n fullInline: 'lotado',\n available: 'Disponível',\n vagas: (booked: number, capacity: number) => `${booked} de ${capacity} vagas`,\n },\n en: {\n timeLabel: 'Available times',\n full: 'Full',\n fullInline: 'full',\n available: 'Available',\n vagas: (booked: number, capacity: number) => `${booked} of ${capacity} spots`,\n },\n} as const;\n\nexport interface TimeSlot {\n value: string;\n /** Hard-blocked - unclickable regardless of `capacity`/`booked`. */\n disabled?: boolean;\n /** Total spots this slot holds - a group session, a class. Omit for a\n * plain 1:1 slot with no capacity tracking (the original contract). */\n capacity?: number;\n /** How many are already booked into it. */\n booked?: number;\n}\n\n/**\n * Month calendar plus available time slots - the heart of the public booking flow.\n * Day names and month names render in pt-BR by default - the real Sereno\n * product always uses it; `locale=\"en\"` exists only for docs/demo purposes.\n *\n * The header navigates: ‹ / › step the month, and the centred title opens a\n * popover to jump straight to a month or year. `year` / `month` set the *initial*\n * view; the component then owns it. Pass `onMonthChange` to react to navigation\n * (e.g. fetch the new month's availability).\n *\n * The day grid uses roving tabindex (SS-228) - only one cell is ever in the\n * Tab order, so Tab enters/leaves it in one stop instead of one per day.\n * Arrow keys move by day/week and cross month boundaries on overflow;\n * Home/End move within the current week row; PageUp/PageDown step the\n * month. An `unavailable` day stays focusable (`aria-disabled`, not the\n * native `disabled` - a disabled button can't receive focus at all) so the\n * cursor can still land on it, just not select it.\n *\n * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`,\n * shared with `DatePicker` (SS-243), which wraps the same grid in a\n * trigger+popover shell instead of this component's always-visible card.\n */\nexport interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Initial year. Defaults to the current year. */\n year?: number;\n /** Initial month, 0-indexed. Defaults to the current month. */\n month?: number;\n /** Selected day-of-month. The highlight only shows in the month it was picked\n * in - navigating away and back to a *different* month never re-highlights it. */\n selectedDate?: number;\n /**\n * Slot labels (\"09:00\") or `TimeSlot` objects. A slot with `capacity` set\n * shows \"booked/capacity\" and switches to a full/overbook-warning look\n * once reached (SS-64) - still pickable unless also `disabled`, since a\n * full slot and a *blocked* one are different things: the first is a\n * deliberate \"yes, overbook it\" the caller can still choose to allow.\n */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability - struck through and unclickable. */\n unavailable?: number[];\n /**\n * Earliest date, ISO \"YYYY-MM-DD\" (the same prop `DatePicker` has). The calendar cannot be\n * navigated to an earlier month or year: the previous-month arrow disables, PageUp and the\n * arrow keys stop at the edge, and the month / year popover disables what is out of range.\n * Every earlier day is struck through on its own, merged with `unavailable`, so there is no\n * need to work out the past days. If `year` / `month` start outside the range they are moved\n * to the nearest month inside it, and `onMonthChange` reports that month at mount.\n */\n min?: string;\n /** Latest date, ISO \"YYYY-MM-DD\". The mirror image of `min`. */\n max?: string;\n onSelectDate?: (day: number) => void;\n onSelectTime?: (time: string) => void;\n /** Fires whenever the visible month changes (arrows or the month/year popover). */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Extra content under each day number - a count badge, a dot, etc. Return\n * `null` for days with nothing to show. When set, every cell grows to keep the\n * grid even. It's the caller's job to scope this (e.g. future days only).\n */\n renderDay?: (day: number) => React.ReactNode;\n /** Defaults to the `locale`-appropriate label (\"Horários disponíveis\" / \"Available times\"). */\n timeLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\n/**\n * `ref` reaches the root `<div>` - plain DOM access (measuring, scrolling\n * into view), not a form value. This isn't a single-value field: the day and\n * the time are two separate, parent-owned selections (`selectedDate` /\n * `selectedTime` + their own `onSelectDate` / `onSelectTime` callbacks), so\n * there's no one \"value\" for `react-hook-form` to register. Register the\n * date and the time as two separate fields at the call site instead (see\n * `DatePicker` for a single-value date field with the same calendar).\n */\nexport const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(function DateTimePicker(\n {\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n min,\n max,\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n },\n ref,\n) {\n const copy = TEXT[locale];\n const label = timeLabel ?? copy.timeLabel;\n // If any slot in the list tracks capacity, plain slots grow the same\n // two-line layout with a generic \"available\" filler instead of leaving a\n // shorter, blank-looking card next to its neighbors (SS-64 follow-up).\n const anyCapacity = times.some((s) => typeof s === 'object' && s.capacity !== undefined);\n return (\n <div\n ref={ref}\n {...rest}\n style={sx({\n position: 'relative',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-card)',\n padding: 'var(--space-4)',\n boxShadow: 'var(--shadow-sm)',\n ...style,\n })}\n >\n <CalendarGrid\n year={year}\n month={month}\n selectedDate={selectedDate}\n unavailable={unavailable}\n min={min}\n max={max}\n onSelectDate={onSelectDate}\n onMonthChange={onMonthChange}\n renderDay={renderDay}\n locale={locale}\n />\n {times.length > 0 && (\n <div style={sx({ marginTop: 'var(--space-4)', paddingTop: 'var(--space-4)', borderTop: 'var(--border-width-hairline) solid var(--border-subtle)' })}>\n <div\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n letterSpacing: 'var(--tracking-caps)',\n textTransform: 'uppercase',\n marginBottom: 'var(--space-3)',\n })}\n >\n {label}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((slot) => {\n const val = typeof slot === 'string' ? slot : slot.value;\n const dis = typeof slot === 'object' && slot.disabled;\n const capacity = typeof slot === 'object' ? slot.capacity : undefined;\n const booked = typeof slot === 'object' ? (slot.booked ?? 0) : 0;\n const hasOwnCapacity = capacity !== undefined;\n // Full ≠ blocked: a full slot is still pickable (a deliberate\n // overbook) unless the caller *also* set `disabled` - that's\n // the actual hard \"no\" (SS-64).\n const full = hasOwnCapacity && booked >= capacity;\n const sel = selectedTime === val;\n // A slot with no capacity of its own still grows the two-line\n // layout when a *sibling* slot tracks capacity, so the row\n // reads consistently instead of one short card among tall ones.\n const showSecondLine = hasOwnCapacity || anyCapacity;\n const secondLine = hasOwnCapacity ? (full ? copy.full : copy.vagas(booked, capacity)) : copy.available;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n aria-label={hasOwnCapacity ? `${val}, ${full ? copy.fullInline + ', ' : ''}${copy.vagas(booked, capacity)}` : undefined}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: showSecondLine ? 'auto' : 'var(--control-height-md)',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n padding: showSecondLine ? 'var(--space-2) 0' : 0,\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border:\n 'var(--border-width-hairline) solid ' +\n (sel ? 'transparent' : full && !dis ? 'var(--interactive-warning)' : 'var(--border-default)'),\n background: sel\n ? 'var(--interactive-accent)'\n : dis\n ? 'var(--interactive-disabled-bg)'\n : full\n ? 'var(--status-warning-bg)'\n : 'var(--bg-surface)',\n color: sel\n ? 'var(--interactive-accent-fg)'\n : dis\n ? 'var(--interactive-disabled-fg)'\n : full\n ? 'var(--status-warning-fg)'\n : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n // Not inline outline:none - see .sereno-dtp-time in styles.css.\n })}\n >\n <span aria-hidden={hasOwnCapacity}>{val}</span>\n {showSecondLine && (\n <span\n aria-hidden={hasOwnCapacity}\n style={sx({\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-medium)',\n color: sel ? 'inherit' : full ? 'var(--status-warning-fg)' : 'var(--text-muted)',\n opacity: sel ? 0.85 : 1,\n })}\n >\n {secondLine}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n});\n\nDateTimePicker.displayName = 'DateTimePicker';\n"],"mappings":";AA4JM,cA6CU,YA7CV;AA1JN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,MAAM,OAAO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AAQ,MAAM,gBAAgB;AAAA,kBAC9B,QACE,yCACC,MAAM,gBAAgB,QAAQ,CAAC,MAAM,+BAA+B;AAAA,kBACvE,YAAY,MACR,8BACA,MACE,mCACA,OACE,6BACA;AAAA,kBACR,OAAO,MACH,iCACA,MACE,mCACA,OACE,6BACA;AAAA,kBACR,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,YAAY;AAAA;AAAA,gBAEd,CAAC;AAAA,gBAED;AAAA,sCAAC,UAAK,eAAa,gBAAiB,eAAI;AAAA,kBACvC,kBACC;AAAA,oBAAC;AAAA;AAAA,sBACC,eAAa;AAAA,sBACb,OAAO,GAAG;AAAA,wBACR,UAAU;AAAA,wBACV,YAAY;AAAA,wBACZ,OAAO,MAAM,YAAY,OAAO,6BAA6B;AAAA,wBAC7D,SAAS,MAAM,OAAO;AAAA,sBACxB,CAAC;AAAA,sBAEA;AAAA;AAAA,kBACH;AAAA;AAAA;AAAA,cApDG;AAAA,YAsDP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["DateTimePicker"]}
|
|
1
|
+
{"version":3,"sources":["../../src/forms/DateTimePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\n\nexport type { CalendarDayContext, CalendarDayDot, CalendarDayDots, CalendarDotTone } from './_internal/calendarDots';\n\nconst TEXT = {\n 'pt-BR': {\n timeLabel: 'Horários disponíveis',\n full: 'Lotado',\n fullInline: 'lotado',\n available: 'Disponível',\n vagas: (booked: number, capacity: number) => `${booked} de ${capacity} vagas`,\n },\n en: {\n timeLabel: 'Available times',\n full: 'Full',\n fullInline: 'full',\n available: 'Available',\n vagas: (booked: number, capacity: number) => `${booked} of ${capacity} spots`,\n },\n} as const;\n\nexport interface TimeSlot {\n value: string;\n /** Hard-blocked - unclickable regardless of `capacity`/`booked`. */\n disabled?: boolean;\n /** Total spots this slot holds - a group session, a class. Omit for a\n * plain 1:1 slot with no capacity tracking (the original contract). */\n capacity?: number;\n /** How many are already booked into it. */\n booked?: number;\n}\n\n/**\n * Month calendar plus available time slots - the heart of the public booking flow.\n * Day names and month names render in pt-BR by default - the real Sereno\n * product always uses it; `locale=\"en\"` exists only for docs/demo purposes.\n *\n * The header navigates: ‹ / › step the month, and the centred title opens a\n * popover to jump straight to a month or year. `year` / `month` set the *initial*\n * view; the component then owns it. Pass `onMonthChange` to react to navigation\n * (e.g. fetch the new month's availability).\n *\n * The day grid uses roving tabindex (SS-228) - only one cell is ever in the\n * Tab order, so Tab enters/leaves it in one stop instead of one per day.\n * Arrow keys move by day/week and cross month boundaries on overflow;\n * Home/End move within the current week row; PageUp/PageDown step the\n * month. An `unavailable` day stays focusable (`aria-disabled`, not the\n * native `disabled` - a disabled button can't receive focus at all) so the\n * cursor can still land on it, just not select it.\n *\n * The calendar body itself (header + day grid) is `./_internal/CalendarGrid`,\n * shared with `DatePicker` (SS-243), which wraps the same grid in a\n * trigger+popover shell instead of this component's always-visible card.\n */\nexport interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /** Initial year. Defaults to the current year. */\n year?: number;\n /** Initial month, 0-indexed. Defaults to the current month. */\n month?: number;\n /** Selected day-of-month. The highlight only shows in the month it was picked\n * in - navigating away and back to a *different* month never re-highlights it. */\n selectedDate?: number;\n /**\n * Slot labels (\"09:00\") or `TimeSlot` objects. A slot with `capacity` set\n * shows \"booked/capacity\" and switches to a full/overbook-warning look\n * once reached (SS-64) - still pickable unless also `disabled`, since a\n * full slot and a *blocked* one are different things: the first is a\n * deliberate \"yes, overbook it\" the caller can still choose to allow.\n */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability - struck through and unclickable. */\n unavailable?: number[];\n /**\n * Earliest date, ISO \"YYYY-MM-DD\" (the same prop `DatePicker` has). The calendar cannot be\n * navigated to an earlier month or year: the previous-month arrow disables, PageUp and the\n * arrow keys stop at the edge, and the month / year popover disables what is out of range.\n * Every earlier day is struck through on its own, merged with `unavailable`, so there is no\n * need to work out the past days. If `year` / `month` start outside the range they are moved\n * to the nearest month inside it, and `onMonthChange` reports that month at mount.\n */\n min?: string;\n /** Latest date, ISO \"YYYY-MM-DD\". The mirror image of `min`. */\n max?: string;\n onSelectDate?: (day: number) => void;\n onSelectTime?: (time: string) => void;\n /** Fires whenever the visible month changes (arrows or the month/year popover). */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Extra content under each day number - a count badge, a note, etc. Return\n * `null` for days with nothing to show. When set, every cell grows to keep the\n * grid even. It's the caller's job to scope this (e.g. future days only).\n * The second argument says what the calendar already knows about the day: whether it is\n * `selected` (painted with the primary color, so content there needs `--interactive-primary-fg`),\n * `today`, or `unavailable`.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, for \"something happens this day\": a list of day\n * numbers (`[3, 17]`), or an object keyed by day number when a dot needs its own `tone` or\n * `label` (`{ 3: { tone: 'warning' } }`). The calendar places the dot and turns it to\n * `--interactive-primary-fg` on the selected day, so nothing has to be redone in `renderDay`.\n * Day numbers of the month on screen, like `unavailable`: refresh them in `onMonthChange`.\n * Shares the slot under the number with `renderDay`, and grows the cells the same way.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own, after the day number. Defaults to the `locale`-appropriate text (\"com marcador\" / \"marked\"). */\n dayDotLabel?: string;\n /** Defaults to the `locale`-appropriate label (\"Horários disponíveis\" / \"Available times\"). */\n timeLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\n/**\n * `ref` reaches the root `<div>` - plain DOM access (measuring, scrolling\n * into view), not a form value. This isn't a single-value field: the day and\n * the time are two separate, parent-owned selections (`selectedDate` /\n * `selectedTime` + their own `onSelectDate` / `onSelectTime` callbacks), so\n * there's no one \"value\" for `react-hook-form` to register. Register the\n * date and the time as two separate fields at the call site instead (see\n * `DatePicker` for a single-value date field with the same calendar).\n */\nexport const DateTimePicker = React.forwardRef<HTMLDivElement, DateTimePickerProps>(function DateTimePicker(\n {\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n min,\n max,\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n },\n ref,\n) {\n const copy = TEXT[locale];\n const label = timeLabel ?? copy.timeLabel;\n // If any slot in the list tracks capacity, plain slots grow the same\n // two-line layout with a generic \"available\" filler instead of leaving a\n // shorter, blank-looking card next to its neighbors (SS-64 follow-up).\n const anyCapacity = times.some((s) => typeof s === 'object' && s.capacity !== undefined);\n return (\n <div\n ref={ref}\n {...rest}\n style={sx({\n position: 'relative',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-card)',\n padding: 'var(--space-4)',\n boxShadow: 'var(--shadow-sm)',\n ...style,\n })}\n >\n <CalendarGrid\n year={year}\n month={month}\n selectedDate={selectedDate}\n unavailable={unavailable}\n min={min}\n max={max}\n onSelectDate={onSelectDate}\n onMonthChange={onMonthChange}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n locale={locale}\n />\n {times.length > 0 && (\n <div style={sx({ marginTop: 'var(--space-4)', paddingTop: 'var(--space-4)', borderTop: 'var(--border-width-hairline) solid var(--border-subtle)' })}>\n <div\n style={sx({\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n letterSpacing: 'var(--tracking-caps)',\n textTransform: 'uppercase',\n marginBottom: 'var(--space-3)',\n })}\n >\n {label}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((slot) => {\n const val = typeof slot === 'string' ? slot : slot.value;\n const dis = typeof slot === 'object' && slot.disabled;\n const capacity = typeof slot === 'object' ? slot.capacity : undefined;\n const booked = typeof slot === 'object' ? (slot.booked ?? 0) : 0;\n const hasOwnCapacity = capacity !== undefined;\n // Full ≠ blocked: a full slot is still pickable (a deliberate\n // overbook) unless the caller *also* set `disabled` - that's\n // the actual hard \"no\" (SS-64).\n const full = hasOwnCapacity && booked >= capacity;\n const sel = selectedTime === val;\n // A slot with no capacity of its own still grows the two-line\n // layout when a *sibling* slot tracks capacity, so the row\n // reads consistently instead of one short card among tall ones.\n const showSecondLine = hasOwnCapacity || anyCapacity;\n const secondLine = hasOwnCapacity ? (full ? copy.full : copy.vagas(booked, capacity)) : copy.available;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n aria-label={hasOwnCapacity ? `${val}, ${full ? copy.fullInline + ', ' : ''}${copy.vagas(booked, capacity)}` : undefined}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: showSecondLine ? 'auto' : 'var(--control-height-md)',\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 2,\n padding: showSecondLine ? 'var(--space-2) 0' : 0,\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border:\n 'var(--border-width-hairline) solid ' +\n (sel ? 'transparent' : full && !dis ? 'var(--interactive-warning)' : 'var(--border-default)'),\n background: sel\n ? 'var(--interactive-accent)'\n : dis\n ? 'var(--interactive-disabled-bg)'\n : full\n ? 'var(--status-warning-bg)'\n : 'var(--bg-surface)',\n color: sel\n ? 'var(--interactive-accent-fg)'\n : dis\n ? 'var(--interactive-disabled-fg)'\n : full\n ? 'var(--status-warning-fg)'\n : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n transition: 'var(--transition-control)',\n // Not inline outline:none - see .sereno-dtp-time in styles.css.\n })}\n >\n <span aria-hidden={hasOwnCapacity}>{val}</span>\n {showSecondLine && (\n <span\n aria-hidden={hasOwnCapacity}\n style={sx({\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-medium)',\n color: sel ? 'inherit' : full ? 'var(--status-warning-fg)' : 'var(--text-muted)',\n opacity: sel ? 0.85 : 1,\n })}\n >\n {secondLine}\n </span>\n )}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n});\n\nDateTimePicker.displayName = 'DateTimePicker';\n"],"mappings":";AA+KM,cA+CU,YA/CV;AA7KN,YAAY,WAAW;AACvB,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAK7B,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AAAA,EACA,IAAI;AAAA,IACF,WAAW;AAAA,IACX,MAAM;AAAA,IACN,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,OAAO,CAAC,QAAgB,aAAqB,GAAG,MAAM,OAAO,QAAQ;AAAA,EACvE;AACF;AA4GO,MAAM,iBAAiB,MAAM,WAAgD,SAASA,gBAC3F;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,CAAC;AAAA,EACT;AAAA,EACA,cAAc,CAAC;AAAA,EACf;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,OAAO,KAAK,MAAM;AACxB,QAAM,QAAQ,a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A,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ,CAAC;AAED,eAAe,cAAc;","names":["DateTimePicker"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { CalendarDayContext, CalendarDayDots } from './calendarDots.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The month calendar body - header (‹ / › month nav + a month/year jump
|
|
@@ -27,13 +28,21 @@ interface CalendarGridProps {
|
|
|
27
28
|
max?: string;
|
|
28
29
|
onSelectDate?: (day: number) => void;
|
|
29
30
|
onMonthChange?: (year: number, month: number) => void;
|
|
30
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Content under each day number. The second argument says what the calendar knows about the
|
|
33
|
+
* day (selected, today, unavailable), so the content can follow it without redoing the logic.
|
|
34
|
+
*/
|
|
35
|
+
renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;
|
|
36
|
+
/** The days that get a dot under their number (see `CalendarDayDots`). Shares the slot under the number with `renderDay`. */
|
|
37
|
+
dayDots?: CalendarDayDots;
|
|
38
|
+
/** What a screen reader says for a dot that has no `label` of its own. Defaults to the `locale`-appropriate text. */
|
|
39
|
+
dayDotLabel?: string;
|
|
31
40
|
/**
|
|
32
41
|
* Day cells are perfect squares (`aspect-ratio`) instead of a fixed pixel
|
|
33
42
|
* height - `DatePicker` (SS-243) opts into this since its popover can be
|
|
34
43
|
* narrower than `DateTimePicker`'s own card, where a fixed height was
|
|
35
|
-
* already tuned and shipped. Ignored when `renderDay` is set -
|
|
36
|
-
* always needs the extra fixed height for its own content.
|
|
44
|
+
* already tuned and shipped. Ignored when `renderDay` or `dayDots` is set -
|
|
45
|
+
* that case always needs the extra fixed height for its own content.
|
|
37
46
|
*/
|
|
38
47
|
squareCells?: boolean;
|
|
39
48
|
/**
|
|
@@ -51,6 +60,6 @@ interface CalendarGridProps {
|
|
|
51
60
|
*/
|
|
52
61
|
locale?: 'pt-BR' | 'en';
|
|
53
62
|
}
|
|
54
|
-
declare function CalendarGrid({ year, month, selectedDate, unavailable, min, max, onSelectDate, onMonthChange, renderDay, squareCells, trimEmptyRows, locale, }: CalendarGridProps): React.JSX.Element;
|
|
63
|
+
declare function CalendarGrid({ year, month, selectedDate, unavailable, min, max, onSelectDate, onMonthChange, renderDay, dayDots, dayDotLabel, squareCells, trimEmptyRows, locale, }: CalendarGridProps): React.JSX.Element;
|
|
55
64
|
|
|
56
65
|
export { CalendarGrid, type CalendarGridProps };
|
|
@@ -3,8 +3,10 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
|
|
5
5
|
import { sx } from "../../_internal/style.js";
|
|
6
|
+
import { srOnlyStyle } from "../../_internal/srOnly.js";
|
|
6
7
|
import { IconButton } from "../../core/IconButton.js";
|
|
7
8
|
import { calendarRange, clampIndex, isDayOutside, yearWindowStart } from "./calendarRange.js";
|
|
9
|
+
import { dotFor, dotStyle, TODAY_RING } from "./calendarDots.js";
|
|
8
10
|
const I18N = {
|
|
9
11
|
"pt-BR": {
|
|
10
12
|
dow: ["D", "S", "T", "Q", "Q", "S", "S"],
|
|
@@ -16,7 +18,8 @@ const I18N = {
|
|
|
16
18
|
prevYears: "Anos anteriores",
|
|
17
19
|
nextYear: "Pr\xF3ximo ano",
|
|
18
20
|
nextYears: "Pr\xF3ximos anos",
|
|
19
|
-
pickerLabel: "Escolher m\xEAs e ano"
|
|
21
|
+
pickerLabel: "Escolher m\xEAs e ano",
|
|
22
|
+
marked: "com marcador"
|
|
20
23
|
},
|
|
21
24
|
en: {
|
|
22
25
|
dow: ["S", "M", "T", "W", "T", "F", "S"],
|
|
@@ -28,7 +31,8 @@ const I18N = {
|
|
|
28
31
|
prevYears: "Previous years",
|
|
29
32
|
nextYear: "Next year",
|
|
30
33
|
nextYears: "Next years",
|
|
31
|
-
pickerLabel: "Choose month and year"
|
|
34
|
+
pickerLabel: "Choose month and year",
|
|
35
|
+
marked: "marked"
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
function daysIn(y, m) {
|
|
@@ -44,6 +48,8 @@ function CalendarGrid({
|
|
|
44
48
|
onSelectDate,
|
|
45
49
|
onMonthChange,
|
|
46
50
|
renderDay,
|
|
51
|
+
dayDots,
|
|
52
|
+
dayDotLabel,
|
|
47
53
|
squareCells = false,
|
|
48
54
|
trimEmptyRows = false,
|
|
49
55
|
locale = "pt-BR"
|
|
@@ -68,8 +74,8 @@ function CalendarGrid({
|
|
|
68
74
|
const gridRef = React.useRef(null);
|
|
69
75
|
const [activeDay, setActiveDay] = React.useState(() => {
|
|
70
76
|
if (selectedDate) return selectedDate;
|
|
71
|
-
const
|
|
72
|
-
let day =
|
|
77
|
+
const todayIndex2 = now.getFullYear() * 12 + now.getMonth();
|
|
78
|
+
let day = todayIndex2 === initialIndex ? now.getDate() : 1;
|
|
73
79
|
if (range.min && initialIndex === range.minIndex) day = Math.max(day, range.min.day);
|
|
74
80
|
if (range.max && initialIndex === range.maxIndex) day = Math.min(day, range.max.day);
|
|
75
81
|
return day;
|
|
@@ -122,7 +128,9 @@ function CalendarGrid({
|
|
|
122
128
|
if (trimEmptyRows) {
|
|
123
129
|
while (cells.length > 7 && cells.slice(-7).every((c) => c === null)) cells.length -= 7;
|
|
124
130
|
}
|
|
125
|
-
const
|
|
131
|
+
const hasSlot = !!renderDay || dayDots !== void 0;
|
|
132
|
+
const cellSizing = hasSlot ? { height: 48 } : squareCells ? { aspectRatio: "1" } : { height: 38 };
|
|
133
|
+
const todayIndex = now.getFullYear() * 12 + now.getMonth();
|
|
126
134
|
const years = Array.from({ length: 12 }, (_, i) => yearBase + i);
|
|
127
135
|
const rovingDay = Math.min(Math.max(1, activeDay), total);
|
|
128
136
|
const onGridKeyDown = (e) => {
|
|
@@ -400,13 +408,16 @@ function CalendarGrid({
|
|
|
400
408
|
if (d === null) return /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: cellSizing }, i);
|
|
401
409
|
const off = unavailable.includes(d) || isDayOutside(range, viewIndex, d);
|
|
402
410
|
const sel = selectedDate === d && viewIndex === selectionIndex;
|
|
403
|
-
const
|
|
411
|
+
const today = viewIndex === todayIndex && d === now.getDate();
|
|
412
|
+
const extra = renderDay?.(d, { selected: sel, today, unavailable: off });
|
|
413
|
+
const dot = dotFor(dayDots, d);
|
|
404
414
|
return /* @__PURE__ */ jsxs(
|
|
405
415
|
"button",
|
|
406
416
|
{
|
|
407
417
|
type: "button",
|
|
408
418
|
"data-day": d,
|
|
409
419
|
"aria-disabled": off || void 0,
|
|
420
|
+
"aria-current": today ? "date" : void 0,
|
|
410
421
|
tabIndex: d === rovingDay ? 0 : -1,
|
|
411
422
|
"aria-pressed": sel,
|
|
412
423
|
onClick: () => {
|
|
@@ -432,6 +443,9 @@ function CalendarGrid({
|
|
|
432
443
|
fontSize: "var(--text-sm)",
|
|
433
444
|
fontWeight: sel ? "var(--weight-bold)" : "var(--weight-medium)",
|
|
434
445
|
textDecoration: off ? "line-through" : "none",
|
|
446
|
+
// Today is told apart by a thin inset ring (also `aria-current` above). Not when it
|
|
447
|
+
// is the selected day: the primary fill already says which day it is.
|
|
448
|
+
boxShadow: today && !sel ? TODAY_RING : void 0,
|
|
435
449
|
transition: "var(--transition-control)"
|
|
436
450
|
// Not inline outline:none - that would always beat the
|
|
437
451
|
// .sereno-dtp-days:focus-visible rule below no matter what
|
|
@@ -441,7 +455,11 @@ function CalendarGrid({
|
|
|
441
455
|
}),
|
|
442
456
|
children: [
|
|
443
457
|
/* @__PURE__ */ jsx("span", { children: d }),
|
|
444
|
-
|
|
458
|
+
hasSlot ? /* @__PURE__ */ jsxs("span", { style: sx({ display: "flex", gap: 4, minHeight: 12, lineHeight: 1 }), children: [
|
|
459
|
+
extra,
|
|
460
|
+
dot ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: sx({ ...dotStyle(dot.tone, { selected: sel, unavailable: off }), alignSelf: "center" }) }) : null
|
|
461
|
+
] }) : null,
|
|
462
|
+
dot ? /* @__PURE__ */ jsx("span", { style: srOnlyStyle, children: dot.label ?? dayDotLabel ?? t.marked }) : null
|
|
445
463
|
]
|
|
446
464
|
},
|
|
447
465
|
i
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/forms/_internal/CalendarGrid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\nimport { sx } from '../../_internal/style';\nimport { IconButton } from '../../core/IconButton';\nimport { calendarRange, clampIndex, isDayOutside, yearWindowStart } from './calendarRange';\n\n/**\n * The month calendar body - header (‹ / › month nav + a month/year jump\n * popover) and the day grid with roving-tabindex keyboard navigation\n * (SS-228). Shared by `DateTimePicker` (rendered inline, with an optional\n * time-slot list under it) and `DatePicker` (rendered inside its own\n * trigger+popover shell) - extracted so neither has to duplicate the\n * keyboard-grid math (SS-243). See `DateTimePicker`'s own doc comment for\n * the full behavior description; this component owns exactly the same\n * state and logic it always has, just without the outer card chrome or\n * the time-slot section, neither of which any of this depends on.\n */\nexport interface CalendarGridProps {\n year?: number;\n month?: number;\n selectedDate?: number;\n unavailable?: number[];\n /**\n * Earliest date, ISO \"YYYY-MM-DD\". The calendar cannot be navigated to an earlier month or\n * year (the previous-month arrow disables, PageUp and the arrow keys stop at the edge, and\n * the month / year popover disables what is out of range), and every earlier day is struck\n * through, with no need to list it in `unavailable`. A value that is not a valid date is ignored.\n */\n min?: string;\n /** Latest date, ISO \"YYYY-MM-DD\". The mirror image of `min`. */\n max?: string;\n onSelectDate?: (day: number) => void;\n onMonthChange?: (year: number, month: number) => void;\n renderDay?: (day: number) => React.ReactNode;\n /**\n * Day cells are perfect squares (`aspect-ratio`) instead of a fixed pixel\n * height - `DatePicker` (SS-243) opts into this since its popover can be\n * narrower than `DateTimePicker`'s own card, where a fixed height was\n * already tuned and shipped. Ignored when `renderDay` is set - that case\n * always needs the extra fixed height for its own content.\n */\n squareCells?: boolean;\n /**\n * Drop wholly-blank trailing rows instead of always padding to 6 (SS-243)\n * `DateTimePicker` needs the fixed 6 rows so its *always-visible* card\n * never jumps height as you navigate months; `DatePicker`'s popover opens\n * and closes anyway, so a variable height per month reads better than a\n * dead empty row (e.g. a 30-day month starting on Sunday only needs 5).\n */\n trimEmptyRows?: boolean;\n /**\n * The product itself (Sereno's real booking app) always renders pt-BR -\n * this only exists so the docs showcase can demo an English-speaking\n * consumer without forking the component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\nconst I18N = {\n 'pt-BR': {\n dow: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],\n months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'],\n monthsShort: ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'],\n prevMonth: 'Mês anterior',\n nextMonth: 'Próximo mês',\n prevYear: 'Ano anterior',\n prevYears: 'Anos anteriores',\n nextYear: 'Próximo ano',\n nextYears: 'Próximos anos',\n pickerLabel: 'Escolher mês e ano',\n },\n en: {\n dow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n prevMonth: 'Previous month',\n nextMonth: 'Next month',\n prevYear: 'Previous year',\n prevYears: 'Previous years',\n nextYear: 'Next year',\n nextYears: 'Next years',\n pickerLabel: 'Choose month and year',\n },\n} as const;\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function CalendarGrid({\n year,\n month,\n selectedDate,\n unavailable = [],\n min,\n max,\n onSelectDate,\n onMonthChange,\n renderDay,\n squareCells = false,\n trimEmptyRows = false,\n locale = 'pt-BR',\n}: CalendarGridProps) {\n const t = I18N[locale];\n const now = React.useMemo(() => new Date(), []);\n // One integer for the visible month - `year*12 + month`. Keeps ‹ / › arithmetic\n // (and rapid clicks) correct across year boundaries with no Date() juggling.\n // `year` / `month` are the *initial* view; the component then owns it. A\n // consumer that needs to reset the view (DatePicker, on reopen) remounts\n // this component instead - see its own comment.\n const range = React.useMemo(() => calendarRange(min, max), [min, max]);\n // `year` / `month` outside `min` .. `max` start on the nearest month inside it.\n const requestedIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const initialIndex = clampIndex(requestedIndex, range);\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\n // `min` / `max` can change after mount (a \"today\" that moves on, a bound that depends on a\n // choice made elsewhere): keep the visible month inside them. Adjusted while rendering, not in\n // an effect, so a month outside the range is never painted, not even for a frame.\n if (viewIndex !== clampIndex(viewIndex, range)) setViewIndex(clampIndex(viewIndex, range));\n const viewYear = Math.floor(viewIndex / 12);\n const viewMonth = viewIndex % 12;\n // `selectedDate` is only a day number, so remember which month that pick was\n // made in - the highlight shows only there, never on the same day of another\n // month you navigate to.\n const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);\n const [open, setOpen] = React.useState(false);\n const [picker, setPicker] = React.useState<'month' | 'year'>('month');\n // Unbounded, the block is `year - 5` exactly as it always was; with a range it is based on the month\n // actually shown (the one the range moved it to).\n const bounded = Number.isFinite(range.minIndex) || Number.isFinite(range.maxIndex);\n const [yearBase, setYearBase] = React.useState(() => yearWindowStart(bounded ? Math.floor(initialIndex / 12) : (year ?? now.getFullYear()), range));\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const titleRef = React.useRef<HTMLButtonElement>(null);\n const popRef = React.useRef<HTMLDivElement>(null);\n const gridRef = React.useRef<HTMLDivElement>(null);\n\n // Roving tabindex for the day grid: only one cell is ever in the Tab\n // order (below), so Tab enters/leaves the whole grid in one stop instead\n // of one per day. `activeDay` is the day-of-month that cell represents -\n // clamped to the visible month's length at render (below), since it\n // persists across a month change (‹ / › or an arrow-key crossing) where\n // the same day number may no longer exist (e.g. the 31st, into February).\n const [activeDay, setActiveDay] = React.useState(() => {\n if (selectedDate) return selectedDate;\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n let day = todayIndex === initialIndex ? now.getDate() : 1;\n // On the first / last month of the range, start on a day that can be picked, not a struck one.\n if (range.min && initialIndex === range.minIndex) day = Math.max(day, range.min.day);\n if (range.max && initialIndex === range.maxIndex) day = Math.min(day, range.max.day);\n return day;\n });\n // Set right before a keyboard move changes activeDay/viewIndex; consumed\n // by the layout effect below to focus the new cell once it's in the DOM -\n // never on an unrelated render (a prop change, a re-render from the\n // parent) or the initial mount.\n const shouldFocusDayRef = React.useRef(false);\n\n // Notify on navigation - never on mount, always with the settled value.\n const onMonthChangeRef = React.useRef(onMonthChange);\n React.useEffect(() => {\n onMonthChangeRef.current = onMonthChange;\n });\n // The one time it does fire on mount: the month asked for was outside `min` .. `max` and was\n // moved inside it. A consumer that tracks the month (`DatePicker` does, to build the picked\n // date) must not be left believing in the one it asked for.\n const adjustedAtMount = React.useRef(requestedIndex !== initialIndex);\n const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\n if (adjustedAtMount.current) onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n return;\n }\n onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n }, [viewIndex]);\n\n // close on outside pointer; move focus into the popover on open\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n setPicker('month');\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n const id = requestAnimationFrame(() => popRef.current?.focus());\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n cancelAnimationFrame(id);\n };\n }, [open]);\n\n const closePopover = React.useCallback(() => {\n setOpen(false);\n setPicker('month');\n titleRef.current?.focus();\n }, []);\n const toggleOpen = React.useCallback(() => {\n setOpen((v) => {\n if (v) setPicker('month');\n return !v;\n });\n }, []);\n\n const first = new Date(viewYear, viewMonth, 1).getDay();\n const total = daysIn(viewYear, viewMonth);\n // Always 6 rows (42 cells) so the calendar's height never shifts between\n // months - trailing blanks pad it out and carry the cell height too.\n const cells: (number | null)[] = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];\n while (cells.length < 42) cells.push(null);\n if (trimEmptyRows) {\n while (cells.length > 7 && cells.slice(-7).every((c) => c === null)) cells.length -= 7;\n }\n // A plain day cell is a perfect square via aspect-ratio when `squareCells`\n // is set - its height then tracks the grid's actual column width (SS-243:\n // DatePicker's popover can be narrower than DateTimePicker's own card)\n // instead of a fixed guess that only looks square at one particular width.\n // `renderDay` needs literal extra height for its own content underneath\n // the day number regardless, so that case always keeps a fixed height.\n const cellSizing: React.CSSProperties = renderDay ? { height: 48 } : squareCells ? { aspectRatio: '1' } : { height: 38 };\n const years = Array.from({ length: 12 }, (_, i) => yearBase + i);\n const rovingDay = Math.min(Math.max(1, activeDay), total);\n\n // Arrow keys move the roving cursor by real calendar days - crossing into\n // the adjacent month's grid when they overflow the visible one, rather\n // than stopping dead at the edge. Home/End stay within the current week\n // row; PageUp/PageDown step the month (reusing the same ‹ / › state\n // change, so onMonthChange fires identically either way).\n const onGridKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n let delta = 0;\n switch (e.key) {\n case 'ArrowRight':\n delta = 1;\n break;\n case 'ArrowLeft':\n delta = -1;\n break;\n case 'ArrowDown':\n delta = 7;\n break;\n case 'ArrowUp':\n delta = -7;\n break;\n case 'Home': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.max(1, row * 7 - first + 1));\n return;\n }\n case 'End': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.min(total, row * 7 + 7 - first));\n return;\n }\n case 'PageUp':\n e.preventDefault();\n // At the first month nothing moves, and the focus flag stays down so it cannot go off later.\n if (viewIndex - 1 < range.minIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i - 1, range));\n return;\n case 'PageDown':\n e.preventDefault();\n if (viewIndex + 1 > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i + 1, range));\n return;\n default:\n return;\n }\n e.preventDefault();\n const next = new Date(viewYear, viewMonth, rovingDay + delta);\n const nextViewIndex = next.getFullYear() * 12 + next.getMonth();\n // An arrow that would cross into a month outside `min` .. `max` is refused: the cursor stays put.\n if (nextViewIndex < range.minIndex || nextViewIndex > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);\n setActiveDay(next.getDate());\n };\n\n // Runs after the grid above (keyed on viewIndex, so a month change remounts\n // it) has committed the DOM for the new activeDay/viewIndex - only then\n // does the target cell actually exist to focus.\n React.useLayoutEffect(() => {\n if (!shouldFocusDayRef.current) return;\n shouldFocusDayRef.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(`[data-day=\"${rovingDay}\"]`)?.focus();\n }, [viewIndex, rovingDay]);\n\n const canPrevMonth = viewIndex > range.minIndex;\n const canNextMonth = viewIndex < range.maxIndex;\n // One month with the header arrows, never outside the range. A press that lands on the first /\n // last month is about to disable the very button that has focus, and a disabled button drops\n // focus to the page: so the title button takes it first.\n const goMonth = (dir: 1 | -1) => {\n const next = clampIndex(viewIndex + dir, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir, range));\n if (clampIndex(next + dir, range) === next) titleRef.current?.focus();\n };\n // The popover's year arrows. In the month view they move the visible month by a year (clamped);\n // in the year view they page a block of 12 years. Same focus hand-off, to the popover itself.\n const canPrevYear = picker === 'month' ? viewYear > range.minYear : yearBase > range.minYear;\n const canNextYear = picker === 'month' ? viewYear < range.maxYear : yearBase + 12 <= range.maxYear;\n const goYear = (dir: 1 | -1) => {\n if (picker === 'month') {\n const next = clampIndex(viewIndex + dir * 12, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir * 12, range));\n const nextYear = Math.floor(next / 12);\n if (dir < 0 ? nextYear <= range.minYear : nextYear >= range.maxYear) popRef.current?.focus();\n } else {\n const next = yearBase + dir * 12;\n setYearBase((b) => b + dir * 12);\n if (dir < 0 ? next <= range.minYear : next + 12 > range.maxYear) popRef.current?.focus();\n }\n };\n\n return (\n <div ref={rootRef}>\n <div\n style={sx({\n position: 'relative',\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n gap: 'var(--space-1)',\n marginBottom: 'var(--space-3)',\n })}\n >\n <IconButton label={t.prevMonth} size=\"sm\" disabled={!canPrevMonth} onClick={() => goMonth(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n <button\n ref={titleRef}\n type=\"button\"\n className=\"sereno-dtp-title\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={toggleOpen}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n textTransform: 'capitalize',\n })}\n >\n {t.months[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label={t.nextMonth} size=\"sm\" disabled={!canNextMonth} onClick={() => goMonth(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n\n {open && (\n <div\n ref={popRef}\n role=\"dialog\"\n aria-label={t.pickerLabel}\n tabIndex={-1}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n closePopover();\n }\n }}\n className=\"sereno-dtp-pop\"\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: '50%',\n transform: 'translateX(-50%)',\n zIndex: 20,\n width: 248,\n maxWidth: 'calc(100vw - 24px)',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <div\n style={sx({\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n marginBottom: 'var(--space-2)',\n })}\n >\n <IconButton label={picker === 'month' ? t.prevYear : t.prevYears} size=\"sm\" disabled={!canPrevYear} onClick={() => goYear(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n {picker === 'month' ? (\n <button\n type=\"button\"\n className=\"sereno-dtp-title\"\n onClick={() => {\n setYearBase(yearWindowStart(viewYear, range));\n setPicker('year');\n }}\n style={sx({\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n })}\n >\n {viewYear}\n </button>\n ) : (\n <span\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n })}\n >\n {years[0]}–{years[11]}\n </span>\n )}\n\n <IconButton label={picker === 'month' ? t.nextYear : t.nextYears} size=\"sm\" disabled={!canNextYear} onClick={() => goYear(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n </div>\n\n <div className=\"sereno-dtp-grid\" style={sx({ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-1)' })}>\n {picker === 'month'\n ? t.monthsShort.map((mo, i) => (\n <button\n key={mo}\n type=\"button\"\n data-current={i === viewMonth || undefined}\n aria-current={i === viewMonth ? 'true' : undefined}\n disabled={viewYear * 12 + i < range.minIndex || viewYear * 12 + i > range.maxIndex}\n onClick={() => {\n setViewIndex(clampIndex(viewYear * 12 + i, range));\n closePopover();\n }}\n >\n {mo}\n </button>\n ))\n : years.map((y) => (\n <button\n key={y}\n type=\"button\"\n data-current={y === viewYear || undefined}\n aria-current={y === viewYear ? 'true' : undefined}\n disabled={y < range.minYear || y > range.maxYear}\n onClick={() => {\n // Picking the first / last year with a month earlier / later than the range\n // allows lands on the nearest month inside it.\n setViewIndex(clampIndex(y * 12 + viewMonth, range));\n setPicker('month');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)', marginBottom: 'var(--space-1)' })}>\n {t.dow.map((d, i) => (\n <span\n key={i}\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-muted)',\n letterSpacing: 'var(--tracking-caps)',\n })}\n >\n {d}\n </span>\n ))}\n </div>\n {/* keyed on the month so cells remount cleanly - no bg transition when a\n slot morphs from one day to another on navigation. */}\n <div\n key={viewIndex}\n ref={gridRef}\n onKeyDown={onGridKeyDown}\n className=\"sereno-dtp-days\"\n style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)' })}\n >\n {cells.map((d, i) => {\n // Blank cells still take the row height so the 6-row grid can't collapse.\n if (d === null) return <span key={i} aria-hidden style={cellSizing} />;\n const off = unavailable.includes(d) || isDayOutside(range, viewIndex, d);\n const sel = selectedDate === d && viewIndex === selectionIndex;\n const extra = renderDay?.(d);\n return (\n <button\n key={i}\n type=\"button\"\n data-day={d}\n // Not the native `disabled` - an unavailable day stays a real,\n // focusable stop on the roving cursor (aria-disabled only) so\n // arrow-key navigation can still land on it and the user can\n // tell it exists, matching the WAI-ARIA date-grid pattern. A\n // truly `disabled` button can't receive focus at all, which\n // would make the roving tabindex below silently break.\n aria-disabled={off || undefined}\n tabIndex={d === rovingDay ? 0 : -1}\n aria-pressed={sel}\n onClick={() => {\n if (off) return;\n setSelectionIndex(viewIndex);\n // Keep the roving cursor in sync with a mouse pick too - a\n // click already moves real DOM focus onto this button\n // natively, so without this the *next* arrow press would\n // jump from wherever the keyboard cursor was left instead\n // of from the day the user can see is focused/selected.\n setActiveDay(d);\n onSelectDate?.(d);\n }}\n style={sx({\n ...cellSizing,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 1,\n borderRadius: 'var(--radius-sm)',\n border: 'none',\n padding: 0,\n cursor: off ? 'not-allowed' : 'pointer',\n background: sel ? 'var(--interactive-primary)' : 'transparent',\n color: sel ? 'var(--interactive-primary-fg)' : off ? 'var(--text-disabled)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: sel ? 'var(--weight-bold)' : 'var(--weight-medium)',\n textDecoration: off ? 'line-through' : 'none',\n transition: 'var(--transition-control)',\n // Not inline outline:none - that would always beat the\n // .sereno-dtp-days:focus-visible rule below no matter what\n // it says (inline style always outranks a class selector).\n // Suppressed as a class rule instead, same specificity as\n // the :focus-visible override that re-enables it.\n })}\n >\n <span>{d}</span>\n {renderDay ? <span style={sx({ display: 'flex', minHeight: 12, lineHeight: 1 })}>{extra}</span> : null}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";AAkVU,cAGF,YAHE;AAhVV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,eAAe,YAAY,cAAc,uBAAuB;AAsDzE,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,KAAK,CAAC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"sources":["../../../src/forms/_internal/CalendarGrid.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronDown, ChevronLeft, ChevronRight } from 'lucide-react';\nimport { sx } from '../../_internal/style';\nimport { srOnlyStyle } from '../../_internal/srOnly';\nimport { IconButton } from '../../core/IconButton';\nimport { calendarRange, clampIndex, isDayOutside, yearWindowStart } from './calendarRange';\nimport { dotFor, dotStyle, TODAY_RING, type CalendarDayContext, type CalendarDayDots } from './calendarDots';\n\n/**\n * The month calendar body - header (‹ / › month nav + a month/year jump\n * popover) and the day grid with roving-tabindex keyboard navigation\n * (SS-228). Shared by `DateTimePicker` (rendered inline, with an optional\n * time-slot list under it) and `DatePicker` (rendered inside its own\n * trigger+popover shell) - extracted so neither has to duplicate the\n * keyboard-grid math (SS-243). See `DateTimePicker`'s own doc comment for\n * the full behavior description; this component owns exactly the same\n * state and logic it always has, just without the outer card chrome or\n * the time-slot section, neither of which any of this depends on.\n */\nexport interface CalendarGridProps {\n year?: number;\n month?: number;\n selectedDate?: number;\n unavailable?: number[];\n /**\n * Earliest date, ISO \"YYYY-MM-DD\". The calendar cannot be navigated to an earlier month or\n * year (the previous-month arrow disables, PageUp and the arrow keys stop at the edge, and\n * the month / year popover disables what is out of range), and every earlier day is struck\n * through, with no need to list it in `unavailable`. A value that is not a valid date is ignored.\n */\n min?: string;\n /** Latest date, ISO \"YYYY-MM-DD\". The mirror image of `min`. */\n max?: string;\n onSelectDate?: (day: number) => void;\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number. The second argument says what the calendar knows about the\n * day (selected, today, unavailable), so the content can follow it without redoing the logic.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /** The days that get a dot under their number (see `CalendarDayDots`). Shares the slot under the number with `renderDay`. */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot that has no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n /**\n * Day cells are perfect squares (`aspect-ratio`) instead of a fixed pixel\n * height - `DatePicker` (SS-243) opts into this since its popover can be\n * narrower than `DateTimePicker`'s own card, where a fixed height was\n * already tuned and shipped. Ignored when `renderDay` or `dayDots` is set -\n * that case always needs the extra fixed height for its own content.\n */\n squareCells?: boolean;\n /**\n * Drop wholly-blank trailing rows instead of always padding to 6 (SS-243)\n * `DateTimePicker` needs the fixed 6 rows so its *always-visible* card\n * never jumps height as you navigate months; `DatePicker`'s popover opens\n * and closes anyway, so a variable height per month reads better than a\n * dead empty row (e.g. a 30-day month starting on Sunday only needs 5).\n */\n trimEmptyRows?: boolean;\n /**\n * The product itself (Sereno's real booking app) always renders pt-BR -\n * this only exists so the docs showcase can demo an English-speaking\n * consumer without forking the component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\nconst I18N = {\n 'pt-BR': {\n dow: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'],\n months: ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'],\n monthsShort: ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'],\n prevMonth: 'Mês anterior',\n nextMonth: 'Próximo mês',\n prevYear: 'Ano anterior',\n prevYears: 'Anos anteriores',\n nextYear: 'Próximo ano',\n nextYears: 'Próximos anos',\n pickerLabel: 'Escolher mês e ano',\n marked: 'com marcador',\n },\n en: {\n dow: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],\n months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],\n monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],\n prevMonth: 'Previous month',\n nextMonth: 'Next month',\n prevYear: 'Previous year',\n prevYears: 'Previous years',\n nextYear: 'Next year',\n nextYears: 'Next years',\n pickerLabel: 'Choose month and year',\n marked: 'marked',\n },\n} as const;\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function CalendarGrid({\n year,\n month,\n selectedDate,\n unavailable = [],\n min,\n max,\n onSelectDate,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n squareCells = false,\n trimEmptyRows = false,\n locale = 'pt-BR',\n}: CalendarGridProps) {\n const t = I18N[locale];\n const now = React.useMemo(() => new Date(), []);\n // One integer for the visible month - `year*12 + month`. Keeps ‹ / › arithmetic\n // (and rapid clicks) correct across year boundaries with no Date() juggling.\n // `year` / `month` are the *initial* view; the component then owns it. A\n // consumer that needs to reset the view (DatePicker, on reopen) remounts\n // this component instead - see its own comment.\n const range = React.useMemo(() => calendarRange(min, max), [min, max]);\n // `year` / `month` outside `min` .. `max` start on the nearest month inside it.\n const requestedIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const initialIndex = clampIndex(requestedIndex, range);\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\n // `min` / `max` can change after mount (a \"today\" that moves on, a bound that depends on a\n // choice made elsewhere): keep the visible month inside them. Adjusted while rendering, not in\n // an effect, so a month outside the range is never painted, not even for a frame.\n if (viewIndex !== clampIndex(viewIndex, range)) setViewIndex(clampIndex(viewIndex, range));\n const viewYear = Math.floor(viewIndex / 12);\n const viewMonth = viewIndex % 12;\n // `selectedDate` is only a day number, so remember which month that pick was\n // made in - the highlight shows only there, never on the same day of another\n // month you navigate to.\n const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);\n const [open, setOpen] = React.useState(false);\n const [picker, setPicker] = React.useState<'month' | 'year'>('month');\n // Unbounded, the block is `year - 5` exactly as it always was; with a range it is based on the month\n // actually shown (the one the range moved it to).\n const bounded = Number.isFinite(range.minIndex) || Number.isFinite(range.maxIndex);\n const [yearBase, setYearBase] = React.useState(() => yearWindowStart(bounded ? Math.floor(initialIndex / 12) : (year ?? now.getFullYear()), range));\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const titleRef = React.useRef<HTMLButtonElement>(null);\n const popRef = React.useRef<HTMLDivElement>(null);\n const gridRef = React.useRef<HTMLDivElement>(null);\n\n // Roving tabindex for the day grid: only one cell is ever in the Tab\n // order (below), so Tab enters/leaves the whole grid in one stop instead\n // of one per day. `activeDay` is the day-of-month that cell represents -\n // clamped to the visible month's length at render (below), since it\n // persists across a month change (‹ / › or an arrow-key crossing) where\n // the same day number may no longer exist (e.g. the 31st, into February).\n const [activeDay, setActiveDay] = React.useState(() => {\n if (selectedDate) return selectedDate;\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n let day = todayIndex === initialIndex ? now.getDate() : 1;\n // On the first / last month of the range, start on a day that can be picked, not a struck one.\n if (range.min && initialIndex === range.minIndex) day = Math.max(day, range.min.day);\n if (range.max && initialIndex === range.maxIndex) day = Math.min(day, range.max.day);\n return day;\n });\n // Set right before a keyboard move changes activeDay/viewIndex; consumed\n // by the layout effect below to focus the new cell once it's in the DOM -\n // never on an unrelated render (a prop change, a re-render from the\n // parent) or the initial mount.\n const shouldFocusDayRef = React.useRef(false);\n\n // Notify on navigation - never on mount, always with the settled value.\n const onMonthChangeRef = React.useRef(onMonthChange);\n React.useEffect(() => {\n onMonthChangeRef.current = onMonthChange;\n });\n // The one time it does fire on mount: the month asked for was outside `min` .. `max` and was\n // moved inside it. A consumer that tracks the month (`DatePicker` does, to build the picked\n // date) must not be left believing in the one it asked for.\n const adjustedAtMount = React.useRef(requestedIndex !== initialIndex);\n const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\n if (adjustedAtMount.current) onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n return;\n }\n onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);\n }, [viewIndex]);\n\n // close on outside pointer; move focus into the popover on open\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n setPicker('month');\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n const id = requestAnimationFrame(() => popRef.current?.focus());\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n cancelAnimationFrame(id);\n };\n }, [open]);\n\n const closePopover = React.useCallback(() => {\n setOpen(false);\n setPicker('month');\n titleRef.current?.focus();\n }, []);\n const toggleOpen = React.useCallback(() => {\n setOpen((v) => {\n if (v) setPicker('month');\n return !v;\n });\n }, []);\n\n const first = new Date(viewYear, viewMonth, 1).getDay();\n const total = daysIn(viewYear, viewMonth);\n // Always 6 rows (42 cells) so the calendar's height never shifts between\n // months - trailing blanks pad it out and carry the cell height too.\n const cells: (number | null)[] = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];\n while (cells.length < 42) cells.push(null);\n if (trimEmptyRows) {\n while (cells.length > 7 && cells.slice(-7).every((c) => c === null)) cells.length -= 7;\n }\n // A plain day cell is a perfect square via aspect-ratio when `squareCells`\n // is set - its height then tracks the grid's actual column width (SS-243:\n // DatePicker's popover can be narrower than DateTimePicker's own card)\n // instead of a fixed guess that only looks square at one particular width.\n // `renderDay` needs literal extra height for its own content underneath\n // the day number regardless, so that case always keeps a fixed height.\n const hasSlot = !!renderDay || dayDots !== undefined;\n const cellSizing: React.CSSProperties = hasSlot ? { height: 48 } : squareCells ? { aspectRatio: '1' } : { height: 38 };\n const todayIndex = now.getFullYear() * 12 + now.getMonth();\n const years = Array.from({ length: 12 }, (_, i) => yearBase + i);\n const rovingDay = Math.min(Math.max(1, activeDay), total);\n\n // Arrow keys move the roving cursor by real calendar days - crossing into\n // the adjacent month's grid when they overflow the visible one, rather\n // than stopping dead at the edge. Home/End stay within the current week\n // row; PageUp/PageDown step the month (reusing the same ‹ / › state\n // change, so onMonthChange fires identically either way).\n const onGridKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n let delta = 0;\n switch (e.key) {\n case 'ArrowRight':\n delta = 1;\n break;\n case 'ArrowLeft':\n delta = -1;\n break;\n case 'ArrowDown':\n delta = 7;\n break;\n case 'ArrowUp':\n delta = -7;\n break;\n case 'Home': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.max(1, row * 7 - first + 1));\n return;\n }\n case 'End': {\n e.preventDefault();\n const row = Math.floor((first + rovingDay - 1) / 7);\n shouldFocusDayRef.current = true;\n setActiveDay(Math.min(total, row * 7 + 7 - first));\n return;\n }\n case 'PageUp':\n e.preventDefault();\n // At the first month nothing moves, and the focus flag stays down so it cannot go off later.\n if (viewIndex - 1 < range.minIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i - 1, range));\n return;\n case 'PageDown':\n e.preventDefault();\n if (viewIndex + 1 > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n setViewIndex((i) => clampIndex(i + 1, range));\n return;\n default:\n return;\n }\n e.preventDefault();\n const next = new Date(viewYear, viewMonth, rovingDay + delta);\n const nextViewIndex = next.getFullYear() * 12 + next.getMonth();\n // An arrow that would cross into a month outside `min` .. `max` is refused: the cursor stays put.\n if (nextViewIndex < range.minIndex || nextViewIndex > range.maxIndex) return;\n shouldFocusDayRef.current = true;\n if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);\n setActiveDay(next.getDate());\n };\n\n // Runs after the grid above (keyed on viewIndex, so a month change remounts\n // it) has committed the DOM for the new activeDay/viewIndex - only then\n // does the target cell actually exist to focus.\n React.useLayoutEffect(() => {\n if (!shouldFocusDayRef.current) return;\n shouldFocusDayRef.current = false;\n gridRef.current?.querySelector<HTMLButtonElement>(`[data-day=\"${rovingDay}\"]`)?.focus();\n }, [viewIndex, rovingDay]);\n\n const canPrevMonth = viewIndex > range.minIndex;\n const canNextMonth = viewIndex < range.maxIndex;\n // One month with the header arrows, never outside the range. A press that lands on the first /\n // last month is about to disable the very button that has focus, and a disabled button drops\n // focus to the page: so the title button takes it first.\n const goMonth = (dir: 1 | -1) => {\n const next = clampIndex(viewIndex + dir, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir, range));\n if (clampIndex(next + dir, range) === next) titleRef.current?.focus();\n };\n // The popover's year arrows. In the month view they move the visible month by a year (clamped);\n // in the year view they page a block of 12 years. Same focus hand-off, to the popover itself.\n const canPrevYear = picker === 'month' ? viewYear > range.minYear : yearBase > range.minYear;\n const canNextYear = picker === 'month' ? viewYear < range.maxYear : yearBase + 12 <= range.maxYear;\n const goYear = (dir: 1 | -1) => {\n if (picker === 'month') {\n const next = clampIndex(viewIndex + dir * 12, range);\n if (next === viewIndex) return;\n setViewIndex((i) => clampIndex(i + dir * 12, range));\n const nextYear = Math.floor(next / 12);\n if (dir < 0 ? nextYear <= range.minYear : nextYear >= range.maxYear) popRef.current?.focus();\n } else {\n const next = yearBase + dir * 12;\n setYearBase((b) => b + dir * 12);\n if (dir < 0 ? next <= range.minYear : next + 12 > range.maxYear) popRef.current?.focus();\n }\n };\n\n return (\n <div ref={rootRef}>\n <div\n style={sx({\n position: 'relative',\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n gap: 'var(--space-1)',\n marginBottom: 'var(--space-3)',\n })}\n >\n <IconButton label={t.prevMonth} size=\"sm\" disabled={!canPrevMonth} onClick={() => goMonth(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n <button\n ref={titleRef}\n type=\"button\"\n className=\"sereno-dtp-title\"\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={toggleOpen}\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 4,\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-base)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n textTransform: 'capitalize',\n })}\n >\n {t.months[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label={t.nextMonth} size=\"sm\" disabled={!canNextMonth} onClick={() => goMonth(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n\n {open && (\n <div\n ref={popRef}\n role=\"dialog\"\n aria-label={t.pickerLabel}\n tabIndex={-1}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n e.stopPropagation();\n closePopover();\n }\n }}\n className=\"sereno-dtp-pop\"\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: '50%',\n transform: 'translateX(-50%)',\n zIndex: 20,\n width: 248,\n maxWidth: 'calc(100vw - 24px)',\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <div\n style={sx({\n display: 'grid',\n gridTemplateColumns: 'auto 1fr auto',\n alignItems: 'center',\n marginBottom: 'var(--space-2)',\n })}\n >\n <IconButton label={picker === 'month' ? t.prevYear : t.prevYears} size=\"sm\" disabled={!canPrevYear} onClick={() => goYear(-1)}>\n <ChevronLeft size={18} strokeWidth={1.75} />\n </IconButton>\n\n {picker === 'month' ? (\n <button\n type=\"button\"\n className=\"sereno-dtp-title\"\n onClick={() => {\n setYearBase(yearWindowStart(viewYear, range));\n setPicker('year');\n }}\n style={sx({\n margin: '0 auto',\n padding: '4px 8px',\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n cursor: 'pointer',\n fontFamily: 'var(--font-display)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-bold)',\n color: 'var(--text-primary)',\n })}\n >\n {viewYear}\n </button>\n ) : (\n <span\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-secondary)',\n })}\n >\n {years[0]}–{years[11]}\n </span>\n )}\n\n <IconButton label={picker === 'month' ? t.nextYear : t.nextYears} size=\"sm\" disabled={!canNextYear} onClick={() => goYear(1)}>\n <ChevronRight size={18} strokeWidth={1.75} />\n </IconButton>\n </div>\n\n <div className=\"sereno-dtp-grid\" style={sx({ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 'var(--space-1)' })}>\n {picker === 'month'\n ? t.monthsShort.map((mo, i) => (\n <button\n key={mo}\n type=\"button\"\n data-current={i === viewMonth || undefined}\n aria-current={i === viewMonth ? 'true' : undefined}\n disabled={viewYear * 12 + i < range.minIndex || viewYear * 12 + i > range.maxIndex}\n onClick={() => {\n setViewIndex(clampIndex(viewYear * 12 + i, range));\n closePopover();\n }}\n >\n {mo}\n </button>\n ))\n : years.map((y) => (\n <button\n key={y}\n type=\"button\"\n data-current={y === viewYear || undefined}\n aria-current={y === viewYear ? 'true' : undefined}\n disabled={y < range.minYear || y > range.maxYear}\n onClick={() => {\n // Picking the first / last year with a month earlier / later than the range\n // allows lands on the nearest month inside it.\n setViewIndex(clampIndex(y * 12 + viewMonth, range));\n setPicker('month');\n }}\n >\n {y}\n </button>\n ))}\n </div>\n </div>\n )}\n </div>\n\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)', marginBottom: 'var(--space-1)' })}>\n {t.dow.map((d, i) => (\n <span\n key={i}\n style={sx({\n textAlign: 'center',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-2xs)',\n fontWeight: 'var(--weight-semibold)',\n color: 'var(--text-muted)',\n letterSpacing: 'var(--tracking-caps)',\n })}\n >\n {d}\n </span>\n ))}\n </div>\n {/* keyed on the month so cells remount cleanly - no bg transition when a\n slot morphs from one day to another on navigation. */}\n <div\n key={viewIndex}\n ref={gridRef}\n onKeyDown={onGridKeyDown}\n className=\"sereno-dtp-days\"\n style={sx({ display: 'grid', gridTemplateColumns: 'repeat(7,1fr)', gap: 'var(--space-1)' })}\n >\n {cells.map((d, i) => {\n // Blank cells still take the row height so the 6-row grid can't collapse.\n if (d === null) return <span key={i} aria-hidden style={cellSizing} />;\n const off = unavailable.includes(d) || isDayOutside(range, viewIndex, d);\n const sel = selectedDate === d && viewIndex === selectionIndex;\n const today = viewIndex === todayIndex && d === now.getDate();\n const extra = renderDay?.(d, { selected: sel, today, unavailable: off });\n const dot = dotFor(dayDots, d);\n return (\n <button\n key={i}\n type=\"button\"\n data-day={d}\n // Not the native `disabled` - an unavailable day stays a real,\n // focusable stop on the roving cursor (aria-disabled only) so\n // arrow-key navigation can still land on it and the user can\n // tell it exists, matching the WAI-ARIA date-grid pattern. A\n // truly `disabled` button can't receive focus at all, which\n // would make the roving tabindex below silently break.\n aria-disabled={off || undefined}\n aria-current={today ? 'date' : undefined}\n tabIndex={d === rovingDay ? 0 : -1}\n aria-pressed={sel}\n onClick={() => {\n if (off) return;\n setSelectionIndex(viewIndex);\n // Keep the roving cursor in sync with a mouse pick too - a\n // click already moves real DOM focus onto this button\n // natively, so without this the *next* arrow press would\n // jump from wherever the keyboard cursor was left instead\n // of from the day the user can see is focused/selected.\n setActiveDay(d);\n onSelectDate?.(d);\n }}\n style={sx({\n ...cellSizing,\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n gap: 1,\n borderRadius: 'var(--radius-sm)',\n border: 'none',\n padding: 0,\n cursor: off ? 'not-allowed' : 'pointer',\n background: sel ? 'var(--interactive-primary)' : 'transparent',\n color: sel ? 'var(--interactive-primary-fg)' : off ? 'var(--text-disabled)' : 'var(--text-primary)',\n fontFamily: 'var(--font-body)',\n fontSize: 'var(--text-sm)',\n fontWeight: sel ? 'var(--weight-bold)' : 'var(--weight-medium)',\n textDecoration: off ? 'line-through' : 'none',\n // Today is told apart by a thin inset ring (also `aria-current` above). Not when it\n // is the selected day: the primary fill already says which day it is.\n boxShadow: today && !sel ? TODAY_RING : undefined,\n transition: 'var(--transition-control)',\n // Not inline outline:none - that would always beat the\n // .sereno-dtp-days:focus-visible rule below no matter what\n // it says (inline style always outranks a class selector).\n // Suppressed as a class rule instead, same specificity as\n // the :focus-visible override that re-enables it.\n })}\n >\n <span>{d}</span>\n {hasSlot ? (\n <span style={sx({ display: 'flex', gap: 4, minHeight: 12, lineHeight: 1 })}>\n {extra}\n {dot ? <span aria-hidden style={sx({ ...dotStyle(dot.tone, { selected: sel, unavailable: off }), alignSelf: 'center' })} /> : null}\n </span>\n ) : null}\n {dot ? <span style={srOnlyStyle}>{dot.label ?? dayDotLabel ?? t.marked}</span> : null}\n </button>\n );\n })}\n </div>\n </div>\n );\n}\n"],"mappings":";AAkWU,cAGF,YAHE;AAhWV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAC3B,SAAS,eAAe,YAAY,cAAc,uBAAuB;AACzE,SAAS,QAAQ,UAAU,kBAAiE;AA8D5F,MAAM,OAAO;AAAA,EACX,SAAS;AAAA,IACP,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,IACvC,QAAQ,CAAC,WAAW,aAAa,YAAS,SAAS,QAAQ,SAAS,SAAS,UAAU,YAAY,WAAW,YAAY,UAAU;AAAA,IACpI,aAAa,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAAA,IAChG,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,UAAU;AAAA,IACV,WAAW;AAAA,IACX,aAAa;AAAA,IACb,QAAQ;AAAA,EACV;AAAA,EACA,IAAI;AAAA,IACF,KAAK,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAAA,IACvC,QAAQ,CAAC,WAAW,YAAY,SAAS,SAAS,OAAO,QAAQ,QAAQ,UAAU,aAAa,WAAW,YAAY,UAAU;AAAA,IACjI,aAA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AA,IA+EP;AAAA,KACF;AAEJ;","names":["todayIndex"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CSSProperties } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What the month calendar (`CalendarGrid`, so `DateTimePicker` and `DatePicker`) says about the
|
|
5
|
+
* day it is drawing, and the dots it can draw under a day by itself, as plain functions so
|
|
6
|
+
* the two callers (the grid and `CalendarLegend`) cannot drift apart.
|
|
7
|
+
*/
|
|
8
|
+
/** The second argument of `renderDay`: the three things the calendar already knows about the day. */
|
|
9
|
+
interface CalendarDayContext {
|
|
10
|
+
/** The day is the selected one (what `aria-pressed` reports). It is painted with the primary color, so content under it must use `--interactive-primary-fg`. */
|
|
11
|
+
selected: boolean;
|
|
12
|
+
/** The day is today. */
|
|
13
|
+
today: boolean;
|
|
14
|
+
/** The day cannot be picked: it is listed in `unavailable`, or falls outside `min` .. `max`. */
|
|
15
|
+
unavailable: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** `brand` is the primary color; the others are the status tones (`Badge`, `Alert`, `Toast`). */
|
|
18
|
+
type CalendarDotTone = 'brand' | 'success' | 'warning' | 'error' | 'info';
|
|
19
|
+
interface CalendarDayDot {
|
|
20
|
+
/** Default `brand`. */
|
|
21
|
+
tone?: CalendarDotTone;
|
|
22
|
+
/** What a screen reader says for the dot, after the day number. Default: the locale's "marked". */
|
|
23
|
+
label?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The days that get a dot under their number: a list of day numbers, or an object keyed by day
|
|
27
|
+
* number when a dot needs its own `tone` or `label`. Day numbers of the month on screen, the same
|
|
28
|
+
* convention as `unavailable`.
|
|
29
|
+
*/
|
|
30
|
+
type CalendarDayDots = number[] | Record<number, CalendarDayDot>;
|
|
31
|
+
declare const DOT_SIZE = 6;
|
|
32
|
+
/**
|
|
33
|
+
* The thin ring around today, drawn inside the cell. `--border-brand` rather than a neutral
|
|
34
|
+
* border: it is 3.17:1 on the card in the light theme (3.47:1 in the dark one), where
|
|
35
|
+
* `--border-strong` is 1.63:1 and would barely show. The calendar and `CalendarLegend` use this one value.
|
|
36
|
+
*/
|
|
37
|
+
declare const TODAY_RING = "inset 0 0 0 1px var(--border-brand)";
|
|
38
|
+
/** The dot of `day`, or `null` when it has none. A day listed without details gets the defaults. */
|
|
39
|
+
declare function dotFor(dots: CalendarDayDots | undefined, day: number): CalendarDayDot | null;
|
|
40
|
+
/**
|
|
41
|
+
* The look of one dot. On the selected day the calendar paints the cell with the primary
|
|
42
|
+
* color, so the dot turns to the color made for text on it (`--interactive-primary-fg`)
|
|
43
|
+
* whatever its tone, or it would vanish into the fill. On a day that cannot be picked it
|
|
44
|
+
* fades with the day number.
|
|
45
|
+
*/
|
|
46
|
+
declare function dotStyle(tone?: CalendarDotTone, state?: {
|
|
47
|
+
selected?: boolean;
|
|
48
|
+
unavailable?: boolean;
|
|
49
|
+
}): CSSProperties;
|
|
50
|
+
|
|
51
|
+
export { type CalendarDayContext, type CalendarDayDot, type CalendarDayDots, type CalendarDotTone, DOT_SIZE, TODAY_RING, dotFor, dotStyle };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const DOT_SIZE = 6;
|
|
2
|
+
const TODAY_RING = "inset 0 0 0 1px var(--border-brand)";
|
|
3
|
+
const TONE_VAR = {
|
|
4
|
+
brand: "--interactive-primary",
|
|
5
|
+
success: "--status-success-dot",
|
|
6
|
+
warning: "--status-warning-dot",
|
|
7
|
+
error: "--status-error-dot",
|
|
8
|
+
info: "--status-info-dot"
|
|
9
|
+
};
|
|
10
|
+
function dotFor(dots, day) {
|
|
11
|
+
if (!dots) return null;
|
|
12
|
+
if (Array.isArray(dots)) return dots.includes(day) ? {} : null;
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(dots, day) ? dots[day] ?? {} : null;
|
|
14
|
+
}
|
|
15
|
+
function dotStyle(tone = "brand", state = {}) {
|
|
16
|
+
return {
|
|
17
|
+
display: "block",
|
|
18
|
+
width: DOT_SIZE,
|
|
19
|
+
height: DOT_SIZE,
|
|
20
|
+
borderRadius: "var(--radius-pill)",
|
|
21
|
+
flex: "0 0 auto",
|
|
22
|
+
background: state.selected ? "var(--interactive-primary-fg)" : "var(" + TONE_VAR[tone] + ")",
|
|
23
|
+
opacity: !state.selected && state.unavailable ? 0.45 : 1
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
DOT_SIZE,
|
|
28
|
+
TODAY_RING,
|
|
29
|
+
dotFor,
|
|
30
|
+
dotStyle
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=calendarDots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/forms/_internal/calendarDots.ts"],"sourcesContent":["import type { CSSProperties } from 'react';\n\n/**\n * What the month calendar (`CalendarGrid`, so `DateTimePicker` and `DatePicker`) says about the\n * day it is drawing, and the dots it can draw under a day by itself, as plain functions so\n * the two callers (the grid and `CalendarLegend`) cannot drift apart.\n */\n\n/** The second argument of `renderDay`: the three things the calendar already knows about the day. */\nexport interface CalendarDayContext {\n /** The day is the selected one (what `aria-pressed` reports). It is painted with the primary color, so content under it must use `--interactive-primary-fg`. */\n selected: boolean;\n /** The day is today. */\n today: boolean;\n /** The day cannot be picked: it is listed in `unavailable`, or falls outside `min` .. `max`. */\n unavailable: boolean;\n}\n\n/** `brand` is the primary color; the others are the status tones (`Badge`, `Alert`, `Toast`). */\nexport type CalendarDotTone = 'brand' | 'success' | 'warning' | 'error' | 'info';\n\nexport interface CalendarDayDot {\n /** Default `brand`. */\n tone?: CalendarDotTone;\n /** What a screen reader says for the dot, after the day number. Default: the locale's \"marked\". */\n label?: string;\n}\n\n/**\n * The days that get a dot under their number: a list of day numbers, or an object keyed by day\n * number when a dot needs its own `tone` or `label`. Day numbers of the month on screen, the same\n * convention as `unavailable`.\n */\nexport type CalendarDayDots = number[] | Record<number, CalendarDayDot>;\n\nexport const DOT_SIZE = 6;\n\n/**\n * The thin ring around today, drawn inside the cell. `--border-brand` rather than a neutral\n * border: it is 3.17:1 on the card in the light theme (3.47:1 in the dark one), where\n * `--border-strong` is 1.63:1 and would barely show. The calendar and `CalendarLegend` use this one value.\n */\nexport const TODAY_RING = 'inset 0 0 0 1px var(--border-brand)';\n\nconst TONE_VAR: Record<CalendarDotTone, string> = {\n brand: '--interactive-primary',\n success: '--status-success-dot',\n warning: '--status-warning-dot',\n error: '--status-error-dot',\n info: '--status-info-dot',\n};\n\n/** The dot of `day`, or `null` when it has none. A day listed without details gets the defaults. */\nexport function dotFor(dots: CalendarDayDots | undefined, day: number): CalendarDayDot | null {\n if (!dots) return null;\n if (Array.isArray(dots)) return dots.includes(day) ? {} : null;\n return Object.prototype.hasOwnProperty.call(dots, day) ? (dots[day] ?? {}) : null;\n}\n\n/**\n * The look of one dot. On the selected day the calendar paints the cell with the primary\n * color, so the dot turns to the color made for text on it (`--interactive-primary-fg`)\n * whatever its tone, or it would vanish into the fill. On a day that cannot be picked it\n * fades with the day number.\n */\nexport function dotStyle(tone: CalendarDotTone = 'brand', state: { selected?: boolean; unavailable?: boolean } = {}): CSSProperties {\n return {\n display: 'block',\n width: DOT_SIZE,\n height: DOT_SIZE,\n borderRadius: 'var(--radius-pill)',\n flex: '0 0 auto',\n background: state.selected ? 'var(--interactive-primary-fg)' : 'var(' + TONE_VAR[tone] + ')',\n opacity: !state.selected && state.unavailable ? 0.45 : 1,\n };\n}\n"],"mappings":"AAmCO,MAAM,WAAW;AAOjB,MAAM,aAAa;AAE1B,MAAM,WAA4C;AAAA,EAChD,OAAO;AAAA,EACP,SAAS;AAAA,EACT,SAAS;AAAA,EACT,OAAO;AAAA,EACP,MAAM;AACR;AAGO,SAAS,OAAO,MAAmC,KAAoC;AAC5F,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,MAAM,QAAQ,IAAI,EAAG,QAAO,KAAK,SAAS,GAAG,IAAI,CAAC,IAAI;AAC1D,SAAO,OAAO,UAAU,eAAe,KAAK,MAAM,GAAG,IAAK,KAAK,GAAG,KAAK,CAAC,IAAK;AAC/E;AAQO,SAAS,SAAS,OAAwB,SAAS,QAAuD,CAAC,GAAkB;AAClI,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,MAAM;AAAA,IACN,YAAY,MAAM,WAAW,kCAAkC,SAAS,SAAS,IAAI,IAAI;AAAA,IACzF,SAAS,CAAC,MAAM,YAAY,MAAM,cAAc,OAAO;AAAA,EACzD;AACF;","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { Button, ButtonProps } from './core/Button.js';
|
|
|
3
3
|
export { IconButton, IconButtonProps } from './core/IconButton.js';
|
|
4
4
|
export { Badge, BadgeProps } from './core/Badge.js';
|
|
5
5
|
export { Card, CardProps } from './core/Card.js';
|
|
6
|
+
export { StatCard, StatCardProps, StatCardTone } from './core/StatCard.js';
|
|
6
7
|
export { Avatar, AvatarProps } from './core/Avatar.js';
|
|
7
8
|
export { Brand, BrandProps } from './core/Brand.js';
|
|
8
9
|
export { Menu, MenuEntry, MenuHeading, MenuItem, MenuProps, MenuSeparator } from './core/Menu.js';
|
|
@@ -14,6 +15,7 @@ export { Checkbox, CheckboxProps } from './forms/Checkbox.js';
|
|
|
14
15
|
export { Radio, RadioProps } from './forms/Radio.js';
|
|
15
16
|
export { Switch, SwitchProps } from './forms/Switch.js';
|
|
16
17
|
export { DateTimePicker, DateTimePickerProps, TimeSlot } from './forms/DateTimePicker.js';
|
|
18
|
+
export { CalendarLegend, CalendarLegendItem, CalendarLegendProps } from './forms/CalendarLegend.js';
|
|
17
19
|
export { DatePicker, DatePickerHandle, DatePickerProps } from './forms/DatePicker.js';
|
|
18
20
|
export { FileUpload, FileUploadProps } from './forms/FileUpload.js';
|
|
19
21
|
export { AvatarUpload, AvatarUploadProps } from './forms/AvatarUpload.js';
|
|
@@ -32,5 +34,6 @@ export { Skeleton, SkeletonProps } from './feedback/Skeleton.js';
|
|
|
32
34
|
export { EmptyState, EmptyStateProps } from './feedback/EmptyState.js';
|
|
33
35
|
export { ThemeProvider } from './theme/ThemeProvider.js';
|
|
34
36
|
export { ThemeToggle } from './theme/ThemeToggle.js';
|
|
37
|
+
export { CalendarDayContext, CalendarDayDot, CalendarDayDots, CalendarDotTone } from './forms/_internal/calendarDots.js';
|
|
35
38
|
import 'react';
|
|
36
39
|
import './_internal/mask.js';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { Button } from "./core/Button.js";
|
|
|
3
3
|
import { IconButton } from "./core/IconButton.js";
|
|
4
4
|
import { Badge } from "./core/Badge.js";
|
|
5
5
|
import { Card } from "./core/Card.js";
|
|
6
|
+
import { StatCard } from "./core/StatCard.js";
|
|
6
7
|
import { Avatar } from "./core/Avatar.js";
|
|
7
8
|
import { Brand } from "./core/Brand.js";
|
|
8
9
|
import { Menu } from "./core/Menu.js";
|
|
@@ -15,7 +16,10 @@ import { Select } from "./forms/Select.js";
|
|
|
15
16
|
import { Checkbox } from "./forms/Checkbox.js";
|
|
16
17
|
import { Radio } from "./forms/Radio.js";
|
|
17
18
|
import { Switch } from "./forms/Switch.js";
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
DateTimePicker
|
|
21
|
+
} from "./forms/DateTimePicker.js";
|
|
22
|
+
import { CalendarLegend } from "./forms/CalendarLegend.js";
|
|
19
23
|
import { DatePicker } from "./forms/DatePicker.js";
|
|
20
24
|
import { FileUpload } from "./forms/FileUpload.js";
|
|
21
25
|
import { AvatarUpload } from "./forms/AvatarUpload.js";
|
|
@@ -47,6 +51,7 @@ export {
|
|
|
47
51
|
BottomNav,
|
|
48
52
|
Brand,
|
|
49
53
|
Button,
|
|
54
|
+
CalendarLegend,
|
|
50
55
|
Card,
|
|
51
56
|
Checkbox,
|
|
52
57
|
DatePicker,
|
|
@@ -63,6 +68,7 @@ export {
|
|
|
63
68
|
Select,
|
|
64
69
|
SidebarNav,
|
|
65
70
|
Skeleton,
|
|
71
|
+
StatCard,
|
|
66
72
|
Stepper,
|
|
67
73
|
Switch,
|
|
68
74
|
Table,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Sereno Design System - public component surface. See the /design-system\n// showcase for the live catalog, or the barrel smoke test for the full list.\n// Icons are passed in as props (lucide-react), never imported here; theming is\n// 100% CSS custom properties.\n\n// core\nexport { Typography, type TypographyProps, type TypographyVariant, type TypographyColor } from './core/Typography';\nexport { Button, type ButtonProps } from './core/Button';\nexport { IconButton, type IconButtonProps } from './core/IconButton';\nexport { Badge, type BadgeProps } from './core/Badge';\nexport { Card, type CardProps } from './core/Card';\nexport { Avatar, type AvatarProps } from './core/Avatar';\nexport { Brand, type BrandProps } from './core/Brand';\nexport { Menu, type MenuProps, type MenuItem, type MenuEntry, type MenuSeparator, type MenuHeading } from './core/Menu';\nexport {\n Table,\n type TableProps,\n type TableRowProps,\n type HeaderCellProps,\n type CellProps,\n type TableSort,\n type SortDirection,\n} from './core/Table';\n\n// forms\nexport { Input, type InputProps } from './forms/Input';\nexport { Textarea, type TextareaProps } from './forms/Textarea';\nexport { Select, type SelectProps, type SelectOption } from './forms/Select';\nexport { Checkbox, type CheckboxProps } from './forms/Checkbox';\nexport { Radio, type RadioProps } from './forms/Radio';\nexport { Switch, type SwitchProps } from './forms/Switch';\nexport { DateTimePicker, type
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Sereno Design System - public component surface. See the /design-system\n// showcase for the live catalog, or the barrel smoke test for the full list.\n// Icons are passed in as props (lucide-react), never imported here; theming is\n// 100% CSS custom properties.\n\n// core\nexport { Typography, type TypographyProps, type TypographyVariant, type TypographyColor } from './core/Typography';\nexport { Button, type ButtonProps } from './core/Button';\nexport { IconButton, type IconButtonProps } from './core/IconButton';\nexport { Badge, type BadgeProps } from './core/Badge';\nexport { Card, type CardProps } from './core/Card';\nexport { StatCard, type StatCardProps, type StatCardTone } from './core/StatCard';\nexport { Avatar, type AvatarProps } from './core/Avatar';\nexport { Brand, type BrandProps } from './core/Brand';\nexport { Menu, type MenuProps, type MenuItem, type MenuEntry, type MenuSeparator, type MenuHeading } from './core/Menu';\nexport {\n Table,\n type TableProps,\n type TableRowProps,\n type HeaderCellProps,\n type CellProps,\n type TableSort,\n type SortDirection,\n} from './core/Table';\n\n// forms\nexport { Input, type InputProps } from './forms/Input';\nexport { Textarea, type TextareaProps } from './forms/Textarea';\nexport { Select, type SelectProps, type SelectOption } from './forms/Select';\nexport { Checkbox, type CheckboxProps } from './forms/Checkbox';\nexport { Radio, type RadioProps } from './forms/Radio';\nexport { Switch, type SwitchProps } from './forms/Switch';\nexport {\n DateTimePicker,\n type DateTimePickerProps,\n type TimeSlot,\n type CalendarDayContext,\n type CalendarDayDot,\n type CalendarDayDots,\n type CalendarDotTone,\n} from './forms/DateTimePicker';\nexport { CalendarLegend, type CalendarLegendProps, type CalendarLegendItem } from './forms/CalendarLegend';\nexport { DatePicker, type DatePickerProps, type DatePickerHandle } from './forms/DatePicker';\nexport { FileUpload, type FileUploadProps } from './forms/FileUpload';\nexport { AvatarUpload, type AvatarUploadProps } from './forms/AvatarUpload';\nexport { SearchInput, type SearchInputProps } from './forms/SearchInput';\n\n// navigation\nexport { TopBar, type TopBarProps, type TopBarLeadingProps, type TopBarTitleProps, type TopBarActionsProps } from './navigation/TopBar';\nexport { Tabs, type TabsProps, type TabsListProps, type TabsTabProps, type TabsPanelProps } from './navigation/Tabs';\nexport { BottomNav, type BottomNavProps, type BottomNavItemProps } from './navigation/BottomNav';\nexport {\n SidebarNav,\n type SidebarNavProps,\n type SidebarNavSectionProps,\n type SidebarNavItemProps,\n type SidebarNavSubItemProps,\n} from './navigation/SidebarNav';\nexport { Stepper, type StepperProps, type StepperStepProps } from './navigation/Stepper';\nexport { Pagination, type PaginationProps, type PaginationLabels } from './navigation/Pagination';\n\n// feedback\nexport { Alert, type AlertProps } from './feedback/Alert';\nexport { Toast, type ToastProps } from './feedback/Toast';\nexport {\n ToastProvider,\n useToast,\n type ToastProviderProps,\n type ToastOptions,\n type ToastApi,\n type ToastContextValue,\n type ToastPosition,\n} from './feedback/ToastProvider';\nexport { Dialog, type DialogProps, type DialogHeaderProps, type DialogBodyProps, type DialogFooterProps } from './feedback/Dialog';\nexport { Skeleton, type SkeletonProps } from './feedback/Skeleton';\nexport { EmptyState, type EmptyStateProps } from './feedback/EmptyState';\n\n// theme - the `data-theme` provider (next-themes) + the light/dark toggle\nexport { ThemeProvider } from './theme/ThemeProvider';\nexport { ThemeToggle } from './theme/ThemeToggle';\n"],"mappings":"AAMA,SAAS,kBAAsF;AAC/F,SAAS,cAAgC;AACzC,SAAS,kBAAwC;AACjD,SAAS,aAA8B;AACvC,SAAS,YAA4B;AACrC,SAAS,gBAAuD;AAChE,SAAS,cAAgC;AACzC,SAAS,aAA8B;AACvC,SAAS,YAAiG;AAC1G;AAAA,EACE;AAAA,OAOK;AAGP,SAAS,aAA8B;AACvC,SAAS,gBAAoC;AAC7C,SAAS,cAAmD;AAC5D,SAAS,gBAAoC;AAC7C,SAAS,aAA8B;AACvC,SAAS,cAAgC;AACzC;AAAA,EACE;AAAA,OAOK;AACP,SAAS,sBAAyE;AAClF,SAAS,kBAA+D;AACxE,SAAS,kBAAwC;AACjD,SAAS,oBAA4C;AACrD,SAAS,mBAA0C;AAGnD,SAAS,cAAyG;AAClH,SAAS,YAAwF;AACjG,SAAS,iBAA+D;AACxE;AAAA,EACE;AAAA,OAKK;AACP,SAAS,eAAyD;AAClE,SAAS,kBAA+D;AAGxE,SAAS,aAA8B;AACvC,SAAS,aAA8B;AACvC;AAAA,EACE;AAAA,EACA;AAAA,OAMK;AACP,SAAS,cAAsG;AAC/G,SAAS,gBAAoC;AAC7C,SAAS,kBAAwC;AAGjD,SAAS,qBAAqB;AAC9B,SAAS,mBAAmB;","names":[]}
|