@matekit/react 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/CHANGELOG.md +71 -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 +106 -0
  193. package/dist/organisms/PaneScaffold/PaneScaffold.js +120 -0
  194. package/dist/organisms/Search/Search.d.ts +207 -0
  195. package/dist/organisms/Search/Search.js +754 -0
  196. package/dist/organisms/Search/SearchSlots.d.ts +16 -0
  197. package/dist/organisms/Search/SearchSlots.js +17 -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 +11991 -0
  262. package/dist/styles.css +12089 -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,60 @@
1
+ import { type ButtonHTMLAttributes, type CSSProperties, type HTMLAttributes, type KeyboardEvent, type MouseEvent, type ReactNode, type Ref } from 'react';
2
+ export type InputChipRemoveEvent = KeyboardEvent<HTMLElement> | MouseEvent<HTMLButtonElement>;
3
+ interface InputChipOwnProps {
4
+ /** Optional icon or `ChipAvatar` and the text: `<ChipAvatar><img alt="" src="…" /></ChipAvatar>Ana`. */
5
+ children?: ReactNode;
6
+ /**
7
+ * Called when removing the chip is requested (remove button, Delete or Backspace). You remove it
8
+ * from your list; the chip doesn't hide itself.
9
+ */
10
+ onRemove: (event: InputChipRemoveEvent) => void;
11
+ /**
12
+ * First part of the remove button's name, followed by the chip's label ("Remove Ana"). Defaults
13
+ * to "Remove". If the chip has an `aria-label`, that is used instead of the label.
14
+ */
15
+ removeLabel?: string | undefined;
16
+ /** Disables both actions. */
17
+ disabled?: boolean | undefined;
18
+ /** Class of the chip's container. */
19
+ className?: string | undefined;
20
+ /** Style of the chip's container. */
21
+ style?: CSSProperties | undefined;
22
+ }
23
+ /** The primary action is a `<button>` (selectable with `selected`). */
24
+ interface InputChipButtonProps extends InputChipOwnProps, Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof InputChipOwnProps> {
25
+ removeOnly?: false | undefined;
26
+ /** Selected: `aria-pressed` on the primary action and the `secondary-container` fill. */
27
+ selected?: boolean | undefined;
28
+ /** Ref to the primary `<button>`. */
29
+ ref?: Ref<HTMLButtonElement> | undefined;
30
+ }
31
+ /** No primary action: the chip can only be removed (the label is text). */
32
+ interface InputChipRemoveOnlyProps extends InputChipOwnProps, Omit<HTMLAttributes<HTMLSpanElement>, keyof InputChipOwnProps> {
33
+ removeOnly: true;
34
+ selected?: undefined;
35
+ /** Ref to the label's `<span>`. */
36
+ ref?: Ref<HTMLSpanElement> | undefined;
37
+ }
38
+ export type InputChipProps = InputChipButtonProps | InputChipRemoveOnlyProps;
39
+ /**
40
+ * Input chip: a piece of data the user entered (a recipient, a tag), with a button to remove it.
41
+ * You manage the list:
42
+ *
43
+ * ```tsx
44
+ * <ChipGroup aria-label="Recipients">
45
+ * {people.map((p) => (
46
+ * <InputChip key={p.id} onRemove={() => setPeople((l) => l.filter((x) => x !== p))}>
47
+ * <ChipAvatar><img alt="" src={p.photo} /></ChipAvatar>{p.name}
48
+ * </InputChip>
49
+ * ))}
50
+ * </ChipGroup>
51
+ * ```
52
+ *
53
+ * With `removeOnly`, the label is not a button (it can only be removed). Native props and the
54
+ * `ref` go to the primary action; `className` and `style`, to the container.
55
+ *
56
+ * After removal, if focus was lost with the chip, it moves to the next chip, or the previous one
57
+ * if it was the last, or to the group if no chips are left; focus you move in `onRemove` is kept.
58
+ */
59
+ export declare function InputChip(props: InputChipProps): import("react").JSX.Element;
60
+ export {};
@@ -0,0 +1,107 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Molécula interactiva (excepción al ADR-0003, ADR-0019): escucha Supr y Retroceso y, después de
4
+ // que el uso quita el chip, mueve el foco al chip vecino. Eso necesita eventos y una referencia
5
+ // al DOM, que solo existen en el cliente.
6
+ //
7
+ // Dos acciones en un mismo chip, como el input chip de @material/web (chips/internal/
8
+ // input-chip.ts y trailing-icons.ts): la principal (un `<button>`, o solo texto con `removeOnly`)
9
+ // y el botón de quitar, con nombre "Remove <etiqueta>" (por defecto) armado con aria-labelledby. El contenedor
10
+ // (`<span>`) dibuja el chip y no es interactivo: no hay controles anidados.
11
+ //
12
+ // Quitar (ADR-0019): el chip avisa con `onRemove(event)` y el uso saca el elemento de su lista
13
+ // (controlado; el chip no se esconde solo). Con Supr o Retroceso sobre cualquiera de las dos
14
+ // acciones (como React Aria TagGroup, useTag.ts; @material/web no lo tiene) o con el botón. Si el
15
+ // chip desaparece y el foco se perdió con él, va al chip siguiente, o al anterior si era el
16
+ // último, o al grupo si no quedan chips. Si el uso movió el foco en `onRemove` (por ejemplo a su
17
+ // campo de texto), se respeta.
18
+ import { useId, useRef, } from 'react';
19
+ import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
20
+ import { Ripple } from '../../atoms/Ripple/Ripple.js';
21
+ import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
22
+ import { CloseIcon } from '../../icons/icons.js';
23
+ import { cx } from '../../internal/interactive.js';
24
+ import { chipContent, chipDataAttributes } from './chip-content.js';
25
+ import { inputChipStrings } from './strings.js';
26
+ const FOCUSABLE = '[data-chip-stop]:not(:disabled)';
27
+ // El primer elemento enfocable del chip vecino (siguiente, o anterior si no hay), o el grupo.
28
+ function focusTargetAfterRemoving(chip) {
29
+ const group = chip.closest('.mk-chip-group');
30
+ const scope = group ?? chip.parentElement;
31
+ if (!scope)
32
+ return null;
33
+ const chips = [...scope.querySelectorAll('[data-chip]')].filter((el) => (el.closest('.mk-chip-group') ?? scope) === (group ?? scope));
34
+ const firstStop = (el) => (el.matches(FOCUSABLE) ? el : el.querySelector(FOCUSABLE));
35
+ const index = chips.indexOf(chip);
36
+ for (const candidate of [...chips.slice(index + 1), ...chips.slice(0, index).reverse()]) {
37
+ const stop = firstStop(candidate);
38
+ if (stop)
39
+ return stop;
40
+ }
41
+ if (group) {
42
+ if (!group.hasAttribute('tabindex'))
43
+ group.tabIndex = -1;
44
+ return group;
45
+ }
46
+ return null;
47
+ }
48
+ const focusLost = () => document.activeElement === null || document.activeElement === document.body;
49
+ /**
50
+ * Input chip: a piece of data the user entered (a recipient, a tag), with a button to remove it.
51
+ * You manage the list:
52
+ *
53
+ * ```tsx
54
+ * <ChipGroup aria-label="Recipients">
55
+ * {people.map((p) => (
56
+ * <InputChip key={p.id} onRemove={() => setPeople((l) => l.filter((x) => x !== p))}>
57
+ * <ChipAvatar><img alt="" src={p.photo} /></ChipAvatar>{p.name}
58
+ * </InputChip>
59
+ * ))}
60
+ * </ChipGroup>
61
+ * ```
62
+ *
63
+ * With `removeOnly`, the label is not a button (it can only be removed). Native props and the
64
+ * `ref` go to the primary action; `className` and `style`, to the container.
65
+ *
66
+ * After removal, if focus was lost with the chip, it moves to the next chip, or the previous one
67
+ * if it was the last, or to the group if no chips are left; focus you move in `onRemove` is kept.
68
+ */
69
+ export function InputChip(props) {
70
+ const { children, onRemove, removeLabel = inputChipStrings.removeLabel, disabled = false, className, style, removeOnly, selected, onKeyDown, ...rest } = props;
71
+ const rootRef = useRef(null);
72
+ const labelId = useId();
73
+ const removeId = useId();
74
+ const content = chipContent(children, { check: selected === true, labelId });
75
+ const ariaLabel = rest['aria-label'];
76
+ const remove = (event) => {
77
+ const chip = rootRef.current;
78
+ if (disabled || !chip)
79
+ return;
80
+ const target = focusTargetAfterRemoving(chip);
81
+ onRemove(event);
82
+ // React aplica la actualización de un evento discreto al terminar el evento; se revisa en una
83
+ // microtarea y, por si el uso la difiere (una transición), en los dos cuadros siguientes.
84
+ const settle = (frames) => {
85
+ if (!chip.isConnected) {
86
+ if (focusLost() && target?.isConnected)
87
+ target.focus({ focusVisible: event.type === 'keydown' });
88
+ }
89
+ else if (frames > 0) {
90
+ requestAnimationFrame(() => settle(frames - 1));
91
+ }
92
+ };
93
+ queueMicrotask(() => settle(2));
94
+ };
95
+ const handleKeyDown = (event) => {
96
+ ;
97
+ onKeyDown?.(event);
98
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey)
99
+ return;
100
+ if (event.key === 'Delete' || event.key === 'Backspace') {
101
+ event.preventDefault();
102
+ remove(event);
103
+ }
104
+ };
105
+ const primary = removeOnly ? (_jsx("span", { ...rest, className: "mk-input-chip-primary", onKeyDown: handleKeyDown, children: content.content })) : (_jsxs("button", { ...rest, ...(selected === undefined ? {} : { 'aria-pressed': selected }), type: rest.type ?? 'button', disabled: disabled, className: "mk-input-chip-primary", "data-chip-stop": "", onKeyDown: handleKeyDown, children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), content.content] }));
106
+ return (_jsxs("span", { ref: rootRef, className: cx('mk-input-chip', className), style: style, "data-chip": "input", "data-selected": selected ? '' : undefined, "data-disabled": disabled ? '' : undefined, "data-remove-only": removeOnly ? '' : undefined, ...chipDataAttributes(content), children: [primary, _jsx("span", { id: removeId, hidden: true, children: ariaLabel ? `${removeLabel} ${ariaLabel}` : removeLabel }), _jsxs("button", { type: "button", className: "mk-input-chip-remove", "data-chip-stop": "", "aria-labelledby": ariaLabel ? removeId : `${removeId} ${labelId}`, disabled: disabled, onClick: remove, onKeyDown: handleKeyDown, children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), _jsx(CloseIcon, {})] })] }));
107
+ }
@@ -0,0 +1,24 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { ToggleButtonOrLinkProps } from '../../internal/interactive.tsx';
3
+ import type { ChipVariant } from './chip-content.tsx';
4
+ interface SuggestionChipOwnProps {
5
+ /** `outlined` or `elevated`. Defaults to `outlined`. */
6
+ variant?: ChipVariant | undefined;
7
+ /** An optional icon and the text. */
8
+ children?: ReactNode;
9
+ }
10
+ /**
11
+ * SuggestionChip props: its own plus one of the three forms of ADR-0010. Only the `<button>`
12
+ * accepts `selected` (toggle) and `disabled`.
13
+ */
14
+ export type SuggestionChipProps = ToggleButtonOrLinkProps<SuggestionChipOwnProps>;
15
+ /**
16
+ * Suggestion chip: a suggested reply or search the user picks ("Sounds good").
17
+ *
18
+ * ```tsx
19
+ * <SuggestionChip onClick={() => reply('Sure')}>Sure</SuggestionChip>
20
+ * <SuggestionChip href="/search?q=empanadas">Empanadas</SuggestionChip>
21
+ * ```
22
+ */
23
+ export declare function SuggestionChip(props: SuggestionChipProps): import("react").JSX.Element;
24
+ export {};
@@ -0,0 +1,17 @@
1
+ // Molécula universal (ADR-0003): sin estado, efectos ni contexto; no lleva 'use client'.
2
+ // Como AssistChip (ver su comentario): botón, `href` o `render` (ADR-0010). El kit también tiene
3
+ // el suggestion seleccionado (Compose no): con `selected`, y solo como `<button>`, es un toggle
4
+ // con `aria-pressed`, como el Button.
5
+ import { chipElement } from './chip-element.js';
6
+ /**
7
+ * Suggestion chip: a suggested reply or search the user picks ("Sounds good").
8
+ *
9
+ * ```tsx
10
+ * <SuggestionChip onClick={() => reply('Sure')}>Sure</SuggestionChip>
11
+ * <SuggestionChip href="/search?q=empanadas">Empanadas</SuggestionChip>
12
+ * ```
13
+ */
14
+ export function SuggestionChip(props) {
15
+ const { variant = 'outlined', selected, className, children, ...rest } = props;
16
+ return chipElement({ name: 'SuggestionChip', type: 'suggestion', variant, selected, checkWhenSelected: false, className, children }, rest);
17
+ }
@@ -0,0 +1,39 @@
1
+ import { type HTMLAttributes, type ReactNode, type Ref } from 'react';
2
+ export type ChipVariant = 'outlined' | 'elevated';
3
+ export interface ChipLabelProps extends HTMLAttributes<HTMLSpanElement> {
4
+ /** Ref to the `<span>`. */
5
+ ref?: Ref<HTMLSpanElement> | undefined;
6
+ }
7
+ /**
8
+ * The chip's label, for when it isn't plain text (formatted text or a translation component).
9
+ * Plain text is already wrapped automatically: `<FilterChip>Vegan</FilterChip>`. If it doesn't
10
+ * fit, it is truncated with an ellipsis; the accessible name is still the full text.
11
+ */
12
+ export declare function ChipLabel({ className, ...props }: ChipLabelProps): import("react").JSX.Element;
13
+ export interface ChipAvatarProps extends HTMLAttributes<HTMLSpanElement> {
14
+ /** Ref to the `<span>`. */
15
+ ref?: Ref<HTMLSpanElement> | undefined;
16
+ }
17
+ /**
18
+ * The input chip's avatar: a 24 px circle with an image (`<img alt="">`, decorative if the name
19
+ * is already in the label) or initials. It goes before the label and makes the chip round, as in
20
+ * the kit. When selected, it shows a check mark instead.
21
+ */
22
+ export declare function ChipAvatar({ className, ...props }: ChipAvatarProps): import("react").JSX.Element;
23
+ export interface ChipContent {
24
+ content: ReactNode;
25
+ leading: boolean;
26
+ trailing: boolean;
27
+ avatar: boolean;
28
+ }
29
+ interface ChipContentOptions {
30
+ check?: boolean | undefined;
31
+ labelId?: string | undefined;
32
+ }
33
+ export declare function chipContent(children: ReactNode, { check, labelId }?: ChipContentOptions): ChipContent;
34
+ export declare const chipDataAttributes: (c: ChipContent) => {
35
+ 'data-leading': string | undefined;
36
+ 'data-trailing': string | undefined;
37
+ 'data-avatar': string | undefined;
38
+ };
39
+ export {};
@@ -0,0 +1,95 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // Módulo universal (ADR-0003): sin estado, efectos, contexto ni eventos; no lleva 'use client'.
3
+ // Partes de los chips (ChipLabel, ChipAvatar) y el reparto del contenido en inicio, etiqueta y
4
+ // final, compartidos por los cuatro tipos (ADR-0019).
5
+ //
6
+ // Los casos simples se escriben como el Button: `<AssistChip><EventIcon />Agendar</AssistChip>`.
7
+ // El texto suelto se envuelve en la etiqueta (`.mk-chip-label`), que necesita ser un elemento para
8
+ // recortarse con puntos suspensivos (un texto suelto en un flex no admite overflow ni
9
+ // text-overflow). Los elementos antes de la etiqueta son el inicio (icono o `ChipAvatar`) y los de
10
+ // después, el final (un icono de desplegable en el filter). La configuración resultante va en
11
+ // atributos `data-*` del chip, que el CSS usa para los rellenos del kit; así no depende de
12
+ // selectores frágiles sobre hermanos.
13
+ import { Children, cloneElement, isValidElement, } from 'react';
14
+ import { CheckIcon } from '../../icons/icons.js';
15
+ import { cx } from '../../internal/interactive.js';
16
+ /**
17
+ * The chip's label, for when it isn't plain text (formatted text or a translation component).
18
+ * Plain text is already wrapped automatically: `<FilterChip>Vegan</FilterChip>`. If it doesn't
19
+ * fit, it is truncated with an ellipsis; the accessible name is still the full text.
20
+ */
21
+ export function ChipLabel({ className, ...props }) {
22
+ return _jsx("span", { ...props, className: cx('mk-chip-label', className) });
23
+ }
24
+ /**
25
+ * The input chip's avatar: a 24 px circle with an image (`<img alt="">`, decorative if the name
26
+ * is already in the label) or initials. It goes before the label and makes the chip round, as in
27
+ * the kit. When selected, it shows a check mark instead.
28
+ */
29
+ export function ChipAvatar({ className, ...props }) {
30
+ return _jsx("span", { ...props, className: cx('mk-chip-avatar', className) });
31
+ }
32
+ const isLabel = (el) => el.type === ChipLabel;
33
+ const isAvatar = (el) => el.type === ChipAvatar;
34
+ // Reparte los hijos de un chip en inicio, etiqueta y final, con los atributos para el CSS.
35
+ export function chipContent(children, { check = false, labelId } = {}) {
36
+ const leading = [];
37
+ const label = [];
38
+ const trailing = [];
39
+ let text = [];
40
+ let labelSeen = false;
41
+ const flushText = () => {
42
+ if (text.length === 0)
43
+ return;
44
+ const first = !labelSeen;
45
+ label.push(_jsx("span", { className: "mk-chip-label", id: first ? labelId : undefined, children: text.join('') }, `label-${label.length}`));
46
+ labelSeen = true;
47
+ text = [];
48
+ };
49
+ for (const child of Children.toArray(children)) {
50
+ if (typeof child === 'string' || typeof child === 'number') {
51
+ text.push(child);
52
+ continue;
53
+ }
54
+ flushText();
55
+ if (!isValidElement(child))
56
+ continue;
57
+ if (isLabel(child)) {
58
+ label.push(labelSeen || labelId === undefined ? child : cloneElement(child, { id: labelId }));
59
+ labelSeen = true;
60
+ }
61
+ else if (labelSeen) {
62
+ trailing.push(child);
63
+ }
64
+ else {
65
+ leading.push(child);
66
+ }
67
+ }
68
+ flushText();
69
+ const avatarEl = leading.find((el) => isValidElement(el) && isAvatar(el));
70
+ const checkIcon = _jsx(CheckIcon, { className: "mk-chip-check" }, "check");
71
+ let start = null;
72
+ if (avatarEl) {
73
+ // El avatar seleccionado conserva su círculo (el chip no cambia de ancho ni de forma) y muestra
74
+ // la marca en lugar de la imagen.
75
+ start = check ? cloneElement(avatarEl, { 'data-checked': '' }, checkIcon) : avatarEl;
76
+ }
77
+ else if (check) {
78
+ start = _jsx("span", { className: "mk-chip-leading", children: checkIcon }, "leading");
79
+ }
80
+ else if (leading.length > 0) {
81
+ start = _jsx("span", { className: "mk-chip-leading", children: leading }, "leading");
82
+ }
83
+ return {
84
+ content: (_jsxs(_Fragment, { children: [start, label, trailing.length > 0 ? _jsx("span", { className: "mk-chip-trailing", children: trailing }, "trailing") : null] })),
85
+ leading: start !== null,
86
+ trailing: trailing.length > 0,
87
+ avatar: avatarEl !== undefined,
88
+ };
89
+ }
90
+ // Atributos de configuración del chip, para los rellenos y la forma (chip.css).
91
+ export const chipDataAttributes = (c) => ({
92
+ 'data-leading': c.leading ? '' : undefined,
93
+ 'data-trailing': c.trailing ? '' : undefined,
94
+ 'data-avatar': c.avatar ? '' : undefined,
95
+ });
@@ -0,0 +1,14 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ChipVariant } from './chip-content.tsx';
3
+ export type ChipType = 'assist' | 'filter' | 'suggestion';
4
+ interface ChipElementOptions {
5
+ name: string;
6
+ type: ChipType;
7
+ variant: ChipVariant;
8
+ selected: boolean | undefined;
9
+ checkWhenSelected: boolean;
10
+ className: string | undefined;
11
+ children: ReactNode;
12
+ }
13
+ export declare function chipElement({ name, type, variant, selected, checkWhenSelected, className, children }: ChipElementOptions, rest: Record<string, unknown>): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,14 @@
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
+ import { chipContent, chipDataAttributes } from './chip-content.js';
8
+ export function chipElement({ name, type, variant, selected, checkWhenSelected, className, children }, rest) {
9
+ const content = chipContent(children, { check: checkWhenSelected && selected === true });
10
+ assertRenderElement(name, rest.render);
11
+ return (_jsxs(Interactive
12
+ // Antes de las props del uso: un aria-pressed propio gana, como en el Button.
13
+ , { ...(selected === undefined ? {} : { 'aria-pressed': selected }), ...rest, "data-chip": type, "data-chip-stop": "", "data-variant": variant, ...chipDataAttributes(content), className: cx('mk-chip', className), children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), content.content] }));
14
+ }
@@ -0,0 +1,8 @@
1
+ export interface InputChipStrings {
2
+ /**
3
+ * `InputChip` `removeLabel`: the remove button. Its accessible name is this text followed by the
4
+ * chip's label ("Remove Ana").
5
+ */
6
+ removeLabel: string;
7
+ }
8
+ export declare const inputChipStrings: InputChipStrings;
@@ -0,0 +1,5 @@
1
+ // Textos por defecto de los chips (en inglés: son salida para quien usa la librería). El índice
2
+ // src/strings/index.ts los reúne con los demás.
3
+ export const inputChipStrings = {
4
+ removeLabel: 'Remove',
5
+ };
@@ -0,0 +1,78 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ButtonElementProps, type LinkElementProps, type RenderElementProps } from '../../atoms/Interactive/Interactive.tsx';
3
+ /**
4
+ * Color role: an `X` container with `on-X` icon and text. The three `*-container` are the classic
5
+ * ones; `primary`, `secondary` and `tertiary` are the stronger tones Expressive adds. A color, not
6
+ * a style, so the prop is `color` (ADR-0034).
7
+ */
8
+ export type FabColor = 'primary-container' | 'secondary-container' | 'tertiary-container' | 'primary' | 'secondary' | 'tertiary';
9
+ /**
10
+ * Material 3 Expressive size: `sm` 56, `md` 80 and `lg` 96 px tall. In the kit, the 56 FAB is
11
+ * called "Default" and the 56 extended FAB "Small"; here both are `sm`, because a collapsed
12
+ * extended FAB looks the same as the FAB of its size. The small 40 px FAB is obsolete in
13
+ * Expressive and not included.
14
+ */
15
+ export type FabSize = 'sm' | 'md' | 'lg';
16
+ interface FabOwnProps {
17
+ /** Color role (`FabColor`). Defaults to `primary-container`. */
18
+ color?: FabColor | undefined;
19
+ /** Size: 56, 80 or 96 px. Defaults to `sm` (56). */
20
+ size?: FabSize | undefined;
21
+ /**
22
+ * Lower elevation (level 1 at rest and 2 on hover, instead of 3 and 4), for when the FAB sits on
23
+ * a surface that is already elevated. Comes from Compose (`loweredElevation`); the kit does not
24
+ * have it.
25
+ */
26
+ lowered?: boolean | undefined;
27
+ disabled?: never;
28
+ }
29
+ type WithElement<Own> = (Own & Omit<LinkElementProps, keyof Own>) | (Own & Omit<ButtonElementProps, keyof Own | 'disabled'>) | (Own & Omit<RenderElementProps, keyof Own>);
30
+ interface FabContentProps extends FabOwnProps {
31
+ /** Accessible name (becomes `aria-label`). Required: the FAB has no visible text. */
32
+ label: string;
33
+ 'aria-label'?: never;
34
+ /** The icon. */
35
+ children?: ReactNode;
36
+ }
37
+ export type FabProps = WithElement<FabContentProps>;
38
+ interface ExtendedFabContentProps extends FabOwnProps {
39
+ /**
40
+ * With `false`, collapses to an icon-only FAB; the text hides with an animation but is still the
41
+ * accessible name. Defaults to `true`.
42
+ */
43
+ expanded?: boolean | undefined;
44
+ /** The icon, first, and the text: `<AddIcon />Create`. */
45
+ children?: ReactNode;
46
+ }
47
+ export type ExtendedFabProps = WithElement<ExtendedFabContentProps>;
48
+ /**
49
+ * Material 3 Expressive floating action button (FAB): the screen's primary action, icon only. A
50
+ * `<button type="button">`, an `<a>` with `href`, or the `render` element.
51
+ *
52
+ * **It does not position itself.** The app places it (for example, `position: fixed` in the
53
+ * bottom-right corner, 16 px from the edges, plus the system safe area); the playground shows it
54
+ * floating in the corner of a frame. That way it also works inside a NavigationRail or any
55
+ * container.
56
+ *
57
+ * ```tsx
58
+ * <Fab label="Write"><EditIcon /></Fab>
59
+ * <Fab label="New" size="lg" color="tertiary" render={<Link href="/new" />}><AddIcon /></Fab>
60
+ * ```
61
+ */
62
+ export declare function Fab(props: FabProps): import("react").JSX.Element;
63
+ /**
64
+ * Material 3 Expressive extended FAB: icon and text, like a Button. The text is the accessible
65
+ * name, also when collapsed. The icon goes first (it is the one left visible when collapsing).
66
+ *
67
+ * With `expanded={false}` it collapses to a FAB of the same size, with the spatial spring and the
68
+ * text fading out; with `prefers-reduced-motion`, the width changes without animating.
69
+ *
70
+ * **It does not position itself**, like `Fab`: the app places it.
71
+ *
72
+ * ```tsx
73
+ * <ExtendedFab><EditIcon />Write</ExtendedFab>
74
+ * <ExtendedFab expanded={!scrolled} size="md" href="/new"><AddIcon />New</ExtendedFab>
75
+ * ```
76
+ */
77
+ export declare function ExtendedFab(props: ExtendedFabProps): import("react").JSX.Element;
78
+ export {};
@@ -0,0 +1,52 @@
1
+ import { Fragment as _Fragment, 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
+ // Atributos que lee fab.css.
8
+ const dataAttributes = (color, size, lowered, expanded) => ({
9
+ 'data-color': color,
10
+ 'data-size': size,
11
+ 'data-lowered': lowered ? '' : undefined,
12
+ 'data-expanded': expanded === undefined ? undefined : String(expanded),
13
+ });
14
+ const atoms = (_jsxs(_Fragment, { children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {})] }));
15
+ /**
16
+ * Material 3 Expressive floating action button (FAB): the screen's primary action, icon only. A
17
+ * `<button type="button">`, an `<a>` with `href`, or the `render` element.
18
+ *
19
+ * **It does not position itself.** The app places it (for example, `position: fixed` in the
20
+ * bottom-right corner, 16 px from the edges, plus the system safe area); the playground shows it
21
+ * floating in the corner of a frame. That way it also works inside a NavigationRail or any
22
+ * container.
23
+ *
24
+ * ```tsx
25
+ * <Fab label="Write"><EditIcon /></Fab>
26
+ * <Fab label="New" size="lg" color="tertiary" render={<Link href="/new" />}><AddIcon /></Fab>
27
+ * ```
28
+ */
29
+ export function Fab(props) {
30
+ const { label, color = 'primary-container', size = 'sm', lowered, className, children, ...rest } = props;
31
+ assertRenderElement('Fab', rest.render);
32
+ return (_jsxs(Interactive, { ...rest, "aria-label": label, ...dataAttributes(color, size, lowered), className: cx('mk-fab', className), children: [atoms, children] }));
33
+ }
34
+ /**
35
+ * Material 3 Expressive extended FAB: icon and text, like a Button. The text is the accessible
36
+ * name, also when collapsed. The icon goes first (it is the one left visible when collapsing).
37
+ *
38
+ * With `expanded={false}` it collapses to a FAB of the same size, with the spatial spring and the
39
+ * text fading out; with `prefers-reduced-motion`, the width changes without animating.
40
+ *
41
+ * **It does not position itself**, like `Fab`: the app places it.
42
+ *
43
+ * ```tsx
44
+ * <ExtendedFab><EditIcon />Write</ExtendedFab>
45
+ * <ExtendedFab expanded={!scrolled} size="md" href="/new"><AddIcon />New</ExtendedFab>
46
+ * ```
47
+ */
48
+ export function ExtendedFab(props) {
49
+ const { expanded = true, color = 'primary-container', size = 'sm', lowered, className, children, ...rest } = props;
50
+ assertRenderElement('ExtendedFab', rest.render);
51
+ return (_jsxs(Interactive, { ...rest, ...dataAttributes(color, size, lowered, expanded), className: cx('mk-extended-fab', className), children: [atoms, _jsx("span", { className: "mk-extended-fab-content", children: _jsx("span", { className: "mk-extended-fab-label", children: children }) })] }));
52
+ }
@@ -0,0 +1,59 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type ToggleButtonOrLinkProps } from '../../internal/interactive.tsx';
3
+ export type IconButtonVariant = 'standard' | 'filled' | 'tonal' | 'outlined';
4
+ export type IconButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
5
+ export type IconButtonWidth = 'narrow' | 'default' | 'wide';
6
+ export type IconButtonShape = 'round' | 'square';
7
+ interface IconButtonOwnProps {
8
+ /** Accessible name (becomes `aria-label`). Required: the button has no visible text. */
9
+ label: string;
10
+ 'aria-label'?: never;
11
+ /** Color style. Defaults to `standard` (no container). */
12
+ variant?: IconButtonVariant | undefined;
13
+ /** Material 3 Expressive size: 32, 40, 56, 96 or 136 px tall. Defaults to `sm`. */
14
+ size?: IconButtonSize | undefined;
15
+ /** Container width: narrower, equal to the height, or wider. Defaults to `default` (equal to the height). */
16
+ width?: IconButtonWidth | undefined;
17
+ /**
18
+ * Resting shape. When pressed it becomes squarer; when a toggle is selected, round becomes
19
+ * square and square becomes round. Defaults to `round`.
20
+ */
21
+ shape?: IconButtonShape | undefined;
22
+ /** The icon. */
23
+ children?: ReactNode;
24
+ }
25
+ /**
26
+ * IconButton props: its own plus one of three forms (ADR-0010), like `ButtonProps`.
27
+ * - Without `href` or `render`: a `<button type="button">` with `ref` to the `<button>`, `disabled`
28
+ * and `selected`, which makes it a toggle (`aria-pressed`; when undefined, a plain button).
29
+ * - With `href`: an `<a>` (`ref` to the `<a>`). With `render`: the router's `Link`.
30
+ * The two link forms do not accept `selected`, `disabled` or `aria-disabled`.
31
+ */
32
+ export type IconButtonProps = ToggleButtonOrLinkProps<IconButtonOwnProps>;
33
+ /**
34
+ * Material 3 Expressive icon button.
35
+ *
36
+ * The icon is the child; the component sizes it with `--mk-icon-size` (20 to 40 px depending on
37
+ * the size). `label` is the name screen readers announce. With `href` or `render` it is a link
38
+ * that looks the same (an icon that opens another page).
39
+ *
40
+ * Customization with CSS variables:
41
+ * - `--mk-icon-button-color`: icon color of the unselected `standard` style (defaults to
42
+ * `on-surface-variant`). Inherited: set on a container, it affects the buttons inside.
43
+ * Selected and disabled keep their colors.
44
+ * - `--mk-icon-button-selected-container` and `--mk-icon-button-selected-color`: background
45
+ * (defaults to none) and icon color (`primary`) of the selected `standard` toggle. Also
46
+ * inherited; the Toolbar sets them for its buttons.
47
+ * - `--mk-icon-button-selected-round`: `1` keeps the selected toggle round (by default it turns
48
+ * square); the Toolbar uses it, as in the kit.
49
+ *
50
+ * ```tsx
51
+ * <IconButton label="Search"><SearchIcon /></IconButton>
52
+ * <IconButton variant="filled" width="wide" label="Favorite" selected={fav} onClick={() => setFav(!fav)}>
53
+ * <StarIcon filled={fav} />
54
+ * </IconButton>
55
+ * <IconButton label="Settings" render={<Link href="/settings" />}><SettingsIcon /></IconButton>
56
+ * ```
57
+ */
58
+ export declare function IconButton(props: IconButtonProps): import("react").JSX.Element;
59
+ export {};
@@ -0,0 +1,36 @@
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 icon button.
9
+ *
10
+ * The icon is the child; the component sizes it with `--mk-icon-size` (20 to 40 px depending on
11
+ * the size). `label` is the name screen readers announce. With `href` or `render` it is a link
12
+ * that looks the same (an icon that opens another page).
13
+ *
14
+ * Customization with CSS variables:
15
+ * - `--mk-icon-button-color`: icon color of the unselected `standard` style (defaults to
16
+ * `on-surface-variant`). Inherited: set on a container, it affects the buttons inside.
17
+ * Selected and disabled keep their colors.
18
+ * - `--mk-icon-button-selected-container` and `--mk-icon-button-selected-color`: background
19
+ * (defaults to none) and icon color (`primary`) of the selected `standard` toggle. Also
20
+ * inherited; the Toolbar sets them for its buttons.
21
+ * - `--mk-icon-button-selected-round`: `1` keeps the selected toggle round (by default it turns
22
+ * square); the Toolbar uses it, as in the kit.
23
+ *
24
+ * ```tsx
25
+ * <IconButton label="Search"><SearchIcon /></IconButton>
26
+ * <IconButton variant="filled" width="wide" label="Favorite" selected={fav} onClick={() => setFav(!fav)}>
27
+ * <StarIcon filled={fav} />
28
+ * </IconButton>
29
+ * <IconButton label="Settings" render={<Link href="/settings" />}><SettingsIcon /></IconButton>
30
+ * ```
31
+ */
32
+ export function IconButton(props) {
33
+ const { label, variant = 'standard', size = 'sm', width = 'default', shape = 'round', selected, className, children, ...rest } = props;
34
+ assertRenderElement('IconButton', rest.render);
35
+ return (_jsxs(Interactive, { ...(selected === undefined ? {} : { 'aria-pressed': selected }), ...rest, "aria-label": label, "data-variant": variant, "data-size": size, "data-width": width, "data-shape": shape, className: cx('mk-icon-button', className), children: [_jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx(FocusRing, {}), children] }));
36
+ }