@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,151 +0,0 @@
1
- import type { MotionVariant, MotionVariantSpeed } from '@yahoo/uds/tokens';
2
- import type { LazyFeatureBundle, MotionConfigProps, Transition } from 'motion/react';
3
- import { LazyMotion, MotionConfig } from 'motion/react';
4
- import { useEffect, useMemo, useState } from 'react';
5
-
6
- import { motion } from '../../tokens/configs/motion';
7
- import { getMotionVar } from '../../utils/getMotionVar';
8
- import { useAvoidMotionLibrary } from '../experimental/client/AvoidMotionLibraryProvider';
9
-
10
- // !NOTE: This is probably one of those _internal_ components
11
-
12
- /* -------------------------------------------------------------------------- */
13
- /* Token defaults - these may one day come from the configurator */
14
- /* -------------------------------------------------------------------------- */
15
- const LAYOUT_VARIANT = 'subtle';
16
- const LAYOUT_SPEED = '3';
17
- const COLOR_VARIANT = 'smooth';
18
- const COLOR_SPEED = '3';
19
-
20
- /* -------------------------------------------------------------------------- */
21
- /* Framer motion features */
22
- /* -------------------------------------------------------------------------- */
23
- const defaultLoadFeatures = () =>
24
- import('@yahoo/uds/__private/motionFeatures/domAnimation').then(
25
- ({ domAnimation }) => domAnimation,
26
- );
27
-
28
- /* -------------------------------------------------------------------------- */
29
- /* Whooooof, finally the Spring Motion Component */
30
- /* -------------------------------------------------------------------------- */
31
- interface SpringMotionConfigProps extends Pick<MotionConfigProps, 'children' | 'reducedMotion'> {
32
- /**
33
- * The layout variant to use for the motion config.
34
- * @default 'subtle'
35
- */
36
- layoutVariant?: MotionVariant;
37
- /**
38
- * The layout speed to use for the motion config.
39
- * @default '3'
40
- */
41
- layoutSpeed?: MotionVariantSpeed;
42
- /**
43
- * The color variant to use for the motion config.
44
- * @default 'smooth'
45
- */
46
- colorVariant?: MotionVariant;
47
- /**
48
- * The color speed to use for the motion config.
49
- * @default '3'
50
- */
51
- colorSpeed?: MotionVariantSpeed;
52
- /**
53
- * A lazy feature bundle to load additional features.
54
- * This is useful for reducing bundle size by loading only the necessary features.
55
- */
56
- loadFeatures?: LazyFeatureBundle;
57
- }
58
-
59
- /**
60
- * **🎬 Spring Motion Config to define motion animations for all UDS components**
61
- *
62
- * @componentType Client component
63
- *
64
- * @description
65
- * The SpringConfig component provides a way to configure the spring animations for the entire application.
66
- * This component provides a way to use uds motion configs with Framer Motion.
67
- */
68
- function SpringMotionConfig({
69
- children,
70
- reducedMotion = 'user',
71
- loadFeatures = defaultLoadFeatures,
72
- layoutVariant = LAYOUT_VARIANT,
73
- layoutSpeed = LAYOUT_SPEED,
74
- colorVariant = COLOR_VARIANT,
75
- colorSpeed = COLOR_SPEED,
76
- }: SpringMotionConfigProps) {
77
- const initialLayoutConfig = motion[layoutVariant][layoutSpeed];
78
- const initialColorConfig = motion[colorVariant][colorSpeed];
79
-
80
- // We need to store the values in state because they're read from the DOM
81
- const [layoutConfig, setLayoutConfig] = useState(initialLayoutConfig);
82
- const [colorConfig, setColorConfig] = useState(initialColorConfig);
83
-
84
- /* -------------------------------------------------------------------------- */
85
- /* Color motion config (background, color, opacity) */
86
- /* -------------------------------------------------------------------------- */
87
- const colorVarConfig = { variant: colorVariant, speed: colorSpeed };
88
- const colorStiffnessVar = getMotionVar({ ...colorVarConfig, control: 'stiffness' });
89
- const colorDampingVar = getMotionVar({ ...colorVarConfig, control: 'damping' });
90
-
91
- /* -------------------------------------------------------------------------- */
92
- /* Layout motion config (scale, position, shape) */
93
- /* -------------------------------------------------------------------------- */
94
- const layoutVarConfig = { variant: layoutVariant, speed: layoutSpeed };
95
- const layoutStiffnessVar = getMotionVar({ ...layoutVarConfig, control: 'stiffness' });
96
- const layoutDampingVar = getMotionVar({ ...layoutVarConfig, control: 'damping' });
97
-
98
- useEffect(() => {
99
- // getComputedStyle is only available in the browser, so we'll keep it inside the useEffect hook
100
- const globalComputedStyles = getComputedStyle(document.documentElement);
101
-
102
- // Get from the root (DOM)
103
- const layoutValues = {
104
- type: 'spring',
105
- damping: Number(globalComputedStyles.getPropertyValue(layoutDampingVar)),
106
- stiffness: Number(globalComputedStyles.getPropertyValue(layoutStiffnessVar)),
107
- };
108
- const colorValues = {
109
- type: 'spring',
110
- damping: Number(globalComputedStyles.getPropertyValue(colorDampingVar)),
111
- stiffness: Number(globalComputedStyles.getPropertyValue(colorStiffnessVar)),
112
- };
113
-
114
- // Set motion states
115
- setLayoutConfig(layoutValues);
116
- setColorConfig(colorValues);
117
- }, [colorDampingVar, colorStiffnessVar, layoutDampingVar, layoutStiffnessVar]);
118
-
119
- const transition = useMemo(
120
- () =>
121
- ({
122
- type: 'spring',
123
- mass: 1, // Each motion component should define their own mass
124
- ...layoutConfig, // Use layout as default transition
125
- layout: layoutConfig,
126
- // Setup Color animations
127
- opacity: colorConfig,
128
- color: colorConfig,
129
- borderColor: colorConfig,
130
- backgroundColor: colorConfig,
131
- }) satisfies Transition,
132
- [colorConfig, layoutConfig],
133
- );
134
-
135
- const avoidMotionLibrary = useAvoidMotionLibrary();
136
- if (avoidMotionLibrary) {
137
- return children;
138
- }
139
-
140
- return (
141
- <LazyMotion features={loadFeatures} strict>
142
- <MotionConfig transition={transition} reducedMotion={reducedMotion}>
143
- {children}
144
- </MotionConfig>
145
- </LazyMotion>
146
- );
147
- }
148
-
149
- SpringMotionConfig.displayName = 'SpringMotionConfig';
150
-
151
- export { SpringMotionConfig, type SpringMotionConfigProps };
@@ -1,377 +0,0 @@
1
- import type { SwitchSize, UniversalSwitchProps } from '@yahoo/uds/tokens';
2
- import { m, useReducedMotion } from 'motion/react';
3
- import type { ChangeEvent, FocusEvent } from 'react';
4
- import React, { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
5
-
6
- import { IconSlot } from '../../components/IconSlot';
7
- import { cx, getStyles } from '../../styles/styler';
8
- import { Box } from '../Box';
9
- import { FormLabel } from '../FormLabel';
10
- import { SpringMotionConfig } from './SpringMotionConfig';
11
-
12
- type NativeInputProps = Omit<
13
- React.InputHTMLAttributes<HTMLInputElement>,
14
- 'type' | 'checked' | 'size' | 'height' | 'width' | 'color' | 'defaultChecked' | 'children'
15
- >;
16
-
17
- type SwitchChangeEvent = ChangeEvent<HTMLInputElement>;
18
-
19
- interface SwitchProps extends NativeInputProps, UniversalSwitchProps {
20
- layerClassNames?: {
21
- root?: string;
22
- switch?: string;
23
- handle?: string;
24
- label?: string;
25
- };
26
- }
27
-
28
- const SIZE_MAP: Record<
29
- SwitchSize,
30
- {
31
- // TODO: this needs to be automatic
32
- isOnX: number;
33
- }
34
- > = {
35
- md: {
36
- isOnX: 20,
37
- },
38
- sm: {
39
- isOnX: 12,
40
- },
41
- } as const;
42
-
43
- const MotionBox = m.create(Box);
44
-
45
- const toggleTransition = { layoutVariant: 'bouncy', layoutSpeed: '4' } as const;
46
-
47
- /**
48
- * **⚙️️ An switch.
49
- *
50
- * @componentType Client component
51
- *
52
- * @description
53
- * A switch (also called a toggle) is a binary on/off input control. It is clickable or touchable on mobile devices allowing users to pick between two clearly opposite choices.
54
- *
55
- * @see
56
- * Check out the {@link https://uds.build/docs/components/switch Switch Docs} for more info
57
- *
58
- * @usage
59
- * - Forms: switch
60
- *
61
- * @example
62
- * ```tsx
63
- * 'use client';
64
- * import { Switch } from "@yahoo/uds";
65
- *
66
- * <Switch label="Name" required />
67
- *```
68
- *
69
- * @related [Checkbox](https://uds.build/docs/components/checkbox).
70
- **/
71
- const Switch = forwardRef<HTMLInputElement, SwitchProps>(function Switch(
72
- {
73
- id,
74
- isOn: isOnProp,
75
- defaultIsOn,
76
- onChange,
77
- label,
78
- labelPosition = 'start',
79
- size = 'md',
80
- onIcon,
81
- offIcon,
82
- reduceMotion: forceReduceMotion,
83
- disabled,
84
- required,
85
- onFocus,
86
- onBlur,
87
- className,
88
- layerClassNames,
89
- ...switchProps
90
- },
91
- parentRef,
92
- ) {
93
- const generatedId = useId();
94
- const uid = id ?? `uds-input-${generatedId}`;
95
-
96
- const innerRef = useRef<HTMLInputElement | null>(null);
97
-
98
- /**
99
- * State
100
- */
101
- const isControlled = isOnProp !== undefined;
102
- const [isOn, setIsOn] = useState(isControlled ? isOnProp : defaultIsOn);
103
- const [isHovered, setIsHovered] = useState(false);
104
-
105
- /**
106
- * Derived values
107
- */
108
- const showHoverEffect = useMemo(() => {
109
- return !disabled && isHovered;
110
- }, [disabled, isHovered]);
111
-
112
- const { isOnX } = SIZE_MAP[size];
113
-
114
- const motionInitialAndAnimate = useMemo(
115
- () => ({
116
- initial: {
117
- scale: 1,
118
- x: isOn ? isOnX : 0,
119
- },
120
- animate: {
121
- scale: showHoverEffect ? 1.05 : 1,
122
- x: isOn ? isOnX : 0,
123
- },
124
- }),
125
- [showHoverEffect, isOn, isOnX],
126
- );
127
-
128
- /**
129
- * Handlers
130
- */
131
- const handleChange = useCallback(
132
- (e: SwitchChangeEvent) => {
133
- onChange?.(e);
134
-
135
- // If uncontrolled, immediate change internal state.
136
- if (!isControlled) {
137
- setIsOn(e.target.checked);
138
- }
139
- },
140
- [isControlled, onChange],
141
- );
142
-
143
- const handleFocus = useCallback(
144
- (e: FocusEvent<HTMLInputElement>) => {
145
- onFocus?.(e);
146
- },
147
- [onFocus],
148
- );
149
-
150
- const handleBlur = useCallback(
151
- (e: FocusEvent<HTMLInputElement>) => {
152
- onBlur?.(e);
153
- },
154
- [onBlur],
155
- );
156
-
157
- const handleHoverStart = useCallback(() => {
158
- setIsHovered(true);
159
- }, []);
160
-
161
- const handleHoverEnd = useCallback(() => {
162
- setIsHovered(false);
163
- }, []);
164
-
165
- // Motion
166
- const prefersReducedMotion = useReducedMotion();
167
- const reduceMotion = forceReduceMotion ? 'always' : 'user';
168
-
169
- const cssAnimationDuration =
170
- prefersReducedMotion || forceReduceMotion ? 'duration-0' : 'duration-120';
171
-
172
- /**
173
- * Effects
174
- */
175
- // Reset state if prop changes.
176
- useEffect(() => {
177
- if (isControlled) {
178
- setIsOn(isOnProp);
179
- }
180
- }, [isOnProp, isControlled]);
181
-
182
- const classNames = {
183
- root: getStyles({
184
- switchSizeRoot: size,
185
- switchVariantRoot: 'default',
186
- switchVariantActiveRoot: isOn ? 'on' : 'off',
187
- display: 'flex',
188
- flexDirection: labelPosition === 'start' ? 'row' : 'row-reverse',
189
- alignItems: 'center',
190
- className: cx(
191
- 'group',
192
- {
193
- 'cursor-pointer': !disabled,
194
- 'cursor-default': disabled,
195
- 'opacity-50': disabled,
196
- },
197
-
198
- layerClassNames?.root,
199
- className,
200
- ),
201
- }),
202
-
203
- switch: getStyles({
204
- switchVariantSwitch: 'default',
205
- switchSizeSwitch: size,
206
- switchVariantActiveSwitch: isOn ? 'on' : 'off',
207
- borderRadius: 'full',
208
- position: 'relative',
209
- alignItems: 'center',
210
- className: cx(
211
- 'uds-ring',
212
- 'uds-ring-within',
213
-
214
- cssAnimationDuration,
215
- 'transition-[background-color,box-shadow]',
216
-
217
- layerClassNames?.switch,
218
- ),
219
- }),
220
-
221
- handle: getStyles({
222
- switchSizeHandle: size,
223
- className: cx(
224
- 'relative',
225
- 'pointer-events-none',
226
- 'rounded-full',
227
- 'overflow-hidden',
228
- layerClassNames?.handle,
229
- ),
230
- }),
231
-
232
- handleCircle: getStyles({
233
- switchVariantActiveHandle: isOn ? 'on' : 'off',
234
- switchVariantHandle: 'default',
235
- className: cx(
236
- 'absolute',
237
- 'top-0',
238
- 'left-0',
239
- 'right-0',
240
- 'bottom-0',
241
-
242
- 'opacity-95 group-hover:opacity-100',
243
-
244
- cssAnimationDuration,
245
- 'transition-[background-color,box-shadow,opacity]',
246
- ),
247
- }),
248
-
249
- handleIcon: getStyles({
250
- switchSizeHandleIcon: size,
251
- switchVariantHandleIcon: 'default',
252
- switchVariantActiveHandleIcon: isOn ? 'on' : 'off',
253
- className: cx(
254
- 'absolute',
255
- 'opacity-0',
256
- 'top-1/2',
257
- 'left-1/2',
258
- 'transform',
259
- 'translate-x-[-50%]',
260
- 'translate-y-[-50%]',
261
-
262
- cssAnimationDuration,
263
- 'transition-opacity',
264
- ),
265
- }),
266
-
267
- htmlCheckbox: cx(
268
- // Control the cursor at the top of the component
269
- // and don't let the input override it back to the
270
- // default value.
271
- 'cursor-[inherit]',
272
-
273
- 'absolute',
274
- 'opacity-0',
275
- 'top-1/2',
276
- 'left-1/2',
277
- 'w-[calc(100%+2px)]',
278
- 'h-[calc(100%+2px)]',
279
- 'transform',
280
- 'translate-x-[-50%]',
281
- 'translate-y-[-50%]',
282
- ),
283
-
284
- label: cx(labelPosition === 'start' ? 'text-start' : 'text-end', layerClassNames?.label),
285
- };
286
-
287
- const RootElement = label ? m.label : m.div;
288
-
289
- return (
290
- <SpringMotionConfig reducedMotion={reduceMotion} {...toggleTransition}>
291
- <RootElement
292
- className={classNames.root}
293
- data-testid="container"
294
- onHoverStart={handleHoverStart}
295
- onHoverEnd={handleHoverEnd}
296
- tabIndex={-1}
297
- >
298
- <MotionBox className={classNames.switch}>
299
- <input
300
- type="checkbox"
301
- // Required for Safari to render a focus ring
302
- tabIndex={0}
303
- // These are standard HTML input props for customization.
304
- {...switchProps}
305
- //
306
- // Provide a ref to the underlying input element for customization.
307
- ref={(ref) => {
308
- // Set internal ref.
309
- innerRef.current = ref;
310
-
311
- // Forward the ref to parent.
312
- if (typeof parentRef === 'function') {
313
- parentRef(ref);
314
- } else if (parentRef !== null) {
315
- parentRef.current = ref;
316
- }
317
- }}
318
- //
319
- // Track focus as a prop for easier styling.
320
- onFocus={handleFocus}
321
- onBlur={handleBlur}
322
- //
323
- // Core props for the switch.
324
- id={uid}
325
- disabled={disabled}
326
- required={required}
327
- checked={isControlled ? isOn : undefined}
328
- defaultChecked={isControlled ? undefined : defaultIsOn}
329
- onChange={handleChange}
330
- //
331
- // styles
332
- className={classNames.htmlCheckbox}
333
- style={{}}
334
- />
335
-
336
- <MotionBox className={classNames.handle} {...motionInitialAndAnimate}>
337
- <Box className={classNames.handleCircle} />
338
-
339
- {onIcon && (
340
- <IconSlot
341
- icon={onIcon}
342
- iconProps={{ variant: 'fill', size: 'sm' }}
343
- data-testid="on-icon"
344
- className={cx(classNames.handleIcon, isOn ? 'opacity-100' : 'opacity-0')}
345
- />
346
- )}
347
-
348
- {offIcon && (
349
- <IconSlot
350
- icon={offIcon}
351
- iconProps={{ variant: 'fill', size: 'sm' }}
352
- data-testid="off-icon"
353
- className={cx(classNames.handleIcon, !isOn ? 'opacity-100' : 'opacity-0')}
354
- />
355
- )}
356
- </MotionBox>
357
- </MotionBox>
358
-
359
- {label && (
360
- <FormLabel
361
- as="div"
362
- variant="inherit"
363
- color="inherit"
364
- required={required}
365
- label={label}
366
- className={classNames.label}
367
- />
368
- )}
369
- </RootElement>
370
- </SpringMotionConfig>
371
- );
372
- });
373
-
374
- // Need to re-set this because of the forwardRef wrapper
375
- Switch.displayName = 'Switch';
376
-
377
- export { Switch, type SwitchProps };
@@ -1,30 +0,0 @@
1
- export { Avatar, type AvatarProps } from './Avatar';
2
- export { AvatarIcon, type AvatarIconProps } from './Avatar';
3
- export { AvatarImage, type AvatarImageProps } from './Avatar';
4
- export { AvatarText, type AvatarTextProps } from './Avatar';
5
- export { Badge, type BadgeProps } from './Badge';
6
- export { Button, type ButtonProps } from './Button';
7
- export { Checkbox, type CheckboxProps } from './Checkbox';
8
- export { Chip, type ChipProps } from './Chip';
9
- export { ChipButton, type ChipButtonProps } from './Chip';
10
- export { ChipDismissible, type ChipDismissibleProps } from './Chip';
11
- export { ChipLink, type ChipLinkProps } from './Chip';
12
- export { ChipToggle, type ChipToggleProps } from './Chip';
13
- export { IconButton, type IconButtonProps } from './IconButton';
14
- export { Input, type InputProps } from './Input';
15
- export { InputHelpText, type InputHelpTextProps } from './Input';
16
- export {
17
- Menu,
18
- type MenuContentProps,
19
- type MenuDividerProps,
20
- type MenuItemCheckboxProps,
21
- type MenuItemProps,
22
- type MenuPlacement,
23
- type MenuProviderProps,
24
- type MenuTriggerProps,
25
- } from './Menu';
26
- export { Pressable, type PressableProps } from './Pressable';
27
- export { Radio, type RadioProps } from './Radio';
28
- export { RadioGroupProvider, type RadioGroupProviderProps } from './Radio';
29
- export { SpringMotionConfig, type SpringMotionConfigProps } from './SpringMotionConfig';
30
- export { Switch, type SwitchProps } from './Switch';
@@ -1,2 +0,0 @@
1
- // https://www.framer.com/motion/guide-reduce-bundle-size/#available-features
2
- export { domAnimation } from 'motion/react';
@@ -1,2 +0,0 @@
1
- // https://www.framer.com/motion/guide-reduce-bundle-size/#available-features
2
- export { domMax } from 'motion/react';
@@ -1,30 +0,0 @@
1
- import { Progress } from '@yahoo/uds-icons';
2
-
3
- import { cx } from '../../styles/styler';
4
- import type { IconProps } from '../Icon';
5
- import { Icon } from '../Icon';
6
-
7
- type SpinnerProps = React.HTMLAttributes<HTMLDivElement> & {
8
- color?: IconProps['color'];
9
- size?: IconProps['size'];
10
- };
11
-
12
- function Spinner({ className, color = 'primary', size = 'lg', ...props }: SpinnerProps) {
13
- return (
14
- <div role="status" className={cx('self-center', 'relative', className)} {...props}>
15
- <Icon
16
- role="img"
17
- name={Progress}
18
- className="animate-spin"
19
- size={size}
20
- color={color}
21
- aria-hidden="true"
22
- />
23
- <span className="sr-only">Loading...</span>
24
- </div>
25
- );
26
- }
27
-
28
- Spinner.displayName = 'Spinner';
29
-
30
- export { Spinner, type SpinnerProps };
@@ -1,38 +0,0 @@
1
- import type { TableColumn } from './Table';
2
-
3
- export type MockData = {
4
- id: number;
5
- name: string;
6
- actions?: () => JSX.Element;
7
- };
8
-
9
- export const data: MockData[] = [
10
- { id: 1, name: 'John Doe' },
11
- { id: 2, name: 'Jane Doe' },
12
- ];
13
-
14
- export const columns: TableColumn<MockData>[] = [
15
- { title: 'ID', dataIndex: 'id' },
16
- { title: 'Name', dataIndex: 'name' },
17
- {
18
- title: 'Actions',
19
- dataIndex: 'actions',
20
- render: () => <button>Edit</button>, // Assuming you want a static button for demonstration
21
- },
22
- ];
23
-
24
- // Sample data type
25
- export type ProductMockData = {
26
- id: number;
27
- product: string;
28
- price: number;
29
- inStock: boolean;
30
- };
31
-
32
- // Sample data
33
- export const productsData: ProductMockData[] = [
34
- { id: 1, product: 'Laptop', price: 1200, inStock: true },
35
- { id: 2, product: 'Smartphone', price: 800, inStock: false },
36
- { id: 3, product: 'Tablet', price: 700, inStock: true },
37
- { id: 4, product: 'Vision Pro', price: 4700, inStock: false },
38
- ];