@matekit/react 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -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 +106 -0
- package/dist/organisms/PaneScaffold/PaneScaffold.js +120 -0
- package/dist/organisms/Search/Search.d.ts +207 -0
- package/dist/organisms/Search/Search.js +754 -0
- package/dist/organisms/Search/SearchSlots.d.ts +16 -0
- package/dist/organisms/Search/SearchSlots.js +17 -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 +11991 -0
- package/dist/styles.css +12089 -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,106 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
2
|
+
import { type LayoutElementProps } from '../../internal/layout-element.tsx';
|
|
3
|
+
/** List-detail panes: the list, the detail of the chosen item and an optional extra one. */
|
|
4
|
+
export type ListDetailPaneName = 'list' | 'detail' | 'extra';
|
|
5
|
+
/** Supporting-pane panes: the main one, the supporting one and an optional extra one. */
|
|
6
|
+
export type SupportingPaneName = 'main' | 'supporting' | 'extra';
|
|
7
|
+
/** A pane's name, in either variant. */
|
|
8
|
+
export type PaneName = ListDetailPaneName | SupportingPaneName;
|
|
9
|
+
/** The variant: `list-detail` (`ListDetailPaneScaffold`) or `supporting` (`SupportingPaneScaffold`). */
|
|
10
|
+
export type PaneScaffoldVariant = 'list-detail' | 'supporting';
|
|
11
|
+
interface PaneScaffoldCommonProps extends LayoutElementProps {
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export interface PaneScaffoldListDetailProps extends PaneScaffoldCommonProps {
|
|
15
|
+
/** List and detail. Panes `list`, `detail` and, optionally, `extra`. Defaults to `list-detail`. */
|
|
16
|
+
variant?: 'list-detail' | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The pane the user is looking at: the only one shown when the scaffold fits one pane, and one of
|
|
19
|
+
* those shown when it fits more (Compose's current destination). Defaults to `list` (Compose
|
|
20
|
+
* starts on the list). Not `current`, which in matekit names the current navigation destination.
|
|
21
|
+
*/
|
|
22
|
+
pane?: ListDetailPaneName | undefined;
|
|
23
|
+
}
|
|
24
|
+
export interface PaneScaffoldSupportingProps extends PaneScaffoldCommonProps {
|
|
25
|
+
/** Content with a supporting pane. Panes `main`, `supporting` and, optionally, `extra`. */
|
|
26
|
+
variant: 'supporting';
|
|
27
|
+
/** The pane the user is looking at (see the list-detail `pane`). Defaults to `main`. */
|
|
28
|
+
pane?: SupportingPaneName | undefined;
|
|
29
|
+
}
|
|
30
|
+
export type PaneScaffoldProps = PaneScaffoldListDetailProps | PaneScaffoldSupportingProps;
|
|
31
|
+
/**
|
|
32
|
+
* Material 3 pane layout, list-detail or content with a supporting pane, showing one, two or three
|
|
33
|
+
* panes like Compose's `ListDetailPaneScaffold` and `SupportingPaneScaffold`. It counts panes by
|
|
34
|
+
* **its own width, not the window's** (unlike `NavigationSuite`, which follows the window): inside a
|
|
35
|
+
* layout with its own sidebar, a 900 px window can show the rail and a single pane.
|
|
36
|
+
*
|
|
37
|
+
* ```tsx
|
|
38
|
+
* <PaneScaffold pane={selected ? 'detail' : 'list'}>
|
|
39
|
+
* <NavigationSuite aria-label="Main">…</NavigationSuite>
|
|
40
|
+
* <Pane name="list" render={<nav aria-label="Messages" />}>
|
|
41
|
+
* <TopAppBar><TopAppBarTitle>Inbox</TopAppBarTitle></TopAppBar>
|
|
42
|
+
* <List>…</List>
|
|
43
|
+
* </Pane>
|
|
44
|
+
* <Pane name="detail" render={<main />}>
|
|
45
|
+
* <TopAppBar>…</TopAppBar>
|
|
46
|
+
* …
|
|
47
|
+
* </Pane>
|
|
48
|
+
* </PaneScaffold>
|
|
49
|
+
* ```
|
|
50
|
+
*
|
|
51
|
+
* - **How many panes:** by the width **of the scaffold** (rail included), with the window size class
|
|
52
|
+
* breakpoints: 1 below 840 px (`WINDOW_WIDTH.expanded`), 2 from 840 and 3 from 1200
|
|
53
|
+
* (`WINDOW_WIDTH.large`). Full screen, that is Compose's rule; inside a narrower layout (an app
|
|
54
|
+
* sidebar), it counts the room it really has. They are container queries: no JavaScript, also from
|
|
55
|
+
* a Server Component. The root has `container-type: inline-size`: in a context that sizes to its
|
|
56
|
+
* content (a flex item without a width), give it a width. Whatever the app shows depending on the
|
|
57
|
+
* number of panes (a back button only needed with one) uses the same container:
|
|
58
|
+
* `@container mk-pane-scaffold (width >= 52.5rem) { … }`.
|
|
59
|
+
* - **Which:** with one, the `pane`. With more, the `pane` and the higher-priority ones (Compose: the
|
|
60
|
+
* detail or the main pane, then the list or the supporting one, then the extra), from start to end:
|
|
61
|
+
* list, detail, extra; or main, supporting, extra. The rest stay mounted and hidden (also from
|
|
62
|
+
* accessibility): their state and scroll position are kept.
|
|
63
|
+
* - **Widths:** the secondary pane is 360 (412 from 1200), the detail or main pane takes the rest, 24
|
|
64
|
+
* between panes; if they do not fit, all shrink equally (Compose's split).
|
|
65
|
+
* - **Look (kit):** `surface` background. From a scaffold width of 600, panes with a surface (all but
|
|
66
|
+
* the list, or what `surface` says) are `surface-container-lowest` with a 28 top radius, 24 below
|
|
67
|
+
* the top edge and down to the bottom one, 24 at the start (0 next to the rail) and 16 at the end.
|
|
68
|
+
* Narrower (a phone, or a scaffold in little room), panes touch the edges, with no surface.
|
|
69
|
+
* - **Scrolling:** each pane scrolls on its own; a `TopAppBar` as first child sticks and collapses
|
|
70
|
+
* inside its pane (ADR-0024).
|
|
71
|
+
* - **Navigation:** a `NavigationSuite` child places itself: the rail at the start (panes stick to it)
|
|
72
|
+
* and the bar at the bottom, full width. Rail or bar is still decided by the window (ADR-0029).
|
|
73
|
+
* - **Height:** the window's (`100dvh`); inside another layout, set it with `style` or a class.
|
|
74
|
+
* - **Safe areas** (`env(safe-area-inset-*)`, with `viewport-fit=cover`): above the panes, on the sides
|
|
75
|
+
* and at the bottom (inside the pane, so it scrolls to the end), except where the `NavigationSuite`
|
|
76
|
+
* already takes them.
|
|
77
|
+
*
|
|
78
|
+
* Native props, `ref` and `render` (for example `render={<div role="presentation" />}`) reach the root
|
|
79
|
+
* `<div>`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function PaneScaffold({ variant, pane, className, style, children, ...props }: PaneScaffoldProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
82
|
+
export interface PaneProps extends LayoutElementProps {
|
|
83
|
+
/**
|
|
84
|
+
* Which pane it is: `list`, `detail` or `extra` in list-detail; `main`, `supporting` or `extra` in
|
|
85
|
+
* supporting. It decides its place, its priority and its width.
|
|
86
|
+
*/
|
|
87
|
+
name: PaneName;
|
|
88
|
+
/**
|
|
89
|
+
* Whether it has its own surface (`surface-container-lowest`, radius 28) from a width of 600.
|
|
90
|
+
* Defaults to `true` for every pane except `list`, which sits on the background as in the kit (its
|
|
91
|
+
* items bring their own background). In a compact window no pane has one.
|
|
92
|
+
*/
|
|
93
|
+
surface?: boolean | undefined;
|
|
94
|
+
children?: ReactNode;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* A pane of the `PaneScaffold`: a `<div>` that scrolls on its own (or the `render` element:
|
|
98
|
+
* `<main />` for the detail, `<nav aria-label="…" />` or `<section aria-label="…" />` for the list).
|
|
99
|
+
* It goes as a direct child of the scaffold, in start-to-end order (list, detail, extra), which is
|
|
100
|
+
* also the reading and Tab order.
|
|
101
|
+
*
|
|
102
|
+
* Its first child can be a `TopAppBar`: it sticks to the top of the pane and collapses as the pane
|
|
103
|
+
* scrolls. Native props, `ref` and `render` reach the element.
|
|
104
|
+
*/
|
|
105
|
+
export declare function Pane({ name, surface, className, style, children, ...props }: PaneProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
106
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Organismo universal (ADR-0003): sin estado, efectos, contexto ni eventos; no lleva 'use client'.
|
|
3
|
+
// Paneles de lista y detalle y de contenido con panel de apoyo, como ListDetailPaneScaffold y
|
|
4
|
+
// SupportingPaneScaffold de Compose (docs/research/11-disposicion-adaptable-compose.md § 2). API y
|
|
5
|
+
// motivos: ADR-0030.
|
|
6
|
+
//
|
|
7
|
+
// Todo lo que cambia con el ancho es CSS (pane-scaffold.css): cuántos paneles se ven, cuáles, su
|
|
8
|
+
// ancho, su superficie y los márgenes salen del ancho del propio scaffold (container queries sobre la
|
|
9
|
+
// raíz, con los cortes de ventana de Compose); la ubicación del NavigationSuite (rail o barra) sigue
|
|
10
|
+
// a la ventana, como la suite. Las zonas seguras también son CSS. El componente solo escribe el caso y el
|
|
11
|
+
// panel de `pane` en atributos (`data-variant`, `data-current`) y el nombre de cada panel
|
|
12
|
+
// (`data-pane`); así el HTML del servidor ya es el correcto y no hay salto al hidratar.
|
|
13
|
+
//
|
|
14
|
+
// Los paneles ocultos quedan montados (`display: none`): su estado de React y lo desplazado
|
|
15
|
+
// sobreviven al cambiar de ventana o de panel actual (comprobado en los tres motores, ADR-0030).
|
|
16
|
+
import { Children, Fragment, isValidElement } from 'react';
|
|
17
|
+
import { isDevelopment } from '../../internal/dev.js';
|
|
18
|
+
import { mkWarn } from '../../internal/diagnostics.js';
|
|
19
|
+
import { cx } from '../../internal/interactive.js';
|
|
20
|
+
import { layoutElement } from '../../internal/layout-element.js';
|
|
21
|
+
const PANES = {
|
|
22
|
+
'list-detail': ['list', 'detail', 'extra'],
|
|
23
|
+
supporting: ['main', 'supporting', 'extra'],
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Material 3 pane layout, list-detail or content with a supporting pane, showing one, two or three
|
|
27
|
+
* panes like Compose's `ListDetailPaneScaffold` and `SupportingPaneScaffold`. It counts panes by
|
|
28
|
+
* **its own width, not the window's** (unlike `NavigationSuite`, which follows the window): inside a
|
|
29
|
+
* layout with its own sidebar, a 900 px window can show the rail and a single pane.
|
|
30
|
+
*
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <PaneScaffold pane={selected ? 'detail' : 'list'}>
|
|
33
|
+
* <NavigationSuite aria-label="Main">…</NavigationSuite>
|
|
34
|
+
* <Pane name="list" render={<nav aria-label="Messages" />}>
|
|
35
|
+
* <TopAppBar><TopAppBarTitle>Inbox</TopAppBarTitle></TopAppBar>
|
|
36
|
+
* <List>…</List>
|
|
37
|
+
* </Pane>
|
|
38
|
+
* <Pane name="detail" render={<main />}>
|
|
39
|
+
* <TopAppBar>…</TopAppBar>
|
|
40
|
+
* …
|
|
41
|
+
* </Pane>
|
|
42
|
+
* </PaneScaffold>
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* - **How many panes:** by the width **of the scaffold** (rail included), with the window size class
|
|
46
|
+
* breakpoints: 1 below 840 px (`WINDOW_WIDTH.expanded`), 2 from 840 and 3 from 1200
|
|
47
|
+
* (`WINDOW_WIDTH.large`). Full screen, that is Compose's rule; inside a narrower layout (an app
|
|
48
|
+
* sidebar), it counts the room it really has. They are container queries: no JavaScript, also from
|
|
49
|
+
* a Server Component. The root has `container-type: inline-size`: in a context that sizes to its
|
|
50
|
+
* content (a flex item without a width), give it a width. Whatever the app shows depending on the
|
|
51
|
+
* number of panes (a back button only needed with one) uses the same container:
|
|
52
|
+
* `@container mk-pane-scaffold (width >= 52.5rem) { … }`.
|
|
53
|
+
* - **Which:** with one, the `pane`. With more, the `pane` and the higher-priority ones (Compose: the
|
|
54
|
+
* detail or the main pane, then the list or the supporting one, then the extra), from start to end:
|
|
55
|
+
* list, detail, extra; or main, supporting, extra. The rest stay mounted and hidden (also from
|
|
56
|
+
* accessibility): their state and scroll position are kept.
|
|
57
|
+
* - **Widths:** the secondary pane is 360 (412 from 1200), the detail or main pane takes the rest, 24
|
|
58
|
+
* between panes; if they do not fit, all shrink equally (Compose's split).
|
|
59
|
+
* - **Look (kit):** `surface` background. From a scaffold width of 600, panes with a surface (all but
|
|
60
|
+
* the list, or what `surface` says) are `surface-container-lowest` with a 28 top radius, 24 below
|
|
61
|
+
* the top edge and down to the bottom one, 24 at the start (0 next to the rail) and 16 at the end.
|
|
62
|
+
* Narrower (a phone, or a scaffold in little room), panes touch the edges, with no surface.
|
|
63
|
+
* - **Scrolling:** each pane scrolls on its own; a `TopAppBar` as first child sticks and collapses
|
|
64
|
+
* inside its pane (ADR-0024).
|
|
65
|
+
* - **Navigation:** a `NavigationSuite` child places itself: the rail at the start (panes stick to it)
|
|
66
|
+
* and the bar at the bottom, full width. Rail or bar is still decided by the window (ADR-0029).
|
|
67
|
+
* - **Height:** the window's (`100dvh`); inside another layout, set it with `style` or a class.
|
|
68
|
+
* - **Safe areas** (`env(safe-area-inset-*)`, with `viewport-fit=cover`): above the panes, on the sides
|
|
69
|
+
* and at the bottom (inside the pane, so it scrolls to the end), except where the `NavigationSuite`
|
|
70
|
+
* already takes them.
|
|
71
|
+
*
|
|
72
|
+
* Native props, `ref` and `render` (for example `render={<div role="presentation" />}`) reach the root
|
|
73
|
+
* `<div>`.
|
|
74
|
+
*/
|
|
75
|
+
export function PaneScaffold({ variant = 'list-detail', pane, className, style, children, ...props }) {
|
|
76
|
+
const shown = pane ?? (variant === 'supporting' ? 'main' : 'list');
|
|
77
|
+
if (isDevelopment())
|
|
78
|
+
warnPanesNotInVariant(variant, children);
|
|
79
|
+
return layoutElement('PaneScaffold', cx('mk-pane-scaffold', className), style, { ...props, 'data-variant': variant, 'data-current': shown }, _jsx("div", { className: "mk-pane-scaffold-grid", children: children }));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* A pane of the `PaneScaffold`: a `<div>` that scrolls on its own (or the `render` element:
|
|
83
|
+
* `<main />` for the detail, `<nav aria-label="…" />` or `<section aria-label="…" />` for the list).
|
|
84
|
+
* It goes as a direct child of the scaffold, in start-to-end order (list, detail, extra), which is
|
|
85
|
+
* also the reading and Tab order.
|
|
86
|
+
*
|
|
87
|
+
* Its first child can be a `TopAppBar`: it sticks to the top of the pane and collapses as the pane
|
|
88
|
+
* scrolls. Native props, `ref` and `render` reach the element.
|
|
89
|
+
*/
|
|
90
|
+
export function Pane({ name, surface = name !== 'list', className, style, children, ...props }) {
|
|
91
|
+
return layoutElement('Pane', cx('mk-pane', className), style, { ...props, 'data-pane': name, 'data-surface': surface ? '' : undefined }, children);
|
|
92
|
+
}
|
|
93
|
+
// Los `Pane` entre los hijos: directos, en arrays y en fragmentos.
|
|
94
|
+
function panesIn(children) {
|
|
95
|
+
const names = [];
|
|
96
|
+
for (const child of Children.toArray(children)) {
|
|
97
|
+
if (!isValidElement(child))
|
|
98
|
+
continue;
|
|
99
|
+
if (child.type === Pane && child.props.name)
|
|
100
|
+
names.push(child.props.name);
|
|
101
|
+
else if (child.type === Fragment)
|
|
102
|
+
names.push(...panesIn(child.props.children));
|
|
103
|
+
}
|
|
104
|
+
return names;
|
|
105
|
+
}
|
|
106
|
+
// En desarrollo, avisa una vez si un `Pane` tiene un nombre de otro caso (`main` en lista y detalle):
|
|
107
|
+
// nunca se mostraría. Mira los hijos directos, en arrays y en fragmentos; no ve los paneles que
|
|
108
|
+
// dibuja otro componente.
|
|
109
|
+
function warnPanesNotInVariant(variant, children) {
|
|
110
|
+
const valid = PANES[variant];
|
|
111
|
+
for (const name of panesIn(children)) {
|
|
112
|
+
if (valid.includes(name))
|
|
113
|
+
continue;
|
|
114
|
+
mkWarn('MK_PANE_NOT_IN_VARIANT', {
|
|
115
|
+
component: 'PaneScaffold',
|
|
116
|
+
problem: `has a <Pane name="${name}">, which is not a pane of variant="${variant}" and is never shown`,
|
|
117
|
+
fix: `use one of ${valid.map((n) => `"${n}"`).join(', ')}, or set variant="${variant === 'list-detail' ? 'supporting' : 'list-detail'}"`,
|
|
118
|
+
}, { name, variant, valid });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { type ChangeEvent, type HTMLAttributes, type InputHTMLAttributes, type KeyboardEvent, type LiHTMLAttributes, type MouseEvent, type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type ListItemProps } from '../List/List.tsx';
|
|
3
|
+
import type { AccessibleNameProps } from '../../internal/accessible-name.ts';
|
|
4
|
+
/** How the suggestions are shown: below the bar (`docked`) or in a modal view that fills the screen. */
|
|
5
|
+
export type SearchViewMode = 'docked' | 'full-screen';
|
|
6
|
+
/**
|
|
7
|
+
* Which view the search uses. `auto` (the default) chooses by the window width: full screen in the
|
|
8
|
+
* compact class (under 600 px, `WINDOW_WIDTH.medium`) and docked from medium.
|
|
9
|
+
*/
|
|
10
|
+
export type SearchViewChoice = 'auto' | SearchViewMode;
|
|
11
|
+
/**
|
|
12
|
+
* The event behind a text change (`onValueChange`): typing (`change`), Escape that clears the text or
|
|
13
|
+
* Enter on a suggestion (`keydown`), the clear button or a click on a suggestion (`click`).
|
|
14
|
+
*/
|
|
15
|
+
export type SearchChangeEvent = ChangeEvent<HTMLInputElement> | KeyboardEvent<HTMLInputElement> | MouseEvent<HTMLElement>;
|
|
16
|
+
export interface SearchProps extends Omit<HTMLAttributes<HTMLElement>, 'onSubmit' | 'onSelect' | 'defaultValue'> {
|
|
17
|
+
/** The search text, controlled. With `onValueChange`. */
|
|
18
|
+
value?: string | undefined;
|
|
19
|
+
/** The initial text when uncontrolled. */
|
|
20
|
+
defaultValue?: string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The text changed, with the event as second argument like `RadioGroup`, `Slider` or `Tabs`
|
|
23
|
+
* (`SearchChangeEvent`): typing, clearing (the button or Escape) or choosing a suggestion (its text).
|
|
24
|
+
*/
|
|
25
|
+
onValueChange?: ((value: string, event: SearchChangeEvent) => void) | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Enter with no active suggestion: search for the text. If the bar is inside a `<form>`, the form
|
|
28
|
+
* is submitted afterwards (like Enter in a native field).
|
|
29
|
+
*/
|
|
30
|
+
onSubmit?: ((value: string) => void) | undefined;
|
|
31
|
+
/** A suggestion was chosen (Enter on the active one, or a click): receives its `value`. */
|
|
32
|
+
onSelect?: ((value: string) => void) | undefined;
|
|
33
|
+
/** The suggestions view (`auto` chooses by the window width). Defaults to `auto`. */
|
|
34
|
+
view?: SearchViewChoice | undefined;
|
|
35
|
+
/** Ref to the `<search>`. For the input, use `ref` on `SearchBar`. */
|
|
36
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Material 3 Expressive search: the root, a `<search>` (the page's search region) that shares the
|
|
40
|
+
* state between the bar and the suggestions. It goes with a `SearchBar` and, if there are
|
|
41
|
+
* suggestions, a `SearchView`.
|
|
42
|
+
*
|
|
43
|
+
* The app provides the suggestions: they are not filtered inside (local filtering or a remote
|
|
44
|
+
* search is up to the app, with the text from `value`/`onValueChange`).
|
|
45
|
+
*
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const [q, setQ] = useState('')
|
|
48
|
+
* const results = FRUITS.filter((f) => matches(f, q))
|
|
49
|
+
* <Search value={q} onValueChange={setQ} onSubmit={search} onSelect={open}>
|
|
50
|
+
* <SearchBar label="Search fruits" placeholder="Search fruits">
|
|
51
|
+
* <SearchBarLeading><SearchIcon /></SearchBarLeading>
|
|
52
|
+
* </SearchBar>
|
|
53
|
+
* <SearchView loading={loading}>
|
|
54
|
+
* {results.map((f) => <SearchSuggestion key={f.id} value={f.name} />)}
|
|
55
|
+
* </SearchView>
|
|
56
|
+
* </Search>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* Keyboard (APG combobox): arrows move the active suggestion (wrapping), Enter chooses the active
|
|
60
|
+
* one or searches, Escape closes the suggestions and, when closed, clears the text; Alt+Down Arrow
|
|
61
|
+
* opens them.
|
|
62
|
+
*
|
|
63
|
+
* It is a block that takes its container's width, up to 720 px (Compose `SearchBarMaxWidth`).
|
|
64
|
+
* Inside a `TopAppBar` (as a direct child) it takes the title's place.
|
|
65
|
+
*/
|
|
66
|
+
export declare function Search({ value: valueProp, defaultValue, onValueChange, onSubmit, onSelect, view, className, children, ref, onPointerDown, onKeyDown, onFocus, ...rest }: SearchProps): import("react").JSX.Element;
|
|
67
|
+
/** Input props the bar does not let you change (the search manages them). */
|
|
68
|
+
type ManagedInputProps = 'type' | 'value' | 'defaultValue' | 'children' | 'aria-label' | 'aria-labelledby' | 'role';
|
|
69
|
+
export type SearchBarProps = Omit<InputHTMLAttributes<HTMLInputElement>, ManagedInputProps> & AccessibleNameProps & {
|
|
70
|
+
/** Name of the clear button, shown while there is text. Defaults to "Clear search". */
|
|
71
|
+
clearLabel?: string | undefined;
|
|
72
|
+
/** The parts: `SearchBarLeading` and `SearchBarTrailing`. */
|
|
73
|
+
children?: ReactNode;
|
|
74
|
+
/** Ref to the `<input>`. */
|
|
75
|
+
ref?: Ref<HTMLInputElement> | undefined;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The search bar: a 56 pill (kit) with the `<input type="search">`, the start and end parts
|
|
79
|
+
* (`SearchBarLeading`, `SearchBarTrailing`) and a clear button while there is text.
|
|
80
|
+
*
|
|
81
|
+
* The accessible name is required (`label`, `aria-labelledby` or `aria-label`): the hint text
|
|
82
|
+
* (`placeholder`) is not a name. Native props (`name`, `placeholder`, `disabled`, `autoFocus`,
|
|
83
|
+
* `onFocus`…) and `ref` go to the `<input>`; `className` and `style`, to the pill. With a
|
|
84
|
+
* `SearchView` in the same `Search`, the input is a `combobox` (APG); without one, a plain search
|
|
85
|
+
* field.
|
|
86
|
+
*
|
|
87
|
+
* Inside a `<form>`, Enter submits the form (with `name`, the text is sent like any other field).
|
|
88
|
+
*/
|
|
89
|
+
export declare function SearchBar({ label, 'aria-label': ariaLabel, 'aria-labelledby': labelledBy, placeholder, clearLabel, className, style, children, ref, onChange, onKeyDown, onClick, onBlur, autoComplete, ...inputProps }: SearchBarProps): import("react").JSX.Element;
|
|
90
|
+
export interface SearchViewProps extends HTMLAttributes<HTMLUListElement> {
|
|
91
|
+
/** Searching: a progress bar above the list and `loadingLabel` in the live region. */
|
|
92
|
+
loading?: boolean | undefined;
|
|
93
|
+
/** The loading text (the progress bar's name and the announcement). Defaults to "Searching…". */
|
|
94
|
+
loadingLabel?: string | undefined;
|
|
95
|
+
/** The text shown when typed text has no suggestions. Defaults to "No results". */
|
|
96
|
+
emptyLabel?: string | undefined;
|
|
97
|
+
/** Announcement of the number of suggestions. Defaults to "1 suggestion" / "N suggestions". */
|
|
98
|
+
formatCount?: ((count: number) => string) | undefined;
|
|
99
|
+
/** Name of the button that closes the full-screen view. Defaults to "Close search". */
|
|
100
|
+
closeLabel?: string | undefined;
|
|
101
|
+
/** Announcement when a suggestion is removed with Delete. Defaults to "Removed …" with its text. */
|
|
102
|
+
formatRemoved?: ((text: string) => string) | undefined;
|
|
103
|
+
/** Description of suggestions that can be removed (`onRemove`). Defaults to "Press Delete to remove". */
|
|
104
|
+
removeHint?: string | undefined;
|
|
105
|
+
/** Ref to the `<ul role="listbox">`. */
|
|
106
|
+
ref?: Ref<HTMLUListElement> | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The search suggestions: a `listbox` with `SearchSuggestion` and `SearchSuggestionGroup` as
|
|
110
|
+
* children. Native props and `ref` go to the `<ul role="listbox">`; `className` and `style`, to the
|
|
111
|
+
* layer that contains it.
|
|
112
|
+
*
|
|
113
|
+
* - **Docked** (medium or wider windows, or `view="docked"`): a top-layer popover anchored below
|
|
114
|
+
* the bar, 2 px apart, as wide as the bar, Surface Container High with a 12 radius (kit). It opens
|
|
115
|
+
* on typing, on a click in the bar or with the arrows, and closes with Escape, on choosing, on
|
|
116
|
+
* searching or when focus leaves the search.
|
|
117
|
+
* - **Full screen** (compact windows, or `view="full-screen"`): a modal `<dialog>` with its own bar
|
|
118
|
+
* (back, the field and clear) and the list below; focus is trapped, Escape and the back button
|
|
119
|
+
* close it, and focus returns to the bar.
|
|
120
|
+
*
|
|
121
|
+
* With text and no suggestions (and not loading), it shows `emptyLabel`. The count is announced in
|
|
122
|
+
* a polite live region half a second after the last change.
|
|
123
|
+
*/
|
|
124
|
+
export declare function SearchView({ loading, loadingLabel, emptyLabel, formatCount, closeLabel, formatRemoved, removeHint, className, style, children, ref, ...listboxProps }: SearchViewProps): import("react").JSX.Element;
|
|
125
|
+
export interface SearchSuggestionProps extends Omit<ListItemProps, 'value' | 'role'> {
|
|
126
|
+
/** What `onSelect` receives when it is chosen. */
|
|
127
|
+
value: string;
|
|
128
|
+
/** The text that goes into the bar when it is chosen. Defaults to `value`. */
|
|
129
|
+
textValue?: string | undefined;
|
|
130
|
+
/** It cannot be chosen; the arrows skip it (`aria-disabled`). */
|
|
131
|
+
disabled?: boolean | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* Removal was requested (Delete with the suggestion active): receives its `value`. The search
|
|
134
|
+
* stores nothing: the app takes it out of its list (and wherever it keeps it). Without
|
|
135
|
+
* `onRemove`, it cannot be removed.
|
|
136
|
+
*/
|
|
137
|
+
onRemove?: ((value: string) => void) | undefined;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A suggestion: a `listbox` option (`<li role="option">`) that looks like a list item (`ListItem`,
|
|
141
|
+
* ADR-0018): its parts `ListItemLeading`, `ListItemHeadline`, `ListItemSupporting` and
|
|
142
|
+
* `ListItemTrailing` go as children. Without children (or with only text), it shows the text as a
|
|
143
|
+
* `ListItemHeadline`.
|
|
144
|
+
*
|
|
145
|
+
* It does not take focus: the arrows mark the active one with `aria-activedescendant` and
|
|
146
|
+
* `aria-selected`, and it is chosen with Enter or a click. No controls inside (an option cannot
|
|
147
|
+
* contain interactive elements).
|
|
148
|
+
*
|
|
149
|
+
* Removing (for example, recent searches): with `onRemove`, Delete on the active one requests it,
|
|
150
|
+
* `formatRemoved` ("Removed …") is announced and the active one moves to the next when the app
|
|
151
|
+
* removes it. The search notifies; the app stores and deletes (like `InputChip`'s `onRemove`). There
|
|
152
|
+
* is no button in the option for the pointer: the app offers a separate action such as "Clear
|
|
153
|
+
* history".
|
|
154
|
+
*
|
|
155
|
+
* ```tsx
|
|
156
|
+
* const { recent, add, remove } = useRecentSearches('searches') // the app's (localStorage, for example)
|
|
157
|
+
* <Search onSubmit={add} onSelect={add} …>
|
|
158
|
+
* <SearchBar label="Search" />
|
|
159
|
+
* <SearchView>
|
|
160
|
+
* {recent.map((r) => <SearchSuggestion key={r} value={r} onRemove={remove} />)}
|
|
161
|
+
* </SearchView>
|
|
162
|
+
* </Search>
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* ```tsx
|
|
166
|
+
* <SearchSuggestion value="mate cocido" />
|
|
167
|
+
* <SearchSuggestion value="p-17" textValue="Yerba">
|
|
168
|
+
* <ListItemLeading><HistoryIcon /></ListItemLeading>
|
|
169
|
+
* <ListItemHeadline>Yerba</ListItemHeadline>
|
|
170
|
+
* <ListItemSupporting>Grocery</ListItemSupporting>
|
|
171
|
+
* </SearchSuggestion>
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export declare function SearchSuggestion({ value, textValue, disabled, onRemove, id, className, children, onClick, 'aria-describedby': describedBy, ...rest }: SearchSuggestionProps): import("react").JSX.Element;
|
|
175
|
+
export interface SearchSuggestionGroupProps extends HTMLAttributes<HTMLUListElement> {
|
|
176
|
+
/** Ref to the `<ul role="group">`. */
|
|
177
|
+
ref?: Ref<HTMLUListElement> | undefined;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A named group of suggestions: for example recent searches and suggested ones. Its children are a
|
|
181
|
+
* `SearchSuggestionGroupLabel` and the `SearchSuggestion`s. It is a `<ul role="group">` named by its
|
|
182
|
+
* label (APG's grouped listbox pattern), inside an `<li role="none">` (an `<li>` does not allow the
|
|
183
|
+
* `group` role). Native props and `ref` go to the `<ul>`; an `aria-labelledby` of your own wins.
|
|
184
|
+
*
|
|
185
|
+
* ```tsx
|
|
186
|
+
* <SearchSuggestionGroup>
|
|
187
|
+
* <SearchSuggestionGroupLabel>Recent</SearchSuggestionGroupLabel>
|
|
188
|
+
* {recent.map((r) => <SearchSuggestion key={r} value={r} />)}
|
|
189
|
+
* </SearchSuggestionGroup>
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export declare function SearchSuggestionGroup({ className, ...rest }: SearchSuggestionGroupProps): import("react").JSX.Element;
|
|
193
|
+
export interface SearchSuggestionGroupLabelProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
194
|
+
/** Ref to the label element (an `<li role="presentation">`). */
|
|
195
|
+
ref?: Ref<HTMLLIElement> | undefined;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* The visible name of a `SearchSuggestionGroup` (for example "Recent"), styled as a list subheader
|
|
199
|
+
* (Title Small, `on-surface-variant`). It names the group (`aria-labelledby`), without passing ids.
|
|
200
|
+
* It is not a suggestion: the arrows skip it.
|
|
201
|
+
*
|
|
202
|
+
* ```tsx
|
|
203
|
+
* <SearchSuggestionGroup><SearchSuggestionGroupLabel>Recent</SearchSuggestionGroupLabel>…</SearchSuggestionGroup>
|
|
204
|
+
* ```
|
|
205
|
+
*/
|
|
206
|
+
export declare function SearchSuggestionGroupLabel({ className, ...props }: SearchSuggestionGroupLabelProps): import("react").JSX.Element;
|
|
207
|
+
export {};
|