@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,73 @@
1
+ import { type ChangeEvent, type FieldsetHTMLAttributes, type HTMLAttributes, type ReactNode, type Ref } from 'react';
2
+ /** What `useRadioGroup()` exposes about a group. */
3
+ export interface RadioGroupState {
4
+ /** `name` shared by the radios (the prop's or a generated one). */
5
+ name: string;
6
+ /** Selected value, or `null` if there is none. */
7
+ value: string | null;
8
+ /** Whether the group is disabled. */
9
+ disabled: boolean;
10
+ }
11
+ interface RadioGroupContextValue extends RadioGroupState {
12
+ required: boolean;
13
+ onRadioChange: (event: ChangeEvent<HTMLInputElement>) => void;
14
+ }
15
+ export declare const useRadioGroupContext: () => RadioGroupContextValue | null;
16
+ /**
17
+ * State of the `RadioGroup` that contains the component: `{ name, value, disabled }`, or `null`
18
+ * outside a group. Useful to compose custom radios, for example a list item that highlights when
19
+ * its option is selected:
20
+ *
21
+ * ```tsx
22
+ * function Option({ value, children }: { value: string; children: ReactNode }) {
23
+ * const group = useRadioGroup()
24
+ * return <div data-selected={group?.value === value || undefined}><RadioButton value={value}>{children}</RadioButton></div>
25
+ * }
26
+ * ```
27
+ */
28
+ export declare function useRadioGroup(): RadioGroupState | null;
29
+ export type RadioGroupOrientation = 'vertical' | 'horizontal';
30
+ export interface RadioGroupProps extends Omit<FieldsetHTMLAttributes<HTMLFieldSetElement>, 'role' | 'name' | 'defaultValue'> {
31
+ /** `RadioGroupLabel` (optional, if `aria-label` or `aria-labelledby` is used) and the `RadioButton`s. */
32
+ children?: ReactNode;
33
+ /** `name` of the radios, for the form. If missing, one is generated. */
34
+ name?: string | undefined;
35
+ /** Selected value (controlled). `null`: none. */
36
+ value?: string | null | undefined;
37
+ /** Initially selected value (uncontrolled). */
38
+ defaultValue?: string | undefined;
39
+ /** Called when the user picks an option, with its `value` and the radio's event. */
40
+ onValueChange?: ((value: string, event: ChangeEvent<HTMLInputElement>) => void) | undefined;
41
+ /** Disables all the options. */
42
+ disabled?: boolean | undefined;
43
+ /** Requires picking an option to submit the form. */
44
+ required?: boolean | undefined;
45
+ /** Layout of the options: a column or a row; the arrows work the same. Defaults to `vertical`. */
46
+ orientation?: RadioGroupOrientation | undefined;
47
+ /** Ref to the `<fieldset>`. */
48
+ ref?: Ref<HTMLFieldSetElement> | undefined;
49
+ }
50
+ /**
51
+ * Group of radio buttons: a `<fieldset role="radiogroup">` that hands its `RadioButton`s the
52
+ * `name`, the selected value and the disabled state. It needs an accessible name:
53
+ * `RadioGroupLabel` as the first child, or `aria-label` / `aria-labelledby`.
54
+ *
55
+ * ```tsx
56
+ * <RadioGroup value={delivery} onValueChange={setDelivery}>
57
+ * <RadioGroupLabel>Delivery</RadioGroupLabel>
58
+ * <RadioButton value="pickup">Pick up in store</RadioButton>
59
+ * <RadioButton value="home">Home delivery</RadioButton>
60
+ * </RadioGroup>
61
+ * ```
62
+ *
63
+ * Uncontrolled: `defaultValue="pickup"`. A radio with its own `checked`, `defaultChecked` or `name`
64
+ * does not take that data from the group.
65
+ */
66
+ export declare function RadioGroup({ children, className, name: nameProp, value: valueProp, defaultValue, onValueChange, disabled, required, orientation, ref, ...props }: RadioGroupProps): import("react").JSX.Element;
67
+ export interface RadioGroupLabelProps extends HTMLAttributes<HTMLLegendElement> {
68
+ /** Ref to the `<legend>`. */
69
+ ref?: Ref<HTMLLegendElement> | undefined;
70
+ }
71
+ /** Visible title of the group: a `<legend>`, which gives the `RadioGroup` its accessible name. Goes first. */
72
+ export declare function RadioGroupLabel({ className, ...props }: RadioGroupLabelProps): import("react").JSX.Element;
73
+ export {};
@@ -0,0 +1,82 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Molécula interactiva (excepción al ADR-0003 registrada en el ADR-0012): el grupo guarda el
4
+ // valor elegido y lo reparte por contexto a sus radios junto con `name`, `disabled` y
5
+ // `required`, así que necesita estado y contexto de React, que solo existen en el cliente.
6
+ // Así lo esperan quienes usan React (MUI, React Aria, Radix y Base UI ponen el valor en el
7
+ // grupo; ver docs/research/10-radio-group-en-librerias.md): `name` automático, controlado desde
8
+ // un solo lugar y `useRadioGroup()` para componer radios propios.
9
+ //
10
+ // El grupo es un <fieldset role="radiogroup"> y no un <div role="radiogroup"> porque el
11
+ // fieldset trae resuelto en HTML:
12
+ // - `disabled` deshabilita todos los radios de adentro (:disabled en CSS y en el árbol de
13
+ // accesibilidad), incluidos los que no leen el contexto.
14
+ // - El nombre accesible sale del <legend> (`RadioGroupLabel`).
15
+ // El rol radiogroup (permitido en <fieldset> por ARIA in HTML) es el del patrón APG "Radio
16
+ // Group" y el que pide @material/web (docs/components/radio.md). El teclado sigue siendo el del
17
+ // navegador: los radios son <input type="radio"> nativos con el mismo `name`.
18
+ //
19
+ // El aviso de cambio es `onValueChange(value, event)` y no `onChange`: el `onChange` del
20
+ // fieldset queda como el del elemento (recibe los change que suben de cualquier control).
21
+ import { createContext, use, useId, useMemo, useState, } from 'react';
22
+ const RadioGroupContext = createContext(null);
23
+ // Contexto completo del grupo, para RadioButton (no se exporta desde el índice).
24
+ export const useRadioGroupContext = () => use(RadioGroupContext);
25
+ /**
26
+ * State of the `RadioGroup` that contains the component: `{ name, value, disabled }`, or `null`
27
+ * outside a group. Useful to compose custom radios, for example a list item that highlights when
28
+ * its option is selected:
29
+ *
30
+ * ```tsx
31
+ * function Option({ value, children }: { value: string; children: ReactNode }) {
32
+ * const group = useRadioGroup()
33
+ * return <div data-selected={group?.value === value || undefined}><RadioButton value={value}>{children}</RadioButton></div>
34
+ * }
35
+ * ```
36
+ */
37
+ export function useRadioGroup() {
38
+ const ctx = use(RadioGroupContext);
39
+ const name = ctx?.name;
40
+ const value = ctx?.value;
41
+ const disabled = ctx?.disabled;
42
+ return useMemo(() => (name === undefined ? null : { name, value: value ?? null, disabled: disabled ?? false }), [name, value, disabled]);
43
+ }
44
+ /**
45
+ * Group of radio buttons: a `<fieldset role="radiogroup">` that hands its `RadioButton`s the
46
+ * `name`, the selected value and the disabled state. It needs an accessible name:
47
+ * `RadioGroupLabel` as the first child, or `aria-label` / `aria-labelledby`.
48
+ *
49
+ * ```tsx
50
+ * <RadioGroup value={delivery} onValueChange={setDelivery}>
51
+ * <RadioGroupLabel>Delivery</RadioGroupLabel>
52
+ * <RadioButton value="pickup">Pick up in store</RadioButton>
53
+ * <RadioButton value="home">Home delivery</RadioButton>
54
+ * </RadioGroup>
55
+ * ```
56
+ *
57
+ * Uncontrolled: `defaultValue="pickup"`. A radio with its own `checked`, `defaultChecked` or `name`
58
+ * does not take that data from the group.
59
+ */
60
+ export function RadioGroup({ children, className, name: nameProp, value: valueProp, defaultValue, onValueChange, disabled = false, required = false, orientation = 'vertical', ref, ...props }) {
61
+ const generatedName = useId();
62
+ const name = nameProp ?? generatedName;
63
+ const [uncontrolled, setUncontrolled] = useState(defaultValue ?? null);
64
+ const controlled = valueProp !== undefined;
65
+ const value = controlled ? valueProp : uncontrolled;
66
+ const context = useMemo(() => ({
67
+ name,
68
+ value,
69
+ disabled,
70
+ required,
71
+ onRadioChange(event) {
72
+ if (!controlled)
73
+ setUncontrolled(event.target.value);
74
+ onValueChange?.(event.target.value, event);
75
+ },
76
+ }), [name, value, disabled, required, controlled, onValueChange]);
77
+ return (_jsx(RadioGroupContext, { value: context, children: _jsx("fieldset", { ...props, ref: ref, role: "radiogroup", disabled: disabled, "aria-orientation": orientation, "data-orientation": orientation, className: className ? `mk-radio-group ${className}` : 'mk-radio-group', children: children }) }));
78
+ }
79
+ /** Visible title of the group: a `<legend>`, which gives the `RadioGroup` its accessible name. Goes first. */
80
+ export function RadioGroupLabel({ className, ...props }) {
81
+ return _jsx("legend", { ...props, className: className ? `mk-radio-group-label ${className}` : 'mk-radio-group-label' });
82
+ }
@@ -0,0 +1,61 @@
1
+ import { type HTMLAttributes, type KeyboardEvent, type MouseEvent, type Ref, type UIEvent } from 'react';
2
+ import type { AccessibleNameProps } from '../../internal/accessible-name.ts';
3
+ /** The event that changed the value: a key, a click on a number, or the end of a scroll (`scrollend`, or the last `scroll`). */
4
+ export type ScrollFieldChangeEvent = KeyboardEvent<HTMLDivElement> | MouseEvent<HTMLDivElement> | UIEvent<HTMLDivElement>;
5
+ interface ScrollFieldOwnProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color' | 'defaultValue' | 'onChange' | 'role' | 'children' | 'aria-label' | 'aria-labelledby'> {
6
+ /**
7
+ * The selected number, controlled, or `null` for none: the wheel then rests on `min` without
8
+ * highlighting it and without `aria-valuenow`, and any scroll, key or click picks a number.
9
+ */
10
+ value?: number | null | undefined;
11
+ /** The initial number when uncontrolled. Defaults to `min`. */
12
+ defaultValue?: number | null | undefined;
13
+ /**
14
+ * A number was picked: when a scroll ends on it, on a key, or on a click on a number. Not called
15
+ * while the wheel is still moving, nor when the value changes from outside.
16
+ */
17
+ onValueChange?: ((value: number, event: ScrollFieldChangeEvent) => void) | undefined;
18
+ /** The first number (integer). Defaults to `0`. */
19
+ min?: number | undefined;
20
+ /** The last number (integer). */
21
+ max: number;
22
+ /** How far Page Up and Page Down move. Defaults to `10`. */
23
+ pageStep?: number | undefined;
24
+ /**
25
+ * Arrow and page keys wrap from the last number to the first and back (the wheel jumps there; it
26
+ * does not loop visually). Defaults to `false`.
27
+ */
28
+ wrap?: boolean | undefined;
29
+ /** The text of each number on the wheel. Defaults to two digits (`"07"`). */
30
+ formatValue?: ((value: number) => string) | undefined;
31
+ /**
32
+ * The text a screen reader announces for a number (`aria-valuetext`), for example `"7 PM"`. Without
33
+ * it, the number itself.
34
+ */
35
+ formatValueText?: ((value: number) => string | undefined) | undefined;
36
+ /** Disabled: not focusable, does not scroll, and its numbers are dimmed. */
37
+ disabled?: boolean | undefined;
38
+ /** Ref to the `role="spinbutton"` element (the scrolling list). */
39
+ ref?: Ref<HTMLDivElement> | undefined;
40
+ }
41
+ export type ScrollFieldProps = ScrollFieldOwnProps & AccessibleNameProps;
42
+ /**
43
+ * Material 3 Expressive scroll field (Compose `ScrollField`): a wheel of numbers that scrolls with a
44
+ * finger, mouse wheel or trackpad and always stops on a number, which becomes the value. The
45
+ * `TimeScroll` wheels are built on it.
46
+ *
47
+ * ```tsx
48
+ * const [guests, setGuests] = useState(2)
49
+ *
50
+ * <ScrollField label="Guests" min={1} max={12} value={guests} onValueChange={setGuests} />
51
+ * ```
52
+ *
53
+ * - **Keyboard:** it is a spin button. Arrow Up and Arrow Down add or take 1, Page Up and Page Down
54
+ * `pageStep`, Home and End go to `min` and `max`, and typing digits picks that number.
55
+ * - **Pointer:** scrolling picks the number that ends in the middle; clicking a number scrolls to it.
56
+ * - It needs an accessible name: `label`, `aria-labelledby` or `aria-label`. Screen readers announce
57
+ * the value (or `formatValueText`), not the list.
58
+ * - Native props and `ref` go to the spin button; `className` and `style` to the container.
59
+ */
60
+ export declare function ScrollField({ value: controlledValue, defaultValue, onValueChange, min, max, pageStep, wrap, formatValue, formatValueText, disabled, label, className, style, onKeyDown, onScroll, onScrollEnd, onWheel, onPointerDown, onTouchStart, ref, ...props }: ScrollFieldProps): import("react").JSX.Element;
61
+ export {};
@@ -0,0 +1,352 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // Molécula interactiva (ADR-0003, ADR-0043): la rueda de selección de Material 3 Expressive
4
+ // (`ScrollField` de Compose, la pieza de `TimeScroll`). Necesita estado (el valor sin controlar, el
5
+ // número centrado mientras se desplaza), efectos (posición inicial, seguir al valor) y eventos, así que
6
+ // todo el módulo es cliente.
7
+ //
8
+ // - Dibujo: una lista de números en un contenedor con scroll snapping de CSS (`scroll-snap-type: y
9
+ // mandatory`, cada número `scroll-snap-align: center`): el desplazamiento con el dedo, la rueda del
10
+ // mouse o el trackpad es el del navegador y siempre termina en un número.
11
+ // - Accesibilidad: el contenedor que se desplaza es el `role="spinbutton"` (una sola parada de Tab, con
12
+ // `aria-valuenow`, `aria-valuemin`, `aria-valuemax` y `aria-valuetext`), y la lista va con
13
+ // `aria-hidden`: el lector anuncia un valor, no 60 opciones. Teclado de APG: flechas, Re Pág, Av Pág,
14
+ // Inicio, Fin, y los dígitos eligen el número (como en TimeInput).
15
+ // - Valor ↔ posición: el valor cambia cuando el desplazamiento termina (`scrollend`, en los tres motores
16
+ // de Playwright; si falta, 150 ms sin eventos `scroll`), no en cada cuadro. Un
17
+ // desplazamiento propio (el valor cambió por teclado, clic o desde afuera) se marca con su destino y no
18
+ // vuelve a avisar; la rueda, el puntero o el dedo lo cancelan y el usuario manda. Si la app controla
19
+ // el valor y no acepta el cambio, la rueda vuelve a su valor.
20
+ // - Posición inicial sin salto y sin JavaScript: hasta que el componente monta (y mientras está oculto,
21
+ // por ejemplo en un diálogo cerrado) la lista no se desplaza: se corre con `translate` por
22
+ // `--_index` (el HTML del servidor ya muestra el valor centrado). Al montar, antes de pintar, se pasa
23
+ // al desplazamiento real en la misma posición (`data-ready` y `scrollTop`). Un ResizeObserver repite
24
+ // el paso cuando la rueda vuelve a tener tamaño.
25
+ // - Sin vuelta infinita (de 59 a 00) por ahora: decidido con el autor (plan, ítem 28b). Con `wrap`,
26
+ // solo el teclado da la vuelta, con un salto sin animar.
27
+ import { useLayoutEffect, useMemo, useReducer, useRef, useState, } from 'react';
28
+ import { FocusRing } from '../../atoms/FocusRing/FocusRing.js';
29
+ import { mergeRefs } from '../../internal/merge-refs.js';
30
+ const pad2 = (n) => String(n).padStart(2, '0');
31
+ // Espera sin eventos `scroll` que da por terminado el desplazamiento donde no hay `scrollend`.
32
+ const SETTLE_MS = 150;
33
+ // Quietud que da por abandonado un desplazamiento suave propio que no llegó (ver `settle`).
34
+ const RECONCILE_MS = 200;
35
+ // Dígitos seguidos (búsqueda por número) dentro de este tiempo forman un solo número.
36
+ const TYPE_MS = 1000;
37
+ const prefersReducedMotion = () => window.matchMedia('(prefers-reduced-motion: reduce)').matches;
38
+ /**
39
+ * Material 3 Expressive scroll field (Compose `ScrollField`): a wheel of numbers that scrolls with a
40
+ * finger, mouse wheel or trackpad and always stops on a number, which becomes the value. The
41
+ * `TimeScroll` wheels are built on it.
42
+ *
43
+ * ```tsx
44
+ * const [guests, setGuests] = useState(2)
45
+ *
46
+ * <ScrollField label="Guests" min={1} max={12} value={guests} onValueChange={setGuests} />
47
+ * ```
48
+ *
49
+ * - **Keyboard:** it is a spin button. Arrow Up and Arrow Down add or take 1, Page Up and Page Down
50
+ * `pageStep`, Home and End go to `min` and `max`, and typing digits picks that number.
51
+ * - **Pointer:** scrolling picks the number that ends in the middle; clicking a number scrolls to it.
52
+ * - It needs an accessible name: `label`, `aria-labelledby` or `aria-label`. Screen readers announce
53
+ * the value (or `formatValueText`), not the list.
54
+ * - Native props and `ref` go to the spin button; `className` and `style` to the container.
55
+ */
56
+ export function ScrollField({ value: controlledValue, defaultValue, onValueChange, min = 0, max, pageStep = 10, wrap = false, formatValue = pad2, formatValueText, disabled = false, label, className, style, onKeyDown, onScroll, onScrollEnd, onWheel, onPointerDown, onTouchStart, ref, ...props }) {
57
+ const count = Math.max(1, Math.floor(max) - Math.floor(min) + 1);
58
+ const clamp = (n) => Math.min(max, Math.max(min, Math.round(n)));
59
+ const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue === undefined ? min : defaultValue);
60
+ const controlled = controlledValue !== undefined;
61
+ const rawValue = controlled ? controlledValue : uncontrolledValue;
62
+ const value = rawValue === null || !Number.isFinite(rawValue) ? null : clamp(rawValue);
63
+ // Índice en la lista donde descansa la rueda: el del valor o, sin valor, el primero.
64
+ const valueIndex = value === null ? 0 : value - min;
65
+ // El número que está en el medio ahora (mientras se desplaza cambia antes que el valor) y si el
66
+ // usuario está desplazando la rueda (entonces el número del medio se resalta aunque no haya valor).
67
+ const [centered, setCentered] = useState(valueIndex);
68
+ const [moving, setMoving] = useState(false);
69
+ const scrollerRef = useRef(null);
70
+ const setRef = useMemo(() => mergeRefs(scrollerRef, ref), [ref]);
71
+ // Lo último que vio el render, para los eventos y efectos que corren después.
72
+ const latest = useRef({ value, valueIndex, controlled, onValueChange });
73
+ latest.current = { value, valueIndex, controlled, onValueChange };
74
+ // Destino de un desplazamiento propio en curso (índice), o null.
75
+ const target = useRef(null);
76
+ // El usuario está desplazando (rueda, puntero o dedo, o un desplazamiento que no es propio).
77
+ const userMoving = useRef(false);
78
+ // Desplazamiento suave propio en curso: hacia dónde (scrollTop), o null.
79
+ const animating = useRef(null);
80
+ const reconcileTimer = useRef(undefined);
81
+ const settleTimer = useRef(undefined);
82
+ const typed = useRef({ text: '', at: 0 });
83
+ const checkAfterRender = useRef(false);
84
+ const [, rerender] = useReducer((n) => n + 1, 0);
85
+ const pitch = (el) => (el.querySelector('.mk-scroll-field-item')?.offsetHeight ?? 0);
86
+ const indexAt = (el) => {
87
+ const p = pitch(el);
88
+ return p ? Math.min(count - 1, Math.max(0, Math.round(el.scrollTop / p))) : 0;
89
+ };
90
+ // Lleva la rueda al índice: suave salvo con movimiento reducido o un salto largo (una vuelta del
91
+ // teclado, Inicio o Fin lejos), que se ve mejor sin recorrer toda la lista.
92
+ const scrollToIndex = (index, animate) => {
93
+ const el = scrollerRef.current;
94
+ if (!el || !el.hasAttribute('data-ready'))
95
+ return;
96
+ const p = pitch(el);
97
+ const top = index * p;
98
+ if (Math.abs(el.scrollTop - top) < 0.5) {
99
+ // Ya está ahí, pero puede quedar uno suave en curso hacia otro número que todavía no se movió (una
100
+ // flecha y enseguida un reset). Cortarlo no sirve: Chrome lo deja a mitad de camino, fuera de un punto
101
+ // de ajuste y sin `scrollend`, y WebKit lo sigue igual (comprobado el 2026-11-30). Se lo deja terminar
102
+ // con este destino: al llegar, `settle` ve que no es el valor y vuelve.
103
+ if (animating.current) {
104
+ target.current = index;
105
+ scheduleReconcile();
106
+ return;
107
+ }
108
+ target.current = null;
109
+ setCentered(index);
110
+ return;
111
+ }
112
+ target.current = index;
113
+ const far = Math.abs(index - indexAt(el)) > Math.max(3, count / 2);
114
+ const smooth = animate && !far && !prefersReducedMotion();
115
+ animating.current = smooth ? { top } : null;
116
+ el.scrollTo({ top, behavior: smooth ? 'smooth' : 'instant' });
117
+ };
118
+ // Al montar (y cada vez que vuelve a tener tamaño): del corrimiento con translate al desplazamiento
119
+ // real, en la misma posición y antes de pintar.
120
+ useLayoutEffect(() => {
121
+ const el = scrollerRef.current;
122
+ if (!el)
123
+ return;
124
+ const activate = () => {
125
+ const p = pitch(el);
126
+ if (!p) {
127
+ // Oculta (display: none): vuelve al corrimiento, que no depende del tamaño.
128
+ el.removeAttribute('data-ready');
129
+ return;
130
+ }
131
+ // Ya activa: un cambio de tamaño lo reajusta el scroll snapping del navegador. (La primera
132
+ // observación del ResizeObserver llega un cuadro después y puede traer un valor viejo.)
133
+ if (el.hasAttribute('data-ready'))
134
+ return;
135
+ el.setAttribute('data-ready', '');
136
+ if (indexAt(el) !== latest.current.valueIndex)
137
+ scrollToIndex(latest.current.valueIndex, false);
138
+ };
139
+ activate();
140
+ const observer = new ResizeObserver(activate);
141
+ observer.observe(el);
142
+ return () => observer.disconnect();
143
+ }, []);
144
+ // El valor cambió (teclado, clic, desde afuera): la rueda va hacia él, salvo que el usuario la esté
145
+ // moviendo (al terminar manda lo que eligió).
146
+ useLayoutEffect(() => {
147
+ const el = scrollerRef.current;
148
+ if (!el || userMoving.current)
149
+ return;
150
+ if (!el.hasAttribute('data-ready')) {
151
+ setCentered(valueIndex);
152
+ return;
153
+ }
154
+ // También si va hacia otro número (dos flechas y una tercera para atrás, rápido).
155
+ if (indexAt(el) !== valueIndex || (target.current !== null && target.current !== valueIndex))
156
+ scrollToIndex(valueIndex, true);
157
+ else
158
+ setCentered(valueIndex);
159
+ }, [valueIndex]);
160
+ useLayoutEffect(() => () => {
161
+ clearTimeout(settleTimer.current);
162
+ clearTimeout(reconcileTimer.current);
163
+ }, []);
164
+ // La rueda quedó quieta fuera del valor después de un desplazamiento propio que no terminó: volver.
165
+ const scheduleReconcile = () => {
166
+ clearTimeout(reconcileTimer.current);
167
+ reconcileTimer.current = setTimeout(() => {
168
+ reconcileTimer.current = undefined;
169
+ const el = scrollerRef.current;
170
+ if (!el || userMoving.current)
171
+ return;
172
+ animating.current = null;
173
+ target.current = null;
174
+ if (Math.abs(el.scrollTop - latest.current.valueIndex * pitch(el)) > 0.5)
175
+ scrollToIndex(latest.current.valueIndex, true);
176
+ else
177
+ setCentered(latest.current.valueIndex);
178
+ }, RECONCILE_MS);
179
+ };
180
+ const commit = (n, event) => {
181
+ const { value: current, controlled: isControlled, onValueChange: notify } = latest.current;
182
+ if (current === n)
183
+ return;
184
+ if (!isControlled)
185
+ setUncontrolledValue(n);
186
+ notify?.(n, event);
187
+ };
188
+ // El desplazamiento terminó: el número del medio pasa a ser el valor (si no era un desplazamiento propio).
189
+ const settle = (event) => {
190
+ clearTimeout(settleTimer.current);
191
+ const el = scrollerRef.current;
192
+ if (!el || !el.hasAttribute('data-ready'))
193
+ return;
194
+ const index = indexAt(el);
195
+ const own = target.current;
196
+ const wasUser = userMoving.current;
197
+ // Uno suave propio que no llegó a su destino: WebKit a veces manda un `scrollend` antes de que arranque
198
+ // (y después sigue), y Firefox lo abandona si la lista se achica en el mismo cuadro (cambio de reloj de
199
+ // 24 a 12 horas; comprobado el 2026-11-30). Se espera: si llegan más `scroll`, su `scrollend` decide; si
200
+ // la rueda queda quieta, `reconcile` la lleva al valor.
201
+ const anim = animating.current;
202
+ if (anim && Math.abs(el.scrollTop - anim.top) > 0.5) {
203
+ scheduleReconcile();
204
+ return;
205
+ }
206
+ animating.current = null;
207
+ target.current = null;
208
+ userMoving.current = false;
209
+ setCentered(index);
210
+ setMoving(false);
211
+ if (own !== null && !wasUser) {
212
+ // Uno propio que no llegó (otro lo interrumpió): seguir hacia el valor.
213
+ if (index !== latest.current.valueIndex)
214
+ scrollToIndex(latest.current.valueIndex, true);
215
+ return;
216
+ }
217
+ if (disabled)
218
+ return;
219
+ commit(min + index, event);
220
+ // Si la app controla el valor y no lo aceptó, la rueda vuelve a su valor: se mira después del render
221
+ // que junta este cambio con el de la app (no en un requestAnimationFrame, que puede llegar antes de
222
+ // ese render, con el valor viejo, y hacía oscilar la rueda entre los dos números).
223
+ checkAfterRender.current = true;
224
+ rerender();
225
+ };
226
+ useLayoutEffect(() => {
227
+ if (!checkAfterRender.current)
228
+ return;
229
+ checkAfterRender.current = false;
230
+ const el = scrollerRef.current;
231
+ if (el && !userMoving.current && target.current === null && indexAt(el) !== valueIndex)
232
+ scrollToIndex(valueIndex, true);
233
+ });
234
+ const handleScroll = (e) => {
235
+ onScroll?.(e);
236
+ const el = e.currentTarget;
237
+ if (!el.hasAttribute('data-ready'))
238
+ return;
239
+ // Todavía se mueve: la vuelta al valor espera a que quede quieta.
240
+ if (reconcileTimer.current !== undefined)
241
+ scheduleReconcile();
242
+ if (target.current === null) {
243
+ userMoving.current = true;
244
+ setMoving(true);
245
+ }
246
+ setCentered(indexAt(el));
247
+ // Respaldo donde no hay `scrollend`: el último `scroll` cierra. Donde lo hay, no se usa: con el dedo
248
+ // quieto a mitad de un arrastre el tiempo se cumpliría antes de soltar.
249
+ if (!('onscrollend' in window)) {
250
+ clearTimeout(settleTimer.current);
251
+ settleTimer.current = setTimeout(() => settle(e), SETTLE_MS);
252
+ }
253
+ };
254
+ const handleScrollEnd = (e) => {
255
+ onScrollEnd?.(e);
256
+ settle(e);
257
+ };
258
+ // Cualquier entrada del usuario sobre la rueda cancela un desplazamiento propio: manda el usuario.
259
+ const takeOver = () => {
260
+ target.current = null;
261
+ animating.current = null;
262
+ clearTimeout(reconcileTimer.current);
263
+ reconcileTimer.current = undefined;
264
+ };
265
+ const step = (delta) => {
266
+ const from = value ?? (delta > 0 ? min - 1 : max + 1);
267
+ let next = from + delta;
268
+ if (wrap)
269
+ next = min + ((((next - min) % count) + count) % count);
270
+ return clamp(next);
271
+ };
272
+ const handleKeyDown = (e) => {
273
+ onKeyDown?.(e);
274
+ if (e.defaultPrevented || disabled || e.altKey || e.ctrlKey || e.metaKey)
275
+ return;
276
+ let next = null;
277
+ switch (e.key) {
278
+ case 'ArrowUp':
279
+ next = step(1);
280
+ break;
281
+ case 'ArrowDown':
282
+ next = step(-1);
283
+ break;
284
+ case 'PageUp':
285
+ next = step(pageStep);
286
+ break;
287
+ case 'PageDown':
288
+ next = step(-pageStep);
289
+ break;
290
+ case 'Home':
291
+ next = min;
292
+ break;
293
+ case 'End':
294
+ next = max;
295
+ break;
296
+ case ' ':
297
+ // Espacio desplazaría la lista una página: en un spinbutton no hace nada.
298
+ e.preventDefault();
299
+ return;
300
+ default:
301
+ if (/^\d$/.test(e.key)) {
302
+ // Dígitos: "4" y luego "5" eligen 45; un número fuera de rango empieza de nuevo con la tecla
303
+ // nueva (como el segmento de React Aria y TimeInput).
304
+ const now = e.timeStamp;
305
+ const text = now - typed.current.at < TYPE_MS ? typed.current.text + e.key : e.key;
306
+ let n = Number(text);
307
+ let kept = text;
308
+ if (n < min || n > max) {
309
+ n = Number(e.key);
310
+ kept = e.key;
311
+ }
312
+ typed.current = { text: kept, at: now };
313
+ if (n >= min && n <= max)
314
+ next = n;
315
+ else {
316
+ e.preventDefault();
317
+ return;
318
+ }
319
+ }
320
+ }
321
+ if (next === null)
322
+ return;
323
+ e.preventDefault();
324
+ // Sin takeOver: un desplazamiento propio en curso sigue marcado y el efecto del valor lo redirige.
325
+ userMoving.current = false;
326
+ commit(next, e);
327
+ };
328
+ const handleItemClick = (n) => (e) => {
329
+ if (disabled)
330
+ return;
331
+ userMoving.current = false;
332
+ commit(n, e);
333
+ };
334
+ // Resaltado: el número del medio, si hay valor o el usuario está moviendo la rueda.
335
+ const highlighted = value !== null || moving ? centered : -1;
336
+ const valueText = value === null ? undefined : formatValueText?.(value);
337
+ const items = [];
338
+ for (let i = 0; i < count; i++) {
339
+ const n = min + i;
340
+ items.push(_jsx("div", { className: "mk-scroll-field-item", "data-selected": i === highlighted || undefined, onClick: handleItemClick(n), children: formatValue(n) }, n));
341
+ }
342
+ return (_jsxs("div", { className: className ? `mk-scroll-field ${className}` : 'mk-scroll-field', style: style, "data-disabled": disabled || undefined, "data-empty": value === null || undefined, children: [_jsx("div", { "aria-label": label, ...props, ref: setRef, className: "mk-scroll-field-scroller", role: "spinbutton", tabIndex: disabled ? undefined : 0, "aria-valuemin": min, "aria-valuemax": max, "aria-valuenow": value ?? undefined, "aria-valuetext": valueText, "aria-disabled": disabled || undefined, style: { '--_index': valueIndex }, onKeyDown: handleKeyDown, onScroll: handleScroll, onScrollEnd: handleScrollEnd, onWheel: (e) => {
343
+ onWheel?.(e);
344
+ takeOver();
345
+ }, onPointerDown: (e) => {
346
+ onPointerDown?.(e);
347
+ takeOver();
348
+ }, onTouchStart: (e) => {
349
+ onTouchStart?.(e);
350
+ takeOver();
351
+ }, children: _jsx("div", { className: "mk-scroll-field-items", "aria-hidden": "true", children: items }) }), _jsx(FocusRing, {})] }));
352
+ }
@@ -0,0 +1,60 @@
1
+ import { type ChangeEvent, type HTMLAttributes, type InputHTMLAttributes, type ReactNode, 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
+ export type RangeSliderValue = [start: number, end: number];
5
+ export interface RangeSliderProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange' | 'children'> {
6
+ /** Values (controlled): start and end. */
7
+ value?: RangeSliderValue | undefined;
8
+ /** Initial values (uncontrolled). Without them, one third and two thirds of the range. */
9
+ defaultValue?: RangeSliderValue | undefined;
10
+ /** Called with both values and the event of the input that changed. */
11
+ onValueChange?: ((value: RangeSliderValue, 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
+ /** Disables both handles. */
19
+ disabled?: boolean | undefined;
20
+ /** Material 3 Expressive size: track of 16, 24, 40, 56 or 96. Defaults to `xs`. */
21
+ size?: SliderSize | undefined;
22
+ /** `vertical`: the minimum at the bottom. Defaults to `horizontal`. */
23
+ orientation?: SliderOrientation | undefined;
24
+ /** A dot at every step. Meant for few steps. */
25
+ ticks?: boolean | undefined;
26
+ /** Value indicator while pressing, dragging and with keyboard focus. Defaults to `true`. */
27
+ valueIndicator?: boolean | undefined;
28
+ /** Text of the values in the indicator and in `aria-valuetext`: a function or an `Intl.NumberFormat`. */
29
+ format?: SliderFormat | undefined;
30
+ /** `RangeSliderStart` and `RangeSliderEnd`. */
31
+ children?: ReactNode;
32
+ /** Ref to the container. */
33
+ ref?: Ref<HTMLDivElement> | undefined;
34
+ }
35
+ /**
36
+ * Material 3 Expressive range slider: two handles, each a native `<input type="range">`
37
+ * (`RangeSliderStart` and `RangeSliderEnd`, with their own accessible name and `name`). The
38
+ * handles do not cross.
39
+ *
40
+ * The container props (`className`, `style`, `id`, `aria-*`…) go to the `<div>`; with
41
+ * `aria-label` or `aria-labelledby` the container becomes a group (`role="group"`).
42
+ *
43
+ * ```tsx
44
+ * <RangeSlider defaultValue={[20, 80]} aria-label="Price">
45
+ * <RangeSliderStart label="Minimum price" name="from" />
46
+ * <RangeSliderEnd label="Maximum price" name="to" />
47
+ * </RangeSlider>
48
+ * ```
49
+ */
50
+ export declare function RangeSlider({ value, defaultValue, onValueChange, min, max, step, disabled, size, orientation, ticks, valueIndicator, format, className, style, children, ...rootProps }: RangeSliderProps): import("react").JSX.Element;
51
+ type ThumbInputProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'value' | 'defaultValue' | 'min' | 'max' | 'step' | 'size' | 'children' | 'aria-label' | 'aria-labelledby'>;
52
+ export type RangeSliderThumbProps = ThumbInputProps & AccessibleNameProps & {
53
+ /** Ref to the native `<input type="range">`. */
54
+ ref?: Ref<HTMLInputElement> | undefined;
55
+ };
56
+ /** Handle for the start of the range (the lower value), inside a `RangeSlider`. Needs an accessible name. */
57
+ export declare function RangeSliderStart(props: RangeSliderThumbProps): import("react").JSX.Element;
58
+ /** Handle for the end of the range (the higher value), inside a `RangeSlider`. Needs an accessible name. */
59
+ export declare function RangeSliderEnd(props: RangeSliderThumbProps): import("react").JSX.Element;
60
+ export {};