@windmorph/react 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/components/autocomplete/Autocomplete.js +1 -1
  2. package/dist/components/autocomplete/Autocomplete.js.map +1 -1
  3. package/dist/components/carousel/carousel-styles.d.ts +6 -15
  4. package/dist/components/carousel/carousel-styles.js +4 -7
  5. package/dist/components/carousel/carousel-styles.js.map +1 -1
  6. package/dist/components/checkbox/checkbox-tokens.d.ts +1 -1
  7. package/dist/components/date-picker/DatePicker.js +11 -4
  8. package/dist/components/date-picker/DatePicker.js.map +1 -1
  9. package/dist/components/date-picker/date-picker-styles.d.ts +3 -3
  10. package/dist/components/fab-menu/FabMenu.js +2 -2
  11. package/dist/components/fab-menu/FabMenu.js.map +1 -1
  12. package/dist/components/list/List.d.ts +9 -0
  13. package/dist/components/list/List.js +7 -4
  14. package/dist/components/list/List.js.map +1 -1
  15. package/dist/components/list/list-styles.js +6 -6
  16. package/dist/components/list/list-styles.js.map +1 -1
  17. package/dist/components/list/list-tokens.d.ts +1 -1
  18. package/dist/components/list/list-tokens.js +50 -0
  19. package/dist/components/list/list-tokens.js.map +1 -1
  20. package/dist/components/menu/Menu.d.ts +13 -0
  21. package/dist/components/menu/Menu.js +14 -1
  22. package/dist/components/menu/Menu.js.map +1 -1
  23. package/dist/components/navigation/NavigationRail.js +52 -15
  24. package/dist/components/navigation/NavigationRail.js.map +1 -1
  25. package/dist/components/navigation/navigation-styles.js +1 -1
  26. package/dist/components/navigation/navigation-styles.js.map +1 -1
  27. package/dist/components/search/SearchBar.js +19 -34
  28. package/dist/components/search/SearchBar.js.map +1 -1
  29. package/dist/components/search/SearchField.d.ts +111 -0
  30. package/dist/components/search/SearchField.js +128 -0
  31. package/dist/components/search/SearchField.js.map +1 -0
  32. package/dist/components/search/search-field-frame.js +36 -0
  33. package/dist/components/search/search-field-frame.js.map +1 -0
  34. package/dist/components/search/search-styles.d.ts +58 -0
  35. package/dist/components/search/search-styles.js +29 -4
  36. package/dist/components/search/search-styles.js.map +1 -1
  37. package/dist/components/select/search-list.js +8 -13
  38. package/dist/components/select/search-list.js.map +1 -1
  39. package/dist/components/slider/Slider.js +5 -1
  40. package/dist/components/slider/Slider.js.map +1 -1
  41. package/dist/components/snackbar/snackbar-tokens.d.ts +1 -1
  42. package/dist/components/text-field/TextField.js +19 -5
  43. package/dist/components/text-field/TextField.js.map +1 -1
  44. package/dist/components/text-field/text-field-styles.js +2 -2
  45. package/dist/components/text-field/text-field-styles.js.map +1 -1
  46. package/dist/components/toolbar/toolbar-styles.js +2 -2
  47. package/dist/components/toolbar/toolbar-styles.js.map +1 -1
  48. package/dist/index.d.ts +3 -2
  49. package/dist/index.js +3 -2
  50. package/dist/primitives/use-m3-interaction.js +10 -6
  51. package/dist/primitives/use-m3-interaction.js.map +1 -1
  52. package/dist/styles/generated/components.css +5 -0
  53. package/dist/styles/utilities.css +22 -15
  54. package/dist/styles.compiled.css +1 -1
  55. package/package.json +1 -1
@@ -0,0 +1,111 @@
1
+ import { Density } from "../../tokens/density.js";
2
+ import { WrapperRootDOMProps } from "../../utils/root-props.js";
3
+ import { SearchBarInputProps } from "./SearchBar.js";
4
+ import { CSSProperties, ReactElement, ReactNode, Ref } from "react";
5
+ //#region src/components/search/SearchField.d.ts
6
+ export interface SearchFieldClassNames {
7
+ /** The outer container, merged with `className`. */
8
+ root?: string;
9
+ /** The pill around the icons and the input. */
10
+ field?: string;
11
+ /** The text input. */
12
+ input?: string;
13
+ /** The leading icon slot. */
14
+ leading?: string;
15
+ /** The trailing slot, holding the clear button and `trailingIcon`. */
16
+ trailing?: string;
17
+ /** The clear button. */
18
+ clear?: string;
19
+ }
20
+ export interface SearchFieldLabels {
21
+ /** The clear button's name, also its tooltip. @default "Clear search" */
22
+ clear: string;
23
+ }
24
+ /**
25
+ * Attributes for the input, e.g. `aria-keyshortcuts`, `enterKeyHint`, `autoComplete`,
26
+ * `spellCheck`, `inputMode` or event handlers: those of {@link SearchBarInputProps}, less
27
+ * `disabled` and `autoFocus`, which are the field's own props.
28
+ */
29
+ export type SearchFieldInputProps = Omit<SearchBarInputProps, 'disabled' | 'autoFocus'>;
30
+ type Naming = {
31
+ /** The search box's accessible name. Required unless `aria-labelledby` is set. */
32
+ 'aria-label': string;
33
+ } | {
34
+ /** The id of the element that names the search box. Required unless `aria-label` is set. */
35
+ 'aria-labelledby': string;
36
+ };
37
+ interface SearchFieldOwnProps extends WrapperRootDOMProps {
38
+ /** The input's id. */
39
+ id?: string;
40
+ /** The ids of elements that describe the search, before any `inputProps['aria-describedby']`. */
41
+ 'aria-describedby'?: string;
42
+ /** The id of an element with more details about the search. */
43
+ 'aria-details'?: string;
44
+ /** The id of what the search filters, e.g. a list of results. */
45
+ 'aria-controls'?: string;
46
+ /** Controlled query. */
47
+ value?: string;
48
+ /** Initial query when uncontrolled. @default "" */
49
+ defaultValue?: string;
50
+ /** Called with the query as it changes, by typing, Escape or the clear button. */
51
+ onChange?: (value: string) => void;
52
+ /** Called with the query when the user presses Enter (the keyboard's search action). */
53
+ onSubmit?: (value: string) => void;
54
+ /** Hint text shown in the empty input, e.g. "Search settings". */
55
+ placeholder?: string;
56
+ /** Leading icon, usually a search icon, or a back button. */
57
+ leadingIcon?: ReactNode;
58
+ /**
59
+ * Trailing content after the clear button: an icon button (e.g. voice search), or an avatar
60
+ * (an `img`, drawn at 30px), as in the search bar.
61
+ */
62
+ trailingIcon?: ReactNode;
63
+ /** Replaces the clear button's icon (Material Symbols `close`). */
64
+ clearIcon?: ReactElement;
65
+ /**
66
+ * Web density, `0` to `-3`: each step takes 4px off the pill (56px at 0, 44px at -3), as on the
67
+ * other fields; icon buttons in it keep their 48px touch targets. Left out, the field takes the
68
+ * density of the nearest `ThemeProvider` or `ThemeScope`. M3 asks for density to be the
69
+ * reader's choice rather than a default, so prefer setting it there, from a setting.
70
+ * @default 0
71
+ */
72
+ density?: Density;
73
+ /** Whether the field is disabled: it takes no input and shows no clear button. */
74
+ disabled?: boolean;
75
+ /** Focus the input when the field mounts. */
76
+ autoFocus?: boolean;
77
+ /** The input element. */
78
+ inputRef?: Ref<HTMLInputElement>;
79
+ /**
80
+ * Attributes for the input. They replace the field's defaults (`enterKeyHint="search"`,
81
+ * `autoComplete="off"`, `spellCheck={false}`); event handlers run before the field's own, and
82
+ * its role, name, value and type always win.
83
+ */
84
+ inputProps?: SearchFieldInputProps;
85
+ /** Words the field shows or announces, in place of the English defaults. */
86
+ labels?: Partial<SearchFieldLabels>;
87
+ /** Ref to the root `<div>` element. */
88
+ ref?: Ref<HTMLDivElement>;
89
+ /** Classes for the root element, merged with `classNames.root`; consumer classes win. */
90
+ className?: string;
91
+ /** Inline styles for the root element. */
92
+ style?: CSSProperties;
93
+ /** Classes for each part, by slot. */
94
+ classNames?: SearchFieldClassNames;
95
+ /** `data-*` attributes, like the other DOM attributes, go to the root. */
96
+ [data: `data-${string}`]: string | number | boolean | undefined;
97
+ }
98
+ export type SearchFieldProps = SearchFieldOwnProps & Naming;
99
+ /**
100
+ * A search box that filters content in place (a settings page, a table, a list pane), drawn as
101
+ * the M3 search bar's 56px pill and filling its container. It never opens a search view: use
102
+ * `SearchBar` for suggestions or results. Escape clears the query, Enter calls `onSubmit`, and a
103
+ * clear button shows while there is text.
104
+ *
105
+ * @example
106
+ * <SearchField aria-label="Search settings" placeholder="Search settings"
107
+ * leadingIcon={<SearchIcon />} value={query} onChange={setQuery} />
108
+ */
109
+ export declare function SearchField(props: SearchFieldProps): import("react").JSX.Element;
110
+ //#endregion
111
+ //# sourceMappingURL=SearchField.d.ts.map
@@ -0,0 +1,128 @@
1
+ "use client";
2
+ import { densityAttribute } from "../../tokens/density.js";
3
+ import { cn } from "../../utils/cn.js";
4
+ import { ButtonContext, standardIconButtons } from "../button/ButtonContext.js";
5
+ import { IconButton } from "../icon-button/IconButton.js";
6
+ import { pickWidgetAria, splitRootProps } from "../../utils/root-props.js";
7
+ import { searchBarStyles, searchFieldStyles } from "./search-styles.js";
8
+ import { SearchFieldFrame } from "./search-field-frame.js";
9
+ import "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { mergeProps, useObjectRef, useSearchField } from "react-aria";
12
+ import { useControlledState } from "react-stately/useControlledState";
13
+ //#region src/components/search/SearchField.tsx
14
+ /** Material Symbols `close`. */
15
+ const ClearIcon = () => /* @__PURE__ */ jsx("svg", {
16
+ viewBox: "0 -960 960 960",
17
+ fill: "currentColor",
18
+ "aria-hidden": "true",
19
+ children: /* @__PURE__ */ jsx("path", { d: "m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" })
20
+ });
21
+ const DEFAULT_LABELS = { clear: "Clear search" };
22
+ /** Presses on these keep their own behaviour; a press anywhere else on the pill focuses the input. */
23
+ const INTERACTIVE = "input, button, a, [role=\"button\"]";
24
+ /**
25
+ * A search box that filters content in place (a settings page, a table, a list pane), drawn as
26
+ * the M3 search bar's 56px pill and filling its container. It never opens a search view: use
27
+ * `SearchBar` for suggestions or results. Escape clears the query, Enter calls `onSubmit`, and a
28
+ * clear button shows while there is text.
29
+ *
30
+ * @example
31
+ * <SearchField aria-label="Search settings" placeholder="Search settings"
32
+ * leadingIcon={<SearchIcon />} value={query} onChange={setQuery} />
33
+ */
34
+ function SearchField(props) {
35
+ const { value, defaultValue, onChange, onSubmit, placeholder, leadingIcon, trailingIcon, clearIcon, density, disabled = false, autoFocus, inputRef, inputProps: consumerInputProps, labels: labelsProp, ref, className, style, classNames, ...rest } = props;
36
+ const labels = {
37
+ ...DEFAULT_LABELS,
38
+ ...labelsProp
39
+ };
40
+ const [query, setQuery] = useControlledState(value, defaultValue ?? "", onChange);
41
+ const objectInputRef = useObjectRef(inputRef);
42
+ const { root: data, rest: own } = splitRootProps(rest, { wrapper: true });
43
+ const { id, "aria-label": label, "aria-labelledby": labelledBy, "aria-describedby": describedBy, "aria-details": details } = own;
44
+ const describedByInput = [describedBy, consumerInputProps?.["aria-describedby"]].filter(Boolean).join(" ") || void 0;
45
+ const { inputProps } = useSearchField({
46
+ id,
47
+ "aria-label": label,
48
+ "aria-labelledby": label == null ? labelledBy : void 0,
49
+ "aria-describedby": describedByInput,
50
+ "aria-details": details,
51
+ placeholder,
52
+ isDisabled: disabled,
53
+ autoFocus
54
+ }, {
55
+ value: query,
56
+ setValue: setQuery
57
+ }, objectInputRef);
58
+ const submitOnEnter = (event) => {
59
+ if (!onSubmit || event.key !== "Enter" || event.nativeEvent.isComposing) return;
60
+ event.preventDefault();
61
+ onSubmit(query);
62
+ };
63
+ const clear = () => {
64
+ setQuery("");
65
+ objectInputRef.current?.focus({ preventScroll: true });
66
+ };
67
+ const focusInput = (event) => {
68
+ if (disabled || event.button !== 0) return;
69
+ if (event.target.closest(INTERACTIVE)) return;
70
+ event.preventDefault();
71
+ objectInputRef.current?.focus();
72
+ };
73
+ const showClear = query !== "" && !disabled;
74
+ const hasTrailing = showClear || trailingIcon != null;
75
+ const styles = searchBarStyles({
76
+ hasLeading: leadingIcon != null,
77
+ hasTrailing,
78
+ disabled
79
+ });
80
+ const rootStyles = searchFieldStyles();
81
+ return /* @__PURE__ */ jsx("div", {
82
+ ...data,
83
+ ref,
84
+ style,
85
+ ...densityAttribute(density),
86
+ "data-disabled": disabled || void 0,
87
+ className: rootStyles.root({ class: cn(classNames?.root, className) }),
88
+ children: /* @__PURE__ */ jsx(ButtonContext, {
89
+ value: standardIconButtons,
90
+ children: /* @__PURE__ */ jsx(SearchFieldFrame, {
91
+ disabled,
92
+ onPointerDown: focusInput,
93
+ className: classNames?.field,
94
+ leading: leadingIcon != null && /* @__PURE__ */ jsx("span", {
95
+ "data-slot": "leading",
96
+ className: styles.leading({ class: cn(rootStyles.slot(), classNames?.leading) }),
97
+ children: leadingIcon
98
+ }),
99
+ trailing: hasTrailing && /* @__PURE__ */ jsxs("span", {
100
+ "data-slot": "trailing",
101
+ className: styles.trailing({ class: cn(rootStyles.slot(), classNames?.trailing) }),
102
+ children: [showClear && /* @__PURE__ */ jsx(IconButton, {
103
+ "aria-label": labels.clear,
104
+ icon: clearIcon ?? /* @__PURE__ */ jsx(ClearIcon, {}),
105
+ "data-slot": "clear",
106
+ preventFocusOnPress: true,
107
+ onPress: clear,
108
+ className: classNames?.clear
109
+ }), trailingIcon]
110
+ }),
111
+ children: /* @__PURE__ */ jsx("input", {
112
+ ...mergeProps({
113
+ enterKeyHint: "search",
114
+ autoComplete: "off",
115
+ spellCheck: false
116
+ }, consumerInputProps, inputProps, pickWidgetAria(own), { onKeyDown: submitOnEnter }),
117
+ ref: objectInputRef,
118
+ "data-slot": "input",
119
+ className: styles.input({ class: classNames?.input })
120
+ })
121
+ })
122
+ })
123
+ });
124
+ }
125
+ //#endregion
126
+ export { SearchField };
127
+
128
+ //# sourceMappingURL=SearchField.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SearchField.js","names":[],"sources":["../../../src/components/search/SearchField.tsx"],"sourcesContent":["'use client';\n\nimport {\n type CSSProperties,\n type KeyboardEvent,\n type PointerEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react';\nimport { mergeProps, useObjectRef, useSearchField } from 'react-aria';\nimport { useControlledState } from 'react-stately/useControlledState';\nimport { densityAttribute, type Density } from '../../tokens/density';\nimport { cn } from '../../utils/cn';\nimport { pickWidgetAria, splitRootProps, type WrapperRootDOMProps } from '../../utils/root-props';\nimport { ButtonContext, standardIconButtons } from '../button/ButtonContext';\nimport { IconButton } from '../icon-button/IconButton';\nimport type { SearchBarInputProps } from './SearchBar';\nimport { SearchFieldFrame } from './search-field-frame';\nimport { searchBarStyles, searchFieldStyles } from './search-styles';\n\n/** Material Symbols `close`. */\nconst ClearIcon = () => (\n <svg viewBox=\"0 -960 960 960\" fill=\"currentColor\" aria-hidden=\"true\">\n <path d=\"m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z\" />\n </svg>\n);\n\nexport interface SearchFieldClassNames {\n /** The outer container, merged with `className`. */\n root?: string;\n /** The pill around the icons and the input. */\n field?: string;\n /** The text input. */\n input?: string;\n /** The leading icon slot. */\n leading?: string;\n /** The trailing slot, holding the clear button and `trailingIcon`. */\n trailing?: string;\n /** The clear button. */\n clear?: string;\n}\n\nexport interface SearchFieldLabels {\n /** The clear button's name, also its tooltip. @default \"Clear search\" */\n clear: string;\n}\n\nconst DEFAULT_LABELS: SearchFieldLabels = { clear: 'Clear search' };\n\n/**\n * Attributes for the input, e.g. `aria-keyshortcuts`, `enterKeyHint`, `autoComplete`,\n * `spellCheck`, `inputMode` or event handlers: those of {@link SearchBarInputProps}, less\n * `disabled` and `autoFocus`, which are the field's own props.\n */\nexport type SearchFieldInputProps = Omit<SearchBarInputProps, 'disabled' | 'autoFocus'>;\n\ntype Naming =\n | {\n /** The search box's accessible name. Required unless `aria-labelledby` is set. */\n 'aria-label': string;\n }\n | {\n /** The id of the element that names the search box. Required unless `aria-label` is set. */\n 'aria-labelledby': string;\n };\n\ninterface SearchFieldOwnProps extends WrapperRootDOMProps {\n /** The input's id. */\n id?: string;\n /** The ids of elements that describe the search, before any `inputProps['aria-describedby']`. */\n 'aria-describedby'?: string;\n /** The id of an element with more details about the search. */\n 'aria-details'?: string;\n /** The id of what the search filters, e.g. a list of results. */\n 'aria-controls'?: string;\n /** Controlled query. */\n value?: string;\n /** Initial query when uncontrolled. @default \"\" */\n defaultValue?: string;\n /** Called with the query as it changes, by typing, Escape or the clear button. */\n onChange?: (value: string) => void;\n /** Called with the query when the user presses Enter (the keyboard's search action). */\n onSubmit?: (value: string) => void;\n /** Hint text shown in the empty input, e.g. \"Search settings\". */\n placeholder?: string;\n /** Leading icon, usually a search icon, or a back button. */\n leadingIcon?: ReactNode;\n /**\n * Trailing content after the clear button: an icon button (e.g. voice search), or an avatar\n * (an `img`, drawn at 30px), as in the search bar.\n */\n trailingIcon?: ReactNode;\n /** Replaces the clear button's icon (Material Symbols `close`). */\n clearIcon?: ReactElement;\n /**\n * Web density, `0` to `-3`: each step takes 4px off the pill (56px at 0, 44px at -3), as on the\n * other fields; icon buttons in it keep their 48px touch targets. Left out, the field takes the\n * density of the nearest `ThemeProvider` or `ThemeScope`. M3 asks for density to be the\n * reader's choice rather than a default, so prefer setting it there, from a setting.\n * @default 0\n */\n density?: Density;\n /** Whether the field is disabled: it takes no input and shows no clear button. */\n disabled?: boolean;\n /** Focus the input when the field mounts. */\n autoFocus?: boolean;\n /** The input element. */\n inputRef?: Ref<HTMLInputElement>;\n /**\n * Attributes for the input. They replace the field's defaults (`enterKeyHint=\"search\"`,\n * `autoComplete=\"off\"`, `spellCheck={false}`); event handlers run before the field's own, and\n * its role, name, value and type always win.\n */\n inputProps?: SearchFieldInputProps;\n /** Words the field shows or announces, in place of the English defaults. */\n labels?: Partial<SearchFieldLabels>;\n /** Ref to the root `<div>` element. */\n ref?: Ref<HTMLDivElement>;\n /** Classes for the root element, merged with `classNames.root`; consumer classes win. */\n className?: string;\n /** Inline styles for the root element. */\n style?: CSSProperties;\n /** Classes for each part, by slot. */\n classNames?: SearchFieldClassNames;\n /** `data-*` attributes, like the other DOM attributes, go to the root. */\n [data: `data-${string}`]: string | number | boolean | undefined;\n}\n\nexport type SearchFieldProps = SearchFieldOwnProps & Naming;\n\n/** Presses on these keep their own behaviour; a press anywhere else on the pill focuses the input. */\nconst INTERACTIVE = 'input, button, a, [role=\"button\"]';\n\n/**\n * A search box that filters content in place (a settings page, a table, a list pane), drawn as\n * the M3 search bar's 56px pill and filling its container. It never opens a search view: use\n * `SearchBar` for suggestions or results. Escape clears the query, Enter calls `onSubmit`, and a\n * clear button shows while there is text.\n *\n * @example\n * <SearchField aria-label=\"Search settings\" placeholder=\"Search settings\"\n * leadingIcon={<SearchIcon />} value={query} onChange={setQuery} />\n */\nexport function SearchField(props: SearchFieldProps) {\n const {\n value,\n defaultValue,\n onChange,\n onSubmit,\n placeholder,\n leadingIcon,\n trailingIcon,\n clearIcon,\n density,\n disabled = false,\n autoFocus,\n inputRef,\n inputProps: consumerInputProps,\n labels: labelsProp,\n ref,\n className,\n style,\n classNames,\n ...rest\n } = props;\n const labels = { ...DEFAULT_LABELS, ...labelsProp };\n const [query, setQuery] = useControlledState(value, defaultValue ?? '', onChange);\n const objectInputRef = useObjectRef(inputRef);\n const { root: data, rest: own } = splitRootProps(rest, { wrapper: true });\n const {\n id,\n 'aria-label': label,\n 'aria-labelledby': labelledBy,\n 'aria-describedby': describedBy,\n 'aria-details': details,\n } = own as {\n id?: string;\n 'aria-label'?: string;\n 'aria-labelledby'?: string;\n 'aria-describedby'?: string;\n 'aria-details'?: string;\n };\n const describedByInput =\n [describedBy, consumerInputProps?.['aria-describedby']].filter(Boolean).join(' ') || undefined;\n\n const { inputProps } = useSearchField(\n {\n id,\n 'aria-label': label,\n 'aria-labelledby': label == null ? labelledBy : undefined,\n 'aria-describedby': describedByInput,\n 'aria-details': details,\n placeholder,\n isDisabled: disabled,\n autoFocus,\n },\n { value: query, setValue: setQuery },\n objectInputRef,\n );\n\n // Enter submits, but not while an input method is composing (it confirms the composition).\n const submitOnEnter = (event: KeyboardEvent<HTMLInputElement>) => {\n if (!onSubmit || event.key !== 'Enter' || event.nativeEvent.isComposing) return;\n event.preventDefault();\n onSubmit(query);\n };\n\n const clear = () => {\n setQuery('');\n // The button goes with the text, so focus stays in the input.\n objectInputRef.current?.focus({ preventScroll: true });\n };\n\n // A press on the pill around the input (its padding, a decorative icon) puts the caret in it.\n const focusInput = (event: PointerEvent<HTMLDivElement>) => {\n if (disabled || event.button !== 0) return;\n if ((event.target as Element).closest(INTERACTIVE)) return;\n event.preventDefault();\n objectInputRef.current?.focus();\n };\n\n const showClear = query !== '' && !disabled;\n const hasTrailing = showClear || trailingIcon != null;\n const styles = searchBarStyles({\n hasLeading: leadingIcon != null,\n hasTrailing,\n disabled,\n });\n const rootStyles = searchFieldStyles();\n\n return (\n <div\n {...data}\n ref={ref}\n style={style}\n {...densityAttribute(density)}\n data-disabled={disabled || undefined}\n className={rootStyles.root({ class: cn(classNames?.root, className) })}\n >\n {/* Icon buttons in a search bar are standard (M3), not the filled default. */}\n <ButtonContext value={standardIconButtons}>\n <SearchFieldFrame\n disabled={disabled}\n onPointerDown={focusInput}\n className={classNames?.field}\n leading={\n leadingIcon != null && (\n <span\n data-slot=\"leading\"\n className={styles.leading({ class: cn(rootStyles.slot(), classNames?.leading) })}\n >\n {leadingIcon}\n </span>\n )\n }\n trailing={\n hasTrailing && (\n <span\n data-slot=\"trailing\"\n className={styles.trailing({ class: cn(rootStyles.slot(), classNames?.trailing) })}\n >\n {showClear && (\n <IconButton\n aria-label={labels.clear}\n icon={clearIcon ?? <ClearIcon />}\n data-slot=\"clear\"\n // A pointer press keeps focus (and a phone's keyboard) in the input.\n preventFocusOnPress\n onPress={clear}\n className={classNames?.clear}\n />\n )}\n {trailingIcon}\n </span>\n )\n }\n >\n <input\n {...mergeProps(\n { enterKeyHint: 'search', autoComplete: 'off', spellCheck: false },\n consumerInputProps,\n inputProps,\n pickWidgetAria(own),\n { onKeyDown: submitOnEnter },\n )}\n ref={objectInputRef}\n data-slot=\"input\"\n className={styles.input({ class: classNames?.input })}\n />\n </SearchFieldFrame>\n </ButtonContext>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,kBACJ,oBAAC,OAAD;CAAK,SAAQ;CAAiB,MAAK;CAAe,eAAY;CAC5D,UAAA,oBAAC,QAAD,EAAM,GAAE,oGAAqG,CAAA;AAC1G,CAAA;AAuBP,MAAM,iBAAoC,EAAE,OAAO,eAAe;;AAoFlE,MAAM,cAAc;;;;;;;;;;;AAYpB,SAAgB,YAAY,OAAyB;CACnD,MAAM,EACJ,OACA,cACA,UACA,UACA,aACA,aACA,cACA,WACA,SACA,WAAW,OACX,WACA,UACA,YAAY,oBACZ,QAAQ,YACR,KACA,WACA,OACA,YACA,GAAG,SACD;CACJ,MAAM,SAAS;EAAE,GAAG;EAAgB,GAAG;CAAW;CAClD,MAAM,CAAC,OAAO,YAAY,mBAAmB,OAAO,gBAAgB,IAAI,QAAQ;CAChF,MAAM,iBAAiB,aAAa,QAAQ;CAC5C,MAAM,EAAE,MAAM,MAAM,MAAM,QAAQ,eAAe,MAAM,EAAE,SAAS,KAAK,CAAC;CACxE,MAAM,EACJ,IACA,cAAc,OACd,mBAAmB,YACnB,oBAAoB,aACpB,gBAAgB,YACd;CAOJ,MAAM,mBACJ,CAAC,aAAa,qBAAqB,mBAAmB,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,KAAK,KAAA;CAEvF,MAAM,EAAE,eAAe,eACrB;EACE;EACA,cAAc;EACd,mBAAmB,SAAS,OAAO,aAAa,KAAA;EAChD,oBAAoB;EACpB,gBAAgB;EAChB;EACA,YAAY;EACZ;CACF,GACA;EAAE,OAAO;EAAO,UAAU;CAAS,GACnC,cACF;CAGA,MAAM,iBAAiB,UAA2C;EAChE,IAAI,CAAC,YAAY,MAAM,QAAQ,WAAW,MAAM,YAAY,aAAa;EACzE,MAAM,eAAe;EACrB,SAAS,KAAK;CAChB;CAEA,MAAM,cAAc;EAClB,SAAS,EAAE;EAEX,eAAe,SAAS,MAAM,EAAE,eAAe,KAAK,CAAC;CACvD;CAGA,MAAM,cAAc,UAAwC;EAC1D,IAAI,YAAY,MAAM,WAAW,GAAG;EACpC,IAAK,MAAM,OAAmB,QAAQ,WAAW,GAAG;EACpD,MAAM,eAAe;EACrB,eAAe,SAAS,MAAM;CAChC;CAEA,MAAM,YAAY,UAAU,MAAM,CAAC;CACnC,MAAM,cAAc,aAAa,gBAAgB;CACjD,MAAM,SAAS,gBAAgB;EAC7B,YAAY,eAAe;EAC3B;EACA;CACF,CAAC;CACD,MAAM,aAAa,kBAAkB;CAErC,OACE,oBAAC,OAAD;EACE,GAAI;EACC;EACE;EACP,GAAI,iBAAiB,OAAO;EAC5B,iBAAe,YAAY,KAAA;EAC3B,WAAW,WAAW,KAAK,EAAE,OAAO,GAAG,YAAY,MAAM,SAAS,EAAE,CAAC;EAGrE,UAAA,oBAAC,eAAD;GAAe,OAAO;GACpB,UAAA,oBAAC,kBAAD;IACY;IACV,eAAe;IACf,WAAW,YAAY;IACvB,SACE,eAAe,QACb,oBAAC,QAAD;KACE,aAAU;KACV,WAAW,OAAO,QAAQ,EAAE,OAAO,GAAG,WAAW,KAAK,GAAG,YAAY,OAAO,EAAE,CAAC;KAE9E,UAAA;IACG,CAAA;IAGV,UACE,eACE,qBAAC,QAAD;KACE,aAAU;KACV,WAAW,OAAO,SAAS,EAAE,OAAO,GAAG,WAAW,KAAK,GAAG,YAAY,QAAQ,EAAE,CAAC;KAFnF,UAAA,CAIG,aACC,oBAAC,YAAD;MACE,cAAY,OAAO;MACnB,MAAM,aAAa,oBAAC,WAAD,CAAY,CAAA;MAC/B,aAAU;MAEV,qBAAA;MACA,SAAS;MACT,WAAW,YAAY;KACxB,CAAA,GAEF,YACG;;IAIV,UAAA,oBAAC,SAAD;KACE,GAAI,WACF;MAAE,cAAc;MAAU,cAAc;MAAO,YAAY;KAAM,GACjE,oBACA,YACA,eAAe,GAAG,GAClB,EAAE,WAAW,cAAc,CAC7B;KACA,KAAK;KACL,aAAU;KACV,WAAW,OAAO,MAAM,EAAE,OAAO,YAAY,MAAM,CAAC;IACrD,CAAA;GACe,CAAA;EACL,CAAA;CACZ,CAAA;AAET"}
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { searchBarStyles } from "./search-styles.js";
3
+ import { jsxs } from "react/jsx-runtime";
4
+ import { mergeProps, useFocusRing } from "react-aria";
5
+ //#region src/components/search/search-field-frame.tsx
6
+ /**
7
+ * The M3 search bar's pill: the `md-comp-search-bar` tokens and the inset focus ring while its
8
+ * input has keyboard focus. `SearchBar` (collapsed and in its views), `SearchField` and a
9
+ * searchable `Select` draw it, so they can't drift; the first two wrap it in standard icon
10
+ * buttons (`standardIconButtons`), which `Select`'s search, with none, doesn't load. Not
11
+ * exported from the package.
12
+ */
13
+ function SearchFieldFrame({ tone = "default", disabled = false, className, leading, trailing, children, ...props }) {
14
+ const { isFocusVisible, focusProps } = useFocusRing({
15
+ within: true,
16
+ isTextInput: true
17
+ });
18
+ return /* @__PURE__ */ jsxs("div", {
19
+ ...mergeProps(props, focusProps),
20
+ "data-tokens": "md-comp-search-bar",
21
+ "data-focus-visible": isFocusVisible || void 0,
22
+ className: searchBarStyles({
23
+ tone,
24
+ disabled
25
+ }).field({ class: className }),
26
+ children: [
27
+ leading,
28
+ children,
29
+ trailing
30
+ ]
31
+ });
32
+ }
33
+ //#endregion
34
+ export { SearchFieldFrame };
35
+
36
+ //# sourceMappingURL=search-field-frame.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-field-frame.js","names":[],"sources":["../../../src/components/search/search-field-frame.tsx"],"sourcesContent":["'use client';\n\nimport type { HTMLAttributes, ReactNode } from 'react';\nimport { mergeProps, useFocusRing } from 'react-aria';\nimport { searchBarStyles } from './search-styles';\n\n/** What the pill draws around its input. Internal: the search bar, `SearchField` and `Select`. */\ninterface SearchFieldFrameProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {\n /** The container colour: the search bar's own, or a search app bar's. @default \"default\" */\n tone?: 'default' | 'appBar' | 'scrolled';\n /** M3's disabled colours. */\n disabled?: boolean;\n /** The leading slot, already wrapped in its `data-slot=\"leading\"` element. */\n leading?: ReactNode;\n /** The trailing slot, already wrapped in its `data-slot=\"trailing\"` element. */\n trailing?: ReactNode;\n /** The input. */\n children: ReactNode;\n}\n\n/**\n * The M3 search bar's pill: the `md-comp-search-bar` tokens and the inset focus ring while its\n * input has keyboard focus. `SearchBar` (collapsed and in its views), `SearchField` and a\n * searchable `Select` draw it, so they can't drift; the first two wrap it in standard icon\n * buttons (`standardIconButtons`), which `Select`'s search, with none, doesn't load. Not\n * exported from the package.\n */\nexport function SearchFieldFrame({\n tone = 'default',\n disabled = false,\n className,\n leading,\n trailing,\n children,\n ...props\n}: SearchFieldFrameProps) {\n // The pill shows the inset focus ring while its input has keyboard focus.\n const { isFocusVisible, focusProps } = useFocusRing({ within: true, isTextInput: true });\n return (\n <div\n {...mergeProps(props, focusProps)}\n data-tokens=\"md-comp-search-bar\"\n data-focus-visible={isFocusVisible || undefined}\n className={searchBarStyles({ tone, disabled }).field({ class: className })}\n >\n {leading}\n {children}\n {trailing}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,SAAgB,iBAAiB,EAC/B,OAAO,WACP,WAAW,OACX,WACA,SACA,UACA,UACA,GAAG,SACqB;CAExB,MAAM,EAAE,gBAAgB,eAAe,aAAa;EAAE,QAAQ;EAAM,aAAa;CAAK,CAAC;CACvF,OACE,qBAAC,OAAD;EACE,GAAI,WAAW,OAAO,UAAU;EAChC,eAAY;EACZ,sBAAoB,kBAAkB,KAAA;EACtC,WAAW,gBAAgB;GAAE;GAAM;EAAS,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,UAAU,CAAC;EAJ3E,UAAA;GAMG;GACA;GACA;EACE;;AAET"}
@@ -50,6 +50,19 @@ export declare const searchBarStyles: import("tailwind-variants").TVReturnType<{
50
50
  input: string;
51
51
  };
52
52
  };
53
+ /**
54
+ * A disabled `SearchField`: M3's disabled colours, the content `on-surface` at 38% and the
55
+ * container at 12%; forced colours draw it in `GrayText`.
56
+ */
57
+ disabled: {
58
+ true: {
59
+ field: string;
60
+ leading: string;
61
+ trailing: string;
62
+ input: string;
63
+ };
64
+ false: {};
65
+ };
53
66
  }, {
54
67
  root: string;
55
68
  field: string[];
@@ -113,6 +126,19 @@ export declare const searchBarStyles: import("tailwind-variants").TVReturnType<{
113
126
  input: string;
114
127
  };
115
128
  };
129
+ /**
130
+ * A disabled `SearchField`: M3's disabled colours, the content `on-surface` at 38% and the
131
+ * container at 12%; forced colours draw it in `GrayText`.
132
+ */
133
+ disabled: {
134
+ true: {
135
+ field: string;
136
+ leading: string;
137
+ trailing: string;
138
+ input: string;
139
+ };
140
+ false: {};
141
+ };
116
142
  }, {
117
143
  root: string;
118
144
  field: string[];
@@ -176,6 +202,19 @@ export declare const searchBarStyles: import("tailwind-variants").TVReturnType<{
176
202
  input: string;
177
203
  };
178
204
  };
205
+ /**
206
+ * A disabled `SearchField`: M3's disabled colours, the content `on-surface` at 38% and the
207
+ * container at 12%; forced colours draw it in `GrayText`.
208
+ */
209
+ disabled: {
210
+ true: {
211
+ field: string;
212
+ leading: string;
213
+ trailing: string;
214
+ input: string;
215
+ };
216
+ false: {};
217
+ };
179
218
  }, {
180
219
  root: string;
181
220
  field: string[];
@@ -191,6 +230,20 @@ export declare const searchBarStyles: import("tailwind-variants").TVReturnType<{
191
230
  fullScreenHeader: string[];
192
231
  fullScreenContent: string[];
193
232
  }>>;
233
+ /**
234
+ * Variant definitions for {@link SearchField}'s root. Its pill and the parts in it are the search
235
+ * bar's ({@link searchBarStyles}), so the two can't drift.
236
+ */
237
+ export declare const searchFieldStyles: import("tailwind-variants").TVReturnType<{}, {
238
+ root: string;
239
+ slot: string;
240
+ }, undefined, {}, {
241
+ root: string;
242
+ slot: string;
243
+ }, import("tailwind-variants").TVReturnTypeLike<{}, {
244
+ root: string;
245
+ slot: string;
246
+ }>>;
194
247
  /** Variant definitions for {@link SearchAppBar}. */
195
248
  export declare const searchAppBarStyles: import("tailwind-variants").TVReturnType<{
196
249
  scrolling: {
@@ -239,5 +292,10 @@ export type SearchBarStyleProps = VariantProps<typeof searchBarStyles>;
239
292
  * component props: their names (`hasIcon`, `isOpen`…) follow the classes and may change.
240
293
  */
241
294
  export type SearchAppBarStyleProps = VariantProps<typeof searchAppBarStyles>;
295
+ /**
296
+ * The variants of {@link searchFieldStyles}, for building on its styles. They are the recipe's keys, not
297
+ * component props: their names follow the classes and may change.
298
+ */
299
+ export type SearchFieldStyleProps = VariantProps<typeof searchFieldStyles>;
242
300
  //#endregion
243
301
  //# sourceMappingURL=search-styles.d.ts.map
@@ -9,8 +9,8 @@ const searchBarStyles = tv({
9
9
  leading: "ms-[4px] flex size-[48px] shrink-0 items-center justify-center text-[color:var(--_md-comp-search-bar-leading-icon-color)] [--md-comp-icon-button-icon-color:currentColor] [&>svg]:size-[24px]",
10
10
  trailing: ["me-[4px] flex h-[48px] min-w-[48px] shrink-0 items-center justify-center gap-[8px] px-[4px] text-[color:var(--_md-comp-search-bar-trailing-icon-color)] [--md-comp-icon-button-icon-color:currentColor]", "[&>svg]:size-[24px] [&>img]:size-[30px] [&>img]:rounded-full"],
11
11
  input: [
12
- "h-full min-w-0 flex-1 bg-transparent text-body-large text-[color:var(--_md-comp-search-bar-input-text-color)] caret-primary outline-none",
13
- "placeholder:text-on-surface-variant",
12
+ "h-full min-w-0 flex-1 bg-transparent text-body-large text-[color:var(--_md-comp-search-bar-input-text-color)] caret-primary outline-none text-ellipsis",
13
+ "placeholder:text-on-surface-variant placeholder:text-ellipsis",
14
14
  "[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none"
15
15
  ],
16
16
  scrim: [
@@ -107,6 +107,19 @@ const searchBarStyles = tv({
107
107
  textAlign: {
108
108
  start: {},
109
109
  center: { input: "text-center" }
110
+ },
111
+ /**
112
+ * A disabled `SearchField`: M3's disabled colours, the content `on-surface` at 38% and the
113
+ * container at 12%; forced colours draw it in `GrayText`.
114
+ */
115
+ disabled: {
116
+ true: {
117
+ field: "bg-on-surface/12 forced-colors:border-[GrayText]",
118
+ leading: "text-on-surface/38 forced-colors:text-[GrayText]",
119
+ trailing: "text-on-surface/38 forced-colors:text-[GrayText]",
120
+ input: "cursor-default text-on-surface/38 placeholder:text-on-surface/38 forced-colors:text-[GrayText]"
121
+ },
122
+ false: {}
110
123
  }
111
124
  },
112
125
  defaultVariants: {
@@ -114,9 +127,21 @@ const searchBarStyles = tv({
114
127
  hasLeading: false,
115
128
  hasTrailing: false,
116
129
  tone: "default",
117
- textAlign: "start"
130
+ textAlign: "start",
131
+ disabled: false
118
132
  }
119
133
  });
134
+ /**
135
+ * Variant definitions for {@link SearchField}'s root. Its pill and the parts in it are the search
136
+ * bar's ({@link searchBarStyles}), so the two can't drift.
137
+ */
138
+ const searchFieldStyles = tv({
139
+ slots: {
140
+ root: "flex h-[calc(56px+var(--md-sys-density,0)*4px)] w-full min-w-0",
141
+ slot: "max-h-full"
142
+ },
143
+ variants: {}
144
+ });
120
145
  /** Variant definitions for {@link SearchAppBar}. */
121
146
  const searchAppBarStyles = tv({
122
147
  slots: {
@@ -138,6 +163,6 @@ const searchAppBarStyles = tv({
138
163
  defaultVariants: { scrolling: false }
139
164
  });
140
165
  //#endregion
141
- export { searchAppBarStyles, searchBarStyles };
166
+ export { searchAppBarStyles, searchBarStyles, searchFieldStyles };
142
167
 
143
168
  //# sourceMappingURL=search-styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"search-styles.js","names":[],"sources":["../../../src/components/search/search-styles.ts"],"sourcesContent":["import { tv, type VariantProps } from '../../utils/tv';\n\n/*\n * Values follow Compose Material 3 (SearchBar.kt: SearchBar, AppBarWithSearch,\n * ExpandedDockedSearchBarWithGap, ExpandedFullScreenSearchBar, SearchBarDefaults.InputField;\n * SearchBar / SearchView tokens).\n *\n * Field: 56px, full corners, `surface-container-high`, 360px wide by default and at most\n * 720px. Input and placeholder `body-large`, `on-surface` / `on-surface-variant`. Icons sit\n * in 48px boxes shifted 4px inwards (leading `on-surface`, trailing `on-surface-variant`);\n * the text keeps 4px from the leading and trailing tap targets (the spec's \"Leading icon and\n * label padding (from tap target): 4dp\" and \"Label and trailing icon padding\"; Compose's\n * code leaves none), so it starts 56px in after a leading icon, 16px without one.\n *\n * Docked (with gap): the expanded field, 56px tall whatever the collapsed bar's height\n * (M3's focused search bar container), sits centred over the collapsed one and widens by 12px on\n * each side (M3 Expressive: the margins change from 24dp to 12dp when focused). It morphs from\n * the bar's bounds (position and size) on the default spatial spring and back on the same\n * spring floored at the bar, so it lands on the bar exactly; a dropdown 2px below it (12px corners,\n * `surface-container-high`; with the bar, at least 240px and at most 2/3 of the window\n * tall, per the M3 spec) slides down from half its height on the default spatial spring\n * (fast spatial back) while its content fades in over 100ms after 50ms, and its height follows\n * the results on the default spatial spring; a 32% scrim covers the page.\n *\n * Full screen, in M3 Expressive's contained style: a `surface-container-low` surface grows\n * from the bar's bounds (28px corners) to the whole window on the slow spatial spring\n * (default spatial back), clamped so nothing overshoots; the field keeps its\n * `surface-container-high` pill and moves and grows from the bar to the top, 8px down and\n * 16px from each side, and the content starts 72px down.\n *\n * In a search app bar the field is `surface-container` (`surface-container-highest` once\n * content scrolls under the bar) and fills the free space up to 312px, then half of it,\n * at most 720px (M3 app bar guidelines).\n *\n * The field's colours and corners come from the search bar's component tokens and the\n * views' from the search view's (`search-tokens.ts`, `--md-comp-search-bar-*` and\n * `--md-comp-search-view-*`); the pill, the dropdown and the full-screen view carry\n * `data-tokens`. The search app bar reads the app bar's tokens (`app-bar-tokens.ts`). A\n * consumer class still wins in `cn()`.\n *\n * Every class is written out in full so Tailwind can find it.\n */\n\nconst contentFade = [\n 'opacity-100 starting:opacity-0 data-exiting:opacity-0',\n // Compose: fade in over 100ms after 50ms (standard accelerate), out over 100ms.\n '[transition-delay:0s,50ms] data-exiting:[transition-delay:0s,0s]',\n];\n\n/** Variant definitions for {@link SearchBar}; extend them to add variants. */\nexport const searchBarStyles = tv({\n slots: {\n // The bar's height is set here alone (56px, Compose's); a consumer `h-*` resizes it.\n root: 'flex h-[56px] w-[360px] max-w-[min(720px,100%)] shrink-0',\n // The pill holding the icons and the input fills the bar.\n // Keyboard focus in the input draws Compose's inset focus ring around the pill.\n // Forced colours drop the pill's colour: a system-colour border keeps its edge.\n field: [\n 'focus-ring-inset flex h-full w-full min-w-0 items-center rounded-[var(--_md-comp-search-bar-container-shape)] text-on-surface',\n 'forced-colors:border forced-colors:border-solid forced-colors:border-[CanvasText]',\n ],\n // Icon buttons in the slots take the slot's colour (and so its icon colour token), as\n // in the app bar's slots: Compose colours the search bar's and view's leading icon\n // `on-surface` and trailing icons `on-surface-variant`, buttons included.\n leading:\n 'ms-[4px] flex size-[48px] shrink-0 items-center justify-center text-[color:var(--_md-comp-search-bar-leading-icon-color)] [--md-comp-icon-button-icon-color:currentColor] [&>svg]:size-[24px]',\n // One or two trailing icon buttons, or an avatar (30px) and an icon button (M3). Two\n // 40px buttons sit 8px apart inside 4px of padding, so their 48px targets meet edge to\n // edge within the slot (a single one is centred in 48px, as before).\n trailing: [\n 'me-[4px] flex h-[48px] min-w-[48px] shrink-0 items-center justify-center gap-[8px] px-[4px] text-[color:var(--_md-comp-search-bar-trailing-icon-color)] [--md-comp-icon-button-icon-color:currentColor]',\n '[&>svg]:size-[24px] [&>img]:size-[30px] [&>img]:rounded-full',\n ],\n input: [\n 'h-full min-w-0 flex-1 bg-transparent text-body-large text-[color:var(--_md-comp-search-bar-input-text-color)] caret-primary outline-none',\n 'placeholder:text-on-surface-variant',\n '[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none',\n ],\n scrim: [\n 'fixed inset-0 z-(--md-sys-z-scrim) bg-scrim/32 opacity-100 data-exiting:pointer-events-none',\n '[transition-property:opacity]',\n '[transition-duration:var(--md-sys-motion-spring-effects-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-effects-default-easing)]',\n 'starting:opacity-0 data-exiting:opacity-0',\n ],\n /*\n * Docked view: the panel sits over the collapsed bar and morphs from the bar's bounds\n * (`--m3-search-left/top/width/height`) to the focused field's (the `-dx/-dy/-dw/-dh`\n * deltas) as `--m3-search-progress` runs 0 → 1, as Compose lerps the layout with its\n * search bar state's progress. `--m3-search-p` is that progress floored at 0 (Compose's\n * `coerceAtLeast(0f)`): the spring may overshoot past the focused bounds on the way in,\n * but never past the bar's on the way back, so the field lands on the bar exactly.\n * Reduced motion: the progress stays at 1, so the field is at its focused size at once.\n */\n dockedPanel: [\n // Leaving, the view takes no presses: the spring's tail runs on after the field has\n // landed on the bar, and a press there ran a suggestion of the invisible dropdown.\n 'fixed z-(--md-sys-z-sheet) flex flex-col outline-none data-exiting:pointer-events-none',\n '[--m3-search-progress:1] [--m3-search-p:max(0,var(--m3-search-progress))]',\n 'motion-safe:starting:[--m3-search-progress:0] motion-safe:data-exiting:[--m3-search-progress:0]',\n 'top-[calc(var(--m3-search-top)_+_var(--m3-search-p)_*_var(--m3-search-dy))]',\n 'left-[calc(var(--m3-search-left)_+_var(--m3-search-p)_*_var(--m3-search-dx))]',\n 'w-[calc(var(--m3-search-width)_+_var(--m3-search-p)_*_var(--m3-search-dw))]',\n // Both ways on the default spatial spring (Compose's collapse spec).\n '[transition-property:--m3-search-progress]',\n '[transition-duration:var(--md-sys-motion-spring-spatial-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-spatial-default-easing)]',\n ],\n // The focused field is 56px (M3), even when the collapsed bar is resized; it grows from\n // the bar's height with the panel.\n // The full-window layer the docked view sits in (React Aria's underlay).\n underlay: 'fixed inset-0 z-(--md-sys-z-sheet) data-exiting:pointer-events-none',\n dockedHeader:\n 'flex h-[calc(var(--m3-search-height)_+_var(--m3-search-p)_*_var(--m3-search-dh))] shrink-0',\n dropdown: [\n 'mt-[2px] overflow-y-auto overscroll-contain data-resizing:overflow-y-hidden data-exiting:pointer-events-none',\n // 58px is the field and the gap above the dropdown.\n 'min-h-[min(182px,calc(66.67dvh-58px))] max-h-[calc(66.67dvh-58px)]',\n // The height follows the content (`--m3-search-content-height`, measured) within those\n // bounds, so it animates as the results change. Without the measurement (before\n // hydration, or under reduced motion) it's `auto`.\n 'h-[clamp(min(182px,calc(66.67dvh_-_58px)),var(--m3-search-content-height),calc(66.67dvh_-_58px))]',\n 'rounded-[var(--_md-comp-search-view-docked-container-shape)] bg-[var(--_md-comp-search-view-container-color)] text-on-surface',\n 'forced-colors:border forced-colors:border-solid forced-colors:border-[CanvasText]',\n // Reduced motion: it only fades.\n 'translate-y-0 motion-safe:starting:-translate-y-1/2 motion-safe:data-exiting:-translate-y-1/2',\n // The delays below cycle, so the height (third) starts at once like the slide.\n '[transition-property:translate,opacity,height]',\n '[transition-duration:var(--md-sys-motion-spring-spatial-default-duration),100ms,var(--md-sys-motion-spring-spatial-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-spatial-default-easing),cubic-bezier(0.3,0,1,1),var(--md-sys-motion-spring-spatial-default-easing)]',\n 'data-exiting:[transition-duration:var(--md-sys-motion-spring-spatial-fast-duration),100ms,var(--md-sys-motion-spring-spatial-fast-duration)]',\n 'data-exiting:[transition-timing-function:var(--md-sys-motion-spring-spatial-fast-easing),cubic-bezier(0,0,0,1),var(--md-sys-motion-spring-spatial-fast-easing)]',\n ...contentFade,\n ],\n /*\n * Full-screen view: the surface grows from the bar's bounds to the window as\n * `--m3-search-progress` runs 0 → 1, through a clip (nothing is transformed). Compose\n * clamps the full-screen progress to 0..1 (`coerceIn`), so `--m3-search-p` is clamped too:\n * the clip and the field never overshoot the window's or the bar's bounds.\n */\n fullScreenPanel: [\n 'fixed inset-0 z-(--md-sys-z-sheet) bg-[var(--_md-comp-search-view-container-color)] text-on-surface outline-none data-exiting:pointer-events-none',\n '[--m3-search-progress:1] [--m3-search-p:clamp(0,var(--m3-search-progress),1)]',\n 'motion-safe:starting:[--m3-search-progress:0] motion-safe:data-exiting:[--m3-search-progress:0]',\n '[clip-path:inset(calc((1_-_var(--m3-search-p))_*_var(--m3-search-top))_calc((1_-_var(--m3-search-p))_*_var(--m3-search-right))_calc((1_-_var(--m3-search-p))_*_var(--m3-search-bottom))_calc((1_-_var(--m3-search-p))_*_var(--m3-search-left))_round_calc((1_-_var(--m3-search-p))_*_28px))]',\n 'motion-safe:[transition-property:--m3-search-progress]',\n 'motion-safe:[transition-duration:var(--md-sys-motion-spring-spatial-slow-duration)]',\n 'motion-safe:[transition-timing-function:var(--md-sys-motion-spring-spatial-slow-easing)]',\n 'motion-safe:data-exiting:[transition-duration:var(--md-sys-motion-spring-spatial-default-duration)]',\n 'motion-safe:data-exiting:[transition-timing-function:var(--md-sys-motion-spring-spatial-default-easing)]',\n // Reduced motion: the view fades in and out over the window instead of growing.\n 'motion-reduce:starting:opacity-0 motion-reduce:data-exiting:opacity-0',\n 'motion-reduce:[transition-property:opacity]',\n 'motion-reduce:[transition-duration:var(--md-sys-motion-spring-effects-fast-duration)]',\n 'motion-reduce:[transition-timing-function:var(--md-sys-motion-spring-effects-fast-easing)]',\n ],\n // Compose's full-screen field is 56px whatever the bar's size, 8px down and 16px from each\n // side; it moves and grows there from the bar's bounds with the surface.\n fullScreenHeader: [\n 'absolute',\n 'start-[calc(var(--m3-search-start)_+_var(--m3-search-p)_*_(16px_-_var(--m3-search-start)))]',\n 'top-[calc(var(--m3-search-top)_+_var(--m3-search-p)_*_(8px_-_var(--m3-search-top)))]',\n 'w-[calc(var(--m3-search-width)_+_var(--m3-search-p)_*_(100%_-_32px_-_var(--m3-search-width)))]',\n 'h-[calc(var(--m3-search-height)_+_var(--m3-search-p)_*_(56px_-_var(--m3-search-height)))]',\n ],\n fullScreenContent: [\n 'absolute inset-x-0 top-[72px] bottom-0 overflow-y-auto overscroll-contain',\n '[transition-property:opacity] [transition-duration:100ms]',\n '[transition-timing-function:cubic-bezier(0.3,0,1,1)]',\n 'data-exiting:[transition-timing-function:cubic-bezier(0,0,0,1)]',\n ...contentFade,\n ],\n },\n variants: {\n /**\n * Inside a search app bar the bar fills the free space up to 312px, then grows to half\n * of it (M3), up to 720px.\n */\n inAppBar: { true: { root: 'w-[max(min(100%,312px),50%)]' }, false: {} },\n // 4px from a tap target (M3), else 16px from the pill's edge.\n hasLeading: { true: { input: 'ps-[4px]' }, false: { input: 'ps-[16px]' } },\n hasTrailing: { true: { input: 'pe-[4px]' }, false: { input: 'pe-[16px]' } },\n /**\n * Container colour: the bar's own; in a search app bar `surface-container`, and one\n * step higher than the bar once content scrolls under it.\n */\n tone: {\n default: { field: 'bg-[var(--_md-comp-search-bar-container-color)]' },\n appBar: { field: 'bg-surface-container' },\n scrolled: { field: 'bg-surface-container-highest' },\n },\n /** Centre the placeholder and the query while the bar is collapsed. */\n textAlign: { start: {}, center: { input: 'text-center' } },\n },\n defaultVariants: {\n inAppBar: false,\n hasLeading: false,\n hasTrailing: false,\n tone: 'default',\n textAlign: 'start',\n },\n});\n\n/** Variant definitions for {@link SearchAppBar}. */\nexport const searchAppBarStyles = tv({\n slots: {\n root: [\n 'flex min-h-[64px] w-full items-center text-on-surface',\n 'bg-[var(--_md-comp-app-bar-container-color)] data-scrolled:bg-[var(--_md-comp-app-bar-on-scroll-container-color)]',\n '[transition-property:background-color]',\n '[transition-duration:var(--md-sys-motion-spring-effects-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-effects-default-easing)]',\n ],\n // Icon buttons take each slot's content colour.\n navigation:\n 'flex shrink-0 items-center ps-[8px] pe-[4px] text-[color:var(--_md-comp-app-bar-leading-icon-color)] [--md-comp-icon-button-icon-color:currentColor]',\n // Centres the search bar in the free space, 8px from its neighbours and 4px vertically.\n search: 'flex min-w-0 flex-1 justify-center ps-[8px] pe-[8px] pt-[4px] pb-[4px]',\n actions:\n 'flex shrink-0 items-center gap-[8px] ps-[4px] pe-[8px] text-[color:var(--_md-comp-app-bar-trailing-icon-color)] [--md-comp-icon-button-icon-color:currentColor]',\n },\n variants: {\n scrolling: {\n true: { root: 'sticky top-(--m3-app-bar-offset) z-(--md-sys-z-sticky)' },\n false: {},\n },\n },\n defaultVariants: { scrolling: false },\n});\n\n/**\n * The variants of {@link searchBarStyles}, for building on its styles. They are the recipe's keys, not\n * component props: their names (`hasIcon`, `isOpen`…) follow the classes and may change.\n */\nexport type SearchBarStyleProps = VariantProps<typeof searchBarStyles>;\n/**\n * The variants of {@link searchAppBarStyles}, for building on its styles. They are the recipe's keys, not\n * component props: their names (`hasIcon`, `isOpen`…) follow the classes and may change.\n */\nexport type SearchAppBarStyleProps = VariantProps<typeof searchAppBarStyles>;\n"],"mappings":";;AA2CA,MAAM,cAAc,CAClB,yDAEA,kEACF;;AAGA,MAAa,kBAAkB,GAAG;CAChC,OAAO;EAEL,MAAM;EAIN,OAAO,CACL,iIACA,mFACF;EAIA,SACE;EAIF,UAAU,CACR,2MACA,8DACF;EACA,OAAO;GACL;GACA;GACA;EACF;EACA,OAAO;GACL;GACA;GACA;GACA;GACA;EACF;EAUA,aAAa;GAGX;GACA;GACA;GACA;GACA;GACA;GAEA;GACA;GACA;EACF;EAIA,UAAU;EACV,cACE;EACF,UAAU;GACR;GAEA;GAIA;GACA;GACA;GAEA;GAEA;GACA;GACA;GACA;GACA;GACA,GAAG;EACL;EAOA,iBAAiB;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GAEA;GACA;GACA;GACA;EACF;EAGA,kBAAkB;GAChB;GACA;GACA;GACA;GACA;EACF;EACA,mBAAmB;GACjB;GACA;GACA;GACA;GACA,GAAG;EACL;CACF;CACA,UAAU;;;;;EAKR,UAAU;GAAE,MAAM,EAAE,MAAM,+BAA+B;GAAG,OAAO,CAAC;EAAE;EAEtE,YAAY;GAAE,MAAM,EAAE,OAAO,WAAW;GAAG,OAAO,EAAE,OAAO,YAAY;EAAE;EACzE,aAAa;GAAE,MAAM,EAAE,OAAO,WAAW;GAAG,OAAO,EAAE,OAAO,YAAY;EAAE;;;;;EAK1E,MAAM;GACJ,SAAS,EAAE,OAAO,kDAAkD;GACpE,QAAQ,EAAE,OAAO,uBAAuB;GACxC,UAAU,EAAE,OAAO,+BAA+B;EACpD;;EAEA,WAAW;GAAE,OAAO,CAAC;GAAG,QAAQ,EAAE,OAAO,cAAc;EAAE;CAC3D;CACA,iBAAiB;EACf,UAAU;EACV,YAAY;EACZ,aAAa;EACb,MAAM;EACN,WAAW;CACb;AACF,CAAC;;AAGD,MAAa,qBAAqB,GAAG;CACnC,OAAO;EACL,MAAM;GACJ;GACA;GACA;GACA;GACA;EACF;EAEA,YACE;EAEF,QAAQ;EACR,SACE;CACJ;CACA,UAAU,EACR,WAAW;EACT,MAAM,EAAE,MAAM,yDAAyD;EACvE,OAAO,CAAC;CACV,EACF;CACA,iBAAiB,EAAE,WAAW,MAAM;AACtC,CAAC"}
1
+ {"version":3,"file":"search-styles.js","names":[],"sources":["../../../src/components/search/search-styles.ts"],"sourcesContent":["import { tv, type VariantProps } from '../../utils/tv';\n\n/*\n * Values follow Compose Material 3 (SearchBar.kt: SearchBar, AppBarWithSearch,\n * ExpandedDockedSearchBarWithGap, ExpandedFullScreenSearchBar, SearchBarDefaults.InputField;\n * SearchBar / SearchView tokens).\n *\n * Field: 56px, full corners, `surface-container-high`, 360px wide by default and at most\n * 720px. Input and placeholder `body-large`, `on-surface` / `on-surface-variant`. Icons sit\n * in 48px boxes shifted 4px inwards (leading `on-surface`, trailing `on-surface-variant`);\n * the text keeps 4px from the leading and trailing tap targets (the spec's \"Leading icon and\n * label padding (from tap target): 4dp\" and \"Label and trailing icon padding\"; Compose's\n * code leaves none), so it starts 56px in after a leading icon, 16px without one.\n *\n * Docked (with gap): the expanded field, 56px tall whatever the collapsed bar's height\n * (M3's focused search bar container), sits centred over the collapsed one and widens by 12px on\n * each side (M3 Expressive: the margins change from 24dp to 12dp when focused). It morphs from\n * the bar's bounds (position and size) on the default spatial spring and back on the same\n * spring floored at the bar, so it lands on the bar exactly; a dropdown 2px below it (12px corners,\n * `surface-container-high`; with the bar, at least 240px and at most 2/3 of the window\n * tall, per the M3 spec) slides down from half its height on the default spatial spring\n * (fast spatial back) while its content fades in over 100ms after 50ms, and its height follows\n * the results on the default spatial spring; a 32% scrim covers the page.\n *\n * Full screen, in M3 Expressive's contained style: a `surface-container-low` surface grows\n * from the bar's bounds (28px corners) to the whole window on the slow spatial spring\n * (default spatial back), clamped so nothing overshoots; the field keeps its\n * `surface-container-high` pill and moves and grows from the bar to the top, 8px down and\n * 16px from each side, and the content starts 72px down.\n *\n * In a search app bar the field is `surface-container` (`surface-container-highest` once\n * content scrolls under the bar) and fills the free space up to 312px, then half of it,\n * at most 720px (M3 app bar guidelines).\n *\n * The field's colours and corners come from the search bar's component tokens and the\n * views' from the search view's (`search-tokens.ts`, `--md-comp-search-bar-*` and\n * `--md-comp-search-view-*`); the pill, the dropdown and the full-screen view carry\n * `data-tokens`. The search app bar reads the app bar's tokens (`app-bar-tokens.ts`). A\n * consumer class still wins in `cn()`.\n *\n * Every class is written out in full so Tailwind can find it.\n */\n\nconst contentFade = [\n 'opacity-100 starting:opacity-0 data-exiting:opacity-0',\n // Compose: fade in over 100ms after 50ms (standard accelerate), out over 100ms.\n '[transition-delay:0s,50ms] data-exiting:[transition-delay:0s,0s]',\n];\n\n/** Variant definitions for {@link SearchBar}; extend them to add variants. */\nexport const searchBarStyles = tv({\n slots: {\n // The bar's height is set here alone (56px, Compose's); a consumer `h-*` resizes it.\n root: 'flex h-[56px] w-[360px] max-w-[min(720px,100%)] shrink-0',\n // The pill holding the icons and the input fills the bar.\n // Keyboard focus in the input draws Compose's inset focus ring around the pill.\n // Forced colours drop the pill's colour: a system-colour border keeps its edge.\n field: [\n 'focus-ring-inset flex h-full w-full min-w-0 items-center rounded-[var(--_md-comp-search-bar-container-shape)] text-on-surface',\n 'forced-colors:border forced-colors:border-solid forced-colors:border-[CanvasText]',\n ],\n // Icon buttons in the slots take the slot's colour (and so its icon colour token), as\n // in the app bar's slots: Compose colours the search bar's and view's leading icon\n // `on-surface` and trailing icons `on-surface-variant`, buttons included.\n leading:\n 'ms-[4px] flex size-[48px] shrink-0 items-center justify-center text-[color:var(--_md-comp-search-bar-leading-icon-color)] [--md-comp-icon-button-icon-color:currentColor] [&>svg]:size-[24px]',\n // One or two trailing icon buttons, or an avatar (30px) and an icon button (M3). Two\n // 40px buttons sit 8px apart inside 4px of padding, so their 48px targets meet edge to\n // edge within the slot (a single one is centred in 48px, as before).\n trailing: [\n 'me-[4px] flex h-[48px] min-w-[48px] shrink-0 items-center justify-center gap-[8px] px-[4px] text-[color:var(--_md-comp-search-bar-trailing-icon-color)] [--md-comp-icon-button-icon-color:currentColor]',\n '[&>svg]:size-[24px] [&>img]:size-[30px] [&>img]:rounded-full',\n ],\n // A hint or query longer than the field ends in an ellipsis, not mid-letter (as a text\n // field's label); the query only while the field isn't focused, since focused it scrolls.\n input: [\n 'h-full min-w-0 flex-1 bg-transparent text-body-large text-[color:var(--_md-comp-search-bar-input-text-color)] caret-primary outline-none text-ellipsis',\n 'placeholder:text-on-surface-variant placeholder:text-ellipsis',\n '[&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none',\n ],\n scrim: [\n 'fixed inset-0 z-(--md-sys-z-scrim) bg-scrim/32 opacity-100 data-exiting:pointer-events-none',\n '[transition-property:opacity]',\n '[transition-duration:var(--md-sys-motion-spring-effects-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-effects-default-easing)]',\n 'starting:opacity-0 data-exiting:opacity-0',\n ],\n /*\n * Docked view: the panel sits over the collapsed bar and morphs from the bar's bounds\n * (`--m3-search-left/top/width/height`) to the focused field's (the `-dx/-dy/-dw/-dh`\n * deltas) as `--m3-search-progress` runs 0 → 1, as Compose lerps the layout with its\n * search bar state's progress. `--m3-search-p` is that progress floored at 0 (Compose's\n * `coerceAtLeast(0f)`): the spring may overshoot past the focused bounds on the way in,\n * but never past the bar's on the way back, so the field lands on the bar exactly.\n * Reduced motion: the progress stays at 1, so the field is at its focused size at once.\n */\n dockedPanel: [\n // Leaving, the view takes no presses: the spring's tail runs on after the field has\n // landed on the bar, and a press there ran a suggestion of the invisible dropdown.\n 'fixed z-(--md-sys-z-sheet) flex flex-col outline-none data-exiting:pointer-events-none',\n '[--m3-search-progress:1] [--m3-search-p:max(0,var(--m3-search-progress))]',\n 'motion-safe:starting:[--m3-search-progress:0] motion-safe:data-exiting:[--m3-search-progress:0]',\n 'top-[calc(var(--m3-search-top)_+_var(--m3-search-p)_*_var(--m3-search-dy))]',\n 'left-[calc(var(--m3-search-left)_+_var(--m3-search-p)_*_var(--m3-search-dx))]',\n 'w-[calc(var(--m3-search-width)_+_var(--m3-search-p)_*_var(--m3-search-dw))]',\n // Both ways on the default spatial spring (Compose's collapse spec).\n '[transition-property:--m3-search-progress]',\n '[transition-duration:var(--md-sys-motion-spring-spatial-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-spatial-default-easing)]',\n ],\n // The focused field is 56px (M3), even when the collapsed bar is resized; it grows from\n // the bar's height with the panel.\n // The full-window layer the docked view sits in (React Aria's underlay).\n underlay: 'fixed inset-0 z-(--md-sys-z-sheet) data-exiting:pointer-events-none',\n dockedHeader:\n 'flex h-[calc(var(--m3-search-height)_+_var(--m3-search-p)_*_var(--m3-search-dh))] shrink-0',\n dropdown: [\n 'mt-[2px] overflow-y-auto overscroll-contain data-resizing:overflow-y-hidden data-exiting:pointer-events-none',\n // 58px is the field and the gap above the dropdown.\n 'min-h-[min(182px,calc(66.67dvh-58px))] max-h-[calc(66.67dvh-58px)]',\n // The height follows the content (`--m3-search-content-height`, measured) within those\n // bounds, so it animates as the results change. Without the measurement (before\n // hydration, or under reduced motion) it's `auto`.\n 'h-[clamp(min(182px,calc(66.67dvh_-_58px)),var(--m3-search-content-height),calc(66.67dvh_-_58px))]',\n 'rounded-[var(--_md-comp-search-view-docked-container-shape)] bg-[var(--_md-comp-search-view-container-color)] text-on-surface',\n 'forced-colors:border forced-colors:border-solid forced-colors:border-[CanvasText]',\n // Reduced motion: it only fades.\n 'translate-y-0 motion-safe:starting:-translate-y-1/2 motion-safe:data-exiting:-translate-y-1/2',\n // The delays below cycle, so the height (third) starts at once like the slide.\n '[transition-property:translate,opacity,height]',\n '[transition-duration:var(--md-sys-motion-spring-spatial-default-duration),100ms,var(--md-sys-motion-spring-spatial-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-spatial-default-easing),cubic-bezier(0.3,0,1,1),var(--md-sys-motion-spring-spatial-default-easing)]',\n 'data-exiting:[transition-duration:var(--md-sys-motion-spring-spatial-fast-duration),100ms,var(--md-sys-motion-spring-spatial-fast-duration)]',\n 'data-exiting:[transition-timing-function:var(--md-sys-motion-spring-spatial-fast-easing),cubic-bezier(0,0,0,1),var(--md-sys-motion-spring-spatial-fast-easing)]',\n ...contentFade,\n ],\n /*\n * Full-screen view: the surface grows from the bar's bounds to the window as\n * `--m3-search-progress` runs 0 → 1, through a clip (nothing is transformed). Compose\n * clamps the full-screen progress to 0..1 (`coerceIn`), so `--m3-search-p` is clamped too:\n * the clip and the field never overshoot the window's or the bar's bounds.\n */\n fullScreenPanel: [\n 'fixed inset-0 z-(--md-sys-z-sheet) bg-[var(--_md-comp-search-view-container-color)] text-on-surface outline-none data-exiting:pointer-events-none',\n '[--m3-search-progress:1] [--m3-search-p:clamp(0,var(--m3-search-progress),1)]',\n 'motion-safe:starting:[--m3-search-progress:0] motion-safe:data-exiting:[--m3-search-progress:0]',\n '[clip-path:inset(calc((1_-_var(--m3-search-p))_*_var(--m3-search-top))_calc((1_-_var(--m3-search-p))_*_var(--m3-search-right))_calc((1_-_var(--m3-search-p))_*_var(--m3-search-bottom))_calc((1_-_var(--m3-search-p))_*_var(--m3-search-left))_round_calc((1_-_var(--m3-search-p))_*_28px))]',\n 'motion-safe:[transition-property:--m3-search-progress]',\n 'motion-safe:[transition-duration:var(--md-sys-motion-spring-spatial-slow-duration)]',\n 'motion-safe:[transition-timing-function:var(--md-sys-motion-spring-spatial-slow-easing)]',\n 'motion-safe:data-exiting:[transition-duration:var(--md-sys-motion-spring-spatial-default-duration)]',\n 'motion-safe:data-exiting:[transition-timing-function:var(--md-sys-motion-spring-spatial-default-easing)]',\n // Reduced motion: the view fades in and out over the window instead of growing.\n 'motion-reduce:starting:opacity-0 motion-reduce:data-exiting:opacity-0',\n 'motion-reduce:[transition-property:opacity]',\n 'motion-reduce:[transition-duration:var(--md-sys-motion-spring-effects-fast-duration)]',\n 'motion-reduce:[transition-timing-function:var(--md-sys-motion-spring-effects-fast-easing)]',\n ],\n // Compose's full-screen field is 56px whatever the bar's size, 8px down and 16px from each\n // side; it moves and grows there from the bar's bounds with the surface.\n fullScreenHeader: [\n 'absolute',\n 'start-[calc(var(--m3-search-start)_+_var(--m3-search-p)_*_(16px_-_var(--m3-search-start)))]',\n 'top-[calc(var(--m3-search-top)_+_var(--m3-search-p)_*_(8px_-_var(--m3-search-top)))]',\n 'w-[calc(var(--m3-search-width)_+_var(--m3-search-p)_*_(100%_-_32px_-_var(--m3-search-width)))]',\n 'h-[calc(var(--m3-search-height)_+_var(--m3-search-p)_*_(56px_-_var(--m3-search-height)))]',\n ],\n fullScreenContent: [\n 'absolute inset-x-0 top-[72px] bottom-0 overflow-y-auto overscroll-contain',\n '[transition-property:opacity] [transition-duration:100ms]',\n '[transition-timing-function:cubic-bezier(0.3,0,1,1)]',\n 'data-exiting:[transition-timing-function:cubic-bezier(0,0,0,1)]',\n ...contentFade,\n ],\n },\n variants: {\n /**\n * Inside a search app bar the bar fills the free space up to 312px, then grows to half\n * of it (M3), up to 720px.\n */\n inAppBar: { true: { root: 'w-[max(min(100%,312px),50%)]' }, false: {} },\n // 4px from a tap target (M3), else 16px from the pill's edge.\n hasLeading: { true: { input: 'ps-[4px]' }, false: { input: 'ps-[16px]' } },\n hasTrailing: { true: { input: 'pe-[4px]' }, false: { input: 'pe-[16px]' } },\n /**\n * Container colour: the bar's own; in a search app bar `surface-container`, and one\n * step higher than the bar once content scrolls under it.\n */\n tone: {\n default: { field: 'bg-[var(--_md-comp-search-bar-container-color)]' },\n appBar: { field: 'bg-surface-container' },\n scrolled: { field: 'bg-surface-container-highest' },\n },\n /** Centre the placeholder and the query while the bar is collapsed. */\n textAlign: { start: {}, center: { input: 'text-center' } },\n /**\n * A disabled `SearchField`: M3's disabled colours, the content `on-surface` at 38% and the\n * container at 12%; forced colours draw it in `GrayText`.\n */\n disabled: {\n true: {\n field: 'bg-on-surface/12 forced-colors:border-[GrayText]',\n leading: 'text-on-surface/38 forced-colors:text-[GrayText]',\n trailing: 'text-on-surface/38 forced-colors:text-[GrayText]',\n input:\n 'cursor-default text-on-surface/38 placeholder:text-on-surface/38 forced-colors:text-[GrayText]',\n },\n false: {},\n },\n },\n defaultVariants: {\n inAppBar: false,\n hasLeading: false,\n hasTrailing: false,\n tone: 'default',\n textAlign: 'start',\n disabled: false,\n },\n});\n\n/**\n * Variant definitions for {@link SearchField}'s root. Its pill and the parts in it are the search\n * bar's ({@link searchBarStyles}), so the two can't drift.\n */\nexport const searchFieldStyles = tv({\n slots: {\n // 56px, the search bar's height, less 4px a density step (44px at -3), filling its\n // container: it filters a page, a list or a pane in place. A consumer `w-*` or `h-*` wins.\n root: 'flex h-[calc(56px+var(--md-sys-density,0)*4px)] w-full min-w-0',\n // The 48px icon slots keep to a dense pill's height; their buttons keep 48px targets.\n slot: 'max-h-full',\n },\n variants: {},\n});\n\n/** Variant definitions for {@link SearchAppBar}. */\nexport const searchAppBarStyles = tv({\n slots: {\n root: [\n 'flex min-h-[64px] w-full items-center text-on-surface',\n 'bg-[var(--_md-comp-app-bar-container-color)] data-scrolled:bg-[var(--_md-comp-app-bar-on-scroll-container-color)]',\n '[transition-property:background-color]',\n '[transition-duration:var(--md-sys-motion-spring-effects-default-duration)]',\n '[transition-timing-function:var(--md-sys-motion-spring-effects-default-easing)]',\n ],\n // Icon buttons take each slot's content colour.\n navigation:\n 'flex shrink-0 items-center ps-[8px] pe-[4px] text-[color:var(--_md-comp-app-bar-leading-icon-color)] [--md-comp-icon-button-icon-color:currentColor]',\n // Centres the search bar in the free space, 8px from its neighbours and 4px vertically.\n search: 'flex min-w-0 flex-1 justify-center ps-[8px] pe-[8px] pt-[4px] pb-[4px]',\n actions:\n 'flex shrink-0 items-center gap-[8px] ps-[4px] pe-[8px] text-[color:var(--_md-comp-app-bar-trailing-icon-color)] [--md-comp-icon-button-icon-color:currentColor]',\n },\n variants: {\n scrolling: {\n true: { root: 'sticky top-(--m3-app-bar-offset) z-(--md-sys-z-sticky)' },\n false: {},\n },\n },\n defaultVariants: { scrolling: false },\n});\n\n/**\n * The variants of {@link searchBarStyles}, for building on its styles. They are the recipe's keys, not\n * component props: their names (`hasIcon`, `isOpen`…) follow the classes and may change.\n */\nexport type SearchBarStyleProps = VariantProps<typeof searchBarStyles>;\n/**\n * The variants of {@link searchAppBarStyles}, for building on its styles. They are the recipe's keys, not\n * component props: their names (`hasIcon`, `isOpen`…) follow the classes and may change.\n */\nexport type SearchAppBarStyleProps = VariantProps<typeof searchAppBarStyles>;\n/**\n * The variants of {@link searchFieldStyles}, for building on its styles. They are the recipe's keys, not\n * component props: their names follow the classes and may change.\n */\nexport type SearchFieldStyleProps = VariantProps<typeof searchFieldStyles>;\n"],"mappings":";;AA2CA,MAAM,cAAc,CAClB,yDAEA,kEACF;;AAGA,MAAa,kBAAkB,GAAG;CAChC,OAAO;EAEL,MAAM;EAIN,OAAO,CACL,iIACA,mFACF;EAIA,SACE;EAIF,UAAU,CACR,2MACA,8DACF;EAGA,OAAO;GACL;GACA;GACA;EACF;EACA,OAAO;GACL;GACA;GACA;GACA;GACA;EACF;EAUA,aAAa;GAGX;GACA;GACA;GACA;GACA;GACA;GAEA;GACA;GACA;EACF;EAIA,UAAU;EACV,cACE;EACF,UAAU;GACR;GAEA;GAIA;GACA;GACA;GAEA;GAEA;GACA;GACA;GACA;GACA;GACA,GAAG;EACL;EAOA,iBAAiB;GACf;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GAEA;GACA;GACA;GACA;EACF;EAGA,kBAAkB;GAChB;GACA;GACA;GACA;GACA;EACF;EACA,mBAAmB;GACjB;GACA;GACA;GACA;GACA,GAAG;EACL;CACF;CACA,UAAU;;;;;EAKR,UAAU;GAAE,MAAM,EAAE,MAAM,+BAA+B;GAAG,OAAO,CAAC;EAAE;EAEtE,YAAY;GAAE,MAAM,EAAE,OAAO,WAAW;GAAG,OAAO,EAAE,OAAO,YAAY;EAAE;EACzE,aAAa;GAAE,MAAM,EAAE,OAAO,WAAW;GAAG,OAAO,EAAE,OAAO,YAAY;EAAE;;;;;EAK1E,MAAM;GACJ,SAAS,EAAE,OAAO,kDAAkD;GACpE,QAAQ,EAAE,OAAO,uBAAuB;GACxC,UAAU,EAAE,OAAO,+BAA+B;EACpD;;EAEA,WAAW;GAAE,OAAO,CAAC;GAAG,QAAQ,EAAE,OAAO,cAAc;EAAE;;;;;EAKzD,UAAU;GACR,MAAM;IACJ,OAAO;IACP,SAAS;IACT,UAAU;IACV,OACE;GACJ;GACA,OAAO,CAAC;EACV;CACF;CACA,iBAAiB;EACf,UAAU;EACV,YAAY;EACZ,aAAa;EACb,MAAM;EACN,WAAW;EACX,UAAU;CACZ;AACF,CAAC;;;;;AAMD,MAAa,oBAAoB,GAAG;CAClC,OAAO;EAGL,MAAM;EAEN,MAAM;CACR;CACA,UAAU,CAAC;AACb,CAAC;;AAGD,MAAa,qBAAqB,GAAG;CACnC,OAAO;EACL,MAAM;GACJ;GACA;GACA;GACA;GACA;EACF;EAEA,YACE;EAEF,QAAQ;EACR,SACE;CACJ;CACA,UAAU,EACR,WAAW;EACT,MAAM,EAAE,MAAM,yDAAyD;EACvE,OAAO,CAAC;CACV,EACF;CACA,iBAAiB,EAAE,WAAW,MAAM;AACtC,CAAC"}
@@ -4,9 +4,10 @@ import { FOCUSABLE_DISABLED_OPTIONS } from "../../utils/focusable-disabled.js";
4
4
  import { menuStyles } from "../menu/menu-styles.js";
5
5
  import { OptionList } from "./option-list.js";
6
6
  import { searchBarStyles } from "../search/search-styles.js";
7
+ import { SearchFieldFrame } from "../search/search-field-frame.js";
7
8
  import { useCallback, useEffect, useRef, useState } from "react";
8
9
  import { jsx, jsxs } from "react/jsx-runtime";
9
- import { useAutocomplete, useFocusRing, useSearchField } from "react-aria";
10
+ import { useAutocomplete, useSearchField } from "react-aria";
10
11
  import { useListState } from "react-stately";
11
12
  //#region src/components/select/search-list.tsx
12
13
  /** Material Symbols `search`. */
@@ -71,10 +72,6 @@ function SearchList({ listProps, search, onSearchChange, filter, autoFocusSearch
71
72
  value: search,
72
73
  setValue: onSearchChange
73
74
  }, inputRef);
74
- const { focusProps, isFocusVisible } = useFocusRing({
75
- within: true,
76
- isTextInput: true
77
- });
78
75
  useEffect(() => {
79
76
  if (autoFocusSearch) inputRef.current?.focus();
80
77
  }, [autoFocusSearch]);
@@ -90,26 +87,24 @@ function SearchList({ listProps, search, onSearchChange, filter, autoFocusSearch
90
87
  className: cn("flex min-h-0 flex-col", embedded ? "flex-1" : [menu.group(), "max-h-[inherit] overflow-hidden"]),
91
88
  children: [/* @__PURE__ */ jsx("div", {
92
89
  className: cn("flex h-[calc(52px+var(--md-sys-density,0)*4px)] shrink-0 pb-[4px]", embedded && "sticky top-0 z-[1] bg-[var(--_md-comp-sheet-bottom-docked-container-color)]"),
93
- children: /* @__PURE__ */ jsxs("div", {
94
- ...focusProps,
95
- "data-tokens": "md-comp-search-bar",
96
- "data-focus-visible": isFocusVisible || void 0,
90
+ children: /* @__PURE__ */ jsx(SearchFieldFrame, {
97
91
  onPointerDown: (event) => {
98
92
  if (event.target !== event.currentTarget) return;
99
93
  event.preventDefault();
100
94
  inputRef.current?.focus();
101
95
  },
102
- className: field.field({ class: cn(denseSearchTarget, classNames?.search) }),
103
- children: [/* @__PURE__ */ jsx("span", {
96
+ className: cn(denseSearchTarget, classNames?.search),
97
+ leading: /* @__PURE__ */ jsx("span", {
104
98
  "data-slot": "leading",
105
99
  className: field.leading({ class: "h-full" }),
106
100
  children: /* @__PURE__ */ jsx(SearchIcon, {})
107
- }), /* @__PURE__ */ jsx("input", {
101
+ }),
102
+ children: /* @__PURE__ */ jsx("input", {
108
103
  ...inputProps,
109
104
  ref: inputRef,
110
105
  "data-slot": "input",
111
106
  className: field.input()
112
- })]
107
+ })
113
108
  })
114
109
  }), /* @__PURE__ */ jsx(OptionList, {
115
110
  embedded: true,