@yahoo/uds 3.59.0-beta.1 → 3.59.0-beta.2

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 (304) hide show
  1. package/cli/bin/uds-darwin-arm64-baseline +0 -0
  2. package/cli/bin/uds-darwin-x64 +0 -0
  3. package/cli/bin/uds-linux-arm64 +0 -0
  4. package/cli/bin/uds-linux-x64-baseline +0 -0
  5. package/dist/components/Box.d.ts +2 -2
  6. package/dist/components/Box.d.ts.map +1 -1
  7. package/dist/components/Divider/Divider.d.cts +2 -2
  8. package/dist/components/Divider/Divider.d.ts +2 -2
  9. package/dist/components/Divider/DividerCore.d.cts +2 -2
  10. package/dist/components/Divider/DividerCore.d.ts +2 -2
  11. package/dist/components/Divider/DividerInternal.d.cts +2 -2
  12. package/dist/components/Divider/DividerInternal.d.ts +2 -2
  13. package/dist/components/FormLabel.d.ts +2 -2
  14. package/dist/components/HStack.d.ts +2 -2
  15. package/dist/components/Icon.d.ts +2 -2
  16. package/dist/components/Link.d.ts +2 -2
  17. package/dist/components/Text.d.cts +5 -5
  18. package/dist/components/Text.d.cts.map +1 -1
  19. package/dist/components/Text.d.ts +8 -8
  20. package/dist/components/Text.d.ts.map +1 -1
  21. package/dist/components/VStack.d.ts +2 -2
  22. package/dist/components/VStack.d.ts.map +1 -1
  23. package/dist/components/client/AnimateHeightChange.d.cts +2 -2
  24. package/dist/components/client/AnimateHeightChange.d.ts +2 -2
  25. package/dist/components/client/Avatar/Avatar.d.cts +2 -2
  26. package/dist/components/client/Avatar/Avatar.d.cts.map +1 -1
  27. package/dist/components/client/Avatar/Avatar.d.ts +2 -2
  28. package/dist/components/client/Avatar/AvatarIcon.d.cts +2 -2
  29. package/dist/components/client/Avatar/AvatarIcon.d.cts.map +1 -1
  30. package/dist/components/client/Avatar/AvatarIcon.d.ts +2 -2
  31. package/dist/components/client/Avatar/AvatarImage.d.cts +2 -2
  32. package/dist/components/client/Avatar/AvatarImage.d.ts +2 -2
  33. package/dist/components/client/Avatar/AvatarText.d.cts +2 -2
  34. package/dist/components/client/Avatar/AvatarText.d.ts +2 -2
  35. package/dist/components/client/IconButton.d.cts +2 -2
  36. package/dist/components/client/IconButton.d.ts +2 -2
  37. package/dist/components/client/IconButton.d.ts.map +1 -1
  38. package/dist/components/client/Input/Input.d.cts +2 -2
  39. package/dist/components/client/Input/Input.d.ts +2 -2
  40. package/dist/components/client/Input/InputHelpText.d.cts +2 -2
  41. package/dist/components/client/Input/InputHelpText.d.cts.map +1 -1
  42. package/dist/components/client/Input/InputHelpText.d.ts +2 -2
  43. package/dist/components/client/Input/InputHelpTextInternal.d.cts +4 -4
  44. package/dist/components/client/Input/InputHelpTextInternal.d.cts.map +1 -1
  45. package/dist/components/client/Input/InputHelpTextInternal.d.ts +4 -4
  46. package/dist/components/client/Menu/Menu.Content.d.cts +2 -2
  47. package/dist/components/client/Menu/Menu.Content.d.ts +2 -2
  48. package/dist/components/client/Menu/Menu.Divider.d.cts +2 -2
  49. package/dist/components/client/Menu/Menu.Divider.d.ts +2 -2
  50. package/dist/components/client/Menu/Menu.Item.d.cts +2 -2
  51. package/dist/components/client/Menu/Menu.ItemBase.d.cts +2 -2
  52. package/dist/components/client/Menu/Menu.ItemBase.d.ts +2 -2
  53. package/dist/components/client/Menu/Menu.ItemCheckbox.d.cts +2 -2
  54. package/dist/components/client/Menu/Menu.ItemCheckbox.d.ts +2 -2
  55. package/dist/components/client/Menu/Menu.Provider.d.cts +2 -2
  56. package/dist/components/client/Menu/Menu.Provider.d.ts +2 -2
  57. package/dist/components/client/Menu/Menu.Trigger.d.cts +2 -2
  58. package/dist/components/client/Menu/Menu.Trigger.d.ts +2 -2
  59. package/dist/components/client/Pressable.d.cts +2 -2
  60. package/dist/components/client/Pressable.d.ts +2 -2
  61. package/dist/components/client/Pressable.d.ts.map +1 -1
  62. package/dist/components/client/Radio/RadioGroupStore.d.ts +2 -2
  63. package/dist/components/client/SpringMotionConfig.d.cts +3 -3
  64. package/dist/components/client/SpringMotionConfig.d.ts +3 -3
  65. package/dist/components/client/SpringMotionConfig.d.ts.map +1 -1
  66. package/dist/components/experimental/Spinner.d.cts +2 -2
  67. package/dist/components/experimental/Spinner.d.cts.map +1 -1
  68. package/dist/components/experimental/Spinner.d.ts +2 -2
  69. package/dist/components/experimental/Table.d.cts +2 -2
  70. package/dist/components/experimental/Table.d.ts +2 -2
  71. package/dist/components/experimental/client/Accordion.d.cts +2 -2
  72. package/dist/components/experimental/client/Accordion.d.cts.map +1 -1
  73. package/dist/components/experimental/client/Accordion.d.ts +2 -2
  74. package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.cts +2 -2
  75. package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.ts +2 -2
  76. package/dist/components/experimental/client/Modal.d.cts +3 -3
  77. package/dist/components/experimental/client/Modal.d.cts.map +1 -1
  78. package/dist/components/experimental/client/Modal.d.ts +3 -3
  79. package/dist/components/experimental/client/Popover.d.cts +3 -3
  80. package/dist/components/experimental/client/Popover.d.cts.map +1 -1
  81. package/dist/components/experimental/client/Popover.d.ts +3 -3
  82. package/dist/components/experimental/client/Tabs.d.cts +3 -3
  83. package/dist/components/experimental/client/Tabs.d.ts +6 -6
  84. package/dist/components/experimental/client/Toast.d.cts +2 -2
  85. package/dist/components/experimental/client/Toast.d.ts +2 -2
  86. package/dist/providers/ColorModeProvider.d.cts +4 -4
  87. package/dist/providers/ColorModeProvider.d.cts.map +1 -1
  88. package/dist/providers/ColorModeProvider.d.ts +4 -4
  89. package/dist/providers/ColorModeProvider.d.ts.map +1 -1
  90. package/dist/providers/ScaleModeProvider.d.cts +4 -4
  91. package/dist/providers/ScaleModeProvider.d.cts.map +1 -1
  92. package/dist/providers/ScaleModeProvider.d.ts +4 -4
  93. package/dist/providers/ScaleModeProvider.d.ts.map +1 -1
  94. package/dist/providers/ThemeProvider.d.cts +2 -2
  95. package/dist/providers/ThemeProvider.d.cts.map +1 -1
  96. package/dist/providers/ThemeProvider.d.ts +2 -2
  97. package/dist/styles/styler.d.cts +33 -33
  98. package/dist/styles/styler.d.ts +33 -33
  99. package/dist/styles/stylerTypes.d.ts.map +1 -1
  100. package/dist/tailwind/tailwind.config.d.ts +3 -3
  101. package/dist/tailwind/tailwindPlugin.d.ts +3 -3
  102. package/dist/tailwind/utils/getMotionStyles.d.cts +1 -1
  103. package/dist/tailwind/utils/getMotionStyles.d.ts +1 -1
  104. package/dist/tokens/automation/utils/getConfigVariantProperties.d.cts +2 -2
  105. package/dist/tokens/automation/utils/getConfigVariantProperties.d.cts.map +1 -1
  106. package/dist/tokens/automation/utils/getConfigVariantProperties.d.ts +2 -2
  107. package/dist/tokens/automation/utils/getConfigVariantProperties.d.ts.map +1 -1
  108. package/dist/tokens/types.d.cts.map +1 -1
  109. package/dist/tokens/types.d.ts.map +1 -1
  110. package/dist/utils/intersperse.d.cts +2 -2
  111. package/dist/utils/intersperse.d.ts +2 -2
  112. package/package.json +1 -3
  113. package/cli/FlattenButtonVariant.mock.tsx +0 -17
  114. package/src/components/Box.tsx +0 -181
  115. package/src/components/Divider/Divider.tsx +0 -44
  116. package/src/components/Divider/DividerCore.tsx +0 -101
  117. package/src/components/Divider/DividerInternal.tsx +0 -56
  118. package/src/components/Divider/index.ts +0 -1
  119. package/src/components/FormLabel.tsx +0 -66
  120. package/src/components/HStack.tsx +0 -53
  121. package/src/components/Icon.tsx +0 -82
  122. package/src/components/IconSlot.tsx +0 -82
  123. package/src/components/Image.tsx +0 -162
  124. package/src/components/Link.tsx +0 -134
  125. package/src/components/Text.tsx +0 -272
  126. package/src/components/VStack.tsx +0 -53
  127. package/src/components/client/AnimateHeightChange.tsx +0 -50
  128. package/src/components/client/Avatar/Avatar.tsx +0 -31
  129. package/src/components/client/Avatar/AvatarIcon.tsx +0 -103
  130. package/src/components/client/Avatar/AvatarImage.tsx +0 -147
  131. package/src/components/client/Avatar/AvatarText.tsx +0 -88
  132. package/src/components/client/Avatar/index.ts +0 -4
  133. package/src/components/client/Avatar/utils.ts +0 -105
  134. package/src/components/client/Badge.tsx +0 -133
  135. package/src/components/client/Button.tsx +0 -312
  136. package/src/components/client/Checkbox.tsx +0 -377
  137. package/src/components/client/Chip/Chip.tsx +0 -81
  138. package/src/components/client/Chip/ChipBase.tsx +0 -151
  139. package/src/components/client/Chip/ChipButton.tsx +0 -54
  140. package/src/components/client/Chip/ChipDismissible.tsx +0 -90
  141. package/src/components/client/Chip/ChipLink.tsx +0 -60
  142. package/src/components/client/Chip/ChipToggle.tsx +0 -79
  143. package/src/components/client/Chip/index.ts +0 -5
  144. package/src/components/client/IconButton.tsx +0 -198
  145. package/src/components/client/Input/Input.tsx +0 -323
  146. package/src/components/client/Input/InputHelpText.tsx +0 -52
  147. package/src/components/client/Input/InputHelpTextInternal.tsx +0 -81
  148. package/src/components/client/Input/index.ts +0 -2
  149. package/src/components/client/Menu/Menu.Content.tsx +0 -391
  150. package/src/components/client/Menu/Menu.Divider.tsx +0 -102
  151. package/src/components/client/Menu/Menu.Item.tsx +0 -114
  152. package/src/components/client/Menu/Menu.ItemBase.tsx +0 -265
  153. package/src/components/client/Menu/Menu.ItemCheckbox.tsx +0 -197
  154. package/src/components/client/Menu/Menu.Provider.tsx +0 -154
  155. package/src/components/client/Menu/Menu.Trigger.tsx +0 -119
  156. package/src/components/client/Menu/Menu.index.tsx +0 -9
  157. package/src/components/client/Menu/Menu.tsx +0 -2
  158. package/src/components/client/Menu/index.ts +0 -7
  159. package/src/components/client/Menu/utils/transformAriakitPlacement.ts +0 -66
  160. package/src/components/client/Pressable.tsx +0 -194
  161. package/src/components/client/Radio/Radio.tsx +0 -351
  162. package/src/components/client/Radio/RadioGroupProvider.tsx +0 -122
  163. package/src/components/client/Radio/RadioGroupStore.tsx +0 -56
  164. package/src/components/client/Radio/index.ts +0 -2
  165. package/src/components/client/Radio/useRadioGroup.ts +0 -149
  166. package/src/components/client/SpringMotionConfig.tsx +0 -151
  167. package/src/components/client/Switch.tsx +0 -377
  168. package/src/components/client/index.ts +0 -30
  169. package/src/components/client/motionFeatures/domAnimation.ts +0 -2
  170. package/src/components/client/motionFeatures/domMax.ts +0 -2
  171. package/src/components/experimental/Spinner.tsx +0 -30
  172. package/src/components/experimental/Table.mocks.tsx +0 -38
  173. package/src/components/experimental/Table.tsx +0 -239
  174. package/src/components/experimental/client/Accordion.tsx +0 -77
  175. package/src/components/experimental/client/AvoidMotionLibraryProvider.tsx +0 -10
  176. package/src/components/experimental/client/Modal.tsx +0 -68
  177. package/src/components/experimental/client/Popover.tsx +0 -63
  178. package/src/components/experimental/client/SwitchV2.tsx +0 -343
  179. package/src/components/experimental/client/Tabs.tsx +0 -106
  180. package/src/components/experimental/client/Toast.tsx +0 -186
  181. package/src/components/experimental/client/index.ts +0 -15
  182. package/src/components/experimental/index.ts +0 -48
  183. package/src/components/index.ts +0 -41
  184. package/src/defaultTokensConfig.ts +0 -31
  185. package/src/fixtures/index.ts +0 -638
  186. package/src/fixtures/macros/typesToConstants.ts +0 -42
  187. package/src/fixtures/utils/getScaleModeRamp.ts +0 -48
  188. package/src/fixtures/utils/getTailwindAsUdsColors.ts +0 -115
  189. package/src/flags.ts +0 -45
  190. package/src/hooks/useForkRef.ts +0 -34
  191. package/src/hooks/useNestedBorderRadius.ts +0 -138
  192. package/src/hooks/useRtl.ts +0 -64
  193. package/src/index.ts +0 -4
  194. package/src/providers/ColorModeProvider.tsx +0 -21
  195. package/src/providers/ScaleModeProvider.tsx +0 -29
  196. package/src/providers/ThemeProvider.tsx +0 -26
  197. package/src/styles/styler.ts +0 -194
  198. package/src/styles/stylerTypes.ts +0 -81
  199. package/src/styles/toast.css +0 -0
  200. package/src/styles/variants.ts +0 -1351
  201. package/src/tailwind/base/addColorModeVars.ts +0 -23
  202. package/src/tailwind/base/addColorModeVarsV2.ts +0 -57
  203. package/src/tailwind/base/addFontFaceDeclarations.ts +0 -13
  204. package/src/tailwind/base/addFontVars.ts +0 -9
  205. package/src/tailwind/base/addMotionVars.ts +0 -9
  206. package/src/tailwind/base/addScaleModeVars.ts +0 -33
  207. package/src/tailwind/base/types.ts +0 -8
  208. package/src/tailwind/components/getButtonStyles.ts +0 -240
  209. package/src/tailwind/components/getFocusRingStyles.ts +0 -32
  210. package/src/tailwind/components/getGroupedTextStyles.ts +0 -29
  211. package/src/tailwind/components/getHitTargetStyles.ts +0 -23
  212. package/src/tailwind/components/getIconButtonStyles.ts +0 -49
  213. package/src/tailwind/components/getIconStyles.ts +0 -13
  214. package/src/tailwind/components/getInputStyles.ts +0 -20
  215. package/src/tailwind/components/getResponsiveTextStyles.ts +0 -161
  216. package/src/tailwind/components/types.ts +0 -14
  217. package/src/tailwind/components/utils.ts +0 -73
  218. package/src/tailwind/defaultTailwindThemeAsUdsConfig.ts +0 -78
  219. package/src/tailwind/postcss.config.ts +0 -6
  220. package/src/tailwind/purger/index.ts +0 -1
  221. package/src/tailwind/tailwind.config.ts +0 -50
  222. package/src/tailwind/tailwind.d.ts +0 -5
  223. package/src/tailwind/tailwindPlugin.ts +0 -724
  224. package/src/tailwind/theme/getFontFamilyTheme.ts +0 -28
  225. package/src/tailwind/tsMorph.ts +0 -1
  226. package/src/tailwind/uds.css +0 -3
  227. package/src/tailwind/utils/addFontsPlugin.ts +0 -17
  228. package/src/tailwind/utils/getColorModeStyles.ts +0 -21
  229. package/src/tailwind/utils/getFontFaceDeclarations.ts +0 -12
  230. package/src/tailwind/utils/getFontStyles.ts +0 -38
  231. package/src/tailwind/utils/getMotionStyles.ts +0 -35
  232. package/src/tailwind/utils/getScaleModeStyles.ts +0 -23
  233. package/src/tailwind/utils/getShadowPresetValues.ts +0 -133
  234. package/src/tailwind/utils/getShadowStyles.ts +0 -26
  235. package/src/tailwind/utils/getShadowVars.ts +0 -40
  236. package/src/tailwind/utils/index.ts +0 -9
  237. package/src/tokens/automation/configs/avatar.ts +0 -297
  238. package/src/tokens/automation/configs/badge.ts +0 -306
  239. package/src/tokens/automation/configs/checkbox.ts +0 -226
  240. package/src/tokens/automation/configs/chip.ts +0 -521
  241. package/src/tokens/automation/configs/divider.ts +0 -112
  242. package/src/tokens/automation/configs/index.ts +0 -10
  243. package/src/tokens/automation/configs/input.ts +0 -496
  244. package/src/tokens/automation/configs/link.ts +0 -183
  245. package/src/tokens/automation/configs/menu.ts +0 -344
  246. package/src/tokens/automation/configs/radio.ts +0 -225
  247. package/src/tokens/automation/configs/switch.ts +0 -323
  248. package/src/tokens/automation/index.ts +0 -5
  249. package/src/tokens/automation/mapTextVariantFixtureToValue.ts +0 -8
  250. package/src/tokens/automation/properties.ts +0 -433
  251. package/src/tokens/automation/types/ComponentConfig.ts +0 -116
  252. package/src/tokens/automation/types/ComponentDB.ts +0 -1
  253. package/src/tokens/automation/types/ComponentStyles.ts +0 -47
  254. package/src/tokens/automation/types/index.ts +0 -2
  255. package/src/tokens/automation/utils/cartesianProduct.ts +0 -13
  256. package/src/tokens/automation/utils/coalesceConfigVariant.ts +0 -49
  257. package/src/tokens/automation/utils/defaults.ts +0 -29
  258. package/src/tokens/automation/utils/generateKeyFromFlatConfigPath.ts +0 -15
  259. package/src/tokens/automation/utils/generateSchemaKey.ts +0 -29
  260. package/src/tokens/automation/utils/getConfigComponentVariant.ts +0 -28
  261. package/src/tokens/automation/utils/getConfigVariantComponentStatesMatrix.ts +0 -40
  262. package/src/tokens/automation/utils/getConfigVariantProperties.ts +0 -32
  263. package/src/tokens/automation/utils/getConfigVariantPseudoStates.ts +0 -70
  264. package/src/tokens/automation/utils/getConfigVariants.ts +0 -73
  265. package/src/tokens/automation/utils/index.ts +0 -939
  266. package/src/tokens/automation/utils/mapColorFixtureToValue.ts +0 -34
  267. package/src/tokens/automation/utils/subcomponents.ts +0 -13
  268. package/src/tokens/automation/utils/variableData.ts +0 -79
  269. package/src/tokens/automation/utils/variantConfigGuards.ts +0 -17
  270. package/src/tokens/configs/borderRadius.ts +0 -23
  271. package/src/tokens/configs/borderWidth.ts +0 -17
  272. package/src/tokens/configs/button.ts +0 -888
  273. package/src/tokens/configs/colorMode.ts +0 -14
  274. package/src/tokens/configs/font.ts +0 -9
  275. package/src/tokens/configs/iconButton.ts +0 -28
  276. package/src/tokens/configs/motion.ts +0 -135
  277. package/src/tokens/configs/palette.ts +0 -124
  278. package/src/tokens/configs/scaleMode.ts +0 -28
  279. package/src/tokens/configs/shadow.ts +0 -286
  280. package/src/tokens/configs/sizes.ts +0 -23
  281. package/src/tokens/configs/spectrum.ts +0 -729
  282. package/src/tokens/configs/typography.ts +0 -417
  283. package/src/tokens/configs/yosConfig.ts +0 -7651
  284. package/src/tokens/consts/buttonMotionTokens.ts +0 -99
  285. package/src/tokens/consts/cssTokens.ts +0 -110
  286. package/src/tokens/consts/defaultModes.ts +0 -15
  287. package/src/tokens/consts/fontDeclarationsMap.ts +0 -509
  288. package/src/tokens/index.ts +0 -15
  289. package/src/tokens/parseButtonVariants.ts +0 -59
  290. package/src/tokens/parseTokens.ts +0 -122
  291. package/src/tokens/types.ts +0 -1882
  292. package/src/tokens/utils/entries.ts +0 -14
  293. package/src/tokens/utils/fromEntries.ts +0 -11
  294. package/src/tokens/utils/mapValues.ts +0 -15
  295. package/src/types.ts +0 -2
  296. package/src/utils/assertUnreachable.ts +0 -6
  297. package/src/utils/composeRefs.ts +0 -23
  298. package/src/utils/createSlot.tsx +0 -131
  299. package/src/utils/entries.ts +0 -6
  300. package/src/utils/falsyToString.ts +0 -3
  301. package/src/utils/getMotionVar.ts +0 -18
  302. package/src/utils/intersperse.ts +0 -45
  303. package/src/utils/mapValues.ts +0 -15
  304. package/src/utils/mergeSlotProps.ts +0 -70
@@ -1,391 +0,0 @@
1
- import type {
2
- MenuProps as AriakitMenuProps,
3
- MenuProviderProps as AriakitMenuProviderProps,
4
- } from '@ariakit/react/menu';
5
- import { Menu as AriakitMenu, useMenuContext } from '@ariakit/react/menu';
6
- import { useStoreState } from '@ariakit/react-core/utils/store';
7
- import { spacingMap } from '@yahoo/uds/fixtures';
8
- import type { SpacingAlias } from '@yahoo/uds/tokens';
9
- import { AnimatePresence, m } from 'motion/react';
10
- import { forwardRef, useEffect, useMemo, useState } from 'react';
11
-
12
- import { useNestedBorderRadius } from '../../../hooks/useNestedBorderRadius';
13
- import { cx } from '../../../styles/styler';
14
- import type { VStackProps } from '../../VStack';
15
- import { VStack } from '../../VStack';
16
-
17
- const MotionVStack = m.create(VStack);
18
-
19
- /* ---------------------------- ANIMATION HELPERS --------------------------- */
20
-
21
- // TODO: Move this to a shared location
22
- type BasePlacement = 'top' | 'bottom' | 'left' | 'right';
23
-
24
- const ANIMATION_CONFIG = { distance: 5, scale: 0.97 };
25
- const variants = {
26
- top: { x: 0, y: ANIMATION_CONFIG.distance },
27
- bottom: { x: 0, y: -ANIMATION_CONFIG.distance },
28
- left: { x: ANIMATION_CONFIG.distance, y: 0 },
29
- right: { x: -ANIMATION_CONFIG.distance, y: 0 },
30
- } as const;
31
-
32
- const getMenuAnimationVariants = (placement: AriakitMenuProviderProps['placement'] = 'bottom') => {
33
- const [base = 'top'] = placement?.split('-') as [BasePlacement];
34
-
35
- return {
36
- closed: { ...variants[base], opacity: 0, scale: ANIMATION_CONFIG.scale },
37
- open: { y: 0, x: 0, opacity: 1, scale: 1 },
38
- };
39
- };
40
-
41
- const useMenuAnimationVariants = (placement: AriakitMenuProviderProps['placement']) => {
42
- return useMemo(() => getMenuAnimationVariants(placement), [placement]);
43
- };
44
-
45
- /* -------------------------------- COMPONENT ------------------------------- */
46
-
47
- interface MenuContentProps extends Omit<VStackProps, 'asChild'> {
48
- gutter?: SpacingAlias;
49
- /** UDS handles nested border radius for the first and last item for you to prevent clipping and visual jank.
50
- * If you need to disable this, set this prop to true.
51
- *
52
- * @link https://github.com/yahoo-uds/uds/blob/main/packages/uds/src/hooks/useNestedBorderRadius.ts
53
- **/
54
- disableAutoBorderRadius?: boolean;
55
- /**
56
- * `portalRef` is similar to `ref` but is scoped to the portal node. It's
57
- * useful when you need to be informed when the portal element is appended to
58
- * the DOM or removed from the DOM.
59
- *
60
- * Live examples:
61
- * - [Form with Select](https://ariakit.org/examples/form-select)
62
- * @example
63
- * ```jsx
64
- * const [portalElement, setPortalElement] = useState(null);
65
- *
66
- * <Portal portalRef={setPortalElement} />
67
- * ```
68
- */
69
- portalRef?: AriakitMenuProps['portalRef'];
70
- /**
71
- * Determines whether the element should be rendered as a React Portal.
72
- *
73
- * Live examples:
74
- * - [Combobox with integrated
75
- * filter](https://ariakit.org/examples/combobox-filtering-integrated)
76
- * - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)
77
- * - [Hovercard with keyboard
78
- * support](https://ariakit.org/examples/hovercard-disclosure)
79
- * - [Menubar](https://ariakit.org/components/menubar)
80
- * - [Standalone Popover](https://ariakit.org/examples/popover-standalone)
81
- * - [Animated Select](https://ariakit.org/examples/select-animated)
82
- * @default true
83
- */
84
- portal?: boolean;
85
- /**
86
- * An HTML element or a memoized callback function that returns an HTML
87
- * element to be used as the portal element. By default, the portal element
88
- * will be a `div` element appended to the `document.body`.
89
- *
90
- * Live examples:
91
- * - [Navigation Menubar](https://ariakit.org/examples/menubar-navigation)
92
- * @example
93
- * ```jsx
94
- * const [portal, setPortal] = useState(null);
95
- *
96
- * <Portal portalElement={portal} />
97
- * <div ref={setPortal} />
98
- * ```
99
- * @example
100
- * ```jsx
101
- * const getPortalElement = useCallback(() => {
102
- * const div = document.createElement("div");
103
- * const portalRoot = document.getElementById("portal-root");
104
- * portalRoot.appendChild(div);
105
- * return div;
106
- * }, []);
107
- *
108
- * <Portal portalElement={getPortalElement} />
109
- * ```
110
- */
111
- portalElement?: AriakitMenuProps['portalElement'];
112
- /**
113
- * Determines whether the popover should hide when the mouse leaves the
114
- * popover or the anchor element and there's no _hover intent_, meaning, the
115
- * mouse isn't moving toward the popover.
116
- *
117
- * This can be either a boolean or a callback receiving the mouse move event
118
- * that initiated the behavior. The callback should return a boolean.
119
- *
120
- * **Note**: This behavior won't be triggered when the popover or any of its
121
- * descendants are in focus.
122
- * @default true
123
- */
124
- hideOnHoverOutside?: AriakitMenuProps['hideOnHoverOutside'];
125
- /**
126
- * Determines if the dialog will hide when the user presses the Escape key.
127
- *
128
- * This prop can be either a boolean or a function that accepts an event as an
129
- * argument and returns a boolean. The event object represents the keydown
130
- * event that initiated the hide action, which could be either a native
131
- * keyboard event or a React synthetic event.
132
- *
133
- * **Note**: When placing Ariakit dialogs inside third-party dialogs, using
134
- * `event.stopPropagation()` within this function will stop the event from
135
- * reaching the third-party dialog, closing only the Ariakit dialog.
136
- * @default true
137
- */
138
- hideOnEscape?: AriakitMenuProps['hideOnEscape'];
139
- /**
140
- * Determines if the dialog should hide when the user clicks or focuses on an
141
- * element outside the dialog.
142
- *
143
- * This prop can be either a boolean or a function that takes an event as an
144
- * argument and returns a boolean. The event object represents the event that
145
- * triggered the action, which could be a native event or a React synthetic
146
- * event of various types.
147
- *
148
- * Live examples:
149
- * - [Selection Popover](https://ariakit.org/examples/popover-selection)
150
- * @default true
151
- */
152
- hideOnInteractOutside?: AriakitMenuProps['hideOnInteractOutside'];
153
- /**
154
- * Determines if the pointer events outside of the popover and its anchor
155
- * element should be disabled during _hover intent_, that is, when the mouse
156
- * is moving toward the popover.
157
- *
158
- * This is required as these external events may trigger focus on other
159
- * elements and close the popover while the user is attempting to hover over
160
- * it.
161
- *
162
- * This can be either a boolean or a callback receiving the mouse event
163
- * happening during hover intent. The callback should return a boolean.
164
- * @default true
165
- */
166
- disablePointerEventsOnApproach?: AriakitMenuProps['disablePointerEventsOnApproach'];
167
- /**
168
- * Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
169
- * If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
170
- * [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
171
- */
172
- store?: AriakitMenuProps['store'];
173
- /**
174
- * Whether the popover should have the same width as the anchor element. This
175
- * will be exposed to CSS as
176
- * [`--popover-anchor-width`](https://ariakit.org/guide/styling#--popover-anchor-width).
177
- * @default false
178
- */
179
- sameWidth?: AriakitMenuProps['sameWidth'];
180
- /**
181
- * @see https://ariakit.org/reference/focusable
182
- * @default true
183
- */
184
- focusable?: AriakitMenuProps['focusable'];
185
- /**
186
- * This is an event handler prop triggered when the dialog's `close` event is
187
- * dispatched. The `close` event is similar to the native dialog
188
- * [`close`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/close_event)
189
- * event. The only difference is that this event can be canceled with
190
- * `event.preventDefault()`, which will prevent the dialog from hiding.
191
- *
192
- * It's important to note that this event only fires when the dialog store's
193
- * [`open`](https://ariakit.org/reference/use-dialog-store#open) state is set
194
- * to `false`. If the controlled
195
- * [`open`](https://ariakit.org/reference/dialog#open) prop value changes, or
196
- * if the dialog's visibility is altered in any other way (such as unmounting
197
- * the dialog without adjusting the open state), this event won't be
198
- * triggered.
199
- *
200
- * Live examples:
201
- * - [Dialog with scrollable
202
- * backdrop](https://ariakit.org/examples/dialog-backdrop-scrollable)
203
- * - [Dialog with details &
204
- * summary](https://ariakit.org/examples/dialog-details)
205
- * - [Warning on Dialog
206
- * hide](https://ariakit.org/examples/dialog-hide-warning)
207
- * - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)
208
- */
209
- onClose?: AriakitMenuProps['onClose'];
210
- }
211
-
212
- /**
213
- * **📦 A Menu Content component**
214
- *
215
- * @componentType Client component
216
- *
217
- * @description
218
- * A content component for the menu, which is used to provide the menu context to the menu items.
219
- *
220
- * @see The {@link https://uds.build/docs/components/menu-content Menu.Content Docs} for more info
221
- *
222
- * @example
223
- * ```tsx
224
- * 'use client'; // Next.js client component
225
- *
226
- * import { Menu, Button } from "@yahoo/uds";
227
- * import { Calendar, Clipboard } from "@yahoo/uds-icons";
228
- *
229
- * export function MenuProviderExample() {
230
- * return (
231
- * <Menu.Provider>
232
- * <Menu.Trigger asChild>
233
- * <Button>Menu Options</Button>
234
- * </Menu.Trigger>
235
- * <Menu.Content>
236
- * <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
237
- * <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
238
- * Clipboard
239
- * </Menu.Item>
240
- * <Menu.Item active>Active Item</Menu.Item>
241
- * </Menu.Content>
242
- * </Menu.Provider>
243
- * )
244
- * }
245
- * ```
246
- *
247
- * @usage
248
- * Using Menu.Content is required to use Menu.Item and Menu.ItemCheckbox. It acts as the actual menu container.
249
- *
250
- * @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
251
- **/
252
- const MenuContent = forwardRef<HTMLDivElement, MenuContentProps>(function MenuContent(
253
- {
254
- // Spacing
255
- gap,
256
- spacing,
257
- spacingBottom,
258
- spacingEnd,
259
- spacingStart,
260
- spacingTop,
261
- gutter = '1',
262
- // Color
263
- backgroundColor = 'primary',
264
- borderRadius = 'md',
265
- // Borders
266
- borderColor,
267
- borderWidth = 'thin',
268
- overflow,
269
- dropShadow = 'lg',
270
- // Styles
271
- className,
272
- // Ariakit props
273
- sameWidth,
274
- focusable,
275
- children,
276
- portalElement,
277
- portal = true,
278
- // Misc
279
- disableAutoBorderRadius,
280
- // Rest
281
- ...props
282
- },
283
- ref,
284
- ) {
285
- const context = useMenuContext();
286
- const open = useStoreState(context, 'open');
287
- const mounted = useStoreState(context, 'mounted');
288
- const currentPlacement = useStoreState(context, 'currentPlacement');
289
-
290
- const placement = useStoreState(context, 'placement');
291
- const [prevPlacement, setPrevPlacement] =
292
- useState<AriakitMenuProviderProps['placement']>(currentPlacement);
293
- const [nextPlacement, setNextPlacement] =
294
- useState<AriakitMenuProviderProps['placement']>(currentPlacement);
295
-
296
- // If placement changes (This can happen when the html direction updates)
297
- useEffect(() => {
298
- if (placement !== nextPlacement) {
299
- setNextPlacement(placement);
300
- }
301
- // eslint-disable-next-line react-hooks/exhaustive-deps
302
- }, [placement]);
303
-
304
- // If the placement is updated because of some collision
305
- useEffect(() => {
306
- if (currentPlacement !== nextPlacement) {
307
- setNextPlacement(currentPlacement);
308
- }
309
- // eslint-disable-next-line react-hooks/exhaustive-deps
310
- }, [currentPlacement]);
311
-
312
- useEffect(() => {
313
- if (mounted && nextPlacement !== prevPlacement) {
314
- setPrevPlacement(nextPlacement);
315
- }
316
- }, [mounted, nextPlacement, prevPlacement]);
317
-
318
- // Setup variants
319
- const motionState = useMemo(() => {
320
- if (!open || !mounted) {
321
- return 'closed';
322
- }
323
- return 'open';
324
- }, [open, mounted]);
325
-
326
- // Allows us to animate the shadow when the menu is open
327
- const shadowVariant = useMemo(() => (open ? dropShadow : 'none'), [open, dropShadow]);
328
-
329
- const variants = useMenuAnimationVariants(nextPlacement);
330
- const borderRadiusClassName = useNestedBorderRadius({ borderRadius, spacing });
331
- const gutterValue = useMemo(() => spacingMap[gutter], [gutter]);
332
-
333
- return (
334
- <AnimatePresence initial={false}>
335
- <AriakitMenu
336
- gutter={gutterValue}
337
- sameWidth={sameWidth}
338
- focusable={focusable}
339
- store={context}
340
- ref={ref}
341
- portalElement={portalElement}
342
- portal={portal}
343
- {...props}
344
- render={
345
- <MotionVStack
346
- backgroundColor={backgroundColor}
347
- gap={gap}
348
- spacing={spacing}
349
- spacingBottom={spacingBottom}
350
- spacingEnd={spacingEnd}
351
- spacingStart={spacingStart}
352
- spacingTop={spacingTop}
353
- borderRadius={borderRadius}
354
- borderColor={borderColor}
355
- borderWidth={borderWidth}
356
- overflow={overflow}
357
- animate={motionState}
358
- variants={variants}
359
- dropShadow={shadowVariant}
360
- className={cx(
361
- // Base class
362
- 'uds-menu-content',
363
- // Handle shadow animation
364
- 'transition-shadow',
365
- 'duration-200',
366
- 'ease-in-out',
367
- // Set a min/max width
368
- 'min-w-60',
369
- 'max-w-lg',
370
- 'max-h-96',
371
- 'overflow-auto',
372
- // Focus ring
373
- 'uds-ring',
374
- 'z-10',
375
- // Misc
376
- 'group',
377
- !disableAutoBorderRadius && borderRadiusClassName,
378
- className,
379
- )}
380
- >
381
- {children}
382
- </MotionVStack>
383
- }
384
- />
385
- </AnimatePresence>
386
- );
387
- });
388
-
389
- MenuContent.displayName = 'MenuContent';
390
-
391
- export { MenuContent, type MenuContentProps };
@@ -1,102 +0,0 @@
1
- import type { AriaRole } from 'react';
2
- import { forwardRef } from 'react';
3
-
4
- import { getStyles } from '../../../styles/styler';
5
- import type { DividerProps } from '../../Divider/Divider';
6
- import { DividerInternal } from '../../Divider/DividerInternal';
7
-
8
- interface MenuDividerProps extends Omit<DividerProps, 'variant'> {
9
- /**
10
- * The role of the divider.
11
- * @default 'separator'
12
- */
13
- role?: AriaRole;
14
- }
15
-
16
- /**
17
- * **〰️ A Menu Divider component**
18
- *
19
- * @componentType Client component
20
- *
21
- * @description
22
- * A divider component for the menu.
23
- *
24
- * @see The {@link https://uds.build/docs/components/menu-divider Menu.Divider Docs} for more info
25
- *
26
- * @example
27
- * ```tsx
28
- * 'use client'; // Next.js client component
29
- *
30
- * import { Menu, Button } from "@yahoo/uds";
31
- *
32
- * export function DividerExample() {
33
- * return (
34
- * <Menu>
35
- * <Menu.Trigger asChild>
36
- * <Button>Menu Options</Button>
37
- * </Menu.Trigger>
38
- * <Menu.Content>
39
- * <Menu.Item>Calendar</Menu.Item>
40
- * <Menu.Divider>Other actions</Menu.Divider>
41
- * <Menu.Item>Clipboard</Menu.Item>
42
- * <Menu.Item active>Active Item</Menu.Item>
43
- * </Menu.Content>
44
- * </Menu>
45
- * )
46
- * }
47
- * ```
48
- *
49
- * @usage
50
- * Use MenuDivider to separate groups of menu items.
51
- *
52
- * @related [Menu](https://uds.build/docs/components/menu), [Menu.Item](https://uds.build/docs/components/menu-item), [Divider](https://uds.build/docs/components/divider)
53
- **/
54
- const MenuDivider = forwardRef<HTMLDivElement, MenuDividerProps>(function MenuDivider(
55
- {
56
- role = 'separator',
57
- contentPosition = 'start',
58
- gap = '4',
59
- children,
60
- spacingVertical = children ? '2' : '0',
61
- spacingHorizontal = children ? '4' : '0',
62
- className,
63
- ...props
64
- },
65
- ref,
66
- ) {
67
- const layerClassNames = {
68
- root: getStyles({
69
- menuDividerVariantRoot: 'default',
70
- className,
71
- }),
72
-
73
- text: getStyles({
74
- menuDividerVariantText: 'default',
75
- }),
76
-
77
- line: getStyles({
78
- menuDividerVariantLine: 'default',
79
- }),
80
- };
81
-
82
- return (
83
- <DividerInternal
84
- ref={ref}
85
- role={role}
86
- variant="inherit"
87
- contentPosition={contentPosition}
88
- gap={gap}
89
- spacingVertical={spacingVertical}
90
- spacingHorizontal={spacingHorizontal}
91
- className={layerClassNames.root}
92
- layerClassNames={layerClassNames}
93
- {...props}
94
- >
95
- {children}
96
- </DividerInternal>
97
- );
98
- });
99
-
100
- MenuDivider.displayName = 'MenuDivider';
101
-
102
- export { MenuDivider, type MenuDividerProps };
@@ -1,114 +0,0 @@
1
- import type { MenuItemProps as AriakitMenuItemProps } from '@ariakit/react/menu';
2
- import { MenuItem as AriakitMenuItem } from '@ariakit/react/menu';
3
- import type { UniversalMenuItemProps } from '@yahoo/uds/tokens';
4
- import type { AriaRole } from 'react';
5
- import { forwardRef } from 'react';
6
-
7
- import { getStyles } from '../../../styles/styler';
8
- import type { PressableProps } from '../Pressable';
9
- import { MenuItemBase } from './Menu.ItemBase';
10
-
11
- interface MenuItemProps
12
- extends Omit<PressableProps, 'asChild'>,
13
- Omit<UniversalMenuItemProps, 'name'> {
14
- /**
15
- * Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
16
- * If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
17
- * [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
18
- */
19
- store?: AriakitMenuItemProps['store'];
20
- /**
21
- * Determines if the menu should hide when this item is clicked.
22
- *
23
- * **Note**: This behavior isn't triggered if this menu item is rendered as a
24
- * link and modifier keys are used to either open the link in a new tab or
25
- * download it.
26
- *
27
- * @default true
28
- */
29
- hideOnClick?: AriakitMenuItemProps['hideOnClick'];
30
- /**
31
- * The role of the menu item.
32
- *
33
- * @default 'menuitem'
34
- */
35
- role?: AriaRole;
36
- }
37
-
38
- /**
39
- * **📋 A Menu Item component for navigation and actions**
40
- *
41
- * @componentType Client component
42
- *
43
- * @description
44
- * A standard menu item that can be used for navigation, actions, or displaying options in a menu.
45
- * Menu items can be styled with active states, icons, and can trigger callbacks when clicked.
46
- * They support both visual and functional customization.
47
- *
48
- * @see The {@link https://uds.build/docs/components/menu-item Menu.Item Docs} for more info
49
- *
50
- * @example
51
- * ```tsx
52
- * 'use client'; // Next.js client component
53
- *
54
- * import { Menu, Button } from "@yahoo/uds";
55
- * import { Calendar, Clipboard } from "@yahoo/uds-icons";
56
- *
57
- * export function MenuItemExample() {
58
- * return (
59
- * <Menu.Provider>
60
- * <Menu.Trigger asChild>
61
- * <Button>Menu Options</Button>
62
- * </Menu.Trigger>
63
- * <Menu.Content>
64
- * <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
65
- * <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
66
- * Clipboard
67
- * </Menu.Item>
68
- * <Menu.Item active>Active Item</Menu.Item>
69
- * </Menu.Content>
70
- * </Menu>
71
- * )
72
- * }
73
- * ```
74
- *
75
- * @usage
76
- * Use MenuItem for standard menu options that trigger actions or navigate to other parts of the application.
77
- * The active prop can be used to highlight the currently selected item.
78
- *
79
- * @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
80
- **/
81
- const MenuItem = forwardRef<HTMLDivElement, MenuItemProps>(function MenuItem(
82
- { active, hideOnClick, ...props },
83
- ref,
84
- ) {
85
- const layerClassNames = {
86
- root: getStyles({
87
- menuItemVariantRoot: 'default',
88
- menuItemVariantActiveRoot: active ? 'on' : 'off',
89
- }),
90
- text: getStyles({
91
- menuItemVariantText: 'default',
92
- menuItemVariantActiveText: active ? 'on' : 'off',
93
- }),
94
- startIcon: getStyles({
95
- menuItemVariantIcon: 'default',
96
- menuItemVariantActiveIcon: active ? 'on' : 'off',
97
- }),
98
- };
99
-
100
- return (
101
- <MenuItemBase
102
- ref={ref}
103
- as={AriakitMenuItem}
104
- active={active}
105
- layerClassNames={layerClassNames}
106
- rootProps={{ hideOnClick }}
107
- {...props}
108
- />
109
- );
110
- });
111
-
112
- MenuItem.displayName = 'MenuItem';
113
-
114
- export { MenuItem, type MenuItemProps };