@matekit/react 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +102 -0
- package/LICENSE +202 -0
- package/NOTICE +56 -0
- package/README.md +115 -2
- package/dist/atoms/Divider/Divider.d.ts +49 -0
- package/dist/atoms/Divider/Divider.js +29 -0
- package/dist/atoms/FocusRing/FocusRing.d.ts +16 -0
- package/dist/atoms/FocusRing/FocusRing.js +16 -0
- package/dist/atoms/Group/Group.d.ts +38 -0
- package/dist/atoms/Group/Group.js +34 -0
- package/dist/atoms/Icon/Icon.d.ts +23 -0
- package/dist/atoms/Icon/Icon.js +19 -0
- package/dist/atoms/Interactive/Interactive.d.ts +98 -0
- package/dist/atoms/Interactive/Interactive.js +87 -0
- package/dist/atoms/Ripple/Ripple.d.ts +14 -0
- package/dist/atoms/Ripple/Ripple.js +63 -0
- package/dist/atoms/Shape/Shape.d.ts +24 -0
- package/dist/atoms/Shape/Shape.js +19 -0
- package/dist/atoms/Shape/shapes.d.ts +8 -0
- package/dist/atoms/Shape/shapes.js +40 -0
- package/dist/atoms/Stack/Stack.d.ts +58 -0
- package/dist/atoms/Stack/Stack.js +33 -0
- package/dist/atoms/StateLayer/StateLayer.d.ts +17 -0
- package/dist/atoms/StateLayer/StateLayer.js +17 -0
- package/dist/atoms/index.d.ts +10 -0
- package/dist/atoms/index.js +10 -0
- package/dist/fonts/roboto-flex/OFL.txt +93 -0
- package/dist/fonts/roboto-flex/roboto-flex-cyrillic-ext.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-cyrillic.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-greek.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-latin-ext.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-latin.woff2 +0 -0
- package/dist/fonts/roboto-flex/roboto-flex-vietnamese.woff2 +0 -0
- package/dist/icons/icons.d.ts +89 -0
- package/dist/icons/icons.js +186 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/dist/internal/accessible-name.d.ts +17 -0
- package/dist/internal/accessible-name.js +33 -0
- package/dist/internal/anchor-position.d.ts +99 -0
- package/dist/internal/anchor-position.js +159 -0
- package/dist/internal/anchored-drag.d.ts +25 -0
- package/dist/internal/anchored-drag.js +106 -0
- package/dist/internal/dev.d.ts +2 -0
- package/dist/internal/dev.js +18 -0
- package/dist/internal/diagnostics.d.ts +46 -0
- package/dist/internal/diagnostics.js +125 -0
- package/dist/internal/group-label.d.ts +22 -0
- package/dist/internal/group-label.js +50 -0
- package/dist/internal/interactive.d.ts +28 -0
- package/dist/internal/interactive.js +18 -0
- package/dist/internal/layout-element.d.ts +21 -0
- package/dist/internal/layout-element.js +33 -0
- package/dist/internal/merge-refs.d.ts +13 -0
- package/dist/internal/merge-refs.js +35 -0
- package/dist/internal/modal-dialog.d.ts +63 -0
- package/dist/internal/modal-dialog.js +267 -0
- package/dist/internal/navigation-count.d.ts +38 -0
- package/dist/internal/navigation-count.js +60 -0
- package/dist/internal/navigation-item.d.ts +14 -0
- package/dist/internal/navigation-item.js +17 -0
- package/dist/internal/nearest-scroller.d.ts +4 -0
- package/dist/internal/nearest-scroller.js +17 -0
- package/dist/internal/open-state.d.ts +15 -0
- package/dist/internal/open-state.js +42 -0
- package/dist/internal/roving-focus.d.ts +41 -0
- package/dist/internal/roving-focus.js +126 -0
- package/dist/internal/settle-animations.d.ts +33 -0
- package/dist/internal/settle-animations.js +48 -0
- package/dist/internal/time-period.d.ts +10 -0
- package/dist/internal/time-period.js +26 -0
- package/dist/internal/time.d.ts +23 -0
- package/dist/internal/time.js +69 -0
- package/dist/internal/typeahead.d.ts +17 -0
- package/dist/internal/typeahead.js +35 -0
- package/dist/molecules/Badge/Badge.d.ts +25 -0
- package/dist/molecules/Badge/Badge.js +16 -0
- package/dist/molecules/Button/Button.d.ts +48 -0
- package/dist/molecules/Button/Button.js +34 -0
- package/dist/molecules/Card/Card.d.ts +159 -0
- package/dist/molecules/Card/Card.js +119 -0
- package/dist/molecules/Checkbox/Checkbox.d.ts +26 -0
- package/dist/molecules/Checkbox/Checkbox.js +40 -0
- package/dist/molecules/Chip/AssistChip.d.ts +23 -0
- package/dist/molecules/Chip/AssistChip.js +22 -0
- package/dist/molecules/Chip/ChipGroup.d.ts +85 -0
- package/dist/molecules/Chip/ChipGroup.js +92 -0
- package/dist/molecules/Chip/FilterChip.d.ts +33 -0
- package/dist/molecules/Chip/FilterChip.js +30 -0
- package/dist/molecules/Chip/InputChip.d.ts +60 -0
- package/dist/molecules/Chip/InputChip.js +107 -0
- package/dist/molecules/Chip/SuggestionChip.d.ts +24 -0
- package/dist/molecules/Chip/SuggestionChip.js +17 -0
- package/dist/molecules/Chip/chip-content.d.ts +39 -0
- package/dist/molecules/Chip/chip-content.js +95 -0
- package/dist/molecules/Chip/chip-element.d.ts +14 -0
- package/dist/molecules/Chip/chip-element.js +14 -0
- package/dist/molecules/Chip/strings.d.ts +8 -0
- package/dist/molecules/Chip/strings.js +5 -0
- package/dist/molecules/Fab/Fab.d.ts +78 -0
- package/dist/molecules/Fab/Fab.js +52 -0
- package/dist/molecules/IconButton/IconButton.d.ts +59 -0
- package/dist/molecules/IconButton/IconButton.js +36 -0
- package/dist/molecules/LoadingIndicator/LoadingIndicator.d.ts +38 -0
- package/dist/molecules/LoadingIndicator/LoadingIndicator.js +25 -0
- package/dist/molecules/LoadingIndicator/determinate.d.ts +3 -0
- package/dist/molecules/LoadingIndicator/determinate.js +47 -0
- package/dist/molecules/LoadingIndicator/loading-indicator-data.d.ts +21 -0
- package/dist/molecules/LoadingIndicator/loading-indicator-data.js +72 -0
- package/dist/molecules/ProgressIndicator/CircularProgressIndicator.d.ts +35 -0
- package/dist/molecules/ProgressIndicator/CircularProgressIndicator.js +30 -0
- package/dist/molecules/ProgressIndicator/LinearProgressIndicator.d.ts +43 -0
- package/dist/molecules/ProgressIndicator/LinearProgressIndicator.js +28 -0
- package/dist/molecules/ProgressIndicator/circular-wavy-data.d.ts +5 -0
- package/dist/molecules/ProgressIndicator/circular-wavy-data.js +19 -0
- package/dist/molecules/ProgressIndicator/progress.d.ts +24 -0
- package/dist/molecules/ProgressIndicator/progress.js +60 -0
- package/dist/molecules/RadioButton/RadioButton.d.ts +27 -0
- package/dist/molecules/RadioButton/RadioButton.js +70 -0
- package/dist/molecules/RadioButton/RadioGroup.d.ts +73 -0
- package/dist/molecules/RadioButton/RadioGroup.js +82 -0
- package/dist/molecules/ScrollField/ScrollField.d.ts +61 -0
- package/dist/molecules/ScrollField/ScrollField.js +352 -0
- package/dist/molecules/Slider/RangeSlider.d.ts +60 -0
- package/dist/molecules/Slider/RangeSlider.js +169 -0
- package/dist/molecules/Slider/Slider.d.ts +54 -0
- package/dist/molecules/Slider/Slider.js +71 -0
- package/dist/molecules/Slider/slider-shared.d.ts +26 -0
- package/dist/molecules/Slider/slider-shared.js +98 -0
- package/dist/molecules/Switch/Switch.d.ts +22 -0
- package/dist/molecules/Switch/Switch.js +20 -0
- package/dist/molecules/TextField/TextField.d.ts +83 -0
- package/dist/molecules/TextField/TextField.js +146 -0
- package/dist/molecules/TextField/TextFieldSlots.d.ts +22 -0
- package/dist/molecules/TextField/TextFieldSlots.js +24 -0
- package/dist/molecules/TimeInput/TimeInput.d.ts +108 -0
- package/dist/molecules/TimeInput/TimeInput.js +347 -0
- package/dist/molecules/TimeInput/strings.d.ts +13 -0
- package/dist/molecules/TimeInput/strings.js +10 -0
- package/dist/molecules/TimeScroll/TimeScroll.d.ts +106 -0
- package/dist/molecules/TimeScroll/TimeScroll.js +213 -0
- package/dist/molecules/TimeScroll/strings.d.ts +13 -0
- package/dist/molecules/TimeScroll/strings.js +12 -0
- package/dist/molecules/index.d.ts +27 -0
- package/dist/molecules/index.js +25 -0
- package/dist/organisms/BottomSheet/BottomSheet.d.ts +128 -0
- package/dist/organisms/BottomSheet/BottomSheet.js +432 -0
- package/dist/organisms/BottomSheet/BottomSheetSlots.d.ts +17 -0
- package/dist/organisms/BottomSheet/BottomSheetSlots.js +16 -0
- package/dist/organisms/BottomSheet/StandardBottomSheet.d.ts +37 -0
- package/dist/organisms/BottomSheet/StandardBottomSheet.js +206 -0
- package/dist/organisms/BottomSheet/bottom-sheet-context.d.ts +31 -0
- package/dist/organisms/BottomSheet/bottom-sheet-context.js +12 -0
- package/dist/organisms/BottomSheet/sheet-drag.d.ts +1 -0
- package/dist/organisms/BottomSheet/sheet-drag.js +4 -0
- package/dist/organisms/BottomSheet/strings.d.ts +9 -0
- package/dist/organisms/BottomSheet/strings.js +8 -0
- package/dist/organisms/ButtonGroup/ButtonGroup.d.ts +97 -0
- package/dist/organisms/ButtonGroup/ButtonGroup.js +242 -0
- package/dist/organisms/ButtonGroup/ButtonGroupItem.d.ts +36 -0
- package/dist/organisms/ButtonGroup/ButtonGroupItem.js +47 -0
- package/dist/organisms/Dialog/Dialog.d.ts +186 -0
- package/dist/organisms/Dialog/Dialog.js +193 -0
- package/dist/organisms/Dialog/DialogSlots.d.ts +60 -0
- package/dist/organisms/Dialog/DialogSlots.js +54 -0
- package/dist/organisms/Dialog/strings.d.ts +5 -0
- package/dist/organisms/Dialog/strings.js +5 -0
- package/dist/organisms/FabMenu/FabMenu.d.ts +104 -0
- package/dist/organisms/FabMenu/FabMenu.js +142 -0
- package/dist/organisms/FabMenu/strings.d.ts +9 -0
- package/dist/organisms/FabMenu/strings.js +5 -0
- package/dist/organisms/List/List.d.ts +190 -0
- package/dist/organisms/List/List.js +148 -0
- package/dist/organisms/Menu/Menu.d.ts +313 -0
- package/dist/organisms/Menu/Menu.js +865 -0
- package/dist/organisms/Menu/MenuSlots.d.ts +35 -0
- package/dist/organisms/Menu/MenuSlots.js +36 -0
- package/dist/organisms/NavigationBar/NavigationBar.d.ts +96 -0
- package/dist/organisms/NavigationBar/NavigationBar.js +77 -0
- package/dist/organisms/NavigationRail/ModalNavigationRail.d.ts +105 -0
- package/dist/organisms/NavigationRail/ModalNavigationRail.js +272 -0
- package/dist/organisms/NavigationRail/NavigationRail.d.ts +148 -0
- package/dist/organisms/NavigationRail/NavigationRail.js +114 -0
- package/dist/organisms/NavigationRail/NavigationRailSection.d.ts +54 -0
- package/dist/organisms/NavigationRail/NavigationRailSection.js +96 -0
- package/dist/organisms/NavigationRail/strings.d.ts +7 -0
- package/dist/organisms/NavigationRail/strings.js +7 -0
- package/dist/organisms/NavigationSuite/NavigationSuite.d.ts +109 -0
- package/dist/organisms/NavigationSuite/NavigationSuite.js +86 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.d.ts +118 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.js +132 -0
- package/dist/organisms/Search/Search.d.ts +213 -0
- package/dist/organisms/Search/Search.js +783 -0
- package/dist/organisms/Search/SearchSlots.d.ts +18 -0
- package/dist/organisms/Search/SearchSlots.js +19 -0
- package/dist/organisms/Search/strings.d.ts +21 -0
- package/dist/organisms/Search/strings.js +12 -0
- package/dist/organisms/Select/Select.d.ts +186 -0
- package/dist/organisms/Select/Select.js +597 -0
- package/dist/organisms/Select/SelectSlots.d.ts +12 -0
- package/dist/organisms/Select/SelectSlots.js +12 -0
- package/dist/organisms/SideSheet/SideSheet.d.ts +88 -0
- package/dist/organisms/SideSheet/SideSheet.js +109 -0
- package/dist/organisms/SideSheet/SideSheetSlots.d.ts +35 -0
- package/dist/organisms/SideSheet/SideSheetSlots.js +37 -0
- package/dist/organisms/SideSheet/strings.d.ts +7 -0
- package/dist/organisms/SideSheet/strings.js +6 -0
- package/dist/organisms/Snackbar/Snackbar.d.ts +46 -0
- package/dist/organisms/Snackbar/Snackbar.js +36 -0
- package/dist/organisms/Snackbar/SnackbarHost.d.ts +57 -0
- package/dist/organisms/Snackbar/SnackbarHost.js +221 -0
- package/dist/organisms/Snackbar/snackbar-queue.d.ts +81 -0
- package/dist/organisms/Snackbar/snackbar-queue.js +114 -0
- package/dist/organisms/Snackbar/strings.d.ts +8 -0
- package/dist/organisms/Snackbar/strings.js +5 -0
- package/dist/organisms/SplitButton/SplitButton.d.ts +73 -0
- package/dist/organisms/SplitButton/SplitButton.js +77 -0
- package/dist/organisms/SplitButton/strings.d.ts +9 -0
- package/dist/organisms/SplitButton/strings.js +5 -0
- package/dist/organisms/Tabs/TabLink.d.ts +27 -0
- package/dist/organisms/Tabs/TabLink.js +25 -0
- package/dist/organisms/Tabs/TabNav.d.ts +19 -0
- package/dist/organisms/Tabs/TabNav.js +55 -0
- package/dist/organisms/Tabs/Tabs.d.ts +147 -0
- package/dist/organisms/Tabs/Tabs.js +223 -0
- package/dist/organisms/Tabs/tab-content.d.ts +23 -0
- package/dist/organisms/Tabs/tab-content.js +105 -0
- package/dist/organisms/Tabs/tab-fit.d.ts +4 -0
- package/dist/organisms/Tabs/tab-fit.js +65 -0
- package/dist/organisms/Tabs/tab-motion.d.ts +2 -0
- package/dist/organisms/Tabs/tab-motion.js +68 -0
- package/dist/organisms/TimePickerDialog/TimePickerDialog.d.ts +26 -0
- package/dist/organisms/TimePickerDialog/TimePickerDialog.js +34 -0
- package/dist/organisms/Toolbar/Toolbar.d.ts +75 -0
- package/dist/organisms/Toolbar/Toolbar.js +84 -0
- package/dist/organisms/Toolbar/ToolbarLayout.d.ts +44 -0
- package/dist/organisms/Toolbar/ToolbarLayout.js +90 -0
- package/dist/organisms/Toolbar/ToolbarScroll.d.ts +8 -0
- package/dist/organisms/Toolbar/ToolbarScroll.js +222 -0
- package/dist/organisms/Tooltip/RichTooltip.d.ts +73 -0
- package/dist/organisms/Tooltip/RichTooltip.js +250 -0
- package/dist/organisms/Tooltip/Tooltip.d.ts +52 -0
- package/dist/organisms/Tooltip/Tooltip.js +99 -0
- package/dist/organisms/Tooltip/tooltip-behavior.d.ts +43 -0
- package/dist/organisms/Tooltip/tooltip-behavior.js +307 -0
- package/dist/organisms/TopAppBar/TopAppBar.d.ts +107 -0
- package/dist/organisms/TopAppBar/TopAppBar.js +78 -0
- package/dist/organisms/TopAppBar/TopAppBarScroll.d.ts +7 -0
- package/dist/organisms/TopAppBar/TopAppBarScroll.js +155 -0
- package/dist/organisms/index.d.ts +36 -0
- package/dist/organisms/index.js +36 -0
- package/dist/palettes/blue.css +275 -0
- package/dist/palettes/green.css +275 -0
- package/dist/palettes/index.css +823 -0
- package/dist/palettes/orange.css +275 -0
- package/dist/shapes.css +115 -0
- package/dist/strings/index.d.ts +35 -0
- package/dist/strings/index.js +39 -0
- package/dist/styles-no-fonts.css +12025 -0
- package/dist/styles.css +12123 -0
- package/dist/stylesheet.d.ts +2 -0
- package/dist/tokens/breakpoints.d.ts +33 -0
- package/dist/tokens/breakpoints.js +31 -0
- package/dist/tokens/space.d.ts +26 -0
- package/dist/tokens/space.js +26 -0
- package/package.json +110 -3
|
@@ -0,0 +1,783 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Organismo interactivo (ADR-0003, ADR-0026): el combobox (sugerencia activa, apertura, teclado
|
|
4
|
+
// APG), el texto controlado o no, la elección de la vista por el ancho de la ventana, la vista a
|
|
5
|
+
// pantalla completa sobre <dialog> (showModal) y la región viva necesitan estado, efectos, contexto
|
|
6
|
+
// y eventos en el cliente. Lo que no los necesita (SearchBarLeading y SearchBarTrailing) es
|
|
7
|
+
// universal y está en SearchSlots.tsx.
|
|
8
|
+
//
|
|
9
|
+
// Partes (ADR-0002, ADR-0026):
|
|
10
|
+
// - Search: la raíz, un <search> (región de búsqueda) con el estado compartido por contexto.
|
|
11
|
+
// - SearchBar: la barra (la píldora de 56) con el <input type="search">; sus props nativas y su
|
|
12
|
+
// `ref` van al input.
|
|
13
|
+
// - SearchView: las sugerencias. Docked: una capa (popover) anclada debajo de la barra. A pantalla
|
|
14
|
+
// completa: un <dialog> modal con su propia barra (volver, el campo y borrar) y la lista.
|
|
15
|
+
// - SearchSuggestion y SearchSuggestionGroup: las opciones (role="option", con las partes de
|
|
16
|
+
// ListItem) y sus grupos con nombre (role="group"), nombrados por SearchSuggestionGroupLabel, sobre la
|
|
17
|
+
// base común de etiqueta de grupo (src/internal/group-label.tsx, con MenuGroupLabel y SelectGroupLabel).
|
|
18
|
+
//
|
|
19
|
+
// Combobox (APG "Combobox" con listbox y autocompletado de lista): el foco se queda en el input;
|
|
20
|
+
// la sugerencia activa es `aria-activedescendant` (foco visual, no real). Las opciones se recorren
|
|
21
|
+
// en el orden del DOM del listbox; sus datos (valor, texto) se registran en un Map por id.
|
|
22
|
+
import { Children, cloneElement, createContext, Fragment, isValidElement, use, useCallback, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, } from 'react';
|
|
23
|
+
import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
|
|
24
|
+
import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
|
|
25
|
+
import { ArrowBackIcon, CloseIcon } from '../../icons/icons.js';
|
|
26
|
+
import { IconButton } from '../../molecules/IconButton/IconButton.js';
|
|
27
|
+
import { LinearProgressIndicator } from '../../molecules/ProgressIndicator/LinearProgressIndicator.js';
|
|
28
|
+
import { ListItem, ListItemHeadline } from '../List/List.js';
|
|
29
|
+
import { partOutsideParent } from '../../internal/diagnostics.js';
|
|
30
|
+
import { followAnchor, placeNextTo, supportsAnchorPositioning } from '../../internal/anchor-position.js';
|
|
31
|
+
import { cx } from '../../internal/interactive.js';
|
|
32
|
+
import { GroupLabel, useGroupLabel } from '../../internal/group-label.js';
|
|
33
|
+
import { mergeRefs } from '../../internal/merge-refs.js';
|
|
34
|
+
import { useModalDialog } from '../../internal/modal-dialog.js';
|
|
35
|
+
import { settleAnimations } from '../../internal/settle-animations.js';
|
|
36
|
+
import { WINDOW_HEIGHT, WINDOW_WIDTH } from '../../tokens/breakpoints.js';
|
|
37
|
+
import { SearchBarTrailing } from './SearchSlots.js';
|
|
38
|
+
import { searchStrings } from './strings.js';
|
|
39
|
+
// Demora antes de anunciar la cantidad de sugerencias: no se repite en cada tecla.
|
|
40
|
+
const ANNOUNCE_DELAY_MS = 500;
|
|
41
|
+
// Tras `formatRemoved` ("Removed …"), el anuncio de la cantidad nueva se calla este tiempo (no lo pisa).
|
|
42
|
+
const REMOVAL_QUIET_MS = 1000;
|
|
43
|
+
// Ventana medium o más ancha y no baja: `min-width` y `min-height` en rem (base 16), como los demás cortes
|
|
44
|
+
// (ADR-0016). Es el mismo corte que Dialog `view="auto"` y NavigationSuite: un teléfono acostado (844 × 390)
|
|
45
|
+
// es ancho pero bajo, y con el teclado en pantalla la lista docked quedaba en una franja; ahí va a pantalla
|
|
46
|
+
// completa (M13, encontrado en Android con mk-mail, 2026-11-30).
|
|
47
|
+
const WIDE_WINDOW_QUERY = `(min-width: ${WINDOW_WIDTH.medium / 16}rem) and (min-height: ${WINDOW_HEIGHT.medium / 16}rem)`;
|
|
48
|
+
function subscribeWideWindow(onChange) {
|
|
49
|
+
const query = matchMedia(WIDE_WINDOW_QUERY);
|
|
50
|
+
query.addEventListener('change', onChange);
|
|
51
|
+
return () => query.removeEventListener('change', onChange);
|
|
52
|
+
}
|
|
53
|
+
// Si la ventana es medium o más ancha, y no baja. En el servidor, sí (la vista docked no cambia el HTML de la barra).
|
|
54
|
+
function useWideWindow() {
|
|
55
|
+
return useSyncExternalStore(subscribeWideWindow, () => matchMedia(WIDE_WINDOW_QUERY).matches, () => true);
|
|
56
|
+
}
|
|
57
|
+
const SearchContext = createContext(null);
|
|
58
|
+
function useSearch(part) {
|
|
59
|
+
const ctx = use(SearchContext);
|
|
60
|
+
if (!ctx)
|
|
61
|
+
throw partOutsideParent(part, 'Search');
|
|
62
|
+
return ctx;
|
|
63
|
+
}
|
|
64
|
+
// Un gesto de puntero en curso: desde el `pointerdown` hasta después del `click` que sigue al
|
|
65
|
+
// `pointerup` (o el `pointercancel`), estén donde estén (un arrastre puede soltarse afuera).
|
|
66
|
+
function usePointerGesture() {
|
|
67
|
+
const active = useRef(false);
|
|
68
|
+
return useMemo(() => ({
|
|
69
|
+
active: () => active.current,
|
|
70
|
+
start() {
|
|
71
|
+
active.current = true;
|
|
72
|
+
const end = () => {
|
|
73
|
+
window.removeEventListener('pointerup', end, true);
|
|
74
|
+
window.removeEventListener('pointercancel', end, true);
|
|
75
|
+
// Después del click, que el navegador despacha enseguida del pointerup.
|
|
76
|
+
setTimeout(() => {
|
|
77
|
+
active.current = false;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
window.addEventListener('pointerup', end, true);
|
|
81
|
+
window.addEventListener('pointercancel', end, true);
|
|
82
|
+
},
|
|
83
|
+
}), []);
|
|
84
|
+
}
|
|
85
|
+
// Anillo de foco de la barra solo con teclado. Un input de texto siempre es :focus-visible (aunque
|
|
86
|
+
// se lo enfoque con un clic o un toque), así que la búsqueda lleva su propia señal: un
|
|
87
|
+
// `pointerdown` dentro de la raíz (mouse, táctil o lápiz; también en la barra de la vista a pantalla
|
|
88
|
+
// completa y en las sugerencias, que son descendientes en el DOM) marca `data-pointer-focus`, y el
|
|
89
|
+
// CSS oculta el anillo mientras esté. La marca se va cuando el foco vuelve a entrar desde afuera
|
|
90
|
+
// sin un gesto de puntero en curso (volver con Tab muestra el anillo) o con una tecla de navegación (las flechas de la lista, Escape, Enter, Tab,
|
|
91
|
+
// Re Pág y Av Pág), como hacen los navegadores con :focus-visible en un botón enfocado con el mouse
|
|
92
|
+
// cuando después se usa el teclado. Escribir o mover el cursor (letras, Retroceso, Izquierda,
|
|
93
|
+
// Derecha, Inicio, Fin) no la quita: es editar el texto, no navegar. Se escribe en el DOM (sin
|
|
94
|
+
// estado de React): no vuelve a dibujar nada.
|
|
95
|
+
const NAVIGATION_KEYS = new Set(['ArrowDown', 'ArrowUp', 'Escape', 'Enter', 'Tab', 'PageDown', 'PageUp']);
|
|
96
|
+
function markPointerFocus(root, pointer) {
|
|
97
|
+
root.toggleAttribute('data-pointer-focus', pointer);
|
|
98
|
+
}
|
|
99
|
+
// Opciones que las flechas recorren, en el orden del DOM (las deshabilitadas se saltean).
|
|
100
|
+
function enabledOptions(listbox) {
|
|
101
|
+
if (!listbox)
|
|
102
|
+
return [];
|
|
103
|
+
return [...listbox.querySelectorAll('[role="option"]:not([aria-disabled="true"])')];
|
|
104
|
+
}
|
|
105
|
+
// El botón que el navegador usaría para el envío implícito con Enter: el primer botón de envío del
|
|
106
|
+
// formulario. Si está deshabilitado, el envío implícito no ocurre (HTML, "implicit submission").
|
|
107
|
+
function defaultSubmitter(form) {
|
|
108
|
+
for (const el of form.elements) {
|
|
109
|
+
const submit = (el instanceof HTMLButtonElement && el.type === 'submit') ||
|
|
110
|
+
(el instanceof HTMLInputElement && (el.type === 'submit' || el.type === 'image'));
|
|
111
|
+
if (submit)
|
|
112
|
+
return el.disabled ? 'blocked' : el;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Material 3 Expressive search: the root, a `<search>` (the page's search region) that shares the
|
|
118
|
+
* state between the bar and the suggestions. It goes with a `SearchBar` and, if there are
|
|
119
|
+
* suggestions, a `SearchView`.
|
|
120
|
+
*
|
|
121
|
+
* The app provides the suggestions: they are not filtered inside (local filtering or a remote
|
|
122
|
+
* search is up to the app, with the text from `value`/`onValueChange`).
|
|
123
|
+
*
|
|
124
|
+
* ```tsx
|
|
125
|
+
* const [q, setQ] = useState('')
|
|
126
|
+
* const results = FRUITS.filter((f) => matches(f, q))
|
|
127
|
+
* <Search value={q} onValueChange={setQ} onSubmit={search} onSelect={open}>
|
|
128
|
+
* <SearchBar label="Search fruits" placeholder="Search fruits">
|
|
129
|
+
* <SearchBarLeading><SearchIcon /></SearchBarLeading>
|
|
130
|
+
* </SearchBar>
|
|
131
|
+
* <SearchView loading={loading}>
|
|
132
|
+
* {results.map((f) => <SearchSuggestion key={f.id} value={f.name} />)}
|
|
133
|
+
* </SearchView>
|
|
134
|
+
* </Search>
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* Keyboard (APG combobox): arrows move the active suggestion (wrapping), Enter chooses the active
|
|
138
|
+
* one or searches, Escape closes the suggestions and, when closed, clears the text; Alt+Down Arrow
|
|
139
|
+
* opens them.
|
|
140
|
+
*
|
|
141
|
+
* It is a block that takes its container's width, up to 720 px (Compose `SearchBarMaxWidth`).
|
|
142
|
+
* Inside a `TopAppBar` (as a direct child) it takes the title's place.
|
|
143
|
+
*/
|
|
144
|
+
export function Search({ value: valueProp, defaultValue, onValueChange, onSubmit, onSelect, view = 'auto', className, children, ref, onPointerDown, onKeyDown, onFocus, ...rest }) {
|
|
145
|
+
const id = useId();
|
|
146
|
+
const wide = useWideWindow();
|
|
147
|
+
const mode = view === 'auto' ? (wide ? 'docked' : 'full-screen') : view;
|
|
148
|
+
const [innerValue, setInnerValue] = useState(defaultValue ?? '');
|
|
149
|
+
const value = valueProp ?? innerValue;
|
|
150
|
+
const [open, setOpen] = useState(false);
|
|
151
|
+
const [expanded, setExpanded] = useState(false);
|
|
152
|
+
const [activeId, setActiveId] = useState(null);
|
|
153
|
+
const [hasView, setHasView] = useState(false);
|
|
154
|
+
const [bar, setBar] = useState({ name: {}, placeholder: undefined, clearLabel: searchStrings.clearLabel });
|
|
155
|
+
const pointerGesture = usePointerGesture();
|
|
156
|
+
const rootRef = useRef(null);
|
|
157
|
+
const setRootRef = useMemo(() => mergeRefs(rootRef, ref), [ref]);
|
|
158
|
+
const barRef = useRef(null);
|
|
159
|
+
const barInputRef = useRef(null);
|
|
160
|
+
const viewInputRef = useRef(null);
|
|
161
|
+
const listboxRef = useRef(null);
|
|
162
|
+
const options = useRef(new Map());
|
|
163
|
+
const pendingRemoval = useRef(null);
|
|
164
|
+
const announceRemoval = useRef(null);
|
|
165
|
+
// Lo último de cada valor, para los manejadores (no cambian la identidad del contexto).
|
|
166
|
+
const latest = useRef({ value, open, expanded, activeId, mode, hasView, onValueChange, onSubmit, onSelect });
|
|
167
|
+
latest.current = { value, open, expanded, activeId, mode, hasView, onValueChange, onSubmit, onSelect };
|
|
168
|
+
// Cambiar de vista (la ventana cruzó los 600 px de ancho o los 480 de alto) cierra las sugerencias.
|
|
169
|
+
useEffect(() => {
|
|
170
|
+
setOpen(false);
|
|
171
|
+
setActiveId(null);
|
|
172
|
+
}, [mode]);
|
|
173
|
+
const setValue = useCallback((next, event) => {
|
|
174
|
+
if (valueProp === undefined)
|
|
175
|
+
setInnerValue(next);
|
|
176
|
+
latest.current.onValueChange?.(next, event);
|
|
177
|
+
}, [valueProp]);
|
|
178
|
+
const requestOpen = useCallback(() => {
|
|
179
|
+
if (!latest.current.hasView || barInputRef.current?.disabled)
|
|
180
|
+
return;
|
|
181
|
+
setOpen(true);
|
|
182
|
+
}, []);
|
|
183
|
+
const requestClose = useCallback(() => {
|
|
184
|
+
setOpen(false);
|
|
185
|
+
setActiveId(null);
|
|
186
|
+
}, []);
|
|
187
|
+
const changeValue = useCallback((next, event) => {
|
|
188
|
+
setValue(next, event);
|
|
189
|
+
setActiveId(null);
|
|
190
|
+
requestOpen();
|
|
191
|
+
}, [setValue, requestOpen]);
|
|
192
|
+
const clear = useCallback((where, event) => {
|
|
193
|
+
setValue('', event);
|
|
194
|
+
setActiveId(null);
|
|
195
|
+
(where === 'view' ? viewInputRef : barInputRef).current?.focus();
|
|
196
|
+
}, [setValue]);
|
|
197
|
+
const select = useCallback((optionId, event) => {
|
|
198
|
+
const data = options.current.get(optionId);
|
|
199
|
+
if (!data || data.disabled)
|
|
200
|
+
return;
|
|
201
|
+
setValue(data.textValue, event);
|
|
202
|
+
latest.current.onSelect?.(data.value);
|
|
203
|
+
requestClose();
|
|
204
|
+
}, [setValue, requestClose]);
|
|
205
|
+
const submit = useCallback(() => {
|
|
206
|
+
latest.current.onSubmit?.(latest.current.value);
|
|
207
|
+
requestClose();
|
|
208
|
+
// El envío del formulario lo hace la búsqueda (no el Enter nativo): con la vista a pantalla
|
|
209
|
+
// completa hay dos campos de texto en el formulario, y con más de uno el navegador no hace el
|
|
210
|
+
// envío implícito. requestSubmit valida y dispara `submit` como el envío nativo.
|
|
211
|
+
const form = barInputRef.current?.form;
|
|
212
|
+
if (!form)
|
|
213
|
+
return;
|
|
214
|
+
const submitter = defaultSubmitter(form);
|
|
215
|
+
if (submitter === 'blocked')
|
|
216
|
+
return;
|
|
217
|
+
form.requestSubmit(submitter);
|
|
218
|
+
}, [requestClose]);
|
|
219
|
+
const handleKeyDown = useCallback((e, where) => {
|
|
220
|
+
if (e.nativeEvent.isComposing || e.ctrlKey || e.metaKey)
|
|
221
|
+
return;
|
|
222
|
+
const s = latest.current;
|
|
223
|
+
// La barra a pantalla completa no muestra la lista: abre la vista (que la tiene).
|
|
224
|
+
const opensView = s.mode === 'full-screen' && where === 'bar';
|
|
225
|
+
const shown = where === 'view' || (!opensView && s.expanded);
|
|
226
|
+
switch (e.key) {
|
|
227
|
+
case 'ArrowDown':
|
|
228
|
+
case 'ArrowUp': {
|
|
229
|
+
if (!s.hasView)
|
|
230
|
+
return;
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
const down = e.key === 'ArrowDown';
|
|
233
|
+
if (opensView) {
|
|
234
|
+
if (down || !e.altKey)
|
|
235
|
+
requestOpen();
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (e.altKey) {
|
|
239
|
+
// Alt+Flecha abajo abre sin activar; Alt+Flecha arriba cierra (APG).
|
|
240
|
+
if (down)
|
|
241
|
+
requestOpen();
|
|
242
|
+
else
|
|
243
|
+
requestClose();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const list = enabledOptions(listboxRef.current);
|
|
247
|
+
if (!shown) {
|
|
248
|
+
// Cerrada: abre y activa la primera (abajo) o la última (arriba), como APG.
|
|
249
|
+
requestOpen();
|
|
250
|
+
setActiveId((down ? list[0] : list.at(-1))?.id ?? null);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (list.length === 0)
|
|
254
|
+
return;
|
|
255
|
+
const i = list.findIndex((o) => o.id === s.activeId);
|
|
256
|
+
const next = down ? (i < 0 || i === list.length - 1 ? 0 : i + 1) : i <= 0 ? list.length - 1 : i - 1;
|
|
257
|
+
setActiveId(list[next]?.id ?? null);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
case 'Enter': {
|
|
261
|
+
if (e.altKey || e.shiftKey)
|
|
262
|
+
return;
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
if (shown && s.activeId)
|
|
265
|
+
select(s.activeId, e);
|
|
266
|
+
else
|
|
267
|
+
submit();
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
case 'Escape': {
|
|
271
|
+
// En la vista a pantalla completa, Escape cierra la vista. Se cancela el Escape nativo:
|
|
272
|
+
// en un campo de búsqueda con texto, Chrome lo usa para borrarlo (y el <dialog> no
|
|
273
|
+
// recibe el cancel).
|
|
274
|
+
if (where === 'view') {
|
|
275
|
+
e.preventDefault();
|
|
276
|
+
requestClose();
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (shown) {
|
|
280
|
+
e.preventDefault();
|
|
281
|
+
requestClose();
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
if (s.value !== '') {
|
|
285
|
+
e.preventDefault();
|
|
286
|
+
setValue('', e);
|
|
287
|
+
setActiveId(null);
|
|
288
|
+
}
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
case 'Delete': {
|
|
292
|
+
// Con una sugerencia activa, Supr es sobre ella (el foco visual), no sobre el texto: la
|
|
293
|
+
// quita si tiene onRemove y, si no, no hace nada (no borra a ciegas una letra del campo).
|
|
294
|
+
// Sin activa, es la edición del texto de siempre. Retroceso queda siempre para el texto.
|
|
295
|
+
if (!shown || !s.activeId)
|
|
296
|
+
return;
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
const data = options.current.get(s.activeId);
|
|
299
|
+
if (!data?.onRemove || data.disabled)
|
|
300
|
+
return;
|
|
301
|
+
const list = enabledOptions(listboxRef.current);
|
|
302
|
+
const i = list.findIndex((o) => o.id === s.activeId);
|
|
303
|
+
// La próxima activa: la siguiente, o la anterior si era la última (cuando el uso la saque
|
|
304
|
+
// del DOM; si no la saca, la activa queda donde estaba).
|
|
305
|
+
pendingRemoval.current = { removed: s.activeId, next: (list[i + 1] ?? list[i - 1])?.id ?? null };
|
|
306
|
+
announceRemoval.current?.(data.textValue);
|
|
307
|
+
data.onRemove(data.value);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
case 'ArrowLeft':
|
|
311
|
+
case 'ArrowRight':
|
|
312
|
+
case 'Home':
|
|
313
|
+
case 'End':
|
|
314
|
+
// Volver a editar el texto: la sugerencia activa se suelta (APG).
|
|
315
|
+
setActiveId(null);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
}, [requestOpen, requestClose, select, submit, setValue]);
|
|
319
|
+
const ctx = useMemo(() => {
|
|
320
|
+
// anchor-name tiene que ser un <dashed-ident>: sin los caracteres que pone useId.
|
|
321
|
+
const safe = id.replace(/[^a-zA-Z0-9_-]/g, '');
|
|
322
|
+
return {
|
|
323
|
+
mode,
|
|
324
|
+
open,
|
|
325
|
+
expanded,
|
|
326
|
+
value,
|
|
327
|
+
activeId,
|
|
328
|
+
listboxId: `${id}listbox`,
|
|
329
|
+
viewId: `${id}view`,
|
|
330
|
+
anchorName: `--mk-search-${safe}`,
|
|
331
|
+
hasView,
|
|
332
|
+
bar,
|
|
333
|
+
rootRef,
|
|
334
|
+
barRef,
|
|
335
|
+
barInputRef,
|
|
336
|
+
viewInputRef,
|
|
337
|
+
listboxRef,
|
|
338
|
+
options,
|
|
339
|
+
pendingRemoval,
|
|
340
|
+
announceRemoval,
|
|
341
|
+
removeHintId: `${id}remove-hint`,
|
|
342
|
+
setHasView,
|
|
343
|
+
setExpanded,
|
|
344
|
+
setBar,
|
|
345
|
+
setActiveId,
|
|
346
|
+
changeValue,
|
|
347
|
+
clear,
|
|
348
|
+
requestOpen,
|
|
349
|
+
requestClose,
|
|
350
|
+
select,
|
|
351
|
+
handleKeyDown,
|
|
352
|
+
};
|
|
353
|
+
}, [id, mode, open, expanded, value, activeId, hasView, bar, changeValue, clear, requestOpen, requestClose, select, handleKeyDown]);
|
|
354
|
+
return (_jsx(SearchContext, { value: ctx, children: _jsx("search", { ...rest, ref: setRootRef, className: cx('mk-search', className), "data-view": mode, onPointerDown: (e) => {
|
|
355
|
+
onPointerDown?.(e);
|
|
356
|
+
markPointerFocus(e.currentTarget, true);
|
|
357
|
+
pointerGesture.start();
|
|
358
|
+
}, onKeyDown: (e) => {
|
|
359
|
+
onKeyDown?.(e);
|
|
360
|
+
if (NAVIGATION_KEYS.has(e.key))
|
|
361
|
+
markPointerFocus(e.currentTarget, false);
|
|
362
|
+
}, onFocus: (e) => {
|
|
363
|
+
onFocus?.(e);
|
|
364
|
+
// El foco entra desde afuera sin un gesto de puntero en curso: Tab, un atajo o un foco
|
|
365
|
+
// por script. Con un gesto en curso (el botón de borrar, que en WebKit no se enfoca con el
|
|
366
|
+
// clic y deja ir el foco al <body> antes de devolverlo al campo), la marca sigue.
|
|
367
|
+
const from = e.relatedTarget;
|
|
368
|
+
if (from instanceof Node && e.currentTarget.contains(from))
|
|
369
|
+
return;
|
|
370
|
+
if (!pointerGesture.active())
|
|
371
|
+
markPointerFocus(e.currentTarget, false);
|
|
372
|
+
}, children: children }) }));
|
|
373
|
+
}
|
|
374
|
+
/**
|
|
375
|
+
* The search bar: a 56 pill (kit) with the `<input type="search">`, the start and end parts
|
|
376
|
+
* (`SearchBarLeading`, `SearchBarTrailing`) and a clear button while there is text.
|
|
377
|
+
*
|
|
378
|
+
* The accessible name is required (`label`, `aria-labelledby` or `aria-label`): the hint text
|
|
379
|
+
* (`placeholder`) is not a name. Native props (`name`, `placeholder`, `disabled`, `autoFocus`,
|
|
380
|
+
* `onFocus`…) and `ref` go to the `<input>`; `className` and `style`, to the pill. With a
|
|
381
|
+
* `SearchView` in the same `Search`, the input is a `combobox` (APG); without one, a plain search
|
|
382
|
+
* field.
|
|
383
|
+
*
|
|
384
|
+
* Inside a `<form>`, Enter submits the form (with `name`, the text is sent like any other field).
|
|
385
|
+
*/
|
|
386
|
+
export function SearchBar({ label, 'aria-label': ariaLabel, 'aria-labelledby': labelledBy, placeholder, clearLabel = searchStrings.clearLabel, className, style, children, ref, onChange, onKeyDown, onClick, onBlur, autoComplete, ...inputProps }) {
|
|
387
|
+
const ctx = useSearch('SearchBar');
|
|
388
|
+
const { setBar, barRef, barInputRef } = ctx;
|
|
389
|
+
const setInputRef = useMemo(() => mergeRefs(barInputRef, ref), [barInputRef, ref]);
|
|
390
|
+
const name = useMemo(() => ({ 'aria-label': label ?? ariaLabel, 'aria-labelledby': labelledBy }), [label, ariaLabel, labelledBy]);
|
|
391
|
+
// La vista a pantalla completa repite el nombre, el texto de ayuda y el botón de borrar.
|
|
392
|
+
useLayoutEffect(() => {
|
|
393
|
+
setBar({ name, placeholder, clearLabel });
|
|
394
|
+
}, [setBar, name, placeholder, clearLabel]);
|
|
395
|
+
const docked = ctx.mode === 'docked';
|
|
396
|
+
const combobox = !ctx.hasView
|
|
397
|
+
? {}
|
|
398
|
+
: docked
|
|
399
|
+
? {
|
|
400
|
+
role: 'combobox',
|
|
401
|
+
'aria-autocomplete': 'list',
|
|
402
|
+
'aria-expanded': ctx.expanded,
|
|
403
|
+
'aria-controls': ctx.listboxId,
|
|
404
|
+
'aria-activedescendant': ctx.expanded && ctx.activeId ? ctx.activeId : undefined,
|
|
405
|
+
}
|
|
406
|
+
: {
|
|
407
|
+
// A pantalla completa la barra abre un diálogo con su propio combobox (APG admite un
|
|
408
|
+
// combobox cuyo popup es un dialog).
|
|
409
|
+
role: 'combobox',
|
|
410
|
+
'aria-haspopup': 'dialog',
|
|
411
|
+
'aria-expanded': ctx.open,
|
|
412
|
+
'aria-controls': ctx.viewId,
|
|
413
|
+
};
|
|
414
|
+
const handleChange = (e) => {
|
|
415
|
+
onChange?.(e);
|
|
416
|
+
ctx.changeValue(e.target.value, e);
|
|
417
|
+
};
|
|
418
|
+
const handleKeyDown = (e) => {
|
|
419
|
+
onKeyDown?.(e);
|
|
420
|
+
if (!e.defaultPrevented)
|
|
421
|
+
ctx.handleKeyDown(e, 'bar');
|
|
422
|
+
};
|
|
423
|
+
const handleClick = (e) => {
|
|
424
|
+
onClick?.(e);
|
|
425
|
+
if (!e.defaultPrevented)
|
|
426
|
+
ctx.requestOpen();
|
|
427
|
+
};
|
|
428
|
+
// Docked: el foco que sale de la búsqueda (clic afuera, Tab) cierra las sugerencias. Un clic en
|
|
429
|
+
// una sugerencia no le saca el foco al input (SearchView cancela el mousedown).
|
|
430
|
+
const handleBlur = (e) => {
|
|
431
|
+
onBlur?.(e);
|
|
432
|
+
if (!docked)
|
|
433
|
+
return;
|
|
434
|
+
const next = e.relatedTarget;
|
|
435
|
+
if (next instanceof Node && ctx.rootRef.current?.contains(next))
|
|
436
|
+
return;
|
|
437
|
+
ctx.requestClose();
|
|
438
|
+
};
|
|
439
|
+
// Un clic en la píldora fuera del input (el relleno, el contenedor) lo enfoca.
|
|
440
|
+
const handlePillClick = (e) => {
|
|
441
|
+
if (e.target !== e.currentTarget)
|
|
442
|
+
return;
|
|
443
|
+
const input = barInputRef.current;
|
|
444
|
+
if (!input || input.disabled)
|
|
445
|
+
return;
|
|
446
|
+
input.focus();
|
|
447
|
+
ctx.requestOpen();
|
|
448
|
+
};
|
|
449
|
+
const parts = splitBarParts(children);
|
|
450
|
+
return (_jsxs("div", { ref: barRef, className: cx('mk-search-bar', className), style: { ...style, anchorName: ctx.anchorName }, onClick: handlePillClick, children: [_jsx(StateLayer, {}), _jsx(FocusRing, {}), parts.before, _jsx("input", { enterKeyHint: "search", spellCheck: false, ...inputProps, ...combobox, ...name, ref: setInputRef, type: "search",
|
|
451
|
+
// Sin la lista de autocompletado del navegador, que taparía las sugerencias.
|
|
452
|
+
autoComplete: autoComplete ?? (ctx.hasView ? 'off' : undefined), className: "mk-search-input", value: ctx.value, placeholder: placeholder, onChange: handleChange, onKeyDown: handleKeyDown, onClick: handleClick, onBlur: handleBlur }), ctx.value !== '' && !inputProps.disabled && !inputProps.readOnly && (_jsx(ClearButton, { label: clearLabel, onClear: (e) => ctx.clear('bar', e) })), parts.after] }));
|
|
453
|
+
}
|
|
454
|
+
// Reparte los hijos de la barra (M1 del plan, WCAG 2.4.3): SearchBarTrailing va después del <input> (y
|
|
455
|
+
// del botón de borrar) y lo demás (SearchBarLeading) antes, para que el orden del DOM, el de Tab y el
|
|
456
|
+
// del lector sea el que se ve, escriba el uso las partes en el orden que las escriba. Entra en los
|
|
457
|
+
// fragmentos (`{cond && <>…</>}`); una parte envuelta en un componente propio no se reconoce y queda
|
|
458
|
+
// antes, como hasta la 0.1.0 (la grilla la ubica igual).
|
|
459
|
+
function splitBarParts(children, before = [], after = [], prefix = '') {
|
|
460
|
+
for (const child of Children.toArray(children)) {
|
|
461
|
+
if (!isValidElement(child)) {
|
|
462
|
+
before.push(child);
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
const keyed = prefix ? cloneElement(child, { key: `${prefix}${String(child.key)}` }) : child;
|
|
466
|
+
if (child.type === Fragment) {
|
|
467
|
+
splitBarParts(child.props.children, before, after, `${prefix}${String(child.key)}/`);
|
|
468
|
+
}
|
|
469
|
+
else if (child.type === SearchBarTrailing) {
|
|
470
|
+
after.push(keyed);
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
before.push(keyed);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return { before, after };
|
|
477
|
+
}
|
|
478
|
+
function ClearButton({ label, onClear }) {
|
|
479
|
+
return (_jsx("span", { className: "mk-search-bar-clear", children: _jsx(IconButton, { label: label, onClick: onClear, children: _jsx(CloseIcon, {}) }) }));
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* The search suggestions: a `listbox` with `SearchSuggestion` and `SearchSuggestionGroup` as
|
|
483
|
+
* children. Native props and `ref` go to the `<ul role="listbox">`; `className` and `style`, to the
|
|
484
|
+
* layer that contains it.
|
|
485
|
+
*
|
|
486
|
+
* - **Docked** (medium or wider windows that are at least 480 px tall, or `view="docked"`): a top-layer popover anchored below
|
|
487
|
+
* the bar, 2 px apart, as wide as the bar, Surface Container High with a 12 radius (kit). It opens
|
|
488
|
+
* on typing, on a click in the bar or with the arrows, and closes with Escape, on choosing, on
|
|
489
|
+
* searching or when focus leaves the search.
|
|
490
|
+
* - **Full screen** (compact windows, narrow or short, or `view="full-screen"`): a modal `<dialog>` with its own bar
|
|
491
|
+
* (back, the field and clear) and the list below; focus is trapped, Escape and the back button
|
|
492
|
+
* close it, and focus returns to the bar.
|
|
493
|
+
*
|
|
494
|
+
* With text and no suggestions (and not loading), it shows `emptyLabel`. The count is announced in
|
|
495
|
+
* a polite live region half a second after the last change.
|
|
496
|
+
*/
|
|
497
|
+
export function SearchView({ loading = false, loadingLabel = searchStrings.loadingLabel, emptyLabel = searchStrings.emptyLabel, formatCount = searchStrings.formatCount, closeLabel = searchStrings.closeLabel, formatRemoved = searchStrings.formatRemoved, removeHint = searchStrings.removeHint, className, style, children, ref, ...listboxProps }) {
|
|
498
|
+
const ctx = useSearch('SearchView');
|
|
499
|
+
const { setHasView, setExpanded, setActiveId, listboxRef, barRef, viewInputRef, requestClose, pendingRemoval, announceRemoval } = ctx;
|
|
500
|
+
const docked = ctx.mode === 'docked';
|
|
501
|
+
const setListRef = useMemo(() => mergeRefs(listboxRef, ref), [listboxRef, ref]);
|
|
502
|
+
useLayoutEffect(() => {
|
|
503
|
+
setHasView(true);
|
|
504
|
+
return () => setHasView(false);
|
|
505
|
+
}, [setHasView]);
|
|
506
|
+
// Cantidad de opciones, del DOM: también cambia si un hijo propio del uso se actualiza solo.
|
|
507
|
+
// Si la activa desaparece, ya no hay activa.
|
|
508
|
+
const [count, setCount] = useState(0);
|
|
509
|
+
const activeRef = useRef(ctx.activeId);
|
|
510
|
+
activeRef.current = ctx.activeId;
|
|
511
|
+
useLayoutEffect(() => {
|
|
512
|
+
const list = listboxRef.current;
|
|
513
|
+
if (!list)
|
|
514
|
+
return;
|
|
515
|
+
const update = () => {
|
|
516
|
+
setCount(list.querySelectorAll('[role="option"]').length);
|
|
517
|
+
const active = activeRef.current;
|
|
518
|
+
if (active && !list.contains(document.getElementById(active))) {
|
|
519
|
+
// La activa desapareció. Si fue la quitada con Supr, pasa a su vecina (si sigue en la lista).
|
|
520
|
+
const pending = pendingRemoval.current;
|
|
521
|
+
const next = pending?.removed === active ? pending.next : null;
|
|
522
|
+
setActiveId(next && list.contains(document.getElementById(next)) ? next : null);
|
|
523
|
+
pendingRemoval.current = null;
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
update();
|
|
527
|
+
const observer = new MutationObserver(update);
|
|
528
|
+
observer.observe(list, { childList: true, subtree: true });
|
|
529
|
+
return () => observer.disconnect();
|
|
530
|
+
}, [listboxRef, setActiveId, docked]);
|
|
531
|
+
const empty = !loading && count === 0 && ctx.value !== '';
|
|
532
|
+
const expanded = docked ? ctx.open && (count > 0 || loading || ctx.value !== '') : ctx.open;
|
|
533
|
+
useLayoutEffect(() => {
|
|
534
|
+
setExpanded(expanded);
|
|
535
|
+
}, [expanded, setExpanded]);
|
|
536
|
+
// La sugerencia activa a la vista dentro de la lista.
|
|
537
|
+
useEffect(() => {
|
|
538
|
+
if (!ctx.activeId)
|
|
539
|
+
return;
|
|
540
|
+
document.getElementById(ctx.activeId)?.scrollIntoView({ block: 'nearest' });
|
|
541
|
+
}, [ctx.activeId]);
|
|
542
|
+
// Región viva: la cantidad, la carga o el vacío, medio segundo después del último cambio (no en
|
|
543
|
+
// cada tecla); al cerrar, se vacía enseguida.
|
|
544
|
+
const message = !expanded ? '' : loading ? loadingLabel : count > 0 ? formatCount(count) : empty ? emptyLabel : '';
|
|
545
|
+
const [announced, setAnnounced] = useState('');
|
|
546
|
+
// Después de quitar una sugerencia se anuncia `formatRemoved` enseguida, y el cambio de cantidad que
|
|
547
|
+
// provoca (o que se cierre la lista) no lo pisa durante un segundo.
|
|
548
|
+
const quietUntil = useRef(0);
|
|
549
|
+
useLayoutEffect(() => {
|
|
550
|
+
announceRemoval.current = (text) => {
|
|
551
|
+
quietUntil.current = performance.now() + REMOVAL_QUIET_MS;
|
|
552
|
+
setAnnounced(formatRemoved(text));
|
|
553
|
+
};
|
|
554
|
+
return () => {
|
|
555
|
+
announceRemoval.current = null;
|
|
556
|
+
};
|
|
557
|
+
}, [announceRemoval, formatRemoved]);
|
|
558
|
+
useEffect(() => {
|
|
559
|
+
const quiet = Math.max(0, quietUntil.current - performance.now());
|
|
560
|
+
if (message === '') {
|
|
561
|
+
if (quiet === 0) {
|
|
562
|
+
setAnnounced('');
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
const timer = setTimeout(() => setAnnounced(''), quiet);
|
|
566
|
+
return () => clearTimeout(timer);
|
|
567
|
+
}
|
|
568
|
+
const timer = setTimeout(() => {
|
|
569
|
+
if (performance.now() < quietUntil.current)
|
|
570
|
+
return;
|
|
571
|
+
setAnnounced(message);
|
|
572
|
+
}, ANNOUNCE_DELAY_MS);
|
|
573
|
+
return () => clearTimeout(timer);
|
|
574
|
+
}, [message]);
|
|
575
|
+
// --- Docked: la capa anclada debajo de la barra ---
|
|
576
|
+
const popupRef = useRef(null);
|
|
577
|
+
const closing = useRef(null);
|
|
578
|
+
const place = useCallback(() => {
|
|
579
|
+
const popup = popupRef.current;
|
|
580
|
+
const anchor = barRef.current;
|
|
581
|
+
if (!popup || !anchor)
|
|
582
|
+
return;
|
|
583
|
+
// Del ancho de la barra (Compose: el desplegable mide lo que la barra colapsada). Con anchor
|
|
584
|
+
// positioning lo da el CSS (la columna del ancla, estirada); sin él, se escribe acá.
|
|
585
|
+
if (!supportsAnchorPositioning())
|
|
586
|
+
popup.style.inlineSize = `${anchor.getBoundingClientRect().width}px`;
|
|
587
|
+
placeNextTo(popup, anchor, { gap: 2 });
|
|
588
|
+
}, [barRef]);
|
|
589
|
+
useLayoutEffect(() => {
|
|
590
|
+
const popup = popupRef.current;
|
|
591
|
+
if (!popup || !docked)
|
|
592
|
+
return;
|
|
593
|
+
if (expanded) {
|
|
594
|
+
closing.current = null;
|
|
595
|
+
popup.removeAttribute('data-closing');
|
|
596
|
+
if (!popup.matches(':popover-open'))
|
|
597
|
+
popup.showPopover();
|
|
598
|
+
place();
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (!popup.matches(':popover-open') || closing.current)
|
|
602
|
+
return;
|
|
603
|
+
// Salida: data-closing dispara las transiciones (search.css); se oculta al terminar (mismo
|
|
604
|
+
// patrón que Menu, src/internal/settle-animations.ts).
|
|
605
|
+
const token = {};
|
|
606
|
+
closing.current = token;
|
|
607
|
+
popup.setAttribute('data-closing', '');
|
|
608
|
+
void settleAnimations(popup, () => closing.current === token).then(() => {
|
|
609
|
+
if (closing.current !== token)
|
|
610
|
+
return;
|
|
611
|
+
closing.current = null;
|
|
612
|
+
popup.removeAttribute('data-closing');
|
|
613
|
+
if (popup.matches(':popover-open'))
|
|
614
|
+
popup.hidePopover();
|
|
615
|
+
});
|
|
616
|
+
}, [expanded, docked, place]);
|
|
617
|
+
useLayoutEffect(() => () => {
|
|
618
|
+
closing.current = null;
|
|
619
|
+
}, []);
|
|
620
|
+
// Abierta: seguir el ancho de la barra; sin anchor positioning, también su posición.
|
|
621
|
+
useEffect(() => {
|
|
622
|
+
if (!docked || !expanded)
|
|
623
|
+
return;
|
|
624
|
+
const anchor = barRef.current;
|
|
625
|
+
const observer = new ResizeObserver(() => place());
|
|
626
|
+
if (anchor)
|
|
627
|
+
observer.observe(anchor);
|
|
628
|
+
const unfollow = followAnchor(place);
|
|
629
|
+
return () => {
|
|
630
|
+
observer.disconnect();
|
|
631
|
+
unfollow();
|
|
632
|
+
};
|
|
633
|
+
}, [docked, expanded, place, barRef]);
|
|
634
|
+
// --- Pantalla completa: <dialog> modal (src/internal/modal-dialog.ts, ADR-0025) ---
|
|
635
|
+
const viewBarRef = useRef(null);
|
|
636
|
+
const { setRef: setDialogRef, dialogProps } = useModalDialog({
|
|
637
|
+
open: !docked && ctx.open,
|
|
638
|
+
// Cualquier pedido (Escape, el cierre del navegador) cierra la vista: el motivo no hace falta.
|
|
639
|
+
onRequestClose: requestClose,
|
|
640
|
+
closeOnScrimClick: false,
|
|
641
|
+
contentSelector: '.mk-search-view-results',
|
|
642
|
+
onOpen: () => expandFromBar(barRef.current, viewBarRef.current),
|
|
643
|
+
});
|
|
644
|
+
// El cursor al final del texto en el campo de la vista (useModalDialog ya lo enfocó).
|
|
645
|
+
useLayoutEffect(() => {
|
|
646
|
+
if (docked || !ctx.open)
|
|
647
|
+
return;
|
|
648
|
+
const input = viewInputRef.current;
|
|
649
|
+
if (input && document.activeElement === input)
|
|
650
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
651
|
+
}, [docked, ctx.open, viewInputRef]);
|
|
652
|
+
// Un clic en la lista no le saca el foco al input (el combobox lo conserva, APG).
|
|
653
|
+
const keepFocus = (e) => {
|
|
654
|
+
if (e.button === 0)
|
|
655
|
+
e.preventDefault();
|
|
656
|
+
};
|
|
657
|
+
const listName = ctx.bar.name;
|
|
658
|
+
const results = (_jsxs(_Fragment, { children: [loading && _jsx(LinearProgressIndicator, { label: loadingLabel, className: "mk-search-progress" }), empty && _jsx("p", { className: "mk-search-empty", children: emptyLabel }), _jsx("span", { hidden: true, id: ctx.removeHintId, children: removeHint }), _jsx("ul", { ...listName, ...listboxProps, ref: setListRef, id: ctx.listboxId, role: "listbox", className: "mk-list mk-search-listbox", children: children })] }));
|
|
659
|
+
const status = (_jsx("span", { role: "status", className: "mk-search-status", children: announced }));
|
|
660
|
+
if (docked) {
|
|
661
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { ref: popupRef, popover: "manual", className: cx('mk-search-results', className), style: { ...style, '--_anchor': ctx.anchorName }, onMouseDown: keepFocus, children: results }), status] }));
|
|
662
|
+
}
|
|
663
|
+
return (_jsxs("dialog", { ...dialogProps, ref: setDialogRef, id: ctx.viewId, ...listName, className: cx('mk-search-view', className), style: style, children: [_jsx("div", { className: "mk-search-view-header", children: _jsxs("div", { ref: viewBarRef, className: "mk-search-bar", "data-in-view": "", children: [_jsx(StateLayer, {}), _jsx(FocusRing, {}), _jsx("span", { className: "mk-search-bar-leading", children: _jsx(IconButton, { label: closeLabel, className: "mk-search-view-close", onClick: requestClose, children: _jsx(ArrowBackIcon, {}) }) }), _jsx(ViewInput, {}), ctx.value !== '' && _jsx(ClearButton, { label: ctx.bar.clearLabel, onClear: (e) => ctx.clear('view', e) })] }) }), _jsx("div", { className: "mk-search-view-results", onMouseDown: keepFocus, children: results }), status] }));
|
|
664
|
+
}
|
|
665
|
+
// El campo de la vista a pantalla completa: el combobox con la lista, sin `name` (el valor viaja en el de la barra).
|
|
666
|
+
function ViewInput() {
|
|
667
|
+
const ctx = useSearch('SearchView');
|
|
668
|
+
return (_jsx("input", { ref: ctx.viewInputRef, ...ctx.bar.name, type: "search", enterKeyHint: "search", spellCheck: false, autoComplete: "off", className: "mk-search-input", "data-autofocus": "", role: "combobox", "aria-autocomplete": "list", "aria-expanded": ctx.open, "aria-controls": ctx.listboxId, "aria-activedescendant": ctx.open && ctx.activeId ? ctx.activeId : undefined, value: ctx.value, placeholder: ctx.bar.placeholder, onChange: (e) => ctx.changeValue(e.target.value, e), onKeyDown: (e) => ctx.handleKeyDown(e, 'view') }));
|
|
669
|
+
}
|
|
670
|
+
// La barra de la vista sale del lugar de la barra colapsada y se estira hasta el suyo (FLIP con la
|
|
671
|
+
// Web Animations API, el resorte FastSpatial de Compose `rememberContainedSearchBarState`). Con
|
|
672
|
+
// movimiento reducido, el resorte spatial vale 0: sin desplazamiento.
|
|
673
|
+
function expandFromBar(from, to) {
|
|
674
|
+
if (!from || !to)
|
|
675
|
+
return;
|
|
676
|
+
const css = getComputedStyle(to);
|
|
677
|
+
const duration = Number.parseFloat(css.getPropertyValue('--md-sys-motion-spring-fast-spatial-duration'));
|
|
678
|
+
if (!(duration > 0))
|
|
679
|
+
return;
|
|
680
|
+
const a = from.getBoundingClientRect();
|
|
681
|
+
const b = to.getBoundingClientRect();
|
|
682
|
+
if (a.width === 0 || b.width === 0)
|
|
683
|
+
return;
|
|
684
|
+
// El inicio del renglón: el ancho cambia desde ese borde (el derecho en RTL).
|
|
685
|
+
const rtl = css.direction === 'rtl';
|
|
686
|
+
const dx = rtl ? a.right - b.right : a.left - b.left;
|
|
687
|
+
const dy = a.top - b.top;
|
|
688
|
+
to.animate([
|
|
689
|
+
{ translate: `${dx}px ${dy}px`, inlineSize: `${a.width}px` },
|
|
690
|
+
{ translate: '0 0', inlineSize: `${b.width}px` },
|
|
691
|
+
], { duration, easing: css.getPropertyValue('--md-sys-motion-spring-fast-spatial-easing').trim() || 'ease' });
|
|
692
|
+
}
|
|
693
|
+
/**
|
|
694
|
+
* A suggestion: a `listbox` option (`<li role="option">`) that looks like a list item (`ListItem`,
|
|
695
|
+
* ADR-0018): its parts `ListItemLeading`, `ListItemHeadline`, `ListItemSupporting` and
|
|
696
|
+
* `ListItemTrailing` go as children. Without children (or with only text), it shows the text as a
|
|
697
|
+
* `ListItemHeadline`.
|
|
698
|
+
*
|
|
699
|
+
* It does not take focus: the arrows mark the active one with `aria-activedescendant` and
|
|
700
|
+
* `aria-selected`, and it is chosen with Enter or a click. No controls inside (an option cannot
|
|
701
|
+
* contain interactive elements).
|
|
702
|
+
*
|
|
703
|
+
* Removing (for example, recent searches): with `onRemove`, Delete on the active one requests it,
|
|
704
|
+
* `formatRemoved` ("Removed …") is announced and the active one moves to the next when the app
|
|
705
|
+
* removes it. The search notifies; the app stores and deletes (like `InputChip`'s `onRemove`). There
|
|
706
|
+
* is no button in the option for the pointer: the app offers a separate action such as "Clear
|
|
707
|
+
* history".
|
|
708
|
+
*
|
|
709
|
+
* ```tsx
|
|
710
|
+
* const { recent, add, remove } = useRecentSearches('searches') // the app's (localStorage, for example)
|
|
711
|
+
* <Search onSubmit={add} onSelect={add} …>
|
|
712
|
+
* <SearchBar label="Search" />
|
|
713
|
+
* <SearchView>
|
|
714
|
+
* {recent.map((r) => <SearchSuggestion key={r} value={r} onRemove={remove} />)}
|
|
715
|
+
* </SearchView>
|
|
716
|
+
* </Search>
|
|
717
|
+
* ```
|
|
718
|
+
*
|
|
719
|
+
* ```tsx
|
|
720
|
+
* <SearchSuggestion value="mate cocido" />
|
|
721
|
+
* <SearchSuggestion value="p-17" textValue="Yerba">
|
|
722
|
+
* <ListItemLeading><HistoryIcon /></ListItemLeading>
|
|
723
|
+
* <ListItemHeadline>Yerba</ListItemHeadline>
|
|
724
|
+
* <ListItemSupporting>Grocery</ListItemSupporting>
|
|
725
|
+
* </SearchSuggestion>
|
|
726
|
+
* ```
|
|
727
|
+
*/
|
|
728
|
+
export function SearchSuggestion({ value, textValue, disabled = false, onRemove, id, className, children, onClick, 'aria-describedby': describedBy, ...rest }) {
|
|
729
|
+
const ctx = useSearch('SearchSuggestion');
|
|
730
|
+
const { options, select } = ctx;
|
|
731
|
+
const generatedId = useId();
|
|
732
|
+
const ownId = id ?? `${generatedId}option`;
|
|
733
|
+
const text = textValue ?? value;
|
|
734
|
+
useLayoutEffect(() => {
|
|
735
|
+
const registry = options.current;
|
|
736
|
+
registry.set(ownId, { value, textValue: text, disabled, onRemove });
|
|
737
|
+
return () => {
|
|
738
|
+
registry.delete(ownId);
|
|
739
|
+
};
|
|
740
|
+
}, [options, ownId, value, text, disabled, onRemove]);
|
|
741
|
+
const active = ctx.activeId === ownId;
|
|
742
|
+
return (_jsx(ListItem, { ...rest, id: ownId, role: "option", "aria-selected": active, "aria-disabled": disabled || undefined, "aria-describedby": [describedBy, onRemove && !disabled ? ctx.removeHintId : undefined].filter(Boolean).join(' ') || undefined, "data-active": active ? '' : undefined, className: cx('mk-search-suggestion', className), onClick: (e) => {
|
|
743
|
+
onClick?.(e);
|
|
744
|
+
if (!e.defaultPrevented)
|
|
745
|
+
select(ownId, e);
|
|
746
|
+
}, children: children === undefined || typeof children === 'string' ? (_jsx(ListItemHeadline, { children: children ?? text })) : (children) }));
|
|
747
|
+
}
|
|
748
|
+
const SearchSuggestionGroupContext = createContext(null);
|
|
749
|
+
/**
|
|
750
|
+
* A named group of suggestions: for example recent searches and suggested ones. Its children are a
|
|
751
|
+
* `SearchSuggestionGroupLabel` and the `SearchSuggestion`s. It is a `<ul role="group">` named by its
|
|
752
|
+
* label (APG's grouped listbox pattern), inside an `<li role="none">` (an `<li>` does not allow the
|
|
753
|
+
* `group` role). Native props and `ref` go to the `<ul>`; an `aria-labelledby` of your own wins.
|
|
754
|
+
*
|
|
755
|
+
* ```tsx
|
|
756
|
+
* <SearchSuggestionGroup>
|
|
757
|
+
* <SearchSuggestionGroupLabel>Recent</SearchSuggestionGroupLabel>
|
|
758
|
+
* {recent.map((r) => <SearchSuggestion key={r} value={r} />)}
|
|
759
|
+
* </SearchSuggestionGroup>
|
|
760
|
+
* ```
|
|
761
|
+
*/
|
|
762
|
+
export function SearchSuggestionGroup({ className, ...rest }) {
|
|
763
|
+
const { registry, labelledBy } = useGroupLabel(rest['aria-labelledby']);
|
|
764
|
+
return (_jsx("li", { role: "none", className: cx('mk-search-suggestion-group', className), children: _jsx(SearchSuggestionGroupContext, { value: registry, children: _jsx("ul", { ...rest, role: "group", "aria-labelledby": labelledBy, className: "mk-list mk-search-suggestion-group-list" }) }) }));
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* The visible name of a `SearchSuggestionGroup` (for example "Recent"), styled as a list subheader
|
|
768
|
+
* (Title Small, `on-surface-variant`). It names the group (`aria-labelledby`), without passing ids.
|
|
769
|
+
* It is not a suggestion: the arrows skip it.
|
|
770
|
+
*
|
|
771
|
+
* ```tsx
|
|
772
|
+
* <SearchSuggestionGroup><SearchSuggestionGroupLabel>Recent</SearchSuggestionGroupLabel>…</SearchSuggestionGroup>
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
775
|
+
export function SearchSuggestionGroupLabel({ className, ...props }) {
|
|
776
|
+
const registry = use(SearchSuggestionGroupContext);
|
|
777
|
+
if (!registry)
|
|
778
|
+
throw partOutsideParent('SearchSuggestionGroupLabel', 'SearchSuggestionGroup');
|
|
779
|
+
// La base (src/internal/group-label.tsx), común con MenuGroupLabel y SelectGroupLabel: el registro del
|
|
780
|
+
// id y la clase común. Un <li> porque el grupo es un <ul>; role="presentation" para que no sea un
|
|
781
|
+
// listitem dentro del listbox.
|
|
782
|
+
return (_jsx(GroupLabel, { role: "presentation", ...props, as: "li", registry: registry, className: cx('mk-search-suggestion-group-label', className) }));
|
|
783
|
+
}
|