@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,343 +0,0 @@
1
- import type { UniversalSwitchProps } from '@yahoo/uds/tokens';
2
- import * as m from 'motion/react-m';
3
- import type { ChangeEvent, FocusEvent } from 'react';
4
- import React, { forwardRef, useCallback, useEffect, useId, 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 { SpringMotionConfig } from '../../client/SpringMotionConfig';
10
- import { FormLabel } from '../../FormLabel';
11
- import { AvoidMotionLibraryProvider } from './AvoidMotionLibraryProvider';
12
-
13
- type NativeInputProps = Omit<
14
- React.InputHTMLAttributes<HTMLInputElement>,
15
- 'type' | 'checked' | 'size' | 'height' | 'width' | 'color' | 'defaultChecked' | 'children'
16
- >;
17
-
18
- type SwitchChangeEvent = ChangeEvent<HTMLInputElement>;
19
-
20
- const loadFeatures = () =>
21
- import('@yahoo/uds/__private/motionFeatures/domMax').then(({ domMax }) => domMax);
22
-
23
- interface SwitchV2Props extends NativeInputProps, UniversalSwitchProps {
24
- layerClassNames?: {
25
- root?: string;
26
- switch?: string;
27
- handle?: string;
28
- label?: string;
29
- };
30
- }
31
-
32
- const MotionBox = m.create(Box);
33
-
34
- /**
35
- * **⚙️️ An switch.
36
- *
37
- * @componentType Client component
38
- *
39
- * @description
40
- * 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.
41
- *
42
- * @see
43
- * Check out the {@link https://uds.build/docs/components/switch Switch Docs} for more info
44
- *
45
- * @usage
46
- * - Forms: switch
47
- *
48
- * @example
49
- * ```tsx
50
- * 'use client';
51
- * import { Switch } from "@yahoo/uds";
52
- *
53
- * <Switch label="Name" required />
54
- *```
55
- *
56
- * @related [Checkbox](https://uds.build/docs/components/checkbox).
57
- **/
58
- const SwitchV2 = forwardRef<HTMLInputElement, SwitchV2Props>(function Switch(
59
- {
60
- id,
61
- isOn: isOnProp,
62
- defaultIsOn,
63
- onChange,
64
- label,
65
- labelPosition = 'start',
66
- size = 'md',
67
- onIcon,
68
- offIcon,
69
- reduceMotion: forceReduceMotion,
70
- disabled,
71
- required,
72
- onFocus,
73
- onBlur,
74
- className,
75
- layerClassNames,
76
- ...switchProps
77
- },
78
- parentRef,
79
- ) {
80
- const generatedId = useId();
81
- const uid = id ?? `uds-input-${generatedId}`;
82
-
83
- const innerRef = useRef<HTMLInputElement | null>(null);
84
-
85
- /**
86
- * State
87
- */
88
- const isControlled = isOnProp !== undefined;
89
- const [isOn, setIsOn] = useState(isControlled ? isOnProp : defaultIsOn);
90
-
91
- /**
92
- * Handlers
93
- */
94
- const handleChange = useCallback(
95
- (e: SwitchChangeEvent) => {
96
- onChange?.(e);
97
-
98
- // If uncontrolled, immediate change internal state.
99
- if (!isControlled) {
100
- setIsOn(e.target.checked);
101
- }
102
- },
103
- [isControlled, onChange],
104
- );
105
-
106
- const handleFocus = useCallback(
107
- (e: FocusEvent<HTMLInputElement>) => {
108
- onFocus?.(e);
109
- },
110
- [onFocus],
111
- );
112
-
113
- const handleBlur = useCallback(
114
- (e: FocusEvent<HTMLInputElement>) => {
115
- onBlur?.(e);
116
- },
117
- [onBlur],
118
- );
119
-
120
- // Motion
121
- const reduceMotion = forceReduceMotion ? 'always' : 'user';
122
- const cssAnimationDuration = forceReduceMotion
123
- ? 'duration-0'
124
- : 'duration-120 motion-reduce:duration-0';
125
-
126
- /**
127
- * Effects
128
- */
129
- // Reset state if prop changes.
130
- useEffect(() => {
131
- if (isControlled) {
132
- setIsOn(isOnProp);
133
- }
134
- }, [isOnProp, isControlled]);
135
-
136
- const classNames = {
137
- root: getStyles({
138
- switchSizeRoot: size,
139
- switchVariantRoot: 'default',
140
- switchVariantActiveRoot: isOn ? 'on' : 'off',
141
- className: cx(
142
- 'group',
143
- 'flex',
144
- 'items-center',
145
-
146
- labelPosition === 'start' ? 'flex-row' : 'flex-row-reverse',
147
-
148
- ...(disabled ? ['cursor-default', 'opacity-50'] : ['cursor-pointer']),
149
-
150
- layerClassNames?.root,
151
- className,
152
- ),
153
- }),
154
-
155
- switch: getStyles({
156
- switchVariantSwitch: 'default',
157
- switchSizeSwitch: size,
158
- switchVariantActiveSwitch: isOn ? 'on' : 'off',
159
- className: cx(
160
- 'uds-ring',
161
- 'uds-ring-within',
162
-
163
- 'relative',
164
- 'rounded-full',
165
- 'items-center',
166
-
167
- cssAnimationDuration,
168
- 'transition-[background-color,box-shadow]',
169
-
170
- layerClassNames?.switch,
171
- ),
172
- }),
173
-
174
- handleContainer: cx('pointer-events-none', 'relative', 'w-full', 'h-full'),
175
-
176
- handle: getStyles({
177
- switchSizeHandle: size,
178
- className: cx(
179
- 'absolute',
180
- 'top-0',
181
- 'bottom-0',
182
-
183
- isOn ? 'right-0' : 'left-0',
184
-
185
- layerClassNames?.handle,
186
- ),
187
- }),
188
-
189
- handleContents: cx(
190
- 'relative',
191
- 'w-full',
192
- 'h-full',
193
-
194
- 'rounded-full',
195
- 'overflow-hidden',
196
-
197
- !disabled && 'group-hover:scale-105',
198
-
199
- 'opacity-95',
200
- !disabled && 'group-hover:opacity-100',
201
-
202
- cssAnimationDuration,
203
- 'transition-[transform,opacity]',
204
- ),
205
-
206
- handleCircle: getStyles({
207
- switchVariantActiveHandle: isOn ? 'on' : 'off',
208
- switchVariantHandle: 'default',
209
- className: cx('absolute', 'top-0', 'left-0', 'right-0', 'bottom-0'),
210
- }),
211
-
212
- handleIcon: getStyles({
213
- switchSizeHandleIcon: size,
214
- switchVariantHandleIcon: 'default',
215
- switchVariantActiveHandleIcon: isOn ? 'on' : 'off',
216
- className: cx(
217
- 'absolute',
218
- 'opacity-0',
219
- 'top-1/2',
220
- 'left-1/2',
221
- 'transform',
222
- 'translate-x-[-50%]',
223
- 'translate-y-[-50%]',
224
-
225
- cssAnimationDuration,
226
- 'transition-opacity',
227
- ),
228
- }),
229
-
230
- htmlCheckbox: cx(
231
- // Control the cursor at the top of the component
232
- // and don't let the input override it back to the
233
- // default value.
234
- 'cursor-[inherit]',
235
-
236
- 'absolute',
237
- 'opacity-0',
238
- 'top-1/2',
239
- 'left-1/2',
240
- 'w-[calc(100%+2px)]',
241
- 'h-[calc(100%+2px)]',
242
- 'transform',
243
- 'translate-x-[-50%]',
244
- 'translate-y-[-50%]',
245
- ),
246
-
247
- label: cx(labelPosition === 'start' ? 'text-start' : 'text-end', layerClassNames?.label),
248
- };
249
-
250
- const RootElement = label ? 'label' : 'div';
251
-
252
- return (
253
- <SpringMotionConfig
254
- reducedMotion={reduceMotion}
255
- loadFeatures={loadFeatures}
256
- layoutVariant="bouncy"
257
- layoutSpeed="4"
258
- >
259
- <RootElement className={classNames.root} data-testid="switch-root" tabIndex={-1}>
260
- <Box className={classNames.switch}>
261
- <input
262
- type="checkbox"
263
- // These are standard HTML input props for customization.
264
- {...switchProps}
265
- //
266
- // Provide a ref to the underlying input element for customization.
267
- ref={(ref) => {
268
- // Set internal ref.
269
- innerRef.current = ref;
270
-
271
- // Forward the ref to parent.
272
- if (typeof parentRef === 'function') {
273
- parentRef(ref);
274
- } else if (parentRef !== null) {
275
- parentRef.current = ref;
276
- }
277
- }}
278
- //
279
- // Track focus as a prop for easier styling.
280
- onFocus={handleFocus}
281
- onBlur={handleBlur}
282
- //
283
- // Core props for the switch.
284
- id={uid}
285
- disabled={disabled}
286
- required={required}
287
- checked={isControlled ? isOn : undefined}
288
- defaultChecked={isControlled ? undefined : defaultIsOn}
289
- onChange={handleChange}
290
- //
291
- // styles
292
- className={classNames.htmlCheckbox}
293
- style={{}}
294
- />
295
-
296
- <Box className={classNames.handleContainer}>
297
- <MotionBox className={classNames.handle} layout="position" layoutDependency={isOn}>
298
- <Box className={classNames.handleContents}>
299
- <Box className={classNames.handleCircle} />
300
-
301
- {onIcon && (
302
- <IconSlot
303
- icon={onIcon}
304
- iconProps={{ variant: 'fill', size: 'sm' }}
305
- data-testid="on-icon"
306
- className={cx(classNames.handleIcon, isOn ? 'opacity-100' : 'opacity-0')}
307
- />
308
- )}
309
-
310
- {offIcon && (
311
- <IconSlot
312
- icon={offIcon}
313
- iconProps={{ variant: 'fill', size: 'sm' }}
314
- data-testid="off-icon"
315
- className={cx(classNames.handleIcon, !isOn ? 'opacity-100' : 'opacity-0')}
316
- />
317
- )}
318
- </Box>
319
- </MotionBox>
320
- </Box>
321
- </Box>
322
-
323
- {label && (
324
- <FormLabel
325
- as="div"
326
- variant="inherit"
327
- color="inherit"
328
- required={required}
329
- label={label}
330
- className={classNames.label}
331
- />
332
- )}
333
- </RootElement>
334
- </SpringMotionConfig>
335
- );
336
- });
337
-
338
- // Need to re-set this because of the forwardRef wrapper
339
- SwitchV2.displayName = 'SwitchV2';
340
-
341
- const SwitchV2AvoidMotionLibraryProvider = AvoidMotionLibraryProvider;
342
-
343
- export { SwitchV2, SwitchV2AvoidMotionLibraryProvider, type SwitchV2Props };
@@ -1,106 +0,0 @@
1
- /* eslint-disable react/no-multi-comp */
2
- import type { TabListProps, TabPanelProps, TabProviderProps as TabsProps } from '@ariakit/react';
3
- import {
4
- Tab as OriginalTab,
5
- TabList as OriginalTabList,
6
- TabPanel as OriginalTabPanel,
7
- TabProvider,
8
- useTabContext,
9
- } from '@ariakit/react';
10
- import { forwardRef } from 'react';
11
-
12
- import { cx, getStyles } from '../../../styles/styler';
13
- import { createSlot } from '../../../utils/createSlot';
14
- import type { IconProps } from '../..';
15
- import { Icon, Pressable, Text } from '../..';
16
-
17
- const Slot = createSlot();
18
-
19
- interface TabProps extends React.PropsWithChildren {
20
- asChild?: boolean;
21
- value: string;
22
- label: string;
23
- startIcon?: IconProps['name'];
24
- }
25
-
26
- function Tabs(props: TabsProps) {
27
- return <TabProvider {...props} />;
28
- }
29
-
30
- Tabs.displayName = 'Tabs';
31
-
32
- const TabList = forwardRef<HTMLDivElement, TabListProps>(function TabList(
33
- { className, ...props }: TabListProps,
34
- ref,
35
- ) {
36
- const styles = getStyles({ display: 'flex', flexDirection: 'row', columnGap: '6', className });
37
- return <OriginalTabList ref={ref} {...props} className={styles} />;
38
- });
39
-
40
- TabList.displayName = 'TabList';
41
-
42
- const Tab = function Tab({ asChild, label, value, startIcon }: TabProps) {
43
- const Comp = asChild ? Slot : 'button';
44
- const styles = getStyles({});
45
- const store = useTabContext();
46
- if (!store) {
47
- throw new Error('Tab must be wrapped in a Tabs component');
48
- }
49
-
50
- const className = cx(
51
- // Resting state
52
- 'text-tertiary',
53
- 'border-b-transparent',
54
- // Selected state
55
- 'aria-selected:border-b-brand',
56
- 'aria-selected:text-secondary',
57
- );
58
-
59
- return (
60
- <OriginalTab
61
- id={value}
62
- className={styles}
63
- render={
64
- <Pressable
65
- borderBottomWidth="medium"
66
- spacingBottom="1"
67
- spacingTop="4"
68
- className={className}
69
- asChild
70
- >
71
- <Comp>
72
- {startIcon ? <Icon name={startIcon} className="text-current" size="md" /> : null}
73
- <Text className="text-current" variant="headline1" as="span">
74
- {label}
75
- </Text>
76
- </Comp>
77
- </Pressable>
78
- }
79
- />
80
- );
81
- };
82
-
83
- Tab.displayName = 'Tab';
84
-
85
- const TabPanel = forwardRef<HTMLDivElement, TabPanelProps>(function TabPanel(props, ref) {
86
- const store = useTabContext();
87
- if (!store) {
88
- throw new Error('TabPanel must be wrapped in a Tabs component');
89
- }
90
- const tabId = store.useState('selectedId');
91
-
92
- return <OriginalTabPanel ref={ref} tabId={tabId} {...props} />;
93
- });
94
-
95
- TabPanel.displayName = 'TabPanel';
96
-
97
- export {
98
- Tab,
99
- TabList,
100
- type TabListProps,
101
- TabPanel,
102
- type TabPanelProps,
103
- type TabProps,
104
- Tabs,
105
- type TabsProps,
106
- };
@@ -1,186 +0,0 @@
1
- import type { BackgroundPaletteAlias, ForegroundColor, LinePaletteAlias } from '@yahoo/uds/tokens';
2
- import { CheckCircle, Cross, Error, Info, Warning } from '@yahoo/uds-icons';
3
- import { isString } from 'lodash';
4
- import type { ReactNode } from 'react';
5
- import type {
6
- CloseButton,
7
- ToastClassName,
8
- ToastContainerProps,
9
- ToastOptions,
10
- ToastPosition,
11
- TypeOptions,
12
- } from 'react-toastify';
13
- import {
14
- Slide,
15
- toast as toastOriginal,
16
- ToastContainer as OriginalToastContainer,
17
- } from 'react-toastify';
18
-
19
- import { cx, getStyles } from '../../../styles/styler';
20
- import { Icon, Text } from '../..';
21
- import { IconButton } from '../../client/IconButton';
22
-
23
- type ToastProps = ToastContainerProps;
24
-
25
- const wrapperStyles = getStyles({
26
- borderRadius: 'md',
27
- spacingVertical: '3',
28
- spacingHorizontal: '5',
29
- display: 'flex',
30
- flexDirection: 'row',
31
- alignItems: 'center',
32
- justifyContent: 'space-between',
33
- columnGap: '5',
34
- overflow: 'hidden',
35
- position: 'relative',
36
- className: 'cursor-pointer',
37
- dropShadow: 'md',
38
- });
39
-
40
- const textStyles = getStyles({
41
- fontSize: 'label2',
42
- lineHeight: 'label2',
43
- fontWeight: 'label2',
44
- color: 'primary',
45
- });
46
-
47
- const backgroundMap: Record<TypeOptions, BackgroundPaletteAlias> = {
48
- default: 'primary',
49
- success: 'primary',
50
- error: 'primary',
51
- info: 'primary',
52
- warning: 'primary',
53
- };
54
-
55
- const borderMap: Record<TypeOptions, LinePaletteAlias> = {
56
- default: 'secondary',
57
- success: 'positive',
58
- error: 'alert',
59
- info: 'info',
60
- warning: 'warning',
61
- } as const;
62
-
63
- const iconColorMap: Record<TypeOptions, ForegroundColor> = {
64
- default: 'primary',
65
- success: 'positive',
66
- error: 'alert',
67
- info: 'info',
68
- warning: 'warning',
69
- } as const;
70
-
71
- const colorMap: Record<TypeOptions, ForegroundColor> = {
72
- default: 'primary',
73
- success: 'primary',
74
- error: 'primary',
75
- info: 'primary',
76
- warning: 'primary',
77
- } as const;
78
-
79
- const getToastClassName =
80
- (toastClassName?: ToastClassName) =>
81
- (context?: {
82
- type?: TypeOptions;
83
- defaultClassName?: string;
84
- position?: ToastPosition;
85
- rtl?: boolean;
86
- }): string => {
87
- const classes = getStyles({
88
- color: colorMap[context?.type || 'default'],
89
- backgroundColor: backgroundMap[context?.type || 'default'],
90
- borderWidth: 'thin',
91
- borderColor: borderMap[context?.type || 'default'],
92
- });
93
-
94
- return cx(
95
- wrapperStyles,
96
- classes,
97
- isString(toastClassName) ? toastClassName : toastClassName?.(context),
98
- 'mb-2 last:mb-0',
99
- );
100
- };
101
-
102
- function CustomCloseButton({ closeToast }: Parameters<typeof CloseButton>[0]) {
103
- return (
104
- <IconButton
105
- className="shrink-0"
106
- name={Cross}
107
- size="sm"
108
- variant="tertiary"
109
- onClick={closeToast}
110
- />
111
- );
112
- }
113
-
114
- CustomCloseButton.displayName = 'CustomCloseButton';
115
-
116
- // eslint-disable-next-line react/no-multi-comp
117
- function ToastContainer({ toastClassName, ...props }: ToastProps) {
118
- return (
119
- <OriginalToastContainer
120
- toastClassName={getToastClassName(toastClassName)}
121
- className={textStyles}
122
- hideProgressBar
123
- transition={Slide}
124
- closeButton={CustomCloseButton}
125
- autoClose={6000}
126
- {...props}
127
- />
128
- );
129
- }
130
-
131
- ToastContainer.displayName = 'ToastContainer';
132
-
133
- type ToastOptionsWithoutType = Omit<ToastOptions, 'type'>;
134
- type ToastFunction = (message: ReactNode, options?: ToastOptionsWithoutType) => void;
135
-
136
- type ToastFunctionWithVariants = ToastFunction & {
137
- positive: ToastFunction;
138
- alert: ToastFunction;
139
- info: ToastFunction;
140
- warning: ToastFunction;
141
- };
142
-
143
- const toast: ToastFunctionWithVariants = Object.assign(
144
- (message: ReactNode, options: ToastOptionsWithoutType = {}) => {
145
- return toastOriginal(() => <Text color="current">{message}</Text>, {
146
- ...options,
147
- type: 'default',
148
- });
149
- },
150
- {
151
- positive: (message: ReactNode, options: ToastOptionsWithoutType = {}) => {
152
- return toastOriginal(() => <Text color="current">{message}</Text>, {
153
- ...options,
154
- type: 'success',
155
- icon: () => (
156
- <Icon name={CheckCircle} size="md" variant="fill" color={iconColorMap['success']} />
157
- ),
158
- });
159
- },
160
- alert: (message: ReactNode, options: ToastOptionsWithoutType = {}) => {
161
- return toastOriginal(() => <Text color="current">{message}</Text>, {
162
- ...options,
163
- type: 'error',
164
- icon: () => <Icon name={Error} size="md" variant="fill" color={iconColorMap['error']} />,
165
- });
166
- },
167
- warning: (message: ReactNode, options: ToastOptionsWithoutType = {}) => {
168
- return toastOriginal(() => <Text color="current">{message}</Text>, {
169
- ...options,
170
- type: 'warning',
171
- icon: () => (
172
- <Icon name={Warning} size="md" variant="fill" color={iconColorMap['warning']} />
173
- ),
174
- });
175
- },
176
- info: (message: ReactNode, options: ToastOptionsWithoutType = {}) => {
177
- return toastOriginal(() => <Text color="current">{message}</Text>, {
178
- ...options,
179
- type: 'info',
180
- icon: () => <Icon name={Info} size="md" variant="fill" color={iconColorMap['info']} />,
181
- });
182
- },
183
- },
184
- );
185
-
186
- export { getToastClassName, toast, ToastContainer, type ToastProps };
@@ -1,15 +0,0 @@
1
- /**
2
- * ------------------- GENERATED | DO NOT MODIFY THIS FILE ------------------
3
- * This file uses eslint-plugin-codegen to automatically watch for changes in
4
- * the `src/components/client` directory and updates this barrel file.
5
- */
6
-
7
- // codegen:start {preset: barrel, exclude: ['*.*.*']}
8
- export * from './Accordion';
9
- export * from './AvoidMotionLibraryProvider';
10
- export * from './Modal';
11
- export * from './Popover';
12
- export * from './SwitchV2';
13
- export * from './Tabs';
14
- export * from './Toast';
15
- // codegen:end
@@ -1,48 +0,0 @@
1
- /**
2
- * ------------------- GENERATED | DO NOT MODIFY THIS SECTION ------------------
3
- * This file uses eslint-plugin-codegen to automatically watch for changes in
4
- * the `src/components` directory and updates this barrel file.
5
- */
6
-
7
- // codegen:start {preset: barrel, exclude: ['*.*.*']}
8
- export * from './Spinner';
9
- export * from './Table';
10
- // codegen:end
11
-
12
- // Client Components
13
- export { Accordion, type AccordionProps } from './client';
14
- export {
15
- Tab,
16
- TabList,
17
- type TabListProps,
18
- TabPanel,
19
- type TabPanelProps,
20
- type TabProps,
21
- Tabs,
22
- type TabsProps,
23
- } from './client';
24
- export { toast, ToastContainer, type ToastProps } from './client';
25
- export {
26
- Popover,
27
- PopoverAnchor,
28
- PopoverArrow,
29
- PopoverDescription,
30
- PopoverDisclosure,
31
- PopoverDisclosureArrow,
32
- PopoverDismiss,
33
- PopoverHeading,
34
- type PopoverHeadingProps,
35
- type PopoverProps,
36
- PopoverProvider,
37
- usePopoverStore,
38
- } from './client';
39
- export {
40
- Modal,
41
- ModalDismiss,
42
- ModalHeader,
43
- type ModalProps,
44
- type ModalStore,
45
- useModalStore,
46
- } from './client';
47
- export { SwitchV2, type SwitchV2Props } from './client';
48
- export { AvoidMotionLibraryProvider, useAvoidMotionLibrary } from './client';