@yahoo/uds 3.159.2 → 3.160.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/automated-config/dist/properties.cjs +1 -1
  2. package/dist/automated-config/dist/properties.js +1 -1
  3. package/dist/components/client/Button/Button.cjs +213 -0
  4. package/dist/components/client/Button/Button.d.cts +50 -0
  5. package/dist/components/client/Button/Button.d.ts +51 -0
  6. package/dist/components/client/Button/Button.js +208 -0
  7. package/dist/components/client/Button/ButtonBase.cjs +120 -0
  8. package/dist/components/client/Button/ButtonBase.d.cts +52 -0
  9. package/dist/components/client/Button/ButtonBase.d.ts +53 -0
  10. package/dist/components/client/Button/ButtonBase.js +116 -0
  11. package/dist/components/client/{buttonConstants.cjs → Button/buttonConstants.cjs} +1 -1
  12. package/dist/components/client/Button/buttonConstants.d.cts +7 -0
  13. package/dist/components/client/Button/buttonConstants.d.ts +8 -0
  14. package/dist/components/client/{buttonConstants.js → Button/buttonConstants.js} +1 -1
  15. package/dist/components/client/Button/index.cjs +10 -0
  16. package/dist/components/client/Button/index.d.cts +4 -0
  17. package/dist/components/client/Button/index.d.ts +5 -0
  18. package/dist/components/client/Button/index.js +5 -0
  19. package/dist/components/client/IconButton/IconButton.cjs +104 -0
  20. package/dist/components/client/IconButton/IconButton.d.cts +17 -0
  21. package/dist/components/client/IconButton/IconButton.d.ts +18 -0
  22. package/dist/components/client/IconButton/IconButton.js +102 -0
  23. package/dist/components/client/IconButton/IconButtonBase.cjs +68 -0
  24. package/dist/components/client/IconButton/IconButtonBase.d.cts +45 -0
  25. package/dist/components/client/IconButton/IconButtonBase.d.ts +46 -0
  26. package/dist/components/client/IconButton/IconButtonBase.js +65 -0
  27. package/dist/components/client/IconButton/index.cjs +8 -0
  28. package/dist/components/client/IconButton/index.d.cts +4 -0
  29. package/dist/components/client/IconButton/index.d.ts +5 -0
  30. package/dist/components/client/IconButton/index.js +5 -0
  31. package/dist/components/client/SpringMotionConfig.cjs +10 -13
  32. package/dist/components/client/SpringMotionConfig.js +10 -13
  33. package/dist/components/client/Switch/Switch.cjs +119 -0
  34. package/dist/components/client/{Switch.d.cts → Switch/Switch.d.cts} +4 -16
  35. package/dist/components/client/{Switch.d.ts → Switch/Switch.d.ts} +4 -16
  36. package/dist/components/client/Switch/Switch.js +115 -0
  37. package/dist/components/client/Switch/SwitchBase.cjs +129 -0
  38. package/dist/components/client/Switch/SwitchBase.d.cts +29 -0
  39. package/dist/components/client/Switch/SwitchBase.d.ts +30 -0
  40. package/dist/components/client/Switch/SwitchBase.js +126 -0
  41. package/dist/components/client/Switch/index.cjs +5 -0
  42. package/dist/components/client/Switch/index.d.cts +3 -0
  43. package/dist/components/client/Switch/index.d.ts +4 -0
  44. package/dist/components/client/Switch/index.js +4 -0
  45. package/dist/components/client/Switch/switchStyles.cjs +17 -0
  46. package/dist/components/client/Switch/switchStyles.d.cts +9 -0
  47. package/dist/components/client/Switch/switchStyles.d.ts +10 -0
  48. package/dist/components/client/Switch/switchStyles.js +16 -0
  49. package/dist/components/client/Switch/types.cjs +2 -0
  50. package/dist/components/client/Switch/types.d.cts +33 -0
  51. package/dist/components/client/Switch/types.d.ts +34 -0
  52. package/dist/components/client/Switch/types.js +2 -0
  53. package/dist/components/client/Toast/Toast.cjs +2 -2
  54. package/dist/components/client/Toast/Toast.d.cts +1 -1
  55. package/dist/components/client/Toast/Toast.d.ts +1 -1
  56. package/dist/components/client/Toast/Toast.js +1 -1
  57. package/dist/components/client/index.cjs +6 -6
  58. package/dist/components/client/index.d.cts +3 -3
  59. package/dist/components/client/index.d.ts +3 -3
  60. package/dist/components/client/index.js +3 -3
  61. package/dist/components/experimental/client/index.cjs +0 -6
  62. package/dist/components/experimental/client/index.d.cts +1 -3
  63. package/dist/components/experimental/client/index.d.ts +1 -3
  64. package/dist/components/experimental/client/index.js +1 -3
  65. package/dist/components/experimental/index.cjs +0 -5
  66. package/dist/components/experimental/index.d.cts +1 -3
  67. package/dist/components/experimental/index.d.ts +1 -3
  68. package/dist/components/experimental/index.js +1 -3
  69. package/dist/components/index.cjs +6 -6
  70. package/dist/components/index.d.cts +3 -3
  71. package/dist/components/index.d.ts +3 -3
  72. package/dist/components/index.js +3 -3
  73. package/dist/css-animation/Button/Button.cjs +85 -0
  74. package/dist/css-animation/Button/Button.d.cts +13 -0
  75. package/dist/css-animation/Button/Button.d.ts +14 -0
  76. package/dist/css-animation/Button/Button.js +82 -0
  77. package/dist/css-animation/Button/index.cjs +5 -0
  78. package/dist/css-animation/Button/index.d.cts +4 -0
  79. package/dist/css-animation/Button/index.d.ts +5 -0
  80. package/dist/css-animation/Button/index.js +4 -0
  81. package/dist/css-animation/IconButton/IconButton.cjs +55 -0
  82. package/dist/css-animation/IconButton/IconButton.d.cts +13 -0
  83. package/dist/css-animation/IconButton/IconButton.d.ts +14 -0
  84. package/dist/css-animation/IconButton/IconButton.js +53 -0
  85. package/dist/css-animation/IconButton/index.cjs +5 -0
  86. package/dist/css-animation/IconButton/index.d.cts +4 -0
  87. package/dist/css-animation/IconButton/index.d.ts +5 -0
  88. package/dist/css-animation/IconButton/index.js +4 -0
  89. package/dist/css-animation/Switch/Switch.cjs +44 -0
  90. package/dist/css-animation/Switch/Switch.d.cts +22 -0
  91. package/dist/css-animation/Switch/Switch.d.ts +23 -0
  92. package/dist/css-animation/Switch/Switch.js +41 -0
  93. package/dist/css-animation/Switch/SwitchStaticHandle.cjs +56 -0
  94. package/dist/css-animation/Switch/SwitchStaticHandle.d.cts +31 -0
  95. package/dist/css-animation/Switch/SwitchStaticHandle.d.ts +32 -0
  96. package/dist/css-animation/Switch/SwitchStaticHandle.js +54 -0
  97. package/dist/css-animation/Switch/index.cjs +5 -0
  98. package/dist/css-animation/Switch/index.d.cts +3 -0
  99. package/dist/css-animation/Switch/index.d.ts +4 -0
  100. package/dist/css-animation/Switch/index.js +4 -0
  101. package/dist/css-animation/index.cjs +9 -0
  102. package/dist/css-animation/index.d.cts +7 -0
  103. package/dist/css-animation/index.d.ts +8 -0
  104. package/dist/css-animation/index.js +6 -0
  105. package/dist/hooks/usePrefersReducedMotion.cjs +24 -0
  106. package/dist/hooks/usePrefersReducedMotion.d.cts +5 -0
  107. package/dist/hooks/usePrefersReducedMotion.d.ts +5 -0
  108. package/dist/hooks/usePrefersReducedMotion.js +22 -0
  109. package/dist/index.cjs +7 -7
  110. package/dist/index.d.cts +3 -3
  111. package/dist/index.d.ts +3 -3
  112. package/dist/index.js +4 -4
  113. package/dist/styles/styler.d.cts +4 -4
  114. package/dist/styles/styler.d.ts +4 -4
  115. package/dist/tailwind-internal/dist/utils/getShadowStyles.d.cts +2 -2
  116. package/dist/tailwind-internal/dist/utils/getShadowStyles.d.ts +2 -2
  117. package/dist/uds/generated/componentData.cjs +308 -317
  118. package/dist/uds/generated/componentData.js +308 -317
  119. package/dist/uds/generated/tailwindPurge.cjs +8 -21
  120. package/dist/uds/generated/tailwindPurge.js +8 -21
  121. package/dist/uds/package.cjs +12 -2
  122. package/dist/uds/package.js +12 -2
  123. package/generated/componentData.json +458 -489
  124. package/generated/tailwindPurge.ts +3 -3
  125. package/package.json +13 -3
  126. package/dist/components/client/Button.cjs +0 -326
  127. package/dist/components/client/Button.d.cts +0 -86
  128. package/dist/components/client/Button.d.ts +0 -87
  129. package/dist/components/client/Button.js +0 -321
  130. package/dist/components/client/IconButton.cjs +0 -161
  131. package/dist/components/client/IconButton.d.cts +0 -46
  132. package/dist/components/client/IconButton.d.ts +0 -47
  133. package/dist/components/client/IconButton.js +0 -159
  134. package/dist/components/client/Switch.cjs +0 -225
  135. package/dist/components/client/Switch.js +0 -222
  136. package/dist/components/client/buttonConstants.d.cts +0 -7
  137. package/dist/components/client/buttonConstants.d.ts +0 -8
  138. package/dist/components/experimental/client/AvoidMotionLibraryProvider.cjs +0 -14
  139. package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.cts +0 -8
  140. package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.ts +0 -9
  141. package/dist/components/experimental/client/AvoidMotionLibraryProvider.js +0 -11
  142. package/dist/components/experimental/client/SwitchV2.cjs +0 -190
  143. package/dist/components/experimental/client/SwitchV2.d.cts +0 -46
  144. package/dist/components/experimental/client/SwitchV2.d.ts +0 -47
  145. package/dist/components/experimental/client/SwitchV2.js +0 -185
@@ -0,0 +1,46 @@
1
+
2
+ "use client";
3
+ import { IconPropsWithSVGProps, UniversalIconButtonProps } from "../../../tokens/types.js";
4
+ import * as _$react from "react";
5
+ import { ForwardRefExoticComponent } from "react";
6
+
7
+ //#region src/components/client/IconButton/IconButtonBase.d.ts
8
+ type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'>;
9
+ type DataAttributes = {
10
+ [name: `data-${string}`]: string;
11
+ };
12
+ interface IconButtonProps extends HtmlButtonProps, UniversalIconButtonProps {
13
+ slotProps?: {
14
+ icon?: Partial<IconPropsWithSVGProps & DataAttributes>;
15
+ };
16
+ }
17
+ type IconButtonRenderArgs = {
18
+ asChild: boolean;
19
+ loading?: boolean;
20
+ name?: IconButtonProps['name'];
21
+ iconVariant: IconButtonProps['iconVariant'];
22
+ children: React.ReactNode;
23
+ iconClassName: string;
24
+ loadingIconClassName: string;
25
+ iconSlotClassName?: string;
26
+ iconSlotProps: Partial<IconPropsWithSVGProps & DataAttributes>;
27
+ };
28
+ type IconButtonRootRenderArgs = {
29
+ asChild: boolean;
30
+ Slot: ForwardRefExoticComponent<HtmlButtonProps>;
31
+ children: React.ReactNode;
32
+ buttonRef: React.ForwardedRef<HTMLButtonElement>;
33
+ type: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
34
+ htmlName?: string;
35
+ rootClassName: string;
36
+ rest: Record<string, unknown>;
37
+ iconContent: React.ReactNode;
38
+ };
39
+ interface IconButtonBaseProps extends IconButtonProps {
40
+ renderIconContent: (args: IconButtonRenderArgs) => React.ReactNode;
41
+ renderRoot: (args: IconButtonRootRenderArgs) => React.ReactNode;
42
+ }
43
+ declare const IconButtonBase: ForwardRefExoticComponent<IconButtonBaseProps & _$react.RefAttributes<HTMLButtonElement>>;
44
+ declare function renderIconButtonAsChild(children: React.ReactNode, content: React.ReactNode): _$react.ReactElement<unknown, string | _$react.JSXElementConstructor<any>>;
45
+ //#endregion
46
+ export { IconButtonBase, type IconButtonProps, type IconButtonRootRenderArgs, renderIconButtonAsChild };
@@ -0,0 +1,65 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ import { cx, getStyles } from "../../../styles/styler.js";
4
+ import { createSlot } from "../../../utils/createSlot.js";
5
+ import { generateDefaultClassName } from "../../../automated-config/dist/utils/generateDefaultClassName.js";
6
+ import { cloneElement, forwardRef, useMemo } from "react";
7
+ //#region src/components/client/IconButton/IconButtonBase.tsx
8
+ const defaultSizeRootClass = generateDefaultClassName("iconbutton", "size", "root");
9
+ const defaultSizeIconClass = generateDefaultClassName("iconbutton", "size", "icon");
10
+ const defaultVariantRootClass = generateDefaultClassName("button", "variant", "root");
11
+ const defaultVariantIconClass = generateDefaultClassName("button", "variant", "icon");
12
+ const IconButtonBase = forwardRef(function IconButtonBase({ variant, size, iconVariant, loading, disableEffects, name, asChild = false, slotProps, type = "button", htmlName, className, children, renderIconContent, renderRoot, ...rest }, forwardedRef) {
13
+ const { className: iconSlotClassName, ...iconSlotProps } = slotProps?.icon ?? {};
14
+ const Slot = useMemo(() => createSlot(), []);
15
+ const rootSizeClass = useMemo(() => size ? getStyles({ iconbuttonSizeRoot: size }) : defaultSizeRootClass, [size]);
16
+ const rootVariantClass = useMemo(() => variant ? getStyles({ buttonVariantRoot: variant }) : defaultVariantRootClass, [variant]);
17
+ const iconSizeClass = useMemo(() => size ? getStyles({ iconbuttonSizeIcon: size }) : defaultSizeIconClass, [size]);
18
+ const iconVariantClass = useMemo(() => variant ? getStyles({ buttonVariantIcon: variant }) : defaultVariantIconClass, [variant]);
19
+ const styles = useMemo(() => ({
20
+ root: cx("uds-ring", "uds-hit-target", "inline-flex overflow-hidden justify-center items-center", "[transform-origin:center]", "[backface-visibility:hidden]", "[transition-property:color,background-color,border-color,box-shadow,text-decoration-color,fill,stroke]", "[transition-timing-function:cubic-bezier(0,0,0.2,1)]", "[transition-duration:220ms]", rootSizeClass, rootVariantClass, rest?.disabled && "cursor-not-allowed", loading && "uds-button-loading", disableEffects && "uds-button-without-effects", className),
21
+ icon: getStyles({ className: cx(iconSizeClass, iconVariantClass) }),
22
+ loadingIcon: getStyles({ className: cx([
23
+ "animate-spin",
24
+ iconSizeClass,
25
+ iconVariantClass
26
+ ]) })
27
+ }), [
28
+ className,
29
+ disableEffects,
30
+ iconSizeClass,
31
+ iconVariantClass,
32
+ loading,
33
+ rest?.disabled,
34
+ rootSizeClass,
35
+ rootVariantClass
36
+ ]);
37
+ return renderRoot({
38
+ asChild,
39
+ Slot,
40
+ children,
41
+ buttonRef: forwardedRef,
42
+ type,
43
+ htmlName,
44
+ rootClassName: styles.root,
45
+ rest,
46
+ iconContent: renderIconContent({
47
+ asChild,
48
+ loading,
49
+ name,
50
+ iconVariant,
51
+ children,
52
+ iconClassName: styles.icon,
53
+ loadingIconClassName: styles.loadingIcon,
54
+ iconSlotClassName,
55
+ iconSlotProps
56
+ })
57
+ });
58
+ });
59
+ IconButtonBase.displayName = "IconButtonBase";
60
+ function renderIconButtonAsChild(children, content) {
61
+ const childProps = children.props;
62
+ return cloneElement(children, childProps, content);
63
+ }
64
+ //#endregion
65
+ export { IconButtonBase, renderIconButtonAsChild };
@@ -0,0 +1,8 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require_components_client_IconButton_IconButtonBase = require("./IconButtonBase.cjs");
5
+ const require_components_client_IconButton_IconButton = require("./IconButton.cjs");
6
+ exports.IconButton = require_components_client_IconButton_IconButton.IconButton;
7
+ exports.IconButtonBase = require_components_client_IconButton_IconButtonBase.IconButtonBase;
8
+ exports.renderIconButtonAsChild = require_components_client_IconButton_IconButtonBase.renderIconButtonAsChild;
@@ -0,0 +1,4 @@
1
+
2
+ import { IconButtonBase, IconButtonRootRenderArgs, renderIconButtonAsChild } from "./IconButtonBase.cjs";
3
+ import { IconButton, IconButtonProps } from "./IconButton.cjs";
4
+ export { IconButton, IconButtonBase, type IconButtonProps, type IconButtonRootRenderArgs, renderIconButtonAsChild };
@@ -0,0 +1,5 @@
1
+
2
+ "use client";
3
+ import { IconButtonBase, IconButtonRootRenderArgs, renderIconButtonAsChild } from "./IconButtonBase.js";
4
+ import { IconButton, IconButtonProps } from "./IconButton.js";
5
+ export { IconButton, IconButtonBase, type IconButtonProps, type IconButtonRootRenderArgs, renderIconButtonAsChild };
@@ -0,0 +1,5 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ import { IconButtonBase, renderIconButtonAsChild } from "./IconButtonBase.js";
4
+ import { IconButton } from "./IconButton.js";
5
+ export { IconButton, IconButtonBase, renderIconButtonAsChild };
@@ -4,7 +4,6 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("../../_virtual/_rolldown/runtime.cjs");
5
5
  const require_index = require("../../css-tokens/dist/index.cjs");
6
6
  const require_index$1 = require("../../motion-tokens/dist/index.cjs");
7
- const require_components_experimental_client_AvoidMotionLibraryProvider = require("../experimental/client/AvoidMotionLibraryProvider.cjs");
8
7
  let react = require("react");
9
8
  let react_jsx_runtime = require("react/jsx-runtime");
10
9
  let motion_react = require("motion/react");
@@ -72,22 +71,20 @@ function SpringMotionConfig({ children, reducedMotion = "user", loadFeatures = d
72
71
  layoutDampingVar,
73
72
  layoutStiffnessVar
74
73
  ]);
75
- const transition = (0, react.useMemo)(() => ({
76
- type: "spring",
77
- mass: 1,
78
- ...layoutConfig,
79
- layout: layoutConfig,
80
- opacity: colorConfig,
81
- color: colorConfig,
82
- borderColor: colorConfig,
83
- backgroundColor: colorConfig
84
- }), [colorConfig, layoutConfig]);
85
- if (require_components_experimental_client_AvoidMotionLibraryProvider.useAvoidMotionLibrary()) return children;
86
74
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.LazyMotion, {
87
75
  features: loadFeatures,
88
76
  strict: true,
89
77
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.MotionConfig, {
90
- transition,
78
+ transition: (0, react.useMemo)(() => ({
79
+ type: "spring",
80
+ mass: 1,
81
+ ...layoutConfig,
82
+ layout: layoutConfig,
83
+ opacity: colorConfig,
84
+ color: colorConfig,
85
+ borderColor: colorConfig,
86
+ backgroundColor: colorConfig
87
+ }), [colorConfig, layoutConfig]),
91
88
  reducedMotion,
92
89
  children
93
90
  })
@@ -2,7 +2,6 @@
2
2
  "use client";
3
3
  import { getMotionVar } from "../../css-tokens/dist/index.js";
4
4
  import { SPRING_MOTION_DEFAULTS, motion } from "../../motion-tokens/dist/index.js";
5
- import { useAvoidMotionLibrary } from "../experimental/client/AvoidMotionLibraryProvider.js";
6
5
  import { useEffect, useMemo, useState } from "react";
7
6
  import { jsx } from "react/jsx-runtime";
8
7
  import { LazyMotion, MotionConfig } from "motion/react";
@@ -70,22 +69,20 @@ function SpringMotionConfig({ children, reducedMotion = "user", loadFeatures = d
70
69
  layoutDampingVar,
71
70
  layoutStiffnessVar
72
71
  ]);
73
- const transition = useMemo(() => ({
74
- type: "spring",
75
- mass: 1,
76
- ...layoutConfig,
77
- layout: layoutConfig,
78
- opacity: colorConfig,
79
- color: colorConfig,
80
- borderColor: colorConfig,
81
- backgroundColor: colorConfig
82
- }), [colorConfig, layoutConfig]);
83
- if (useAvoidMotionLibrary()) return children;
84
72
  return /* @__PURE__ */ jsx(LazyMotion, {
85
73
  features: loadFeatures,
86
74
  strict: true,
87
75
  children: /* @__PURE__ */ jsx(MotionConfig, {
88
- transition,
76
+ transition: useMemo(() => ({
77
+ type: "spring",
78
+ mass: 1,
79
+ ...layoutConfig,
80
+ layout: layoutConfig,
81
+ opacity: colorConfig,
82
+ color: colorConfig,
83
+ borderColor: colorConfig,
84
+ backgroundColor: colorConfig
85
+ }), [colorConfig, layoutConfig]),
89
86
  reducedMotion,
90
87
  children
91
88
  })
@@ -0,0 +1,119 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
5
+ const require_styles_styler = require("../../../styles/styler.cjs");
6
+ const require_components_IconSlot = require("../../IconSlot.cjs");
7
+ const require_components_Box = require("../../Box.cjs");
8
+ const require_components_client_SpringMotionConfig = require("../SpringMotionConfig.cjs");
9
+ const require_hooks_usePrefersReducedMotion = require("../../../hooks/usePrefersReducedMotion.cjs");
10
+ const require_components_client_Switch_SwitchBase = require("./SwitchBase.cjs");
11
+ let react = require("react");
12
+ react = require_runtime.__toESM(react);
13
+ let react_jsx_runtime = require("react/jsx-runtime");
14
+ let motion_react_m = require("motion/react-m");
15
+ motion_react_m = require_runtime.__toESM(motion_react_m);
16
+ //#region src/components/client/Switch/Switch.tsx
17
+ const MotionBox = motion_react_m.create(require_components_Box.Box);
18
+ MotionBox.displayName = "SwitchMotionBox";
19
+ const toggleTransition = {
20
+ layoutVariant: "bouncy",
21
+ layoutSpeed: "4"
22
+ };
23
+ /**
24
+ * **⚙️️ An switch.
25
+ *
26
+ * @componentType Client component
27
+ *
28
+ * @description
29
+ * 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.
30
+ *
31
+ * @see
32
+ * Check out the {@link https://uds.build/docs/components/switch Switch Docs} for more info
33
+ *
34
+ * @usage
35
+ * - Forms: switch
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * 'use client';
40
+ * import { Switch } from "@yahoo/uds";
41
+ *
42
+ * <Switch label="Name" required />
43
+ *```
44
+ *
45
+ * @related [Checkbox](https://uds.build/docs/components/checkbox).
46
+ **/
47
+ const Switch = (0, react.forwardRef)(function Switch({ reduceMotion: forceReduceMotion, ...props }, parentRef) {
48
+ const prefersReducedMotion = require_hooks_usePrefersReducedMotion.usePrefersReducedMotion();
49
+ const reduceMotion = forceReduceMotion ? "always" : "user";
50
+ const cssAnimationDuration = prefersReducedMotion || forceReduceMotion ? "duration-0" : "duration-120";
51
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_Switch_SwitchBase.SwitchBase, {
52
+ ...props,
53
+ ref: parentRef,
54
+ cssAnimationDuration,
55
+ enableHoverTracking: true,
56
+ renderHandle: ({ size, isOn, isOnX, showHoverEffect, disabled, onIcon, offIcon, cssAnimationDuration, handleSlotProps }) => {
57
+ const motionInitialAndAnimate = {
58
+ initial: {
59
+ scale: 1,
60
+ x: isOn ? isOnX : 0
61
+ },
62
+ animate: {
63
+ scale: showHoverEffect ? 1.05 : 1,
64
+ x: isOn ? isOnX : 0
65
+ }
66
+ };
67
+ const classNames = {
68
+ handle: require_styles_styler.getStyles({
69
+ switchSizeHandle: size,
70
+ className: require_styles_styler.cx("relative", "pointer-events-none", "uds-border-radius-full", "overflow-hidden")
71
+ }),
72
+ handleCircle: require_styles_styler.getStyles({
73
+ switchVariantActiveHandle: isOn ? "on" : "off",
74
+ switchVariantHandle: "default",
75
+ className: require_styles_styler.cx("absolute", "top-0", "left-0", "right-0", "bottom-0", "opacity-95", !disabled && "group-hover:opacity-100", cssAnimationDuration, "transition-[background-color,box-shadow,opacity]")
76
+ }),
77
+ handleIcon: require_styles_styler.getStyles({
78
+ switchSizeHandleIcon: size,
79
+ switchVariantHandleIcon: "default",
80
+ switchVariantActiveHandleIcon: isOn ? "on" : "off",
81
+ className: require_styles_styler.cx("absolute", "opacity-0", "top-1/2", "left-1/2", "transform", "translate-x-[-50%]", "translate-y-[-50%]", cssAnimationDuration, "transition-opacity")
82
+ })
83
+ };
84
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
85
+ reducedMotion: reduceMotion,
86
+ ...toggleTransition,
87
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(MotionBox, {
88
+ className: classNames.handle,
89
+ ...motionInitialAndAnimate,
90
+ ...handleSlotProps,
91
+ children: [
92
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, { className: classNames.handleCircle }),
93
+ onIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
94
+ icon: onIcon,
95
+ iconProps: {
96
+ variant: "fill",
97
+ size: "sm"
98
+ },
99
+ "data-testid": "on-icon",
100
+ className: require_styles_styler.cx(classNames.handleIcon, isOn ? "opacity-100" : "opacity-0")
101
+ }),
102
+ offIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
103
+ icon: offIcon,
104
+ iconProps: {
105
+ variant: "fill",
106
+ size: "sm"
107
+ },
108
+ "data-testid": "off-icon",
109
+ className: require_styles_styler.cx(classNames.handleIcon, !isOn ? "opacity-100" : "opacity-0")
110
+ })
111
+ ]
112
+ })
113
+ });
114
+ }
115
+ });
116
+ });
117
+ Switch.displayName = "Switch";
118
+ //#endregion
119
+ exports.Switch = Switch;
@@ -1,21 +1,9 @@
1
1
 
2
- import { UniversalSwitchProps } from "../../types/dist/index.cjs";
2
+ import { SwitchProps as SwitchProps$1 } from "./types.cjs";
3
3
  import React from "react";
4
4
 
5
- //#region src/components/client/Switch.d.ts
6
- type NativeInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'size' | 'height' | 'width' | 'color' | 'defaultChecked' | 'children'>;
7
- type DataAttributes = {
8
- [name: `data-${string}`]: string;
9
- };
10
- interface SwitchProps extends NativeInputProps, UniversalSwitchProps {
11
- /** Props to be passed into various slots within the component. */
12
- slotProps?: {
13
- root?: DataAttributes;
14
- switch?: DataAttributes;
15
- handle?: DataAttributes;
16
- label?: DataAttributes;
17
- };
18
- }
5
+ //#region src/components/client/Switch/Switch.d.ts
6
+ type SwitchProps = SwitchProps$1;
19
7
  /**
20
8
  * **⚙️️ An switch.
21
9
  *
@@ -40,6 +28,6 @@ interface SwitchProps extends NativeInputProps, UniversalSwitchProps {
40
28
  *
41
29
  * @related [Checkbox](https://uds.build/docs/components/checkbox).
42
30
  **/
43
- declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
31
+ declare const Switch: React.ForwardRefExoticComponent<SwitchProps$1 & React.RefAttributes<HTMLInputElement>>;
44
32
  //#endregion
45
33
  export { Switch, type SwitchProps };
@@ -1,22 +1,10 @@
1
1
 
2
2
  "use client";
3
- import { UniversalSwitchProps } from "../../types/dist/index.js";
3
+ import { SwitchProps as SwitchProps$1 } from "./types.js";
4
4
  import React from "react";
5
5
 
6
- //#region src/components/client/Switch.d.ts
7
- type NativeInputProps = Omit<React.InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'size' | 'height' | 'width' | 'color' | 'defaultChecked' | 'children'>;
8
- type DataAttributes = {
9
- [name: `data-${string}`]: string;
10
- };
11
- interface SwitchProps extends NativeInputProps, UniversalSwitchProps {
12
- /** Props to be passed into various slots within the component. */
13
- slotProps?: {
14
- root?: DataAttributes;
15
- switch?: DataAttributes;
16
- handle?: DataAttributes;
17
- label?: DataAttributes;
18
- };
19
- }
6
+ //#region src/components/client/Switch/Switch.d.ts
7
+ type SwitchProps = SwitchProps$1;
20
8
  /**
21
9
  * **⚙️️ An switch.
22
10
  *
@@ -41,6 +29,6 @@ interface SwitchProps extends NativeInputProps, UniversalSwitchProps {
41
29
  *
42
30
  * @related [Checkbox](https://uds.build/docs/components/checkbox).
43
31
  **/
44
- declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLInputElement>>;
32
+ declare const Switch: React.ForwardRefExoticComponent<SwitchProps$1 & React.RefAttributes<HTMLInputElement>>;
45
33
  //#endregion
46
34
  export { Switch, type SwitchProps };
@@ -0,0 +1,115 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ import { cx, getStyles } from "../../../styles/styler.js";
4
+ import { IconSlot } from "../../IconSlot.js";
5
+ import { Box } from "../../Box.js";
6
+ import { SpringMotionConfig } from "../SpringMotionConfig.js";
7
+ import { usePrefersReducedMotion } from "../../../hooks/usePrefersReducedMotion.js";
8
+ import { SwitchBase } from "./SwitchBase.js";
9
+ import { forwardRef } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import * as m from "motion/react-m";
12
+ //#region src/components/client/Switch/Switch.tsx
13
+ const MotionBox = m.create(Box);
14
+ MotionBox.displayName = "SwitchMotionBox";
15
+ const toggleTransition = {
16
+ layoutVariant: "bouncy",
17
+ layoutSpeed: "4"
18
+ };
19
+ /**
20
+ * **⚙️️ An switch.
21
+ *
22
+ * @componentType Client component
23
+ *
24
+ * @description
25
+ * 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.
26
+ *
27
+ * @see
28
+ * Check out the {@link https://uds.build/docs/components/switch Switch Docs} for more info
29
+ *
30
+ * @usage
31
+ * - Forms: switch
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * 'use client';
36
+ * import { Switch } from "@yahoo/uds";
37
+ *
38
+ * <Switch label="Name" required />
39
+ *```
40
+ *
41
+ * @related [Checkbox](https://uds.build/docs/components/checkbox).
42
+ **/
43
+ const Switch = forwardRef(function Switch({ reduceMotion: forceReduceMotion, ...props }, parentRef) {
44
+ const prefersReducedMotion = usePrefersReducedMotion();
45
+ const reduceMotion = forceReduceMotion ? "always" : "user";
46
+ const cssAnimationDuration = prefersReducedMotion || forceReduceMotion ? "duration-0" : "duration-120";
47
+ return /* @__PURE__ */ jsx(SwitchBase, {
48
+ ...props,
49
+ ref: parentRef,
50
+ cssAnimationDuration,
51
+ enableHoverTracking: true,
52
+ renderHandle: ({ size, isOn, isOnX, showHoverEffect, disabled, onIcon, offIcon, cssAnimationDuration, handleSlotProps }) => {
53
+ const motionInitialAndAnimate = {
54
+ initial: {
55
+ scale: 1,
56
+ x: isOn ? isOnX : 0
57
+ },
58
+ animate: {
59
+ scale: showHoverEffect ? 1.05 : 1,
60
+ x: isOn ? isOnX : 0
61
+ }
62
+ };
63
+ const classNames = {
64
+ handle: getStyles({
65
+ switchSizeHandle: size,
66
+ className: cx("relative", "pointer-events-none", "uds-border-radius-full", "overflow-hidden")
67
+ }),
68
+ handleCircle: getStyles({
69
+ switchVariantActiveHandle: isOn ? "on" : "off",
70
+ switchVariantHandle: "default",
71
+ className: cx("absolute", "top-0", "left-0", "right-0", "bottom-0", "opacity-95", !disabled && "group-hover:opacity-100", cssAnimationDuration, "transition-[background-color,box-shadow,opacity]")
72
+ }),
73
+ handleIcon: getStyles({
74
+ switchSizeHandleIcon: size,
75
+ switchVariantHandleIcon: "default",
76
+ switchVariantActiveHandleIcon: isOn ? "on" : "off",
77
+ className: cx("absolute", "opacity-0", "top-1/2", "left-1/2", "transform", "translate-x-[-50%]", "translate-y-[-50%]", cssAnimationDuration, "transition-opacity")
78
+ })
79
+ };
80
+ return /* @__PURE__ */ jsx(SpringMotionConfig, {
81
+ reducedMotion: reduceMotion,
82
+ ...toggleTransition,
83
+ children: /* @__PURE__ */ jsxs(MotionBox, {
84
+ className: classNames.handle,
85
+ ...motionInitialAndAnimate,
86
+ ...handleSlotProps,
87
+ children: [
88
+ /* @__PURE__ */ jsx(Box, { className: classNames.handleCircle }),
89
+ onIcon && /* @__PURE__ */ jsx(IconSlot, {
90
+ icon: onIcon,
91
+ iconProps: {
92
+ variant: "fill",
93
+ size: "sm"
94
+ },
95
+ "data-testid": "on-icon",
96
+ className: cx(classNames.handleIcon, isOn ? "opacity-100" : "opacity-0")
97
+ }),
98
+ offIcon && /* @__PURE__ */ jsx(IconSlot, {
99
+ icon: offIcon,
100
+ iconProps: {
101
+ variant: "fill",
102
+ size: "sm"
103
+ },
104
+ "data-testid": "off-icon",
105
+ className: cx(classNames.handleIcon, !isOn ? "opacity-100" : "opacity-0")
106
+ })
107
+ ]
108
+ })
109
+ });
110
+ }
111
+ });
112
+ });
113
+ Switch.displayName = "Switch";
114
+ //#endregion
115
+ export { Switch };
@@ -0,0 +1,129 @@
1
+ /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
+ "use client";
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ const require_runtime = require("../../../_virtual/_rolldown/runtime.cjs");
5
+ const require_styles_styler = require("../../../styles/styler.cjs");
6
+ const require_components_Box = require("../../Box.cjs");
7
+ const require_components_FormLabel = require("../../FormLabel.cjs");
8
+ const require_components_client_Switch_switchStyles = require("./switchStyles.cjs");
9
+ let react = require("react");
10
+ react = require_runtime.__toESM(react);
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ //#region src/components/client/Switch/SwitchBase.tsx
13
+ const SwitchBase = (0, react.forwardRef)(function SwitchBase({ id, isOn: isOnProp, defaultIsOn, onChange, label, labelPosition = "start", size = "md", onIcon, offIcon, disabled, required, onFocus, onBlur, className, style, slotProps, cssAnimationDuration, enableHoverTracking = false, renderHandle, ...switchProps }, parentRef) {
14
+ const generatedId = (0, react.useId)();
15
+ const uid = id ?? `uds-input-${generatedId}`;
16
+ const rootSlotProps = slotProps?.root ?? {};
17
+ const switchSlotProps = slotProps?.switch ?? {};
18
+ const handleSlotProps = slotProps?.handle ?? {};
19
+ const labelSlotProps = slotProps?.label ?? {};
20
+ const innerRef = (0, react.useRef)(null);
21
+ const isControlled = isOnProp !== void 0;
22
+ const [uncontrolledIsOn, setUncontrolledIsOn] = (0, react.useState)(defaultIsOn ?? false);
23
+ const [isHovered, setIsHovered] = (0, react.useState)(false);
24
+ const showHoverEffect = (0, react.useMemo)(() => {
25
+ return enableHoverTracking && !disabled && isHovered;
26
+ }, [
27
+ disabled,
28
+ enableHoverTracking,
29
+ isHovered
30
+ ]);
31
+ const { isOnX, isOnTranslateClass } = require_components_client_Switch_switchStyles.SIZE_MAP[size];
32
+ const isOn = isControlled ? isOnProp ?? false : uncontrolledIsOn;
33
+ const handleChange = (0, react.useCallback)((e) => {
34
+ onChange?.(e);
35
+ if (!isControlled) setUncontrolledIsOn(e.target.checked);
36
+ }, [isControlled, onChange]);
37
+ const handleFocus = (0, react.useCallback)((e) => {
38
+ onFocus?.(e);
39
+ }, [onFocus]);
40
+ const handleBlur = (0, react.useCallback)((e) => {
41
+ onBlur?.(e);
42
+ }, [onBlur]);
43
+ const handleHoverStart = (0, react.useCallback)(() => {
44
+ if (enableHoverTracking) setIsHovered(true);
45
+ }, [enableHoverTracking]);
46
+ const handleHoverEnd = (0, react.useCallback)(() => {
47
+ if (enableHoverTracking) setIsHovered(false);
48
+ }, [enableHoverTracking]);
49
+ const classNames = {
50
+ root: require_styles_styler.getStyles({
51
+ switchSizeRoot: size,
52
+ switchVariantRoot: "default",
53
+ switchVariantActiveRoot: isOn ? "on" : "off",
54
+ display: "flex",
55
+ flexDirection: labelPosition === "start" ? "row" : "row-reverse",
56
+ alignItems: "center",
57
+ className: require_styles_styler.cx("group", {
58
+ "cursor-pointer": !disabled,
59
+ "cursor-default": disabled,
60
+ "opacity-50": disabled
61
+ }, className)
62
+ }),
63
+ switch: require_styles_styler.getStyles({
64
+ switchVariantSwitch: "default",
65
+ switchSizeSwitch: size,
66
+ switchVariantActiveSwitch: isOn ? "on" : "off",
67
+ borderRadius: "full",
68
+ position: "relative",
69
+ alignItems: "center",
70
+ className: require_styles_styler.cx("uds-ring", "uds-ring-within", cssAnimationDuration, "transition-[background-color,box-shadow]")
71
+ }),
72
+ htmlCheckbox: require_styles_styler.cx("cursor-[inherit]", "absolute", "opacity-0", "top-1/2", "left-1/2", "w-[calc(100%+2px)]", "h-[calc(100%+2px)]", "transform", "translate-x-[-50%]", "translate-y-[-50%]"),
73
+ label: require_styles_styler.cx(labelPosition === "start" ? "text-start" : "text-end")
74
+ };
75
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(label ? "label" : "div", {
76
+ className: classNames.root,
77
+ "data-testid": "container",
78
+ style,
79
+ tabIndex: -1,
80
+ onPointerEnter: handleHoverStart,
81
+ onPointerLeave: handleHoverEnd,
82
+ ...rootSlotProps,
83
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
84
+ className: classNames.switch,
85
+ ...switchSlotProps,
86
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
87
+ type: "checkbox",
88
+ tabIndex: 0,
89
+ ...switchProps,
90
+ ref: (ref) => {
91
+ innerRef.current = ref;
92
+ if (typeof parentRef === "function") parentRef(ref);
93
+ else if (parentRef !== null) parentRef.current = ref;
94
+ },
95
+ onFocus: handleFocus,
96
+ onBlur: handleBlur,
97
+ id: uid,
98
+ disabled,
99
+ required,
100
+ checked: isControlled ? isOn : void 0,
101
+ defaultChecked: isControlled ? void 0 : defaultIsOn,
102
+ onChange: handleChange,
103
+ className: classNames.htmlCheckbox
104
+ }), renderHandle({
105
+ size,
106
+ isOn,
107
+ isOnX,
108
+ isOnTranslateClass,
109
+ showHoverEffect,
110
+ disabled,
111
+ onIcon,
112
+ offIcon,
113
+ cssAnimationDuration,
114
+ handleSlotProps
115
+ })]
116
+ }), label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_FormLabel.FormLabel, {
117
+ as: "div",
118
+ variant: "inherit",
119
+ color: "inherit",
120
+ required,
121
+ label,
122
+ className: classNames.label,
123
+ ...labelSlotProps
124
+ })]
125
+ });
126
+ });
127
+ SwitchBase.displayName = "SwitchBase";
128
+ //#endregion
129
+ exports.SwitchBase = SwitchBase;