@sereno-ds/ui 0.25.7 → 0.27.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/forms/DatePicker.d.ts +48 -0
- package/dist/forms/DatePicker.js +237 -0
- package/dist/forms/DatePicker.js.map +1 -0
- package/dist/forms/DateTimePicker.d.ts +27 -3
- package/dist/forms/DateTimePicker.js +70 -394
- package/dist/forms/DateTimePicker.js.map +1 -1
- package/dist/forms/Select.js +1 -31
- package/dist/forms/Select.js.map +1 -1
- package/dist/forms/_internal/CalendarGrid.d.ts +47 -0
- package/dist/forms/_internal/CalendarGrid.js +434 -0
- package/dist/forms/_internal/CalendarGrid.js.map +1 -0
- package/dist/forms/_internal/fieldBoxStyle.d.ts +14 -0
- package/dist/forms/_internal/fieldBoxStyle.js +37 -0
- package/dist/forms/_internal/fieldBoxStyle.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import { ChevronDown, ChevronLeft, ChevronRight } from "lucide-react";
|
|
5
3
|
import { sx } from "../_internal/style";
|
|
6
|
-
import {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
import { CalendarGrid } from "./_internal/CalendarGrid";
|
|
5
|
+
const TEXT = {
|
|
6
|
+
"pt-BR": {
|
|
7
|
+
timeLabel: "Hor\xE1rios dispon\xEDveis",
|
|
8
|
+
full: "Lotado",
|
|
9
|
+
fullInline: "lotado",
|
|
10
|
+
available: "Dispon\xEDvel",
|
|
11
|
+
vagas: (booked, capacity) => `${booked} de ${capacity} vagas`
|
|
12
|
+
},
|
|
13
|
+
en: {
|
|
14
|
+
timeLabel: "Available times",
|
|
15
|
+
full: "Full",
|
|
16
|
+
fullInline: "full",
|
|
17
|
+
available: "Available",
|
|
18
|
+
vagas: (booked, capacity) => `${booked} of ${capacity} spots`
|
|
19
|
+
}
|
|
20
|
+
};
|
|
13
21
|
function DateTimePicker({
|
|
14
22
|
year,
|
|
15
23
|
month,
|
|
@@ -21,133 +29,18 @@ function DateTimePicker({
|
|
|
21
29
|
onSelectTime,
|
|
22
30
|
onMonthChange,
|
|
23
31
|
renderDay,
|
|
24
|
-
timeLabel
|
|
32
|
+
timeLabel,
|
|
33
|
+
locale = "pt-BR",
|
|
25
34
|
style,
|
|
26
35
|
...rest
|
|
27
36
|
}) {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
const viewYear = Math.floor(viewIndex / 12);
|
|
32
|
-
const viewMonth = viewIndex % 12;
|
|
33
|
-
const [selectionIndex, setSelectionIndex] = React.useState(initialIndex);
|
|
34
|
-
const [open, setOpen] = React.useState(false);
|
|
35
|
-
const [picker, setPicker] = React.useState("month");
|
|
36
|
-
const [yearBase, setYearBase] = React.useState(() => (year ?? now.getFullYear()) - 5);
|
|
37
|
-
const rootRef = React.useRef(null);
|
|
38
|
-
const titleRef = React.useRef(null);
|
|
39
|
-
const popRef = React.useRef(null);
|
|
40
|
-
const gridRef = React.useRef(null);
|
|
41
|
-
const [activeDay, setActiveDay] = React.useState(() => {
|
|
42
|
-
if (selectedDate) return selectedDate;
|
|
43
|
-
const todayIndex = now.getFullYear() * 12 + now.getMonth();
|
|
44
|
-
return todayIndex === initialIndex ? now.getDate() : 1;
|
|
45
|
-
});
|
|
46
|
-
const shouldFocusDayRef = React.useRef(false);
|
|
47
|
-
const onMonthChangeRef = React.useRef(onMonthChange);
|
|
48
|
-
React.useEffect(() => {
|
|
49
|
-
onMonthChangeRef.current = onMonthChange;
|
|
50
|
-
});
|
|
51
|
-
const didMount = React.useRef(false);
|
|
52
|
-
React.useEffect(() => {
|
|
53
|
-
if (!didMount.current) {
|
|
54
|
-
didMount.current = true;
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
onMonthChangeRef.current?.(Math.floor(viewIndex / 12), viewIndex % 12);
|
|
58
|
-
}, [viewIndex]);
|
|
59
|
-
React.useEffect(() => {
|
|
60
|
-
if (!open) return;
|
|
61
|
-
const onDown = (e) => {
|
|
62
|
-
if (rootRef.current && !rootRef.current.contains(e.target)) {
|
|
63
|
-
setOpen(false);
|
|
64
|
-
setPicker("month");
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
document.addEventListener("pointerdown", onDown, true);
|
|
68
|
-
const id = requestAnimationFrame(() => popRef.current?.focus());
|
|
69
|
-
return () => {
|
|
70
|
-
document.removeEventListener("pointerdown", onDown, true);
|
|
71
|
-
cancelAnimationFrame(id);
|
|
72
|
-
};
|
|
73
|
-
}, [open]);
|
|
74
|
-
const closePopover = React.useCallback(() => {
|
|
75
|
-
setOpen(false);
|
|
76
|
-
setPicker("month");
|
|
77
|
-
titleRef.current?.focus();
|
|
78
|
-
}, []);
|
|
79
|
-
const toggleOpen = React.useCallback(() => {
|
|
80
|
-
setOpen((v) => {
|
|
81
|
-
if (v) setPicker("month");
|
|
82
|
-
return !v;
|
|
83
|
-
});
|
|
84
|
-
}, []);
|
|
85
|
-
const first = new Date(viewYear, viewMonth, 1).getDay();
|
|
86
|
-
const total = daysIn(viewYear, viewMonth);
|
|
87
|
-
const cells = [...Array(first).fill(null), ...Array.from({ length: total }, (_, i) => i + 1)];
|
|
88
|
-
while (cells.length < 42) cells.push(null);
|
|
89
|
-
const cellH = renderDay ? 48 : 38;
|
|
90
|
-
const years = Array.from({ length: 12 }, (_, i) => yearBase + i);
|
|
91
|
-
const rovingDay = Math.min(Math.max(1, activeDay), total);
|
|
92
|
-
const onGridKeyDown = (e) => {
|
|
93
|
-
let delta = 0;
|
|
94
|
-
switch (e.key) {
|
|
95
|
-
case "ArrowRight":
|
|
96
|
-
delta = 1;
|
|
97
|
-
break;
|
|
98
|
-
case "ArrowLeft":
|
|
99
|
-
delta = -1;
|
|
100
|
-
break;
|
|
101
|
-
case "ArrowDown":
|
|
102
|
-
delta = 7;
|
|
103
|
-
break;
|
|
104
|
-
case "ArrowUp":
|
|
105
|
-
delta = -7;
|
|
106
|
-
break;
|
|
107
|
-
case "Home": {
|
|
108
|
-
e.preventDefault();
|
|
109
|
-
const row = Math.floor((first + rovingDay - 1) / 7);
|
|
110
|
-
shouldFocusDayRef.current = true;
|
|
111
|
-
setActiveDay(Math.max(1, row * 7 - first + 1));
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
case "End": {
|
|
115
|
-
e.preventDefault();
|
|
116
|
-
const row = Math.floor((first + rovingDay - 1) / 7);
|
|
117
|
-
shouldFocusDayRef.current = true;
|
|
118
|
-
setActiveDay(Math.min(total, row * 7 + 7 - first));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
case "PageUp":
|
|
122
|
-
e.preventDefault();
|
|
123
|
-
shouldFocusDayRef.current = true;
|
|
124
|
-
setViewIndex((i) => i - 1);
|
|
125
|
-
return;
|
|
126
|
-
case "PageDown":
|
|
127
|
-
e.preventDefault();
|
|
128
|
-
shouldFocusDayRef.current = true;
|
|
129
|
-
setViewIndex((i) => i + 1);
|
|
130
|
-
return;
|
|
131
|
-
default:
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
e.preventDefault();
|
|
135
|
-
const next = new Date(viewYear, viewMonth, rovingDay + delta);
|
|
136
|
-
const nextViewIndex = next.getFullYear() * 12 + next.getMonth();
|
|
137
|
-
shouldFocusDayRef.current = true;
|
|
138
|
-
if (nextViewIndex !== viewIndex) setViewIndex(nextViewIndex);
|
|
139
|
-
setActiveDay(next.getDate());
|
|
140
|
-
};
|
|
141
|
-
React.useLayoutEffect(() => {
|
|
142
|
-
if (!shouldFocusDayRef.current) return;
|
|
143
|
-
shouldFocusDayRef.current = false;
|
|
144
|
-
gridRef.current?.querySelector(`[data-day="${rovingDay}"]`)?.focus();
|
|
145
|
-
}, [viewIndex, rovingDay]);
|
|
37
|
+
const copy = TEXT[locale];
|
|
38
|
+
const label = timeLabel ?? copy.timeLabel;
|
|
39
|
+
const anyCapacity = times.some((s) => typeof s === "object" && s.capacity !== void 0);
|
|
146
40
|
return /* @__PURE__ */ jsxs(
|
|
147
41
|
"div",
|
|
148
42
|
{
|
|
149
43
|
...rest,
|
|
150
|
-
ref: rootRef,
|
|
151
44
|
style: sx({
|
|
152
45
|
position: "relative",
|
|
153
46
|
background: "var(--bg-surface)",
|
|
@@ -158,263 +51,18 @@ function DateTimePicker({
|
|
|
158
51
|
...style
|
|
159
52
|
}),
|
|
160
53
|
children: [
|
|
161
|
-
/* @__PURE__ */ jsxs(
|
|
162
|
-
"div",
|
|
163
|
-
{
|
|
164
|
-
style: sx({
|
|
165
|
-
position: "relative",
|
|
166
|
-
display: "grid",
|
|
167
|
-
gridTemplateColumns: "auto 1fr auto",
|
|
168
|
-
alignItems: "center",
|
|
169
|
-
gap: "var(--space-1)",
|
|
170
|
-
marginBottom: "var(--space-3)"
|
|
171
|
-
}),
|
|
172
|
-
children: [
|
|
173
|
-
/* @__PURE__ */ jsx(IconButton, { label: "M\xEAs anterior", size: "sm", onClick: () => setViewIndex((i) => i - 1), children: /* @__PURE__ */ jsx(ChevronLeft, { size: 18, strokeWidth: 1.75 }) }),
|
|
174
|
-
/* @__PURE__ */ jsxs(
|
|
175
|
-
"button",
|
|
176
|
-
{
|
|
177
|
-
ref: titleRef,
|
|
178
|
-
type: "button",
|
|
179
|
-
className: "sereno-dtp-title",
|
|
180
|
-
"aria-haspopup": "dialog",
|
|
181
|
-
"aria-expanded": open,
|
|
182
|
-
onClick: toggleOpen,
|
|
183
|
-
style: sx({
|
|
184
|
-
display: "inline-flex",
|
|
185
|
-
alignItems: "center",
|
|
186
|
-
justifyContent: "center",
|
|
187
|
-
gap: 4,
|
|
188
|
-
margin: "0 auto",
|
|
189
|
-
padding: "4px 8px",
|
|
190
|
-
border: "none",
|
|
191
|
-
borderRadius: "var(--radius-sm)",
|
|
192
|
-
background: "transparent",
|
|
193
|
-
cursor: "pointer",
|
|
194
|
-
fontFamily: "var(--font-display)",
|
|
195
|
-
fontSize: "var(--text-base)",
|
|
196
|
-
fontWeight: "var(--weight-bold)",
|
|
197
|
-
color: "var(--text-primary)",
|
|
198
|
-
textTransform: "capitalize"
|
|
199
|
-
}),
|
|
200
|
-
children: [
|
|
201
|
-
MONTHS[viewMonth],
|
|
202
|
-
" ",
|
|
203
|
-
viewYear,
|
|
204
|
-
/* @__PURE__ */ jsx(ChevronDown, { size: 15, strokeWidth: 2, style: { opacity: 0.6 } })
|
|
205
|
-
]
|
|
206
|
-
}
|
|
207
|
-
),
|
|
208
|
-
/* @__PURE__ */ jsx(IconButton, { label: "Pr\xF3ximo m\xEAs", size: "sm", onClick: () => setViewIndex((i) => i + 1), children: /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75 }) }),
|
|
209
|
-
open && /* @__PURE__ */ jsxs(
|
|
210
|
-
"div",
|
|
211
|
-
{
|
|
212
|
-
ref: popRef,
|
|
213
|
-
role: "dialog",
|
|
214
|
-
"aria-label": "Escolher m\xEAs e ano",
|
|
215
|
-
tabIndex: -1,
|
|
216
|
-
onKeyDown: (e) => {
|
|
217
|
-
if (e.key === "Escape") {
|
|
218
|
-
e.stopPropagation();
|
|
219
|
-
closePopover();
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
className: "sereno-dtp-pop",
|
|
223
|
-
style: sx({
|
|
224
|
-
position: "absolute",
|
|
225
|
-
top: "calc(100% + 6px)",
|
|
226
|
-
left: "50%",
|
|
227
|
-
transform: "translateX(-50%)",
|
|
228
|
-
zIndex: 20,
|
|
229
|
-
width: 248,
|
|
230
|
-
maxWidth: "calc(100vw - 24px)",
|
|
231
|
-
background: "var(--bg-surface)",
|
|
232
|
-
border: "var(--border-width-hairline) solid var(--border-default)",
|
|
233
|
-
borderRadius: "var(--radius-md)",
|
|
234
|
-
boxShadow: "var(--shadow-lg)",
|
|
235
|
-
padding: "var(--space-3)",
|
|
236
|
-
outline: "none"
|
|
237
|
-
}),
|
|
238
|
-
children: [
|
|
239
|
-
/* @__PURE__ */ jsxs(
|
|
240
|
-
"div",
|
|
241
|
-
{
|
|
242
|
-
style: sx({
|
|
243
|
-
display: "grid",
|
|
244
|
-
gridTemplateColumns: "auto 1fr auto",
|
|
245
|
-
alignItems: "center",
|
|
246
|
-
marginBottom: "var(--space-2)"
|
|
247
|
-
}),
|
|
248
|
-
children: [
|
|
249
|
-
/* @__PURE__ */ jsx(
|
|
250
|
-
IconButton,
|
|
251
|
-
{
|
|
252
|
-
label: picker === "month" ? "Ano anterior" : "Anos anteriores",
|
|
253
|
-
size: "sm",
|
|
254
|
-
onClick: () => picker === "month" ? setViewIndex((i) => i - 12) : setYearBase((b) => b - 12),
|
|
255
|
-
children: /* @__PURE__ */ jsx(ChevronLeft, { size: 18, strokeWidth: 1.75 })
|
|
256
|
-
}
|
|
257
|
-
),
|
|
258
|
-
picker === "month" ? /* @__PURE__ */ jsx(
|
|
259
|
-
"button",
|
|
260
|
-
{
|
|
261
|
-
type: "button",
|
|
262
|
-
className: "sereno-dtp-title",
|
|
263
|
-
onClick: () => {
|
|
264
|
-
setYearBase(viewYear - 5);
|
|
265
|
-
setPicker("year");
|
|
266
|
-
},
|
|
267
|
-
style: sx({
|
|
268
|
-
margin: "0 auto",
|
|
269
|
-
padding: "4px 8px",
|
|
270
|
-
border: "none",
|
|
271
|
-
borderRadius: "var(--radius-sm)",
|
|
272
|
-
background: "transparent",
|
|
273
|
-
cursor: "pointer",
|
|
274
|
-
fontFamily: "var(--font-display)",
|
|
275
|
-
fontSize: "var(--text-sm)",
|
|
276
|
-
fontWeight: "var(--weight-bold)",
|
|
277
|
-
color: "var(--text-primary)"
|
|
278
|
-
}),
|
|
279
|
-
children: viewYear
|
|
280
|
-
}
|
|
281
|
-
) : /* @__PURE__ */ jsxs(
|
|
282
|
-
"span",
|
|
283
|
-
{
|
|
284
|
-
style: sx({
|
|
285
|
-
textAlign: "center",
|
|
286
|
-
fontFamily: "var(--font-body)",
|
|
287
|
-
fontSize: "var(--text-sm)",
|
|
288
|
-
fontWeight: "var(--weight-semibold)",
|
|
289
|
-
color: "var(--text-secondary)"
|
|
290
|
-
}),
|
|
291
|
-
children: [
|
|
292
|
-
years[0],
|
|
293
|
-
"\u2013",
|
|
294
|
-
years[11]
|
|
295
|
-
]
|
|
296
|
-
}
|
|
297
|
-
),
|
|
298
|
-
/* @__PURE__ */ jsx(
|
|
299
|
-
IconButton,
|
|
300
|
-
{
|
|
301
|
-
label: picker === "month" ? "Pr\xF3ximo ano" : "Pr\xF3ximos anos",
|
|
302
|
-
size: "sm",
|
|
303
|
-
onClick: () => picker === "month" ? setViewIndex((i) => i + 12) : setYearBase((b) => b + 12),
|
|
304
|
-
children: /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75 })
|
|
305
|
-
}
|
|
306
|
-
)
|
|
307
|
-
]
|
|
308
|
-
}
|
|
309
|
-
),
|
|
310
|
-
/* @__PURE__ */ jsx("div", { className: "sereno-dtp-grid", style: sx({ display: "grid", gridTemplateColumns: "repeat(3, 1fr)", gap: "var(--space-1)" }), children: picker === "month" ? MONTHS_SHORT.map((mo, i) => /* @__PURE__ */ jsx(
|
|
311
|
-
"button",
|
|
312
|
-
{
|
|
313
|
-
type: "button",
|
|
314
|
-
"data-current": i === viewMonth || void 0,
|
|
315
|
-
"aria-current": i === viewMonth ? "true" : void 0,
|
|
316
|
-
onClick: () => {
|
|
317
|
-
setViewIndex(viewYear * 12 + i);
|
|
318
|
-
closePopover();
|
|
319
|
-
},
|
|
320
|
-
children: mo
|
|
321
|
-
},
|
|
322
|
-
mo
|
|
323
|
-
)) : years.map((y) => /* @__PURE__ */ jsx(
|
|
324
|
-
"button",
|
|
325
|
-
{
|
|
326
|
-
type: "button",
|
|
327
|
-
"data-current": y === viewYear || void 0,
|
|
328
|
-
"aria-current": y === viewYear ? "true" : void 0,
|
|
329
|
-
onClick: () => {
|
|
330
|
-
setViewIndex(y * 12 + viewMonth);
|
|
331
|
-
setPicker("month");
|
|
332
|
-
},
|
|
333
|
-
children: y
|
|
334
|
-
},
|
|
335
|
-
y
|
|
336
|
-
)) })
|
|
337
|
-
]
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
]
|
|
341
|
-
}
|
|
342
|
-
),
|
|
343
|
-
/* @__PURE__ */ jsx("div", { style: sx({ display: "grid", gridTemplateColumns: "repeat(7,1fr)", gap: "var(--space-1)", marginBottom: "var(--space-1)" }), children: DOW.map((d, i) => /* @__PURE__ */ jsx(
|
|
344
|
-
"span",
|
|
345
|
-
{
|
|
346
|
-
style: sx({
|
|
347
|
-
textAlign: "center",
|
|
348
|
-
fontFamily: "var(--font-body)",
|
|
349
|
-
fontSize: "var(--text-2xs)",
|
|
350
|
-
fontWeight: "var(--weight-semibold)",
|
|
351
|
-
color: "var(--text-muted)",
|
|
352
|
-
letterSpacing: "var(--tracking-caps)"
|
|
353
|
-
}),
|
|
354
|
-
children: d
|
|
355
|
-
},
|
|
356
|
-
i
|
|
357
|
-
)) }),
|
|
358
54
|
/* @__PURE__ */ jsx(
|
|
359
|
-
|
|
55
|
+
CalendarGrid,
|
|
360
56
|
{
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
return /* @__PURE__ */ jsxs(
|
|
371
|
-
"button",
|
|
372
|
-
{
|
|
373
|
-
type: "button",
|
|
374
|
-
"data-day": d,
|
|
375
|
-
"aria-disabled": off || void 0,
|
|
376
|
-
tabIndex: d === rovingDay ? 0 : -1,
|
|
377
|
-
"aria-pressed": sel,
|
|
378
|
-
onClick: () => {
|
|
379
|
-
if (off) return;
|
|
380
|
-
setSelectionIndex(viewIndex);
|
|
381
|
-
setActiveDay(d);
|
|
382
|
-
onSelectDate?.(d);
|
|
383
|
-
},
|
|
384
|
-
style: sx({
|
|
385
|
-
height: cellH,
|
|
386
|
-
display: "flex",
|
|
387
|
-
flexDirection: "column",
|
|
388
|
-
alignItems: "center",
|
|
389
|
-
justifyContent: "center",
|
|
390
|
-
gap: 1,
|
|
391
|
-
borderRadius: "var(--radius-sm)",
|
|
392
|
-
border: "none",
|
|
393
|
-
padding: 0,
|
|
394
|
-
cursor: off ? "not-allowed" : "pointer",
|
|
395
|
-
background: sel ? "var(--interactive-primary)" : "transparent",
|
|
396
|
-
color: sel ? "var(--interactive-primary-fg)" : off ? "var(--text-disabled)" : "var(--text-primary)",
|
|
397
|
-
fontFamily: "var(--font-body)",
|
|
398
|
-
fontSize: "var(--text-sm)",
|
|
399
|
-
fontWeight: sel ? "var(--weight-bold)" : "var(--weight-medium)",
|
|
400
|
-
textDecoration: off ? "line-through" : "none",
|
|
401
|
-
transition: "var(--transition-control)"
|
|
402
|
-
// Not inline outline:none — that would always beat the
|
|
403
|
-
// .sereno-dtp-days:focus-visible rule below no matter what
|
|
404
|
-
// it says (inline style always outranks a class selector).
|
|
405
|
-
// Suppressed as a class rule instead, same specificity as
|
|
406
|
-
// the :focus-visible override that re-enables it.
|
|
407
|
-
}),
|
|
408
|
-
children: [
|
|
409
|
-
/* @__PURE__ */ jsx("span", { children: d }),
|
|
410
|
-
renderDay ? /* @__PURE__ */ jsx("span", { style: sx({ display: "flex", minHeight: 12, lineHeight: 1 }), children: extra }) : null
|
|
411
|
-
]
|
|
412
|
-
},
|
|
413
|
-
i
|
|
414
|
-
);
|
|
415
|
-
})
|
|
416
|
-
},
|
|
417
|
-
viewIndex
|
|
57
|
+
year,
|
|
58
|
+
month,
|
|
59
|
+
selectedDate,
|
|
60
|
+
unavailable,
|
|
61
|
+
onSelectDate,
|
|
62
|
+
onMonthChange,
|
|
63
|
+
renderDay,
|
|
64
|
+
locale
|
|
65
|
+
}
|
|
418
66
|
),
|
|
419
67
|
times.length > 0 && /* @__PURE__ */ jsxs("div", { style: sx({ marginTop: "var(--space-4)", paddingTop: "var(--space-4)", borderTop: "var(--border-width-hairline) solid var(--border-subtle)" }), children: [
|
|
420
68
|
/* @__PURE__ */ jsx(
|
|
@@ -429,34 +77,62 @@ function DateTimePicker({
|
|
|
429
77
|
textTransform: "uppercase",
|
|
430
78
|
marginBottom: "var(--space-3)"
|
|
431
79
|
}),
|
|
432
|
-
children:
|
|
80
|
+
children: label
|
|
433
81
|
}
|
|
434
82
|
),
|
|
435
|
-
/* @__PURE__ */ jsx("div", { style: sx({ display: "grid", gridTemplateColumns: "repeat(auto-fill,minmax(76px,1fr))", gap: "var(--space-2)" }), children: times.map((
|
|
436
|
-
const val = typeof
|
|
437
|
-
const dis = typeof
|
|
83
|
+
/* @__PURE__ */ jsx("div", { style: sx({ display: "grid", gridTemplateColumns: "repeat(auto-fill,minmax(76px,1fr))", gap: "var(--space-2)" }), children: times.map((slot) => {
|
|
84
|
+
const val = typeof slot === "string" ? slot : slot.value;
|
|
85
|
+
const dis = typeof slot === "object" && slot.disabled;
|
|
86
|
+
const capacity = typeof slot === "object" ? slot.capacity : void 0;
|
|
87
|
+
const booked = typeof slot === "object" ? slot.booked ?? 0 : 0;
|
|
88
|
+
const hasOwnCapacity = capacity !== void 0;
|
|
89
|
+
const full = hasOwnCapacity && booked >= capacity;
|
|
438
90
|
const sel = selectedTime === val;
|
|
439
|
-
|
|
91
|
+
const showSecondLine = hasOwnCapacity || anyCapacity;
|
|
92
|
+
const secondLine = hasOwnCapacity ? full ? copy.full : copy.vagas(booked, capacity) : copy.available;
|
|
93
|
+
return /* @__PURE__ */ jsxs(
|
|
440
94
|
"button",
|
|
441
95
|
{
|
|
442
96
|
type: "button",
|
|
443
97
|
disabled: dis,
|
|
98
|
+
"aria-label": hasOwnCapacity ? `${val} \u2014 ${full ? copy.fullInline + ", " : ""}${copy.vagas(booked, capacity)}` : void 0,
|
|
444
99
|
onClick: () => onSelectTime && onSelectTime(val),
|
|
445
100
|
className: "sereno-dtp-time",
|
|
446
101
|
style: sx({
|
|
447
|
-
height: "var(--control-height-md)",
|
|
102
|
+
height: showSecondLine ? "auto" : "var(--control-height-md)",
|
|
103
|
+
display: "flex",
|
|
104
|
+
flexDirection: "column",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
justifyContent: "center",
|
|
107
|
+
gap: 2,
|
|
108
|
+
padding: showSecondLine ? "var(--space-2) 0" : 0,
|
|
448
109
|
borderRadius: "var(--radius-control)",
|
|
449
110
|
cursor: dis ? "not-allowed" : "pointer",
|
|
450
|
-
border: "var(--border-width-hairline) solid " + (sel ? "transparent" : "var(--border-default)"),
|
|
451
|
-
background: sel ? "var(--interactive-accent)" : dis ? "var(--interactive-disabled-bg)" : "var(--bg-surface)",
|
|
452
|
-
color: sel ? "var(--interactive-accent-fg)" : dis ? "var(--interactive-disabled-fg)" : "var(--text-primary)",
|
|
111
|
+
border: "var(--border-width-hairline) solid " + (sel ? "transparent" : full && !dis ? "var(--interactive-warning)" : "var(--border-default)"),
|
|
112
|
+
background: sel ? "var(--interactive-accent)" : dis ? "var(--interactive-disabled-bg)" : full ? "var(--status-warning-bg)" : "var(--bg-surface)",
|
|
113
|
+
color: sel ? "var(--interactive-accent-fg)" : dis ? "var(--interactive-disabled-fg)" : full ? "var(--status-warning-fg)" : "var(--text-primary)",
|
|
453
114
|
fontFamily: "var(--font-body)",
|
|
454
115
|
fontSize: "var(--text-sm)",
|
|
455
116
|
fontWeight: "var(--weight-semibold)",
|
|
456
117
|
transition: "var(--transition-control)"
|
|
457
118
|
// Not inline outline:none — see .sereno-dtp-time in styles.css.
|
|
458
119
|
}),
|
|
459
|
-
children:
|
|
120
|
+
children: [
|
|
121
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": hasOwnCapacity, children: val }),
|
|
122
|
+
showSecondLine && /* @__PURE__ */ jsx(
|
|
123
|
+
"span",
|
|
124
|
+
{
|
|
125
|
+
"aria-hidden": hasOwnCapacity,
|
|
126
|
+
style: sx({
|
|
127
|
+
fontSize: "var(--text-2xs)",
|
|
128
|
+
fontWeight: "var(--weight-medium)",
|
|
129
|
+
color: sel ? "inherit" : full ? "var(--status-warning-fg)" : "var(--text-muted)",
|
|
130
|
+
opacity: sel ? 0.85 : 1
|
|
131
|
+
}),
|
|
132
|
+
children: secondLine
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
]
|
|
460
136
|
},
|
|
461
137
|
val
|
|
462
138
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/forms/DateTimePicker.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\nexport interface TimeSlot {\n value: string;\n disabled?: boolean;\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.\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 */\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 /** Slot labels (\"09:00\") or objects with `disabled`. */\n times?: (string | TimeSlot)[];\n selectedTime?: string;\n /** Day numbers with no availability — struck through and unclickable. */\n unavailable?: number[];\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 timeLabel?: string;\n}\n\nconst DOW = ['D', 'S', 'T', 'Q', 'Q', 'S', 'S'];\nconst MONTHS = ['janeiro', 'fevereiro', 'março', 'abril', 'maio', 'junho', 'julho', 'agosto', 'setembro', 'outubro', 'novembro', 'dezembro'];\nconst MONTHS_SHORT = ['jan', 'fev', 'mar', 'abr', 'mai', 'jun', 'jul', 'ago', 'set', 'out', 'nov', 'dez'];\n\nfunction daysIn(y: number, m: number): number {\n return new Date(y, m + 1, 0).getDate();\n}\n\nexport function DateTimePicker({\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel = 'Horários disponíveis',\n style,\n ...rest\n}: DateTimePickerProps) {\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 owns it after mount\n // (re-mount with a `key` to force a different start).\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 const cellH = renderDay ? 48 : 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\n {...rest}\n ref={rootRef}\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 <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=\"Mês anterior\" 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 {MONTHS[viewMonth]} {viewYear}\n <ChevronDown size={15} strokeWidth={2} style={{ opacity: 0.6 }} />\n </button>\n\n <IconButton label=\"Próximo mês\" 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=\"Escolher mês e ano\"\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' ? 'Ano anterior' : 'Anos anteriores'}\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' ? 'Próximo ano' : 'Próximos anos'}\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 ? MONTHS_SHORT.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 {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={{ height: cellH }} />;\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 height: cellH,\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 {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 {timeLabel}\n </div>\n <div style={sx({ display: 'grid', gridTemplateColumns: 'repeat(auto-fill,minmax(76px,1fr))', gap: 'var(--space-2)' })}>\n {times.map((t) => {\n const val = typeof t === 'string' ? t : t.value;\n const dis = typeof t === 'object' && t.disabled;\n const sel = selectedTime === val;\n return (\n <button\n key={val}\n type=\"button\"\n disabled={dis}\n onClick={() => onSelectTime && onSelectTime(val)}\n className=\"sereno-dtp-time\"\n style={sx({\n height: 'var(--control-height-md)',\n borderRadius: 'var(--radius-control)',\n cursor: dis ? 'not-allowed' : 'pointer',\n border: 'var(--border-width-hairline) solid ' + (sel ? 'transparent' : 'var(--border-default)'),\n background: sel ? 'var(--interactive-accent)' : dis ? 'var(--interactive-disabled-bg)' : 'var(--bg-surface)',\n color: sel ? 'var(--interactive-accent-fg)' : dis ? 'var(--interactive-disabled-fg)' : '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 {val}\n </button>\n );\n })}\n </div>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAmQU,cAGF,YAHE;AAjQV,YAAY,WAAW;AACvB,SAAS,aAAa,aAAa,oBAAoB;AACvD,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAkD3B,MAAM,MAAM,CAAC,KAAK,KAAK,KAAK,KAAK,KAAK,KAAK,GAAG;AAC9C,MAAM,SAAS,CAAC,WAAW,aAAa,YAAS,SAAS,QAAQ,SAAS,SAAS,UAAU,YAAY,WAAW,YAAY,UAAU;AAC3I,MAAM,eAAe,CAAC,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,OAAO,KAAK;AAExG,SAAS,OAAO,GAAW,GAAmB;AAC5C,SAAO,IAAI,KAAK,GAAG,IAAI,GAAG,CAAC,EAAE,QAAQ;AACvC;AAEO,SAAS,eAAe;AAAA,EAC7B;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ,CAAC;AA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cAChB,CAAC;AAAA,cAEA;AAAA;AAAA,UACH;AAAA,UACA,oBAAC,SAAI,OAAO,GAAG,EAAE,SAAS,QAAQ,qBAAqB,sCAAsC,KAAK,iBAAiB,CAAC,GACjH,gBAAM,IAAI,CAAC,MAAM;AAChB,kBAAM,MAAM,OAAO,MAAM,WAAW,IAAI,EAAE;AAC1C,kBAAM,MAAM,OAAO,MAAM,YAAY,EAAE;AACvC,kBAAM,MAAM,iBAAiB;AAC7B,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,MAAK;AAAA,gBACL,UAAU;AAAA,gBACV,SAAS,MAAM,gBAAgB,aAAa,GAAG;AAAA,gBAC/C,WAAU;AAAA,gBACV,OAAO,GAAG;AAAA,kBACR,QAAQ;AAAA,kBACR,cAAc;AAAA,kBACd,QAAQ,MAAM,gBAAgB;AAAA,kBAC9B,QAAQ,yCAAyC,MAAM,gBAAgB;AAAA,kBACvE,YAAY,MAAM,8BAA8B,MAAM,mCAAmC;AAAA,kBACzF,OAAO,MAAM,iCAAiC,MAAM,mCAAmC;AAAA,kBACvF,YAAY;AAAA,kBACZ,UAAU;AAAA,kBACV,YAAY;AAAA,kBACZ,YAAY;AAAA;AAAA,gBAEd,CAAC;AAAA,gBAEA;AAAA;AAAA,cAnBI;AAAA,YAoBP;AAAA,UAEJ,CAAC,GACH;AAAA,WACF;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
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 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\nexport function DateTimePicker({\n year,\n month,\n selectedDate,\n times = [],\n selectedTime,\n unavailable = [],\n onSelectDate,\n onSelectTime,\n onMonthChange,\n renderDay,\n timeLabel,\n locale = 'pt-BR',\n style,\n ...rest\n}: DateTimePickerProps) {\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 {...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 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"],"mappings":";AAkIM,cA2CU,YA3CV;AA/HN,SAAS,UAAU;AACnB,SAAS,oBAAoB;AAE7B,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;AA0EO,SAAS,eAAe;AAAA,EAC7B;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,SAAS;AAAA,EACT;AAAA,EACA,GAAG;AACL,GAAwB;AACtB,QAAM,OAAO,KAAK,MAAM;AACxB,QAAM,QAAQ,aAAa,KAAK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