@sereno-ds/ui 0.36.4 → 0.37.1

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.
@@ -4,6 +4,7 @@ import * as React from "react";
4
4
  import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
5
5
  import { sx } from "../../_internal/style.js";
6
6
  import { IconButton } from "../../core/IconButton.js";
7
+ import { calendarRange, clampIndex, isDayOutside, yearWindowStart } from "./calendarRange.js";
7
8
  const I18N = {
8
9
  "pt-BR": {
9
10
  dow: ["D", "S", "T", "Q", "Q", "S", "S"],
@@ -38,6 +39,8 @@ function CalendarGrid({
38
39
  month,
39
40
  selectedDate,
40
41
  unavailable = [],
42
+ min,
43
+ max,
41
44
  onSelectDate,
42
45
  onMonthChange,
43
46
  renderDay,
@@ -47,14 +50,18 @@ function CalendarGrid({
47
50
  }) {
48
51
  const t = I18N[locale];
49
52
  const now = React.useMemo(() => /* @__PURE__ */ new Date(), []);
50
- const initialIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());
53
+ const range = React.useMemo(() => calendarRange(min, max), [min, max]);
54
+ const requestedIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());
55
+ const initialIndex = clampIndex(requestedIndex, range);
51
56
  const [viewIndex, setViewIndex] = React.useState(initialIndex);
57
+ if (viewIndex !== clampIndex(viewIndex, range)) setViewIndex(clampIndex(viewIndex, range));
52
58
  const viewYear = Math.floor(viewIndex / 12);
53
59
  const viewMonth = viewIndex % 12;
54
60
  const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);
55
61
  const [open, setOpen] = React.useState(false);
56
62
  const [picker, setPicker] = React.useState("month");
57
- const [yearBase, setYearBase] = React.useState(() => (year ?? now.getFullYear()) - 5);
63
+ const bounded = Number.isFinite(range.minIndex) || Number.isFinite(range.maxIndex);
64
+ const [yearBase, setYearBase] = React.useState(() => yearWindowStart(bounded ? Math.floor(initialIndex / 12) : year ?? now.getFullYear(), range));
58
65
  const rootRef = React.useRef(null);
59
66
  const titleRef = React.useRef(null);
60
67
  const popRef = React.useRef(null);
@@ -62,17 +69,22 @@ function CalendarGrid({
62
69
  const [activeDay, setActiveDay] = React.useState(() => {
63
70
  if (selectedDate) return selectedDate;
64
71
  const todayIndex = now.getFullYear() * 12 + now.getMonth();
65
- return todayIndex === initialIndex ? now.getDate() : 1;
72
+ let day = todayIndex === initialIndex ? now.getDate() : 1;
73
+ if (range.min && initialIndex === range.minIndex) day = Math.max(day, range.min.day);
74
+ if (range.max && initialIndex === range.maxIndex) day = Math.min(day, range.max.day);
75
+ return day;
66
76
  });
67
77
  const shouldFocusDayRef = React.useRef(false);
68
78
  const onMonthChangeRef = React.useRef(onMonthChange);
69
79
  React.useEffect(() => {
70
80
  onMonthChangeRef.current = onMonthChange;
71
81
  });
82
+ const adjustedAtMount = React.useRef(requestedIndex !== initialIndex);
72
83
  const didMount = React.useRef(false);
73
84
  React.useEffect(() => {
74
85
  if (!didMount.current) {
75
86
  didMount.current = true;
87
+ if (adjustedAtMount.current) onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);
76
88
  return;
77
89
  }
78
90
  onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);
@@ -144,13 +156,15 @@ function CalendarGrid({
144
156
  }
145
157
  case "PageUp":
146
158
  e.preventDefault();
159
+ if (viewIndex - 1 < range.minIndex) return;
147
160
  shouldFocusDayRef.current = true;
148
- setViewIndex((i) => i - 1);
161
+ setViewIndex((i) => clampIndex(i - 1, range));
149
162
  return;
150
163
  case "PageDown":
151
164
  e.preventDefault();
165
+ if (viewIndex + 1 > range.maxIndex) return;
152
166
  shouldFocusDayRef.current = true;
153
- setViewIndex((i) => i + 1);
167
+ setViewIndex((i) => clampIndex(i + 1, range));
154
168
  return;
155
169
  default:
156
170
  return;
@@ -158,6 +172,7 @@ function CalendarGrid({
158
172
  e.preventDefault();
159
173
  const next = new Date(viewYear, viewMonth, rovingDay + delta);
160
174
  const nextViewIndex = next.getFullYear() * 12 + next.getMonth();
175
+ if (nextViewIndex < range.minIndex || nextViewIndex > range.maxIndex) return;
161
176
  shouldFocusDayRef.current = true;
162
177
  if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);
163
178
  setActiveDay(next.getDate());
@@ -167,6 +182,29 @@ function CalendarGrid({
167
182
  shouldFocusDayRef.current = false;
168
183
  gridRef.current?.querySelector(`[data-day="${rovingDay}"]`)?.focus();
169
184
  }, [viewIndex, rovingDay]);
185
+ const canPrevMonth = viewIndex > range.minIndex;
186
+ const canNextMonth = viewIndex < range.maxIndex;
187
+ const goMonth = (dir) => {
188
+ const next = clampIndex(viewIndex + dir, range);
189
+ if (next === viewIndex) return;
190
+ setViewIndex((i) => clampIndex(i + dir, range));
191
+ if (clampIndex(next + dir, range) === next) titleRef.current?.focus();
192
+ };
193
+ const canPrevYear = picker === "month" ? viewYear > range.minYear : yearBase > range.minYear;
194
+ const canNextYear = picker === "month" ? viewYear < range.maxYear : yearBase + 12 <= range.maxYear;
195
+ const goYear = (dir) => {
196
+ if (picker === "month") {
197
+ const next = clampIndex(viewIndex + dir * 12, range);
198
+ if (next === viewIndex) return;
199
+ setViewIndex((i) => clampIndex(i + dir * 12, range));
200
+ const nextYear = Math.floor(next / 12);
201
+ if (dir < 0 ? nextYear <= range.minYear : nextYear >= range.maxYear) popRef.current?.focus();
202
+ } else {
203
+ const next = yearBase + dir * 12;
204
+ setYearBase((b) => b + dir * 12);
205
+ if (dir < 0 ? next <= range.minYear : next + 12 > range.maxYear) popRef.current?.focus();
206
+ }
207
+ };
170
208
  return /* @__PURE__ */ jsxs("div", { ref: rootRef, children: [
171
209
  /* @__PURE__ */ jsxs(
172
210
  "div",
@@ -180,7 +218,7 @@ function CalendarGrid({
180
218
  marginBottom: "var(--space-3)"
181
219
  }),
182
220
  children: [
183
- /* @__PURE__ */ jsx(IconButton, { label: t.prevMonth, size: "sm", onClick: () => setViewIndex((i) => i - 1), children: /* @__PURE__ */ jsx(ChevronLeft, { size: 18, strokeWidth: 1.75 }) }),
221
+ /* @__PURE__ */ jsx(IconButton, { label: t.prevMonth, size: "sm", disabled: !canPrevMonth, onClick: () => goMonth(-1), children: /* @__PURE__ */ jsx(ChevronLeft, { size: 18, strokeWidth: 1.75 }) }),
184
222
  /* @__PURE__ */ jsxs(
185
223
  "button",
186
224
  {
@@ -215,7 +253,7 @@ function CalendarGrid({
215
253
  ]
216
254
  }
217
255
  ),
218
- /* @__PURE__ */ jsx(IconButton, { label: t.nextMonth, size: "sm", onClick: () => setViewIndex((i) => i + 1), children: /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75 }) }),
256
+ /* @__PURE__ */ jsx(IconButton, { label: t.nextMonth, size: "sm", disabled: !canNextMonth, onClick: () => goMonth(1), children: /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75 }) }),
219
257
  open && /* @__PURE__ */ jsxs(
220
258
  "div",
221
259
  {
@@ -256,22 +294,14 @@ function CalendarGrid({
256
294
  marginBottom: "var(--space-2)"
257
295
  }),
258
296
  children: [
259
- /* @__PURE__ */ jsx(
260
- IconButton,
261
- {
262
- label: picker === "month" ? t.prevYear : t.prevYears,
263
- size: "sm",
264
- onClick: () => picker === "month" ? setViewIndex((i) => i - 12) : setYearBase((b) => b - 12),
265
- children: /* @__PURE__ */ jsx(ChevronLeft, { size: 18, strokeWidth: 1.75 })
266
- }
267
- ),
297
+ /* @__PURE__ */ jsx(IconButton, { label: picker === "month" ? t.prevYear : t.prevYears, size: "sm", disabled: !canPrevYear, onClick: () => goYear(-1), children: /* @__PURE__ */ jsx(ChevronLeft, { size: 18, strokeWidth: 1.75 }) }),
268
298
  picker === "month" ? /* @__PURE__ */ jsx(
269
299
  "button",
270
300
  {
271
301
  type: "button",
272
302
  className: "sereno-dtp-title",
273
303
  onClick: () => {
274
- setYearBase(viewYear - 5);
304
+ setYearBase(yearWindowStart(viewYear, range));
275
305
  setPicker("year");
276
306
  },
277
307
  style: sx({
@@ -305,15 +335,7 @@ function CalendarGrid({
305
335
  ]
306
336
  }
307
337
  ),
308
- /* @__PURE__ */ jsx(
309
- IconButton,
310
- {
311
- label: picker === "month" ? t.nextYear : t.nextYears,
312
- size: "sm",
313
- onClick: () => picker === "month" ? setViewIndex((i) => i + 12) : setYearBase((b) => b + 12),
314
- children: /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75 })
315
- }
316
- )
338
+ /* @__PURE__ */ jsx(IconButton, { label: picker === "month" ? t.nextYear : t.nextYears, size: "sm", disabled: !canNextYear, onClick: () => goYear(1), children: /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75 }) })
317
339
  ]
318
340
  }
319
341
  ),
@@ -323,8 +345,9 @@ function CalendarGrid({
323
345
  type: "button",
324
346
  "data-current": i === viewMonth || void 0,
325
347
  "aria-current": i === viewMonth ? "true" : void 0,
348
+ disabled: viewYear * 12 + i < range.minIndex || viewYear * 12 + i > range.maxIndex,
326
349
  onClick: () => {
327
- setViewIndex(viewYear * 12 + i);
350
+ setViewIndex(clampIndex(viewYear * 12 + i, range));
328
351
  closePopover();
329
352
  },
330
353
  children: mo
@@ -336,8 +359,9 @@ function CalendarGrid({
336
359
  type: "button",
337
360
  "data-current": y === viewYear || void 0,
338
361
  "aria-current": y === viewYear ? "true" : void 0,
362
+ disabled: y < range.minYear || y > range.maxYear,
339
363
  onClick: () => {
340
- setViewIndex(y * 12 + viewMonth);
364
+ setViewIndex(clampIndex(y * 12 + viewMonth, range));
341
365
  setPicker("month");
342
366
  },
343
367
  children: y
@@ -374,7 +398,7 @@ function CalendarGrid({
374
398
  style: sx({ display: "grid", gridTemplateColumns: "repeat(7,1fr)", gap: "var(--space-1)" }),
375
399
  children: cells.map((d, i) => {
376
400
  if (d === null) return /* @__PURE__ */ jsx("span", { "aria-hidden": true, style: cellSizing }, i);
377
- const off = unavailable.includes(d);
401
+ const off = unavailable.includes(d) || isDayOutside(range, viewIndex, d);
378
402
  const sel = selectedDate === d && viewIndex === selectionIndex;
379
403
  const extra = renderDay?.(d);
380
404
  return /* @__PURE__ */ jsxs(
@@ -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';\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 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 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 initialIndex = (year ?? now.getFullYear()) * 12 + (month ?? now.getMonth());\n const [viewIndex, setViewIndex] = React.useState(initialIndex);\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 const [yearBase, setYearBase] = React.useState(() => (year ?? now.getFullYear()) - 5);\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 return todayIndex === initialIndex ? now.getDate() : 1;\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 const didMount = React.useRef(false);\n React.useEffect(() => {\n if (!didMount.current) {\n didMount.current = true;\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 shouldFocusDayRef.current = true;\n setViewIndex((i) => i - 1);\n return;\n case 'PageDown':\n e.preventDefault();\n shouldFocusDayRef.current = true;\n setViewIndex((i) => i + 1);\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 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 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\" onClick={() => setViewIndex((i) => i - 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\" onClick={() => setViewIndex((i) => i + 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\n label={picker === 'month' ? t.prevYear : t.prevYears}\n size=\"sm\"\n onClick={() => (picker === 'month' ? setViewIndex((i) => i - 12) : setYearBase((b) => b - 12))}\n >\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(viewYear - 5);\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\n label={picker === 'month' ? t.nextYear : t.nextYears}\n size=\"sm\"\n onClick={() => (picker === 'month' ? setViewIndex((i) => i + 12) : setYearBase((b) => b + 12))}\n >\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 onClick={() => {\n setViewIndex(viewYear * 12 + i);\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 onClick={() => {\n setViewIndex(y * 12 + viewMonth);\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);\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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C,gBAAc;AAAA,cACd,SAAS,MAAM;AACb,oBAAI,IAAK;AACT,kCAAkB,SAAS;AAM3B,6BAAa,CAAC;AACd,+BAAe,CAAC;AAAA,cAClB;AAAA,cACA,OAAO,GAAG;AAAA,gBACR,GAAG;AAAA,gBACH,SAAS;AAAA,gBACT,eAAe;AAAA,gBACf,YAAY;AAAA,gBACZ,gBAAgB;AAAA,gBAChB,KAAK;AAAA,gBACL,cAAc;AAAA,gBACd,QAAQ;AAAA,gBACR,SAAS;AAAA,gBACT,QAAQ,MAAM,gBAAgB;AAAA,gBAC9B,YAAY,MAAM,+BAA+B;AAAA,gBACjD,OAAO,MAAM,kCAAkC,MAAM,yBAAyB;AAAA,gBAC9E,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,YAAY,MAAM,uBAAuB;AAAA,gBACzC,gBAAgB,MAAM,iBAAiB;AAAA,gBACvC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMd,CAAC;AAAA,cAED;AAAA,oCAAC,UAAM,aAAE;AAAA,gBACR,YAAY,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,WAAW,IAAI,YAAY,EAAE,CAAC,GAAI,iBAAM,IAAU;AAAA;AAAA;AAAA,YAjD7F;AAAA,UAkDP;AAAA,QAEJ,CAAC;AAAA;AAAA,MAlEI;AAAA,IAmEP;AAAA,KACF;AAEJ;","names":[]}
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,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,EACf;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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AY;AAAA,gBACZ,gBAAgB;AAAA,gBAChB,KAAK;AAAA,gBACL,cAAc;AAAA,gBACd,QAAQ;AAAA,gBACR,SAAS;AAAA,gBACT,QAAQ,MAAM,gBAAgB;AAAA,gBAC9B,YAAY,MAAM,+BAA+B;AAAA,gBACjD,OAAO,MAAM,kCAAkC,MAAM,yBAAyB;AAAA,gBAC9E,YAAY;AAAA,gBACZ,UAAU;AAAA,gBACV,YAAY,MAAM,uBAAuB;AAAA,gBACzC,gBAAgB,MAAM,iBAAiB;AAAA,gBACvC,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAMd,CAAC;AAAA,cAED;AAAA,oCAAC,UAAM,aAAE;AAAA,gBACR,YAAY,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,WAAW,IAAI,YAAY,EAAE,CAAC,GAAI,iBAAM,IAAU;AAAA;AAAA;AAAA,YAjD7F;AAAA,UAkDP;AAAA,QAEJ,CAAC;AAAA;AAAA,MAlEI;AAAA,IAmEP;AAAA,KACF;AAEJ;","names":[]}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The `min` / `max` limits of the month calendar (`CalendarGrid`, so `DateTimePicker` and
3
+ * `DatePicker`), as pure functions. A month is one integer, `year * 12 + month` (month
4
+ * 0-indexed), the same one `CalendarGrid` keeps for its visible month, so stepping and
5
+ * clamping is plain arithmetic with no `Date` juggling across year ends.
6
+ */
7
+ interface YMD {
8
+ year: number;
9
+ /** 0-indexed, like `Date`. */
10
+ month: number;
11
+ day: number;
12
+ }
13
+ /** "YYYY-MM-DD" to its parts, or `null` for anything else (a bad bound is ignored, not guessed at). */
14
+ declare function parseISODate(iso: string | undefined): YMD | null;
15
+ declare function toISODate(year: number, month: number, day: number): string;
16
+ interface CalendarRange {
17
+ min: YMD | null;
18
+ max: YMD | null;
19
+ /** The first / last visible month, as `year * 12 + month`. `-Infinity` / `Infinity` when unbounded. */
20
+ minIndex: number;
21
+ maxIndex: number;
22
+ /** The first / last year with any valid month. `-Infinity` / `Infinity` when unbounded. */
23
+ minYear: number;
24
+ maxYear: number;
25
+ }
26
+ declare function calendarRange(min?: string, max?: string): CalendarRange;
27
+ /**
28
+ * The nearest visible month inside the range. `min` wins if the two cross (a range with
29
+ * `min` after `max` has no valid month at all, so there is nothing better to show).
30
+ */
31
+ declare function clampIndex(index: number, range: CalendarRange): number;
32
+ /** Whether `day` of the month `index` falls before `min` or after `max`. */
33
+ declare function isDayOutside(range: CalendarRange, index: number, day: number): boolean;
34
+ /**
35
+ * First year of the 12-year block the year picker opens on: the visible year with 5 before it,
36
+ * pulled back inside the range when it can be, so the block is not mostly years that cannot be
37
+ * picked. Unbounded, it is exactly `viewYear - 5`, as it always was.
38
+ */
39
+ declare function yearWindowStart(viewYear: number, range: CalendarRange): number;
40
+
41
+ export { type CalendarRange, type YMD, calendarRange, clampIndex, isDayOutside, parseISODate, toISODate, yearWindowStart };
@@ -0,0 +1,45 @@
1
+ function parseISODate(iso) {
2
+ if (!iso) return null;
3
+ const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
4
+ if (!m) return null;
5
+ return { year: Number(m[1]), month: Number(m[2]) - 1, day: Number(m[3]) };
6
+ }
7
+ function toISODate(year, month, day) {
8
+ return `${String(year).padStart(4, "0")}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
9
+ }
10
+ function calendarRange(min, max) {
11
+ const lo = parseISODate(min);
12
+ const hi = parseISODate(max);
13
+ return {
14
+ min: lo,
15
+ max: hi,
16
+ minIndex: lo ? lo.year * 12 + lo.month : -Infinity,
17
+ maxIndex: hi ? hi.year * 12 + hi.month : Infinity,
18
+ minYear: lo ? lo.year : -Infinity,
19
+ maxYear: hi ? hi.year : Infinity
20
+ };
21
+ }
22
+ function clampIndex(index, range) {
23
+ return Math.max(range.minIndex, Math.min(range.maxIndex, index));
24
+ }
25
+ function isDayOutside(range, index, day) {
26
+ const key = index * 32 + day;
27
+ if (range.min && key < range.minIndex * 32 + range.min.day) return true;
28
+ if (range.max && key > range.maxIndex * 32 + range.max.day) return true;
29
+ return false;
30
+ }
31
+ function yearWindowStart(viewYear, range) {
32
+ let base = viewYear - 5;
33
+ if (Number.isFinite(range.maxYear)) base = Math.min(base, range.maxYear - 11);
34
+ if (Number.isFinite(range.minYear)) base = Math.max(base, range.minYear);
35
+ return base;
36
+ }
37
+ export {
38
+ calendarRange,
39
+ clampIndex,
40
+ isDayOutside,
41
+ parseISODate,
42
+ toISODate,
43
+ yearWindowStart
44
+ };
45
+ //# sourceMappingURL=calendarRange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/forms/_internal/calendarRange.ts"],"sourcesContent":["/**\n * The `min` / `max` limits of the month calendar (`CalendarGrid`, so `DateTimePicker` and\n * `DatePicker`), as pure functions. A month is one integer, `year * 12 + month` (month\n * 0-indexed), the same one `CalendarGrid` keeps for its visible month, so stepping and\n * clamping is plain arithmetic with no `Date` juggling across year ends.\n */\n\nexport interface YMD {\n year: number;\n /** 0-indexed, like `Date`. */\n month: number;\n day: number;\n}\n\n/** \"YYYY-MM-DD\" to its parts, or `null` for anything else (a bad bound is ignored, not guessed at). */\nexport function parseISODate(iso: string | undefined): YMD | null {\n if (!iso) return null;\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n if (!m) return null;\n return { year: Number(m[1]), month: Number(m[2]) - 1, day: Number(m[3]) };\n}\n\nexport function toISODate(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, '0')}-${String(month + 1).padStart(2, '0')}-${String(day).padStart(2, '0')}`;\n}\n\nexport interface CalendarRange {\n min: YMD | null;\n max: YMD | null;\n /** The first / last visible month, as `year * 12 + month`. `-Infinity` / `Infinity` when unbounded. */\n minIndex: number;\n maxIndex: number;\n /** The first / last year with any valid month. `-Infinity` / `Infinity` when unbounded. */\n minYear: number;\n maxYear: number;\n}\n\nexport function calendarRange(min?: string, max?: string): CalendarRange {\n const lo = parseISODate(min);\n const hi = parseISODate(max);\n return {\n min: lo,\n max: hi,\n minIndex: lo ? lo.year * 12 + lo.month : -Infinity,\n maxIndex: hi ? hi.year * 12 + hi.month : Infinity,\n minYear: lo ? lo.year : -Infinity,\n maxYear: hi ? hi.year : Infinity,\n };\n}\n\n/**\n * The nearest visible month inside the range. `min` wins if the two cross (a range with\n * `min` after `max` has no valid month at all, so there is nothing better to show).\n */\nexport function clampIndex(index: number, range: CalendarRange): number {\n return Math.max(range.minIndex, Math.min(range.maxIndex, index));\n}\n\n/** Whether `day` of the month `index` falls before `min` or after `max`. */\nexport function isDayOutside(range: CalendarRange, index: number, day: number): boolean {\n // A day is at most 31, so `index * 32 + day` orders dates the same way the calendar does.\n const key = index * 32 + day;\n if (range.min && key < range.minIndex * 32 + range.min.day) return true;\n if (range.max && key > range.maxIndex * 32 + range.max.day) return true;\n return false;\n}\n\n/**\n * First year of the 12-year block the year picker opens on: the visible year with 5 before it,\n * pulled back inside the range when it can be, so the block is not mostly years that cannot be\n * picked. Unbounded, it is exactly `viewYear - 5`, as it always was.\n */\nexport function yearWindowStart(viewYear: number, range: CalendarRange): number {\n let base = viewYear - 5;\n if (Number.isFinite(range.maxYear)) base = Math.min(base, range.maxYear - 11);\n if (Number.isFinite(range.minYear)) base = Math.max(base, range.minYear);\n return base;\n}\n"],"mappings":"AAeO,SAAS,aAAa,KAAqC;AAChE,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,IAAI,4BAA4B,KAAK,GAAG;AAC9C,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,EAAE,MAAM,OAAO,EAAE,CAAC,CAAC,GAAG,OAAO,OAAO,EAAE,CAAC,CAAC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC,CAAC,EAAE;AAC1E;AAEO,SAAS,UAAU,MAAc,OAAe,KAAqB;AAC1E,SAAO,GAAG,OAAO,IAAI,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,CAAC,IAAI,OAAO,GAAG,EAAE,SAAS,GAAG,GAAG,CAAC;AAC/G;AAaO,SAAS,cAAc,KAAc,KAA6B;AACvE,QAAM,KAAK,aAAa,GAAG;AAC3B,QAAM,KAAK,aAAa,GAAG;AAC3B,SAAO;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AAAA,IACL,UAAU,KAAK,GAAG,OAAO,KAAK,GAAG,QAAQ;AAAA,IACzC,UAAU,KAAK,GAAG,OAAO,KAAK,GAAG,QAAQ;AAAA,IACzC,SAAS,KAAK,GAAG,OAAO;AAAA,IACxB,SAAS,KAAK,GAAG,OAAO;AAAA,EAC1B;AACF;AAMO,SAAS,WAAW,OAAe,OAA8B;AACtE,SAAO,KAAK,IAAI,MAAM,UAAU,KAAK,IAAI,MAAM,UAAU,KAAK,CAAC;AACjE;AAGO,SAAS,aAAa,OAAsB,OAAe,KAAsB;AAEtF,QAAM,MAAM,QAAQ,KAAK;AACzB,MAAI,MAAM,OAAO,MAAM,MAAM,WAAW,KAAK,MAAM,IAAI,IAAK,QAAO;AACnE,MAAI,MAAM,OAAO,MAAM,MAAM,WAAW,KAAK,MAAM,IAAI,IAAK,QAAO;AACnE,SAAO;AACT;AAOO,SAAS,gBAAgB,UAAkB,OAA8B;AAC9E,MAAI,OAAO,WAAW;AACtB,MAAI,OAAO,SAAS,MAAM,OAAO,EAAG,QAAO,KAAK,IAAI,MAAM,MAAM,UAAU,EAAE;AAC5E,MAAI,OAAO,SAAS,MAAM,OAAO,EAAG,QAAO,KAAK,IAAI,MAAM,MAAM,OAAO;AACvE,SAAO;AACT;","names":[]}
package/dist/styles.css CHANGED
@@ -285,6 +285,11 @@
285
285
  transition: background-color var(--duration-fast) var(--ease-standard);
286
286
  }
287
287
  .sereno-dtp-grid button:hover { background: var(--interactive-ghost-hover); }
288
+ /* A month / year outside the calendar's `min` .. `max` (SS-331): not pickable, and not focusable either.
289
+ The :hover rule above stays as it was (its specificity decides the [data-current] tie below); the
290
+ disabled one only turns it off for a disabled button. */
291
+ .sereno-dtp-grid button:disabled { color: var(--text-disabled); cursor: not-allowed; }
292
+ .sereno-dtp-grid button:disabled:hover { background: transparent; }
288
293
  .sereno-dtp-grid button:focus-visible { outline: 2px solid var(--border-focus); outline-offset: -2px; }
289
294
  /* The day grid's own focus ring (SS-228) - was missing entirely: the day
290
295
  button used to set outline:none *inline*, which always wins over a class
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sereno-ds/ui",
3
- "version": "0.36.4",
3
+ "version": "0.37.1",
4
4
  "description": "Sereno Design System: React primitives (token-driven, inline styles, no UI base lib).",
5
5
  "license": "MIT",
6
6
  "author": "Sereno",