@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.
Files changed (268) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +56 -0
  4. package/README.md +115 -2
  5. package/dist/atoms/Divider/Divider.d.ts +49 -0
  6. package/dist/atoms/Divider/Divider.js +29 -0
  7. package/dist/atoms/FocusRing/FocusRing.d.ts +16 -0
  8. package/dist/atoms/FocusRing/FocusRing.js +16 -0
  9. package/dist/atoms/Group/Group.d.ts +38 -0
  10. package/dist/atoms/Group/Group.js +34 -0
  11. package/dist/atoms/Icon/Icon.d.ts +23 -0
  12. package/dist/atoms/Icon/Icon.js +19 -0
  13. package/dist/atoms/Interactive/Interactive.d.ts +98 -0
  14. package/dist/atoms/Interactive/Interactive.js +87 -0
  15. package/dist/atoms/Ripple/Ripple.d.ts +14 -0
  16. package/dist/atoms/Ripple/Ripple.js +63 -0
  17. package/dist/atoms/Shape/Shape.d.ts +24 -0
  18. package/dist/atoms/Shape/Shape.js +19 -0
  19. package/dist/atoms/Shape/shapes.d.ts +8 -0
  20. package/dist/atoms/Shape/shapes.js +40 -0
  21. package/dist/atoms/Stack/Stack.d.ts +58 -0
  22. package/dist/atoms/Stack/Stack.js +33 -0
  23. package/dist/atoms/StateLayer/StateLayer.d.ts +17 -0
  24. package/dist/atoms/StateLayer/StateLayer.js +17 -0
  25. package/dist/atoms/index.d.ts +10 -0
  26. package/dist/atoms/index.js +10 -0
  27. package/dist/fonts/roboto-flex/OFL.txt +93 -0
  28. package/dist/fonts/roboto-flex/roboto-flex-cyrillic-ext.woff2 +0 -0
  29. package/dist/fonts/roboto-flex/roboto-flex-cyrillic.woff2 +0 -0
  30. package/dist/fonts/roboto-flex/roboto-flex-greek.woff2 +0 -0
  31. package/dist/fonts/roboto-flex/roboto-flex-latin-ext.woff2 +0 -0
  32. package/dist/fonts/roboto-flex/roboto-flex-latin.woff2 +0 -0
  33. package/dist/fonts/roboto-flex/roboto-flex-vietnamese.woff2 +0 -0
  34. package/dist/icons/icons.d.ts +89 -0
  35. package/dist/icons/icons.js +186 -0
  36. package/dist/icons/index.d.ts +1 -0
  37. package/dist/icons/index.js +3 -0
  38. package/dist/index.d.ts +8 -0
  39. package/dist/index.js +12 -0
  40. package/dist/internal/accessible-name.d.ts +17 -0
  41. package/dist/internal/accessible-name.js +33 -0
  42. package/dist/internal/anchor-position.d.ts +99 -0
  43. package/dist/internal/anchor-position.js +159 -0
  44. package/dist/internal/anchored-drag.d.ts +25 -0
  45. package/dist/internal/anchored-drag.js +106 -0
  46. package/dist/internal/dev.d.ts +2 -0
  47. package/dist/internal/dev.js +18 -0
  48. package/dist/internal/diagnostics.d.ts +46 -0
  49. package/dist/internal/diagnostics.js +125 -0
  50. package/dist/internal/group-label.d.ts +22 -0
  51. package/dist/internal/group-label.js +50 -0
  52. package/dist/internal/interactive.d.ts +28 -0
  53. package/dist/internal/interactive.js +18 -0
  54. package/dist/internal/layout-element.d.ts +21 -0
  55. package/dist/internal/layout-element.js +33 -0
  56. package/dist/internal/merge-refs.d.ts +13 -0
  57. package/dist/internal/merge-refs.js +35 -0
  58. package/dist/internal/modal-dialog.d.ts +63 -0
  59. package/dist/internal/modal-dialog.js +267 -0
  60. package/dist/internal/navigation-count.d.ts +38 -0
  61. package/dist/internal/navigation-count.js +60 -0
  62. package/dist/internal/navigation-item.d.ts +14 -0
  63. package/dist/internal/navigation-item.js +17 -0
  64. package/dist/internal/nearest-scroller.d.ts +4 -0
  65. package/dist/internal/nearest-scroller.js +17 -0
  66. package/dist/internal/open-state.d.ts +15 -0
  67. package/dist/internal/open-state.js +42 -0
  68. package/dist/internal/roving-focus.d.ts +41 -0
  69. package/dist/internal/roving-focus.js +126 -0
  70. package/dist/internal/settle-animations.d.ts +33 -0
  71. package/dist/internal/settle-animations.js +48 -0
  72. package/dist/internal/time-period.d.ts +10 -0
  73. package/dist/internal/time-period.js +26 -0
  74. package/dist/internal/time.d.ts +23 -0
  75. package/dist/internal/time.js +69 -0
  76. package/dist/internal/typeahead.d.ts +17 -0
  77. package/dist/internal/typeahead.js +35 -0
  78. package/dist/molecules/Badge/Badge.d.ts +25 -0
  79. package/dist/molecules/Badge/Badge.js +16 -0
  80. package/dist/molecules/Button/Button.d.ts +48 -0
  81. package/dist/molecules/Button/Button.js +34 -0
  82. package/dist/molecules/Card/Card.d.ts +159 -0
  83. package/dist/molecules/Card/Card.js +119 -0
  84. package/dist/molecules/Checkbox/Checkbox.d.ts +26 -0
  85. package/dist/molecules/Checkbox/Checkbox.js +40 -0
  86. package/dist/molecules/Chip/AssistChip.d.ts +23 -0
  87. package/dist/molecules/Chip/AssistChip.js +22 -0
  88. package/dist/molecules/Chip/ChipGroup.d.ts +85 -0
  89. package/dist/molecules/Chip/ChipGroup.js +92 -0
  90. package/dist/molecules/Chip/FilterChip.d.ts +33 -0
  91. package/dist/molecules/Chip/FilterChip.js +30 -0
  92. package/dist/molecules/Chip/InputChip.d.ts +60 -0
  93. package/dist/molecules/Chip/InputChip.js +107 -0
  94. package/dist/molecules/Chip/SuggestionChip.d.ts +24 -0
  95. package/dist/molecules/Chip/SuggestionChip.js +17 -0
  96. package/dist/molecules/Chip/chip-content.d.ts +39 -0
  97. package/dist/molecules/Chip/chip-content.js +95 -0
  98. package/dist/molecules/Chip/chip-element.d.ts +14 -0
  99. package/dist/molecules/Chip/chip-element.js +14 -0
  100. package/dist/molecules/Chip/strings.d.ts +8 -0
  101. package/dist/molecules/Chip/strings.js +5 -0
  102. package/dist/molecules/Fab/Fab.d.ts +78 -0
  103. package/dist/molecules/Fab/Fab.js +52 -0
  104. package/dist/molecules/IconButton/IconButton.d.ts +59 -0
  105. package/dist/molecules/IconButton/IconButton.js +36 -0
  106. package/dist/molecules/LoadingIndicator/LoadingIndicator.d.ts +38 -0
  107. package/dist/molecules/LoadingIndicator/LoadingIndicator.js +25 -0
  108. package/dist/molecules/LoadingIndicator/determinate.d.ts +3 -0
  109. package/dist/molecules/LoadingIndicator/determinate.js +47 -0
  110. package/dist/molecules/LoadingIndicator/loading-indicator-data.d.ts +21 -0
  111. package/dist/molecules/LoadingIndicator/loading-indicator-data.js +72 -0
  112. package/dist/molecules/ProgressIndicator/CircularProgressIndicator.d.ts +35 -0
  113. package/dist/molecules/ProgressIndicator/CircularProgressIndicator.js +30 -0
  114. package/dist/molecules/ProgressIndicator/LinearProgressIndicator.d.ts +43 -0
  115. package/dist/molecules/ProgressIndicator/LinearProgressIndicator.js +28 -0
  116. package/dist/molecules/ProgressIndicator/circular-wavy-data.d.ts +5 -0
  117. package/dist/molecules/ProgressIndicator/circular-wavy-data.js +19 -0
  118. package/dist/molecules/ProgressIndicator/progress.d.ts +24 -0
  119. package/dist/molecules/ProgressIndicator/progress.js +60 -0
  120. package/dist/molecules/RadioButton/RadioButton.d.ts +27 -0
  121. package/dist/molecules/RadioButton/RadioButton.js +70 -0
  122. package/dist/molecules/RadioButton/RadioGroup.d.ts +73 -0
  123. package/dist/molecules/RadioButton/RadioGroup.js +82 -0
  124. package/dist/molecules/ScrollField/ScrollField.d.ts +61 -0
  125. package/dist/molecules/ScrollField/ScrollField.js +352 -0
  126. package/dist/molecules/Slider/RangeSlider.d.ts +60 -0
  127. package/dist/molecules/Slider/RangeSlider.js +169 -0
  128. package/dist/molecules/Slider/Slider.d.ts +54 -0
  129. package/dist/molecules/Slider/Slider.js +71 -0
  130. package/dist/molecules/Slider/slider-shared.d.ts +26 -0
  131. package/dist/molecules/Slider/slider-shared.js +98 -0
  132. package/dist/molecules/Switch/Switch.d.ts +22 -0
  133. package/dist/molecules/Switch/Switch.js +20 -0
  134. package/dist/molecules/TextField/TextField.d.ts +83 -0
  135. package/dist/molecules/TextField/TextField.js +146 -0
  136. package/dist/molecules/TextField/TextFieldSlots.d.ts +22 -0
  137. package/dist/molecules/TextField/TextFieldSlots.js +24 -0
  138. package/dist/molecules/TimeInput/TimeInput.d.ts +108 -0
  139. package/dist/molecules/TimeInput/TimeInput.js +347 -0
  140. package/dist/molecules/TimeInput/strings.d.ts +13 -0
  141. package/dist/molecules/TimeInput/strings.js +10 -0
  142. package/dist/molecules/TimeScroll/TimeScroll.d.ts +106 -0
  143. package/dist/molecules/TimeScroll/TimeScroll.js +213 -0
  144. package/dist/molecules/TimeScroll/strings.d.ts +13 -0
  145. package/dist/molecules/TimeScroll/strings.js +12 -0
  146. package/dist/molecules/index.d.ts +27 -0
  147. package/dist/molecules/index.js +25 -0
  148. package/dist/organisms/BottomSheet/BottomSheet.d.ts +128 -0
  149. package/dist/organisms/BottomSheet/BottomSheet.js +432 -0
  150. package/dist/organisms/BottomSheet/BottomSheetSlots.d.ts +17 -0
  151. package/dist/organisms/BottomSheet/BottomSheetSlots.js +16 -0
  152. package/dist/organisms/BottomSheet/StandardBottomSheet.d.ts +37 -0
  153. package/dist/organisms/BottomSheet/StandardBottomSheet.js +206 -0
  154. package/dist/organisms/BottomSheet/bottom-sheet-context.d.ts +31 -0
  155. package/dist/organisms/BottomSheet/bottom-sheet-context.js +12 -0
  156. package/dist/organisms/BottomSheet/sheet-drag.d.ts +1 -0
  157. package/dist/organisms/BottomSheet/sheet-drag.js +4 -0
  158. package/dist/organisms/BottomSheet/strings.d.ts +9 -0
  159. package/dist/organisms/BottomSheet/strings.js +8 -0
  160. package/dist/organisms/ButtonGroup/ButtonGroup.d.ts +97 -0
  161. package/dist/organisms/ButtonGroup/ButtonGroup.js +242 -0
  162. package/dist/organisms/ButtonGroup/ButtonGroupItem.d.ts +36 -0
  163. package/dist/organisms/ButtonGroup/ButtonGroupItem.js +47 -0
  164. package/dist/organisms/Dialog/Dialog.d.ts +186 -0
  165. package/dist/organisms/Dialog/Dialog.js +193 -0
  166. package/dist/organisms/Dialog/DialogSlots.d.ts +60 -0
  167. package/dist/organisms/Dialog/DialogSlots.js +54 -0
  168. package/dist/organisms/Dialog/strings.d.ts +5 -0
  169. package/dist/organisms/Dialog/strings.js +5 -0
  170. package/dist/organisms/FabMenu/FabMenu.d.ts +104 -0
  171. package/dist/organisms/FabMenu/FabMenu.js +142 -0
  172. package/dist/organisms/FabMenu/strings.d.ts +9 -0
  173. package/dist/organisms/FabMenu/strings.js +5 -0
  174. package/dist/organisms/List/List.d.ts +190 -0
  175. package/dist/organisms/List/List.js +148 -0
  176. package/dist/organisms/Menu/Menu.d.ts +313 -0
  177. package/dist/organisms/Menu/Menu.js +865 -0
  178. package/dist/organisms/Menu/MenuSlots.d.ts +35 -0
  179. package/dist/organisms/Menu/MenuSlots.js +36 -0
  180. package/dist/organisms/NavigationBar/NavigationBar.d.ts +96 -0
  181. package/dist/organisms/NavigationBar/NavigationBar.js +77 -0
  182. package/dist/organisms/NavigationRail/ModalNavigationRail.d.ts +105 -0
  183. package/dist/organisms/NavigationRail/ModalNavigationRail.js +272 -0
  184. package/dist/organisms/NavigationRail/NavigationRail.d.ts +148 -0
  185. package/dist/organisms/NavigationRail/NavigationRail.js +114 -0
  186. package/dist/organisms/NavigationRail/NavigationRailSection.d.ts +54 -0
  187. package/dist/organisms/NavigationRail/NavigationRailSection.js +96 -0
  188. package/dist/organisms/NavigationRail/strings.d.ts +7 -0
  189. package/dist/organisms/NavigationRail/strings.js +7 -0
  190. package/dist/organisms/NavigationSuite/NavigationSuite.d.ts +109 -0
  191. package/dist/organisms/NavigationSuite/NavigationSuite.js +86 -0
  192. package/dist/organisms/PaneScaffold/PaneScaffold.d.ts +118 -0
  193. package/dist/organisms/PaneScaffold/PaneScaffold.js +132 -0
  194. package/dist/organisms/Search/Search.d.ts +213 -0
  195. package/dist/organisms/Search/Search.js +783 -0
  196. package/dist/organisms/Search/SearchSlots.d.ts +18 -0
  197. package/dist/organisms/Search/SearchSlots.js +19 -0
  198. package/dist/organisms/Search/strings.d.ts +21 -0
  199. package/dist/organisms/Search/strings.js +12 -0
  200. package/dist/organisms/Select/Select.d.ts +186 -0
  201. package/dist/organisms/Select/Select.js +597 -0
  202. package/dist/organisms/Select/SelectSlots.d.ts +12 -0
  203. package/dist/organisms/Select/SelectSlots.js +12 -0
  204. package/dist/organisms/SideSheet/SideSheet.d.ts +88 -0
  205. package/dist/organisms/SideSheet/SideSheet.js +109 -0
  206. package/dist/organisms/SideSheet/SideSheetSlots.d.ts +35 -0
  207. package/dist/organisms/SideSheet/SideSheetSlots.js +37 -0
  208. package/dist/organisms/SideSheet/strings.d.ts +7 -0
  209. package/dist/organisms/SideSheet/strings.js +6 -0
  210. package/dist/organisms/Snackbar/Snackbar.d.ts +46 -0
  211. package/dist/organisms/Snackbar/Snackbar.js +36 -0
  212. package/dist/organisms/Snackbar/SnackbarHost.d.ts +57 -0
  213. package/dist/organisms/Snackbar/SnackbarHost.js +221 -0
  214. package/dist/organisms/Snackbar/snackbar-queue.d.ts +81 -0
  215. package/dist/organisms/Snackbar/snackbar-queue.js +114 -0
  216. package/dist/organisms/Snackbar/strings.d.ts +8 -0
  217. package/dist/organisms/Snackbar/strings.js +5 -0
  218. package/dist/organisms/SplitButton/SplitButton.d.ts +73 -0
  219. package/dist/organisms/SplitButton/SplitButton.js +77 -0
  220. package/dist/organisms/SplitButton/strings.d.ts +9 -0
  221. package/dist/organisms/SplitButton/strings.js +5 -0
  222. package/dist/organisms/Tabs/TabLink.d.ts +27 -0
  223. package/dist/organisms/Tabs/TabLink.js +25 -0
  224. package/dist/organisms/Tabs/TabNav.d.ts +19 -0
  225. package/dist/organisms/Tabs/TabNav.js +55 -0
  226. package/dist/organisms/Tabs/Tabs.d.ts +147 -0
  227. package/dist/organisms/Tabs/Tabs.js +223 -0
  228. package/dist/organisms/Tabs/tab-content.d.ts +23 -0
  229. package/dist/organisms/Tabs/tab-content.js +105 -0
  230. package/dist/organisms/Tabs/tab-fit.d.ts +4 -0
  231. package/dist/organisms/Tabs/tab-fit.js +65 -0
  232. package/dist/organisms/Tabs/tab-motion.d.ts +2 -0
  233. package/dist/organisms/Tabs/tab-motion.js +68 -0
  234. package/dist/organisms/TimePickerDialog/TimePickerDialog.d.ts +26 -0
  235. package/dist/organisms/TimePickerDialog/TimePickerDialog.js +34 -0
  236. package/dist/organisms/Toolbar/Toolbar.d.ts +75 -0
  237. package/dist/organisms/Toolbar/Toolbar.js +84 -0
  238. package/dist/organisms/Toolbar/ToolbarLayout.d.ts +44 -0
  239. package/dist/organisms/Toolbar/ToolbarLayout.js +90 -0
  240. package/dist/organisms/Toolbar/ToolbarScroll.d.ts +8 -0
  241. package/dist/organisms/Toolbar/ToolbarScroll.js +222 -0
  242. package/dist/organisms/Tooltip/RichTooltip.d.ts +73 -0
  243. package/dist/organisms/Tooltip/RichTooltip.js +250 -0
  244. package/dist/organisms/Tooltip/Tooltip.d.ts +52 -0
  245. package/dist/organisms/Tooltip/Tooltip.js +99 -0
  246. package/dist/organisms/Tooltip/tooltip-behavior.d.ts +43 -0
  247. package/dist/organisms/Tooltip/tooltip-behavior.js +307 -0
  248. package/dist/organisms/TopAppBar/TopAppBar.d.ts +107 -0
  249. package/dist/organisms/TopAppBar/TopAppBar.js +78 -0
  250. package/dist/organisms/TopAppBar/TopAppBarScroll.d.ts +7 -0
  251. package/dist/organisms/TopAppBar/TopAppBarScroll.js +155 -0
  252. package/dist/organisms/index.d.ts +36 -0
  253. package/dist/organisms/index.js +36 -0
  254. package/dist/palettes/blue.css +275 -0
  255. package/dist/palettes/green.css +275 -0
  256. package/dist/palettes/index.css +823 -0
  257. package/dist/palettes/orange.css +275 -0
  258. package/dist/shapes.css +115 -0
  259. package/dist/strings/index.d.ts +35 -0
  260. package/dist/strings/index.js +39 -0
  261. package/dist/styles-no-fonts.css +12025 -0
  262. package/dist/styles.css +12123 -0
  263. package/dist/stylesheet.d.ts +2 -0
  264. package/dist/tokens/breakpoints.d.ts +33 -0
  265. package/dist/tokens/breakpoints.js +31 -0
  266. package/dist/tokens/space.d.ts +26 -0
  267. package/dist/tokens/space.js +26 -0
  268. package/package.json +110 -3
@@ -0,0 +1,34 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
3
+ import { Ripple } from '../../atoms/Ripple/Ripple.js';
4
+ import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
5
+ import { Interactive } from '../../atoms/Interactive/Interactive.js';
6
+ import { assertRenderElement, cx } from '../../internal/interactive.js';
7
+ /**
8
+ * Material 3 Expressive button.
9
+ *
10
+ * Icons are passed as children, with no special props: the CSS gives them the button's size and
11
+ * spacing. With `href` or `render` it is a link that looks the same.
12
+ *
13
+ * Customization with CSS variables (inherited; the Toolbar sets them for its buttons):
14
+ * `--mk-button-unselected-container`, `--mk-button-unselected-color`,
15
+ * `--mk-button-selected-container` and `--mk-button-selected-color` change the toggle colors of
16
+ * the `filled` style (the default) when unselected and selected. Disabled keeps its own.
17
+ * `--mk-button-selected-round: 1` keeps the selected toggle round (in any style; by default it
18
+ * turns square).
19
+ *
20
+ * ```tsx
21
+ * <Button>Save</Button>
22
+ * <Button variant="tonal" size="md"><svg …/>Create</Button>
23
+ * <Button variant="outlined" selected={on} onClick={() => setOn(!on)}>Favorite</Button>
24
+ * <Button variant="text" href="/orders/42">View details</Button>
25
+ * <Button render={<Link href="/orders/42" />}>View details</Button>
26
+ * ```
27
+ */
28
+ export function Button(props) {
29
+ const { variant = 'filled', size = 'sm', shape = 'round', selected, className, children, ...rest } = props;
30
+ assertRenderElement('Button', rest.render);
31
+ return (_jsxs(Interactive
32
+ // Antes de las props del uso: un aria-pressed propio gana, como antes.
33
+ , { ...(selected === undefined ? {} : { 'aria-pressed': selected }), ...rest, "data-variant": variant, "data-size": size, "data-shape": shape, className: cx('mk-button', className), children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), children] }));
34
+ }
@@ -0,0 +1,159 @@
1
+ import type { HTMLAttributes, ReactNode, Ref } from 'react';
2
+ import { type ButtonElementProps, type LinkElementProps, type RenderElementProps } from '../../atoms/Interactive/Interactive.tsx';
3
+ /** Material 3 style: with a shadow, filled or with a border. */
4
+ export type CardVariant = 'elevated' | 'filled' | 'outlined';
5
+ /**
6
+ * The kit's layout: `vertical` ("Stacked": full-width image between the parts) or `horizontal`
7
+ * (image on the side, at the end or the start depending on its place among the children).
8
+ */
9
+ export type CardOrientation = 'vertical' | 'horizontal';
10
+ export interface CardProps extends HTMLAttributes<HTMLDivElement> {
11
+ /** Style. Defaults to `elevated`. */
12
+ variant?: CardVariant | undefined;
13
+ /** The kit's layout. Defaults to `vertical`. */
14
+ orientation?: CardOrientation | undefined;
15
+ /**
16
+ * With `true`, the layout adapts to the card's own width (container queries), not the window's:
17
+ * - `vertical` at 600 px (37.5rem) or more: the image moves to the side (40 % of the width).
18
+ * - `horizontal` below 320 px (20rem): it stacks, with the image on top.
19
+ * - Below 240 px (15rem): the actions stack at full width.
20
+ *
21
+ * With `false`, the card keeps the kit's layout at any width. The thresholds can't be changed
22
+ * with CSS variables (an `@container` condition doesn't accept `var()`): for others, use
23
+ * `adaptive={false}` and choose `orientation` from the app. Defaults to `true`.
24
+ */
25
+ adaptive?: boolean | undefined;
26
+ /** Ref to the card's container. */
27
+ ref?: Ref<HTMLDivElement> | undefined;
28
+ }
29
+ /**
30
+ * Material 3 card: a surface that groups content and actions about one subject.
31
+ *
32
+ * On its own it is not interactive. To make the whole card lead to a destination or perform an
33
+ * action, put a `CardPrimaryAction` (link or button) inside, usually wrapping the headline: its
34
+ * area covers the card and the buttons in `CardActions` still work separately.
35
+ *
36
+ * It takes its container's width and its content's height. Since it measures its own width
37
+ * (`container-type: inline-size`), its width can't come from its content: in a flex row, give it
38
+ * `flex: 1` or a width; in a grid, the cell already gives it one. For a grid of cards, CSS grid is
39
+ * enough (cards in a row get the same height, with the actions at the bottom):
40
+ *
41
+ * ```css
42
+ * .cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
43
+ * ```
44
+ *
45
+ * ```tsx
46
+ * <Card variant="outlined">
47
+ * <CardHeader>
48
+ * <img src="/ana.jpg" alt="" width={40} height={40} />
49
+ * <CardHeadline><CardPrimaryAction href="/notes/1">Trip notes</CardPrimaryAction></CardHeadline>
50
+ * <CardSubhead>Ana · 2 hours ago</CardSubhead>
51
+ * </CardHeader>
52
+ * <CardMedia><img src="/photo.jpg" alt="" /></CardMedia>
53
+ * <CardContent>
54
+ * <p>Supporting text.</p>
55
+ * <CardActions><Button variant="outlined" size="sm">Share</Button></CardActions>
56
+ * </CardContent>
57
+ * </Card>
58
+ * ```
59
+ */
60
+ export declare function Card({ variant, orientation, adaptive, className, children, ...rest }: CardProps): import("react").JSX.Element;
61
+ interface CardPrimaryActionOwnProps {
62
+ /** The text of the destination or action (usually the headline): it is the accessible name. */
63
+ children?: ReactNode;
64
+ }
65
+ /**
66
+ * Props of `CardPrimaryAction`: with `href`, an `<a>`; with `render`, the element you pass (the
67
+ * router's `<Link href="…" />`, ADR-0010); with neither, a `<button type="button">` with its
68
+ * native attributes.
69
+ */
70
+ export type CardPrimaryActionProps = (CardPrimaryActionOwnProps & Omit<ButtonElementProps, keyof CardPrimaryActionOwnProps>) | (CardPrimaryActionOwnProps & Omit<LinkElementProps, keyof CardPrimaryActionOwnProps>) | (CardPrimaryActionOwnProps & Omit<RenderElementProps, keyof CardPrimaryActionOwnProps>);
71
+ /**
72
+ * The card's primary action: a link or button whose area covers the whole card (with a
73
+ * pseudo-element), with the state layer, ripple and focus ring drawn on the card's edge. The
74
+ * card's other controls sit on top and are focused separately.
75
+ *
76
+ * Use one per card, usually wrapping the headline text. The card has no disabled state (the kit
77
+ * has none): if needed, disable the specific control. As a button, the native `disabled` makes
78
+ * the card stop reacting to the pointer (no layer, ripple or elevation change), without changing
79
+ * its colors.
80
+ *
81
+ * While it covers the card, the card's text can't be selected with the pointer (the text of the
82
+ * controls on top can).
83
+ *
84
+ * ```tsx
85
+ * <CardHeadline><CardPrimaryAction href="/notes/1">Trip notes</CardPrimaryAction></CardHeadline>
86
+ * <CardHeadline><CardPrimaryAction onClick={open}>Trip notes</CardPrimaryAction></CardHeadline>
87
+ * ```
88
+ */
89
+ export declare function CardPrimaryAction(props: CardPrimaryActionProps): import("react").JSX.Element;
90
+ export interface CardHeaderProps extends HTMLAttributes<HTMLDivElement> {
91
+ /** Ref to the header. */
92
+ ref?: Ref<HTMLDivElement> | undefined;
93
+ }
94
+ /**
95
+ * Card header: a row with whatever goes before the headline (a 40 avatar), the headline and
96
+ * subhead (`CardHeadline` and `CardSubhead`, one below the other) and whatever goes after (for
97
+ * example an `IconButton`). Anything that isn't the headline or subhead goes before if it comes
98
+ * before the headline in the code, and after if it comes after.
99
+ */
100
+ export declare function CardHeader({ className, ...props }: CardHeaderProps): import("react").JSX.Element;
101
+ export interface CardHeadlineProps extends HTMLAttributes<HTMLHeadingElement> {
102
+ /** Heading level (`<h1>` to `<h6>`), by the page. Defaults to `3`. */
103
+ level?: 1 | 2 | 3 | 4 | 5 | 6 | undefined;
104
+ /** Ref to the heading. */
105
+ ref?: Ref<HTMLHeadingElement> | undefined;
106
+ }
107
+ /**
108
+ * Card headline, as a heading (`<h3>` by default) so screen readers can jump from card to card.
109
+ * In the header, Title Medium; in the content, Body Large (kit). It wraps instead of overflowing,
110
+ * also with long words; it is not truncated (the headline is the primary action's name and
111
+ * truncating it would hide information).
112
+ */
113
+ export declare function CardHeadline({ level, className, ...props }: CardHeadlineProps): import("react").JSX.Element;
114
+ export interface CardSubheadProps extends HTMLAttributes<HTMLParagraphElement> {
115
+ /** Ref to the paragraph. */
116
+ ref?: Ref<HTMLParagraphElement> | undefined;
117
+ }
118
+ /** Subhead, below `CardHeadline` (Body Medium; in the content, On Surface Variant). */
119
+ export declare function CardSubhead({ className, ...props }: CardSubheadProps): import("react").JSX.Element;
120
+ export interface CardMediaProps extends HTMLAttributes<HTMLDivElement> {
121
+ /** Ref to the media container. */
122
+ ref?: Ref<HTMLDivElement> | undefined;
123
+ }
124
+ /**
125
+ * The card's image or video: the child (`<img>`, `<video>`, `<picture>` or the Next.js `Image`)
126
+ * covers the container with `object-fit: cover`.
127
+ *
128
+ * - Stacked: at full width, with the `--mk-card-media-aspect-ratio` aspect ratio (defaults to
129
+ * 360 / 188, the kit's), so it scales with the width; with the card's corners if it is the
130
+ * first or last part.
131
+ * - On the side (horizontal, or wide vertical): as tall as the card and `--mk-card-media-size`
132
+ * wide (80 px in the horizontal one, 40 % in the wide vertical one); at the end, or at the start
133
+ * if it is the first part.
134
+ *
135
+ * A decorative image takes `alt=""`; if the image conveys something, its alternative text.
136
+ */
137
+ export declare function CardMedia({ className, ...props }: CardMediaProps): import("react").JSX.Element;
138
+ export interface CardContentProps extends HTMLAttributes<HTMLDivElement> {
139
+ /** Ref to the content. */
140
+ ref?: Ref<HTMLDivElement> | undefined;
141
+ }
142
+ /**
143
+ * Card content, with 16 padding. Free text (`<p>`) is the kit's supporting text (Body Medium, On
144
+ * Surface Variant). There are 32 between blocks (`--mk-card-content-gap`), except between the
145
+ * headline and its subhead. It grows to fill the card, so `CardActions` stays at the bottom when
146
+ * the card is taller than its content (in a grid row).
147
+ */
148
+ export declare function CardContent({ className, ...props }: CardContentProps): import("react").JSX.Element;
149
+ export interface CardActionsProps extends HTMLAttributes<HTMLDivElement> {
150
+ /** Ref to the actions container. */
151
+ ref?: Ref<HTMLDivElement> | undefined;
152
+ }
153
+ /**
154
+ * Card actions (buttons), aligned to the end with 8 between them. They wrap when they don't fit
155
+ * on one line, and in a card narrower than 240 px they stack at full width. They go at the end of
156
+ * `CardContent` (as in the kit) or directly in the card. They sit above `CardPrimaryAction`'s area.
157
+ */
158
+ export declare function CardActions({ className, ...props }: CardActionsProps): import("react").JSX.Element;
159
+ export {};
@@ -0,0 +1,119 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
3
+ import { Ripple } from '../../atoms/Ripple/Ripple.js';
4
+ import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
5
+ import { Interactive, } from '../../atoms/Interactive/Interactive.js';
6
+ import { assertRenderElement, cx } from '../../internal/interactive.js';
7
+ /**
8
+ * Material 3 card: a surface that groups content and actions about one subject.
9
+ *
10
+ * On its own it is not interactive. To make the whole card lead to a destination or perform an
11
+ * action, put a `CardPrimaryAction` (link or button) inside, usually wrapping the headline: its
12
+ * area covers the card and the buttons in `CardActions` still work separately.
13
+ *
14
+ * It takes its container's width and its content's height. Since it measures its own width
15
+ * (`container-type: inline-size`), its width can't come from its content: in a flex row, give it
16
+ * `flex: 1` or a width; in a grid, the cell already gives it one. For a grid of cards, CSS grid is
17
+ * enough (cards in a row get the same height, with the actions at the bottom):
18
+ *
19
+ * ```css
20
+ * .cards { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); }
21
+ * ```
22
+ *
23
+ * ```tsx
24
+ * <Card variant="outlined">
25
+ * <CardHeader>
26
+ * <img src="/ana.jpg" alt="" width={40} height={40} />
27
+ * <CardHeadline><CardPrimaryAction href="/notes/1">Trip notes</CardPrimaryAction></CardHeadline>
28
+ * <CardSubhead>Ana · 2 hours ago</CardSubhead>
29
+ * </CardHeader>
30
+ * <CardMedia><img src="/photo.jpg" alt="" /></CardMedia>
31
+ * <CardContent>
32
+ * <p>Supporting text.</p>
33
+ * <CardActions><Button variant="outlined" size="sm">Share</Button></CardActions>
34
+ * </CardContent>
35
+ * </Card>
36
+ * ```
37
+ */
38
+ export function Card({ variant = 'elevated', orientation = 'vertical', adaptive = true, className, children, ...rest }) {
39
+ return (_jsx("div", { ...rest, className: cx('mk-card', className), "data-variant": variant, "data-orientation": orientation, "data-adaptive": adaptive ? undefined : 'false', children: _jsx("div", { className: "mk-card-layout", children: children }) }));
40
+ }
41
+ /**
42
+ * The card's primary action: a link or button whose area covers the whole card (with a
43
+ * pseudo-element), with the state layer, ripple and focus ring drawn on the card's edge. The
44
+ * card's other controls sit on top and are focused separately.
45
+ *
46
+ * Use one per card, usually wrapping the headline text. The card has no disabled state (the kit
47
+ * has none): if needed, disable the specific control. As a button, the native `disabled` makes
48
+ * the card stop reacting to the pointer (no layer, ripple or elevation change), without changing
49
+ * its colors.
50
+ *
51
+ * While it covers the card, the card's text can't be selected with the pointer (the text of the
52
+ * controls on top can).
53
+ *
54
+ * ```tsx
55
+ * <CardHeadline><CardPrimaryAction href="/notes/1">Trip notes</CardPrimaryAction></CardHeadline>
56
+ * <CardHeadline><CardPrimaryAction onClick={open}>Trip notes</CardPrimaryAction></CardHeadline>
57
+ * ```
58
+ */
59
+ export function CardPrimaryAction(props) {
60
+ const { className, children, ...rest } = props;
61
+ assertRenderElement('CardPrimaryAction', rest.render);
62
+ return (_jsxs(Interactive, { ...rest, className: cx('mk-card-primary-action', className), children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), children] }));
63
+ }
64
+ /**
65
+ * Card header: a row with whatever goes before the headline (a 40 avatar), the headline and
66
+ * subhead (`CardHeadline` and `CardSubhead`, one below the other) and whatever goes after (for
67
+ * example an `IconButton`). Anything that isn't the headline or subhead goes before if it comes
68
+ * before the headline in the code, and after if it comes after.
69
+ */
70
+ export function CardHeader({ className, ...props }) {
71
+ return _jsx("div", { ...props, className: cx('mk-card-header', className) });
72
+ }
73
+ /**
74
+ * Card headline, as a heading (`<h3>` by default) so screen readers can jump from card to card.
75
+ * In the header, Title Medium; in the content, Body Large (kit). It wraps instead of overflowing,
76
+ * also with long words; it is not truncated (the headline is the primary action's name and
77
+ * truncating it would hide information).
78
+ */
79
+ export function CardHeadline({ level = 3, className, ...props }) {
80
+ const Tag = `h${level}`;
81
+ return _jsx(Tag, { ...props, className: cx('mk-card-headline', className) });
82
+ }
83
+ /** Subhead, below `CardHeadline` (Body Medium; in the content, On Surface Variant). */
84
+ export function CardSubhead({ className, ...props }) {
85
+ return _jsx("p", { ...props, className: cx('mk-card-subhead', className) });
86
+ }
87
+ /**
88
+ * The card's image or video: the child (`<img>`, `<video>`, `<picture>` or the Next.js `Image`)
89
+ * covers the container with `object-fit: cover`.
90
+ *
91
+ * - Stacked: at full width, with the `--mk-card-media-aspect-ratio` aspect ratio (defaults to
92
+ * 360 / 188, the kit's), so it scales with the width; with the card's corners if it is the
93
+ * first or last part.
94
+ * - On the side (horizontal, or wide vertical): as tall as the card and `--mk-card-media-size`
95
+ * wide (80 px in the horizontal one, 40 % in the wide vertical one); at the end, or at the start
96
+ * if it is the first part.
97
+ *
98
+ * A decorative image takes `alt=""`; if the image conveys something, its alternative text.
99
+ */
100
+ export function CardMedia({ className, ...props }) {
101
+ return _jsx("div", { ...props, className: cx('mk-card-media', className) });
102
+ }
103
+ /**
104
+ * Card content, with 16 padding. Free text (`<p>`) is the kit's supporting text (Body Medium, On
105
+ * Surface Variant). There are 32 between blocks (`--mk-card-content-gap`), except between the
106
+ * headline and its subhead. It grows to fill the card, so `CardActions` stays at the bottom when
107
+ * the card is taller than its content (in a grid row).
108
+ */
109
+ export function CardContent({ className, ...props }) {
110
+ return _jsx("div", { ...props, className: cx('mk-card-content', className) });
111
+ }
112
+ /**
113
+ * Card actions (buttons), aligned to the end with 8 between them. They wrap when they don't fit
114
+ * on one line, and in a card narrower than 240 px they stack at full width. They go at the end of
115
+ * `CardContent` (as in the kit) or directly in the card. They sit above `CardPrimaryAction`'s area.
116
+ */
117
+ export function CardActions({ className, ...props }) {
118
+ return _jsx("div", { ...props, className: cx('mk-card-actions', className) });
119
+ }
@@ -0,0 +1,26 @@
1
+ import { type InputHTMLAttributes, type ReactNode, type Ref } from 'react';
2
+ export interface CheckboxProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'children'> {
3
+ /** Label text or content. Clicking it also toggles the checkbox. */
4
+ children?: ReactNode;
5
+ /** "Partially checked" state (for example, when only some items of a group are checked). */
6
+ indeterminate?: boolean | undefined;
7
+ /** Error state: error colors and `aria-invalid` on the input. */
8
+ error?: boolean | undefined;
9
+ /** Ref to the native `<input>`. */
10
+ ref?: Ref<HTMLInputElement> | undefined;
11
+ }
12
+ /**
13
+ * Material 3 checkbox, on a native `<input type="checkbox">`: it works in forms, with the
14
+ * keyboard (Space) and with screen readers with no extra code.
15
+ *
16
+ * The input's props (`checked`, `defaultChecked`, `onChange`, `name`, `value`, `disabled`,
17
+ * `required`…) are passed through. `className` and `style` go to the container (`<label>`).
18
+ *
19
+ * ```tsx
20
+ * <Checkbox defaultChecked>Remember me</Checkbox>
21
+ * <Checkbox checked={all} indeterminate={some} onChange={(e) => setAll(e.target.checked)}>
22
+ * Select all
23
+ * </Checkbox>
24
+ * ```
25
+ */
26
+ export declare function Checkbox({ children, indeterminate, error, className, style, ref, ...inputProps }: CheckboxProps): import("react").JSX.Element;
@@ -0,0 +1,40 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Molécula interactiva (ADR-0003): el estado indeterminado de un <input type="checkbox"> solo
4
+ // existe como propiedad del DOM (input.indeterminate), no como atributo, así que hace falta
5
+ // JavaScript en el cliente para aplicarlo.
6
+ import { useCallback, useLayoutEffect, useRef } from 'react';
7
+ import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
8
+ import { Ripple } from '../../atoms/Ripple/Ripple.js';
9
+ import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
10
+ /**
11
+ * Material 3 checkbox, on a native `<input type="checkbox">`: it works in forms, with the
12
+ * keyboard (Space) and with screen readers with no extra code.
13
+ *
14
+ * The input's props (`checked`, `defaultChecked`, `onChange`, `name`, `value`, `disabled`,
15
+ * `required`…) are passed through. `className` and `style` go to the container (`<label>`).
16
+ *
17
+ * ```tsx
18
+ * <Checkbox defaultChecked>Remember me</Checkbox>
19
+ * <Checkbox checked={all} indeterminate={some} onChange={(e) => setAll(e.target.checked)}>
20
+ * Select all
21
+ * </Checkbox>
22
+ * ```
23
+ */
24
+ export function Checkbox({ children, indeterminate = false, error = false, className, style, ref, ...inputProps }) {
25
+ const inputRef = useRef(null);
26
+ // Se aplica en cada render: el navegador quita el estado indeterminado al hacer clic, y
27
+ // así la casilla vuelve a reflejar la prop si el componente padre no la cambió.
28
+ useLayoutEffect(() => {
29
+ if (inputRef.current)
30
+ inputRef.current.indeterminate = indeterminate;
31
+ });
32
+ const setRefs = useCallback((node) => {
33
+ inputRef.current = node;
34
+ if (typeof ref === 'function')
35
+ return ref(node);
36
+ if (ref)
37
+ ref.current = node;
38
+ }, [ref]);
39
+ return (_jsxs("label", { className: className ? `mk-checkbox ${className}` : 'mk-checkbox', style: style, "data-error": error || undefined, children: [_jsxs("span", { className: "mk-checkbox-control", children: [_jsx("input", { ...inputProps, ref: setRefs, type: "checkbox", className: "mk-checkbox-input", "aria-invalid": error || inputProps['aria-invalid'] || undefined }), _jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), _jsx("span", { className: "mk-checkbox-box", "aria-hidden": "true", children: _jsxs("svg", { className: "mk-checkbox-icon", viewBox: "0 0 18 18", focusable: "false", children: [_jsx("path", { className: "mk-checkbox-check", d: "M3.5 9.2 7.2 12.9 14.5 5.4" }), _jsx("path", { className: "mk-checkbox-dash", d: "M3 9h12" })] }) })] }), children != null && children !== false && _jsx("span", { className: "mk-checkbox-label", children: children })] }));
40
+ }
@@ -0,0 +1,23 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ToggleButtonOrLinkProps } from '../../internal/interactive.tsx';
3
+ import type { ChipVariant } from './chip-content.tsx';
4
+ interface AssistChipOwnProps {
5
+ /** `outlined` or `elevated`, for when the chip sits on an image. Defaults to `outlined`. */
6
+ variant?: ChipVariant | undefined;
7
+ /** An optional icon and the text: `<EventIcon />Schedule`. */
8
+ children?: ReactNode;
9
+ selected?: never;
10
+ }
11
+ /** AssistChip props: its own plus one of the three forms of ADR-0010 (button, `href` or `render`). */
12
+ export type AssistChipProps = ToggleButtonOrLinkProps<AssistChipOwnProps>;
13
+ /**
14
+ * Assist chip: a smart or contextual action ("Add to calendar", "Get directions"). The leading
15
+ * icon is in `primary`.
16
+ *
17
+ * ```tsx
18
+ * <AssistChip onClick={schedule}><EventIcon />Add to calendar</AssistChip>
19
+ * <AssistChip variant="elevated" href="/map">View on map</AssistChip>
20
+ * ```
21
+ */
22
+ export declare function AssistChip(props: AssistChipProps): import("react").JSX.Element;
23
+ export {};
@@ -0,0 +1,22 @@
1
+ // Molécula universal (ADR-0003): sin estado, efectos ni contexto; no lleva 'use client'.
2
+ // Estados y colores son CSS (chip.css). Contiene la onda (Ripple), un átomo cliente, como el
3
+ // Button: sigue sirviendo desde un Server Component.
4
+ //
5
+ // Elemento (ADR-0010): sin `href` ni `render`, un `<button type="button">`; con `href`, un `<a>`
6
+ // ("Ver en el mapa" navega); con `render={<Link href="…" />}`, el enlace del enrutador. Los tipos
7
+ // rechazan `disabled` en las formas de enlace (LinkModeExclusions). Un assist chip no es un
8
+ // toggle: no acepta `selected` (el kit no tiene assist seleccionado).
9
+ import { chipElement } from './chip-element.js';
10
+ /**
11
+ * Assist chip: a smart or contextual action ("Add to calendar", "Get directions"). The leading
12
+ * icon is in `primary`.
13
+ *
14
+ * ```tsx
15
+ * <AssistChip onClick={schedule}><EventIcon />Add to calendar</AssistChip>
16
+ * <AssistChip variant="elevated" href="/map">View on map</AssistChip>
17
+ * ```
18
+ */
19
+ export function AssistChip(props) {
20
+ const { variant = 'outlined', className, children, ...rest } = props;
21
+ return chipElement({ name: 'AssistChip', type: 'assist', variant, selected: undefined, checkWhenSelected: false, className, children }, rest);
22
+ }
@@ -0,0 +1,85 @@
1
+ import { type HTMLAttributes, type MouseEvent, type ReactNode, type Ref } from 'react';
2
+ export type ChipGroupSelectionMode = 'none' | 'single' | 'multiple';
3
+ export type ChipGroupLayout = 'wrap' | 'scroll';
4
+ /** What `useChipGroup()` exposes about the group. */
5
+ export interface ChipGroupState {
6
+ /** `none` if the group doesn't manage selection. */
7
+ selectionMode: ChipGroupSelectionMode;
8
+ /** Selected values (in `single`, zero or one). */
9
+ value: readonly string[];
10
+ }
11
+ interface ChipGroupContextValue extends ChipGroupState {
12
+ toggle: (value: string, event: MouseEvent<HTMLButtonElement>) => void;
13
+ }
14
+ export declare const useChipGroupContext: () => ChipGroupContextValue | null;
15
+ /**
16
+ * State of the `ChipGroup` that contains the component, or `null` outside a group. Use it to
17
+ * compose your own chips that are marked according to the group's selection.
18
+ */
19
+ export declare function useChipGroup(): ChipGroupState | null;
20
+ interface ChipGroupBaseProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role' | 'defaultValue' | 'aria-label' | 'aria-labelledby'> {
21
+ /** The chips. */
22
+ children?: ReactNode;
23
+ /**
24
+ * `wrap`: several rows, with 8 px between chips and 16 between rows. `scroll`: a single row that
25
+ * scrolls horizontally (the thin scrollbar sits in the bottom padding and doesn't cover the
26
+ * chips; the focused chip is scrolled into view). Defaults to `wrap`.
27
+ */
28
+ layout?: ChipGroupLayout | undefined;
29
+ /** Ref to the `<div role="toolbar">`. */
30
+ ref?: Ref<HTMLDivElement> | undefined;
31
+ }
32
+ /** Required accessible name, as @material/web asks for the chip set. */
33
+ type ChipGroupNameProps = {
34
+ 'aria-label': string;
35
+ 'aria-labelledby'?: string | undefined;
36
+ } | {
37
+ 'aria-label'?: string | undefined;
38
+ 'aria-labelledby': string;
39
+ };
40
+ interface NoSelection {
41
+ selectionMode?: 'none' | undefined;
42
+ value?: undefined;
43
+ defaultValue?: undefined;
44
+ onValueChange?: undefined;
45
+ }
46
+ interface SingleSelection {
47
+ /** One FilterChip selected at a time (or none: tapping it again deselects it). */
48
+ selectionMode: 'single';
49
+ /** Selected value (controlled); `null`, none. */
50
+ value?: string | null | undefined;
51
+ /** Initially selected value (uncontrolled). */
52
+ defaultValue?: string | null | undefined;
53
+ /** Called on selecting or deselecting, with the new value and the chip's event. */
54
+ onValueChange?: ((value: string | null, event: MouseEvent<HTMLButtonElement>) => void) | undefined;
55
+ }
56
+ interface MultipleSelection {
57
+ /** Any number of FilterChips selected. */
58
+ selectionMode: 'multiple';
59
+ /** Selected values (controlled). */
60
+ value?: readonly string[] | undefined;
61
+ /** Initially selected values (uncontrolled). */
62
+ defaultValue?: readonly string[] | undefined;
63
+ /** Called on selecting or deselecting, with the new list (in click order) and the event. */
64
+ onValueChange?: ((value: string[], event: MouseEvent<HTMLButtonElement>) => void) | undefined;
65
+ }
66
+ export type ChipGroupProps = ChipGroupBaseProps & ChipGroupNameProps & (NoSelection | SingleSelection | MultipleSelection);
67
+ /**
68
+ * Chip group: a named `<div role="toolbar">` (`aria-label` or `aria-labelledby`) with a single
69
+ * Tab stop and Left and Right arrows between chips (also between an input chip's action and its
70
+ * remove button), Home and End. It lays out the chips with `Stack`.
71
+ *
72
+ * With `selectionMode`, it manages the selection of the `FilterChip`s that have a `value`:
73
+ *
74
+ * ```tsx
75
+ * <ChipGroup aria-label="Diet" selectionMode="multiple" value={diet} onValueChange={setDiet}>
76
+ * <FilterChip value="vegan">Vegan</FilterChip>
77
+ * <FilterChip value="gluten-free">Gluten-free</FilterChip>
78
+ * </ChipGroup>
79
+ * ```
80
+ *
81
+ * Filters stay toggle buttons (`aria-pressed`) in both modes, as in @material/web: in `single`,
82
+ * selecting one deselects the previous one. For a required form choice, use `RadioGroup`.
83
+ */
84
+ export declare function ChipGroup(props: ChipGroupProps): import("react").JSX.Element;
85
+ export {};
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Molécula interactiva (excepción al ADR-0003 registrada en el ADR-0019, como el RadioGroup del
4
+ // ADR-0012): el grupo necesita estado, efectos, contexto y eventos.
5
+ // - Teclado: una sola parada de Tab y flechas (foco itinerante, "roving tabindex"), el patrón
6
+ // APG "Toolbar" y lo que hace el chip-set de @material/web (role="toolbar", izquierda y derecha
7
+ // con vuelta en los extremos, Inicio y Fin, RTL, sin pasar por los deshabilitados). Los chips
8
+ // suelen venir de a muchos (filtros, destinatarios): con Tab por chip, cruzar una fila de 12
9
+ // filtros costaría 12 pulsaciones.
10
+ // - Selección (opcional): el valor de los FilterChip con `value`, simple o múltiple, repartido por
11
+ // contexto como en el RadioGroup, con `onValueChange` y `useChipGroup()`.
12
+ // Sin JavaScript (antes de hidratar), cada chip es una parada de Tab: el grupo sigue usable.
13
+ //
14
+ // El foco itinerante se maneja sobre el DOM (`tabIndex` de las paradas, marcadas con
15
+ // `data-chip-stop`), no con estado de React, como @material/web: así cuenta los chips que se
16
+ // agregan, quitan o deshabilitan sin que cada chip se registre, también los de `render`. Vive en
17
+ // src/internal/roving-focus.ts, compartido con Tabs (ADR-0023).
18
+ import { createContext, use, useCallback, useMemo, useRef, useState, } from 'react';
19
+ import { Stack } from '../../atoms/Stack/Stack.js';
20
+ import { cx } from '../../internal/interactive.js';
21
+ import { mergeRefs } from '../../internal/merge-refs.js';
22
+ import { useRovingFocus } from '../../internal/roving-focus.js';
23
+ const ChipGroupContext = createContext(null);
24
+ // Contexto completo, para FilterChip (no se exporta desde el índice).
25
+ export const useChipGroupContext = () => use(ChipGroupContext);
26
+ /**
27
+ * State of the `ChipGroup` that contains the component, or `null` outside a group. Use it to
28
+ * compose your own chips that are marked according to the group's selection.
29
+ */
30
+ export function useChipGroup() {
31
+ const ctx = use(ChipGroupContext);
32
+ const mode = ctx?.selectionMode;
33
+ const value = ctx?.value;
34
+ return useMemo(() => (mode === undefined || value === undefined ? null : { selectionMode: mode, value }), [mode, value]);
35
+ }
36
+ // Paradas: las acciones de los chips (también el botón de quitar del input chip), sin las de un
37
+ // grupo anidado. El foco itinerante es el de src/internal/roving-focus.ts, compartido con Tabs.
38
+ const ROVING = { stop: '[data-chip-stop]', scope: '.mk-chip-group' };
39
+ const toArray = (v) => v == null ? [] : typeof v === 'string' ? [v] : v;
40
+ /**
41
+ * Chip group: a named `<div role="toolbar">` (`aria-label` or `aria-labelledby`) with a single
42
+ * Tab stop and Left and Right arrows between chips (also between an input chip's action and its
43
+ * remove button), Home and End. It lays out the chips with `Stack`.
44
+ *
45
+ * With `selectionMode`, it manages the selection of the `FilterChip`s that have a `value`:
46
+ *
47
+ * ```tsx
48
+ * <ChipGroup aria-label="Diet" selectionMode="multiple" value={diet} onValueChange={setDiet}>
49
+ * <FilterChip value="vegan">Vegan</FilterChip>
50
+ * <FilterChip value="gluten-free">Gluten-free</FilterChip>
51
+ * </ChipGroup>
52
+ * ```
53
+ *
54
+ * Filters stay toggle buttons (`aria-pressed`) in both modes, as in @material/web: in `single`,
55
+ * selecting one deselects the previous one. For a required form choice, use `RadioGroup`.
56
+ */
57
+ export function ChipGroup(props) {
58
+ const { children, className, layout = 'wrap', selectionMode = 'none', value: valueProp, defaultValue, onValueChange, onKeyDown, onFocus, ref, ...rest } = props;
59
+ const rootRef = useRef(null);
60
+ const mergedRef = useMemo(() => mergeRefs(ref, rootRef), [ref]);
61
+ const [uncontrolled, setUncontrolled] = useState(() => toArray(defaultValue));
62
+ const controlled = valueProp !== undefined;
63
+ const value = controlled ? toArray(valueProp) : uncontrolled;
64
+ const toggle = useCallback((chip, event) => {
65
+ if (selectionMode === 'none')
66
+ return;
67
+ const on = value.includes(chip);
68
+ if (selectionMode === 'single') {
69
+ const next = on ? null : chip;
70
+ if (!controlled)
71
+ setUncontrolled(toArray(next));
72
+ onValueChange?.(next, event);
73
+ }
74
+ else {
75
+ const next = on ? value.filter((v) => v !== chip) : [...value, chip];
76
+ if (!controlled)
77
+ setUncontrolled(next);
78
+ onValueChange?.(next, event);
79
+ }
80
+ }, [selectionMode, value, controlled, onValueChange]);
81
+ const context = useMemo(() => ({ selectionMode, value, toggle }), [selectionMode, value, toggle]);
82
+ const roving = useRovingFocus(rootRef, ROVING);
83
+ const handleFocus = (event) => {
84
+ onFocus?.(event);
85
+ roving.onFocus(event);
86
+ };
87
+ const handleKeyDown = (event) => {
88
+ onKeyDown?.(event);
89
+ roving.onKeyDown(event);
90
+ };
91
+ return (_jsx(ChipGroupContext, { value: context, children: _jsx(Stack, { ...rest, ref: mergedRef, direction: "row", wrap: layout === 'wrap', gap: 100, align: "center", role: "toolbar", "aria-orientation": "horizontal", "data-layout": layout, className: cx('mk-chip-group', className), onKeyDown: handleKeyDown, onFocus: handleFocus, children: children }) }));
92
+ }
@@ -0,0 +1,33 @@
1
+ import type { ButtonHTMLAttributes, ReactNode, Ref } from 'react';
2
+ import type { ChipVariant } from './chip-content.tsx';
3
+ export interface FilterChipProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'value'> {
4
+ /** `outlined` or `elevated`. Defaults to `outlined`. */
5
+ variant?: ChipVariant | undefined;
6
+ /**
7
+ * Selected (controlled). When undefined: the `ChipGroup` with selection decides by `value`, or
8
+ * `false` outside a group. When selected, the leading icon becomes a check mark.
9
+ */
10
+ selected?: boolean | undefined;
11
+ /** The filter's value in a `ChipGroup` with `selectionMode`. Also goes to the button's `value`. */
12
+ value?: string | undefined;
13
+ /** An optional icon, the text and, if needed, a trailing icon (a dropdown). */
14
+ children?: ReactNode;
15
+ /** Ref to the `<button>`. */
16
+ ref?: Ref<HTMLButtonElement> | undefined;
17
+ }
18
+ /**
19
+ * Filter chip: a toggle that filters content ("Vegan", "Free shipping"). When selected, it is
20
+ * filled in `secondary-container` and shows a check mark at the start.
21
+ *
22
+ * ```tsx
23
+ * <FilterChip selected={vegan} onClick={() => setVegan(!vegan)}>Vegan</FilterChip>
24
+ * <ChipGroup aria-label="Diet" selectionMode="multiple" defaultValue={['vegan']}>
25
+ * <FilterChip value="vegan">Vegan</FilterChip>
26
+ * <FilterChip value="gluten-free">Gluten-free</FilterChip>
27
+ * </ChipGroup>
28
+ * ```
29
+ *
30
+ * Your own `onClick` is called before the group is notified; with `event.preventDefault()`, the
31
+ * group doesn't change the selection.
32
+ */
33
+ export declare function FilterChip(props: FilterChipProps): import("react").JSX.Element;