@sereno-ds/ui 0.42.1 → 0.44.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 +16 -3
- package/dist/core/ActionCard.d.ts +1 -1
- package/dist/core/ActionCard.js +9 -8
- package/dist/core/ActionCard.js.map +1 -1
- package/dist/core/Button.d.ts +1 -9
- package/dist/core/Button.js +1 -22
- package/dist/core/Button.js.map +1 -1
- package/dist/forms/Autocomplete.js +3 -4
- package/dist/forms/Autocomplete.js.map +1 -1
- package/dist/forms/AvatarUpload.js +1 -4
- package/dist/forms/AvatarUpload.js.map +1 -1
- package/dist/forms/Checkbox.js +6 -5
- package/dist/forms/Checkbox.js.map +1 -1
- package/dist/forms/DatePicker.js +2 -1
- package/dist/forms/DatePicker.js.map +1 -1
- package/dist/forms/Input.js +5 -15
- package/dist/forms/Input.js.map +1 -1
- package/dist/forms/Radio.js +6 -5
- package/dist/forms/Radio.js.map +1 -1
- package/dist/forms/SearchInput.js.map +1 -1
- package/dist/forms/Select.js +3 -1
- package/dist/forms/Select.js.map +1 -1
- package/dist/forms/Textarea.js +6 -17
- package/dist/forms/Textarea.js.map +1 -1
- package/dist/forms/_internal/choiceVars.d.ts +9 -0
- package/dist/forms/_internal/choiceVars.js +7 -0
- package/dist/forms/_internal/choiceVars.js.map +1 -0
- package/dist/forms/_internal/fieldBoxStyle.d.ts +6 -2
- package/dist/forms/_internal/fieldBoxStyle.js +6 -4
- package/dist/forms/_internal/fieldBoxStyle.js.map +1 -1
- package/dist/forms/_internal/fieldFrame.d.ts +26 -0
- package/dist/forms/_internal/fieldFrame.js +11 -0
- package/dist/forms/_internal/fieldFrame.js.map +1 -0
- package/dist/navigation/SidebarNav.js +10 -3
- package/dist/navigation/SidebarNav.js.map +1 -1
- package/dist/navigation/_internal/SidebarNavItems.js +14 -31
- package/dist/navigation/_internal/SidebarNavItems.js.map +1 -1
- package/dist/styles.css +77 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,16 +18,29 @@ 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
|
|
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` and `
|
|
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
|
|
|
30
|
-
|
|
30
|
+
These components carry a class the stylesheet's state rules hang on:
|
|
31
|
+
|
|
32
|
+
| Component | Class | Also |
|
|
33
|
+
|---|---|---|
|
|
34
|
+
| `Button`, `IconButton` | `sereno-btn` | |
|
|
35
|
+
| `Card` | `sereno-card` | `data-interactive`, `data-clickable` |
|
|
36
|
+
| `ActionCard` | `sereno-action` | |
|
|
37
|
+
| `SidebarNav` items and sub items | `sereno-sidenav-row` | |
|
|
38
|
+
| `Checkbox`, `Radio` | `sereno-choice` on the row (the `<label>`), `sereno-check` / `sereno-radio` on the box | |
|
|
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
|
+
|
|
43
|
+
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`:
|
|
31
44
|
|
|
32
45
|
```css
|
|
33
46
|
/* a ghost button on a brand-coloured band: its hover fill vanishes on that colour */
|
|
@@ -28,6 +28,6 @@ interface ActionCardProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElem
|
|
|
28
28
|
/** `primary` is the option to steer toward, `error` a destructive one. */
|
|
29
29
|
variant?: ActionCardVariant;
|
|
30
30
|
}
|
|
31
|
-
declare function ActionCard({ title, description, icon, trailing, selected, variant, disabled, style, ...rest }: ActionCardProps): React.JSX.Element;
|
|
31
|
+
declare function ActionCard({ title, description, icon, trailing, selected, variant, disabled, className, style, ...rest }: ActionCardProps): React.JSX.Element;
|
|
32
32
|
|
|
33
33
|
export { ActionCard, type ActionCardProps, type ActionCardVariant };
|
package/dist/core/ActionCard.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ChevronRight } from "lucide-react";
|
|
4
4
|
import { sx } from "../_internal/style.js";
|
|
5
|
-
import { useInteract } from "./Button.js";
|
|
6
5
|
import { Typography } from "./Typography.js";
|
|
7
6
|
const VARIANTS = {
|
|
8
7
|
default: { tileBg: "var(--bg-subtle)", tileFg: "var(--text-secondary)", edge: "var(--border-brand)" },
|
|
@@ -18,14 +17,15 @@ function ActionCard({
|
|
|
18
17
|
selected,
|
|
19
18
|
variant = "default",
|
|
20
19
|
disabled = false,
|
|
20
|
+
className,
|
|
21
21
|
style,
|
|
22
22
|
...rest
|
|
23
23
|
}) {
|
|
24
|
-
const st = useInteract(disabled);
|
|
25
24
|
const v = VARIANTS[variant] || VARIANTS.default;
|
|
26
25
|
const on = selected === true;
|
|
27
26
|
const arrow = trailing === void 0 ? /* @__PURE__ */ jsx(ChevronRight, { size: 18, strokeWidth: 1.75, "aria-hidden": true }) : trailing;
|
|
28
|
-
const ring = on ? "0 0 0 1.5px " + v.edge : "0 0 0 1px " + (
|
|
27
|
+
const ring = on ? "0 0 0 1.5px " + v.edge : "0 0 0 1px " + (disabled ? "var(--border-subtle)" : "var(--border-default)");
|
|
28
|
+
const ringHover = on ? ring : "0 0 0 1px " + v.edge;
|
|
29
29
|
const muted = disabled ? { color: "var(--text-disabled)" } : void 0;
|
|
30
30
|
const titleStyle = disabled ? muted : v.title ? { color: v.title } : void 0;
|
|
31
31
|
return /* @__PURE__ */ jsxs(
|
|
@@ -34,9 +34,13 @@ function ActionCard({
|
|
|
34
34
|
type: "button",
|
|
35
35
|
disabled,
|
|
36
36
|
"aria-pressed": selected,
|
|
37
|
-
...st.handlers,
|
|
38
37
|
...rest,
|
|
38
|
+
className: ["sereno-action", className].filter(Boolean).join(" "),
|
|
39
39
|
style: sx({
|
|
40
|
+
"--sd-bg": "var(--bg-surface)",
|
|
41
|
+
"--sd-bg-hover": disabled ? void 0 : hoverFill(v.edge),
|
|
42
|
+
"--sd-ring": ring,
|
|
43
|
+
"--sd-ring-hover": disabled ? void 0 : ringHover,
|
|
40
44
|
display: "flex",
|
|
41
45
|
alignItems: "center",
|
|
42
46
|
gap: "var(--space-3)",
|
|
@@ -48,12 +52,9 @@ function ActionCard({
|
|
|
48
52
|
color: "inherit",
|
|
49
53
|
border: "none",
|
|
50
54
|
borderRadius: "var(--radius-card)",
|
|
51
|
-
background: !disabled && st.hover ? hoverFill(v.edge) : "var(--bg-surface)",
|
|
52
|
-
boxShadow: [ring, st.focus ? "var(--focus-ring)" : null].filter(Boolean).join(", "),
|
|
53
|
-
transform: st.press && !disabled ? "scale(var(--press-scale))" : "none",
|
|
54
55
|
cursor: disabled ? "not-allowed" : "pointer",
|
|
55
56
|
transition: "var(--transition-control)",
|
|
56
|
-
// The focus ring
|
|
57
|
+
// The focus ring is the box-shadow of `.sereno-action:focus-visible`, the same substitute `Button` and `Card` use.
|
|
57
58
|
outline: "none",
|
|
58
59
|
...style
|
|
59
60
|
}),
|
|
@@ -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 {
|
|
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,8BAA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AAQ,WAAW,gBAAgB;AAAA,QACnC,YAAY;AAAA;AAAA,QAEZ,SAAS;AAAA,QACT,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":[]}
|
package/dist/core/Button.d.ts
CHANGED
|
@@ -18,14 +18,6 @@ interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
|
18
18
|
iconRight?: React.ReactNode;
|
|
19
19
|
children?: React.ReactNode;
|
|
20
20
|
}
|
|
21
|
-
interface InteractState {
|
|
22
|
-
hover: boolean;
|
|
23
|
-
press: boolean;
|
|
24
|
-
focus: boolean;
|
|
25
|
-
handlers: React.HTMLAttributes<HTMLElement>;
|
|
26
|
-
}
|
|
27
|
-
/** Shared hover / press / focus-visible tracking used by Button, IconButton and Card. */
|
|
28
|
-
declare function useInteract(disabled: boolean): InteractState;
|
|
29
21
|
declare function Button({ variant, size, fullWidth, disabled, loading, iconLeft, iconRight, children, className, style, ...rest }: ButtonProps): React.JSX.Element;
|
|
30
22
|
|
|
31
|
-
export { Button, type ButtonProps
|
|
23
|
+
export { Button, type ButtonProps };
|
package/dist/core/Button.js
CHANGED
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
4
3
|
import { sx } from "../_internal/style.js";
|
|
5
|
-
function useInteract(disabled) {
|
|
6
|
-
const [hover, setHover] = React.useState(false);
|
|
7
|
-
const [press, setPress] = React.useState(false);
|
|
8
|
-
const [focus, setFocus] = React.useState(false);
|
|
9
|
-
const handlers = disabled ? {} : {
|
|
10
|
-
onMouseEnter: () => setHover(true),
|
|
11
|
-
onMouseLeave: () => {
|
|
12
|
-
setHover(false);
|
|
13
|
-
setPress(false);
|
|
14
|
-
},
|
|
15
|
-
onMouseDown: () => setPress(true),
|
|
16
|
-
onMouseUp: () => setPress(false),
|
|
17
|
-
onFocus: (e) => {
|
|
18
|
-
if (e.target.matches(":focus-visible")) setFocus(true);
|
|
19
|
-
},
|
|
20
|
-
onBlur: () => setFocus(false)
|
|
21
|
-
};
|
|
22
|
-
return { hover, press, focus, handlers };
|
|
23
|
-
}
|
|
24
4
|
const SIZES = {
|
|
25
5
|
sm: { h: "var(--control-height-sm)", px: "var(--space-3)", fs: "var(--text-sm)", gap: "6px" },
|
|
26
6
|
md: { h: "var(--control-height-md)", px: "var(--space-4)", fs: "var(--text-base)", gap: "8px" },
|
|
@@ -90,7 +70,6 @@ function Button({ variant = "primary", size = "md", fullWidth = false, disabled
|
|
|
90
70
|
);
|
|
91
71
|
}
|
|
92
72
|
export {
|
|
93
|
-
Button
|
|
94
|
-
useInteract
|
|
73
|
+
Button
|
|
95
74
|
};
|
|
96
75
|
//# sourceMappingURL=Button.js.map
|
package/dist/core/Button.js.map
CHANGED
|
@@ -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\
|
|
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,KAAK;AACH,aAAO,EAAE,WAAW,6BAA6B,iBAAiB,mCAAmC,kBAAkB,oCAAoC,WAAW,gCAAgC,WAAW,eAAe,WAAW,oBAAoB,iBAAiB,wBAAwB,aAAa,2BAA2B;AAAA,IAClV,KAAK;AACH,aAAO,EAAE,WAAW,gCAAgC,iBAAiB,sCAAsC,kBAAkB,uCAAuC,WAAW,mCAAmC,WAAW,yBAAyB,WAAW,mBAAmB;AAAA,IACtR,KAAK;AACH,aAAO,EAAE,WAAW,eAAe,iBAAiB,kCAAkC,WAAW,yBAAyB,WAAW,eAAe,WAAW,OAAO;AAAA,IACxK,KAAK;AACH,aAAO,EAAE,WAAW,8BAA8B,iBAAiB,oCAAoC,WAAW,iCAAiC,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;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":[]}
|
|
@@ -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
|
-
|
|
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;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AAe;AAAA,gBACrC,SAAS;AAAA,gBAET,8BAAC,KAAE,MAAM,IAAI,aAAa,GAAG;AAAA;AAAA,YAC/B;AAAA,YAEF;AAAA,cAAC;AAAA;AAAA,gBACC,MAAK;AAAA,gBACL,WAAU;AAAA,gBACV,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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,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"]}
|
|
@@ -312,15 +312,13 @@ const AvatarUpload = React.forwardRef(function AvatarUpload2({
|
|
|
312
312
|
});
|
|
313
313
|
AvatarUpload.displayName = "AvatarUpload";
|
|
314
314
|
function MenuItem({ icon, label, onClick, danger }) {
|
|
315
|
-
const [hover, setHover] = React.useState(false);
|
|
316
315
|
return /* @__PURE__ */ jsxs(
|
|
317
316
|
"button",
|
|
318
317
|
{
|
|
319
318
|
type: "button",
|
|
320
319
|
role: "menuitem",
|
|
320
|
+
className: "sereno-menuitem",
|
|
321
321
|
onClick,
|
|
322
|
-
onMouseEnter: () => setHover(true),
|
|
323
|
-
onMouseLeave: () => setHover(false),
|
|
324
322
|
style: sx({
|
|
325
323
|
display: "flex",
|
|
326
324
|
alignItems: "center",
|
|
@@ -330,7 +328,6 @@ function MenuItem({ icon, label, onClick, danger }) {
|
|
|
330
328
|
padding: "0 var(--space-3)",
|
|
331
329
|
border: "none",
|
|
332
330
|
borderRadius: "var(--radius-sm)",
|
|
333
|
-
background: hover ? "var(--bg-subtle)" : "transparent",
|
|
334
331
|
cursor: "pointer",
|
|
335
332
|
fontFamily: "var(--font-body)",
|
|
336
333
|
fontSize: "var(--text-sm)",
|