@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
@@ -1,321 +0,0 @@
1
- /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
- "use client";
3
- import { BUTTON_GAP_VAR, BUTTON_SCALE_EFFECT_HOVER, BUTTON_SCALE_EFFECT_PRESSED, BUTTON_SCALE_EFFECT_REST } from "../../css-tokens/dist/index.js";
4
- import { cx, getStyles } from "../../styles/styler.js";
5
- import { createSlot } from "../../utils/createSlot.js";
6
- import { Icon } from "../Icon.js";
7
- import { IconSlot } from "../IconSlot.js";
8
- import { generateDefaultClassName } from "../../automated-config/dist/utils/generateDefaultClassName.js";
9
- import "./buttonConstants.js";
10
- import { SpringMotionConfig } from "./SpringMotionConfig.js";
11
- import { Progress } from "@yahoo/uds-icons";
12
- import { cloneElement, forwardRef, isValidElement, useImperativeHandle, useMemo, useRef } from "react";
13
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
14
- import { AnimatePresence, m, useReducedMotion } from "motion/react";
15
- //#region src/components/client/Button.tsx
16
- const iconContainerMotionVariants = {
17
- hide: {
18
- display: "none",
19
- width: "0px",
20
- opacity: 0
21
- },
22
- loading: {
23
- display: "flex",
24
- width: "auto",
25
- opacity: 1
26
- },
27
- icon: {
28
- display: "flex",
29
- width: "auto",
30
- opacity: 1
31
- }
32
- };
33
- const SCALE_DOWN = .7;
34
- const hiddenState = {
35
- scale: SCALE_DOWN,
36
- opacity: 0
37
- };
38
- const visibleState = {
39
- scale: [
40
- SCALE_DOWN,
41
- SCALE_DOWN,
42
- 1
43
- ],
44
- opacity: [
45
- 0,
46
- 0,
47
- 1
48
- ],
49
- transition: { times: [
50
- 0,
51
- .5,
52
- 1
53
- ] }
54
- };
55
- const iconMotionVariants = {
56
- hide: hiddenState,
57
- icon: visibleState,
58
- loading: hiddenState
59
- };
60
- const loadingMotionVariants = {
61
- hide: hiddenState,
62
- icon: hiddenState,
63
- loading: visibleState
64
- };
65
- function getGapVariant({ startIcon, endIcon, loading }) {
66
- if (loading || startIcon || endIcon) return "withIcon";
67
- return "withoutIcon";
68
- }
69
- function getStartVariant({ loading, startIcon }) {
70
- if (loading) return "loading";
71
- if (startIcon) return "icon";
72
- return "hide";
73
- }
74
- const defaultVariantRootClass = generateDefaultClassName("button", "variant", "root");
75
- const defaultVariantIconClass = generateDefaultClassName("button", "variant", "icon");
76
- const defaultSizeRootClass = generateDefaultClassName("button", "size", "root");
77
- const defaultSizeIconClass = generateDefaultClassName("button", "size", "icon");
78
- /**
79
- * **🖲️ A button element that can be used to trigger an action**
80
- *
81
- * @componentType Client component
82
- *
83
- * @description A button is a fundamental component used to trigger an action or event. Buttons are interactive elements that users can click, tap, or otherwise engage with to submit forms, open dialogues, or perform any other interaction within an application or website. Consider an IconButton for buttons that only contain an icon.
84
- *
85
- * @see The {@link https://uds.build/docs/components/button Button Docs} for more info
86
- *
87
- * @example
88
- * ```tsx
89
- * 'use client';
90
- * import { Button, HStack } from "@yahoo/uds";
91
- *
92
- * export function Demo() {
93
- * return (
94
- * <HStack gap="2">
95
- * <Button onClick={console.log}>Save</Button>
96
- * <Button variant="secondary" onClick={console.log}>Cancel</Button>
97
- * </HStack>
98
- * )
99
- * }
100
- * ```
101
- *
102
- *
103
- * @usage
104
- * Buttons should be used to clearly indicate and initiate actions that users can take.
105
- *
106
- * @related [Icon](https://uds.build/docs/components/icon), [IconButton](https://uds.build/docs/components/icon-button), [Pressable](https://uds.build/docs/components/pressable)
107
- **/
108
- const Button = forwardRef(function Button({ size, variant, startIcon, endIcon, iconVariant, loading, disableEffects, children, asChild = false, slotProps, type = "button", className, width, ...rest }, forwardedRef) {
109
- const ref = useRef(null);
110
- useImperativeHandle(forwardedRef, () => ref.current);
111
- const { className: startIconClassName, ...startIconSlotProps } = slotProps?.startIcon ?? {};
112
- const { className: endIconClassName, ...endIconSlotProps } = slotProps?.endIcon ?? {};
113
- const { className: contentClassName, ...contentSlotProps } = slotProps?.content ?? {};
114
- const prefersReducedMotion = useReducedMotion();
115
- const disableMotion = !!disableEffects || !!rest?.disabled;
116
- const layoutVariant = prefersReducedMotion ? "smooth" : "subtle";
117
- const endVariant = endIcon ? "icon" : "hide";
118
- const gapVariant = getGapVariant({
119
- startIcon,
120
- endIcon,
121
- loading
122
- });
123
- const startVariant = getStartVariant({
124
- loading,
125
- startIcon
126
- });
127
- const Slot = useMemo(() => createSlot(), []);
128
- const MotionSlot = useMemo(() => m.create(Slot), [Slot]);
129
- const buttonVariants = useMemo(() => ({
130
- rest: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_REST})` },
131
- hover: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_HOVER})` },
132
- pressed: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_PRESSED})` },
133
- withIcon: { columnGap: `var(${BUTTON_GAP_VAR})` },
134
- withoutIcon: { columnGap: "0px" }
135
- }), [disableMotion]);
136
- const rootSizeClass = useMemo(() => size ? getStyles({ buttonSizeRoot: size }) : defaultSizeRootClass, [size]);
137
- const rootVariantClass = useMemo(() => variant ? getStyles({ buttonVariantRoot: variant }) : defaultVariantRootClass, [variant]);
138
- const iconSizeClass = useMemo(() => size ? getStyles({ buttonSizeIcon: size }) : defaultSizeIconClass, [size]);
139
- const iconVariantClass = useMemo(() => variant ? getStyles({ buttonVariantIcon: variant }) : defaultVariantIconClass, [variant]);
140
- const styles = useMemo(() => ({
141
- root: getStyles({
142
- width,
143
- className: cx([
144
- "uds-ring",
145
- "uds-hit-target",
146
- "inline-flex max-w-full overflow-hidden justify-center items-center whitespace-nowrap select-none",
147
- "[transform-origin:center]",
148
- "[backface-visibility:hidden]",
149
- "[transition-property:color,background-color,border-color,box-shadow,text-decoration-color,fill,stroke]",
150
- "[transition-timing-function:cubic-bezier(0,0,0.2,1)]",
151
- "[transition-duration:220ms]",
152
- rootSizeClass,
153
- rootVariantClass,
154
- rest?.disabled && "cursor-not-allowed",
155
- loading && "uds-button-loading",
156
- disableEffects && "uds-button-without-effects",
157
- gapVariant === "withIcon" && "uds-button-with-gap",
158
- className
159
- ])
160
- }),
161
- iconContainer: "flex shrink-0 overflow-clip uds-button-icon-container",
162
- icon: getStyles({ className: cx([iconSizeClass, iconVariantClass]) }),
163
- loadingIcon: getStyles({ className: cx([
164
- "animate-spin",
165
- iconSizeClass,
166
- iconVariantClass
167
- ]) }),
168
- content: cx(["min-w-0 truncate"])
169
- }), [
170
- className,
171
- disableEffects,
172
- gapVariant,
173
- iconSizeClass,
174
- iconVariantClass,
175
- loading,
176
- rest?.disabled,
177
- rootSizeClass,
178
- rootVariantClass,
179
- width
180
- ]);
181
- const startContent = useMemo(() => /* @__PURE__ */ jsx(m.span, {
182
- className: styles.iconContainer,
183
- initial: false,
184
- variants: iconContainerMotionVariants,
185
- animate: startVariant,
186
- children: /* @__PURE__ */ jsxs(AnimatePresence, {
187
- initial: false,
188
- mode: "popLayout",
189
- children: [loading && /* @__PURE__ */ jsx(m.span, {
190
- variants: loadingMotionVariants,
191
- initial: "hide",
192
- animate: "loading",
193
- exit: "hide",
194
- children: /* @__PURE__ */ jsx(Icon, {
195
- className: styles.loadingIcon,
196
- size: "sm",
197
- name: Progress,
198
- variant: iconVariant,
199
- color: "current"
200
- })
201
- }, "loading"), startIcon && !loading && /* @__PURE__ */ jsx(m.span, {
202
- variants: iconMotionVariants,
203
- initial: "hide",
204
- animate: "icon",
205
- exit: "hide",
206
- children: /* @__PURE__ */ jsx(IconSlot, {
207
- className: cx(styles.icon, startIconClassName),
208
- icon: startIcon,
209
- iconProps: {
210
- size: "sm",
211
- variant: iconVariant,
212
- color: "current"
213
- },
214
- ...startIconSlotProps
215
- })
216
- })]
217
- })
218
- }), [
219
- styles,
220
- iconVariant,
221
- loading,
222
- startIcon,
223
- startVariant,
224
- startIconClassName,
225
- startIconSlotProps
226
- ]);
227
- const endContent = useMemo(() => /* @__PURE__ */ jsx(m.span, {
228
- className: styles.iconContainer,
229
- initial: false,
230
- variants: iconContainerMotionVariants,
231
- animate: endVariant,
232
- children: /* @__PURE__ */ jsx(AnimatePresence, {
233
- initial: false,
234
- mode: "popLayout",
235
- children: endIcon && /* @__PURE__ */ jsx(m.span, {
236
- variants: iconMotionVariants,
237
- initial: "hide",
238
- animate: "icon",
239
- exit: "hide",
240
- children: /* @__PURE__ */ jsx(IconSlot, {
241
- className: cx(styles.icon, endIconClassName),
242
- icon: endIcon,
243
- iconProps: {
244
- size: "sm",
245
- variant: iconVariant,
246
- color: "current"
247
- },
248
- ...endIconSlotProps
249
- })
250
- })
251
- })
252
- }), [
253
- endIcon,
254
- styles,
255
- iconVariant,
256
- endVariant,
257
- endIconClassName,
258
- endIconSlotProps
259
- ]);
260
- if (asChild && isValidElement(children)) {
261
- const childProps = children.props;
262
- return /* @__PURE__ */ jsx(SpringMotionConfig, {
263
- layoutSpeed: "3",
264
- layoutVariant,
265
- children: /* @__PURE__ */ jsx(MotionSlot, {
266
- type,
267
- className: styles.root,
268
- initial: ["rest", gapVariant],
269
- animate: [
270
- "hide",
271
- "rest",
272
- gapVariant
273
- ],
274
- variants: buttonVariants,
275
- whileHover: "hover",
276
- whileTap: "pressed",
277
- ...rest,
278
- children: cloneElement(children, childProps, /* @__PURE__ */ jsxs(Fragment$1, { children: [
279
- startContent,
280
- /* @__PURE__ */ jsx("span", {
281
- className: cx(styles.content, contentClassName),
282
- ...contentSlotProps,
283
- children: children.props.children
284
- }),
285
- endContent
286
- ] }))
287
- })
288
- });
289
- }
290
- return /* @__PURE__ */ jsx(SpringMotionConfig, {
291
- layoutSpeed: "3",
292
- layoutVariant,
293
- children: /* @__PURE__ */ jsxs(m.button, {
294
- ref,
295
- type,
296
- className: styles.root,
297
- initial: ["rest", gapVariant],
298
- animate: [
299
- "hide",
300
- "rest",
301
- gapVariant
302
- ],
303
- variants: buttonVariants,
304
- whileHover: "hover",
305
- whileTap: "pressed",
306
- ...rest,
307
- children: [
308
- startContent,
309
- /* @__PURE__ */ jsx("span", {
310
- className: cx(styles.content, contentClassName),
311
- ...contentSlotProps,
312
- children
313
- }),
314
- endContent
315
- ]
316
- })
317
- });
318
- });
319
- Button.displayName = "Button";
320
- //#endregion
321
- export { Button, iconMotionVariants, loadingMotionVariants };
@@ -1,161 +0,0 @@
1
- /*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
2
- "use client";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- require("../../_virtual/_rolldown/runtime.cjs");
5
- const require_index = require("../../css-tokens/dist/index.cjs");
6
- const require_styles_styler = require("../../styles/styler.cjs");
7
- const require_utils_createSlot = require("../../utils/createSlot.cjs");
8
- const require_components_Icon = require("../Icon.cjs");
9
- const require_generateDefaultClassName = require("../../automated-config/dist/utils/generateDefaultClassName.cjs");
10
- require("./buttonConstants.cjs");
11
- const require_components_client_SpringMotionConfig = require("./SpringMotionConfig.cjs");
12
- const require_components_client_Button = require("./Button.cjs");
13
- let _yahoo_uds_icons = require("@yahoo/uds-icons");
14
- let react = require("react");
15
- let react_jsx_runtime = require("react/jsx-runtime");
16
- let motion_react = require("motion/react");
17
- //#region src/components/client/IconButton.tsx
18
- const defaultSizeRootClass = require_generateDefaultClassName.generateDefaultClassName("iconbutton", "size", "root");
19
- const defaultSizeIconClass = require_generateDefaultClassName.generateDefaultClassName("iconbutton", "size", "icon");
20
- const defaultVariantRootClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "root");
21
- const defaultVariantIconClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "icon");
22
- /**
23
- * **⚙️️ An icon button element that can be used to trigger an action**
24
- *
25
- * @componentType Client component
26
- *
27
- * @description An icon button is essentially an interactive icon. They should be used to display an icon which, when clicked, allows the user to trigger an action. Icon buttons provide additional features such hover states, focus states, and pressable functionality.
28
- *
29
- * @see
30
- * Check out the {@link https://uds.build/docs/components/icon-button IconButton Docs} for more info
31
- *
32
- * @usage
33
- * - When you need a button that is represented by an icon rather than text. This is useful in compact spaces, toolbars, or when the action is commonly understood through a visual symbol.
34
- * - If you need a button that is used to trigger a non-critical action.
35
- *
36
- * @example
37
- * ```tsx
38
- * 'use client';
39
- * import { IconButton } from "@yahoo/uds";
40
- * import { AddFolder } from "@yahoo/uds-icons";
41
- *
42
- * <IconButton name={AddFolder} variant="primary" />
43
- * ```
44
- *
45
- * @related [Icon](https://uds.build/docs/components/icon), [Button](https://uds.build/docs/components/button), and [Pressable](https://uds.build/docs/components/pressable)
46
- *
47
- **/
48
- const IconButton = (0, react.forwardRef)(function IconButton({ variant, size, iconVariant, loading, disableEffects, name, asChild = false, slotProps, type = "button", htmlName, className, children, ...rest }, forwardedRef) {
49
- const ref = (0, react.useRef)(null);
50
- (0, react.useImperativeHandle)(forwardedRef, () => ref.current);
51
- const { className: iconSlotClassName, ...iconSlotProps } = slotProps?.icon ?? {};
52
- const prefersReducedMotion = (0, motion_react.useReducedMotion)();
53
- const disableMotion = !!disableEffects || !!rest?.disabled;
54
- const layoutVariant = (0, react.useMemo)(() => prefersReducedMotion ? "smooth" : "subtle", [prefersReducedMotion]);
55
- const Slot = (0, react.useMemo)(() => require_utils_createSlot.createSlot(), []);
56
- const MotionSlot = (0, react.useMemo)(() => motion_react.m.create(Slot), [Slot]);
57
- const buttonVariants = (0, react.useMemo)(() => ({
58
- rest: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_REST})` },
59
- hover: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_HOVER})` },
60
- pressed: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_PRESSED})` }
61
- }), [disableMotion]);
62
- const rootSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ iconbuttonSizeRoot: size }) : defaultSizeRootClass, [size]);
63
- const rootVariantClass = (0, react.useMemo)(() => variant ? require_styles_styler.getStyles({ buttonVariantRoot: variant }) : defaultVariantRootClass, [variant]);
64
- const iconSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ iconbuttonSizeIcon: size }) : defaultSizeIconClass, [size]);
65
- const iconVariantClass = (0, react.useMemo)(() => variant ? require_styles_styler.getStyles({ buttonVariantIcon: variant }) : defaultVariantIconClass, [variant]);
66
- const styles = (0, react.useMemo)(() => ({
67
- root: require_styles_styler.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),
68
- icon: require_styles_styler.getStyles({ className: require_styles_styler.cx(iconSizeClass, iconVariantClass) }),
69
- loadingIcon: require_styles_styler.getStyles({ className: require_styles_styler.cx([
70
- "animate-spin",
71
- iconSizeClass,
72
- iconVariantClass
73
- ]) })
74
- }), [
75
- className,
76
- disableEffects,
77
- iconSizeClass,
78
- iconVariantClass,
79
- loading,
80
- rest?.disabled,
81
- rootSizeClass,
82
- rootVariantClass
83
- ]);
84
- const iconContent = (0, react.useMemo)(() => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(motion_react.AnimatePresence, {
85
- initial: false,
86
- mode: "popLayout",
87
- children: [loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
88
- variants: require_components_client_Button.loadingMotionVariants,
89
- initial: "loading",
90
- animate: "loading",
91
- exit: "hide",
92
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
93
- size: "sm",
94
- name: _yahoo_uds_icons.Progress,
95
- variant: iconVariant,
96
- color: "current",
97
- className: styles.loadingIcon
98
- })
99
- }, "loading"), name && !loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
100
- variants: require_components_client_Button.iconMotionVariants,
101
- initial: "icon",
102
- animate: "icon",
103
- exit: "hide",
104
- children: !asChild && children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
105
- size: "sm",
106
- name,
107
- variant: iconVariant,
108
- color: "current",
109
- className: require_styles_styler.cx(styles.icon, iconSlotClassName),
110
- ...iconSlotProps
111
- })
112
- }, name.name)]
113
- }), [
114
- asChild,
115
- children,
116
- iconSlotClassName,
117
- iconSlotProps,
118
- iconVariant,
119
- loading,
120
- name,
121
- styles
122
- ]);
123
- if (asChild && (0, react.isValidElement)(children)) {
124
- const childProps = children.props;
125
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
126
- layoutSpeed: "3",
127
- layoutVariant,
128
- reducedMotion: disableEffects ? "always" : "user",
129
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MotionSlot, {
130
- type,
131
- className: styles.root,
132
- initial: "icon",
133
- variants: buttonVariants,
134
- whileHover: "hover",
135
- whileTap: "pressed",
136
- ...rest,
137
- children: (0, react.cloneElement)(children, childProps, iconContent)
138
- })
139
- });
140
- }
141
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
142
- layoutSpeed: "3",
143
- layoutVariant,
144
- reducedMotion: disableEffects ? "always" : "user",
145
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.button, {
146
- ref,
147
- type,
148
- className: styles.root,
149
- name: htmlName,
150
- initial: "icon",
151
- variants: buttonVariants,
152
- whileHover: "hover",
153
- whileTap: "pressed",
154
- ...rest,
155
- children: iconContent
156
- })
157
- });
158
- });
159
- IconButton.displayName = "IconButton";
160
- //#endregion
161
- exports.IconButton = IconButton;
@@ -1,46 +0,0 @@
1
-
2
- import { IconPropsWithSVGProps, UniversalIconButtonProps } from "../../tokens/types.cjs";
3
- import * as _$react from "react";
4
- import { ForwardRefExoticComponent } from "react";
5
- import { HTMLMotionProps } from "motion/react";
6
-
7
- //#region src/components/client/IconButton.d.ts
8
- type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'> & Omit<HTMLMotionProps<'button'>, 'name'>;
9
- type DataAttributes = {
10
- [name: `data-${string}`]: string;
11
- };
12
- interface IconButtonProps extends HtmlButtonProps, UniversalIconButtonProps {
13
- /** Props to be passed into various slots within the component. */
14
- slotProps?: {
15
- icon?: Partial<IconPropsWithSVGProps & DataAttributes>;
16
- };
17
- }
18
- /**
19
- * **⚙️️ An icon button element that can be used to trigger an action**
20
- *
21
- * @componentType Client component
22
- *
23
- * @description An icon button is essentially an interactive icon. They should be used to display an icon which, when clicked, allows the user to trigger an action. Icon buttons provide additional features such hover states, focus states, and pressable functionality.
24
- *
25
- * @see
26
- * Check out the {@link https://uds.build/docs/components/icon-button IconButton Docs} for more info
27
- *
28
- * @usage
29
- * - When you need a button that is represented by an icon rather than text. This is useful in compact spaces, toolbars, or when the action is commonly understood through a visual symbol.
30
- * - If you need a button that is used to trigger a non-critical action.
31
- *
32
- * @example
33
- * ```tsx
34
- * 'use client';
35
- * import { IconButton } from "@yahoo/uds";
36
- * import { AddFolder } from "@yahoo/uds-icons";
37
- *
38
- * <IconButton name={AddFolder} variant="primary" />
39
- * ```
40
- *
41
- * @related [Icon](https://uds.build/docs/components/icon), [Button](https://uds.build/docs/components/button), and [Pressable](https://uds.build/docs/components/pressable)
42
- *
43
- **/
44
- declare const IconButton: ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
45
- //#endregion
46
- export { IconButton, type IconButtonProps };
@@ -1,47 +0,0 @@
1
-
2
- "use client";
3
- import { IconPropsWithSVGProps, UniversalIconButtonProps } from "../../tokens/types.js";
4
- import * as _$react from "react";
5
- import { ForwardRefExoticComponent } from "react";
6
- import { HTMLMotionProps } from "motion/react";
7
-
8
- //#region src/components/client/IconButton.d.ts
9
- type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'> & Omit<HTMLMotionProps<'button'>, 'name'>;
10
- type DataAttributes = {
11
- [name: `data-${string}`]: string;
12
- };
13
- interface IconButtonProps extends HtmlButtonProps, UniversalIconButtonProps {
14
- /** Props to be passed into various slots within the component. */
15
- slotProps?: {
16
- icon?: Partial<IconPropsWithSVGProps & DataAttributes>;
17
- };
18
- }
19
- /**
20
- * **⚙️️ An icon button element that can be used to trigger an action**
21
- *
22
- * @componentType Client component
23
- *
24
- * @description An icon button is essentially an interactive icon. They should be used to display an icon which, when clicked, allows the user to trigger an action. Icon buttons provide additional features such hover states, focus states, and pressable functionality.
25
- *
26
- * @see
27
- * Check out the {@link https://uds.build/docs/components/icon-button IconButton Docs} for more info
28
- *
29
- * @usage
30
- * - When you need a button that is represented by an icon rather than text. This is useful in compact spaces, toolbars, or when the action is commonly understood through a visual symbol.
31
- * - If you need a button that is used to trigger a non-critical action.
32
- *
33
- * @example
34
- * ```tsx
35
- * 'use client';
36
- * import { IconButton } from "@yahoo/uds";
37
- * import { AddFolder } from "@yahoo/uds-icons";
38
- *
39
- * <IconButton name={AddFolder} variant="primary" />
40
- * ```
41
- *
42
- * @related [Icon](https://uds.build/docs/components/icon), [Button](https://uds.build/docs/components/button), and [Pressable](https://uds.build/docs/components/pressable)
43
- *
44
- **/
45
- declare const IconButton: ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
46
- //#endregion
47
- export { IconButton, type IconButtonProps };