@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,35 @@
1
+ import type { HTMLAttributes, Ref } from 'react';
2
+ import { type DividerProps } from '../../atoms/Divider/Divider.tsx';
3
+ export interface MenuItemLeadingProps extends HTMLAttributes<HTMLSpanElement> {
4
+ ref?: Ref<HTMLSpanElement> | undefined;
5
+ }
6
+ /**
7
+ * Leading icon of a `MenuItem` (20 px, `on-surface-variant`). Empty, it leaves an icon's indent to
8
+ * align the text with the items that have one. It goes first even if written after the text. When
9
+ * selected, the kit uses the filled version of the icon (`<StarIcon filled />`).
10
+ *
11
+ * ```tsx
12
+ * <MenuItem><MenuItemLeading><EditIcon /></MenuItemLeading>Edit</MenuItem>
13
+ * ```
14
+ */
15
+ export declare function MenuItemLeading({ className, ...props }: MenuItemLeadingProps): import("react").JSX.Element;
16
+ export interface MenuItemTrailingProps extends HTMLAttributes<HTMLSpanElement> {
17
+ ref?: Ref<HTMLSpanElement> | undefined;
18
+ }
19
+ /**
20
+ * Trailing content of a `MenuItem`, against the end edge: a keyboard shortcut, an icon or a badge,
21
+ * in `on-surface-variant`. It is part of the item's accessible name; if it is a shortcut, also add
22
+ * `aria-keyshortcuts` to the `MenuItem`.
23
+ *
24
+ * ```tsx
25
+ * <MenuItem aria-keyshortcuts="Control+C">Copy<MenuItemTrailing>Ctrl+C</MenuItemTrailing></MenuItem>
26
+ * ```
27
+ */
28
+ export declare function MenuItemTrailing({ className, ...props }: MenuItemTrailingProps): import("react").JSX.Element;
29
+ export type MenuDividerProps = Omit<DividerProps, 'orientation' | 'decorative'>;
30
+ /**
31
+ * Divider between groups of items (`role="separator"`): the `Divider` atom with a 6 px margin above
32
+ * and below. It is not focusable. Separate a group of `type="radio"` items from the rest with
33
+ * dividers, as APG asks.
34
+ */
35
+ export declare function MenuDivider({ className, ...props }: MenuDividerProps): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Divider } from '../../atoms/Divider/Divider.js';
3
+ const cx = (base, extra) => (extra ? `${base} ${extra}` : base);
4
+ /**
5
+ * Leading icon of a `MenuItem` (20 px, `on-surface-variant`). Empty, it leaves an icon's indent to
6
+ * align the text with the items that have one. It goes first even if written after the text. When
7
+ * selected, the kit uses the filled version of the icon (`<StarIcon filled />`).
8
+ *
9
+ * ```tsx
10
+ * <MenuItem><MenuItemLeading><EditIcon /></MenuItemLeading>Edit</MenuItem>
11
+ * ```
12
+ */
13
+ export function MenuItemLeading({ className, ...props }) {
14
+ return _jsx("span", { ...props, className: cx('mk-menu-item-leading', className) });
15
+ }
16
+ /**
17
+ * Trailing content of a `MenuItem`, against the end edge: a keyboard shortcut, an icon or a badge,
18
+ * in `on-surface-variant`. It is part of the item's accessible name; if it is a shortcut, also add
19
+ * `aria-keyshortcuts` to the `MenuItem`.
20
+ *
21
+ * ```tsx
22
+ * <MenuItem aria-keyshortcuts="Control+C">Copy<MenuItemTrailing>Ctrl+C</MenuItemTrailing></MenuItem>
23
+ * ```
24
+ */
25
+ export function MenuItemTrailing({ className, ...props }) {
26
+ return _jsx("span", { ...props, className: cx('mk-menu-item-trailing', className) });
27
+ }
28
+ /**
29
+ * Divider between groups of items (`role="separator"`): the `Divider` atom with a 6 px margin above
30
+ * and below. It is not focusable. Separate a group of `type="radio"` items from the rest with
31
+ * dividers, as APG asks.
32
+ */
33
+ export function MenuDivider({ className, ...props }) {
34
+ // El rol explícito repite el implícito del <hr>, como antes de usar el átomo.
35
+ return _jsx(Divider, { role: "separator", ...props, className: cx('mk-menu-divider', className) });
36
+ }
@@ -0,0 +1,96 @@
1
+ import type { HTMLAttributes, Ref } from 'react';
2
+ import type { ButtonElementProps, LinkElementProps, RenderElementProps } from '../../atoms/Interactive/Interactive.tsx';
3
+ import { type NavigationItemOwnProps } from '../../internal/navigation-item.tsx';
4
+ export type NavigationBarLayout = 'vertical' | 'horizontal';
5
+ export interface NavigationBarProps extends HTMLAttributes<HTMLElement> {
6
+ /**
7
+ * Item layout: `vertical` (icon above the label, for phones in portrait) or `horizontal` (icon
8
+ * next to the label, for medium screens). Defaults to `vertical`.
9
+ */
10
+ layout?: NavigationBarLayout | undefined;
11
+ /** Ref to the `<nav>`. */
12
+ ref?: Ref<HTMLElement> | undefined;
13
+ }
14
+ /**
15
+ * Material 3 Expressive navigation bar: a 64 px tall `<nav>` in `surface-container`, with the items
16
+ * spread across its width. It adds the bottom margin of the system's safe area
17
+ * (`env(safe-area-inset-bottom)`, with `viewport-fit=cover`).
18
+ *
19
+ * If the page has more than one `<nav>`, give it a name with `aria-label`.
20
+ *
21
+ * **Destinations: 3 to 5, in any window** (Material guidance). The destinations share the width
22
+ * equally (like Compose's `weight(1f)`): with few, each one is wider; with more than fit at their
23
+ * size, they shrink (the indicator and the label give way, the label is truncated with an ellipsis
24
+ * and the accessible name stays complete) down to 24 px wide, the minimum target size of WCAG 2.5.8,
25
+ * without overflowing the page. With more than 5, it warns in development
26
+ * (`MK_NAVIGATION_TOO_MANY_DESTINATIONS`); the fix is to have fewer, or move the rest to a
27
+ * `ModalNavigationRail` or a `Menu`. The warning counts the `NavigationBarItem` children (also in
28
+ * arrays, fragments or wrapped one by one, as in a `Tooltip`); it does not see the ones another
29
+ * component renders.
30
+ *
31
+ * ```tsx
32
+ * <NavigationBar aria-label="Main">
33
+ * <NavigationBarItem href="/" current>
34
+ * <NavigationBarItemIcon><HomeIcon /></NavigationBarItemIcon>
35
+ * <NavigationBarItemLabel>Home</NavigationBarItemLabel>
36
+ * </NavigationBarItem>
37
+ * <NavigationBarItem href="/favorites">
38
+ * <NavigationBarItemIcon><StarIcon /></NavigationBarItemIcon>
39
+ * <NavigationBarItemLabel>Favorites</NavigationBarItemLabel>
40
+ * <Badge label="3 new">3</Badge>
41
+ * </NavigationBarItem>
42
+ * </NavigationBar>
43
+ * ```
44
+ */
45
+ export declare function NavigationBar({ layout, className, ...props }: NavigationBarProps): import("react").JSX.Element;
46
+ /** `current` and the children: icon (`NavigationBarItemIcon`), label (`NavigationBarItemLabel`) and `Badge`. */
47
+ type NavigationBarItemOwnProps = NavigationItemOwnProps;
48
+ /** With `href`, the item is an `<a>`. */
49
+ export type NavigationBarItemLinkProps = NavigationBarItemOwnProps & LinkElementProps;
50
+ /** Without `href`, the item is a `<button type="button">`. */
51
+ export type NavigationBarItemButtonProps = NavigationBarItemOwnProps & ButtonElementProps;
52
+ /**
53
+ * With `render`, the element passed (the router's `Link`), cloned with the classes, `aria-current`
54
+ * and the parts as children.
55
+ */
56
+ export type NavigationBarItemRenderProps = NavigationBarItemOwnProps & RenderElementProps;
57
+ export type NavigationBarItemProps = NavigationBarItemLinkProps | NavigationBarItemButtonProps | NavigationBarItemRenderProps;
58
+ /**
59
+ * A destination of the bar. An `<a>` if it gets `href`, a `<button type="button">` if not, or the
60
+ * `render` element (the router's `Link`). The current one has `aria-current="page"`.
61
+ *
62
+ * The accessible name comes from the content: the label and the badge's `label`, in that order.
63
+ * The icon is decorative. Without a visible label, `aria-label` is required.
64
+ *
65
+ * Keyboard: the native element's (Tab moves through; Enter follows a link; Enter and Space activate
66
+ * a button).
67
+ *
68
+ * ```tsx
69
+ * // Next.js (App Router): the bar can stay a Server Component.
70
+ * <NavigationBarItem current={pathname === '/'} render={<Link href="/" />}>
71
+ * <NavigationBarItemIcon><HomeIcon /></NavigationBarItemIcon>
72
+ * <NavigationBarItemLabel>Home</NavigationBarItemLabel>
73
+ * </NavigationBarItem>
74
+ * ```
75
+ */
76
+ export declare function NavigationBarItem(props: NavigationBarItemProps): import("react").JSX.Element;
77
+ export interface NavigationBarItemIconProps extends HTMLAttributes<HTMLSpanElement> {
78
+ ref?: Ref<HTMLSpanElement> | undefined;
79
+ }
80
+ /**
81
+ * The item's icon (24 px), inside the indicator. `on-surface-variant` when not current and
82
+ * `on-secondary-container` when current. For the filled icon of the current one, pass it the same
83
+ * boolean as `current`: `<StarIcon filled={current} />`. It is decorative (hidden from screen
84
+ * readers).
85
+ */
86
+ export declare function NavigationBarItemIcon({ className, ...props }: NavigationBarItemIconProps): import("react").JSX.Element;
87
+ export interface NavigationBarItemLabelProps extends HTMLAttributes<HTMLSpanElement> {
88
+ ref?: Ref<HTMLSpanElement> | undefined;
89
+ }
90
+ /**
91
+ * The item's label (Label Medium), on a single line; if it does not fit, it is truncated with an
92
+ * ellipsis. `on-surface-variant` when not current; when current, `secondary` below the indicator
93
+ * (vertical) or `on-secondary-container` inside it (horizontal).
94
+ */
95
+ export declare function NavigationBarItemLabel({ className, ...props }: NavigationBarItemLabelProps): import("react").JSX.Element;
96
+ export {};
@@ -0,0 +1,77 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cx } from '../../internal/interactive.js';
3
+ import { navigationItem } from '../../internal/navigation-item.js';
4
+ import { warnTooManyDestinations } from '../../internal/navigation-count.js';
5
+ /**
6
+ * Material 3 Expressive navigation bar: a 64 px tall `<nav>` in `surface-container`, with the items
7
+ * spread across its width. It adds the bottom margin of the system's safe area
8
+ * (`env(safe-area-inset-bottom)`, with `viewport-fit=cover`).
9
+ *
10
+ * If the page has more than one `<nav>`, give it a name with `aria-label`.
11
+ *
12
+ * **Destinations: 3 to 5, in any window** (Material guidance). The destinations share the width
13
+ * equally (like Compose's `weight(1f)`): with few, each one is wider; with more than fit at their
14
+ * size, they shrink (the indicator and the label give way, the label is truncated with an ellipsis
15
+ * and the accessible name stays complete) down to 24 px wide, the minimum target size of WCAG 2.5.8,
16
+ * without overflowing the page. With more than 5, it warns in development
17
+ * (`MK_NAVIGATION_TOO_MANY_DESTINATIONS`); the fix is to have fewer, or move the rest to a
18
+ * `ModalNavigationRail` or a `Menu`. The warning counts the `NavigationBarItem` children (also in
19
+ * arrays, fragments or wrapped one by one, as in a `Tooltip`); it does not see the ones another
20
+ * component renders.
21
+ *
22
+ * ```tsx
23
+ * <NavigationBar aria-label="Main">
24
+ * <NavigationBarItem href="/" current>
25
+ * <NavigationBarItemIcon><HomeIcon /></NavigationBarItemIcon>
26
+ * <NavigationBarItemLabel>Home</NavigationBarItemLabel>
27
+ * </NavigationBarItem>
28
+ * <NavigationBarItem href="/favorites">
29
+ * <NavigationBarItemIcon><StarIcon /></NavigationBarItemIcon>
30
+ * <NavigationBarItemLabel>Favorites</NavigationBarItemLabel>
31
+ * <Badge label="3 new">3</Badge>
32
+ * </NavigationBarItem>
33
+ * </NavigationBar>
34
+ * ```
35
+ */
36
+ export function NavigationBar({ layout = 'vertical', className, ...props }) {
37
+ warnTooManyDestinations('NavigationBar', props.children, NavigationBarItem);
38
+ return _jsx("nav", { ...props, className: cx('mk-navigation-bar', className), "data-layout": layout });
39
+ }
40
+ /**
41
+ * A destination of the bar. An `<a>` if it gets `href`, a `<button type="button">` if not, or the
42
+ * `render` element (the router's `Link`). The current one has `aria-current="page"`.
43
+ *
44
+ * The accessible name comes from the content: the label and the badge's `label`, in that order.
45
+ * The icon is decorative. Without a visible label, `aria-label` is required.
46
+ *
47
+ * Keyboard: the native element's (Tab moves through; Enter follows a link; Enter and Space activate
48
+ * a button).
49
+ *
50
+ * ```tsx
51
+ * // Next.js (App Router): the bar can stay a Server Component.
52
+ * <NavigationBarItem current={pathname === '/'} render={<Link href="/" />}>
53
+ * <NavigationBarItemIcon><HomeIcon /></NavigationBarItemIcon>
54
+ * <NavigationBarItemLabel>Home</NavigationBarItemLabel>
55
+ * </NavigationBarItem>
56
+ * ```
57
+ */
58
+ export function NavigationBarItem(props) {
59
+ return navigationItem('NavigationBarItem', 'mk-navigation-bar-item', props);
60
+ }
61
+ /**
62
+ * The item's icon (24 px), inside the indicator. `on-surface-variant` when not current and
63
+ * `on-secondary-container` when current. For the filled icon of the current one, pass it the same
64
+ * boolean as `current`: `<StarIcon filled={current} />`. It is decorative (hidden from screen
65
+ * readers).
66
+ */
67
+ export function NavigationBarItemIcon({ className, ...props }) {
68
+ return _jsx("span", { "aria-hidden": "true", ...props, className: cx('mk-navigation-bar-item-icon', className) });
69
+ }
70
+ /**
71
+ * The item's label (Label Medium), on a single line; if it does not fit, it is truncated with an
72
+ * ellipsis. `on-surface-variant` when not current; when current, `secondary` below the indicator
73
+ * (vertical) or `on-secondary-container` inside it (horizontal).
74
+ */
75
+ export function NavigationBarItemLabel({ className, ...props }) {
76
+ return _jsx("span", { ...props, className: cx('mk-navigation-bar-item-label', className) });
77
+ }
@@ -0,0 +1,105 @@
1
+ import { type ButtonHTMLAttributes, type DialogHTMLAttributes, type Ref } from 'react';
2
+ import type { NavigationRailAlign } from './NavigationRail.tsx';
3
+ /**
4
+ * Why a modal navigation rail asks to close (`onClose(reason)`):
5
+ * - `select`: a destination was chosen (with `closeOnSelect`);
6
+ * - `close-button`: `ModalNavigationRailClose`;
7
+ * - `drag`: a drag towards the edge was released past half its width, or fast;
8
+ * - `escape`, `scrim`, `native`: Escape or the platform's close request, a click on the scrim, or
9
+ * the `<dialog>` closing itself (`close()`), as in `Dialog`.
10
+ */
11
+ export type ModalNavigationRailCloseReason = 'select' | 'close-button' | 'drag' | 'escape' | 'scrim' | 'native';
12
+ export interface ModalNavigationRailProps extends Omit<DialogHTMLAttributes<HTMLDialogElement>, 'open' | 'onClose'> {
13
+ /**
14
+ * Open or closed, controlled by the app (usually with its menu button: the rail has no trigger of
15
+ * its own). Defaults to closed.
16
+ */
17
+ open?: boolean | undefined;
18
+ /**
19
+ * A **close request**, with the reason (`ModalNavigationRailCloseReason`): Escape, the scrim,
20
+ * `ModalNavigationRailClose`, a drag towards the edge (past half its width, or fast), a native
21
+ * close or, with `closeOnSelect`, choosing a destination. The rail does not close by itself: the
22
+ * app decides by passing `open={false}`, or refuses by keeping `open` (the rail goes back and stays
23
+ * modal).
24
+ */
25
+ onClose?: ((reason: ModalNavigationRailCloseReason) => void) | undefined;
26
+ /**
27
+ * Whether choosing a destination (`NavigationRailItem`) asks to close (`'select'`). Defaults to
28
+ * `true`: on navigating, the rail reveals the new page. A click that opens another tab (with Ctrl,
29
+ * Cmd, Shift or Alt, or with the middle button) does not count, nor does a destination with
30
+ * `aria-disabled`. With `false`, the app closes whenever it wants (as in Compose, where the
31
+ * destination's `onClick` requests the close).
32
+ */
33
+ closeOnSelect?: boolean | undefined;
34
+ /** Whether a click on the scrim asks to close. Defaults to `true`. */
35
+ closeOnScrimClick?: boolean | undefined;
36
+ /**
37
+ * Accessible name of the dialog (its `aria-label`). Defaults to "Navigation rail". With
38
+ * `aria-labelledby`, that one wins. An empty label leaves the rail unnamed and warns in
39
+ * development (`MK_SURFACE_UNNAMED`).
40
+ */
41
+ label?: string | undefined;
42
+ 'aria-label'?: never;
43
+ /** Alignment of the destinations, as in `NavigationRail`. Defaults to `top`. */
44
+ align?: NavigationRailAlign | undefined;
45
+ /** Ref to the native `<dialog>`. */
46
+ ref?: Ref<HTMLDialogElement> | undefined;
47
+ }
48
+ /**
49
+ * Modal variant of the NavigationRail: the expanded rail over the content, from the start edge (in
50
+ * RTL, the right one), full height, with a scrim and trapped focus. It is Compose's
51
+ * `ModalWideNavigationRail` coming in from off screen, the Expressive replacement for the navigation
52
+ * drawer: for small screens with more destinations than fit in a bar, or to expand a collapsed rail
53
+ * without shifting the content.
54
+ *
55
+ * ```tsx
56
+ * const [open, setOpen] = useState(false)
57
+ *
58
+ * <IconButton label="Open navigation" aria-haspopup="dialog" onClick={() => setOpen(true)}>
59
+ * <MenuIcon />
60
+ * </IconButton>
61
+ * <ModalNavigationRail open={open} onClose={() => setOpen(false)}>
62
+ * <NavigationRailHeader>
63
+ * <ModalNavigationRailClose />
64
+ * </NavigationRailHeader>
65
+ * <NavigationRailItem href="/" current>
66
+ * <NavigationRailItemIcon><HomeIcon filled /></NavigationRailItemIcon>
67
+ * <NavigationRailItemLabel>Home</NavigationRailItemLabel>
68
+ * </NavigationRailItem>
69
+ * …
70
+ * </ModalNavigationRail>
71
+ * ```
72
+ *
73
+ * - **Content:** the parts of the expanded `NavigationRail` (`NavigationRailHeader`,
74
+ * `NavigationRailItem`, `NavigationRailItemIcon`, `NavigationRailItemLabel`, `Badge`), inside a
75
+ * `<nav>`. Also any other content (a title, a filter, group headings).
76
+ * - **Focus:** on open, the current destination (`current`); if there is none, the element with
77
+ * `data-autofocus` or the first focusable. Tab wraps around inside. On close, it returns to
78
+ * whoever had it (the menu button).
79
+ * - **Closing:** Escape, the scrim, `ModalNavigationRailClose`, dragging towards the edge (it
80
+ * follows the pointer; on release it closes if it went past half the width or was fast, and goes
81
+ * back if the parent does not close it) and, with `closeOnSelect` (the default), choosing a
82
+ * destination: all of them ask to close with `onClose(reason)`, each with its reason.
83
+ * - **Destinations:** no limit: if they do not fit in height, the rail scrolls vertically (it never
84
+ * warns). It is where the destinations that do not fit in a `NavigationBar` or a collapsed rail go.
85
+ * - **Measurements:** the expanded rail's width (220, `--mk-navigation-rail-expanded-width` up to
86
+ * 360), no wider than the window minus 48 (to tap the scrim and close); `surface-container` with
87
+ * radius 16 on the content side (0 against the edge). It adds the safe areas at the top, the
88
+ * bottom and the edge side.
89
+ *
90
+ * Native props, `className`, `style` and `ref` reach the `<dialog>`.
91
+ */
92
+ export declare function ModalNavigationRail({ open, onClose, closeOnSelect, closeOnScrimClick, label, align, className, children, ref, onCancel, onClick, onKeyDown, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onClickCapture, onDragStart, ...props }: ModalNavigationRailProps): import("react").JSX.Element;
93
+ export interface ModalNavigationRailCloseProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children' | 'aria-label'> {
94
+ /** The button's accessible name (its `aria-label`). Defaults to "Close rail". */
95
+ label?: string | undefined;
96
+ 'aria-label'?: never;
97
+ ref?: Ref<HTMLButtonElement> | undefined;
98
+ }
99
+ /**
100
+ * Menu button of the open rail, inside `NavigationRailHeader`: the kit's 56 px square icon button
101
+ * with `menu_open` (mirrored in RTL, like Compose's `AutoMirrored`). It asks the
102
+ * `ModalNavigationRail` to close (`onClose('close-button')`), unless your own `onClick` calls
103
+ * `preventDefault()`.
104
+ */
105
+ export declare function ModalNavigationRailClose({ label, className, onClick, ...props }: ModalNavigationRailCloseProps): import("react").JSX.Element;
@@ -0,0 +1,272 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ // Organismo interactivo (ADR-0003, ADR-0029): un <dialog> abierto con showModal() (efecto), con la
4
+ // base modal común de Dialog y los sheets (src/internal/modal-dialog.ts, ADR-0025): foco atrapado,
5
+ // página inerte, Escape y scrim que piden cerrar con su motivo, Tab que da la vuelta, salida animada con
6
+ // settleAnimations y foco devuelto. Lo propio del rail: el <nav> del rail expandido adentro (las
7
+ // mismas partes y el mismo CSS que NavigationRail), el foco inicial en el destino actual y el cierre
8
+ // al elegir un destino. ModalNavigationRailClose lee el cierre por contexto, por eso es cliente.
9
+ //
10
+ // Arrastrar para cerrar (como ModalWideNavigationRail con hideOnCollapse, que lo habilita con
11
+ // anchoredDraggable): eventos de puntero sobre el <dialog>; el gesto pasa al rail solo si, al pasar
12
+ // los 8 px, es horizontal y hacia el borde de inicio (así no le quita al contenido el desplazamiento
13
+ // vertical ni, con mouse, la selección de texto); al soltar decide con computeTarget
14
+ // (src/internal/anchored-drag.ts, compartido con el BottomSheet) y los umbrales de Compose para el
15
+ // rail: la mitad del ancho o 125 px/s. Cerrar se pide a onClose('drag'); si el padre no cierra, vuelve. El
16
+ // táctil no necesita un `touchmove` no pasivo: `touch-action: pan-y pinch-zoom` deja el gesto
17
+ // horizontal a los eventos de puntero (modal-navigation-rail.css).
18
+ //
19
+ // Es un componente aparte y no una prop `modal` de NavigationRail: el rail sigue universal (sin
20
+ // 'use client'), y el modal comparte con él solo las partes (NavigationRailHeader,
21
+ // NavigationRailItem…), que son universales.
22
+ //
23
+ // Compose: ModalWideNavigationRail con hideOnCollapse (entra desde fuera de la pantalla), en
24
+ // compose/material3/material3/src/commonMain/kotlin/androidx/compose/material3/WideNavigationRail.kt
25
+ // (commit de12189a63, 2026-11-11). Ver modal-navigation-rail.css y 07-jetpack-compose.md.
26
+ import { createContext, use, useMemo, useRef, } from 'react';
27
+ import { IconButton } from '../../molecules/IconButton/IconButton.js';
28
+ import { MenuOpenIcon } from '../../icons/icons.js';
29
+ import { useModalDialog, onScrim } from '../../internal/modal-dialog.js';
30
+ import { computeTarget, DRAG_SLOP, VELOCITY_THRESHOLD, VelocityTracker } from '../../internal/anchored-drag.js';
31
+ import { partOutsideParent } from '../../internal/diagnostics.js';
32
+ import { cx } from '../../internal/interactive.js';
33
+ import { modalNavigationRailStrings } from './strings.js';
34
+ const ModalNavigationRailContext = createContext(null);
35
+ const ITEM = '.mk-navigation-rail-item';
36
+ const CURRENT = `${ITEM}[aria-current]:not([aria-current='false'])`;
37
+ // Campos donde un arrastre con mouse selecciona texto: no arrastran el rail.
38
+ const FIELD = 'input, textarea, select, [contenteditable]:not([contenteditable="false"])';
39
+ // Umbral de distancia del rail en Compose: la mitad del recorrido (ModalWideNavigationRailContent,
40
+ // `positionalThreshold = { distance -> distance * 0.5f }`). El de velocidad es el de
41
+ // AnchoredDraggable, 125 px/s, igual que el del BottomSheet.
42
+ const POSITIONAL_FRACTION = 0.5;
43
+ // Clic que el navegador manda a otra pestaña o ventana: no cierra el rail.
44
+ const opensElsewhere = (e) => e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey;
45
+ /**
46
+ * Modal variant of the NavigationRail: the expanded rail over the content, from the start edge (in
47
+ * RTL, the right one), full height, with a scrim and trapped focus. It is Compose's
48
+ * `ModalWideNavigationRail` coming in from off screen, the Expressive replacement for the navigation
49
+ * drawer: for small screens with more destinations than fit in a bar, or to expand a collapsed rail
50
+ * without shifting the content.
51
+ *
52
+ * ```tsx
53
+ * const [open, setOpen] = useState(false)
54
+ *
55
+ * <IconButton label="Open navigation" aria-haspopup="dialog" onClick={() => setOpen(true)}>
56
+ * <MenuIcon />
57
+ * </IconButton>
58
+ * <ModalNavigationRail open={open} onClose={() => setOpen(false)}>
59
+ * <NavigationRailHeader>
60
+ * <ModalNavigationRailClose />
61
+ * </NavigationRailHeader>
62
+ * <NavigationRailItem href="/" current>
63
+ * <NavigationRailItemIcon><HomeIcon filled /></NavigationRailItemIcon>
64
+ * <NavigationRailItemLabel>Home</NavigationRailItemLabel>
65
+ * </NavigationRailItem>
66
+ * …
67
+ * </ModalNavigationRail>
68
+ * ```
69
+ *
70
+ * - **Content:** the parts of the expanded `NavigationRail` (`NavigationRailHeader`,
71
+ * `NavigationRailItem`, `NavigationRailItemIcon`, `NavigationRailItemLabel`, `Badge`), inside a
72
+ * `<nav>`. Also any other content (a title, a filter, group headings).
73
+ * - **Focus:** on open, the current destination (`current`); if there is none, the element with
74
+ * `data-autofocus` or the first focusable. Tab wraps around inside. On close, it returns to
75
+ * whoever had it (the menu button).
76
+ * - **Closing:** Escape, the scrim, `ModalNavigationRailClose`, dragging towards the edge (it
77
+ * follows the pointer; on release it closes if it went past half the width or was fast, and goes
78
+ * back if the parent does not close it) and, with `closeOnSelect` (the default), choosing a
79
+ * destination: all of them ask to close with `onClose(reason)`, each with its reason.
80
+ * - **Destinations:** no limit: if they do not fit in height, the rail scrolls vertically (it never
81
+ * warns). It is where the destinations that do not fit in a `NavigationBar` or a collapsed rail go.
82
+ * - **Measurements:** the expanded rail's width (220, `--mk-navigation-rail-expanded-width` up to
83
+ * 360), no wider than the window minus 48 (to tap the scrim and close); `surface-container` with
84
+ * radius 16 on the content side (0 against the edge). It adds the safe areas at the top, the
85
+ * bottom and the edge side.
86
+ *
87
+ * Native props, `className`, `style` and `ref` reach the `<dialog>`.
88
+ */
89
+ export function ModalNavigationRail({ open = false, onClose, closeOnSelect = true, closeOnScrimClick = true, label = modalNavigationRailStrings.label, align = 'top', className, children, ref, onCancel, onClick, onKeyDown, onPointerDown, onPointerMove, onPointerUp, onPointerCancel, onClickCapture, onDragStart, ...props }) {
90
+ const drag = useRef(null);
91
+ // El clic que el navegador manda al terminar un arrastre con mouse no elige el destino de abajo.
92
+ const swallowClick = useRef(false);
93
+ const clearDrag = (dialog) => {
94
+ dialog.removeAttribute('data-dragging');
95
+ dialog.removeAttribute('data-released');
96
+ dialog.style.removeProperty('--_drag');
97
+ };
98
+ const modal = useModalDialog({
99
+ open,
100
+ onRequestClose: onClose,
101
+ closeOnScrimClick,
102
+ ref,
103
+ contentSelector: '.mk-navigation-rail',
104
+ // Tiene nombre por defecto ("Navigation rail"): avisa solo con `label=""` o un aria-labelledby
105
+ // que no apunta a nada con texto.
106
+ unnamed: {
107
+ component: 'ModalNavigationRail',
108
+ fix: 'keep the default label or pass a non-empty one (<ModalNavigationRail label="Main menu">), or point aria-labelledby at an element with text',
109
+ },
110
+ // El foco inicial va al destino actual (como el menú de páginas de una app); data-autofocus,
111
+ // que el hook enfoca después, le gana.
112
+ onOpen: (dialog) => {
113
+ drag.current = null;
114
+ clearDrag(dialog);
115
+ dialog.querySelector(CURRENT)?.focus();
116
+ },
117
+ onClosed: (dialog) => {
118
+ drag.current = null;
119
+ clearDrag(dialog);
120
+ },
121
+ onCancel,
122
+ onKeyDown,
123
+ onPointerDown: (e) => {
124
+ onPointerDown?.(e);
125
+ swallowClick.current = false;
126
+ const dialog = e.currentTarget;
127
+ if (e.defaultPrevented || !e.isPrimary || e.button !== 0 || drag.current)
128
+ return;
129
+ if (dialog.hasAttribute('data-closing') || onScrim(dialog, e))
130
+ return;
131
+ const mouse = e.pointerType === 'mouse';
132
+ if (mouse && e.target.closest(FIELD))
133
+ return;
134
+ const dir = getComputedStyle(dialog).direction === 'rtl' ? 1 : -1;
135
+ const tracker = new VelocityTracker();
136
+ tracker.add(performance.now(), dir * e.clientX);
137
+ drag.current = {
138
+ id: e.pointerId,
139
+ mouse,
140
+ startX: e.clientX,
141
+ startY: e.clientY,
142
+ dir,
143
+ width: dialog.getBoundingClientRect().width,
144
+ offset: 0,
145
+ active: false,
146
+ tracker,
147
+ };
148
+ },
149
+ onClick: (e) => {
150
+ onClick?.(e);
151
+ if (!closeOnSelect || opensElsewhere(e) || !(e.target instanceof Element))
152
+ return;
153
+ const item = e.target.closest(ITEM);
154
+ if (!item || !e.currentTarget.contains(item) || item.matches("[aria-disabled='true'], :disabled"))
155
+ return;
156
+ modal.requestClose('select');
157
+ },
158
+ });
159
+ const handlePointerMove = (e) => {
160
+ onPointerMove?.(e);
161
+ const d = drag.current;
162
+ if (!d || d.id !== e.pointerId)
163
+ return;
164
+ const dialog = e.currentTarget;
165
+ const dx = e.clientX - d.startX;
166
+ const dy = e.clientY - d.startY;
167
+ if (!d.active) {
168
+ if (Math.hypot(dx, dy) < DRAG_SLOP)
169
+ return;
170
+ // Solo un gesto horizontal hacia el borde es del rail: uno vertical desplaza los destinos y,
171
+ // con mouse, uno hacia el contenido sigue seleccionando texto.
172
+ if (Math.abs(dx) <= Math.abs(dy) || Math.sign(dx) !== d.dir) {
173
+ drag.current = null;
174
+ return;
175
+ }
176
+ d.active = true;
177
+ // Sigue al puntero desde acá, sin el salto del umbral.
178
+ d.startX = e.clientX;
179
+ try {
180
+ dialog.setPointerCapture(e.pointerId);
181
+ }
182
+ catch {
183
+ // NotFoundError: un evento sintético, sin puntero activo detrás.
184
+ }
185
+ // Con mouse, el gesto pudo empezar una selección de texto: ya no es una selección.
186
+ if (d.mouse)
187
+ dialog.ownerDocument.getSelection()?.removeAllRanges();
188
+ dialog.setAttribute('data-dragging', '');
189
+ }
190
+ e.preventDefault();
191
+ d.offset = Math.min(Math.max(d.dir * (e.clientX - d.startX), 0), d.width);
192
+ d.tracker.add(performance.now(), d.dir * e.clientX);
193
+ dialog.style.setProperty('--_drag', `${d.offset}px`);
194
+ };
195
+ const release = (dialog, velocity) => {
196
+ const d = drag.current;
197
+ drag.current = null;
198
+ if (!d?.active)
199
+ return;
200
+ // Con mouse, el gesto termina en un clic sobre el <dialog> (por la captura): ese no cuenta.
201
+ swallowClick.current = d.mouse;
202
+ const target = velocity === null
203
+ ? 'open'
204
+ : computeTarget([
205
+ ['open', 0],
206
+ ['closed', d.width],
207
+ ], d.offset, velocity, d.width * POSITIONAL_FRACTION, VELOCITY_THRESHOLD, 'ModalNavigationRail');
208
+ dialog.removeAttribute('data-dragging');
209
+ if (target === 'open') {
210
+ // Sin data-dragging vuelve la transición: del punto donde se soltó a su lugar.
211
+ dialog.style.removeProperty('--_drag');
212
+ return;
213
+ }
214
+ // Cerrar se pide al padre. Si cierra, la salida parte del punto donde se soltó; si no, el rail
215
+ // vuelve en el cuadro siguiente.
216
+ // data-released: con movimiento reducido, la salida se funde en ese punto en vez de saltar.
217
+ dialog.setAttribute('data-released', '');
218
+ modal.requestClose('drag');
219
+ requestAnimationFrame(() => {
220
+ if (!dialog.hasAttribute('data-closing'))
221
+ clearDrag(dialog);
222
+ });
223
+ };
224
+ const handlePointerUp = (e) => {
225
+ onPointerUp?.(e);
226
+ const d = drag.current;
227
+ if (!d || d.id !== e.pointerId)
228
+ return;
229
+ release(e.currentTarget, d.active ? d.tracker.velocity(performance.now()) : 0);
230
+ };
231
+ const handlePointerCancel = (e) => {
232
+ onPointerCancel?.(e);
233
+ if (drag.current?.id !== e.pointerId)
234
+ return;
235
+ release(e.currentTarget, null);
236
+ };
237
+ const handleClickCapture = (e) => {
238
+ onClickCapture?.(e);
239
+ if (!swallowClick.current)
240
+ return;
241
+ swallowClick.current = false;
242
+ e.preventDefault();
243
+ e.stopPropagation();
244
+ };
245
+ // Un destino es un enlace: con mouse, el navegador empezaría a arrastrar el enlace (y cancelaría
246
+ // los eventos de puntero) antes de que el gesto se decida.
247
+ const handleDragStart = (e) => {
248
+ onDragStart?.(e);
249
+ if (drag.current)
250
+ e.preventDefault();
251
+ };
252
+ const ctx = useMemo(() => ({ requestClose: modal.requestClose }),
253
+ // requestClose cambia con onClose.
254
+ [onClose]);
255
+ return (_jsx(ModalNavigationRailContext, { value: ctx, children: _jsx("dialog", { ...props, ...modal.dialogProps, onPointerMove: handlePointerMove, onPointerUp: handlePointerUp, onPointerCancel: handlePointerCancel, onClickCapture: handleClickCapture, onDragStart: handleDragStart, ref: modal.setRef, className: cx('mk-navigation-rail-modal', className), "aria-label": props['aria-labelledby'] ? undefined : label, children: _jsx("nav", { className: "mk-navigation-rail", "data-expanded": "true", "data-variant": "docked", "data-align": align, children: children }) }) }));
256
+ }
257
+ /**
258
+ * Menu button of the open rail, inside `NavigationRailHeader`: the kit's 56 px square icon button
259
+ * with `menu_open` (mirrored in RTL, like Compose's `AutoMirrored`). It asks the
260
+ * `ModalNavigationRail` to close (`onClose('close-button')`), unless your own `onClick` calls
261
+ * `preventDefault()`.
262
+ */
263
+ export function ModalNavigationRailClose({ label = modalNavigationRailStrings.closeLabel, className, onClick, ...props }) {
264
+ const ctx = use(ModalNavigationRailContext);
265
+ if (!ctx)
266
+ throw partOutsideParent('ModalNavigationRailClose', 'ModalNavigationRail');
267
+ return (_jsx(IconButton, { ...props, label: label, size: "md", shape: "square", className: cx('mk-navigation-rail-modal-close', className), onClick: (e) => {
268
+ onClick?.(e);
269
+ if (!e.defaultPrevented)
270
+ ctx.requestClose('close-button');
271
+ }, children: _jsx(MenuOpenIcon, {}) }));
272
+ }