@sereno-ds/ui 0.43.0 → 0.45.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/README.md CHANGED
@@ -18,12 +18,12 @@ npm i @sereno-ds/ui @sereno-ds/tokens lucide-react
18
18
 
19
19
  ```ts
20
20
  import '@sereno-ds/tokens/tokens.css'; // the token layer (colors, spacing, dark overrides…)
21
- import '@sereno-ds/ui/styles.css'; // keyframes, structural rules, and the hover / press / focus of Button, IconButton and Card
21
+ import '@sereno-ds/ui/styles.css'; // keyframes, structural rules, and the hover / press / focus of the interactive components
22
22
  ```
23
23
 
24
24
  `tokens.css` **must** come first. Both are side-effect CSS: import them once (a root layout, `_app`, or `main.tsx`), not per-component.
25
25
 
26
- **`styles.css` is required**, not decorative: `Button`, `IconButton`, `Card`, `ActionCard`, the rows of `SidebarNav`, `Checkbox`, `Radio` and the actions of `AvatarUpload` take their hover / press / focus states (and, for the first four, their colours and border) from it. Their values are on the element, the rules that switch between them are in the stylesheet, so without it they render unstyled or with no hover.
26
+ **`styles.css` is required**, not decorative: `Button`, `IconButton`, `Card`, `ActionCard`, the rows and the collapse control of `SidebarNav`, `Checkbox`, `Radio`, the actions of `AvatarUpload` and the text fields (`Input`, `Textarea`, `Select`, `DatePicker`, `Autocomplete`) take their hover / press / focus states (and, for several of them, their colours and border) from it. Their values are on the element, the rules that switch between them are in the stylesheet, so without it they render unstyled, with no hover and no focus ring.
27
27
 
28
28
  #### Restyling a state with plain CSS
29
29
 
@@ -37,6 +37,9 @@ These components carry a class the stylesheet's state rules hang on:
37
37
  | `SidebarNav` items and sub items | `sereno-sidenav-row` | |
38
38
  | `Checkbox`, `Radio` | `sereno-choice` on the row (the `<label>`), `sereno-check` / `sereno-radio` on the box | |
39
39
  | the actions of `AvatarUpload` | `sereno-menuitem` | |
40
+ | the collapse control of `SidebarNav` | `sereno-sidenav-toggle` | |
41
+ | `Input` (its row), `Textarea`, the boxes of `Select`, `DatePicker` and `Autocomplete` | `sereno-field` | `data-active` while a popup is open |
42
+ | `Switch` | `sereno-switch` on the track, `sereno-switch-thumb` on the thumb | |
40
43
 
41
44
  The state rules have the specificity of `.sereno-btn:hover` (one class and one pseudo-class), so a rule of yours with the same specificity **that comes later** wins, with no `!important`:
42
45
 
@@ -53,6 +56,10 @@ Or change what the DS reads, on the element itself (the component reads `--inter
53
56
 
54
57
  The class names and the `data-` attributes are the styling hooks. The `--sd-*` custom properties are how the component hands its values to the stylesheet and are **not** a public API: restyle with the rules above, not by setting them.
55
58
 
59
+ #### High contrast (forced colors)
60
+
61
+ In Windows High Contrast (`forced-colors: active`) the browser replaces every colour with a system one and drops every `box-shadow`. `styles.css` has a block for that mode: the keyboard focus of `Button`, `IconButton`, `Card`, `ActionCard`, `Switch` and the text fields is drawn as a `Highlight` outline, and the `Switch` is drawn with a border and system fills (it has no other way to show up). Nothing there applies outside forced colors, and an `outline` rule of your own on those classes still wins by coming later. If you restyle a focus ring as a shadow, do the same for forced colors.
62
+
56
63
  ### 2. Provide the fonts
57
64
 
58
65
  Components reference three font CSS variables. Define them however you host fonts; the tokens already carry a system fallback, so text renders without them, just off-brand.
@@ -54,8 +54,6 @@ function ActionCard({
54
54
  borderRadius: "var(--radius-card)",
55
55
  cursor: disabled ? "not-allowed" : "pointer",
56
56
  transition: "var(--transition-control)",
57
- // The focus ring is the box-shadow of `.sereno-action:focus-visible`, the same substitute `Button` and `Card` use.
58
- outline: "none",
59
57
  ...style
60
58
  }),
61
59
  children: [
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/ActionCard.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Typography } from './Typography';\n\nexport type ActionCardVariant = 'default' | 'primary' | 'error';\n\n/**\n * A whole card you press: an icon, a title, a line of explanation and an arrow, in a real\n * `<button>`. For the options of a decision (\"Reschedule\", \"Cancel the booking\") and for the\n * entries of a settings flow. A `Card` with `interactive` is the bare surface; this is the\n * finished control, with the keyboard, the focus ring and the disabled state taken care of.\n *\n * It is an action, not a radio: arrow keys do not move between cards. `selected` marks a card as\n * a toggle (`aria-pressed`); for \"choose exactly one of these\" the semantics are a radio group's,\n * which this is not.\n */\nexport interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title' | 'children'> {\n /** What the card does. Short: it is the name a screen reader says. */\n title: React.ReactNode;\n /** One line that says what happens. */\n description?: React.ReactNode;\n /** An icon (a `lucide-react` element), drawn in a tile on the left. Hidden from a screen reader: the title says it. */\n icon?: React.ReactNode;\n /** What sits on the right. An arrow by default; any node, or `null` for nothing. */\n trailing?: React.ReactNode;\n /**\n * Passing it (true or false) makes the card a toggle: it reports `aria-pressed` and, when true,\n * wears the brand ring. Leave it out for a plain action.\n */\n selected?: boolean;\n /** `primary` is the option to steer toward, `error` a destructive one. */\n variant?: ActionCardVariant;\n}\n\n// `title` is the text color of the variant, when it has one. The error one is `--status-error-fg`, not\n// `--interactive-error`: on the hover fill the latter is 3.53:1 in the light theme (4.2:1 in the dark one),\n// under AA for text this size, where the status text color stays at 4.86:1 and 6.69:1.\nconst VARIANTS: Record<ActionCardVariant, { tileBg: string; tileFg: string; edge: string; title?: string }> = {\n default: { tileBg: 'var(--bg-subtle)', tileFg: 'var(--text-secondary)', edge: 'var(--border-brand)' },\n primary: { tileBg: 'var(--interactive-primary)', tileFg: 'var(--interactive-primary-fg)', edge: 'var(--border-brand)' },\n error: { tileBg: 'var(--status-error-bg)', tileFg: 'var(--status-error-fg)', edge: 'var(--status-error-dot)', title: 'var(--status-error-fg)' },\n};\n\n// The fill of a hovered card: a few percent of the variant's own ring color over the surface. Not\n// `--interactive-ghost-hover`: that grey is the very color of the icon tile (`--bg-subtle`), so on hover the\n// tile vanished into the card. This tint keeps the tile showing (1.20:1 against it in the light theme, 1.17:1\n// in the dark one, close to the 1.28:1 and 1.23:1 it has against the idle card) and keeps every text above AA.\nconst hoverFill = (edge: string) => 'color-mix(in srgb, ' + edge + ' 6%, var(--bg-surface))';\n\nexport function ActionCard({\n title,\n description,\n icon,\n trailing,\n selected,\n variant = 'default',\n disabled = false,\n className,\n style,\n ...rest\n}: ActionCardProps) {\n const v = VARIANTS[variant] || VARIANTS.default;\n const on = selected === true;\n const arrow = trailing === undefined ? <ChevronRight size={18} strokeWidth={1.75} aria-hidden /> : trailing;\n\n // The ring and the fill, each with its hover value, as custom properties `.sereno-action` (styles.css) switches\n // between on `:hover`, `:active` and `:focus-visible` (SS-577): the card holds no hover / press / focus state.\n // A selected card wears the same ring hovered or not; a disabled one has no hover value at all.\n const ring = on ? '0 0 0 1.5px ' + v.edge : '0 0 0 1px ' + (disabled ? 'var(--border-subtle)' : 'var(--border-default)');\n const ringHover = on ? ring : '0 0 0 1px ' + v.edge;\n // Only set when disabled: a `color: undefined` in a style would wipe the Typography's own.\n const muted = disabled ? { color: 'var(--text-disabled)' } : undefined;\n const titleStyle = disabled ? muted : v.title ? { color: v.title } : undefined;\n\n return (\n <button\n type=\"button\"\n disabled={disabled}\n aria-pressed={selected}\n {...rest}\n className={['sereno-action', className].filter(Boolean).join(' ')}\n style={sx({\n '--sd-bg': 'var(--bg-surface)',\n '--sd-bg-hover': disabled ? undefined : hoverFill(v.edge),\n '--sd-ring': ring,\n '--sd-ring-hover': disabled ? undefined : ringHover,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n width: '100%',\n minWidth: 0,\n padding: 'var(--space-3) var(--space-4)',\n textAlign: 'left',\n fontFamily: 'var(--font-body)',\n color: 'inherit',\n border: 'none',\n borderRadius: 'var(--radius-card)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n // The focus ring is the box-shadow of `.sereno-action:focus-visible`, the same substitute `Button` and `Card` use.\n outline: 'none',\n ...style,\n })}\n >\n {icon ? (\n <span\n aria-hidden\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n flex: '0 0 auto',\n width: 40,\n height: 40,\n borderRadius: 'var(--radius-md)',\n background: disabled ? 'var(--interactive-disabled-bg)' : v.tileBg,\n color: disabled ? 'var(--interactive-disabled-fg)' : v.tileFg,\n })}\n >\n {icon}\n </span>\n ) : null}\n\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2, flex: '1 1 auto', minWidth: 0 })}>\n <Typography as=\"span\" variant=\"label\" style={titleStyle}>\n {title}\n </Typography>\n {description ? (\n <Typography as=\"span\" variant=\"bodySm\" style={muted}>\n {description}\n </Typography>\n ) : null}\n </span>\n\n {arrow ? (\n <span style={sx({ display: 'inline-flex', flex: '0 0 auto', color: disabled ? 'var(--text-disabled)' : 'var(--text-muted)' })}>\n {arrow}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":";AAkEyC,cA4DnC,YA5DmC;AA/DzC,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAmC3B,MAAM,WAAwG;AAAA,EAC5G,SAAS,EAAE,QAAQ,oBAAoB,QAAQ,yBAAyB,MAAM,sBAAsB;AAAA,EACpG,SAAS,EAAE,QAAQ,8BAA8B,QAAQ,iCAAiC,MAAM,sBAAsB;AAAA,EACtH,OAAO,EAAE,QAAQ,0BAA0B,QAAQ,0BAA0B,MAAM,2BAA2B,OAAO,yBAAyB;AAChJ;AAMA,MAAM,YAAY,CAAC,SAAiB,wBAAwB,OAAO;AAE5D,SAAS,WAAW;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAoB;AAClB,QAAM,IAAI,SAAS,OAAO,KAAK,SAAS;AACxC,QAAM,KAAK,aAAa;AACxB,QAAM,QAAQ,aAAa,SAAY,oBAAC,gBAAa,MAAM,IAAI,aAAa,MAAM,eAAW,MAAC,IAAK;AAKnG,QAAM,OAAO,KAAK,iBAAiB,EAAE,OAA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AU,EAAE,CAAC,GACjG;AAAA,8BAAC,cAAW,IAAG,QAAO,SAAQ,SAAQ,OAAO,YAC1C,iBACH;AAAA,UACC,cACC,oBAAC,cAAW,IAAG,QAAO,SAAQ,UAAS,OAAO,OAC3C,uBACH,IACE;AAAA,WACN;AAAA,QAEC,QACC,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,eAAe,MAAM,YAAY,OAAO,WAAW,yBAAyB,oBAAoB,CAAC,GACzH,iBACH,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/core/ActionCard.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { ChevronRight } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Typography } from './Typography';\n\nexport type ActionCardVariant = 'default' | 'primary' | 'error';\n\n/**\n * A whole card you press: an icon, a title, a line of explanation and an arrow, in a real\n * `<button>`. For the options of a decision (\"Reschedule\", \"Cancel the booking\") and for the\n * entries of a settings flow. A `Card` with `interactive` is the bare surface; this is the\n * finished control, with the keyboard, the focus ring and the disabled state taken care of.\n *\n * It is an action, not a radio: arrow keys do not move between cards. `selected` marks a card as\n * a toggle (`aria-pressed`); for \"choose exactly one of these\" the semantics are a radio group's,\n * which this is not.\n */\nexport interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'title' | 'children'> {\n /** What the card does. Short: it is the name a screen reader says. */\n title: React.ReactNode;\n /** One line that says what happens. */\n description?: React.ReactNode;\n /** An icon (a `lucide-react` element), drawn in a tile on the left. Hidden from a screen reader: the title says it. */\n icon?: React.ReactNode;\n /** What sits on the right. An arrow by default; any node, or `null` for nothing. */\n trailing?: React.ReactNode;\n /**\n * Passing it (true or false) makes the card a toggle: it reports `aria-pressed` and, when true,\n * wears the brand ring. Leave it out for a plain action.\n */\n selected?: boolean;\n /** `primary` is the option to steer toward, `error` a destructive one. */\n variant?: ActionCardVariant;\n}\n\n// `title` is the text color of the variant, when it has one. The error one is `--status-error-fg`, not\n// `--interactive-error`: on the hover fill the latter is 3.53:1 in the light theme (4.2:1 in the dark one),\n// under AA for text this size, where the status text color stays at 4.86:1 and 6.69:1.\nconst VARIANTS: Record<ActionCardVariant, { tileBg: string; tileFg: string; edge: string; title?: string }> = {\n default: { tileBg: 'var(--bg-subtle)', tileFg: 'var(--text-secondary)', edge: 'var(--border-brand)' },\n primary: { tileBg: 'var(--interactive-primary)', tileFg: 'var(--interactive-primary-fg)', edge: 'var(--border-brand)' },\n error: { tileBg: 'var(--status-error-bg)', tileFg: 'var(--status-error-fg)', edge: 'var(--status-error-dot)', title: 'var(--status-error-fg)' },\n};\n\n// The fill of a hovered card: a few percent of the variant's own ring color over the surface. Not\n// `--interactive-ghost-hover`: that grey is the very color of the icon tile (`--bg-subtle`), so on hover the\n// tile vanished into the card. This tint keeps the tile showing (1.20:1 against it in the light theme, 1.17:1\n// in the dark one, close to the 1.28:1 and 1.23:1 it has against the idle card) and keeps every text above AA.\nconst hoverFill = (edge: string) => 'color-mix(in srgb, ' + edge + ' 6%, var(--bg-surface))';\n\nexport function ActionCard({\n title,\n description,\n icon,\n trailing,\n selected,\n variant = 'default',\n disabled = false,\n className,\n style,\n ...rest\n}: ActionCardProps) {\n const v = VARIANTS[variant] || VARIANTS.default;\n const on = selected === true;\n const arrow = trailing === undefined ? <ChevronRight size={18} strokeWidth={1.75} aria-hidden /> : trailing;\n\n // The ring and the fill, each with its hover value, as custom properties `.sereno-action` (styles.css) switches\n // between on `:hover`, `:active` and `:focus-visible` (SS-577): the card holds no hover / press / focus state.\n // A selected card wears the same ring hovered or not; a disabled one has no hover value at all.\n const ring = on ? '0 0 0 1.5px ' + v.edge : '0 0 0 1px ' + (disabled ? 'var(--border-subtle)' : 'var(--border-default)');\n const ringHover = on ? ring : '0 0 0 1px ' + v.edge;\n // Only set when disabled: a `color: undefined` in a style would wipe the Typography's own.\n const muted = disabled ? { color: 'var(--text-disabled)' } : undefined;\n const titleStyle = disabled ? muted : v.title ? { color: v.title } : undefined;\n\n return (\n <button\n type=\"button\"\n disabled={disabled}\n aria-pressed={selected}\n {...rest}\n className={['sereno-action', className].filter(Boolean).join(' ')}\n style={sx({\n '--sd-bg': 'var(--bg-surface)',\n '--sd-bg-hover': disabled ? undefined : hoverFill(v.edge),\n '--sd-ring': ring,\n '--sd-ring-hover': disabled ? undefined : ringHover,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-3)',\n width: '100%',\n minWidth: 0,\n padding: 'var(--space-3) var(--space-4)',\n textAlign: 'left',\n fontFamily: 'var(--font-body)',\n color: 'inherit',\n border: 'none',\n borderRadius: 'var(--radius-card)',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n ...style,\n })}\n >\n {icon ? (\n <span\n aria-hidden\n style={sx({\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n flex: '0 0 auto',\n width: 40,\n height: 40,\n borderRadius: 'var(--radius-md)',\n background: disabled ? 'var(--interactive-disabled-bg)' : v.tileBg,\n color: disabled ? 'var(--interactive-disabled-fg)' : v.tileFg,\n })}\n >\n {icon}\n </span>\n ) : null}\n\n <span style={sx({ display: 'flex', flexDirection: 'column', gap: 2, flex: '1 1 auto', minWidth: 0 })}>\n <Typography as=\"span\" variant=\"label\" style={titleStyle}>\n {title}\n </Typography>\n {description ? (\n <Typography as=\"span\" variant=\"bodySm\" style={muted}>\n {description}\n </Typography>\n ) : null}\n </span>\n\n {arrow ? (\n <span style={sx({ display: 'inline-flex', flex: '0 0 auto', color: disabled ? 'var(--text-disabled)' : 'var(--text-muted)' })}>\n {arrow}\n </span>\n ) : null}\n </button>\n );\n}\n"],"mappings":";AAkEyC,cA0DnC,YA1DmC;AA/DzC,SAAS,oBAAoB;AAC7B,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAmC3B,MAAM,WAAwG;AAAA,EAC5G,SAAS,EAAE,QAAQ,oBAAoB,QAAQ,yBAAyB,MAAM,sBAAsB;AAAA,EACpG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A,QACR,cAAc;AAAA,QACd,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA,QACZ,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,eACC;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,YACX,OAAO,GAAG;AAAA,cACR,SAAS;AAAA,cACT,YAAY;AAAA,cACZ,gBAAgB;AAAA,cAChB,MAAM;AAAA,cACN,OAAO;AAAA,cACP,QAAQ;AAAA,cACR,cAAc;AAAA,cACd,YAAY,WAAW,mCAAmC,EAAE;AAAA,cAC5D,OAAO,WAAW,mCAAmC,EAAE;AAAA,YACzD,CAAC;AAAA,YAEA;AAAA;AAAA,QACH,IACE;AAAA,QAEJ,qBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,QAAQ,eAAe,UAAU,KAAK,GAAG,MAAM,YAAY,UAAU,EAAE,CAAC,GACjG;AAAA,8BAAC,cAAW,IAAG,QAAO,SAAQ,SAAQ,OAAO,YAC1C,iBACH;AAAA,UACC,cACC,oBAAC,cAAW,IAAG,QAAO,SAAQ,UAAS,OAAO,OAC3C,uBACH,IACE;AAAA,WACN;AAAA,QAEC,QACC,oBAAC,UAAK,OAAO,GAAG,EAAE,SAAS,eAAe,MAAM,YAAY,OAAO,WAAW,yBAAyB,oBAAoB,CAAC,GACzH,iBACH,IACE;AAAA;AAAA;AAAA,EACN;AAEJ;","names":[]}
@@ -57,7 +57,6 @@ function Button({ variant = "primary", size = "md", fullWidth = false, disabled
57
57
  cursor: disabled ? "not-allowed" : "pointer",
58
58
  opacity: loading ? 0.75 : 1,
59
59
  transition: "var(--transition-control)",
60
- outline: "none",
61
60
  textUnderlineOffset: "2px",
62
61
  ...style
63
62
  }),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Primary action control. `primary` for navigation-level commitment, `accent` for the single\n * conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the\n * same words as Badge / Alert / Toast. (No `info` - in Sereno that is the brand indigo = `primary`.)\n */\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual role. Only one `accent` button per screen. */\n variant?: 'primary' | 'accent' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'error';\n /** Control height. `lg`/`xl` are the mobile defaults (≥44px tap target). */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n fullWidth?: boolean;\n disabled?: boolean;\n /** Shows a spinner and blocks interaction. */\n loading?: boolean;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n children?: React.ReactNode;\n}\n\nconst SIZES = {\n sm: { h: 'var(--control-height-sm)', px: 'var(--space-3)', fs: 'var(--text-sm)', gap: '6px' },\n md: { h: 'var(--control-height-md)', px: 'var(--space-4)', fs: 'var(--text-base)', gap: '8px' },\n lg: { h: 'var(--control-height-lg)', px: 'var(--space-5)', fs: 'var(--text-md)', gap: '10px' },\n xl: { h: 'var(--control-height-xl)', px: 'var(--space-6)', fs: 'var(--text-lg)', gap: '10px' },\n} as const;\n\n/**\n * What a variant looks like in each state, as the custom properties `.sereno-btn` (styles.css) reads:\n * the base, then only what differs on `:hover`, `:active` (pressed) and `:focus-visible` (SS-577). The\n * browser switches between them, so a button holds no hover / press / focus state and does not re-render when\n * the pointer crosses it. A property left out falls back to the one before it in the CSS.\n */\nfunction stateVars(variant: NonNullable<ButtonProps['variant']>): Record<string, string> {\n switch (variant) {\n case 'accent':\n return { '--sd-bg': 'var(--interactive-accent)', '--sd-bg-hover': 'var(--interactive-accent-hover)', '--sd-bg-active': 'var(--interactive-accent-active)', '--sd-fg': 'var(--interactive-accent-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)', '--sd-sh-hover': 'var(--shadow-accent)', '--sd-ring': 'var(--focus-ring-accent)' };\n case 'secondary':\n return { '--sd-bg': 'var(--interactive-secondary)', '--sd-bg-hover': 'var(--interactive-secondary-hover)', '--sd-bg-active': 'var(--interactive-secondary-active)', '--sd-fg': 'var(--interactive-secondary-fg)', '--sd-bd': 'var(--border-default)', '--sd-sh': 'var(--shadow-xs)' };\n case 'ghost':\n return { '--sd-bg': 'transparent', '--sd-bg-hover': 'var(--interactive-ghost-hover)', '--sd-fg': 'var(--text-secondary)', '--sd-bd': 'transparent', '--sd-sh': 'none' };\n case 'success':\n return { '--sd-bg': 'var(--interactive-success)', '--sd-bg-hover': 'var(--interactive-success-hover)', '--sd-fg': 'var(--interactive-success-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'warning':\n return { '--sd-bg': 'var(--interactive-warning)', '--sd-bg-hover': 'var(--interactive-warning-hover)', '--sd-fg': 'var(--interactive-warning-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'error':\n return { '--sd-bg': 'var(--interactive-error)', '--sd-bg-hover': 'var(--interactive-error-hover)', '--sd-fg': 'var(--interactive-error-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'link':\n return { '--sd-bg': 'transparent', '--sd-fg': 'var(--text-link)', '--sd-fg-hover': 'var(--text-link-hover)', '--sd-bd': 'transparent', '--sd-sh': 'none', '--sd-deco-hover': 'underline' };\n default:\n return { '--sd-bg': 'var(--interactive-primary)', '--sd-bg-hover': 'var(--interactive-primary-hover)', '--sd-bg-active': 'var(--interactive-primary-active)', '--sd-fg': 'var(--interactive-primary-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)', '--sd-sh-hover': 'var(--shadow-brand)' };\n }\n}\n\n/** A disabled control: one look, no hover, no press, no ring (the CSS rules exclude `:disabled`). */\nconst DISABLED_VARS = { '--sd-bg': 'var(--interactive-disabled-bg)', '--sd-fg': 'var(--interactive-disabled-fg)', '--sd-bd': 'transparent', '--sd-sh': 'none' };\n\nexport function Button({ variant = 'primary', size = 'md', fullWidth = false, disabled = false, loading = false, iconLeft, iconRight, children, className, style, ...rest }: ButtonProps) {\n const sz = SIZES[size] || SIZES.md;\n const isLink = variant === 'link';\n return (\n <button\n type=\"button\"\n disabled={disabled || loading}\n {...rest}\n className={['sereno-btn', className].filter(Boolean).join(' ')}\n style={sx({\n ...(disabled ? DISABLED_VARS : stateVars(variant)),\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: sz.gap,\n height: isLink ? 'auto' : sz.h,\n padding: isLink ? 0 : '0 ' + sz.px,\n width: fullWidth ? '100%' : undefined,\n fontFamily: 'var(--font-body)',\n fontSize: sz.fs,\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n borderRadius: isLink ? 'var(--radius-xs)' : 'var(--radius-control)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: loading ? 0.75 : 1,\n transition: 'var(--transition-control)',\n outline: 'none',\n textUnderlineOffset: '2px',\n ...style,\n })}\n >\n {loading ? (\n <span style={sx({ width: '1em', height: '1em', borderRadius: '999px', border: '2px solid currentColor', borderTopColor: 'transparent', display: 'inline-block', animation: 'sereno-spin .7s linear infinite' })} />\n ) : (\n iconLeft\n )}\n {children}\n {iconRight}\n </button>\n );\n}"],"mappings":";AAiEI,SA8BI,KA9BJ;AA9DJ,SAAS,UAAU;AAqBnB,MAAM,QAAQ;AAAA,EACZ,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,MAAM;AAAA,EAC5F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,oBAAoB,KAAK,MAAM;AAAA,EAC9F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO;AAAA,EAC7F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO;AAC/F;AAQA,SAAS,UAAU,SAAsE;AACvF,UAAQ,SAAS;AAAA,IACf,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AAM,SAAS,YAAY;AAC3B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,UAAU,YAAY;AAAA,MACrB,GAAG;AAAA,MACJ,WAAW,CAAC,cAAc,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC7D,OAAO,GAAG;AAAA,QACR,GAAI,WAAW,gBAAgB,UAAU,OAAO;AAAA,QAChD,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,KAAK,GAAG;AAAA,QACR,QAAQ,SAAS,SAAS,GAAG;AAAA,QAC7B,SAAS,SAAS,IAAI,OAAO,GAAG;AAAA,QAChC,OAAO,YAAY,SAAS;AAAA,QAC5B,YAAY;AAAA,QACZ,UAAU,GAAG;AAAA,QACb,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,cAAc,SAAS,qBAAqB;AAAA,QAC5C,aAAa;AAAA,QACb,aAAa;AAAA,QACb,QAAQ,WAAW,gBAAgB;AAAA,QACnC,SAAS,UAAU,OAAO;AAAA,QAC1B,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,qBAAqB;AAAA,QACrB,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,kBACC,oBAAC,UAAK,OAAO,GAAG,EAAE,OAAO,OAAO,QAAQ,OAAO,cAAc,SAAS,QAAQ,0BAA0B,gBAAgB,eAAe,SAAS,gBAAgB,WAAW,kCAAkC,CAAC,GAAG,IAEjN;AAAA,QAED;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/core/Button.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Primary action control. `primary` for navigation-level commitment, `accent` for the single\n * conversion action on a view. `success` / `warning` / `error` are the semantic fills, using the\n * same words as Badge / Alert / Toast. (No `info` - in Sereno that is the brand indigo = `primary`.)\n */\nexport interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Visual role. Only one `accent` button per screen. */\n variant?: 'primary' | 'accent' | 'secondary' | 'ghost' | 'link' | 'success' | 'warning' | 'error';\n /** Control height. `lg`/`xl` are the mobile defaults (≥44px tap target). */\n size?: 'sm' | 'md' | 'lg' | 'xl';\n fullWidth?: boolean;\n disabled?: boolean;\n /** Shows a spinner and blocks interaction. */\n loading?: boolean;\n iconLeft?: React.ReactNode;\n iconRight?: React.ReactNode;\n children?: React.ReactNode;\n}\n\nconst SIZES = {\n sm: { h: 'var(--control-height-sm)', px: 'var(--space-3)', fs: 'var(--text-sm)', gap: '6px' },\n md: { h: 'var(--control-height-md)', px: 'var(--space-4)', fs: 'var(--text-base)', gap: '8px' },\n lg: { h: 'var(--control-height-lg)', px: 'var(--space-5)', fs: 'var(--text-md)', gap: '10px' },\n xl: { h: 'var(--control-height-xl)', px: 'var(--space-6)', fs: 'var(--text-lg)', gap: '10px' },\n} as const;\n\n/**\n * What a variant looks like in each state, as the custom properties `.sereno-btn` (styles.css) reads:\n * the base, then only what differs on `:hover`, `:active` (pressed) and `:focus-visible` (SS-577). The\n * browser switches between them, so a button holds no hover / press / focus state and does not re-render when\n * the pointer crosses it. A property left out falls back to the one before it in the CSS.\n */\nfunction stateVars(variant: NonNullable<ButtonProps['variant']>): Record<string, string> {\n switch (variant) {\n case 'accent':\n return { '--sd-bg': 'var(--interactive-accent)', '--sd-bg-hover': 'var(--interactive-accent-hover)', '--sd-bg-active': 'var(--interactive-accent-active)', '--sd-fg': 'var(--interactive-accent-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)', '--sd-sh-hover': 'var(--shadow-accent)', '--sd-ring': 'var(--focus-ring-accent)' };\n case 'secondary':\n return { '--sd-bg': 'var(--interactive-secondary)', '--sd-bg-hover': 'var(--interactive-secondary-hover)', '--sd-bg-active': 'var(--interactive-secondary-active)', '--sd-fg': 'var(--interactive-secondary-fg)', '--sd-bd': 'var(--border-default)', '--sd-sh': 'var(--shadow-xs)' };\n case 'ghost':\n return { '--sd-bg': 'transparent', '--sd-bg-hover': 'var(--interactive-ghost-hover)', '--sd-fg': 'var(--text-secondary)', '--sd-bd': 'transparent', '--sd-sh': 'none' };\n case 'success':\n return { '--sd-bg': 'var(--interactive-success)', '--sd-bg-hover': 'var(--interactive-success-hover)', '--sd-fg': 'var(--interactive-success-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'warning':\n return { '--sd-bg': 'var(--interactive-warning)', '--sd-bg-hover': 'var(--interactive-warning-hover)', '--sd-fg': 'var(--interactive-warning-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'error':\n return { '--sd-bg': 'var(--interactive-error)', '--sd-bg-hover': 'var(--interactive-error-hover)', '--sd-fg': 'var(--interactive-error-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)' };\n case 'link':\n return { '--sd-bg': 'transparent', '--sd-fg': 'var(--text-link)', '--sd-fg-hover': 'var(--text-link-hover)', '--sd-bd': 'transparent', '--sd-sh': 'none', '--sd-deco-hover': 'underline' };\n default:\n return { '--sd-bg': 'var(--interactive-primary)', '--sd-bg-hover': 'var(--interactive-primary-hover)', '--sd-bg-active': 'var(--interactive-primary-active)', '--sd-fg': 'var(--interactive-primary-fg)', '--sd-bd': 'transparent', '--sd-sh': 'var(--shadow-xs)', '--sd-sh-hover': 'var(--shadow-brand)' };\n }\n}\n\n/** A disabled control: one look, no hover, no press, no ring (the CSS rules exclude `:disabled`). */\nconst DISABLED_VARS = { '--sd-bg': 'var(--interactive-disabled-bg)', '--sd-fg': 'var(--interactive-disabled-fg)', '--sd-bd': 'transparent', '--sd-sh': 'none' };\n\nexport function Button({ variant = 'primary', size = 'md', fullWidth = false, disabled = false, loading = false, iconLeft, iconRight, children, className, style, ...rest }: ButtonProps) {\n const sz = SIZES[size] || SIZES.md;\n const isLink = variant === 'link';\n return (\n <button\n type=\"button\"\n disabled={disabled || loading}\n {...rest}\n className={['sereno-btn', className].filter(Boolean).join(' ')}\n style={sx({\n ...(disabled ? DISABLED_VARS : stateVars(variant)),\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n gap: sz.gap,\n height: isLink ? 'auto' : sz.h,\n padding: isLink ? 0 : '0 ' + sz.px,\n width: fullWidth ? '100%' : undefined,\n fontFamily: 'var(--font-body)',\n fontSize: sz.fs,\n fontWeight: 'var(--weight-semibold)',\n letterSpacing: 'var(--tracking-snug)',\n borderRadius: isLink ? 'var(--radius-xs)' : 'var(--radius-control)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n cursor: disabled ? 'not-allowed' : 'pointer',\n opacity: loading ? 0.75 : 1,\n transition: 'var(--transition-control)',\n textUnderlineOffset: '2px',\n ...style,\n })}\n >\n {loading ? (\n <span style={sx({ width: '1em', height: '1em', borderRadius: '999px', border: '2px solid currentColor', borderTopColor: 'transparent', display: 'inline-block', animation: 'sereno-spin .7s linear infinite' })} />\n ) : (\n iconLeft\n )}\n {children}\n {iconRight}\n </button>\n );\n}"],"mappings":";AAiEI,SA6BI,KA7BJ;AA9DJ,SAAS,UAAU;AAqBnB,MAAM,QAAQ;AAAA,EACZ,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,MAAM;AAAA,EAC5F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,oBAAoB,KAAK,MAAM;AAAA,EAC9F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO;AAAA,EAC7F,IAAI,EAAE,GAAG,4BAA4B,IAAI,kBAAkB,IAAI,kBAAkB,KAAK,OAAO;AAC/F;AAQA,SAAS,UAAU,SAAsE;AACvF,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,EAAE,WAAW,6BAA6B,iBAAiB,mCAAmC,kBAAkB,oCAAoC,WAAW,gCAAgC,WAAW,eAAe,WAAW,oBAAoB,iBAAiB,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W,CAAC,cAAc,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC7D,OAAO,GAAG;AAAA,QACR,GAAI,WAAW,gBAAgB,UAAU,OAAO;AAAA,QAChD,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,KAAK,GAAG;AAAA,QACR,QAAQ,SAAS,SAAS,GAAG;AAAA,QAC7B,SAAS,SAAS,IAAI,OAAO,GAAG;AAAA,QAChC,OAAO,YAAY,SAAS;AAAA,QAC5B,YAAY;AAAA,QACZ,UAAU,GAAG;AAAA,QACb,YAAY;AAAA,QACZ,eAAe;AAAA,QACf,cAAc,SAAS,qBAAqB;AAAA,QAC5C,aAAa;AAAA,QACb,aAAa;AAAA,QACb,QAAQ,WAAW,gBAAgB;AAAA,QACnC,SAAS,UAAU,OAAO;AAAA,QAC1B,YAAY;AAAA,QACZ,qBAAqB;AAAA,QACrB,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA,kBACC,oBAAC,UAAK,OAAO,GAAG,EAAE,OAAO,OAAO,QAAQ,OAAO,cAAc,SAAS,QAAQ,0BAA0B,gBAAgB,eAAe,SAAS,gBAAgB,WAAW,kCAAkC,CAAC,GAAG,IAEjN;AAAA,QAED;AAAA,QACA;AAAA;AAAA;AAAA,EACH;AAEJ;","names":[]}
package/dist/core/Card.js CHANGED
@@ -37,9 +37,6 @@ function Card({ padding = "md", elevation = "sm", interactive = false, selected
37
37
  padding: PADS[padding],
38
38
  transition: "var(--transition-control)",
39
39
  cursor: interactive ? "pointer" : "default",
40
- // outline:none is safe here (unlike the CSS-class pattern elsewhere in
41
- // this package): the focus ring is the box-shadow `.sereno-card[data-clickable]:focus-visible` draws.
42
- outline: clickable ? "none" : void 0,
43
40
  ...style
44
41
  }),
45
42
  children
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/Card.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Neutral surface container: a crisp 1px ring + optional soft lift + 14px radius. The base of every list row and panel. */\nexport interface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n padding?: 'none' | 'sm' | 'md' | 'lg';\n elevation?: 'none' | 'sm' | 'md' | 'lg';\n /** Adds hover lift, press scale and pointer cursor. */\n interactive?: boolean;\n /** Brand-coloured ring for a chosen option. */\n selected?: boolean;\n children?: React.ReactNode;\n}\n\nconst PADS = { none: 0, sm: 'var(--space-3)', md: 'var(--space-4)', lg: 'var(--space-5)' } as const;\n// The edge is a box-shadow ring (pixel-crisp at any radius), with the elevation\n// drop-shadow layered beneath it - never a real `border` fighting the shadow.\nconst DROP = { none: '', sm: 'var(--shadow-xs)', md: 'var(--shadow-md)', lg: 'var(--shadow-lg)' } as const;\n/** A shadow that draws nothing: lets `box-shadow: ring, drop` stay valid when there is no drop (`elevation=\"none\"`). */\nconst NO_SHADOW = '0 0 0 0 transparent';\n\nexport function Card({ padding = 'md', elevation = 'sm', interactive = false, selected = false, children, style, className, onClick, onKeyDown, ...rest }: CardProps) {\n // A Card only needs real button semantics (SS-228) when it owns its own\n // onClick - `interactive` alone (no onClick) means it's just borrowing the\n // hover/press visual inside an already-interactive wrapper (e.g. the\n // landing page's Cards inside a <Link>), and giving it a tabIndex there\n // would nest one focusable control inside another.\n const clickable = interactive && !!onClick;\n\n // The edge is a ring and the lift a drop shadow, each with its hover value. `.sereno-card` (styles.css)\n // switches between them on :hover / :active / :focus-visible (SS-577), so the card keeps no state.\n const ring = selected ? '0 0 0 1.5px var(--border-brand)' : '0 0 0 1px var(--border-default)';\n const ringHover = selected ? ring : '0 0 0 1px var(--border-strong)';\n const drop = (selected ? 'var(--shadow-md)' : DROP[elevation]) || NO_SHADOW;\n const dropHover = selected ? 'var(--shadow-md)' : elevation === 'lg' ? 'var(--shadow-lg)' : 'var(--shadow-md)';\n\n return (\n <div\n role={clickable ? 'button' : undefined}\n tabIndex={clickable ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n clickable\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n // Not a real MouseEvent - every onClick in this codebase ignores\n // the event argument, so the cast is safe in practice.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- see above\n onClick(e as any);\n }\n onKeyDown?.(e);\n }\n : onKeyDown\n }\n {...rest}\n className={['sereno-card', className].filter(Boolean).join(' ')}\n data-interactive={interactive || undefined}\n data-clickable={clickable || undefined}\n style={sx({\n '--sd-ring': ring,\n '--sd-ring-h': ringHover,\n '--sd-drop': drop,\n '--sd-drop-h': dropHover,\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-card)',\n padding: PADS[padding],\n transition: 'var(--transition-control)',\n cursor: interactive ? 'pointer' : 'default',\n // outline:none is safe here (unlike the CSS-class pattern elsewhere in\n // this package): the focus ring is the box-shadow `.sereno-card[data-clickable]:focus-visible` draws.\n outline: clickable ? 'none' : undefined,\n ...style,\n })}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";AAuCI;AApCJ,SAAS,UAAU;AAanB,MAAM,OAAO,EAAE,MAAM,GAAG,IAAI,kBAAkB,IAAI,kBAAkB,IAAI,iBAAiB;AAGzF,MAAM,OAAO,EAAE,MAAM,IAAI,IAAI,oBAAoB,IAAI,oBAAoB,IAAI,mBAAmB;AAEhG,MAAM,YAAY;AAEX,SAAS,KAAK,EAAE,UAAU,MAAM,YAAY,MAAM,cAAc,OAAO,WAAW,OAAO,UAAU,OAAO,WAAW,SAAS,WAAW,GAAG,KAAK,GAAc;AAMpK,QAAM,YAAY,eAAe,CAAC,CAAC;AAInC,QAAM,OAAO,WAAW,oCAAoC;AAC5D,QAAM,YAAY,WAAW,OAAO;AACpC,QAAM,QAAQ,WAAW,qBAAqB,KAAK,SAAS,MAAM;AAClE,QAAM,YAAY,WAAW,qBAAqB,cAAc,OAAO,qBAAqB;AAE5F,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAM,YAAY,WAAW;AAAA,MAC7B,UAAU,YAAY,IAAI;AAAA,MAC1B;AAAA,MACA,WACE,YACI,CAAC,MAAM;AACL,YAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK;AACtC,YAAE,eAAe;AAIjB,kBAAQ,CAAQ;AAAA,QAClB;AACA,oBAAY,CAAC;AAAA,MACf,IACA;AAAA,MAEL,GAAG;AAAA,MACJ,WAAW,CAAC,eAAe,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC9D,oBAAkB,eAAe;AAAA,MACjC,kBAAgB,aAAa;AAAA,MAC7B,OAAO,GAAG;AAAA,QACR,aAAa;AAAA,QACb,eAAe;AAAA,QACf,aAAa;AAAA,QACb,eAAe;AAAA,QACf,YAAY;AAAA,QACZ,cAAc;AAAA,QACd,SAAS,KAAK,OAAO;AAAA,QACrB,YAAY;AAAA,QACZ,QAAQ,cAAc,YAAY;AAAA;AAAA;AAAA,QAGlC,SAAS,YAAY,SAAS;AAAA,QAC9B,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/core/Card.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/** Neutral surface container: a crisp 1px ring + optional soft lift + 14px radius. The base of every list row and panel. */\nexport interface CardProps extends React.HTMLAttributes<HTMLDivElement> {\n padding?: 'none' | 'sm' | 'md' | 'lg';\n elevation?: 'none' | 'sm' | 'md' | 'lg';\n /** Adds hover lift, press scale and pointer cursor. */\n interactive?: boolean;\n /** Brand-coloured ring for a chosen option. */\n selected?: boolean;\n children?: React.ReactNode;\n}\n\nconst PADS = { none: 0, sm: 'var(--space-3)', md: 'var(--space-4)', lg: 'var(--space-5)' } as const;\n// The edge is a box-shadow ring (pixel-crisp at any radius), with the elevation\n// drop-shadow layered beneath it - never a real `border` fighting the shadow.\nconst DROP = { none: '', sm: 'var(--shadow-xs)', md: 'var(--shadow-md)', lg: 'var(--shadow-lg)' } as const;\n/** A shadow that draws nothing: lets `box-shadow: ring, drop` stay valid when there is no drop (`elevation=\"none\"`). */\nconst NO_SHADOW = '0 0 0 0 transparent';\n\nexport function Card({ padding = 'md', elevation = 'sm', interactive = false, selected = false, children, style, className, onClick, onKeyDown, ...rest }: CardProps) {\n // A Card only needs real button semantics (SS-228) when it owns its own\n // onClick - `interactive` alone (no onClick) means it's just borrowing the\n // hover/press visual inside an already-interactive wrapper (e.g. the\n // landing page's Cards inside a <Link>), and giving it a tabIndex there\n // would nest one focusable control inside another.\n const clickable = interactive && !!onClick;\n\n // The edge is a ring and the lift a drop shadow, each with its hover value. `.sereno-card` (styles.css)\n // switches between them on :hover / :active / :focus-visible (SS-577), so the card keeps no state.\n const ring = selected ? '0 0 0 1.5px var(--border-brand)' : '0 0 0 1px var(--border-default)';\n const ringHover = selected ? ring : '0 0 0 1px var(--border-strong)';\n const drop = (selected ? 'var(--shadow-md)' : DROP[elevation]) || NO_SHADOW;\n const dropHover = selected ? 'var(--shadow-md)' : elevation === 'lg' ? 'var(--shadow-lg)' : 'var(--shadow-md)';\n\n return (\n <div\n role={clickable ? 'button' : undefined}\n tabIndex={clickable ? 0 : undefined}\n onClick={onClick}\n onKeyDown={\n clickable\n ? (e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n // Not a real MouseEvent - every onClick in this codebase ignores\n // the event argument, so the cast is safe in practice.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- see above\n onClick(e as any);\n }\n onKeyDown?.(e);\n }\n : onKeyDown\n }\n {...rest}\n className={['sereno-card', className].filter(Boolean).join(' ')}\n data-interactive={interactive || undefined}\n data-clickable={clickable || undefined}\n style={sx({\n '--sd-ring': ring,\n '--sd-ring-h': ringHover,\n '--sd-drop': drop,\n '--sd-drop-h': dropHover,\n background: 'var(--bg-surface)',\n borderRadius: 'var(--radius-card)',\n padding: PADS[padding],\n transition: 'var(--transition-control)',\n cursor: interactive ? 'pointer' : 'default',\n ...style,\n })}\n >\n {children}\n </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A,EACH;AAEJ;","names":[]}
@@ -46,7 +46,6 @@ function IconButton({ variant = "ghost", size = "md", label, disabled = false, c
46
46
  borderStyle: "solid",
47
47
  cursor: disabled ? "not-allowed" : "pointer",
48
48
  transition: "var(--transition-control)",
49
- outline: "none",
50
49
  ...style
51
50
  }),
52
51
  children
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/IconButton.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Square icon-only control for toolbars, card corners and top bars. Always pass `label`.\n * `success` / `warning` / `error` are solid semantic fills - same words as Button / Badge.\n */\nexport interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: 'ghost' | 'secondary' | 'primary' | 'success' | 'warning' | 'error';\n size?: 'sm' | 'md' | 'lg';\n /** Accessible name - becomes aria-label and title. Required. */\n label: string;\n disabled?: boolean;\n /** The icon element (Lucide 20px stroke 1.75). */\n children?: React.ReactNode;\n}\n\nconst S = { sm: 32, md: 40, lg: 48 } as const;\n\n/** Solid-fill variants: [base, hover, fg]. */\nconst SOLID: Partial<Record<NonNullable<IconButtonProps['variant']>, [string, string, string]>> = {\n primary: ['--interactive-primary', '--interactive-primary-hover', '--interactive-primary-fg'],\n success: ['--interactive-success', '--interactive-success-hover', '--interactive-success-fg'],\n warning: ['--interactive-warning', '--interactive-warning-hover', '--interactive-warning-fg'],\n error: ['--interactive-error', '--interactive-error-hover', '--interactive-error-fg'],\n};\n\nexport function IconButton({ variant = 'ghost', size = 'md', label, disabled = false, children, className, style, ...rest }: IconButtonProps) {\n const d = S[size] || S.md;\n const solid = SOLID[variant];\n const outline = variant === 'secondary';\n\n // The values of each state, for `.sereno-btn` (styles.css) to switch between on :hover / :active / :focus-visible\n // (SS-577). Only a press scale and a focus ring are common to all; the rest is per variant.\n let vars: Record<string, string>;\n if (disabled) {\n vars = { '--sd-bg': 'var(--interactive-disabled-bg)', '--sd-fg': 'var(--interactive-disabled-fg)' };\n } else if (solid) {\n vars = { '--sd-bg': `var(${solid[0]})`, '--sd-bg-hover': `var(${solid[1]})`, '--sd-fg': `var(${solid[2]})` };\n } else if (outline) {\n vars = { '--sd-bg': 'var(--interactive-secondary)', '--sd-bg-hover': 'var(--interactive-secondary-hover)', '--sd-fg': 'var(--text-secondary)' };\n } else {\n vars = { '--sd-bg': 'transparent', '--sd-bg-hover': 'var(--interactive-ghost-hover)', '--sd-fg': 'var(--text-secondary)' };\n }\n vars['--sd-bd'] = outline ? 'var(--border-default)' : 'transparent';\n vars['--sd-sh'] = 'none';\n\n return (\n <button\n type=\"button\"\n aria-label={label}\n title={label}\n disabled={disabled}\n {...rest}\n className={['sereno-btn', className].filter(Boolean).join(' ')}\n style={sx({\n ...vars,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: d,\n height: d,\n flex: '0 0 auto',\n borderRadius: 'var(--radius-control)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n outline: 'none',\n ...style,\n })}\n >\n {children}\n </button>\n );\n}\n"],"mappings":";AAkDI;AA/CJ,SAAS,UAAU;AAgBnB,MAAM,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAGnC,MAAM,QAA4F;AAAA,EAChG,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,OAAO,CAAC,uBAAuB,6BAA6B,wBAAwB;AACtF;AAEO,SAAS,WAAW,EAAE,UAAU,SAAS,OAAO,MAAM,OAAO,WAAW,OAAO,UAAU,WAAW,OAAO,GAAG,KAAK,GAAoB;AAC5I,QAAM,IAAI,EAAE,IAAI,KAAK,EAAE;AACvB,QAAM,QAAQ,MAAM,OAAO;AAC3B,QAAM,UAAU,YAAY;AAI5B,MAAI;AACJ,MAAI,UAAU;AACZ,WAAO,EAAE,WAAW,kCAAkC,WAAW,iCAAiC;AAAA,EACpG,WAAW,OAAO;AAChB,WAAO,EAAE,WAAW,OAAO,MAAM,CAAC,CAAC,KAAK,iBAAiB,OAAO,MAAM,CAAC,CAAC,KAAK,WAAW,OAAO,MAAM,CAAC,CAAC,IAAI;AAAA,EAC7G,WAAW,SAAS;AAClB,WAAO,EAAE,WAAW,gCAAgC,iBAAiB,sCAAsC,WAAW,wBAAwB;AAAA,EAChJ,OAAO;AACL,WAAO,EAAE,WAAW,eAAe,iBAAiB,kCAAkC,WAAW,wBAAwB;AAAA,EAC3H;AACA,OAAK,SAAS,IAAI,UAAU,0BAA0B;AACtD,OAAK,SAAS,IAAI;AAElB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO;AAAA,MACP;AAAA,MACC,GAAG;AAAA,MACJ,WAAW,CAAC,cAAc,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC7D,OAAO,GAAG;AAAA,QACR,GAAG;AAAA,QACH,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA,QACZ,SAAS;AAAA,QACT,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/core/IconButton.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { sx } from '../_internal/style';\n\n/**\n * Square icon-only control for toolbars, card corners and top bars. Always pass `label`.\n * `success` / `warning` / `error` are solid semantic fills - same words as Button / Badge.\n */\nexport interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n variant?: 'ghost' | 'secondary' | 'primary' | 'success' | 'warning' | 'error';\n size?: 'sm' | 'md' | 'lg';\n /** Accessible name - becomes aria-label and title. Required. */\n label: string;\n disabled?: boolean;\n /** The icon element (Lucide 20px stroke 1.75). */\n children?: React.ReactNode;\n}\n\nconst S = { sm: 32, md: 40, lg: 48 } as const;\n\n/** Solid-fill variants: [base, hover, fg]. */\nconst SOLID: Partial<Record<NonNullable<IconButtonProps['variant']>, [string, string, string]>> = {\n primary: ['--interactive-primary', '--interactive-primary-hover', '--interactive-primary-fg'],\n success: ['--interactive-success', '--interactive-success-hover', '--interactive-success-fg'],\n warning: ['--interactive-warning', '--interactive-warning-hover', '--interactive-warning-fg'],\n error: ['--interactive-error', '--interactive-error-hover', '--interactive-error-fg'],\n};\n\nexport function IconButton({ variant = 'ghost', size = 'md', label, disabled = false, children, className, style, ...rest }: IconButtonProps) {\n const d = S[size] || S.md;\n const solid = SOLID[variant];\n const outline = variant === 'secondary';\n\n // The values of each state, for `.sereno-btn` (styles.css) to switch between on :hover / :active / :focus-visible\n // (SS-577). Only a press scale and a focus ring are common to all; the rest is per variant.\n let vars: Record<string, string>;\n if (disabled) {\n vars = { '--sd-bg': 'var(--interactive-disabled-bg)', '--sd-fg': 'var(--interactive-disabled-fg)' };\n } else if (solid) {\n vars = { '--sd-bg': `var(${solid[0]})`, '--sd-bg-hover': `var(${solid[1]})`, '--sd-fg': `var(${solid[2]})` };\n } else if (outline) {\n vars = { '--sd-bg': 'var(--interactive-secondary)', '--sd-bg-hover': 'var(--interactive-secondary-hover)', '--sd-fg': 'var(--text-secondary)' };\n } else {\n vars = { '--sd-bg': 'transparent', '--sd-bg-hover': 'var(--interactive-ghost-hover)', '--sd-fg': 'var(--text-secondary)' };\n }\n vars['--sd-bd'] = outline ? 'var(--border-default)' : 'transparent';\n vars['--sd-sh'] = 'none';\n\n return (\n <button\n type=\"button\"\n aria-label={label}\n title={label}\n disabled={disabled}\n {...rest}\n className={['sereno-btn', className].filter(Boolean).join(' ')}\n style={sx({\n ...vars,\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n width: d,\n height: d,\n flex: '0 0 auto',\n borderRadius: 'var(--radius-control)',\n borderWidth: 'var(--border-width-hairline)',\n borderStyle: 'solid',\n cursor: disabled ? 'not-allowed' : 'pointer',\n transition: 'var(--transition-control)',\n ...style,\n })}\n >\n {children}\n </button>\n );\n}\n"],"mappings":";AAkDI;AA/CJ,SAAS,UAAU;AAgBnB,MAAM,IAAI,EAAE,IAAI,IAAI,IAAI,IAAI,IAAI,GAAG;AAGnC,MAAM,QAA4F;AAAA,EAChG,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,SAAS,CAAC,yBAAyB,+BAA+B,0BAA0B;AAAA,EAC5F,OAAO,CAAC,uBAAuB,6BAA6B,wBAAwB;AACtF;AAEO,SAAS,WAAW,EAAE,UAAU,SAAS,OAAO,MAAM,OAAO,WAAW,OAAO,UAAU,WAAW,OAAO,GAAG,KAAK,GAAoB;AAC5I,QAAM,IAAI,EAAE,IAAI,KAAK,EAAE;AACvB,QAAM,QAAQ,MAAM,OAAO;AAC3B,QAAM,UAAU,YAAY;AAI5B,MAAI;AACJ,MAAI,UAAU;AACZ,WAAO,EAAE,WAAW,kCAAkC,WAAW,iCAAiC;AAAA,EACpG,WAAW,OAAO;AAChB,WAAO,EAAE,WAAW,OAAO,MAAM,CAAC,CAAC,KAAK,iBAAiB,OAAO,MAAM,CAAC,CAAC,KAAK,WAAW,OAAO,MAAM,CAAC,CAAC,IAAI;AAAA,EAC7G,WAAW,SAAS;AAClB,WAAO,EAAE,WAAW,gCAAgC,iBAAiB,sCAAsC,WAAW,wBAAwB;AAAA,EAChJ,OAAO;AACL,WAAO,EAAE,WAAW,eAAe,iBAAiB,kCAAkC,WAAW,wBAAwB;AAAA,EAC3H;AACA,OAAK,SAAS,IAAI,UAAU,0BAA0B;AACtD,OAAK,SAAS,IAAI;AAElB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,cAAY;AAAA,MACZ,OAAO;AAAA,MACP;AAAA,MACC,GAAG;AAAA,MACJ,WAAW,CAAC,cAAc,SAAS,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAAA,MAC7D,OAAO,GAAG;AAAA,QACR,GAAG;AAAA,QACH,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,gBAAgB;AAAA,QAChB,OAAO;AAAA,QACP,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,cAAc;AAAA,QACd,aAAa;AAAA,QACb,aAAa;AAAA,QACb,QAAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA,QACZ,GAAG;AAAA,MACL,CAAC;AAAA,MAEA;AAAA;AAAA,EACH;AAEJ;","names":[]}
@@ -15,6 +15,7 @@ import { useOutsidePress } from "../_internal/useOutsidePress.js";
15
15
  import { revealInList, useRevealActive } from "../_internal/useRevealActive.js";
16
16
  import { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from "../_internal/MenuOption.js";
17
17
  import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
18
+ import { fieldBoxProps } from "./_internal/fieldFrame.js";
18
19
  const TEXT = {
19
20
  "pt-BR": {
20
21
  placeholder: "Buscar\u2026",
@@ -90,7 +91,6 @@ const Autocomplete = React.forwardRef(function Autocomplete2({
90
91
  const text = draft ?? valueLabel;
91
92
  const query = draft ?? "";
92
93
  const [open, setOpen] = React.useState(false);
93
- const [focused, setFocused] = React.useState(false);
94
94
  const [activeKey, setActiveKey] = React.useState(null);
95
95
  const activeFromOpen = React.useRef(false);
96
96
  const pick = (key) => {
@@ -370,7 +370,8 @@ const Autocomplete = React.forwardRef(function Autocomplete2({
370
370
  e.preventDefault();
371
371
  inputRef.current?.focus();
372
372
  },
373
- style: sx({ ...fieldBoxStyle(size, !!error, focused || open, !!disabled), cursor: disabled ? "not-allowed" : "text" }),
373
+ ...fieldBoxProps(open),
374
+ style: sx({ ...fieldBoxStyle(size, !!error, !!disabled), cursor: disabled ? "not-allowed" : "text" }),
374
375
  children: [
375
376
  /* @__PURE__ */ jsx(
376
377
  "input",
@@ -401,12 +402,10 @@ const Autocomplete = React.forwardRef(function Autocomplete2({
401
402
  onChange,
402
403
  onKeyDown,
403
404
  onFocus: (e) => {
404
- setFocused(true);
405
405
  selectOnClick.current = true;
406
406
  e.currentTarget.select();
407
407
  },
408
408
  onBlur: (e) => {
409
- setFocused(false);
410
409
  if (boxRef.current?.contains(e.relatedTarget)) return;
411
410
  settle();
412
411
  },
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { srOnlyStyle } from '../_internal/srOnly';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useLatest } from '../_internal/useLatest';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { revealInList, useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nexport interface AutocompleteOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/** Every string the component says. Defaults come from `locale`; pass `labels` to change some. */\nexport interface AutocompleteLabels {\n /** Placeholder of the text box while nothing is chosen. */\n placeholder: string;\n /** aria-label of the clear (×) button. */\n clear: string;\n /** aria-label of the chevron button while the list is closed. */\n open: string;\n /** aria-label of the chevron button while the list is open. */\n close: string;\n /** What a screen reader hears while `loading` (the list itself shows only a spinner). */\n loading: string;\n /** The row shown when no option is left to show. */\n empty: string;\n /** What a screen reader hears when the list changes size. */\n results: (count: number) => string;\n}\n\nconst TEXT: Record<'pt-BR' | 'en', AutocompleteLabels> = {\n 'pt-BR': {\n placeholder: 'Buscar…',\n clear: 'Limpar seleção',\n open: 'Abrir lista',\n close: 'Fechar lista',\n loading: 'Carregando…',\n empty: 'Nenhum resultado',\n results: (n) => (n === 1 ? '1 resultado' : n + ' resultados'),\n },\n en: {\n placeholder: 'Search…',\n clear: 'Clear selection',\n open: 'Open list',\n close: 'Close list',\n loading: 'Loading…',\n empty: 'No results',\n results: (n) => (n === 1 ? '1 result' : n + ' results'),\n },\n};\n\n/**\n * Single choice from a list you search by typing. Like `Select`, but the box is a text field: type\n * to narrow the list, pick one row, and the value is that row. For a list too long to scroll\n * (past ~12 options), or one the server searches and pages (a thousand clients, fifty at a time).\n *\n * The value is the chosen option itself, `{ value, label }`, and it carries its own label. The\n * box shows `value.label` whether or not that option is in `options` right now, which is what\n * keeps the label when the page it came from is no longer loaded. `options` is only what the list\n * shows. `onValueChange` gives the option (or `null` when cleared), not a string.\n *\n * Two kinds of search, one prop apart:\n * - the default filters `options` itself, as you type (case and accents ignored);\n * - `filter={false}` leaves the list alone and tells you what was typed (`onSearch`, debounced),\n * for a list the server already filtered.\n *\n * It is a text box, not free text: what is typed never becomes the value. Leaving the box puts the\n * chosen label back.\n */\nexport interface AutocompleteProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n /** What the list shows now. Appending rows while it is open is fine: the list keeps its scroll. */\n options?: AutocompleteOption[];\n /** Controlled value: the chosen option, or `null` for none. */\n value?: AutocompleteOption | null;\n /** Uncontrolled initial value. */\n defaultValue?: AutocompleteOption | null;\n /** The chosen option, or `null` when the value is cleared. */\n onValueChange?: (option: AutocompleteOption | null) => void;\n /**\n * How typing narrows `options`. `true` (default): keep the rows whose label contains the text,\n * ignoring case and accents. `false`: show `options` as they are (the server did the filtering).\n * A function decides per row.\n */\n filter?: boolean | ((option: AutocompleteOption, query: string) => boolean);\n /**\n * The text to search for changed: fired as the user types (after `debounce`) and with `''` once\n * the box goes back to showing the chosen label (pick, clear, leave, Esc). Never with the label\n * itself, so it is safe to run the query here. Use it with `filter={false}`.\n */\n onSearch?: (query: string) => void;\n /** Debounce for `onSearch` while typing, in ms. */\n debounce?: number;\n /** The list is waiting for rows: a spinner under them (or alone), the list marked busy, and a screen reader told. */\n loading?: boolean;\n /**\n * The list was scrolled to within about five rows of its end. Fires once per list size, never\n * while `loading`. Pass it only while there is a next page, so a list that is complete asks for nothing.\n */\n onReachEnd?: () => void;\n /** The list opened or closed. For a list that loads when it opens. */\n onOpenChange?: (open: boolean) => void;\n /** A × button, and an emptied box clears the value. */\n clearable?: boolean;\n /** Shown in muted text while nothing is chosen. Defaults to the `locale` text. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Form field name - mirrored to a hidden input so the chosen value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the text box. Only needed when there's no visible `label`. Takes\n * precedence over `label` if both are set - don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set - stops the field from growing\n * the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /** Language of the built-in texts. */\n locale?: 'pt-BR' | 'en';\n /** Override any built-in text. */\n labels?: Partial<AutocompleteLabels>;\n}\n\n/** How close to the end of the list, in rows, `onReachEnd` fires. */\nconst REACH_ROWS = 5;\n\nconst MARKS = /[̀-ͯ]/g;\nconst plain = (s: string) => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\nfunction narrow(\n options: AutocompleteOption[],\n filter: AutocompleteProps['filter'],\n query: string,\n): AutocompleteOption[] {\n if (filter === false) return options;\n const q = query.trim();\n if (!q) return options;\n if (typeof filter === 'function') return options.filter((o) => filter(o, query));\n const needle = plain(q);\n return options.filter((o) => plain(o.label).includes(needle));\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the chosen value (rendered only\n * when `name` is set - pass it, as `register()` does), the same as `Select`. A plain\n * `{...register(name)}` spread still won't validate on change: wire it through `Controller`, or\n * call the registered `onChange` yourself from `onValueChange`.\n */\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>(function Autocomplete(\n {\n label,\n hint,\n error,\n required,\n options = [],\n value: valueProp,\n defaultValue,\n onValueChange,\n filter = true,\n onSearch,\n debounce = 250,\n loading = false,\n onReachEnd,\n onOpenChange,\n clearable = true,\n placeholder,\n size = 'md',\n disabled,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n locale = 'pt-BR',\n labels,\n },\n ref,\n) {\n const reactId = React.useId();\n const rid = id || reactId;\n const listboxId = `${rid}-listbox`;\n const copy: AutocompleteLabels = { ...TEXT[locale], ...labels };\n const coarse = useCoarsePointer();\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const panelRef = React.useRef<HTMLDivElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n\n // ── value: the chosen option, with its own label ──\n const isControlled = valueProp !== undefined;\n const [inner, setInner] = React.useState<AutocompleteOption | null>(defaultValue ?? null);\n const value = isControlled ? valueProp : inner;\n const valueLabel = value?.label ?? '';\n\n // ── the text box: the chosen label, until the user types (`draft`) ──\n const [draft, setDraft] = React.useState<string | null>(null);\n const text = draft ?? valueLabel;\n const query = draft ?? '';\n\n const [open, setOpen] = React.useState(false);\n const [focused, setFocused] = React.useState(false);\n const [activeKey, setActiveKey] = React.useState<string | null>(null);\n // The active row is the chosen one only because the list opened on it, not because the user went\n // there: set by opening, cleared by the first thing the user does to the highlight.\n const activeFromOpen = React.useRef(false);\n const pick = (key: string | null) => {\n activeFromOpen.current = false;\n setActiveKey(key);\n };\n\n const visible = React.useMemo(() => narrow(options, filter, query), [options, filter, query]);\n const activeIndex = activeKey === null ? -1 : visible.findIndex((o) => o.value === activeKey && !o.disabled);\n const activeId = activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null;\n\n const rows = visible.length;\n const status = loading ? copy.loading : rows === 0 ? copy.empty : null;\n\n // ── open / close, told to the app once per change ──\n const onOpenChangeRef = useLatest(onOpenChange);\n const toldOpen = React.useRef(false);\n React.useEffect(() => {\n if (toldOpen.current === open) return;\n toldOpen.current = open;\n onOpenChangeRef.current?.(open);\n }, [open, onOpenChangeRef]);\n\n // ── search: told to the app when the query changes, debounced while typing ──\n const onSearchRef = useLatest(onSearch);\n const searchTimer = React.useRef<number | undefined>(undefined);\n const toldQuery = React.useRef('');\n React.useEffect(() => () => window.clearTimeout(searchTimer.current), []);\n const search = (q: string, immediate: boolean) => {\n window.clearTimeout(searchTimer.current);\n const run = () => {\n if (q === toldQuery.current) return;\n toldQuery.current = q;\n onSearchRef.current?.(q);\n };\n if (immediate) run();\n else searchTimer.current = window.setTimeout(run, debounce);\n };\n\n /** The box goes back to the chosen label: closes the list, drops what was typed, resets the query. */\n const settle = () => {\n setOpen(false);\n setDraft(null);\n search('', true);\n };\n\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef,\n itemCount: rows + (status ? 1 : 0),\n onDismiss: () => settle(),\n });\n // The chosen row can arrive after the list opened (a list that loads when it opens, on the page around\n // the chosen row). It is brought into view then, unless the user has already scrolled the list away\n // from the top: a user paging down for the next page is not carried off to a row that just landed.\n useRevealActive(open, activeId, place, revealInList, (el) => !activeFromOpen.current || (el.parentElement?.scrollTop ?? 0) === 0);\n\n // ── pagination: ask for more once the list is near its end ──\n const onReachEndRef = useLatest(onReachEnd);\n const askedFor = React.useRef<string | null>(null);\n // What the list is, for \"once per size\": a new search that happens to return as many rows is a new list.\n const shape = options.length + '|' + (options[0]?.value ?? '') + '|' + (options[options.length - 1]?.value ?? '');\n useIsoLayoutEffect(() => {\n if (!open) {\n askedFor.current = null;\n return;\n }\n const list = listRef.current;\n if (!list || rows === 0) return;\n const check = () => {\n if (loading || !onReachEndRef.current || askedFor.current === shape) return;\n const remaining = list.scrollHeight - list.scrollTop - list.clientHeight;\n if (remaining > (list.scrollHeight / rows) * REACH_ROWS) return;\n askedFor.current = shape;\n onReachEndRef.current();\n };\n check();\n list.addEventListener('scroll', check, { passive: true });\n return () => list.removeEventListener('scroll', check);\n }, [open, loading, shape, place, rows, onReachEndRef]);\n\n // A new search starts at the top.\n const firstValue = options[0]?.value;\n useIsoLayoutEffect(() => {\n if (draft !== null && listRef.current) listRef.current.scrollTop = 0;\n }, [draft, firstValue]);\n\n // iOS keeps the keyboard (and the field) up when you tap on plain page: close on any press outside.\n useOutsidePress(open, [boxRef, panelRef], () => settle());\n\n // ── choosing ──\n const firstEnabledKey = () => visible.find((o) => !o.disabled)?.value ?? null;\n const lastEnabledKey = () => {\n for (let i = rows - 1; i >= 0; i--) if (!visible[i].disabled) return visible[i].value;\n return null;\n };\n const move = (dir: 1 | -1) => {\n let i = activeIndex < 0 ? (dir === 1 ? -1 : rows) : activeIndex;\n for (let step = 0; step < rows; step++) {\n i += dir;\n if (i < 0 || i >= rows) return; // the ends are walls, not a loop: a paged list has no \"wrap\"\n if (!visible[i].disabled) {\n pick(visible[i].value);\n return;\n }\n }\n };\n\n const choose = (o: AutocompleteOption) => {\n if (o.disabled) return;\n if (!isControlled) setInner(o);\n onValueChange?.(o);\n setOpen(false);\n setDraft(null);\n search('', true);\n // On a phone the keyboard goes with the choice.\n if (coarse) inputRef.current?.blur();\n };\n const clear = () => {\n if (value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n setDraft(''); // empty at once, even if the app takes a moment to take the value away\n search('', true);\n inputRef.current?.focus();\n };\n\n const selectedKey = value?.value;\n // Opening starts on the chosen row. If it is not in the list *yet* because the list is empty (it\n // loads when it opens), it stays the active one so it is revealed when it arrives. With rows on screen\n // that do not include it, it is not chased: the list is not moved under the user later.\n const startKey = (fallback: string | null) =>\n selectedKey !== undefined && (rows === 0 || visible.some((o) => o.value === selectedKey)) ? selectedKey : fallback;\n const openFromPointer = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(null));\n setOpen(true);\n };\n const openFromKey = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(firstEnabledKey()));\n setOpen(true);\n };\n\n const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const next = e.currentTarget.value;\n setDraft(next);\n // Filtering here, the first match is ready for Enter. A server search has not answered yet:\n // an Enter now would pick a row of the old answer, so nothing is active until the user moves.\n pick(filter === false ? null : narrow(options, filter, next).find((o) => !o.disabled)?.value ?? null);\n setOpen(true);\n if (next === '' && clearable && value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n search(next, false);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.nativeEvent.isComposing) return; // an IME is still composing the text\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) openFromKey();\n else move(1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) openFromKey();\n else move(-1);\n return;\n case 'Home':\n case 'End':\n if (open) {\n e.preventDefault();\n pick(e.key === 'Home' ? firstEnabledKey() : lastEnabledKey());\n }\n return;\n case 'Enter':\n // Closed: let the form have its Enter. Open: it is for the list, never a submit.\n if (open) {\n e.preventDefault();\n if (activeIndex >= 0) choose(visible[activeIndex]);\n }\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n settle();\n }\n return;\n default:\n }\n };\n\n // Select the text on the way in, so typing replaces the label instead of appending to it. The click\n // that gave the focus would put the caret back, hence the second select.\n const selectOnClick = React.useRef(false);\n\n const fieldAria = fieldA11y(rid, { hint, error, required });\n const rowPadY = menuRowPadY(coarse, size);\n const fontSize = size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)';\n const showClear = clearable && !disabled && text !== '';\n\n const list = (\n <div\n ref={panelRef}\n // Keeps the focus in the text box: pressing the list (or its scrollbar) must not blur it.\n onMouseDown={(e) => e.preventDefault()}\n style={sx({\n ...menuSurfaceStyle(size),\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n maxHeight: place?.maxH,\n ...(place?.strategy === 'fixed'\n ? {\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n zIndex: 1100,\n }\n : {\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place?.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n zIndex: 100,\n }),\n })}\n >\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel ?? label}\n aria-busy={loading || undefined}\n tabIndex={-1}\n style={sx({\n ...menuListStyle,\n position: 'relative', // so an option's offsetTop is measured from the list\n flex: '1 1 auto',\n minHeight: 0,\n padding: rows ? 'var(--space-1)' : 0,\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {visible.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === selectedKey}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n // Pointer *move*, not enter: a list that scrolls under a still mouse (the keyboard\n // revealing a row) must not hand the highlight to whatever slid beneath it.\n onPointerMove={() => !o.disabled && pick(o.value)}\n onClick={() => choose(o)}\n />\n ))}\n </ul>\n {status && (\n // Loading is a lone spinner, no text and no rule above it: a screen reader gets the words from the\n // live region below, and this is for the eye. \"No results\" is the same row with words.\n <div\n aria-hidden=\"true\"\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: coarse ? 44 : undefined,\n padding: 'var(--space-3)',\n color: 'var(--text-muted)',\n fontSize: coarse ? 'var(--text-base)' : 'var(--text-sm)',\n })}\n >\n {loading ? (\n <span\n style={sx({\n flex: '0 0 auto',\n width: 18,\n height: 18,\n borderRadius: '999px',\n border: '2px solid var(--border-default)',\n borderTopColor: 'var(--text-brand)',\n animation: 'sereno-spin .7s linear infinite',\n })}\n />\n ) : (\n status\n )}\n </div>\n )}\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div style={sx({ position: 'relative', width: '100%' })}>\n <div\n ref={boxRef}\n // The padding around the text is part of the field: pressing it puts the caret in the box.\n onMouseDown={(e) => {\n if (e.target === inputRef.current || disabled) return;\n e.preventDefault();\n inputRef.current?.focus();\n }}\n style={sx({ ...fieldBoxStyle(size, !!error, focused || open, !!disabled), cursor: disabled ? 'not-allowed' : 'text' })}\n >\n <input\n ref={inputRef}\n id={rid}\n type=\"text\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeId ? activeId : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n // A text box that looks like a name or an address draws the browser's autofill and the\n // password managers. Best effort: Chrome ignores `autoComplete=\"off\"`, and Bitwarden only\n // honors its attribute when the user turned that option on.\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n enterKeyHint=\"done\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-bwignore=\"true\"\n data-form-type=\"other\"\n disabled={disabled}\n placeholder={placeholder ?? copy.placeholder}\n value={text}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onFocus={(e) => {\n setFocused(true);\n selectOnClick.current = true;\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n setFocused(false);\n if (boxRef.current?.contains(e.relatedTarget as Node | null)) return;\n settle();\n }}\n onClick={(e) => {\n const el = e.currentTarget;\n if (selectOnClick.current && el.selectionStart === el.selectionEnd) el.select();\n selectOnClick.current = false;\n if (!open) openFromPointer();\n }}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding - the box's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize,\n lineHeight: 1.2,\n textOverflow: 'ellipsis',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n })}\n />\n {showClear && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n aria-label={copy.clear}\n onMouseDown={(e) => e.preventDefault()}\n onClick={clear}\n >\n <X size={16} strokeWidth={2} />\n </button>\n )}\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={open ? copy.close : copy.open}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n inputRef.current?.focus({ preventScroll: true });\n if (open) settle();\n else openFromPointer();\n }}\n style={sx({\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </button>\n </div>\n\n {open && place && place.strategy === 'inline' && list}\n {open && place && place.strategy === 'fixed' && createPortal(list, document.body)}\n\n {/* Always rendered, so the change of its text is what a screen reader announces. */}\n <div role=\"status\" aria-live=\"polite\" style={srOnlyStyle}>\n {open ? (loading ? copy.loading : rows === 0 ? copy.empty : copy.results(rows)) : ''}\n </div>\n </div>\n {name && <input ref={ref} type=\"hidden\" name={name} value={value?.value ?? ''} />}\n </Field>\n );\n});\n\nAutocomplete.displayName = 'Autocomplete';\n"],"mappings":";AAkbI,SA6CM,KA7CN;AAhbJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa,SAAS;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AAC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UAAU;AAAA,gBACV;AAAA,gBACA,cAAY,OAAO,KAAK,QAAQ,KAAK;AAAA,gBACrC,aAAa,CAAC,MAAM,EAAE,eAAe;AAAA,gBACrC,SAAS,MAAM;AACb,2BAAS,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;AAC/C,sBAAI,KAAM,QAAO;AAAA,sBACZ,iBAAgB;AAAA,gBACvB;AAAA,gBACA,OAAO,GAAG;AAAA,kBACR,YAAY;AAAA,kBACZ,WAAW,OAAO,mBAAmB;AAAA,gBACvC,CAAC;AAAA,gBAED,8BAAC,eAAY,MAAM,IAAI,aAAa,MAAM;AAAA;AAAA,YAC5C;AAAA;AAAA;AAAA,MACF;AAAA,MAEC,QAAQ,SAAS,MAAM,aAAa,YAAY;AAAA,MAChD,QAAQ,SAAS,MAAM,aAAa,WAAW,aAAa,MAAM,SAAS,IAAI;AAAA,MAGhF,oBAAC,SAAI,MAAK,UAAS,aAAU,UAAS,OAAO,aAC1C,iBAAQ,UAAU,KAAK,UAAU,SAAS,IAAI,KAAK,QAAQ,KAAK,QAAQ,IAAI,IAAK,IACpF;AAAA,OACF;AAAA,IACC,QAAQ,oBAAC,WAAM,KAAU,MAAK,UAAS,MAAY,OAAO,OAAO,SAAS,IAAI;AAAA,KACjF;AAEJ,CAAC;AAED,aAAa,cAAc;","names":["Autocomplete","list"]}
1
+ {"version":3,"sources":["../../src/forms/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { ChevronDown, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { srOnlyStyle } from '../_internal/srOnly';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useLatest } from '../_internal/useLatest';\nimport { useCoarsePointer } from '../_internal/useCoarsePointer';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { revealInList, useRevealActive } from '../_internal/useRevealActive';\nimport { MenuOption, menuListStyle, menuRowPadY, menuSurfaceStyle } from '../_internal/MenuOption';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\nimport { fieldBoxProps } from './_internal/fieldFrame';\n\nexport interface AutocompleteOption {\n value: string;\n label: string;\n disabled?: boolean;\n}\n\n/** Every string the component says. Defaults come from `locale`; pass `labels` to change some. */\nexport interface AutocompleteLabels {\n /** Placeholder of the text box while nothing is chosen. */\n placeholder: string;\n /** aria-label of the clear (×) button. */\n clear: string;\n /** aria-label of the chevron button while the list is closed. */\n open: string;\n /** aria-label of the chevron button while the list is open. */\n close: string;\n /** What a screen reader hears while `loading` (the list itself shows only a spinner). */\n loading: string;\n /** The row shown when no option is left to show. */\n empty: string;\n /** What a screen reader hears when the list changes size. */\n results: (count: number) => string;\n}\n\nconst TEXT: Record<'pt-BR' | 'en', AutocompleteLabels> = {\n 'pt-BR': {\n placeholder: 'Buscar…',\n clear: 'Limpar seleção',\n open: 'Abrir lista',\n close: 'Fechar lista',\n loading: 'Carregando…',\n empty: 'Nenhum resultado',\n results: (n) => (n === 1 ? '1 resultado' : n + ' resultados'),\n },\n en: {\n placeholder: 'Search…',\n clear: 'Clear selection',\n open: 'Open list',\n close: 'Close list',\n loading: 'Loading…',\n empty: 'No results',\n results: (n) => (n === 1 ? '1 result' : n + ' results'),\n },\n};\n\n/**\n * Single choice from a list you search by typing. Like `Select`, but the box is a text field: type\n * to narrow the list, pick one row, and the value is that row. For a list too long to scroll\n * (past ~12 options), or one the server searches and pages (a thousand clients, fifty at a time).\n *\n * The value is the chosen option itself, `{ value, label }`, and it carries its own label. The\n * box shows `value.label` whether or not that option is in `options` right now, which is what\n * keeps the label when the page it came from is no longer loaded. `options` is only what the list\n * shows. `onValueChange` gives the option (or `null` when cleared), not a string.\n *\n * Two kinds of search, one prop apart:\n * - the default filters `options` itself, as you type (case and accents ignored);\n * - `filter={false}` leaves the list alone and tells you what was typed (`onSearch`, debounced),\n * for a list the server already filtered.\n *\n * It is a text box, not free text: what is typed never becomes the value. Leaving the box puts the\n * chosen label back.\n */\nexport interface AutocompleteProps {\n label?: string;\n hint?: string;\n /** Error message; also turns the control red. */\n error?: string;\n required?: boolean;\n /** What the list shows now. Appending rows while it is open is fine: the list keeps its scroll. */\n options?: AutocompleteOption[];\n /** Controlled value: the chosen option, or `null` for none. */\n value?: AutocompleteOption | null;\n /** Uncontrolled initial value. */\n defaultValue?: AutocompleteOption | null;\n /** The chosen option, or `null` when the value is cleared. */\n onValueChange?: (option: AutocompleteOption | null) => void;\n /**\n * How typing narrows `options`. `true` (default): keep the rows whose label contains the text,\n * ignoring case and accents. `false`: show `options` as they are (the server did the filtering).\n * A function decides per row.\n */\n filter?: boolean | ((option: AutocompleteOption, query: string) => boolean);\n /**\n * The text to search for changed: fired as the user types (after `debounce`) and with `''` once\n * the box goes back to showing the chosen label (pick, clear, leave, Esc). Never with the label\n * itself, so it is safe to run the query here. Use it with `filter={false}`.\n */\n onSearch?: (query: string) => void;\n /** Debounce for `onSearch` while typing, in ms. */\n debounce?: number;\n /** The list is waiting for rows: a spinner under them (or alone), the list marked busy, and a screen reader told. */\n loading?: boolean;\n /**\n * The list was scrolled to within about five rows of its end. Fires once per list size, never\n * while `loading`. Pass it only while there is a next page, so a list that is complete asks for nothing.\n */\n onReachEnd?: () => void;\n /** The list opened or closed. For a list that loads when it opens. */\n onOpenChange?: (open: boolean) => void;\n /** A × button, and an emptied box clears the value. */\n clearable?: boolean;\n /** Shown in muted text while nothing is chosen. Defaults to the `locale` text. */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Form field name - mirrored to a hidden input so the chosen value can be submitted. */\n name?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /**\n * Accessible name for the text box. Only needed when there's no visible `label`. Takes\n * precedence over `label` if both are set - don't pass both.\n */\n 'aria-label'?: string;\n /** Reserve the hint/error row's height even with neither set - stops the field from growing\n * the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n /** Language of the built-in texts. */\n locale?: 'pt-BR' | 'en';\n /** Override any built-in text. */\n labels?: Partial<AutocompleteLabels>;\n}\n\n/** How close to the end of the list, in rows, `onReachEnd` fires. */\nconst REACH_ROWS = 5;\n\nconst MARKS = /[̀-ͯ]/g;\nconst plain = (s: string) => s.normalize('NFD').replace(MARKS, '').toLowerCase();\n\nfunction narrow(\n options: AutocompleteOption[],\n filter: AutocompleteProps['filter'],\n query: string,\n): AutocompleteOption[] {\n if (filter === false) return options;\n const q = query.trim();\n if (!q) return options;\n if (typeof filter === 'function') return options.filter((o) => filter(o, query));\n const needle = plain(q);\n return options.filter((o) => plain(o.label).includes(needle));\n}\n\n/**\n * `ref` reaches the hidden `<input type=\"hidden\">` that mirrors the chosen value (rendered only\n * when `name` is set - pass it, as `register()` does), the same as `Select`. A plain\n * `{...register(name)}` spread still won't validate on change: wire it through `Controller`, or\n * call the registered `onChange` yourself from `onValueChange`.\n */\nexport const Autocomplete = React.forwardRef<HTMLInputElement, AutocompleteProps>(function Autocomplete(\n {\n label,\n hint,\n error,\n required,\n options = [],\n value: valueProp,\n defaultValue,\n onValueChange,\n filter = true,\n onSearch,\n debounce = 250,\n loading = false,\n onReachEnd,\n onOpenChange,\n clearable = true,\n placeholder,\n size = 'md',\n disabled,\n name,\n id,\n containerStyle,\n 'aria-label': ariaLabel,\n preserveHelperSpace,\n locale = 'pt-BR',\n labels,\n },\n ref,\n) {\n const reactId = React.useId();\n const rid = id || reactId;\n const listboxId = `${rid}-listbox`;\n const copy: AutocompleteLabels = { ...TEXT[locale], ...labels };\n const coarse = useCoarsePointer();\n\n const inputRef = React.useRef<HTMLInputElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const panelRef = React.useRef<HTMLDivElement>(null);\n const listRef = React.useRef<HTMLUListElement>(null);\n\n // ── value: the chosen option, with its own label ──\n const isControlled = valueProp !== undefined;\n const [inner, setInner] = React.useState<AutocompleteOption | null>(defaultValue ?? null);\n const value = isControlled ? valueProp : inner;\n const valueLabel = value?.label ?? '';\n\n // ── the text box: the chosen label, until the user types (`draft`) ──\n const [draft, setDraft] = React.useState<string | null>(null);\n const text = draft ?? valueLabel;\n const query = draft ?? '';\n\n const [open, setOpen] = React.useState(false);\n const [activeKey, setActiveKey] = React.useState<string | null>(null);\n // The active row is the chosen one only because the list opened on it, not because the user went\n // there: set by opening, cleared by the first thing the user does to the highlight.\n const activeFromOpen = React.useRef(false);\n const pick = (key: string | null) => {\n activeFromOpen.current = false;\n setActiveKey(key);\n };\n\n const visible = React.useMemo(() => narrow(options, filter, query), [options, filter, query]);\n const activeIndex = activeKey === null ? -1 : visible.findIndex((o) => o.value === activeKey && !o.disabled);\n const activeId = activeIndex >= 0 ? `${rid}-opt-${activeIndex}` : null;\n\n const rows = visible.length;\n const status = loading ? copy.loading : rows === 0 ? copy.empty : null;\n\n // ── open / close, told to the app once per change ──\n const onOpenChangeRef = useLatest(onOpenChange);\n const toldOpen = React.useRef(false);\n React.useEffect(() => {\n if (toldOpen.current === open) return;\n toldOpen.current = open;\n onOpenChangeRef.current?.(open);\n }, [open, onOpenChangeRef]);\n\n // ── search: told to the app when the query changes, debounced while typing ──\n const onSearchRef = useLatest(onSearch);\n const searchTimer = React.useRef<number | undefined>(undefined);\n const toldQuery = React.useRef('');\n React.useEffect(() => () => window.clearTimeout(searchTimer.current), []);\n const search = (q: string, immediate: boolean) => {\n window.clearTimeout(searchTimer.current);\n const run = () => {\n if (q === toldQuery.current) return;\n toldQuery.current = q;\n onSearchRef.current?.(q);\n };\n if (immediate) run();\n else searchTimer.current = window.setTimeout(run, debounce);\n };\n\n /** The box goes back to the chosen label: closes the list, drops what was typed, resets the query. */\n const settle = () => {\n setOpen(false);\n setDraft(null);\n search('', true);\n };\n\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef,\n itemCount: rows + (status ? 1 : 0),\n onDismiss: () => settle(),\n });\n // The chosen row can arrive after the list opened (a list that loads when it opens, on the page around\n // the chosen row). It is brought into view then, unless the user has already scrolled the list away\n // from the top: a user paging down for the next page is not carried off to a row that just landed.\n useRevealActive(open, activeId, place, revealInList, (el) => !activeFromOpen.current || (el.parentElement?.scrollTop ?? 0) === 0);\n\n // ── pagination: ask for more once the list is near its end ──\n const onReachEndRef = useLatest(onReachEnd);\n const askedFor = React.useRef<string | null>(null);\n // What the list is, for \"once per size\": a new search that happens to return as many rows is a new list.\n const shape = options.length + '|' + (options[0]?.value ?? '') + '|' + (options[options.length - 1]?.value ?? '');\n useIsoLayoutEffect(() => {\n if (!open) {\n askedFor.current = null;\n return;\n }\n const list = listRef.current;\n if (!list || rows === 0) return;\n const check = () => {\n if (loading || !onReachEndRef.current || askedFor.current === shape) return;\n const remaining = list.scrollHeight - list.scrollTop - list.clientHeight;\n if (remaining > (list.scrollHeight / rows) * REACH_ROWS) return;\n askedFor.current = shape;\n onReachEndRef.current();\n };\n check();\n list.addEventListener('scroll', check, { passive: true });\n return () => list.removeEventListener('scroll', check);\n }, [open, loading, shape, place, rows, onReachEndRef]);\n\n // A new search starts at the top.\n const firstValue = options[0]?.value;\n useIsoLayoutEffect(() => {\n if (draft !== null && listRef.current) listRef.current.scrollTop = 0;\n }, [draft, firstValue]);\n\n // iOS keeps the keyboard (and the field) up when you tap on plain page: close on any press outside.\n useOutsidePress(open, [boxRef, panelRef], () => settle());\n\n // ── choosing ──\n const firstEnabledKey = () => visible.find((o) => !o.disabled)?.value ?? null;\n const lastEnabledKey = () => {\n for (let i = rows - 1; i >= 0; i--) if (!visible[i].disabled) return visible[i].value;\n return null;\n };\n const move = (dir: 1 | -1) => {\n let i = activeIndex < 0 ? (dir === 1 ? -1 : rows) : activeIndex;\n for (let step = 0; step < rows; step++) {\n i += dir;\n if (i < 0 || i >= rows) return; // the ends are walls, not a loop: a paged list has no \"wrap\"\n if (!visible[i].disabled) {\n pick(visible[i].value);\n return;\n }\n }\n };\n\n const choose = (o: AutocompleteOption) => {\n if (o.disabled) return;\n if (!isControlled) setInner(o);\n onValueChange?.(o);\n setOpen(false);\n setDraft(null);\n search('', true);\n // On a phone the keyboard goes with the choice.\n if (coarse) inputRef.current?.blur();\n };\n const clear = () => {\n if (value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n setDraft(''); // empty at once, even if the app takes a moment to take the value away\n search('', true);\n inputRef.current?.focus();\n };\n\n const selectedKey = value?.value;\n // Opening starts on the chosen row. If it is not in the list *yet* because the list is empty (it\n // loads when it opens), it stays the active one so it is revealed when it arrives. With rows on screen\n // that do not include it, it is not chased: the list is not moved under the user later.\n const startKey = (fallback: string | null) =>\n selectedKey !== undefined && (rows === 0 || visible.some((o) => o.value === selectedKey)) ? selectedKey : fallback;\n const openFromPointer = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(null));\n setOpen(true);\n };\n const openFromKey = () => {\n activeFromOpen.current = true;\n setActiveKey(startKey(firstEnabledKey()));\n setOpen(true);\n };\n\n const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n const next = e.currentTarget.value;\n setDraft(next);\n // Filtering here, the first match is ready for Enter. A server search has not answered yet:\n // an Enter now would pick a row of the old answer, so nothing is active until the user moves.\n pick(filter === false ? null : narrow(options, filter, next).find((o) => !o.disabled)?.value ?? null);\n setOpen(true);\n if (next === '' && clearable && value) {\n if (!isControlled) setInner(null);\n onValueChange?.(null);\n }\n search(next, false);\n };\n\n const onKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {\n if (disabled || e.nativeEvent.isComposing) return; // an IME is still composing the text\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!open) openFromKey();\n else move(1);\n return;\n case 'ArrowUp':\n e.preventDefault();\n if (!open) openFromKey();\n else move(-1);\n return;\n case 'Home':\n case 'End':\n if (open) {\n e.preventDefault();\n pick(e.key === 'Home' ? firstEnabledKey() : lastEnabledKey());\n }\n return;\n case 'Enter':\n // Closed: let the form have its Enter. Open: it is for the list, never a submit.\n if (open) {\n e.preventDefault();\n if (activeIndex >= 0) choose(visible[activeIndex]);\n }\n return;\n case 'Escape':\n if (open) {\n e.preventDefault();\n // Only the list closes: a Dialog around the field keeps its own Esc for the next press.\n // (`stopImmediate...` too: React may listen on `document`, where the Dialog listens as well.)\n e.stopPropagation();\n e.nativeEvent.stopImmediatePropagation();\n settle();\n }\n return;\n default:\n }\n };\n\n // Select the text on the way in, so typing replaces the label instead of appending to it. The click\n // that gave the focus would put the caret back, hence the second select.\n const selectOnClick = React.useRef(false);\n\n const fieldAria = fieldA11y(rid, { hint, error, required });\n const rowPadY = menuRowPadY(coarse, size);\n const fontSize = size === 'sm' ? 'var(--text-sm)' : 'var(--text-base)';\n const showClear = clearable && !disabled && text !== '';\n\n const list = (\n <div\n ref={panelRef}\n // Keeps the focus in the text box: pressing the list (or its scrollbar) must not blur it.\n onMouseDown={(e) => e.preventDefault()}\n style={sx({\n ...menuSurfaceStyle(size),\n display: 'flex',\n flexDirection: 'column',\n overflow: 'hidden',\n maxHeight: place?.maxH,\n ...(place?.strategy === 'fixed'\n ? {\n position: 'fixed',\n top: place.top,\n left: place.left,\n width: place.width,\n ...(place.above ? { transform: 'translateY(-100%)' } : null),\n zIndex: 1100,\n }\n : {\n position: 'absolute',\n left: 0,\n right: 0,\n ...(place?.above ? { bottom: 'calc(100% + 6px)' } : { top: 'calc(100% + 6px)' }),\n zIndex: 100,\n }),\n })}\n >\n <ul\n ref={listRef}\n id={listboxId}\n role=\"listbox\"\n aria-label={ariaLabel ?? label}\n aria-busy={loading || undefined}\n tabIndex={-1}\n style={sx({\n ...menuListStyle,\n position: 'relative', // so an option's offsetTop is measured from the list\n flex: '1 1 auto',\n minHeight: 0,\n padding: rows ? 'var(--space-1)' : 0,\n overscrollBehavior: 'contain', // don't chain the list's scroll to the page\n })}\n >\n {visible.map((o, i) => (\n <MenuOption\n key={o.value}\n id={`${rid}-opt-${i}`}\n label={o.label}\n selected={o.value === selectedKey}\n active={i === activeIndex}\n disabled={o.disabled}\n coarse={coarse}\n padY={rowPadY}\n // Pointer *move*, not enter: a list that scrolls under a still mouse (the keyboard\n // revealing a row) must not hand the highlight to whatever slid beneath it.\n onPointerMove={() => !o.disabled && pick(o.value)}\n onClick={() => choose(o)}\n />\n ))}\n </ul>\n {status && (\n // Loading is a lone spinner, no text and no rule above it: a screen reader gets the words from the\n // live region below, and this is for the eye. \"No results\" is the same row with words.\n <div\n aria-hidden=\"true\"\n style={sx({\n flex: '0 0 auto',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: coarse ? 44 : undefined,\n padding: 'var(--space-3)',\n color: 'var(--text-muted)',\n fontSize: coarse ? 'var(--text-base)' : 'var(--text-sm)',\n })}\n >\n {loading ? (\n <span\n style={sx({\n flex: '0 0 auto',\n width: 18,\n height: 18,\n borderRadius: '999px',\n border: '2px solid var(--border-default)',\n borderTopColor: 'var(--text-brand)',\n animation: 'sereno-spin .7s linear infinite',\n })}\n />\n ) : (\n status\n )}\n </div>\n )}\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} requiredExposed htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div style={sx({ position: 'relative', width: '100%' })}>\n <div\n ref={boxRef}\n // The padding around the text is part of the field: pressing it puts the caret in the box.\n onMouseDown={(e) => {\n if (e.target === inputRef.current || disabled) return;\n e.preventDefault();\n inputRef.current?.focus();\n }}\n // The focus ring comes from the `:focus` of the text box (styles.css); only the open list is state here.\n {...fieldBoxProps(open)}\n style={sx({ ...fieldBoxStyle(size, !!error, !!disabled), cursor: disabled ? 'not-allowed' : 'text' })}\n >\n <input\n ref={inputRef}\n id={rid}\n type=\"text\"\n role=\"combobox\"\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n aria-expanded={open}\n aria-controls={open ? listboxId : undefined}\n aria-activedescendant={open && activeId ? activeId : undefined}\n aria-label={ariaLabel}\n {...fieldAria}\n // A text box that looks like a name or an address draws the browser's autofill and the\n // password managers. Best effort: Chrome ignores `autoComplete=\"off\"`, and Bitwarden only\n // honors its attribute when the user turned that option on.\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n enterKeyHint=\"done\"\n data-1p-ignore\n data-lpignore=\"true\"\n data-bwignore=\"true\"\n data-form-type=\"other\"\n disabled={disabled}\n placeholder={placeholder ?? copy.placeholder}\n value={text}\n onChange={onChange}\n onKeyDown={onKeyDown}\n onFocus={(e) => {\n selectOnClick.current = true;\n e.currentTarget.select();\n }}\n onBlur={(e) => {\n if (boxRef.current?.contains(e.relatedTarget as Node | null)) return;\n settle();\n }}\n onClick={(e) => {\n const el = e.currentTarget;\n if (selectOnClick.current && el.selectionStart === el.selectionEnd) el.select();\n selectOnClick.current = false;\n if (!open) openFromPointer();\n }}\n style={sx({\n flex: 1,\n minWidth: 0,\n margin: 0,\n padding: 0, // reset the UA input padding - the box's own padding insets it\n border: 'none',\n outline: 'none',\n background: 'transparent',\n fontFamily: 'var(--font-body)',\n fontSize,\n lineHeight: 1.2,\n textOverflow: 'ellipsis',\n color: disabled ? 'var(--text-disabled)' : 'var(--text-primary)',\n })}\n />\n {showClear && (\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n aria-label={copy.clear}\n onMouseDown={(e) => e.preventDefault()}\n onClick={clear}\n >\n <X size={16} strokeWidth={2} />\n </button>\n )}\n <button\n type=\"button\"\n className=\"ds-affix-btn\"\n tabIndex={-1}\n disabled={disabled}\n aria-label={open ? copy.close : copy.open}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n inputRef.current?.focus({ preventScroll: true });\n if (open) settle();\n else openFromPointer();\n }}\n style={sx({\n transition: 'transform var(--duration-fast) var(--ease-standard)',\n transform: open ? 'rotate(180deg)' : 'none',\n })}\n >\n <ChevronDown size={16} strokeWidth={1.75} />\n </button>\n </div>\n\n {open && place && place.strategy === 'inline' && list}\n {open && place && place.strategy === 'fixed' && createPortal(list, document.body)}\n\n {/* Always rendered, so the change of its text is what a screen reader announces. */}\n <div role=\"status\" aria-live=\"polite\" style={srOnlyStyle}>\n {open ? (loading ? copy.loading : rows === 0 ? copy.empty : copy.results(rows)) : ''}\n </div>\n </div>\n {name && <input ref={ref} type=\"hidden\" name={name} value={value?.value ?? ''} />}\n </Field>\n );\n});\n\nAutocomplete.displayName = 'Autocomplete';\n"],"mappings":";AAkbI,SA6CM,KA7CN;AAhbJ,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,aAAa,SAAS;AAC/B,SAAS,UAAU;AACnB,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AACjC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,cAAc,uBAAuB;AAC9C,SAAS,YAAY,eAAe,aAAa,wBAAwB;AACzE,SAAS,qBAAqB;AAC9B,SAAS,qBAAqB;AA0B9B,MAAM,OAAmD;AAAA,EACvD,SAAS;AAAA,IACP,aAAa;AAAA,IACb,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS,CAAC,MAAO,MAAM,IAAI,gBAAgB,IAAI;AAAA,EACjD;AAAA,EACA,IAAI;AAAA,IACF,aAAa;AAAA,IACb,OAAO;AAAA,IACP,MAAM;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS,CAAC,MAAO,MAAM,IAAI,aAAa,IAAI;AAAA,EAC9C;AACF;AAkFA,MAAM,aAAa;AAEnB,MAAM,QAAQ;AACd,MAAM,QAAQ,CAAC,MAAc,EAAE,UAAU,KAAK,EAAE,QAAQ,OAAO,EAAE,EAAE,YAAY;AAE/E,SAAS,OACP,SACA,QACA,OACsB;AACtB,MAAI,WAAW,MAAO,QAAO;AAC7B,QAAM,IAAI,MAAM,KA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cAAc;","names":["Autocomplete","list"]}
@@ -12,6 +12,7 @@ import { useOutsidePress } from "../_internal/useOutsidePress.js";
12
12
  import { CalendarGrid } from "./_internal/CalendarGrid.js";
13
13
  import { parseISODate as parseISO, toISODate as toISO } from "./_internal/calendarRange.js";
14
14
  import { fieldBoxStyle } from "./_internal/fieldBoxStyle.js";
15
+ import { fieldBoxProps } from "./_internal/fieldFrame.js";
15
16
  const TEXT = {
16
17
  "pt-BR": { placeholder: "Selecionar data", dialogLabel: "Escolher data", clearLabel: "Limpar data" },
17
18
  en: { placeholder: "Pick a date", dialogLabel: "Choose a date", clearLabel: "Clear date" }
@@ -188,7 +189,7 @@ const DatePicker = React.forwardRef(function DatePicker2({
188
189
  }
189
190
  );
190
191
  return /* @__PURE__ */ jsx(Field, { label, hint, error, required, htmlFor: rid, style: containerStyle, preserveHelperSpace, children: /* @__PURE__ */ jsxs("div", { ref: rootRef, style: { position: "relative", width: "100%" }, children: [
191
- /* @__PURE__ */ jsxs("div", { ref: boxRef, onKeyDown: onBoxKeyDown, style: fieldBoxStyle(size, !!error, open, disabled), children: [
192
+ /* @__PURE__ */ jsxs("div", { ref: boxRef, onKeyDown: onBoxKeyDown, ...fieldBoxProps(open), style: fieldBoxStyle(size, !!error, disabled), children: [
192
193
  /* @__PURE__ */ jsxs(
193
194
  "button",
194
195
  {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * The widest a calendar gets once it leaves the field's own width, i.e. when portalled out of a Dialog. Its\n * cells are square, so it is as tall as it is wide: at the width of a wide dialog field it would be a\n * 450px-tall slab that covers the field and half the window. Inline it is untouched (still the field's width).\n */\nconst PORTALLED_MAX_WIDTH = 320;\n\n/** What a keyboard can reach inside `root`, in tab order (the calendar's roving day has `tabindex=\"0\"`, the others `-1`). */\nfunction tabbables(root: HTMLElement | null): HTMLElement[] {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>('button:not(:disabled), [tabindex]')).filter((el) => el.tabIndex >= 0);\n}\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const popoverRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // Where the calendar sits. Normally a plain `position: absolute` child of\n // `rootRef` (itself `position: relative`) - the same \"inline\" strategy\n // Select's panel uses for its common case, and the same one DateTimePicker's\n // own month/year popover already uses. The browser glues it to the trigger\n // through *any* scroll (page or a nested overflow container) for free - no JS\n // measuring position, no listening for scroll/resize, and critically, it\n // never has to close on scroll the way a `position: fixed` popover computed\n // once would (that was tried first here and didn't hold up - see PR history).\n //\n // The one place that fails is inside a `position: fixed` container (a\n // Dialog): its body scrolls and clips an inline child, cutting the calendar\n // off. There `useMenuPlacement` answers 'fixed' (what Select and\n // Autocomplete already do) and the calendar is portalled to <body> at the\n // field's viewport rect, closing if the field moves. Outside a dialog nothing\n // changes: still inline, still below the field, never flipped (the hook's\n // `above` / `maxH` are not used at all: see `fitTop` for the portalled case).\n // `itemCount` is just the hook's height estimate; a calendar is not a list.\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef: popoverRef,\n itemCount: 8,\n onDismiss: () => setOpen(false),\n });\n const portalled = open && place?.strategy === 'fixed';\n\n // The hook picks \"below\" or \"above\" from a rough guess at the height, which suits a list capped at 288px but not\n // a calendar (about as tall as it is wide). So once the portalled calendar is on screen it is measured and kept\n // inside the window: under the field if it fits, else above it, else as far up as it needs (over the field rather\n // than cut off). The month changes the row count, hence the dependencies. Runs before paint: no visible jump.\n const [fitTop, setFitTop] = React.useState<number | null>(null);\n useIsoLayoutEffect(() => {\n const popover = popoverRef.current;\n const box = boxRef.current;\n if (!portalled || !popover || !box) return;\n const GAP = 6;\n const EDGE = 8;\n const field = box.getBoundingClientRect();\n const height = popover.offsetHeight;\n const viewport = window.innerHeight || document.documentElement.clientHeight || 900;\n const below = field.bottom + GAP;\n const above = field.top - GAP - height;\n setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));\n }, [portalled, place, viewYear, viewMonth]);\n\n // A press outside the field closes the calendar. The portalled calendar is outside `rootRef` in the DOM but\n // still part of the field, so both count as inside.\n useOutsidePress(open, [rootRef, popoverRef], () => setOpen(false));\n React.useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // handled: a Dialog around the field keeps its own Esc for the next press\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('keydown', onKey, true);\n return () => document.removeEventListener('keydown', onKey, true);\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 // Inline, the calendar follows the field in the DOM, so Tab walks field -> calendar -> next field on its\n // own. Portalled to the end of <body> it does not, so the focus is handed over by hand to keep that order.\n const onBoxKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab' || e.shiftKey || !portalled) return;\n const controls = tabbables(e.currentTarget);\n if (e.target !== controls[controls.length - 1]) return; // not the control the calendar follows\n const first = tabbables(popoverRef.current)[0];\n if (!first) return;\n e.preventDefault();\n first.focus();\n };\n\n const onPopoverKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab') return;\n const controls = tabbables(boxRef.current);\n const field = controls[controls.length - 1]; // the control the calendar follows in the DOM\n const inside = tabbables(e.currentTarget);\n if (e.shiftKey && e.target === inside[0]) {\n e.preventDefault();\n field?.focus();\n } else if (!e.shiftKey && e.target === inside[inside.length - 1]) {\n // Not prevented on purpose: with the focus back on the field the Tab goes on to whatever follows it.\n setOpen(false);\n field?.focus();\n }\n };\n\n // One popover, two positions (see `useMenuPlacement` above): the calendar and its look are the same.\n const renderPopover = (position: React.CSSProperties) => (\n <div\n ref={popoverRef}\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n onKeyDown={portalled ? onPopoverKeyDown : undefined}\n style={sx({\n ...position,\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 background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div ref={boxRef} onKeyDown={onBoxKeyDown} style={fieldBoxStyle(size, !!error, open, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && place?.strategy === 'inline' &&\n renderPopover({ position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0, zIndex: 20 })}\n {open && place?.strategy === 'fixed' &&\n createPortal(\n renderPopover({\n position: 'fixed',\n top: fitTop ?? place.top, // `fitTop` is measured (see above); the hook's guess only holds the first, unpainted render\n left: place.left,\n width: Math.min(place.width, PORTALLED_MAX_WIDTH),\n boxSizing: 'border-box',\n zIndex: 1100, // above the Dialog (1000), level with Select / Autocomplete's portalled lists\n }),\n document.body,\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AAmTM,cA6BI,YA7BJ;AAjTN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,UAAU,aAAa,aAAa;AAC7D,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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AA;AAAA,MAC/B;AAAA,OAEJ;AAAA,IAEC,QAAQ,OAAO,aAAa,YAC3B,cAAc,EAAE,UAAU,YAAY,KAAK,oBAAoB,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,CAAC;AAAA,IAC/F,QAAQ,OAAO,aAAa,WAC3B;AAAA,MACE,cAAc;AAAA,QACZ,UAAU;AAAA,QACV,KAAK,UAAU,MAAM;AAAA;AAAA,QACrB,MAAM,MAAM;AAAA,QACZ,OAAO,KAAK,IAAI,MAAM,OAAO,mBAAmB;AAAA,QAChD,WAAW;AAAA,QACX,QAAQ;AAAA;AAAA,MACV,CAAC;AAAA,MACD,SAAS;AAAA,IACX;AAAA,KACJ,GACF;AAEJ,CAAC;AAED,WAAW,cAAc;","names":["DatePicker"]}
1
+ {"version":3,"sources":["../../src/forms/DatePicker.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { createPortal } from 'react-dom';\nimport { Calendar as CalendarIcon, X } from 'lucide-react';\nimport { sx } from '../_internal/style';\nimport { Field } from '../_internal/Field';\nimport { fieldA11y } from '../_internal/fieldA11y';\nimport { useIsoLayoutEffect } from '../_internal/useIsoLayoutEffect';\nimport { useMenuPlacement } from '../_internal/useMenuPlacement';\nimport { useOutsidePress } from '../_internal/useOutsidePress';\nimport { CalendarGrid } from './_internal/CalendarGrid';\nimport type { CalendarDayContext, CalendarDayDots } from './_internal/calendarDots';\nimport { parseISODate as parseISO, toISODate as toISO } from './_internal/calendarRange';\nimport { fieldBoxStyle } from './_internal/fieldBoxStyle';\nimport { fieldBoxProps } from './_internal/fieldFrame';\n\nconst TEXT = {\n 'pt-BR': { placeholder: 'Selecionar data', dialogLabel: 'Escolher data', clearLabel: 'Limpar data' },\n en: { placeholder: 'Pick a date', dialogLabel: 'Choose a date', clearLabel: 'Clear date' },\n} as const;\n\n/**\n * The widest a calendar gets once it leaves the field's own width, i.e. when portalled out of a Dialog. Its\n * cells are square, so it is as tall as it is wide: at the width of a wide dialog field it would be a\n * 450px-tall slab that covers the field and half the window. Inline it is untouched (still the field's width).\n */\nconst PORTALLED_MAX_WIDTH = 320;\n\n/** What a keyboard can reach inside `root`, in tab order (the calendar's roving day has `tabindex=\"0\"`, the others `-1`). */\nfunction tabbables(root: HTMLElement | null): HTMLElement[] {\n if (!root) return [];\n return Array.from(root.querySelectorAll<HTMLElement>('button:not(:disabled), [tabindex]')).filter((el) => el.tabIndex >= 0);\n}\n\n/**\n * Imperative handle exposed via `ref` - there's no single native element\n * underneath (the trigger is a `<button>`, the value a plain ISO string in\n * React state), so `ref` can't hand back something `.value`-readable the way\n * a real `<input>` would. `focus()` is real and covers `setFocus()`-on-error;\n * reading the current value still means the `value`/`onChange` props, not the\n * ref. `onChange(value: string)` also isn't a `ChangeEvent`, so a plain\n * `{...register(name)}` spread won't work regardless - use `Controller`.\n */\nexport interface DatePickerHandle {\n focus: () => void;\n}\n\nexport interface DatePickerProps {\n label?: string;\n hint?: string;\n error?: string;\n required?: boolean;\n /** Defaults to the `locale`-appropriate text (\"Selecionar data\" / \"Pick a date\"). */\n placeholder?: string;\n size?: 'sm' | 'md' | 'lg';\n disabled?: boolean;\n /** Controlled value, ISO \"YYYY-MM-DD\". */\n value?: string;\n /** Uncontrolled initial value, ISO \"YYYY-MM-DD\". */\n defaultValue?: string;\n onChange?: (value: string) => void;\n /**\n * Earliest selectable date, ISO \"YYYY-MM-DD\". Every day before it is struck through, and the\n * calendar cannot be navigated to an earlier month or year (the previous-month arrow disables,\n * PageUp and the arrow keys stop at the edge, the month / year popover disables what is out of\n * range). An initial value or month before it opens on `min`'s month.\n */\n min?: string;\n /** Latest selectable date, ISO \"YYYY-MM-DD\". The mirror image of `min`: later days are struck through and later months and years cannot be reached. */\n max?: string;\n /**\n * Fires when the month on screen changes (the arrows, or the month / year popover), with the\n * new year and the 0-indexed month. Not when the popover opens: it opens on the month of the\n * value, or on the current one. Refresh `dayDots` / `renderDay` here.\n */\n onMonthChange?: (year: number, month: number) => void;\n /**\n * Content under each day number (a count, a note), the same as `DateTimePicker`'s. The second\n * argument says whether the day is `selected`, `today` or `unavailable`. When set, the day cells\n * grow taller to hold it.\n */\n renderDay?: (day: number, context: CalendarDayContext) => React.ReactNode;\n /**\n * The days that get a dot under their number, the same as `DateTimePicker`'s: day numbers\n * (`[3, 17]`), or an object keyed by day number for a per-dot `tone` or `label`. Day numbers of\n * the month on screen, so refresh them in `onMonthChange`.\n */\n dayDots?: CalendarDayDots;\n /** What a screen reader says for a dot with no `label` of its own. Defaults to the `locale`-appropriate text. */\n dayDotLabel?: string;\n id?: string;\n containerStyle?: React.CSSProperties;\n /** aria-label for the clear (×) button. Defaults to the `locale`-appropriate text. */\n clearLabel?: string;\n /**\n * The real Sereno product always renders pt-BR - this only exists so the\n * docs showcase can demo an English-speaking consumer without forking the\n * component. Default stays `'pt-BR'`.\n */\n locale?: 'pt-BR' | 'en';\n /** Reserve the hint/error row's height even with neither set - stops the\n * field from growing the moment a validation message appears. */\n preserveHelperSpace?: boolean;\n}\n\nfunction formatDisplay(iso: string, locale: 'pt-BR' | 'en'): string {\n const d = parseISO(iso);\n if (!d) return iso;\n return new Intl.DateTimeFormat(locale === 'en' ? 'en-US' : 'pt-BR', { day: '2-digit', month: '2-digit', year: 'numeric' }).format(\n new Date(d.year, d.month, d.day),\n );\n}\n\n/**\n * Field for picking a single date - no time, no slots (`DateTimePicker`'s\n * job). A text-field-styled trigger showing the selected date opens a\n * popover with the same calendar grid `DateTimePicker` uses (roving\n * tabindex, month/year jump - see `./_internal/CalendarGrid`), so the two\n * share every bit of calendar behavior (SS-243).\n *\n * Value contract matches the rest of the forms package: `value` /\n * `defaultValue` + `onChange(value)`, a plain ISO \"YYYY-MM-DD\" string -\n * drops in wherever `<input type=\"date\">` would go, but themed instead of\n * the browser's own, and in pt-BR by default (the real Sereno product\n * always uses it; `locale=\"en\"` exists only for docs/demo purposes). A\n * clear (×) button appears once a value is set.\n */\nexport const DatePicker = React.forwardRef<DatePickerHandle, DatePickerProps>(function DatePicker(\n {\n label,\n hint,\n error,\n required,\n placeholder,\n size = 'md',\n disabled = false,\n value,\n defaultValue,\n onChange,\n min,\n max,\n onMonthChange,\n renderDay,\n dayDots,\n dayDotLabel,\n id,\n containerStyle,\n clearLabel,\n locale = 'pt-BR',\n preserveHelperSpace,\n },\n ref,\n) {\n const copy = TEXT[locale];\n const [inner, setInner] = React.useState(defaultValue ?? '');\n const iso = value !== undefined ? value : inner;\n const parsed = parseISO(iso);\n const now = React.useMemo(() => new Date(), []);\n\n const [open, setOpen] = React.useState(false);\n // The month currently shown in the popover - resets to the value's month\n // (or today's) every time the popover opens, via the conditional mount\n // below; CalendarGrid itself only takes year/month as its *initial* view.\n const [viewYear, setViewYear] = React.useState(parsed?.year ?? now.getFullYear());\n const [viewMonth, setViewMonth] = React.useState(parsed?.month ?? now.getMonth());\n\n const rootRef = React.useRef<HTMLDivElement>(null);\n const boxRef = React.useRef<HTMLDivElement>(null);\n const popoverRef = React.useRef<HTMLDivElement>(null);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const generatedId = React.useId();\n const rid = id || generatedId;\n\n React.useImperativeHandle(ref, () => ({ focus: () => triggerRef.current?.focus() }), []);\n\n // Where the calendar sits. Normally a plain `position: absolute` child of\n // `rootRef` (itself `position: relative`) - the same \"inline\" strategy\n // Select's panel uses for its common case, and the same one DateTimePicker's\n // own month/year popover already uses. The browser glues it to the trigger\n // through *any* scroll (page or a nested overflow container) for free - no JS\n // measuring position, no listening for scroll/resize, and critically, it\n // never has to close on scroll the way a `position: fixed` popover computed\n // once would (that was tried first here and didn't hold up - see PR history).\n //\n // The one place that fails is inside a `position: fixed` container (a\n // Dialog): its body scrolls and clips an inline child, cutting the calendar\n // off. There `useMenuPlacement` answers 'fixed' (what Select and\n // Autocomplete already do) and the calendar is portalled to <body> at the\n // field's viewport rect, closing if the field moves. Outside a dialog nothing\n // changes: still inline, still below the field, never flipped (the hook's\n // `above` / `maxH` are not used at all: see `fitTop` for the portalled case).\n // `itemCount` is just the hook's height estimate; a calendar is not a list.\n const place = useMenuPlacement({\n open,\n anchorRef: boxRef,\n panelRef: popoverRef,\n itemCount: 8,\n onDismiss: () => setOpen(false),\n });\n const portalled = open && place?.strategy === 'fixed';\n\n // The hook picks \"below\" or \"above\" from a rough guess at the height, which suits a list capped at 288px but not\n // a calendar (about as tall as it is wide). So once the portalled calendar is on screen it is measured and kept\n // inside the window: under the field if it fits, else above it, else as far up as it needs (over the field rather\n // than cut off). The month changes the row count, hence the dependencies. Runs before paint: no visible jump.\n const [fitTop, setFitTop] = React.useState<number | null>(null);\n useIsoLayoutEffect(() => {\n const popover = popoverRef.current;\n const box = boxRef.current;\n if (!portalled || !popover || !box) return;\n const GAP = 6;\n const EDGE = 8;\n const field = box.getBoundingClientRect();\n const height = popover.offsetHeight;\n const viewport = window.innerHeight || document.documentElement.clientHeight || 900;\n const below = field.bottom + GAP;\n const above = field.top - GAP - height;\n setFitTop(below + height <= viewport - EDGE ? below : above >= EDGE ? above : Math.max(EDGE, viewport - EDGE - height));\n }, [portalled, place, viewYear, viewMonth]);\n\n // A press outside the field closes the calendar. The portalled calendar is outside `rootRef` in the DOM but\n // still part of the field, so both count as inside.\n useOutsidePress(open, [rootRef, popoverRef], () => setOpen(false));\n React.useEffect(() => {\n if (!open) return;\n const onKey = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n e.preventDefault(); // handled: a Dialog around the field keeps its own Esc for the next press\n setOpen(false);\n triggerRef.current?.focus();\n }\n };\n document.addEventListener('keydown', onKey, true);\n return () => document.removeEventListener('keydown', onKey, true);\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 // Inline, the calendar follows the field in the DOM, so Tab walks field -> calendar -> next field on its\n // own. Portalled to the end of <body> it does not, so the focus is handed over by hand to keep that order.\n const onBoxKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab' || e.shiftKey || !portalled) return;\n const controls = tabbables(e.currentTarget);\n if (e.target !== controls[controls.length - 1]) return; // not the control the calendar follows\n const first = tabbables(popoverRef.current)[0];\n if (!first) return;\n e.preventDefault();\n first.focus();\n };\n\n const onPopoverKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {\n if (e.key !== 'Tab') return;\n const controls = tabbables(boxRef.current);\n const field = controls[controls.length - 1]; // the control the calendar follows in the DOM\n const inside = tabbables(e.currentTarget);\n if (e.shiftKey && e.target === inside[0]) {\n e.preventDefault();\n field?.focus();\n } else if (!e.shiftKey && e.target === inside[inside.length - 1]) {\n // Not prevented on purpose: with the focus back on the field the Tab goes on to whatever follows it.\n setOpen(false);\n field?.focus();\n }\n };\n\n // One popover, two positions (see `useMenuPlacement` above): the calendar and its look are the same.\n const renderPopover = (position: React.CSSProperties) => (\n <div\n ref={popoverRef}\n role=\"dialog\"\n aria-label={label || copy.dialogLabel}\n tabIndex={-1}\n onKeyDown={portalled ? onPopoverKeyDown : undefined}\n style={sx({\n ...position,\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 background: 'var(--bg-surface)',\n border: 'var(--border-width-hairline) solid var(--border-default)',\n borderRadius: 'var(--radius-md)',\n boxShadow: 'var(--shadow-lg)',\n padding: 'var(--space-3)',\n outline: 'none',\n })}\n >\n <CalendarGrid\n year={viewYear}\n month={viewMonth}\n selectedDate={parsed && parsed.year === viewYear && parsed.month === viewMonth ? parsed.day : undefined}\n min={min}\n max={max}\n onMonthChange={(y, m) => {\n setViewYear(y);\n setViewMonth(m);\n onMonthChange?.(y, m);\n }}\n renderDay={renderDay}\n dayDots={dayDots}\n dayDotLabel={dayDotLabel}\n onSelectDate={commit}\n squareCells\n trimEmptyRows\n locale={locale}\n />\n </div>\n );\n\n return (\n <Field label={label} hint={hint} error={error} required={required} htmlFor={rid} style={containerStyle} preserveHelperSpace={preserveHelperSpace}>\n <div ref={rootRef} style={{ position: 'relative', width: '100%' }}>\n {/* The bordered box lives on this wrapper `div`, not on a `<button>`\n - the open-trigger and the clear (×) button are real, independent\n sibling buttons inside it, since a button can't nest another. */}\n <div ref={boxRef} onKeyDown={onBoxKeyDown} {...fieldBoxProps(open)} style={fieldBoxStyle(size, !!error, disabled)}>\n <button\n ref={triggerRef}\n id={rid}\n type=\"button\"\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n // Ties the trigger to the hint / error line below, so they are read when it takes focus.\n {...fieldA11y(rid, { hint, error })}\n onClick={() => (open ? setOpen(false) : openPopover())}\n style={sx({\n flex: 1,\n minWidth: 0,\n display: 'flex',\n alignItems: 'center',\n gap: 'var(--space-2)',\n border: 'none',\n background: 'transparent',\n padding: 0,\n font: 'inherit',\n color: 'inherit',\n cursor: 'inherit',\n textAlign: 'left',\n })}\n >\n <CalendarIcon size={16} strokeWidth={1.75} style={{ flex: '0 0 auto', opacity: 0.7 }} />\n <span\n style={sx({\n flex: 1,\n textAlign: 'left',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n whiteSpace: 'nowrap',\n color: iso ? 'inherit' : 'var(--text-muted)',\n })}\n >\n {iso ? formatDisplay(iso, locale) : (placeholder ?? copy.placeholder)}\n </span>\n </button>\n {iso && !disabled && (\n <button\n type=\"button\"\n aria-label={clearLabel ?? copy.clearLabel}\n onClick={(e) => {\n e.stopPropagation();\n clear();\n }}\n style={sx({\n flex: '0 0 auto',\n display: 'inline-flex',\n alignItems: 'center',\n justifyContent: 'center',\n marginRight: -4,\n padding: 4,\n border: 'none',\n borderRadius: 'var(--radius-sm)',\n background: 'transparent',\n color: 'var(--text-muted)',\n cursor: 'pointer',\n })}\n >\n <X size={14} strokeWidth={2} />\n </button>\n )}\n </div>\n\n {open && place?.strategy === 'inline' &&\n renderPopover({ position: 'absolute', top: 'calc(100% + 6px)', left: 0, right: 0, zIndex: 20 })}\n {open && place?.strategy === 'fixed' &&\n createPortal(\n renderPopover({\n position: 'fixed',\n top: fitTop ?? place.top, // `fitTop` is measured (see above); the hook's guess only holds the first, unpainted render\n left: place.left,\n width: Math.min(place.width, PORTALLED_MAX_WIDTH),\n boxSizing: 'border-box',\n zIndex: 1100, // above the Dialog (1000), level with Select / Autocomplete's portalled lists\n }),\n document.body,\n )}\n </div>\n </Field>\n );\n});\n\nDatePicker.displayName = 'DatePicker';\n"],"mappings":";AAoTM,cA6BI,YA7BJ;AAlTN,YAAY,WAAW;AACvB,SAAS,oBAAoB;AAC7B,SAAS,YAAY,cAAc,SAAS;AAC5C,SAAS,UAAU;AACnB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,uBAAuB;AAChC,SAAS,oBAAoB;AAE7B,SAAS,gBAAgB,UAAU,aAAa,aAAa;AAC7D,SAAS,qBAAqB;AAC9B,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;AAOA,MAAM,sBAAsB;AAG5B,SAAS,UAAU,MAAyC;AAC1D,MAAI,CAAC,KAAM,QAAO,CAAC;AACnB,SAAO,MAAM,KAAK,KAAK,iBAA8B,mCAAmC,CAAC,EAAE,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC;AAC5H;AAyEA,SAAS,cAAc,KAAa,QAAgC;AAClE,QAAM,IAAI,SAAS,GAAG;AACtB,MAAI,CAAC,EAAG,QAAO;AACf,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