@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,265 +0,0 @@
1
- import type {
2
- MenuItem as AriakitMenuItem,
3
- MenuItemCheckbox as AriakitMenuItemCheckbox,
4
- } from '@ariakit/react';
5
- import type { UniversalMenuItemProps } from '@yahoo/uds/tokens';
6
- import { AnimatePresence, m } from 'motion/react';
7
- import { Children, forwardRef, useMemo } from 'react';
8
-
9
- import { cx, getStyles } from '../../../styles/styler';
10
- import { HStack } from '../../HStack';
11
- import { IconSlot } from '../../IconSlot';
12
- import type { PressableProps } from '../Pressable';
13
- import { Pressable } from '../Pressable';
14
-
15
- /* -------------------------------------------------------------------------- */
16
- /* TYPE DEFINITIONS */
17
- /* -------------------------------------------------------------------------- */
18
-
19
- type MenuItemRootComponent = typeof AriakitMenuItem | typeof AriakitMenuItemCheckbox;
20
-
21
- interface MenuItemBaseProps extends Omit<PressableProps, 'asChild'>, UniversalMenuItemProps {
22
- /** Whether to show the end icon */
23
- hideEndIcon?: boolean;
24
- /** The component to render as the root */
25
- as: MenuItemRootComponent;
26
- /** Additional props to pass to the root component */
27
- rootProps?: Record<string, unknown>;
28
-
29
- /** Internal overrides for downstream components. */
30
- layerClassNames?: {
31
- root?: string;
32
- text?: string;
33
- startIcon?: string;
34
- endIcon?: string;
35
- };
36
- }
37
-
38
- /* -------------------------------------------------------------------------- */
39
- /* CONSTANTS & MAPPINGS */
40
- /* -------------------------------------------------------------------------- */
41
-
42
- const ITEM_CLASS_NAME = 'uds-menu-item';
43
-
44
- const iconAnimationVariants = {
45
- visible: { scale: 1, opacity: 1 },
46
- hidden: { scale: 0.7, opacity: 0 },
47
- };
48
- /* -------------------------------------------------------------------------- */
49
- /* HELPER FUNCTIONS */
50
- /* -------------------------------------------------------------------------- */
51
-
52
- type MenuItemClassesProps = Pick<MenuItemBaseProps, 'active' | 'disabled' | 'className'>;
53
-
54
- /** Builds the class names for the menu item */
55
- const buildMenuItemClasses = ({ active, disabled, className }: MenuItemClassesProps) => {
56
- return cx(
57
- ITEM_CLASS_NAME,
58
- 'flex',
59
- // hover state - only apply if not active and not disabled
60
- // TODO: update hover color to a non-palette color
61
- // focus state
62
- 'focus-visible:text-brand',
63
- 'focus-visible:bg-brand-secondary',
64
- 'focus-visible:z-10',
65
- 'uds-ring',
66
- // TODO find a solution that doesn't require !
67
- '!-outline-offset-2',
68
- // active state
69
- active && ['[&:not([aria-checked])]:cursor-default'],
70
- // disabled state
71
- disabled && 'opacity-25 cursor-not-allowed',
72
- // Checked state
73
- // 'aria-checked:text-brand',
74
- // 'aria-checked:bg-brand-secondary',
75
- // 'aria-checked:font-medium',
76
- // // TODO: update hover color to a non-palette color
77
- // 'aria-checked:hover:bg-purple-2',
78
- // Misc
79
- 'duration-20 transition-[font-variation-settings] ease-in-out',
80
- 'z-0',
81
- className,
82
- );
83
- };
84
-
85
- /* -------------------------------------------------------------------------- */
86
- /* MENU ITEM COMPONENT(S) */
87
- /* -------------------------------------------------------------------------- */
88
-
89
- /**
90
- * @private This is an internal component shared by [Menu.Item](https://uds.build/docs/components/menu#menu-item) and [Menu.ItemCheckbox](https://uds.build/docs/components/menu#menu-item-checkbox)
91
- * and may change without notice. Please do not use this component directly.
92
- */
93
- const MenuItemBase = forwardRef<HTMLDivElement, MenuItemBaseProps>(function MenuItemBase(
94
- {
95
- spacing = '0',
96
- spacingBottom,
97
- spacingEnd,
98
- spacingHorizontal = '4',
99
- spacingStart,
100
- spacingTop,
101
- spacingVertical = '3.5',
102
- columnGap = '2',
103
- className,
104
- children,
105
- endIcon,
106
- startIcon,
107
- hideEndIcon,
108
- active,
109
- disabled,
110
- as: RootComponent,
111
- name,
112
- alignItems = 'center',
113
- justifyContent = 'space-between',
114
- layerClassNames,
115
- slots,
116
- rootProps,
117
- ...props
118
- },
119
- ref,
120
- ) {
121
- const hasMultipleChildren = Children.count(children) > 1;
122
- const menuItemClassName = buildMenuItemClasses({ active, disabled, className });
123
-
124
- /**
125
- * Get content styles based on children layout needs
126
- */
127
- const contentStyles = getStyles({
128
- // Base styles
129
- className: cx(`${ITEM_CLASS_NAME}-content truncate`, layerClassNames?.text),
130
- textAlign: 'start',
131
- // Layout styles - only apply alignment props if we have multiple children
132
- ...(hasMultipleChildren && {
133
- columnGap,
134
- display: 'flex',
135
- alignItems: 'center',
136
- width: 'full',
137
- justifyContent: 'space-between',
138
- }),
139
- });
140
-
141
- /**
142
- * Styles
143
- */
144
- const classNames = useMemo(
145
- () => ({
146
- root: getStyles({
147
- menuSizeRoot: 'default',
148
- flexDirection: 'row',
149
- spacing,
150
- spacingBottom,
151
- spacingEnd,
152
- spacingHorizontal,
153
- spacingStart,
154
- spacingTop,
155
- spacingVertical,
156
- columnGap,
157
- alignItems,
158
- justifyContent,
159
- className: cx(menuItemClassName, layerClassNames?.root),
160
- }),
161
-
162
- startIcon: getStyles({
163
- menuSizeStartIcon: 'default',
164
- className: layerClassNames?.startIcon,
165
- }),
166
-
167
- endIcon: getStyles({
168
- menuSizeEndIcon: 'default',
169
- className: layerClassNames?.endIcon,
170
- }),
171
- }),
172
- [
173
- alignItems,
174
- columnGap,
175
- justifyContent,
176
- layerClassNames?.endIcon,
177
- layerClassNames?.root,
178
- layerClassNames?.startIcon,
179
- menuItemClassName,
180
- spacing,
181
- spacingBottom,
182
- spacingEnd,
183
- spacingHorizontal,
184
- spacingStart,
185
- spacingTop,
186
- spacingVertical,
187
- ],
188
- );
189
-
190
- // Must follow ariakit extension guidelines:
191
- // https://ariakit.org/guide/composition#custom-components-must-be-open-for-extension
192
- const rootRender =
193
- slots?.root ??
194
- ((p) => (
195
- <Pressable
196
- {...p}
197
- {...props}
198
- onClick={(e) => {
199
- p.onClick?.(e);
200
- props.onClick?.(e);
201
- }}
202
- />
203
- ));
204
-
205
- return (
206
- <RootComponent
207
- ref={ref}
208
- name={name ?? ''}
209
- {...rootProps}
210
- render={rootRender}
211
- disabled={disabled}
212
- className={classNames.root}
213
- >
214
- <HStack gap={columnGap} alignItems="center" width="full">
215
- <AnimatePresence initial={false}>
216
- {startIcon && (
217
- <m.span
218
- variants={iconAnimationVariants}
219
- initial="hidden"
220
- animate="visible"
221
- exit="hidden"
222
- className="uds-start-icon"
223
- >
224
- <IconSlot
225
- icon={startIcon}
226
- className={classNames.startIcon}
227
- iconProps={{
228
- size: 'sm',
229
- variant: active ? 'fill' : 'outline',
230
- color: 'current',
231
- }}
232
- />
233
- </m.span>
234
- )}
235
- </AnimatePresence>
236
- <span className={contentStyles}>{children}</span>
237
- </HStack>
238
- <AnimatePresence initial={false} mode="popLayout">
239
- {!hideEndIcon && endIcon && (
240
- <m.span
241
- variants={iconAnimationVariants}
242
- initial="hidden"
243
- animate="visible"
244
- exit="hidden"
245
- className="uds-end-icon"
246
- >
247
- <IconSlot
248
- icon={endIcon}
249
- className={classNames.endIcon}
250
- iconProps={{
251
- size: 'sm',
252
- variant: active ? 'fill' : 'outline',
253
- color: 'current',
254
- }}
255
- />
256
- </m.span>
257
- )}
258
- </AnimatePresence>
259
- </RootComponent>
260
- );
261
- });
262
-
263
- MenuItemBase.displayName = 'MenuItemBase';
264
-
265
- export { ITEM_CLASS_NAME, MenuItemBase };
@@ -1,197 +0,0 @@
1
- import { useStoreState } from '@ariakit/react';
2
- import type { MenuItemCheckboxProps as AriakitMenuItemCheckboxProps } from '@ariakit/react/menu';
3
- import { MenuItemCheckbox as AriakitMenuItemCheckbox, useMenuContext } from '@ariakit/react/menu';
4
- import type { UniversalMenuItemProps } from '@yahoo/uds/tokens';
5
- import { Check } from '@yahoo/uds-icons';
6
- import type { ChangeEvent, HTMLAttributes } from 'react';
7
- import { forwardRef, useCallback, useEffect, useMemo, useRef } from 'react';
8
-
9
- import { cx, getStyles } from '../../../styles/styler';
10
- import type { PressableProps } from '../Pressable';
11
- import { MenuItemBase } from './Menu.ItemBase';
12
-
13
- type HtmlButtonProps = HTMLAttributes<HTMLButtonElement>;
14
-
15
- interface MenuItemCheckboxProps
16
- extends Omit<PressableProps, 'asChild'>,
17
- HtmlButtonProps,
18
- UniversalMenuItemProps {
19
- /**
20
- * The name of the field in the
21
- * [`values`](https://ariakit.org/reference/menu-provider#values) state.
22
- *
23
- * Live examples at [MenuItemCheckbox](https://ariakit.org/examples/menu-item-checkbox)
24
- */
25
- name: string;
26
- /**
27
- * The controlled checked state of the element. It will set the menu
28
- * [`values`](https://ariakit.org/reference/menu-provider#values) state if
29
- * provided.
30
- */
31
- checked?: boolean;
32
- /**
33
- * The default checked state of the element. It will set the default value in
34
- * the menu [`values`](https://ariakit.org/reference/menu-provider#values)
35
- * state if provided.
36
- */
37
- defaultChecked?: boolean;
38
- /**
39
- * Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
40
- * If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
41
- * [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
42
- */
43
- store?: AriakitMenuItemCheckboxProps['store'];
44
- /**
45
- * Determines if the menu should hide when this item is clicked.
46
- *
47
- * **Note**: This behavior isn't triggered if this menu item is rendered as a
48
- * link and modifier keys are used to either open the link in a new tab or
49
- * download it.
50
- *
51
- * @default undefined
52
- */
53
- hideOnClick?: AriakitMenuItemCheckboxProps['hideOnClick'];
54
- }
55
-
56
- /**
57
- * **✅ A Menu Item Checkbox component**
58
- *
59
- * @componentType Client component
60
- *
61
- * @description
62
- * A checkable menu item that toggles between selected and unselected states. Menu item checkboxes
63
- * allow users to select multiple options from a menu, displaying a checkmark when active. They maintain
64
- * their state even when the menu is closed and reopened.
65
- *
66
- * @see The {@link https://uds.build/docs/components/menu-item-checkbox Menu.ItemCheckbox Docs} for more info
67
- *
68
- * @example
69
- * ```tsx
70
- * 'use client'; // Next.js client component
71
- *
72
- * import { Menu, Button } from "@yahoo/uds";
73
- *
74
- * export function MenuItemCheckboxExample() {
75
- * return (
76
- * <Menu.Provider>
77
- * <Menu.Trigger asChild>
78
- * <Button>Filter Options</Button>
79
- * </Menu.Trigger>
80
- * <Menu.Content>
81
- * <Menu.ItemCheckbox name="showArchived" defaultChecked={false}>
82
- * Show Archived
83
- * </Menu.ItemCheckbox>
84
- * <Menu.ItemCheckbox name="includeComments" defaultChecked={true}>
85
- * Include Comments
86
- * </Menu.ItemCheckbox>
87
- * </Menu.Content>
88
- * </Menu.Provider>
89
- * )
90
- * }
91
- * ```
92
- *
93
- * @usage
94
- * Use MenuItemCheckbox when you need to provide users with multiple selectable options within a menu.
95
- * Unlike radio options, checkboxes allow for multiple simultaneous selections.
96
- *
97
- * @related [Menu](https://uds.build/docs/components/menu), [Menu.Item](https://uds.build/docs/components/menu-item)
98
- **/
99
- const MenuItemCheckbox = forwardRef<
100
- HTMLDivElement,
101
- Omit<MenuItemCheckboxProps, 'rootProps' | 'hideEndIcon' | 'active'>
102
- >(function MenuItemCheckbox(
103
- { name, endIcon = Check, checked, defaultChecked, hideOnClick, className, ...props },
104
- ref,
105
- ) {
106
- const itemName = name;
107
- const hasInitialized = useRef(false);
108
-
109
- // Connect to the menu store
110
- const context = useMenuContext();
111
- const allState = useStoreState(context);
112
-
113
- // Initialize default value in menu store if provided
114
- useEffect(() => {
115
- if (!hasInitialized.current && defaultChecked !== undefined && context) {
116
- context.setValues((prev) => ({ ...prev, [itemName]: defaultChecked }));
117
- hasInitialized.current = true;
118
- }
119
- }, [context, defaultChecked, itemName]);
120
-
121
- // Get checked state from the menu store
122
- const isChecked = useMemo(() => {
123
- // If controlled, use the checked prop
124
- if (checked !== undefined) {
125
- return checked;
126
- }
127
-
128
- // Check DOM element state first
129
- if (allState?.items?.length) {
130
- const item = allState?.items.find(
131
- (item) => (item.element as HTMLInputElement)?.name === itemName,
132
- );
133
-
134
- if (item?.element) {
135
- return (item.element as HTMLInputElement).checked;
136
- }
137
- }
138
-
139
- // Fall back to store value or default
140
- const storeValue = allState?.values[itemName];
141
- return typeof storeValue === 'boolean' ? storeValue : (defaultChecked ?? false);
142
- }, [allState?.items, allState?.values, itemName, checked, defaultChecked]);
143
-
144
- // Update the menu store when the checkbox is interacted with
145
- const handleChange = useCallback(
146
- (d: ChangeEvent<HTMLInputElement>) => {
147
- // Only update store if not controlled
148
- if (checked === undefined) {
149
- context?.setValues((prev) => ({ ...prev, [itemName]: d.target.checked }));
150
- }
151
- },
152
- [itemName, context, checked],
153
- );
154
-
155
- const layerClassNames = {
156
- root: getStyles({
157
- menuItemCheckboxVariantRoot: 'default',
158
- menuItemCheckboxVariantActiveRoot: isChecked ? 'on' : 'off',
159
- }),
160
- text: getStyles({
161
- menuItemCheckboxVariantText: 'default',
162
- menuItemCheckboxVariantActiveText: isChecked ? 'on' : 'off',
163
- }),
164
- startIcon: getStyles({
165
- menuItemCheckboxVariantStartIcon: 'default',
166
- menuItemCheckboxVariantActiveStartIcon: isChecked ? 'on' : 'off',
167
- }),
168
- endIcon: getStyles({
169
- menuItemCheckboxVariantEndIcon: 'default',
170
- menuItemCheckboxVariantActiveEndIcon: isChecked ? 'on' : 'off',
171
- }),
172
- };
173
-
174
- return (
175
- <MenuItemBase
176
- ref={ref}
177
- as={AriakitMenuItemCheckbox}
178
- hideEndIcon={!isChecked}
179
- endIcon={endIcon}
180
- active={isChecked}
181
- className={cx('uds-menu-item-checkbox', className)}
182
- layerClassNames={layerClassNames}
183
- name={name}
184
- rootProps={{
185
- onChange: handleChange,
186
- defaultChecked,
187
- checked: checked !== undefined ? checked : undefined,
188
- hideOnClick,
189
- }}
190
- {...props}
191
- />
192
- );
193
- });
194
-
195
- MenuItemCheckbox.displayName = 'MenuItemCheckbox';
196
-
197
- export { MenuItemCheckbox, type MenuItemCheckboxProps };
@@ -1,154 +0,0 @@
1
- import type { MenuProviderProps as AriakitMenuProviderProps } from '@ariakit/react/menu';
2
- import { MenuProvider as AriakitMenuProvider } from '@ariakit/react/menu';
3
- import type { PropsWithChildren } from 'react';
4
-
5
- import { useRtl } from '../../../hooks/useRtl';
6
- import { SpringMotionConfig } from '../SpringMotionConfig';
7
- import { transformAriakitPlacement } from './utils/transformAriakitPlacement';
8
-
9
- /** Valid vertical placement values for the menu */
10
- type VerticalPlacement = 'top' | 'bottom';
11
- /** Valid horizontal placement values for the menu */
12
- type HorizontalPlacement = 'start' | 'end';
13
- /** Combined placement values for menu positioning */
14
- type MenuPlacement =
15
- | VerticalPlacement
16
- | HorizontalPlacement
17
- | `${VerticalPlacement}-${HorizontalPlacement}`
18
- | `${HorizontalPlacement}-${VerticalPlacement}`;
19
-
20
- type MenuProviderProps = PropsWithChildren<{
21
- /**
22
- * A callback that gets called when the
23
- * [`values`](https://ariakit.org/reference/menu-provider#values) state
24
- * changes.
25
- *
26
- * Live examples:
27
- * - [`MenuItemCheckbox`](https://uds.build/docs/components/menu-item-checkbox).
28
- */
29
- setValues?: (values: Record<string, boolean>) => void | AriakitMenuProviderProps['setValues'];
30
- /**
31
- * A map of names and values that will be used by the
32
- * [`MenuItemCheckbox`](https://uds.build/docs/components/menu-item-checkbox).
33
- *
34
- * Live examples:
35
- * - [MenuItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
36
- */
37
- values?: AriakitMenuProviderProps['values'];
38
- /**
39
- * The placement of the Menu.Content.
40
- *
41
- * @default 'bottom'
42
- */
43
- placement?: MenuPlacement;
44
- /**
45
- * Object returned by the [`useMenuStore`](https://ariakit.org/reference/use-menu-store) hook.
46
- * If not provided, the closest [`Menu.Content`](https://uds.build/docs/components/menu#menu-content) or
47
- * [`Menu.Provider`](https://uds.build/docs/components/menu#menu-provider) context will be used.
48
- */
49
- store?: AriakitMenuProviderProps['store'];
50
- /**
51
- * Whether the menu should be rendered in RTL direction.
52
- *
53
- * This only affects the some component behavior behavior. You still need to set
54
- * `dir="rtl"` on HTML/CSS.
55
- * @default false
56
- */
57
- rtl?: AriakitMenuProviderProps['rtl'];
58
- /**
59
- * Whether the content is visible.
60
- * @default false
61
- */
62
- open?: AriakitMenuProviderProps['open'];
63
- /**
64
- * A callback that gets called when the
65
- * [`open`](https://ariakit.org/reference/disclosure-provider#open) state
66
- * changes.
67
- * @example
68
- * const [open, setOpen] = useState(false);
69
- * const disclosure = useDisclosureStore({ open, setOpen });
70
- */
71
- setOpen?: AriakitMenuProviderProps['setOpen'];
72
- /**
73
- * Whether the content should be visible by default.
74
- * @default false
75
- */
76
- defaultOpen?: AriakitMenuProviderProps['defaultOpen'];
77
- /**
78
- * Determines how the focus behaves when the user reaches the end of the
79
- * composite widget.
80
- *
81
- * Live examples:
82
- * - [Command Menu](https://uds.build/docs/components/menu)
83
- * @default false
84
- */
85
- focusLoop?: AriakitMenuProviderProps['focusLoop'];
86
- /**
87
- * If enabled, moving to the next item from the last one in a row or column
88
- * will focus on the first item in the next row or column and vice-versa.
89
- * `true` wraps between rows and columns, `horizontal` wraps only between rows, and `vertical` wraps only between columns.
90
- *
91
- * @default false
92
- */
93
- focusWrap?: AriakitMenuProviderProps['focusWrap'];
94
- }>;
95
-
96
- /**
97
- * **🏗️ A Menu Provider component**
98
- *
99
- * @componentType Server component
100
- *
101
- * @description
102
- * A provider component for the menu, which is used to provide the menu context to the menu items.
103
- *
104
- * @see The {@link https://uds.build/docs/components/menu-provider Menu.Provider Docs} for more info
105
- *
106
- * @example
107
- * ```tsx
108
- * 'use client'; // Next.js client component
109
- *
110
- * import { Menu, Button } from "@yahoo/uds";
111
- * import { Calendar, Clipboard } from "@yahoo/uds-icons";
112
- *
113
- * export function MenuProviderExample() {
114
- * return (
115
- * <Menu.Provider>
116
- * <Menu.Trigger asChild>
117
- * <Button>Menu Options</Button>
118
- * </Menu.Trigger>
119
- * <Menu.Content>
120
- * <Menu.Item startIcon={Calendar}>Calendar</Menu.Item>
121
- * <Menu.Item startIcon={Clipboard} endIcon={DiagonalRightUp}>
122
- * Clipboard
123
- * </Menu.Item>
124
- * <Menu.Item active>Active Item</Menu.Item>
125
- * </Menu.Content>
126
- * </Menu.Provider>
127
- * )
128
- * }
129
- * ```
130
- *
131
- * @usage
132
- * Use MenuItem for standard menu options that trigger actions or navigate to other parts of the application.
133
- * The active prop can be used to highlight the currently selected item.
134
- *
135
- * @related [Menu](https://uds.build/docs/components/menu), [Menu.ItemCheckbox](https://uds.build/docs/components/menu-item-checkbox)
136
- **/
137
- const MenuProvider = function MenuProvider({
138
- placement = 'bottom',
139
- rtl: explicitRtl,
140
- ...props
141
- }: MenuProviderProps) {
142
- const isRtl = useRtl({ explicit: explicitRtl });
143
- const ariakitPlacement = transformAriakitPlacement(placement, { rtl: isRtl });
144
-
145
- return (
146
- <SpringMotionConfig>
147
- <AriakitMenuProvider placement={ariakitPlacement} rtl={isRtl} {...props} />
148
- </SpringMotionConfig>
149
- );
150
- };
151
-
152
- MenuProvider.displayName = 'MenuProvider';
153
-
154
- export { type MenuPlacement, MenuProvider, type MenuProviderProps };