@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,16 @@
|
|
|
1
|
+
import type { HTMLAttributes, Ref } from 'react';
|
|
2
|
+
export interface SearchBarPartProps extends HTMLAttributes<HTMLSpanElement> {
|
|
3
|
+
/** Ref to the part's `<span>`. */
|
|
4
|
+
ref?: Ref<HTMLSpanElement> | undefined;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The start of the bar: an `IconButton` (menu, back) or a 24 icon (the magnifier). In a 48 area,
|
|
8
|
+
* On Surface color (kit; Compose `SearchBarTokens.LeadingIconColor`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function SearchBarLeading({ className, ...props }: SearchBarPartProps): import("react").JSX.Element;
|
|
11
|
+
/**
|
|
12
|
+
* The end of the bar: one or two `IconButton`s (voice, more options) or an avatar (a 30 round
|
|
13
|
+
* `<img>` in a 50 area, kit). On Surface Variant color. The bar adds the clear button by itself,
|
|
14
|
+
* before this part, while there is text.
|
|
15
|
+
*/
|
|
16
|
+
export declare function SearchBarTrailing({ className, ...props }: SearchBarPartProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from '../../internal/interactive.js';
|
|
3
|
+
/**
|
|
4
|
+
* The start of the bar: an `IconButton` (menu, back) or a 24 icon (the magnifier). In a 48 area,
|
|
5
|
+
* On Surface color (kit; Compose `SearchBarTokens.LeadingIconColor`).
|
|
6
|
+
*/
|
|
7
|
+
export function SearchBarLeading({ className, ...props }) {
|
|
8
|
+
return _jsx("span", { ...props, className: cx('mk-search-bar-leading', className) });
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The end of the bar: one or two `IconButton`s (voice, more options) or an avatar (a 30 round
|
|
12
|
+
* `<img>` in a 50 area, kit). On Surface Variant color. The bar adds the clear button by itself,
|
|
13
|
+
* before this part, while there is text.
|
|
14
|
+
*/
|
|
15
|
+
export function SearchBarTrailing({ className, ...props }) {
|
|
16
|
+
return _jsx("span", { ...props, className: cx('mk-search-bar-trailing', className) });
|
|
17
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface SearchStrings {
|
|
2
|
+
/** `SearchBar` `clearLabel`: the button that clears the text. */
|
|
3
|
+
clearLabel: string;
|
|
4
|
+
/** `SearchView` `closeLabel`: the button that closes the full-screen view. */
|
|
5
|
+
closeLabel: string;
|
|
6
|
+
/** `SearchView` `loadingLabel`: the progress bar and the loading announcement. */
|
|
7
|
+
loadingLabel: string;
|
|
8
|
+
/** `SearchView` `emptyLabel`: the text shown when typed text has no suggestions. */
|
|
9
|
+
emptyLabel: string;
|
|
10
|
+
/** `SearchView` `removeHint`: the hidden description of suggestions that can be removed. */
|
|
11
|
+
removeHint: string;
|
|
12
|
+
/**
|
|
13
|
+
* `SearchView` `formatCount`: the announcement of the number of suggestions. A function per
|
|
14
|
+
* language, so each one builds its own plurals (with `Intl.PluralRules` if it has more than two
|
|
15
|
+
* forms).
|
|
16
|
+
*/
|
|
17
|
+
formatCount: (count: number) => string;
|
|
18
|
+
/** `SearchView` `formatRemoved`: the announcement when a suggestion is removed, with its text. */
|
|
19
|
+
formatRemoved: (text: string) => string;
|
|
20
|
+
}
|
|
21
|
+
export declare const searchStrings: SearchStrings;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Textos por defecto de Search (en inglés: son salida para quien usa la librería). Cada clave se
|
|
2
|
+
// llama como la prop que lo cambia; el índice src/strings/index.ts los reúne con los demás.
|
|
3
|
+
// Universal: sin 'use client', sin estado ni llamadas al cargar el módulo.
|
|
4
|
+
export const searchStrings = {
|
|
5
|
+
clearLabel: 'Clear search',
|
|
6
|
+
closeLabel: 'Close search',
|
|
7
|
+
loadingLabel: 'Searching…',
|
|
8
|
+
emptyLabel: 'No results',
|
|
9
|
+
removeHint: 'Press Delete to remove',
|
|
10
|
+
formatCount: (count) => (count === 1 ? '1 suggestion' : `${count} suggestions`),
|
|
11
|
+
formatRemoved: (text) => `Removed ${text}`,
|
|
12
|
+
};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { type FormEvent, type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode, type Ref } from 'react';
|
|
2
|
+
/** The field style, the same as `TextFieldVariant`. */
|
|
3
|
+
export type SelectVariant = 'filled' | 'outlined';
|
|
4
|
+
/**
|
|
5
|
+
* Why the list asked to open or close (`onOpenChange(open, reason)`):
|
|
6
|
+
* - `trigger`: a click on the field, or a key on the closed field (Arrow Down, Arrow Up, Enter,
|
|
7
|
+
* Space, Alt+Arrow Down, Home, End or a letter); a click on the open field closes it;
|
|
8
|
+
* - `select`: an option was chosen (click, Enter, Space or Alt+Arrow Up);
|
|
9
|
+
* - `escape`: Escape closed it without changing the value;
|
|
10
|
+
* - `tab`: Tab chose the active option and moved on (APG);
|
|
11
|
+
* - `outside`: a click outside the field and the list;
|
|
12
|
+
* - `focus-out`: focus left the field some other way (a script, another window).
|
|
13
|
+
*/
|
|
14
|
+
export type SelectOpenChangeReason = 'trigger' | 'select' | 'escape' | 'tab' | 'outside' | 'focus-out';
|
|
15
|
+
/** The event that chose a value: a click on an option or a key on the field. */
|
|
16
|
+
export type SelectChangeEvent = MouseEvent<HTMLElement> | KeyboardEvent<HTMLElement>;
|
|
17
|
+
export interface SelectProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color' | 'defaultValue' | 'onChange' | 'onInvalid' | 'role' | 'placeholder'> {
|
|
18
|
+
/** `filled` (with a container and a bottom indicator) or `outlined` (with a border). Defaults to `filled`. */
|
|
19
|
+
variant?: SelectVariant | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Shown in the field while no option is chosen: with a `SelectLabel`, only once the label floats
|
|
22
|
+
* (focus), as in Material 3. Not a name.
|
|
23
|
+
*/
|
|
24
|
+
placeholder?: ReactNode;
|
|
25
|
+
/** The chosen option's `value`, controlled. `''` means none. */
|
|
26
|
+
value?: string | undefined;
|
|
27
|
+
/** The initial value when uncontrolled, and the one `form.reset()` restores. Defaults to `''`. */
|
|
28
|
+
defaultValue?: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The user chose an option with a different value: the value and the event (`SelectChangeEvent`).
|
|
31
|
+
* Not called by `form.reset()`, like the native `change`.
|
|
32
|
+
*/
|
|
33
|
+
onValueChange?: ((value: string, event: SelectChangeEvent) => void) | undefined;
|
|
34
|
+
/** The list open or closed, controlled. Without it, the select keeps its own state. */
|
|
35
|
+
open?: boolean | undefined;
|
|
36
|
+
/** Initial open state when uncontrolled. Defaults to `false`. */
|
|
37
|
+
defaultOpen?: boolean | undefined;
|
|
38
|
+
/** The user asked to open or close the list, with the reason (`SelectOpenChangeReason`). */
|
|
39
|
+
onOpenChange?: ((open: boolean, reason: SelectOpenChangeReason) => void) | undefined;
|
|
40
|
+
/** Error state: error colors and `aria-invalid`. Put the message in `SelectSupporting`. */
|
|
41
|
+
error?: boolean | undefined;
|
|
42
|
+
/** Disabled: not focusable, not submitted and not validated, like a disabled `<select>`. */
|
|
43
|
+
disabled?: boolean | undefined;
|
|
44
|
+
/** A value is required to submit the form (native validation, `aria-required`). */
|
|
45
|
+
required?: boolean | undefined;
|
|
46
|
+
/** The name the value is submitted under. */
|
|
47
|
+
name?: string | undefined;
|
|
48
|
+
/** The `id` of the `<form>` the value belongs to, when the select is outside it. */
|
|
49
|
+
form?: string | undefined;
|
|
50
|
+
/** The hidden native `<select>` failed validation (the form was submitted without a value). */
|
|
51
|
+
onInvalid?: ((event: FormEvent<HTMLSelectElement>) => void) | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Ref to the hidden native `<select>` that takes part in the form, for its validity API
|
|
54
|
+
* (`setCustomValidity`, `validity`, `reportValidity`).
|
|
55
|
+
*/
|
|
56
|
+
inputRef?: Ref<HTMLSelectElement> | undefined;
|
|
57
|
+
/** Ref to the field (`role="combobox"`), the element that takes focus. */
|
|
58
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
59
|
+
/** The parts: `SelectLabel`, `SelectLeading`, `SelectSupporting` and `SelectContent` with the options. */
|
|
60
|
+
children?: ReactNode;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Material 3 select (the "exposed dropdown menu"), built by composition like `TextField`: the text
|
|
64
|
+
* field box (filled or outlined, floating label, supporting text, error) that opens a list of
|
|
65
|
+
* options, with the WAI-ARIA APG "select-only combobox" pattern. It submits with `name` in a
|
|
66
|
+
* `<form>`, and `required` takes part in native validation. The parts are direct children, placed
|
|
67
|
+
* by class (their order does not matter):
|
|
68
|
+
*
|
|
69
|
+
* ```tsx
|
|
70
|
+
* <Select variant="outlined" name="subject" required value={v} onValueChange={setV} error={!!err}>
|
|
71
|
+
* <SelectLabel>Subject</SelectLabel>
|
|
72
|
+
* <SelectContent>
|
|
73
|
+
* <SelectOption value="general">General question</SelectOption>
|
|
74
|
+
* <SelectGroup>
|
|
75
|
+
* <SelectGroupLabel>Sales</SelectGroupLabel>
|
|
76
|
+
* <SelectOption value="billing">Billing</SelectOption>
|
|
77
|
+
* </SelectGroup>
|
|
78
|
+
* </SelectContent>
|
|
79
|
+
* <SelectSupporting>{err ?? 'We answer within 48 hours'}</SelectSupporting>
|
|
80
|
+
* </Select>
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* - **Keyboard:** on the closed field, Arrow Down, Arrow Up, Enter, Space and Alt+Arrow Down open
|
|
84
|
+
* the list on the chosen option (or the first); Home and End open it on the first or last; a
|
|
85
|
+
* letter opens it on the next option starting with it. Open, the arrows move without wrapping,
|
|
86
|
+
* Home, End, Page Up and Page Down jump, letters search, Enter, Space and Alt+Arrow Up choose and
|
|
87
|
+
* close, Escape closes without changing, and Tab chooses the active option and moves on (APG).
|
|
88
|
+
* Focus never leaves the field: the active option is `aria-activedescendant`.
|
|
89
|
+
* - **Pointer:** a click on the field opens or closes the list; a click on an option chooses it; a
|
|
90
|
+
* click outside closes it.
|
|
91
|
+
* - The list is as wide as the field, below it (above if there is no room) and scrolls when long.
|
|
92
|
+
* - Native props, `id` and `ref` go to the combobox element; `className` and `style` to the field
|
|
93
|
+
* box. Default width 280 px, like `TextField`.
|
|
94
|
+
* - The field shows the chosen option's text already in the server HTML when the option is a
|
|
95
|
+
* `SelectOption` written inside `SelectContent` (or a `SelectGroup`) with plain-text children or
|
|
96
|
+
* `textValue`.
|
|
97
|
+
*/
|
|
98
|
+
export declare function Select({ variant, placeholder, value: controlledValue, defaultValue, onValueChange, open, defaultOpen, onOpenChange, error, disabled, required, name, form, onInvalid, inputRef, className, style, children, ref, onKeyDown, onBlur, ...props }: SelectProps): import("react").JSX.Element;
|
|
99
|
+
export interface SelectLabelProps extends HTMLAttributes<HTMLSpanElement> {
|
|
100
|
+
/** The label text. In the outlined field it is repeated, hidden, to open the border's notch. */
|
|
101
|
+
children?: ReactNode;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The field's label, the same as `TextFieldLabel`: in place of the text at rest (Body Large), it
|
|
105
|
+
* floats up (Body Small) with focus or a value. It names the field and the list (`aria-labelledby`;
|
|
106
|
+
* not a `<label>`, since the combobox is not a labelable element).
|
|
107
|
+
*
|
|
108
|
+
* In the outlined field it also draws the border with a notch (a hidden `<fieldset>`/`<legend>`), so
|
|
109
|
+
* its content should be plain text.
|
|
110
|
+
*/
|
|
111
|
+
export declare function SelectLabel({ id, className, children, ...props }: SelectLabelProps): import("react").JSX.Element;
|
|
112
|
+
export interface SelectSupportingProps extends HTMLAttributes<HTMLDivElement> {
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Text below the field (Body Small), the same as `TextFieldSupporting`: the field's description
|
|
116
|
+
* (`aria-describedby`). With `error` on the `Select` it takes the error color: to show the error
|
|
117
|
+
* message, change its content.
|
|
118
|
+
*/
|
|
119
|
+
export declare function SelectSupporting({ id, className, ...props }: SelectSupportingProps): import("react").JSX.Element;
|
|
120
|
+
export interface SelectContentProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'color'> {
|
|
121
|
+
/** Ref to the list (`role="listbox"`, a popover). */
|
|
122
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
123
|
+
/** The options: `SelectOption` and `SelectGroup` (with its `SelectGroupLabel`). */
|
|
124
|
+
children?: ReactNode;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The list of options (`role="listbox"`), drawn as a Material 3 menu like `MenuContent`: a popover
|
|
128
|
+
* in the top layer, as wide as the field, below it (above if there is no room), scrolling when
|
|
129
|
+
* long. Named like the field. Always mounted, hidden while closed. Native props, `className`,
|
|
130
|
+
* `style` and `ref` go to the list.
|
|
131
|
+
*/
|
|
132
|
+
export declare function SelectContent({ className, style, children, ref, onMouseDown, ...props }: SelectContentProps): import("react").JSX.Element;
|
|
133
|
+
export interface SelectOptionProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'onSelect'> {
|
|
134
|
+
/** The value the select takes (and submits) when this option is chosen. Not empty. */
|
|
135
|
+
value: string;
|
|
136
|
+
/**
|
|
137
|
+
* The text shown in the field and matched by typing. Needed when the content is not plain text
|
|
138
|
+
* (development builds warn with `MK_OPTION_TEXT_UNRESOLVED`); defaults to the option's text.
|
|
139
|
+
*/
|
|
140
|
+
textValue?: string | undefined;
|
|
141
|
+
/** Disabled: announced (`aria-disabled`), skipped by the keyboard and not chosen by a click. */
|
|
142
|
+
disabled?: boolean | undefined;
|
|
143
|
+
/** Ref to the option element. */
|
|
144
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* An option of a `Select` (`role="option"`), inside `SelectContent` or a `SelectGroup`, drawn as a
|
|
148
|
+
* Material 3 menu item: 48 px rows, Label Large, the chosen one in `tertiary-container`. It never
|
|
149
|
+
* takes focus: the keyboard marks the active option with `aria-activedescendant` and
|
|
150
|
+
* `aria-selected`.
|
|
151
|
+
*
|
|
152
|
+
* ```tsx
|
|
153
|
+
* <SelectOption value="ar">Argentina</SelectOption>
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function SelectOption({ value, textValue, disabled, className, children, id, onClick, onPointerMove, ...props }: SelectOptionProps): import("react").JSX.Element;
|
|
157
|
+
export interface SelectGroupProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
|
|
158
|
+
/** Ref to the group element. */
|
|
159
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* A group of options inside `SelectContent` (`role="group"`, named by its `SelectGroupLabel`). The
|
|
163
|
+
* keyboard moves through the options of all groups as one list.
|
|
164
|
+
*
|
|
165
|
+
* ```tsx
|
|
166
|
+
* <SelectGroup>
|
|
167
|
+
* <SelectGroupLabel>Fruit</SelectGroupLabel>
|
|
168
|
+
* <SelectOption value="apple">Apple</SelectOption>
|
|
169
|
+
* </SelectGroup>
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
export declare function SelectGroup({ className, ...props }: SelectGroupProps): import("react").JSX.Element;
|
|
173
|
+
export interface SelectGroupLabelProps extends HTMLAttributes<HTMLDivElement> {
|
|
174
|
+
/** Ref to the label element. */
|
|
175
|
+
ref?: Ref<HTMLDivElement> | undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The heading of a `SelectGroup` (the kit's menu section label: 32 px, Label Large,
|
|
179
|
+
* `on-surface-variant`). It names the group (`aria-labelledby`), without passing ids. It is not an
|
|
180
|
+
* option: the arrows and the typeahead skip it.
|
|
181
|
+
*
|
|
182
|
+
* ```tsx
|
|
183
|
+
* <SelectGroup><SelectGroupLabel>Fruit</SelectGroupLabel>…</SelectGroup>
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare function SelectGroupLabel({ className, ...props }: SelectGroupLabelProps): import("react").JSX.Element;
|