@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,169 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Molécula interactiva (excepción al ADR-0003, registrada en el ADR-0014): como Slider, guarda los
4
+ // dos valores para dibujar la pista activa entre los handles, y los reparte por contexto a sus dos
5
+ // partes, RangeSliderStart y RangeSliderEnd (API por composición, ADR-0002, como RadioGroup en el
6
+ // ADR-0012). Cada parte es un <input type="range"> nativo con su propio nombre accesible y su
7
+ // propio `name`: el patrón "Slider (Multi-Thumb)" de la guía APG con dos sliders nativos.
8
+ //
9
+ // Los dos inputs cubren el control entero (así comparten la escala) y cada uno recibe el puntero
10
+ // de su lado del punto medio entre los handles (clip-path en slider.css, como @material/web). El
11
+ // componente solo agrega:
12
+ // - que los handles no se crucen: si un valor pasa al otro, vuelve a quedar igual (con el teclado
13
+ // y con el puntero);
14
+ // - con los dos valores iguales, arrastrar hacia el lado del otro mueve al otro ("flip" de
15
+ // @material/web), porque si no el que quedó arriba no podría salir hacia ese lado;
16
+ // - reenfocar al soltar el puntero (WebKit no enfoca un range con el clic) y las flechas en
17
+ // vertical y RTL, como Slider.
18
+ import { createContext, useContext, useEffect, useMemo, useRef, useState, } from 'react';
19
+ import { partOutsideParent } from '../../internal/diagnostics.js';
20
+ import { mergeRefs } from '../../internal/merge-refs.js';
21
+ import { formatValue, handleArrowKeys, markFractions, normalizeValue, setNativeValue, SliderHandle, SliderTrack, toFraction, } from './slider-shared.js';
22
+ const RangeSliderContext = createContext(null);
23
+ /**
24
+ * Material 3 Expressive range slider: two handles, each a native `<input type="range">`
25
+ * (`RangeSliderStart` and `RangeSliderEnd`, with their own accessible name and `name`). The
26
+ * handles do not cross.
27
+ *
28
+ * The container props (`className`, `style`, `id`, `aria-*`…) go to the `<div>`; with
29
+ * `aria-label` or `aria-labelledby` the container becomes a group (`role="group"`).
30
+ *
31
+ * ```tsx
32
+ * <RangeSlider defaultValue={[20, 80]} aria-label="Price">
33
+ * <RangeSliderStart label="Minimum price" name="from" />
34
+ * <RangeSliderEnd label="Maximum price" name="to" />
35
+ * </RangeSlider>
36
+ * ```
37
+ */
38
+ export function RangeSlider({ value, defaultValue, onValueChange, min = 0, max = 100, step = 1, disabled = false, size = 'xs', orientation = 'horizontal', ticks = false, valueIndicator = true, format, className, style, children, ...rootProps }) {
39
+ const controlled = value !== undefined;
40
+ const initial = () => {
41
+ const span = max - min;
42
+ const [s, e] = defaultValue ?? [min + span / 3, min + (2 * span) / 3];
43
+ const start = normalizeValue(s, min, max, step);
44
+ return [start, Math.max(start, normalizeValue(e, min, max, step))];
45
+ };
46
+ const [inner, setInner] = useState(initial);
47
+ const values = controlled
48
+ ? [normalizeValue(value[0], min, max, step), normalizeValue(value[1], min, max, step)]
49
+ : inner;
50
+ const valuesRef = useRef(values);
51
+ valuesRef.current = values;
52
+ const inputs = useRef([null, null]);
53
+ const action = useRef(null);
54
+ const vertical = orientation === 'vertical';
55
+ // No controlado: al reiniciar el formulario (que no dispara `input`), vuelven los valores iniciales.
56
+ const initialRef = useRef(initial);
57
+ initialRef.current = initial;
58
+ useEffect(() => {
59
+ const form = inputs.current[0]?.form ?? inputs.current[1]?.form;
60
+ if (controlled || !form)
61
+ return;
62
+ const onReset = () => setInner(initialRef.current());
63
+ form.addEventListener('reset', onReset);
64
+ return () => form.removeEventListener('reset', onReset);
65
+ }, [controlled]);
66
+ const context = useMemo(() => {
67
+ const commit = (next, event) => {
68
+ if (!controlled)
69
+ setInner(next);
70
+ onValueChange?.(next, event);
71
+ };
72
+ return {
73
+ values,
74
+ min,
75
+ max,
76
+ step,
77
+ disabled,
78
+ vertical,
79
+ valueIndicator,
80
+ format,
81
+ inputs,
82
+ onThumbChange(index, event) {
83
+ const current = valuesRef.current;
84
+ const own = event.currentTarget;
85
+ const other = inputs.current[index === 0 ? 1 : 0];
86
+ let v = own.valueAsNumber;
87
+ const a = action.current;
88
+ // Si al presionar estaban iguales, pasar al otro lado mueve al otro (y el presionado vuelve
89
+ // a su valor). Firefox y WebKit mueven el valor al punto del clic aunque caiga sobre el
90
+ // thumb, así que el primer movimiento puede ir hacia el lado contrario: el cambio se
91
+ // decide cuando el valor cruza, no en el primer movimiento (como @material/web).
92
+ if (a && a.index === index && a.canFlip && a.start[0] === a.start[1]) {
93
+ const crosses = index === 0 ? v > a.start[1] : v < a.start[0];
94
+ if (crosses) {
95
+ a.canFlip = false;
96
+ a.flipped = true;
97
+ }
98
+ }
99
+ if (a?.flipped && a.index === index && other) {
100
+ const fixed = a.start[index];
101
+ setNativeValue(own, fixed);
102
+ const moved = index === 0 ? Math.max(v, fixed) : Math.min(v, fixed);
103
+ setNativeValue(other, moved);
104
+ commit(index === 0 ? [fixed, moved] : [moved, fixed], event);
105
+ return;
106
+ }
107
+ // Sin cruzarse: si pasa al otro, queda igual.
108
+ const limit = current[index === 0 ? 1 : 0];
109
+ const clamped = index === 0 ? Math.min(v, limit) : Math.max(v, limit);
110
+ if (clamped !== v) {
111
+ setNativeValue(own, clamped);
112
+ v = clamped;
113
+ }
114
+ commit(index === 0 ? [v, current[1]] : [current[0], v], event);
115
+ },
116
+ onThumbPointerDown(index) {
117
+ const [s0, e0] = valuesRef.current;
118
+ action.current = { index, start: [s0, e0], canFlip: true, flipped: false };
119
+ addEventListener('pointerup', () => {
120
+ const a = action.current;
121
+ action.current = null;
122
+ const target = inputs.current[a?.flipped ? (index === 0 ? 1 : 0) : index];
123
+ // WebKit no enfoca un range con el clic; y si hubo flip, el foco va al que se movió.
124
+ target?.focus({ preventScroll: true });
125
+ if (a?.flipped && target)
126
+ target.dispatchEvent(new Event('change', { bubbles: true }));
127
+ }, { once: true });
128
+ },
129
+ };
130
+ }, [values[0], values[1], min, max, step, disabled, vertical, valueIndicator, format, controlled, onValueChange]);
131
+ const named = rootProps['aria-label'] !== undefined || rootProps['aria-labelledby'] !== undefined;
132
+ return (_jsxs("div", { role: named ? 'group' : undefined, ...rootProps, className: className ? `mk-slider ${className}` : 'mk-slider', style: {
133
+ ...style,
134
+ '--_v1': toFraction(values[0], min, max),
135
+ '--_v2': toFraction(values[1], min, max),
136
+ }, "data-size": size, "data-orientation": orientation, "data-variant": "range", children: [_jsx(SliderTrack, { startSegment: true, marks: markFractions({ min, max, step, ticks, startStop: true, skipCenter: false }) }), _jsx(RangeSliderContext.Provider, { value: context, children: children })] }));
137
+ }
138
+ function RangeSliderThumb({ index, label, ref, onChange, onKeyDown, onPointerDown, disabled, ...inputProps }) {
139
+ const ctx = useContext(RangeSliderContext);
140
+ if (!ctx)
141
+ throw partOutsideParent(index === 0 ? 'RangeSliderStart' : 'RangeSliderEnd', 'RangeSlider');
142
+ const { inputs } = ctx;
143
+ const setRef = useMemo(() => mergeRefs((node) => {
144
+ inputs.current[index] = node;
145
+ }, ref), [inputs, index, ref]);
146
+ const current = ctx.values[index];
147
+ const text = formatValue(current, ctx.format);
148
+ return (_jsxs(_Fragment, { children: [_jsx("input", { ...inputProps, ref: setRef, type: "range", className: "mk-slider-input", "data-thumb": index === 0 ? 'start' : 'end', min: ctx.min, max: ctx.max, step: ctx.step,
149
+ // Controlado siempre por el estado del grupo: así el valor recortado o desviado (flip)
150
+ // vuelve al input en el render siguiente.
151
+ value: String(current), disabled: disabled ?? (ctx.disabled || undefined), "aria-label": label ?? inputProps['aria-label'], "aria-valuetext": inputProps['aria-valuetext'] ?? (ctx.format ? text : undefined), "aria-orientation": ctx.vertical ? 'vertical' : undefined, onChange: (event) => {
152
+ onChange?.(event);
153
+ ctx.onThumbChange(index, event);
154
+ }, onKeyDown: (event) => {
155
+ onKeyDown?.(event);
156
+ handleArrowKeys(event, ctx.vertical);
157
+ }, onPointerDown: (event) => {
158
+ onPointerDown?.(event);
159
+ ctx.onThumbPointerDown(index);
160
+ } }), _jsx(SliderHandle, { label: text, indicator: ctx.valueIndicator })] }));
161
+ }
162
+ /** Handle for the start of the range (the lower value), inside a `RangeSlider`. Needs an accessible name. */
163
+ export function RangeSliderStart(props) {
164
+ return _jsx(RangeSliderThumb, { ...props, index: 0 });
165
+ }
166
+ /** Handle for the end of the range (the higher value), inside a `RangeSlider`. Needs an accessible name. */
167
+ export function RangeSliderEnd(props) {
168
+ return _jsx(RangeSliderThumb, { ...props, index: 1 });
169
+ }
@@ -0,0 +1,54 @@
1
+ import { type ChangeEvent, type InputHTMLAttributes, type Ref } from 'react';
2
+ import type { AccessibleNameProps } from '../../internal/accessible-name.ts';
3
+ import { type SliderFormat, type SliderOrientation, type SliderSize } from './slider-shared.tsx';
4
+ type NativeInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'min' | 'max' | 'step' | 'size' | 'children' | 'aria-label' | 'aria-labelledby'>;
5
+ export interface SliderOwnProps {
6
+ /** Value (controlled). */
7
+ value?: number | undefined;
8
+ /** Initial value (uncontrolled). Without it, the midpoint, like the native input. */
9
+ defaultValue?: number | undefined;
10
+ /** Called with the new value and the input's event on every change. */
11
+ onValueChange?: ((value: number, event: ChangeEvent<HTMLInputElement>) => void) | undefined;
12
+ /** Minimum. Defaults to `0`. */
13
+ min?: number | undefined;
14
+ /** Maximum. Defaults to `100`. */
15
+ max?: number | undefined;
16
+ /** Step. Defaults to `1`. */
17
+ step?: number | undefined;
18
+ /** Material 3 Expressive size: track of 16, 24, 40, 56 or 96. Defaults to `xs`. */
19
+ size?: SliderSize | undefined;
20
+ /** `vertical`: the minimum at the bottom. Defaults to `horizontal`. */
21
+ orientation?: SliderOrientation | undefined;
22
+ /** The active track goes from the center to the value, with stop dots at both ends. */
23
+ centered?: boolean | undefined;
24
+ /** A dot at every step. Meant for few steps (one per item). */
25
+ ticks?: boolean | undefined;
26
+ /** Value indicator while pressing, dragging and with keyboard focus. Defaults to `true`. */
27
+ valueIndicator?: boolean | undefined;
28
+ /**
29
+ * Text of the value in the indicator and in `aria-valuetext`: a function or an
30
+ * `Intl.NumberFormat`. Without it, the plain number (and no `aria-valuetext`: the screen reader
31
+ * announces the number).
32
+ */
33
+ format?: SliderFormat | undefined;
34
+ /** Ref to the native `<input type="range">`. */
35
+ ref?: Ref<HTMLInputElement> | undefined;
36
+ }
37
+ export type SliderProps = NativeInputProps & SliderOwnProps & AccessibleNameProps;
38
+ /**
39
+ * Material 3 Expressive slider on a native, invisible `<input type="range">` that covers the drawn
40
+ * control: keyboard, dragging, forms and screen readers are the browser's.
41
+ *
42
+ * It needs an accessible name: `label`, `aria-labelledby` or `aria-label`. The input props
43
+ * (`name`, `disabled`, `onChange`, `onInput`, `id`, `form`…) pass through as they are; `className`
44
+ * and `style` go to the container.
45
+ *
46
+ * ```tsx
47
+ * <Slider label="Volume" defaultValue={40} />
48
+ * <Slider label="Brightness" value={v} onValueChange={setV} size="md" />
49
+ * <Slider label="Balance" min={-50} max={50} defaultValue={0} centered />
50
+ * <Slider label="Price" step={10} ticks format={new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })} />
51
+ * ```
52
+ */
53
+ export declare function Slider({ value, defaultValue, onValueChange, min, max, step, size, orientation, centered, ticks, valueIndicator, format, label, className, style, ref, onChange, onKeyDown, onPointerDown, disabled, ...inputProps }: SliderProps): import("react").JSX.Element;
54
+ export {};
@@ -0,0 +1,71 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Molécula interactiva (excepción al ADR-0003, registrada en el ADR-0014). La pista activa depende
4
+ // del valor, y con el <input type="range"> nativo no hay forma de reflejarlo en CSS en los tres
5
+ // motores: Firefox tiene ::-moz-range-progress, Chrome y WebKit no (comprobado el 2026-11-25). El
6
+ // componente guarda el valor (o lo recibe, controlado) y lo pasa al CSS como fracción (--_v2), y
7
+ // con él escribe el indicador de valor.
8
+ //
9
+ // El control se dibuja con elementos propios y el input nativo, invisible, lo cubre entero: el
10
+ // teclado (flechas, Re Pág, Av Pág, Inicio y Fin), el arrastre, el clic en la pista, el envío en
11
+ // formularios y la accesibilidad (rol slider, valores) son del navegador. Las únicas ayudas: las
12
+ // flechas izquierda y derecha en vertical y en RTL, donde los motores no coinciden
13
+ // (slider-shared.tsx), y reenfocar el input al soltar el puntero, porque WebKit no lo enfoca con
14
+ // un clic (como hace @material/web).
15
+ import { useEffect, useMemo, useRef, useState } from 'react';
16
+ import { mergeRefs } from '../../internal/merge-refs.js';
17
+ import { formatValue, handleArrowKeys, markFractions, normalizeValue, SliderHandle, SliderTrack, toFraction, } from './slider-shared.js';
18
+ /**
19
+ * Material 3 Expressive slider on a native, invisible `<input type="range">` that covers the drawn
20
+ * control: keyboard, dragging, forms and screen readers are the browser's.
21
+ *
22
+ * It needs an accessible name: `label`, `aria-labelledby` or `aria-label`. The input props
23
+ * (`name`, `disabled`, `onChange`, `onInput`, `id`, `form`…) pass through as they are; `className`
24
+ * and `style` go to the container.
25
+ *
26
+ * ```tsx
27
+ * <Slider label="Volume" defaultValue={40} />
28
+ * <Slider label="Brightness" value={v} onValueChange={setV} size="md" />
29
+ * <Slider label="Balance" min={-50} max={50} defaultValue={0} centered />
30
+ * <Slider label="Price" step={10} ticks format={new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' })} />
31
+ * ```
32
+ */
33
+ export function Slider({ value, defaultValue, onValueChange, min = 0, max = 100, step = 1, size = 'xs', orientation = 'horizontal', centered = false, ticks = false, valueIndicator = true, format, label, className, style, ref, onChange, onKeyDown, onPointerDown, disabled, ...inputProps }) {
34
+ const controlled = value !== undefined;
35
+ const [inner, setInner] = useState(() => normalizeValue(defaultValue, min, max, step));
36
+ const current = controlled ? normalizeValue(value, min, max, step) : inner;
37
+ const inputRef = useRef(null);
38
+ const setInputRef = useMemo(() => mergeRefs(inputRef, ref), [ref]);
39
+ const vertical = orientation === 'vertical';
40
+ // No controlado: el input es el dueño del valor. Se lee al montar (por si el saneamiento del
41
+ // navegador difiere del calculado) y después de reiniciar el formulario, que no dispara `input`.
42
+ useEffect(() => {
43
+ const input = inputRef.current;
44
+ if (controlled || !input)
45
+ return;
46
+ setInner(input.valueAsNumber);
47
+ const form = input.form;
48
+ if (!form)
49
+ return;
50
+ const onReset = () => setTimeout(() => setInner(input.valueAsNumber));
51
+ form.addEventListener('reset', onReset);
52
+ return () => form.removeEventListener('reset', onReset);
53
+ }, [controlled]);
54
+ const text = formatValue(current, format);
55
+ const ariaValueText = inputProps['aria-valuetext'] ?? (format ? text : undefined);
56
+ return (_jsxs("div", { className: className ? `mk-slider ${className}` : 'mk-slider', style: { ...style, '--_v2': toFraction(current, min, max) }, "data-size": size, "data-orientation": orientation, "data-variant": centered ? 'centered' : 'standard', children: [_jsx(SliderTrack, { startSegment: centered, marks: markFractions({ min, max, step, ticks, startStop: centered, skipCenter: centered }) }), _jsx("input", { ...inputProps, ref: setInputRef, type: "range", className: "mk-slider-input", "data-thumb": "end", min: min, max: max, step: step, disabled: disabled, "aria-label": label ?? inputProps['aria-label'], "aria-valuetext": ariaValueText, "aria-orientation": vertical ? 'vertical' : undefined, ...(controlled ? { value: String(current) } : { defaultValue: defaultValue === undefined ? undefined : String(defaultValue) }), onChange: (event) => {
57
+ onChange?.(event);
58
+ const next = event.currentTarget.valueAsNumber;
59
+ if (!controlled)
60
+ setInner(next);
61
+ onValueChange?.(next, event);
62
+ }, onKeyDown: (event) => {
63
+ onKeyDown?.(event);
64
+ handleArrowKeys(event, vertical);
65
+ }, onPointerDown: (event) => {
66
+ onPointerDown?.(event);
67
+ const input = event.currentTarget;
68
+ // WebKit no enfoca un range con el clic: se enfoca al soltar, como @material/web.
69
+ addEventListener('pointerup', () => input.focus({ preventScroll: true }), { once: true });
70
+ } }), _jsx(SliderHandle, { label: text, indicator: valueIndicator })] }));
71
+ }
@@ -0,0 +1,26 @@
1
+ import type { KeyboardEvent, ReactNode } from 'react';
2
+ export type SliderSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
3
+ export type SliderOrientation = 'horizontal' | 'vertical';
4
+ /** Text of a value: a function or an `Intl.NumberFormat`. */
5
+ export type SliderFormat = ((value: number) => string) | Intl.NumberFormat;
6
+ export declare function normalizeValue(value: number | undefined, min: number, max: number, step: number): number;
7
+ export declare function toFraction(value: number, min: number, max: number): number;
8
+ export declare function formatValue(value: number, format: SliderFormat | undefined): string;
9
+ export declare function setNativeValue(input: HTMLInputElement, value: number): void;
10
+ export declare function handleArrowKeys(event: KeyboardEvent<HTMLInputElement>, vertical: boolean): void;
11
+ export declare function markFractions(options: {
12
+ min: number;
13
+ max: number;
14
+ step: number;
15
+ ticks: boolean;
16
+ startStop: boolean;
17
+ skipCenter: boolean;
18
+ }): number[];
19
+ export declare function SliderTrack({ marks, startSegment }: {
20
+ marks: number[];
21
+ startSegment: boolean;
22
+ }): import("react").JSX.Element;
23
+ export declare function SliderHandle({ label, indicator }: {
24
+ label: ReactNode;
25
+ indicator: boolean;
26
+ }): import("react").JSX.Element;
@@ -0,0 +1,98 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
3
+ import { StateLayer } from '../../atoms/StateLayer/StateLayer.js';
4
+ // Decimales de un número, para no arrastrar errores de coma flotante al ajustar al paso.
5
+ function decimals(n) {
6
+ const s = String(n);
7
+ if (s.includes('e-'))
8
+ return Number(s.split('e-')[1]);
9
+ return s.split('.')[1]?.length ?? 0;
10
+ }
11
+ // El valor que tendría el input nativo (algoritmo de saneamiento de HTML para `range`): dentro de
12
+ // [min, max], ajustado al paso contado desde `min` (los empates, hacia arriba) y, si el ajuste
13
+ // pasa de `max`, el paso anterior. Sin valor, el punto medio.
14
+ export function normalizeValue(value, min, max, step) {
15
+ const hi = max < min ? min : max;
16
+ const raw = value === undefined || Number.isNaN(value) ? min + (hi - min) / 2 : value;
17
+ const clamped = Math.min(Math.max(raw, min), hi);
18
+ if (!(step > 0))
19
+ return clamped;
20
+ const places = Math.max(decimals(step), decimals(min));
21
+ // toFixed(9) antes de redondear: 0,35 / 0,1 da 3,4999…, y el navegador (que cuenta en decimal) da 4.
22
+ const steps = Math.floor(Number(((clamped - min) / step).toFixed(9)) + 0.5);
23
+ let snapped = Number((min + steps * step).toFixed(places));
24
+ if (snapped > hi)
25
+ snapped = Number((snapped - step).toFixed(places));
26
+ return snapped;
27
+ }
28
+ // Fracción de 0 a 1 de un valor en [min, max].
29
+ export function toFraction(value, min, max) {
30
+ return max > min ? (value - min) / (max - min) : 0;
31
+ }
32
+ export function formatValue(value, format) {
33
+ if (typeof format === 'function')
34
+ return format(value);
35
+ return format ? format.format(value) : String(value);
36
+ }
37
+ // Asigna el valor de un input sin pasar por el seguimiento de React (que se instala en la
38
+ // instancia): así el `input` que se despacha después llega a `onChange` como uno del usuario.
39
+ export function setNativeValue(input, value) {
40
+ Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(input, String(value));
41
+ }
42
+ function dispatchValueEvents(input) {
43
+ input.dispatchEvent(new Event('input', { bubbles: true }));
44
+ input.dispatchEvent(new Event('change', { bubbles: true }));
45
+ }
46
+ // Flechas izquierda y derecha donde los motores no coinciden (comprobado el 2026-11-25):
47
+ // - horizontal de derecha a izquierda: Chrome y Firefox mueven el handle hacia la flecha
48
+ // (derecha baja el valor); WebKit sube el valor con la derecha, que mueve el handle a la
49
+ // izquierda;
50
+ // - vertical (writing-mode): Chrome y WebKit suben el valor con la derecha (como pide la guía
51
+ // APG, "Right Arrow: increase"); Firefox lo baja.
52
+ // En esos dos casos la flecha se resuelve acá, como en Chrome: en vertical, derecha sube; en
53
+ // horizontal, el handle va hacia la flecha. Arriba, abajo, Re Pág, Av Pág, Inicio y Fin siguen
54
+ // siendo del navegador, que los resuelve igual en los tres.
55
+ export function handleArrowKeys(event, vertical) {
56
+ const { key } = event;
57
+ if (event.defaultPrevented || (key !== 'ArrowLeft' && key !== 'ArrowRight'))
58
+ return;
59
+ const input = event.currentTarget;
60
+ const rtl = !vertical && getComputedStyle(input).direction === 'rtl';
61
+ if (!vertical && !rtl)
62
+ return;
63
+ event.preventDefault();
64
+ const before = input.value;
65
+ if ((key === 'ArrowRight') !== rtl)
66
+ input.stepUp();
67
+ else
68
+ input.stepDown();
69
+ if (input.value !== before)
70
+ dispatchValueEvents(input);
71
+ }
72
+ // Fracciones de las marcas: los pasos (con `ticks`) y los puntos de parada de los extremos.
73
+ export function markFractions(options) {
74
+ const { min, max, step, ticks, startStop, skipCenter } = options;
75
+ const marks = new Set([1]);
76
+ if (startStop)
77
+ marks.add(0);
78
+ if (ticks && max > min && step > 0) {
79
+ const count = Math.floor((max - min) / step + 1e-9);
80
+ for (let k = 0; k <= count; k++)
81
+ marks.add(Number(((k * step) / (max - min)).toFixed(6)));
82
+ }
83
+ // En el centrado, el centro cae en la separación de 4 entre pistas (Compose también lo saltea).
84
+ if (skipCenter)
85
+ marks.delete(0.5);
86
+ return [...marks].sort((a, b) => a - b);
87
+ }
88
+ // La pista: dos o tres tramos (inactivo, activo, inactivo) que calcula slider.css con las
89
+ // fracciones del elemento principal (--_v1 y --_v2). Cada tramo recorta su propia copia de las
90
+ // marcas: así los puntos toman el color del tramo y desaparecen en la separación del handle.
91
+ export function SliderTrack({ marks, startSegment }) {
92
+ const segments = startSegment ? ['inactive-start', 'active', 'inactive-end'] : ['active', 'inactive-end'];
93
+ return (_jsx("span", { className: "mk-slider-track", "aria-hidden": "true", children: segments.map((segment) => (_jsx("span", { className: "mk-slider-segment", "data-segment": segment, children: _jsx("span", { className: "mk-slider-marks", children: marks.map((t) => (_jsx("span", { className: "mk-slider-mark", style: { '--_t': t } }, t))) }) }, segment))) }));
94
+ }
95
+ // Handle dibujado, con la capa de estado, el anillo de foco y el indicador de valor.
96
+ export function SliderHandle({ label, indicator }) {
97
+ return (_jsxs("span", { className: "mk-slider-handle", "aria-hidden": "true", children: [_jsx(StateLayer, {}), _jsx(FocusRing, {}), indicator && _jsx("span", { className: "mk-slider-value-indicator", children: label })] }));
98
+ }
@@ -0,0 +1,22 @@
1
+ import type { InputHTMLAttributes, ReactNode, Ref } from 'react';
2
+ export interface SwitchProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'role' | 'children'> {
3
+ /** Text or content of the label; it is the accessible name. Clicking it also toggles the switch. */
4
+ children?: ReactNode;
5
+ /** Shows a check mark on the handle when on and a cross when off. */
6
+ icons?: boolean | undefined;
7
+ /** Ref to the native `<input>`. */
8
+ ref?: Ref<HTMLInputElement> | undefined;
9
+ }
10
+ /**
11
+ * Material 3 switch, on a native `<input type="checkbox" role="switch">`: it works in forms, with
12
+ * the keyboard (Space) and with screen readers, which announce it as a switch that is on or off.
13
+ *
14
+ * The input props (`checked`, `defaultChecked`, `onChange`, `name`, `value`, `disabled`,
15
+ * `required`…) pass through as they are. `className` and `style` go to the container (`<label>`).
16
+ *
17
+ * ```tsx
18
+ * <Switch defaultChecked>Wi-Fi</Switch>
19
+ * <Switch checked={on} onChange={(e) => setOn(e.target.checked)} icons>Airplane mode</Switch>
20
+ * ```
21
+ */
22
+ export declare function Switch({ children, icons, className, style, ref, ...inputProps }: SwitchProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
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 { CheckIcon, CloseIcon } from '../../icons/icons.js';
6
+ /**
7
+ * Material 3 switch, on a native `<input type="checkbox" role="switch">`: it works in forms, with
8
+ * the keyboard (Space) and with screen readers, which announce it as a switch that is on or off.
9
+ *
10
+ * The input props (`checked`, `defaultChecked`, `onChange`, `name`, `value`, `disabled`,
11
+ * `required`…) pass through as they are. `className` and `style` go to the container (`<label>`).
12
+ *
13
+ * ```tsx
14
+ * <Switch defaultChecked>Wi-Fi</Switch>
15
+ * <Switch checked={on} onChange={(e) => setOn(e.target.checked)} icons>Airplane mode</Switch>
16
+ * ```
17
+ */
18
+ export function Switch({ children, icons = false, className, style, ref, ...inputProps }) {
19
+ return (_jsxs("label", { className: className ? `mk-switch ${className}` : 'mk-switch', style: style, "data-icons": icons || undefined, children: [_jsxs("span", { className: "mk-switch-control", children: [_jsx("input", { ...inputProps, ref: ref, type: "checkbox", role: "switch", className: "mk-switch-input" }), _jsx("span", { className: "mk-switch-track", "aria-hidden": "true", children: _jsx(FocusRing, {}) }), _jsx(StateLayer, {}), _jsx(Ripple, {}), _jsx("span", { className: "mk-switch-handle", "aria-hidden": "true", children: icons && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { className: "mk-switch-icon-on" }), _jsx(CloseIcon, { className: "mk-switch-icon-off" })] })) })] }), children != null && children !== false && _jsx("span", { className: "mk-switch-label", children: children })] }));
20
+ }
@@ -0,0 +1,83 @@
1
+ import { type HTMLAttributes, type InputHTMLAttributes, type LabelHTMLAttributes, type ReactNode, type Ref, type TextareaHTMLAttributes } from 'react';
2
+ export type TextFieldVariant = 'filled' | 'outlined';
3
+ export interface TextFieldProps extends HTMLAttributes<HTMLDivElement> {
4
+ /** `filled` (with a background and a bottom indicator) or `outlined` (with a border). Defaults to `filled`. */
5
+ variant?: TextFieldVariant | undefined;
6
+ /** Error state: error colors and `aria-invalid` on the input. */
7
+ error?: boolean | undefined;
8
+ /** Disables the input. `disabled` can also be passed to the `TextFieldInput`. */
9
+ disabled?: boolean | undefined;
10
+ /** Ref to the container. For the input, use `ref` on `TextFieldInput`. */
11
+ ref?: Ref<HTMLDivElement> | undefined;
12
+ }
13
+ /**
14
+ * Material 3 text field, built by composition. The parts go as direct children (the container is
15
+ * a grid that places them by class, in any order):
16
+ *
17
+ * ```tsx
18
+ * <TextField variant="outlined" error={!!err}>
19
+ * <TextFieldLeading><SearchIcon /></TextFieldLeading>
20
+ * <TextFieldLabel>Search</TextFieldLabel>
21
+ * <TextFieldInput value={q} onChange={(e) => setQ(e.target.value)} />
22
+ * <TextFieldTrailing><IconButton label="Clear"><CancelIcon /></IconButton></TextFieldTrailing>
23
+ * <TextFieldSupporting>{err ?? 'At least 3 letters'}</TextFieldSupporting>
24
+ * </TextField>
25
+ * ```
26
+ *
27
+ * The label is associated with the input and the supporting text becomes its description without
28
+ * passing ids; if you pass them (`id` on `TextFieldInput` or `TextFieldSupporting`), they are kept.
29
+ * `className` and `style` go to the container; the default width is 280 px (the kit's), with
30
+ * `max-width: 100%`. In a form it usually looks better full width (`width: 100%`). Inside a CSS
31
+ * grid, the implicit column takes the minimum width of its content (the 280 px) even if the
32
+ * container is narrower: use `grid-template-columns: minmax(0, 1fr)` on the grid so the field
33
+ * shrinks.
34
+ */
35
+ export declare function TextField({ variant, error, disabled, className, children, ref, ...props }: TextFieldProps): import("react").JSX.Element;
36
+ export interface TextFieldLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
37
+ /** The label text. In the outlined field it is repeated, hidden, to open the border's notch. */
38
+ children?: ReactNode;
39
+ }
40
+ /**
41
+ * Label of the field: at rest it takes the place of the text (Body Large) and floats up (Body
42
+ * Small) with focus or a value. It is a `<label>` associated with the input.
43
+ *
44
+ * In the outlined field it also draws the border (a `<fieldset>` with a `<legend>`, hidden from
45
+ * screen readers): the `<legend>` holds an invisible copy of the text and the browser cuts the
46
+ * border to its size. So the content should be text only.
47
+ */
48
+ export declare function TextFieldLabel({ className, htmlFor, children, ...props }: TextFieldLabelProps): import("react").JSX.Element;
49
+ export interface TextFieldInputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'children'> {
50
+ /** Ref to the native `<input>`. */
51
+ ref?: Ref<HTMLInputElement> | undefined;
52
+ }
53
+ /**
54
+ * The field's native `<input>`. It accepts all its props (`type`, `value`, `defaultValue`,
55
+ * `onChange`, `name`, `required`, `maxLength`, `autoComplete`…) and `ref`.
56
+ *
57
+ * Its accessible name comes from `TextFieldLabel`; without one, pass `aria-label` or
58
+ * `aria-labelledby` (a `placeholder` is not a name). Development builds warn when it ends up
59
+ * unnamed (`MK_FIELD_UNNAMED`).
60
+ *
61
+ * Without a `placeholder`, a one-space one is used: the floating label needs it to know, with
62
+ * `:placeholder-shown`, whether the field is empty. Your own `placeholder` shows only once the
63
+ * label has floated (with focus), as in Material 3.
64
+ */
65
+ export declare function TextFieldInput({ id, className, placeholder, ref, ...props }: TextFieldInputProps): import("react").JSX.Element;
66
+ export interface TextFieldTextareaProps extends Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, 'children'> {
67
+ /** Ref to the native `<textarea>`. */
68
+ ref?: Ref<HTMLTextAreaElement> | undefined;
69
+ }
70
+ /**
71
+ * Multi-line variant: a native `<textarea>` instead of the input. The field grows with `rows`
72
+ * (defaults to 2) or with CSS (`field-sizing: content`, `resize`). Same label, placeholder and
73
+ * accessible association rules as `TextFieldInput`.
74
+ */
75
+ export declare function TextFieldTextarea({ id, className, placeholder, ref, ...props }: TextFieldTextareaProps): import("react").JSX.Element;
76
+ export interface TextFieldSupportingProps extends HTMLAttributes<HTMLDivElement> {
77
+ }
78
+ /**
79
+ * Supporting text below the field (Body Small). It becomes the input's accessible description
80
+ * (`aria-describedby`). In error it takes the error color: to show the error message, change its
81
+ * content.
82
+ */
83
+ export declare function TextFieldSupporting({ id, className, ...props }: TextFieldSupportingProps): import("react").JSX.Element;