@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,142 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
// Organismo cliente (ADR-0033). El FAB menu de Material 3 Expressive es un "menu button" de WAI-ARIA
|
|
4
|
+
// APG sobre el Menu de matekit (ADR-0007): FabMenu es un Menu con el color repartido por contexto,
|
|
5
|
+
// FabMenuTrigger es un MenuTrigger con un Fab, FabMenuContent es un MenuContent y FabMenuItem un
|
|
6
|
+
// MenuItem. El popover, la posición, el teclado (flechas, Inicio, Fin, letra, Escape, Tab), el clic
|
|
7
|
+
// afuera, el foco devuelto y la espera de la salida son del Menu, sin código nuevo. Lo propio:
|
|
8
|
+
// - El contexto del color (`color`) para el FAB y los elementos, que viven en ramas distintas (el
|
|
9
|
+
// FAB en la página y los elementos en la capa superior).
|
|
10
|
+
// - La demora escalonada de cada elemento (`fabMenuStagger`), la de Compose: un entero animado con
|
|
11
|
+
// el resorte SlowEffects decide cuántos elementos se ven, desde el FAB hacia arriba al abrir y desde
|
|
12
|
+
// arriba hacia el FAB al cerrar. Se calcula en el render y viaja por contexto a cada elemento, que
|
|
13
|
+
// la escribe en una variable CSS: sin efectos ni medidas.
|
|
14
|
+
// - La transformación del FAB en el botón de cerrar (tamaño, radio, color e icono) y la aparición de
|
|
15
|
+
// cada elemento son CSS (fab-menu.css), con `aria-expanded` que pone MenuTrigger.
|
|
16
|
+
import { Children, createContext, isValidElement, use, useMemo, } from 'react';
|
|
17
|
+
import { CloseIcon } from '../../icons/icons.js';
|
|
18
|
+
import { partOutsideParent } from '../../internal/diagnostics.js';
|
|
19
|
+
import { cx } from '../../internal/interactive.js';
|
|
20
|
+
import { Fab } from '../../molecules/Fab/Fab.js';
|
|
21
|
+
import { Menu, MenuContent, MenuItem, MenuTrigger, useMenu } from '../Menu/Menu.js';
|
|
22
|
+
import { fabMenuStrings } from './strings.js';
|
|
23
|
+
const FabMenuContext = createContext(null);
|
|
24
|
+
function useFabMenu(part) {
|
|
25
|
+
const color = use(FabMenuContext);
|
|
26
|
+
if (!color)
|
|
27
|
+
throw partOutsideParent(part, 'FabMenu');
|
|
28
|
+
return color;
|
|
29
|
+
}
|
|
30
|
+
const StaggerContext = createContext({ enter: 0, exit: 0 });
|
|
31
|
+
// Resorte SlowEffects (tokens/motion.json, igual en los esquemas expressive y standard): masa 1,
|
|
32
|
+
// rigidez 800, amortiguación 1 (crítica). Compose anima con él la cantidad de elementos visibles.
|
|
33
|
+
const SLOW_EFFECTS_OMEGA = Math.sqrt(800);
|
|
34
|
+
// Primer instante (ms) en que la envolvente del resorte crítico, (1 + ωt)·e^(−ωt), baja a `c` o
|
|
35
|
+
// menos (0 < c ≤ 1). Es decreciente, así que alcanza con bisección.
|
|
36
|
+
function crossing(c) {
|
|
37
|
+
if (c >= 1)
|
|
38
|
+
return 0;
|
|
39
|
+
const envelope = (u) => (1 + u) * Math.exp(-u);
|
|
40
|
+
let lo = 0;
|
|
41
|
+
let hi = 50;
|
|
42
|
+
for (let i = 0; i < 60; i++) {
|
|
43
|
+
const mid = (lo + hi) / 2;
|
|
44
|
+
if (envelope(mid) <= c)
|
|
45
|
+
hi = mid;
|
|
46
|
+
else
|
|
47
|
+
lo = mid;
|
|
48
|
+
}
|
|
49
|
+
return Math.round((hi / SLOW_EFFECTS_OMEGA) * 1000);
|
|
50
|
+
}
|
|
51
|
+
// Demoras del escalonado de Compose (`FloatingActionButtonMenuItemColumn`, ADR-0033) para `count`
|
|
52
|
+
// elementos, en el orden del DOM (el primero es el de arriba, el último el más cercano al FAB).
|
|
53
|
+
//
|
|
54
|
+
// Compose anima un entero de 0 a N (abrir) o de N a 0 (cerrar) con SlowEffects; el valor se trunca
|
|
55
|
+
// (`Int.VectorConverter`) y el elemento de índice i se ve si i ≥ N − valor. Cada uno, al aparecer o
|
|
56
|
+
// desaparecer, anima su ancho (FastSpatial) y su opacidad (FastEffects): eso es CSS. El resorte
|
|
57
|
+
// termina cuando le falta menos de 1 (`visibilityThreshold = 1`), así que al abrir los dos de arriba
|
|
58
|
+
// aparecen juntos; al cerrar, el de arriba se va enseguida.
|
|
59
|
+
export function fabMenuStagger(count) {
|
|
60
|
+
return Array.from({ length: count }, (_, i) => {
|
|
61
|
+
const needed = Math.min(count - i, count - 1);
|
|
62
|
+
const enter = needed <= 0 ? 0 : crossing(1 - needed / count);
|
|
63
|
+
const exit = i === 0 ? 0 : crossing((count - i) / count);
|
|
64
|
+
return { enter, exit };
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Material 3 Expressive FAB menu: a FAB that morphs into the close button and shows a column of
|
|
69
|
+
* actions above it, aligned to its end edge. It is matekit's `Menu` (the WAI-ARIA APG "menu button"
|
|
70
|
+
* pattern) with another presentation: it renders no element, it groups the FAB (`FabMenuTrigger`)
|
|
71
|
+
* and the column (`FabMenuContent`). It takes the `Menu` props (`open`, `defaultOpen`,
|
|
72
|
+
* `onOpenChange(open, reason)` with `MenuOpenChangeReason`).
|
|
73
|
+
*
|
|
74
|
+
* **It does not position itself**, like `Fab`: the app places the `FabMenuTrigger` (for example in
|
|
75
|
+
* the bottom end corner, 16 px from the edges); the column appears in the top layer, 8 px above the
|
|
76
|
+
* FAB.
|
|
77
|
+
*
|
|
78
|
+
* ```tsx
|
|
79
|
+
* <FabMenu color="tertiary-container">
|
|
80
|
+
* <FabMenuTrigger label="Create"><AddIcon /></FabMenuTrigger>
|
|
81
|
+
* <FabMenuContent>
|
|
82
|
+
* <FabMenuItem onSelect={newNote}><EditIcon />Note</FabMenuItem>
|
|
83
|
+
* <FabMenuItem onSelect={newList}><CheckIcon />List</FabMenuItem>
|
|
84
|
+
* </FabMenuContent>
|
|
85
|
+
* </FabMenu>
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* - **Keyboard** (the Menu's): on the FAB, Enter, Space and Down Arrow open it and focus the first
|
|
89
|
+
* item (the top one); Up Arrow, the last one (closest to the FAB). Inside, arrows with wrap-around,
|
|
90
|
+
* Home, End and typeahead; Escape closes and returns focus to the FAB; Tab closes and moves on.
|
|
91
|
+
* - A click on the open FAB, or outside the column, closes it.
|
|
92
|
+
*/
|
|
93
|
+
export function FabMenu({ color = 'primary-container', children, ...props }) {
|
|
94
|
+
return (_jsx(FabMenuContext, { value: color, children: _jsx(Menu, { ...props, children: children }) }));
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The FAB that opens and closes the menu, inside a `FabMenu`: a `Fab` `<button>` with
|
|
98
|
+
* `aria-haspopup="menu"`, `aria-expanded`, `aria-controls` and the `MenuTrigger` events. Closed it is
|
|
99
|
+
* a regular FAB in `X-container`; open it morphs (FastSpatial spring) into the kit's close button:
|
|
100
|
+
* 56 × 56, round, in `X` with `on-X` and the 20 px close icon. `size` takes the FAB sizes (`sm`/`md`/
|
|
101
|
+
* `lg` = 56/80/96), not the `Button` ones. Native props, `onClick`, `onKeyDown`, `className`, `style`
|
|
102
|
+
* and `ref` reach the `<button>` (an `onClick` with `preventDefault()` does not open the menu).
|
|
103
|
+
*/
|
|
104
|
+
export function FabMenuTrigger({ label = fabMenuStrings.label, size = 'sm', lowered, className, children, ...props }) {
|
|
105
|
+
const color = useFabMenu('FabMenuTrigger');
|
|
106
|
+
useMenu('FabMenuTrigger');
|
|
107
|
+
return (_jsx(MenuTrigger, { children: _jsxs(Fab, { ...props, label: label, color: color, size: size, lowered: lowered, className: cx('mk-fab-menu-trigger', className), children: [_jsx("span", { className: "mk-fab-menu-trigger-icon", "data-icon": "closed", children: children }), _jsx("span", { className: "mk-fab-menu-trigger-icon", "data-icon": "open", children: _jsx(CloseIcon, {}) })] }) }));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The column of actions: the Menu's `MenuContent` (`role="menu"`, a popover in the top layer named
|
|
111
|
+
* after the FAB), with no background or shadow, placed above the FAB and aligned to its end edge
|
|
112
|
+
* (CSS anchor positioning), with 4 px between items and 8 to the FAB. Each item appears staggered,
|
|
113
|
+
* from the FAB upwards, growing from the end edge.
|
|
114
|
+
*
|
|
115
|
+
* The items must be direct children (the stagger counts the children). Native props, `className`,
|
|
116
|
+
* `style` and `ref` reach the container.
|
|
117
|
+
*/
|
|
118
|
+
export function FabMenuContent({ className, children, ...props }) {
|
|
119
|
+
useFabMenu('FabMenuContent');
|
|
120
|
+
const count = Children.toArray(children).filter(isValidElement).length;
|
|
121
|
+
const delays = useMemo(() => fabMenuStagger(count), [count]);
|
|
122
|
+
let index = 0;
|
|
123
|
+
const staggered = Children.map(children, (child) => {
|
|
124
|
+
if (!isValidElement(child))
|
|
125
|
+
return child;
|
|
126
|
+
const delay = delays[index++] ?? { enter: 0, exit: 0 };
|
|
127
|
+
return _jsx(StaggerContext, { value: delay, children: child });
|
|
128
|
+
});
|
|
129
|
+
return (_jsx(MenuContent, { ...props, "data-settle-subtree": "", className: cx('mk-fab-menu-content', className), children: staggered }));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* An action of the FAB menu: a `MenuItem` (`role="menuitem"`, out of the Tab order) shaped as a
|
|
133
|
+
* 56 px pill, in `X-container` with `on-X-container`, a 24 px icon and a Title Medium label, written
|
|
134
|
+
* as children (`<EditIcon />Note`). Choosing it calls `onSelect` and closes the menu; `disabled`
|
|
135
|
+
* announces it and keeps it focusable without activating it (APG), dimmed. Native props and `ref`
|
|
136
|
+
* reach the `<button>`.
|
|
137
|
+
*/
|
|
138
|
+
export function FabMenuItem({ className, style, ...props }) {
|
|
139
|
+
const color = useFabMenu('FabMenuItem');
|
|
140
|
+
const delay = use(StaggerContext);
|
|
141
|
+
return (_jsx(MenuItem, { ...props, "data-color": color, className: cx('mk-fab-menu-item', className), style: { ...style, '--_enter-delay': `${delay.enter}ms`, '--_exit-delay': `${delay.exit}ms` } }));
|
|
142
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface FabMenuStrings {
|
|
2
|
+
/**
|
|
3
|
+
* Accessible name of the FAB that opens and closes the menu (`FabMenuTrigger` `label`), which only
|
|
4
|
+
* shows an icon; it also names the menu. It does not change on open: `aria-expanded` announces the
|
|
5
|
+
* state (ADR-0033). Prefer one that names the actions ("Create").
|
|
6
|
+
*/
|
|
7
|
+
label: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const fabMenuStrings: FabMenuStrings;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { DetailsHTMLAttributes, HTMLAttributes, LiHTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { type ButtonElementProps, type LinkElementProps, type RenderElementProps } from '../../atoms/Interactive/Interactive.tsx';
|
|
3
|
+
import { type LinkModeExclusions } from '../../internal/interactive.tsx';
|
|
4
|
+
/**
|
|
5
|
+
* The kit's list type: `standard` (items touching) or `segmented` (blocks 2 px apart, with 16 px
|
|
6
|
+
* outer corners and 4 px inner ones, on `Group`).
|
|
7
|
+
*/
|
|
8
|
+
export type ListVariant = 'standard' | 'segmented';
|
|
9
|
+
interface ListOwnProps extends HTMLAttributes<HTMLUListElement> {
|
|
10
|
+
/** Ref to the `<ul>`. */
|
|
11
|
+
ref?: Ref<HTMLUListElement> | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `List` props. Dividers exist only in the standard list: in the segmented one, the gap between
|
|
15
|
+
* blocks already divides.
|
|
16
|
+
*/
|
|
17
|
+
export type ListProps = (ListOwnProps & {
|
|
18
|
+
/** List type. Defaults to `standard`. */
|
|
19
|
+
variant?: 'standard' | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* A 1 px line (`outline-variant`) between items, inset 16 on each side (Compose's
|
|
22
|
+
* `ListTokens.Divider*Space`). It is a border drawn by CSS, not an `<hr>`: an `<hr>` cannot be
|
|
23
|
+
* a child of a `<ul>`, and a separator between items is not content.
|
|
24
|
+
*/
|
|
25
|
+
dividers?: boolean | undefined;
|
|
26
|
+
}) | (ListOwnProps & {
|
|
27
|
+
variant: 'segmented';
|
|
28
|
+
dividers?: undefined;
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Material 3 list: a vertical index of items (`ListItem`).
|
|
32
|
+
*
|
|
33
|
+
* It is a `<ul role="list">`: the explicit role is needed because, without bullets
|
|
34
|
+
* (`list-style: none`), Safari stops announcing the list with VoiceOver. It takes its container's
|
|
35
|
+
* width and adapts its items to its own width with container queries (not the window's): it is meant
|
|
36
|
+
* to live in a 360 px pane. Since it measures its own width, in a flex row it needs `flex: 1` or a
|
|
37
|
+
* width.
|
|
38
|
+
*
|
|
39
|
+
* Items can be links (`ListItemAction` with `href` or `render`): settings rows that lead to a
|
|
40
|
+
* subpage, results, or the list of a list-detail screen, where the open item has `current`. It does
|
|
41
|
+
* not replace NavigationBar or NavigationRail (the main navigation). A list of options with radios
|
|
42
|
+
* goes inside a `RadioGroup`.
|
|
43
|
+
*
|
|
44
|
+
* ```tsx
|
|
45
|
+
* <List>
|
|
46
|
+
* <ListItem>
|
|
47
|
+
* <ListItemLeading><InboxIcon /></ListItemLeading>
|
|
48
|
+
* <ListItemHeadline><ListItemAction href="/inbox" current>Inbox</ListItemAction></ListItemHeadline>
|
|
49
|
+
* <ListItemTrailing>24</ListItemTrailing>
|
|
50
|
+
* </ListItem>
|
|
51
|
+
* </List>
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function List({ variant, dividers, className, children, ...rest }: ListProps): import("react").JSX.Element;
|
|
55
|
+
/** Vertical alignment of the leading and trailing content: centered (`middle`) or top (`top`). */
|
|
56
|
+
export type ListItemAlign = 'middle' | 'top';
|
|
57
|
+
export interface ListItemProps extends LiHTMLAttributes<HTMLLIElement> {
|
|
58
|
+
/**
|
|
59
|
+
* Alignment of the leading and trailing content relative to the text. Defaults to `middle`; `top`
|
|
60
|
+
* for text of three lines or more (kit: leading and trailing 10 from the top edge).
|
|
61
|
+
*/
|
|
62
|
+
align?: ListItemAlign | undefined;
|
|
63
|
+
/** Ref to the `<li>`. */
|
|
64
|
+
ref?: Ref<HTMLLIElement> | undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* List item (`<li>`). It takes the parts as children, in this order: `ListItemLeading`,
|
|
68
|
+
* `ListItemOverline`, `ListItemHeadline`, `ListItemSupporting` and `ListItemTrailing` (all optional
|
|
69
|
+
* except the headline). The height comes from the content: at least 52 with one line, 64 with two
|
|
70
|
+
* and 80 with three (kit).
|
|
71
|
+
*
|
|
72
|
+
* Interactive in three ways, one per item:
|
|
73
|
+
* - **Link or button**: `ListItemAction` inside the headline; it covers the whole item. With
|
|
74
|
+
* `current`, the open item (for example in the detail pane) looks selected.
|
|
75
|
+
* - **Selection**: a `Checkbox`, `RadioButton` or `Switch` as a child, with the text inside it; the
|
|
76
|
+
* whole row activates it and the text is its name. When checked (checkbox or radio), the item
|
|
77
|
+
* looks selected.
|
|
78
|
+
* - **Accordion**: `ListItemDetails` with `ListItemSummary`.
|
|
79
|
+
*
|
|
80
|
+
* The selected and disabled states come from those controls (`aria-current`, `:checked`,
|
|
81
|
+
* `disabled`), not from props of the item: a content item is neither selected nor disabled.
|
|
82
|
+
*
|
|
83
|
+
* **Dragged:** matekit does not reorder items, but it draws the state. While your app drags an
|
|
84
|
+
* item (with its own drag and drop and keyboard reordering), set `data-dragged` on it: it takes
|
|
85
|
+
* Compose's reorder look (`tertiary-container` with `on-tertiary-container` content, 16 px corners,
|
|
86
|
+
* elevation level 4, a 16 % state layer), over the selected look. Announce the moves yourself, for
|
|
87
|
+
* example in a live region.
|
|
88
|
+
*/
|
|
89
|
+
export declare function ListItem({ align, className, children, ...rest }: ListItemProps): import("react").JSX.Element;
|
|
90
|
+
/** The kit's type of leading content, which sets its size and shape. */
|
|
91
|
+
export type ListItemLeadingVariant = 'icon' | 'avatar' | 'image' | 'video';
|
|
92
|
+
export interface ListItemLeadingProps extends HTMLAttributes<HTMLSpanElement> {
|
|
93
|
+
/**
|
|
94
|
+
* - `icon` (the default): a 20 px icon in `on-surface-variant`, or any content. Empty, it is the
|
|
95
|
+
* kit's 20 px indent (it aligns the text with that of items with an icon).
|
|
96
|
+
* - `avatar`: a 40 px circle; an image inside covers it, or initials on `primary-container`.
|
|
97
|
+
* - `image`: 56 × 56, radius 4 and an `outline-variant` border (kit).
|
|
98
|
+
* - `video`: 114 × 64, radius 4 (kit); it shrinks in narrow lists.
|
|
99
|
+
*/
|
|
100
|
+
variant?: ListItemLeadingVariant | undefined;
|
|
101
|
+
/** Ref to the `<span>`. */
|
|
102
|
+
ref?: Ref<HTMLSpanElement> | undefined;
|
|
103
|
+
}
|
|
104
|
+
/** The item's leading content: an icon, avatar, image, video or an `IconButton`. */
|
|
105
|
+
export declare function ListItemLeading({ variant, className, ...props }: ListItemLeadingProps): import("react").JSX.Element;
|
|
106
|
+
export interface ListItemTextProps extends HTMLAttributes<HTMLSpanElement> {
|
|
107
|
+
/** Ref to the `<span>`. */
|
|
108
|
+
ref?: Ref<HTMLSpanElement> | undefined;
|
|
109
|
+
}
|
|
110
|
+
/** Text above the headline (Label Medium, `on-surface-variant`). */
|
|
111
|
+
export declare function ListItemOverline({ className, ...props }: ListItemTextProps): import("react").JSX.Element;
|
|
112
|
+
/**
|
|
113
|
+
* Headline (Body Large, `on-surface`). It wraps, also inside long words, and is not truncated: it is
|
|
114
|
+
* the item's name (that of its `ListItemAction` or its control).
|
|
115
|
+
*/
|
|
116
|
+
export declare function ListItemHeadline({ className, ...props }: ListItemTextProps): import("react").JSX.Element;
|
|
117
|
+
/**
|
|
118
|
+
* Supporting text (Body Medium, `on-surface-variant`). It is truncated to 2 lines with an ellipsis
|
|
119
|
+
* (Material's three-line list); `--mk-list-item-supporting-lines` changes the count (`none`, no
|
|
120
|
+
* truncation). When truncated, screen readers still read it in full.
|
|
121
|
+
*/
|
|
122
|
+
export declare function ListItemSupporting({ className, ...props }: ListItemTextProps): import("react").JSX.Element;
|
|
123
|
+
/**
|
|
124
|
+
* Trailing content: text (Label Large, `on-surface-variant`), a 20 px icon, both (8 apart) or an
|
|
125
|
+
* `IconButton`. In a list narrower than 320 px, if it is only text, it moves below the headline. A
|
|
126
|
+
* selection control does not go here: it wraps the item's text (see `ListItem`).
|
|
127
|
+
*/
|
|
128
|
+
export declare function ListItemTrailing({ className, ...props }: ListItemTextProps): import("react").JSX.Element;
|
|
129
|
+
interface ListItemActionOwnProps {
|
|
130
|
+
/** The text of the destination or the action (the headline): it is the accessible name. */
|
|
131
|
+
children?: ReactNode;
|
|
132
|
+
/**
|
|
133
|
+
* Current item, for example the one open in the detail pane (`aria-current="page"`): the item looks
|
|
134
|
+
* selected (Secondary Container). If the `render` element already sets `aria-current` (React
|
|
135
|
+
* Router's `NavLink`), it is not needed. For another value (`"true"`, `"step"`), pass
|
|
136
|
+
* `aria-current` directly.
|
|
137
|
+
*/
|
|
138
|
+
current?: boolean | undefined;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* `ListItemAction` props: with `href`, an `<a>`; with `render`, the element passed (the router's
|
|
142
|
+
* `<Link href="…" />`, ADR-0010); with neither, a `<button type="button">`, the only one that accepts
|
|
143
|
+
* `disabled`.
|
|
144
|
+
*/
|
|
145
|
+
export type ListItemActionProps = (ListItemActionOwnProps & Omit<ButtonElementProps, keyof ListItemActionOwnProps>) | (ListItemActionOwnProps & LinkModeExclusions & Omit<LinkElementProps, keyof ListItemActionOwnProps | keyof LinkModeExclusions>) | (ListItemActionOwnProps & LinkModeExclusions & Omit<RenderElementProps, keyof ListItemActionOwnProps | keyof LinkModeExclusions>);
|
|
146
|
+
/**
|
|
147
|
+
* The item's action: a link or button whose area covers the whole item (with a pseudo-element), with
|
|
148
|
+
* the state layer, the ripple and the focus ring on the item's edge. It goes inside
|
|
149
|
+
* `ListItemHeadline`, wrapping its text. Other controls of the item (a trailing `IconButton`) stay
|
|
150
|
+
* on top and are focused separately.
|
|
151
|
+
*
|
|
152
|
+
* While it covers the item, its text cannot be selected with the pointer.
|
|
153
|
+
*
|
|
154
|
+
* ```tsx
|
|
155
|
+
* <ListItemHeadline><ListItemAction href="/inbox" current>Inbox</ListItemAction></ListItemHeadline>
|
|
156
|
+
* <ListItemHeadline><ListItemAction onClick={remove}>Delete</ListItemAction></ListItemHeadline>
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export declare function ListItemAction(props: ListItemActionProps): import("react").JSX.Element;
|
|
160
|
+
export interface ListItemDetailsProps extends DetailsHTMLAttributes<HTMLDetailsElement> {
|
|
161
|
+
/** Ref to the `<details>`. */
|
|
162
|
+
ref?: Ref<HTMLDetailsElement> | undefined;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* An item that expands (accordion): a native `<details>` inside the `ListItem`. The first child is
|
|
166
|
+
* `ListItemSummary` (the row, with the kit's 32 × 40 button); the rest is the content shown when
|
|
167
|
+
* open. `open` and `onToggle` are the native element's; with the same `name` on several, one opens
|
|
168
|
+
* at a time.
|
|
169
|
+
*
|
|
170
|
+
* ```tsx
|
|
171
|
+
* <ListItem>
|
|
172
|
+
* <ListItemDetails name="help">
|
|
173
|
+
* <ListItemSummary><ListItemHeadline>How long does shipping take?</ListItemHeadline></ListItemSummary>
|
|
174
|
+
* <p>Between 2 and 5 business days.</p>
|
|
175
|
+
* </ListItemDetails>
|
|
176
|
+
* </ListItem>
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
export declare function ListItemDetails({ className, ...props }: ListItemDetailsProps): import("react").JSX.Element;
|
|
180
|
+
export interface ListItemSummaryProps extends HTMLAttributes<HTMLElement> {
|
|
181
|
+
/** Ref to the `<summary>`. */
|
|
182
|
+
ref?: Ref<HTMLElement> | undefined;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The row of a `ListItemDetails` (`<summary>`): the item's parts and, at the end, the 32 × 40
|
|
186
|
+
* indicator that rotates on open. Enter and Space open and close it; its accessible name is its
|
|
187
|
+
* text. It does not accept other controls inside (that would be a nested interactive).
|
|
188
|
+
*/
|
|
189
|
+
export declare function ListItemSummary({ className, children, ...props }: ListItemSummaryProps): import("react").JSX.Element;
|
|
190
|
+
export {};
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
|
|
3
|
+
import { Group } from '../../atoms/Group/Group.js';
|
|
4
|
+
import { Ripple } from '../../atoms/Ripple/Ripple.js';
|
|
5
|
+
import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
|
|
6
|
+
import { ExpandMoreIcon } from '../../icons/icons.js';
|
|
7
|
+
import { Interactive, } from '../../atoms/Interactive/Interactive.js';
|
|
8
|
+
import { assertRenderElement, cx } from '../../internal/interactive.js';
|
|
9
|
+
/**
|
|
10
|
+
* Material 3 list: a vertical index of items (`ListItem`).
|
|
11
|
+
*
|
|
12
|
+
* It is a `<ul role="list">`: the explicit role is needed because, without bullets
|
|
13
|
+
* (`list-style: none`), Safari stops announcing the list with VoiceOver. It takes its container's
|
|
14
|
+
* width and adapts its items to its own width with container queries (not the window's): it is meant
|
|
15
|
+
* to live in a 360 px pane. Since it measures its own width, in a flex row it needs `flex: 1` or a
|
|
16
|
+
* width.
|
|
17
|
+
*
|
|
18
|
+
* Items can be links (`ListItemAction` with `href` or `render`): settings rows that lead to a
|
|
19
|
+
* subpage, results, or the list of a list-detail screen, where the open item has `current`. It does
|
|
20
|
+
* not replace NavigationBar or NavigationRail (the main navigation). A list of options with radios
|
|
21
|
+
* goes inside a `RadioGroup`.
|
|
22
|
+
*
|
|
23
|
+
* ```tsx
|
|
24
|
+
* <List>
|
|
25
|
+
* <ListItem>
|
|
26
|
+
* <ListItemLeading><InboxIcon /></ListItemLeading>
|
|
27
|
+
* <ListItemHeadline><ListItemAction href="/inbox" current>Inbox</ListItemAction></ListItemHeadline>
|
|
28
|
+
* <ListItemTrailing>24</ListItemTrailing>
|
|
29
|
+
* </ListItem>
|
|
30
|
+
* </List>
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function List({ variant = 'standard', dividers = false, className, children, ...rest }) {
|
|
34
|
+
const listProps = {
|
|
35
|
+
...rest,
|
|
36
|
+
role: 'list',
|
|
37
|
+
className: cx('mk-list', className),
|
|
38
|
+
'data-variant': variant,
|
|
39
|
+
'data-dividers': dividers && variant === 'standard' ? '' : undefined,
|
|
40
|
+
};
|
|
41
|
+
if (variant === 'segmented') {
|
|
42
|
+
// Group clona el <ul> con su clase y sus esquinas por posición (ADR-0017).
|
|
43
|
+
return (_jsx(Group, { orientation: "vertical", render: _jsx("ul", { ...listProps }), children: children }));
|
|
44
|
+
}
|
|
45
|
+
return _jsx("ul", { ...listProps, children: children });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* List item (`<li>`). It takes the parts as children, in this order: `ListItemLeading`,
|
|
49
|
+
* `ListItemOverline`, `ListItemHeadline`, `ListItemSupporting` and `ListItemTrailing` (all optional
|
|
50
|
+
* except the headline). The height comes from the content: at least 52 with one line, 64 with two
|
|
51
|
+
* and 80 with three (kit).
|
|
52
|
+
*
|
|
53
|
+
* Interactive in three ways, one per item:
|
|
54
|
+
* - **Link or button**: `ListItemAction` inside the headline; it covers the whole item. With
|
|
55
|
+
* `current`, the open item (for example in the detail pane) looks selected.
|
|
56
|
+
* - **Selection**: a `Checkbox`, `RadioButton` or `Switch` as a child, with the text inside it; the
|
|
57
|
+
* whole row activates it and the text is its name. When checked (checkbox or radio), the item
|
|
58
|
+
* looks selected.
|
|
59
|
+
* - **Accordion**: `ListItemDetails` with `ListItemSummary`.
|
|
60
|
+
*
|
|
61
|
+
* The selected and disabled states come from those controls (`aria-current`, `:checked`,
|
|
62
|
+
* `disabled`), not from props of the item: a content item is neither selected nor disabled.
|
|
63
|
+
*
|
|
64
|
+
* **Dragged:** matekit does not reorder items, but it draws the state. While your app drags an
|
|
65
|
+
* item (with its own drag and drop and keyboard reordering), set `data-dragged` on it: it takes
|
|
66
|
+
* Compose's reorder look (`tertiary-container` with `on-tertiary-container` content, 16 px corners,
|
|
67
|
+
* elevation level 4, a 16 % state layer), over the selected look. Announce the moves yourself, for
|
|
68
|
+
* example in a live region.
|
|
69
|
+
*/
|
|
70
|
+
export function ListItem({ align = 'middle', className, children, ...rest }) {
|
|
71
|
+
return (_jsxs("li", { ...rest, className: cx('mk-list-item', className), "data-align": align === 'top' ? 'top' : undefined, children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), children] }));
|
|
72
|
+
}
|
|
73
|
+
/** The item's leading content: an icon, avatar, image, video or an `IconButton`. */
|
|
74
|
+
export function ListItemLeading({ variant = 'icon', className, ...props }) {
|
|
75
|
+
return _jsx("span", { ...props, className: cx('mk-list-item-leading', className), "data-variant": variant });
|
|
76
|
+
}
|
|
77
|
+
/** Text above the headline (Label Medium, `on-surface-variant`). */
|
|
78
|
+
export function ListItemOverline({ className, ...props }) {
|
|
79
|
+
return _jsx("span", { ...props, className: cx('mk-list-item-overline', className) });
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Headline (Body Large, `on-surface`). It wraps, also inside long words, and is not truncated: it is
|
|
83
|
+
* the item's name (that of its `ListItemAction` or its control).
|
|
84
|
+
*/
|
|
85
|
+
export function ListItemHeadline({ className, ...props }) {
|
|
86
|
+
return _jsx("span", { ...props, className: cx('mk-list-item-headline', className) });
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Supporting text (Body Medium, `on-surface-variant`). It is truncated to 2 lines with an ellipsis
|
|
90
|
+
* (Material's three-line list); `--mk-list-item-supporting-lines` changes the count (`none`, no
|
|
91
|
+
* truncation). When truncated, screen readers still read it in full.
|
|
92
|
+
*/
|
|
93
|
+
export function ListItemSupporting({ className, ...props }) {
|
|
94
|
+
return _jsx("span", { ...props, className: cx('mk-list-item-supporting', className) });
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Trailing content: text (Label Large, `on-surface-variant`), a 20 px icon, both (8 apart) or an
|
|
98
|
+
* `IconButton`. In a list narrower than 320 px, if it is only text, it moves below the headline. A
|
|
99
|
+
* selection control does not go here: it wraps the item's text (see `ListItem`).
|
|
100
|
+
*/
|
|
101
|
+
export function ListItemTrailing({ className, ...props }) {
|
|
102
|
+
return _jsx("span", { ...props, className: cx('mk-list-item-trailing', className) });
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The item's action: a link or button whose area covers the whole item (with a pseudo-element), with
|
|
106
|
+
* the state layer, the ripple and the focus ring on the item's edge. It goes inside
|
|
107
|
+
* `ListItemHeadline`, wrapping its text. Other controls of the item (a trailing `IconButton`) stay
|
|
108
|
+
* on top and are focused separately.
|
|
109
|
+
*
|
|
110
|
+
* While it covers the item, its text cannot be selected with the pointer.
|
|
111
|
+
*
|
|
112
|
+
* ```tsx
|
|
113
|
+
* <ListItemHeadline><ListItemAction href="/inbox" current>Inbox</ListItemAction></ListItemHeadline>
|
|
114
|
+
* <ListItemHeadline><ListItemAction onClick={remove}>Delete</ListItemAction></ListItemHeadline>
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export function ListItemAction(props) {
|
|
118
|
+
const { current, className, children, ...rest } = props;
|
|
119
|
+
const aria = current ? { 'aria-current': 'page' } : {};
|
|
120
|
+
assertRenderElement('ListItemAction', rest.render);
|
|
121
|
+
return (_jsxs(Interactive, { ...aria, ...rest, className: cx('mk-list-item-action', className), children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), children] }));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* An item that expands (accordion): a native `<details>` inside the `ListItem`. The first child is
|
|
125
|
+
* `ListItemSummary` (the row, with the kit's 32 × 40 button); the rest is the content shown when
|
|
126
|
+
* open. `open` and `onToggle` are the native element's; with the same `name` on several, one opens
|
|
127
|
+
* at a time.
|
|
128
|
+
*
|
|
129
|
+
* ```tsx
|
|
130
|
+
* <ListItem>
|
|
131
|
+
* <ListItemDetails name="help">
|
|
132
|
+
* <ListItemSummary><ListItemHeadline>How long does shipping take?</ListItemHeadline></ListItemSummary>
|
|
133
|
+
* <p>Between 2 and 5 business days.</p>
|
|
134
|
+
* </ListItemDetails>
|
|
135
|
+
* </ListItem>
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export function ListItemDetails({ className, ...props }) {
|
|
139
|
+
return _jsx("details", { ...props, className: cx('mk-list-item-details', className) });
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The row of a `ListItemDetails` (`<summary>`): the item's parts and, at the end, the 32 × 40
|
|
143
|
+
* indicator that rotates on open. Enter and Space open and close it; its accessible name is its
|
|
144
|
+
* text. It does not accept other controls inside (that would be a nested interactive).
|
|
145
|
+
*/
|
|
146
|
+
export function ListItemSummary({ className, children, ...props }) {
|
|
147
|
+
return (_jsxs("summary", { ...props, className: cx('mk-list-item-summary', className), children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), children, _jsx("span", { className: "mk-list-item-expand", "aria-hidden": "true", children: _jsx(ExpandMoreIcon, {}) })] }));
|
|
148
|
+
}
|