@sereno-ds/ui 0.26.0 → 0.27.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.
Files changed (43) hide show
  1. package/dist/_internal/CharCount.js +1 -1
  2. package/dist/_internal/Field.js +1 -1
  3. package/dist/core/Avatar.js +1 -1
  4. package/dist/core/Badge.js +1 -1
  5. package/dist/core/Brand.js +1 -1
  6. package/dist/core/Button.js +1 -1
  7. package/dist/core/Card.js +2 -2
  8. package/dist/core/IconButton.js +2 -2
  9. package/dist/core/Menu.js +1 -1
  10. package/dist/core/Table.js +1 -1
  11. package/dist/feedback/Alert.js +1 -1
  12. package/dist/feedback/Dialog.js +1 -1
  13. package/dist/feedback/EmptyState.js +1 -1
  14. package/dist/feedback/Skeleton.js +1 -1
  15. package/dist/feedback/Toast.js +1 -1
  16. package/dist/feedback/ToastProvider.js +2 -2
  17. package/dist/forms/AvatarUpload.js +3 -3
  18. package/dist/forms/Checkbox.js +1 -1
  19. package/dist/forms/DatePicker.d.ts +14 -3
  20. package/dist/forms/DatePicker.js +96 -41
  21. package/dist/forms/DatePicker.js.map +1 -1
  22. package/dist/forms/DateTimePicker.d.ts +23 -3
  23. package/dist/forms/DateTimePicker.js +63 -14
  24. package/dist/forms/DateTimePicker.js.map +1 -1
  25. package/dist/forms/FileUpload.js +2 -2
  26. package/dist/forms/Input.js +4 -4
  27. package/dist/forms/Radio.js +1 -1
  28. package/dist/forms/SearchInput.js +2 -2
  29. package/dist/forms/Select.js +3 -3
  30. package/dist/forms/Switch.js +1 -1
  31. package/dist/forms/Textarea.js +3 -3
  32. package/dist/forms/_internal/CalendarGrid.d.ts +7 -1
  33. package/dist/forms/_internal/CalendarGrid.js +39 -14
  34. package/dist/forms/_internal/CalendarGrid.js.map +1 -1
  35. package/dist/forms/_internal/fieldBoxStyle.js +1 -1
  36. package/dist/index.js +32 -32
  37. package/dist/navigation/BottomNav.js +1 -1
  38. package/dist/navigation/SidebarNav.js +2 -2
  39. package/dist/navigation/Stepper.js +1 -1
  40. package/dist/navigation/Tabs.js +1 -1
  41. package/dist/navigation/TopBar.js +1 -1
  42. package/dist/theme/ThemeToggle.js +1 -1
  43. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { sx } from "./style";
3
+ import { sx } from "./style.js";
4
4
  function CharCount({ count, max }) {
5
5
  const atLimit = max != null && count >= max;
6
6
  return /* @__PURE__ */ jsx(
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { sx } from "./style";
3
+ import { sx } from "./style.js";
4
4
  function Field({ label, hint, error, required, htmlFor, counter, children, style }) {
5
5
  return /* @__PURE__ */ jsxs("div", { style: sx({ display: "flex", flexDirection: "column", gap: "var(--space-2)", ...style }), children: [
6
6
  label && /* @__PURE__ */ jsxs(
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
3
+ import { sx } from "../_internal/style.js";
4
4
  const S = { xs: 24, sm: 32, md: 40, lg: 56, xl: 80 };
5
5
  function initials(name) {
6
6
  return (name || "").trim().split(/\s+/).slice(0, 2).map((w) => w[0] || "").join("").toUpperCase();
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
3
+ import { sx } from "../_internal/style.js";
4
4
  const TONES = {
5
5
  success: ["--status-success-bg", "--status-success-fg", "--status-success-dot"],
6
6
  warning: ["--status-warning-bg", "--status-warning-fg", "--status-warning-dot"],
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { sx } from "../_internal/style";
4
+ import { sx } from "../_internal/style.js";
5
5
  const DROP = "M24 3 C 22 7.5 8 22 8 31.5 C 8 39 15 45 24 45 C 33 45 40 39 40 31.5 C 40 22 26 7.5 24 3 Z";
6
6
  function Mark({ size, mono, decorative }) {
7
7
  const gid = React.useId();
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { sx } from "../_internal/style";
4
+ import { sx } from "../_internal/style.js";
5
5
  function useInteract(disabled) {
6
6
  const [hover, setHover] = React.useState(false);
7
7
  const [press, setPress] = React.useState(false);
package/dist/core/Card.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
4
- import { useInteract } from "./Button";
3
+ import { sx } from "../_internal/style.js";
4
+ import { useInteract } from "./Button.js";
5
5
  const PADS = { none: 0, sm: "var(--space-3)", md: "var(--space-4)", lg: "var(--space-5)" };
6
6
  const DROP = { none: "", sm: "var(--shadow-xs)", md: "var(--shadow-md)", lg: "var(--shadow-lg)" };
7
7
  function Card({ padding = "md", elevation = "sm", interactive = false, selected = false, children, style, onClick, onKeyDown, ...rest }) {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
4
- import { useInteract } from "./Button";
3
+ import { sx } from "../_internal/style.js";
4
+ import { useInteract } from "./Button.js";
5
5
  const S = { sm: 32, md: 40, lg: 48 };
6
6
  const SOLID = {
7
7
  primary: ["--interactive-primary", "--interactive-primary-hover", "--interactive-primary-fg"],
package/dist/core/Menu.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
- import { sx } from "../_internal/style";
5
+ import { sx } from "../_internal/style.js";
6
6
  const isItem = (e) => !("separator" in e) && !("heading" in e);
7
7
  const GAP = 6;
8
8
  const GUTTER = 12;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { ChevronDown, ChevronsUpDown, ChevronUp } from "lucide-react";
4
- import { sx } from "../_internal/style";
4
+ import { sx } from "../_internal/style.js";
5
5
  function TableRoot({
6
6
  caption,
7
7
  density = "comfortable",
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { X } from "lucide-react";
4
- import { sx } from "../_internal/style";
4
+ import { sx } from "../_internal/style.js";
5
5
  const TONES = {
6
6
  info: ["--status-info-bg", "--status-info-fg"],
7
7
  success: ["--status-success-bg", "--status-success-fg"],
@@ -3,7 +3,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { X } from "lucide-react";
6
- import { sx } from "../_internal/style";
6
+ import { sx } from "../_internal/style.js";
7
7
  const SIZE_W = { sm: 440, md: 600, lg: 800, xl: 1e3 };
8
8
  const FOCUSABLE_SELECTOR = 'a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';
9
9
  function focusableIn(el) {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
3
+ import { sx } from "../_internal/style.js";
4
4
  function EmptyState({ icon, title, description, action, compact = false, style, ...rest }) {
5
5
  return /* @__PURE__ */ jsxs(
6
6
  "div",
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- import { sx } from "../_internal/style";
3
+ import { sx } from "../_internal/style.js";
4
4
  const BASE = { background: "var(--bg-subtle)", animation: "sereno-pulse 1.6s var(--ease-gentle) infinite" };
5
5
  function Bar({ w, h, r }) {
6
6
  return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", style: sx({ ...BASE, display: "block", width: w, height: h, borderRadius: r, flex: "0 0 auto" }) });
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { X } from "lucide-react";
4
- import { sx } from "../_internal/style";
4
+ import { sx } from "../_internal/style.js";
5
5
  const TONES = {
6
6
  success: ["--status-success-bg", "--status-success-fg"],
7
7
  warning: ["--status-warning-bg", "--status-warning-fg"],
@@ -2,8 +2,8 @@
2
2
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
- import { Toast } from "./Toast";
6
- import { sx } from "../_internal/style";
5
+ import { Toast } from "./Toast.js";
6
+ import { sx } from "../_internal/style.js";
7
7
  const ToastContext = React.createContext(null);
8
8
  const EXIT_MS = 180;
9
9
  let seq = 0;
@@ -3,9 +3,9 @@ import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
4
  import { createPortal } from "react-dom";
5
5
  import { Camera, Check, ImagePlus, Pencil, Trash2, X, ZoomIn, ZoomOut } from "lucide-react";
6
- import { sx } from "../_internal/style";
7
- import { Field } from "../_internal/Field";
8
- import { Dialog } from "../feedback/Dialog";
6
+ import { sx } from "../_internal/style.js";
7
+ import { Field } from "../_internal/Field.js";
8
+ import { Dialog } from "../feedback/Dialog.js";
9
9
  const EN = {
10
10
  trigger: "Change photo",
11
11
  upload: "Upload a photo",
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { sx } from "../_internal/style";
4
+ import { sx } from "../_internal/style.js";
5
5
  function Checkbox({ label, description, checked, defaultChecked, disabled, indeterminate, size = "md", onChange, style, ...rest }) {
6
6
  const [hover, setHover] = React.useState(false);
7
7
  const box = size === "sm" ? 16 : 20;
@@ -5,6 +5,7 @@ interface DatePickerProps {
5
5
  hint?: string;
6
6
  error?: string;
7
7
  required?: boolean;
8
+ /** Defaults to the `locale`-appropriate text ("Selecionar data" / "Pick a date"). */
8
9
  placeholder?: string;
9
10
  size?: 'sm' | 'md' | 'lg';
10
11
  disabled?: boolean;
@@ -19,6 +20,14 @@ interface DatePickerProps {
19
20
  max?: string;
20
21
  id?: string;
21
22
  containerStyle?: React.CSSProperties;
23
+ /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */
24
+ clearLabel?: string;
25
+ /**
26
+ * The real Sereno product always renders pt-BR — this only exists so the
27
+ * docs showcase can demo an English-speaking consumer without forking the
28
+ * component. Default stays `'pt-BR'`.
29
+ */
30
+ locale?: 'pt-BR' | 'en';
22
31
  }
23
32
  /**
24
33
  * Field for picking a single date — no time, no slots (`DateTimePicker`'s
@@ -29,9 +38,11 @@ interface DatePickerProps {
29
38
  *
30
39
  * Value contract matches the rest of the forms package: `value` /
31
40
  * `defaultValue` + `onChange(value)`, a plain ISO "YYYY-MM-DD" string —
32
- * drops in wherever `<input type="date">` would go, but themed and in
33
- * pt-BR instead of the browser's own (English, unstyled) date picker.
41
+ * drops in wherever `<input type="date">` would go, but themed instead of
42
+ * the browser's own, and in pt-BR by default (the real Sereno product
43
+ * always uses it; `locale="en"` exists only for docs/demo purposes). A
44
+ * clear (×) button appears once a value is set.
34
45
  */
35
- declare function DatePicker({ label, hint, error, required, placeholder, size, disabled, value, defaultValue, onChange, min, max, id, containerStyle, }: DatePickerProps): React.JSX.Element;
46
+ declare function DatePicker({ label, hint, error, required, placeholder, size, disabled, value, defaultValue, onChange, min, max, id, containerStyle, clearLabel, locale, }: DatePickerProps): React.JSX.Element;
36
47
 
37
48
  export { DatePicker, type DatePickerProps };
@@ -1,11 +1,15 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import * as React from "react";
4
- import { Calendar as CalendarIcon } from "lucide-react";
5
- import { sx } from "../_internal/style";
6
- import { Field } from "../_internal/Field";
7
- import { CalendarGrid } from "./_internal/CalendarGrid";
8
- import { fieldBoxStyle } from "./_internal/fieldBoxStyle";
4
+ import { Calendar as CalendarIcon, X } from "lucide-react";
5
+ import { sx } from "../_internal/style.js";
6
+ import { Field } from "../_internal/Field.js";
7
+ import { CalendarGrid } from "./_internal/CalendarGrid.js";
8
+ import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
9
+ const TEXT = {
10
+ "pt-BR": { placeholder: "Selecionar data", dialogLabel: "Escolher data", clearLabel: "Limpar data" },
11
+ en: { placeholder: "Pick a date", dialogLabel: "Choose a date", clearLabel: "Clear date" }
12
+ };
9
13
  function parseISO(iso) {
10
14
  if (!iso) return null;
11
15
  const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(iso);
@@ -15,10 +19,12 @@ function parseISO(iso) {
15
19
  function toISO(year, month, day) {
16
20
  return `${String(year).padStart(4, "0")}-${String(month + 1).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
17
21
  }
18
- function formatDisplay(iso) {
22
+ function formatDisplay(iso, locale) {
19
23
  const d = parseISO(iso);
20
24
  if (!d) return iso;
21
- return new Intl.DateTimeFormat("pt-BR", { day: "2-digit", month: "2-digit", year: "numeric" }).format(new Date(d.year, d.month, d.day));
25
+ return new Intl.DateTimeFormat(locale === "en" ? "en-US" : "pt-BR", { day: "2-digit", month: "2-digit", year: "numeric" }).format(
26
+ new Date(d.year, d.month, d.day)
27
+ );
22
28
  }
23
29
  function daysIn(year, month) {
24
30
  return new Date(year, month + 1, 0).getDate();
@@ -45,7 +51,7 @@ function DatePicker({
45
51
  hint,
46
52
  error,
47
53
  required,
48
- placeholder = "Selecionar data",
54
+ placeholder,
49
55
  size = "md",
50
56
  disabled = false,
51
57
  value,
@@ -54,8 +60,11 @@ function DatePicker({
54
60
  min,
55
61
  max,
56
62
  id,
57
- containerStyle
63
+ containerStyle,
64
+ clearLabel,
65
+ locale = "pt-BR"
58
66
  }) {
67
+ const copy = TEXT[locale];
59
68
  const [inner, setInner] = React.useState(defaultValue ?? "");
60
69
  const iso = value !== void 0 ? value : inner;
61
70
  const parsed = parseISO(iso);
@@ -100,43 +109,88 @@ function DatePicker({
100
109
  setOpen(false);
101
110
  triggerRef.current?.focus();
102
111
  };
112
+ const clear = () => {
113
+ if (value === void 0) setInner("");
114
+ onChange?.("");
115
+ triggerRef.current?.focus();
116
+ };
103
117
  const unavailable = React.useMemo(() => unavailableForMonth(viewYear, viewMonth, min, max), [viewYear, viewMonth, min, max]);
104
118
  return /* @__PURE__ */ jsx(Field, { label, hint, error, required, htmlFor: rid, style: containerStyle, children: /* @__PURE__ */ jsxs("div", { ref: rootRef, style: { position: "relative", width: "100%" }, children: [
105
- /* @__PURE__ */ jsxs(
106
- "button",
107
- {
108
- ref: triggerRef,
109
- id: rid,
110
- type: "button",
111
- disabled,
112
- "aria-haspopup": "dialog",
113
- "aria-expanded": open,
114
- onClick: () => open ? setOpen(false) : openPopover(),
115
- style: fieldBoxStyle(size, !!error, open, disabled),
116
- children: [
117
- /* @__PURE__ */ jsx(CalendarIcon, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto", opacity: 0.7 } }),
118
- /* @__PURE__ */ jsx(
119
- "span",
120
- {
121
- style: sx({
122
- flex: 1,
123
- textAlign: "left",
124
- overflow: "hidden",
125
- textOverflow: "ellipsis",
126
- whiteSpace: "nowrap",
127
- color: iso ? "inherit" : "var(--text-muted)"
128
- }),
129
- children: iso ? formatDisplay(iso) : placeholder
130
- }
131
- )
132
- ]
133
- }
134
- ),
119
+ /* @__PURE__ */ jsxs("div", { style: fieldBoxStyle(size, !!error, open, disabled), children: [
120
+ /* @__PURE__ */ jsxs(
121
+ "button",
122
+ {
123
+ ref: triggerRef,
124
+ id: rid,
125
+ type: "button",
126
+ disabled,
127
+ "aria-haspopup": "dialog",
128
+ "aria-expanded": open,
129
+ onClick: () => open ? setOpen(false) : openPopover(),
130
+ style: sx({
131
+ flex: 1,
132
+ minWidth: 0,
133
+ display: "flex",
134
+ alignItems: "center",
135
+ gap: "var(--space-2)",
136
+ border: "none",
137
+ background: "transparent",
138
+ padding: 0,
139
+ font: "inherit",
140
+ color: "inherit",
141
+ cursor: "inherit",
142
+ textAlign: "left"
143
+ }),
144
+ children: [
145
+ /* @__PURE__ */ jsx(CalendarIcon, { size: 16, strokeWidth: 1.75, style: { flex: "0 0 auto", opacity: 0.7 } }),
146
+ /* @__PURE__ */ jsx(
147
+ "span",
148
+ {
149
+ style: sx({
150
+ flex: 1,
151
+ textAlign: "left",
152
+ overflow: "hidden",
153
+ textOverflow: "ellipsis",
154
+ whiteSpace: "nowrap",
155
+ color: iso ? "inherit" : "var(--text-muted)"
156
+ }),
157
+ children: iso ? formatDisplay(iso, locale) : placeholder ?? copy.placeholder
158
+ }
159
+ )
160
+ ]
161
+ }
162
+ ),
163
+ iso && !disabled && /* @__PURE__ */ jsx(
164
+ "button",
165
+ {
166
+ type: "button",
167
+ "aria-label": clearLabel ?? copy.clearLabel,
168
+ onClick: (e) => {
169
+ e.stopPropagation();
170
+ clear();
171
+ },
172
+ style: sx({
173
+ flex: "0 0 auto",
174
+ display: "inline-flex",
175
+ alignItems: "center",
176
+ justifyContent: "center",
177
+ marginRight: -4,
178
+ padding: 4,
179
+ border: "none",
180
+ borderRadius: "var(--radius-sm)",
181
+ background: "transparent",
182
+ color: "var(--text-muted)",
183
+ cursor: "pointer"
184
+ }),
185
+ children: /* @__PURE__ */ jsx(X, { size: 14, strokeWidth: 2 })
186
+ }
187
+ )
188
+ ] }),
135
189
  open && /* @__PURE__ */ jsx(
136
190
  "div",
137
191
  {
138
192
  role: "dialog",
139
- "aria-label": label || "Escolher data",
193
+ "aria-label": label || copy.dialogLabel,
140
194
  tabIndex: -1,
141
195
  style: sx({
142
196
  position: "absolute",
@@ -169,7 +223,8 @@ function DatePicker({
169
223
  },
170
224
  onSelectDate: commit,
171
225
  squareCells: true,
172
- trimEmptyRows: true
226
+ trimEmptyRows: true,
227
+ locale
173
228
  }
174
229
  )
175
230
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Calendar as CalendarIcon } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Earliest selectable date, ISO \"YYYY-MM-DD\" — every day before it is unavailable. */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\" — every day after it is unavailable. */\n max?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n}\n\ninterface YMD {\n year: number;\n month: number;\n day: number;\n}\n\nfunction parseISO(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\nfunction toISO(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\nfunction formatDisplay(iso: string): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat('pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(new Date(d.year, d.month, d.day));\n}\n\nfunction daysIn(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\n/** Every day of (year, month) that falls before `min` or after `max`. */\nfunction unavailableForMonth(year: number, month: number, min?: string, max?: string): number[] {\n if (!min && !max) return [];\n const minD = parseISO(min);\n const maxD = parseISO(max);\n const out: number[] = [];\n const total = daysIn(year, month);\n for (let day = 1; day <= total; day++) {\n if (minD && year * 372 + month * 31 + day < minD.year * 372 + minD.month * 31 + minD.day) {\n out.push(day);\n continue;\n }\n if (maxD && year * 372 + month * 31 + day > maxD.year * 372 + maxD.month * 31 + maxD.day) {\n out.push(day);\n }\n }\n return out;\n}\n\n/**\n * Field for picking a single date — no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump — see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string —\n * drops in wherever `<input type=\"date\">` would go, but themed and in\n * pt-BR instead of the browser's own (English, unstyled) date picker.\n */\nexport function DatePicker({\n label,\n hint,\n error,\n required,\n placeholder = 'Selecionar data',\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n id,\n containerStyle,\n}: DatePickerProps) {\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover — resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n // A plain `position: absolute` child of `rootRef` (itself `position:\n // relative`) — the same \"inline\" strategy Select's panel uses for its\n // common case, and the same one DateTimePicker's own month/year popover\n // already uses. The browser glues it to the trigger through *any* scroll\n // (page or a nested overflow container) for free — no JS measuring\n // position, no listening for scroll/resize, and critically, it never has\n // to close on scroll the way a `position: fixed` popover computed once\n // would (that was tried first here and didn't hold up — see PR history).\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const unavailable = React.useMemo(() => unavailableForMonth(viewYear, viewMonth, min, max), [viewYear, viewMonth, min, max]);\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={fieldBoxStyle(size, !!error, open, disabled)}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso) : placeholder}\n </span>\n </button>\n\n {open && (\n <div\n role=\"dialog\"\n aria-label={label || 'Escolher data'}\n tabIndex={-1}\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: 0,\n right: 0,\n // The 7-column grid needs some floor width to stay readable —\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\n zIndex: 20,\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n unavailable={unavailable}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n }}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n />\n </div>\n )}\n </div>\n </Field>\n );\n}\n"],"mappings":";AA0KQ,SAUE,KAVF;AAxKR,YAAY,WAAW;AACvB,SAAS,YAAY,oBAAoB;AACzC,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AA6B9B,SAAS,SAAS,KAAqC;AACrD,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;AAEA,SAAS,MAAM,MAAc,OAAe,KAAqB;AAC/D,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;AAEA,SAAS,cAAc,KAAqB;AAC1C,QAAM,IAAI,SAAS,GAAG;AACtB,MAAI,CAAC,EAAG,QAAO;AACf,SAAO,IAAI,KAAK,eAAe,SAAS,EAAE,KAAK,WAAW,OAAO,WAAW,MAAM,UAAU,CAAC,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC;AACxI;AAEA,SAAS,O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AM;AACvB,0BAAY,CAAC;AACb,2BAAa,CAAC;AAAA,YAChB;AAAA,YACA,cAAc;AAAA,YACd,aAAW;AAAA,YACX,eAAa;AAAA;AAAA,QACf;AAAA;AAAA,IACF;AAAA,KAEJ,GACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /** Earliest selectable date, ISO \"YYYY-MM-DD\" — every day before it is unavailable. */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\" — every day after it is unavailable. */\n max?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR — this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n}\n\ninterface YMD {\n year: number;\n month: number;\n day: number;\n}\n\nfunction parseISO(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\nfunction toISO(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\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\nfunction daysIn(year: number, month: number): number {\n return new Date(year, month + 1, 0).getDate();\n}\n\n/** Every day of (year, month) that falls before `min` or after `max`. */\nfunction unavailableForMonth(year: number, month: number, min?: string, max?: string): number[] {\n if (!min && !max) return [];\n const minD = parseISO(min);\n const maxD = parseISO(max);\n const out: number[] = [];\n const total = daysIn(year, month);\n for (let day = 1; day <= total; day++) {\n if (minD && year * 372 + month * 31 + day < minD.year * 372 + minD.month * 31 + minD.day) {\n out.push(day);\n continue;\n }\n if (maxD && year * 372 + month * 31 + day > maxD.year * 372 + maxD.month * 31 + maxD.day) {\n out.push(day);\n }\n }\n return out;\n}\n\n/**\n * Field for picking a single date — no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump — see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string —\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport function DatePicker({\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n}: DatePickerProps) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover — resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n // A plain `position: absolute` child of `rootRef` (itself `position:\n // relative`) — the same \"inline\" strategy Select's panel uses for its\n // common case, and the same one DateTimePicker's own month/year popover\n // already uses. The browser glues it to the trigger through *any* scroll\n // (page or a nested overflow container) for free — no JS measuring\n // position, no listening for scroll/resize, and critically, it never has\n // to close on scroll the way a `position: fixed` popover computed once\n // would (that was tried first here and didn't hold up — see PR history).\n React.useEffect(() => {\n if (!open) return;\n const onDown = (e: PointerEvent) => {\n if (rootRef.current && !rootRef.current.contains(e.target as Node)) {\n setOpen(false);\n }\n };\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('pointerdown', onDown, true);\n document.addEventListener('keydown', onKey, true);\n return () => {\n document.removeEventListener('pointerdown', onDown, true);\n document.removeEventListener('keydown', onKey, true);\n };\n }, [open]);\n\n const openPopover = () => {\n if (disabled) return;\n setViewYear(parsed?.year ?? now.getFullYear());\n setViewMonth(parsed?.month ?? now.getMonth());\n setOpen(true);\n };\n\n const commit = (day: number) => {\n const next = toISO(viewYear, viewMonth, day);\n if (value === undefined) setInner(next);\n onChange?.(next);\n setOpen(false);\n triggerRef.current?.focus();\n };\n\n const clear = () => {\n if (value === undefined) setInner('');\n onChange?.('');\n triggerRef.current?.focus();\n };\n\n const unavailable = React.useMemo(() => unavailableForMonth(viewYear, viewMonth, min, max), [viewYear, viewMonth, min, max]);\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n — the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && (\n <div\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n style={sx({\n position: 'absolute',\n top: 'calc(100% + 6px)',\n left: 0,\n right: 0,\n // The 7-column grid needs some floor width to stay readable —\n // a narrow field (e.g. a compact \"Data\" next to \"Motivo\")\n // would otherwise squeeze it. `left`/`right: 0` already\n // matches the trigger's own width for anything wider.\n minWidth: 272,\n zIndex: 20,\n background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n unavailable={unavailable}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n }}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n )}\n </div>\n </Field>\n );\n}\n"],"mappings":";AAyMU,SAuBE,KAvBF;AAvMV,YAAY,WAAW;AACvB,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,oBAAoB;AAC7B,SAAS,qBAAqB;AAE9B,MAAM,OAAO;AAAA,EACX,SAAS,EAAE,aAAa,mBAAmB,aAAa,iBAAiB,YAAY,cAAc;AAAA,EACnG,IAAI,EAAE,aAAa,eAAe,aAAa,iBAAiB,YAAY,aAAa;AAC3F;AAsCA,SAAS,SAAS,KAAqC;AACrD,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;AAEA,SAAS,MAAM,MAAc,OAAe,KAAqB;AAC/D,SAAO,GAAG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AAA,YACC,MAAM;AAAA,YACN,OAAO;AAAA,YACP,cAAc,UAAU,OAAO,SAAS,YAAY,OAAO,UAAU,YAAY,OAAO,MAAM;AAAA,YAC9F;AAAA,YACA,eAAe,CAAC,GAAG,MAAM;AACvB,0BAAY,CAAC;AACb,2BAAa,CAAC;AAAA,YAChB;AAAA,YACA,cAAc;AAAA,YACd,aAAW;AAAA,YACX,eAAa;AAAA,YACb;AAAA;AAAA,QACF;AAAA;AAAA,IACF;AAAA,KAEJ,GACF;AAEJ;","names":[]}
@@ -2,11 +2,18 @@ import * as React from 'react';
2
2
 
3
3
  interface TimeSlot {
4
4
  value: string;
5
+ /** Hard-blocked — unclickable regardless of `capacity`/`booked`. */
5
6
  disabled?: boolean;
7
+ /** Total spots this slot holds — a group session, a class. Omit for a
8
+ * plain 1:1 slot with no capacity tracking (the original contract). */
9
+ capacity?: number;
10
+ /** How many are already booked into it. */
11
+ booked?: number;
6
12
  }
7
13
  /**
8
14
  * Month calendar plus available time slots — the heart of the public booking flow.
9
- * Day names and month names render in pt-BR.
15
+ * Day names and month names render in pt-BR by default — the real Sereno
16
+ * product always uses it; `locale="en"` exists only for docs/demo purposes.
10
17
  *
11
18
  * The header navigates: ‹ / › step the month, and the centred title opens a
12
19
  * popover to jump straight to a month or year. `year` / `month` set the *initial*
@@ -33,7 +40,13 @@ interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
33
40
  /** Selected day-of-month. The highlight only shows in the month it was picked
34
41
  * in — navigating away and back to a *different* month never re-highlights it. */
35
42
  selectedDate?: number;
36
- /** Slot labels ("09:00") or objects with `disabled`. */
43
+ /**
44
+ * Slot labels ("09:00") or `TimeSlot` objects. A slot with `capacity` set
45
+ * shows "booked/capacity" and switches to a full/overbook-warning look
46
+ * once reached (SS-64) — still pickable unless also `disabled`, since a
47
+ * full slot and a *blocked* one are different things: the first is a
48
+ * deliberate "yes, overbook it" the caller can still choose to allow.
49
+ */
37
50
  times?: (string | TimeSlot)[];
38
51
  selectedTime?: string;
39
52
  /** Day numbers with no availability — struck through and unclickable. */
@@ -48,8 +61,15 @@ interface DateTimePickerProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
48
61
  * grid even. It's the caller's job to scope this (e.g. future days only).
49
62
  */
50
63
  renderDay?: (day: number) => React.ReactNode;
64
+ /** Defaults to the `locale`-appropriate label ("Horários disponíveis" / "Available times"). */
51
65
  timeLabel?: string;
66
+ /**
67
+ * The real Sereno product always renders pt-BR — this only exists so the
68
+ * docs showcase can demo an English-speaking consumer without forking the
69
+ * component. Default stays `'pt-BR'`.
70
+ */
71
+ locale?: 'pt-BR' | 'en';
52
72
  }
53
- declare function DateTimePicker({ year, month, selectedDate, times, selectedTime, unavailable, onSelectDate, onSelectTime, onMonthChange, renderDay, timeLabel, style, ...rest }: DateTimePickerProps): React.JSX.Element;
73
+ declare function DateTimePicker({ year, month, selectedDate, times, selectedTime, unavailable, onSelectDate, onSelectTime, onMonthChange, renderDay, timeLabel, locale, style, ...rest }: DateTimePickerProps): React.JSX.Element;
54
74
 
55
75
  export { DateTimePicker, type DateTimePickerProps, type TimeSlot };