@yahoo/uds 3.159.1 → 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.
- package/dist/automated-config/dist/properties.cjs +1 -1
- package/dist/automated-config/dist/properties.js +1 -1
- package/dist/components/Text.cjs +4 -2
- package/dist/components/Text.js +4 -2
- package/dist/components/client/Button/Button.cjs +213 -0
- package/dist/components/client/Button/Button.d.cts +50 -0
- package/dist/components/client/Button/Button.d.ts +51 -0
- package/dist/components/client/Button/Button.js +208 -0
- package/dist/components/client/Button/ButtonBase.cjs +120 -0
- package/dist/components/client/Button/ButtonBase.d.cts +52 -0
- package/dist/components/client/Button/ButtonBase.d.ts +53 -0
- package/dist/components/client/Button/ButtonBase.js +116 -0
- package/dist/components/client/{buttonConstants.cjs → Button/buttonConstants.cjs} +1 -1
- package/dist/components/client/Button/buttonConstants.d.cts +7 -0
- package/dist/components/client/Button/buttonConstants.d.ts +8 -0
- package/dist/components/client/{buttonConstants.js → Button/buttonConstants.js} +1 -1
- package/dist/components/client/Button/index.cjs +10 -0
- package/dist/components/client/Button/index.d.cts +4 -0
- package/dist/components/client/Button/index.d.ts +5 -0
- package/dist/components/client/Button/index.js +5 -0
- package/dist/components/client/IconButton/IconButton.cjs +104 -0
- package/dist/components/client/IconButton/IconButton.d.cts +17 -0
- package/dist/components/client/IconButton/IconButton.d.ts +18 -0
- package/dist/components/client/IconButton/IconButton.js +102 -0
- package/dist/components/client/IconButton/IconButtonBase.cjs +68 -0
- package/dist/components/client/IconButton/IconButtonBase.d.cts +45 -0
- package/dist/components/client/IconButton/IconButtonBase.d.ts +46 -0
- package/dist/components/client/IconButton/IconButtonBase.js +65 -0
- package/dist/components/client/IconButton/index.cjs +8 -0
- package/dist/components/client/IconButton/index.d.cts +4 -0
- package/dist/components/client/IconButton/index.d.ts +5 -0
- package/dist/components/client/IconButton/index.js +5 -0
- package/dist/components/client/Pressable.cjs +3 -1
- package/dist/components/client/Pressable.js +3 -1
- package/dist/components/client/SpringMotionConfig.cjs +10 -13
- package/dist/components/client/SpringMotionConfig.js +10 -13
- package/dist/components/client/Switch/Switch.cjs +119 -0
- package/dist/components/client/{Switch.d.cts → Switch/Switch.d.cts} +4 -16
- package/dist/components/client/{Switch.d.ts → Switch/Switch.d.ts} +4 -16
- package/dist/components/client/Switch/Switch.js +115 -0
- package/dist/components/client/Switch/SwitchBase.cjs +129 -0
- package/dist/components/client/Switch/SwitchBase.d.cts +29 -0
- package/dist/components/client/Switch/SwitchBase.d.ts +30 -0
- package/dist/components/client/Switch/SwitchBase.js +126 -0
- package/dist/components/client/Switch/index.cjs +5 -0
- package/dist/components/client/Switch/index.d.cts +3 -0
- package/dist/components/client/Switch/index.d.ts +4 -0
- package/dist/components/client/Switch/index.js +4 -0
- package/dist/components/client/Switch/switchStyles.cjs +17 -0
- package/dist/components/client/Switch/switchStyles.d.cts +9 -0
- package/dist/components/client/Switch/switchStyles.d.ts +10 -0
- package/dist/components/client/Switch/switchStyles.js +16 -0
- package/dist/components/client/Switch/types.cjs +2 -0
- package/dist/components/client/Switch/types.d.cts +33 -0
- package/dist/components/client/Switch/types.d.ts +34 -0
- package/dist/components/client/Switch/types.js +2 -0
- package/dist/components/client/Toast/Toast.cjs +2 -2
- package/dist/components/client/Toast/Toast.d.cts +1 -1
- package/dist/components/client/Toast/Toast.d.ts +1 -1
- package/dist/components/client/Toast/Toast.js +1 -1
- package/dist/components/client/index.cjs +6 -6
- package/dist/components/client/index.d.cts +3 -3
- package/dist/components/client/index.d.ts +3 -3
- package/dist/components/client/index.js +3 -3
- package/dist/components/experimental/client/index.cjs +0 -6
- package/dist/components/experimental/client/index.d.cts +1 -3
- package/dist/components/experimental/client/index.d.ts +1 -3
- package/dist/components/experimental/client/index.js +1 -3
- package/dist/components/experimental/index.cjs +0 -5
- package/dist/components/experimental/index.d.cts +1 -3
- package/dist/components/experimental/index.d.ts +1 -3
- package/dist/components/experimental/index.js +1 -3
- package/dist/components/index.cjs +6 -6
- package/dist/components/index.d.cts +3 -3
- package/dist/components/index.d.ts +3 -3
- package/dist/components/index.js +3 -3
- package/dist/css-animation/Button/Button.cjs +85 -0
- package/dist/css-animation/Button/Button.d.cts +13 -0
- package/dist/css-animation/Button/Button.d.ts +14 -0
- package/dist/css-animation/Button/Button.js +82 -0
- package/dist/css-animation/Button/index.cjs +5 -0
- package/dist/css-animation/Button/index.d.cts +4 -0
- package/dist/css-animation/Button/index.d.ts +5 -0
- package/dist/css-animation/Button/index.js +4 -0
- package/dist/css-animation/IconButton/IconButton.cjs +55 -0
- package/dist/css-animation/IconButton/IconButton.d.cts +13 -0
- package/dist/css-animation/IconButton/IconButton.d.ts +14 -0
- package/dist/css-animation/IconButton/IconButton.js +53 -0
- package/dist/css-animation/IconButton/index.cjs +5 -0
- package/dist/css-animation/IconButton/index.d.cts +4 -0
- package/dist/css-animation/IconButton/index.d.ts +5 -0
- package/dist/css-animation/IconButton/index.js +4 -0
- package/dist/css-animation/Switch/Switch.cjs +44 -0
- package/dist/css-animation/Switch/Switch.d.cts +22 -0
- package/dist/css-animation/Switch/Switch.d.ts +23 -0
- package/dist/css-animation/Switch/Switch.js +41 -0
- package/dist/css-animation/Switch/SwitchStaticHandle.cjs +56 -0
- package/dist/css-animation/Switch/SwitchStaticHandle.d.cts +31 -0
- package/dist/css-animation/Switch/SwitchStaticHandle.d.ts +32 -0
- package/dist/css-animation/Switch/SwitchStaticHandle.js +54 -0
- package/dist/css-animation/Switch/index.cjs +5 -0
- package/dist/css-animation/Switch/index.d.cts +3 -0
- package/dist/css-animation/Switch/index.d.ts +4 -0
- package/dist/css-animation/Switch/index.js +4 -0
- package/dist/css-animation/index.cjs +9 -0
- package/dist/css-animation/index.d.cts +7 -0
- package/dist/css-animation/index.d.ts +8 -0
- package/dist/css-animation/index.js +6 -0
- package/dist/hooks/usePrefersReducedMotion.cjs +24 -0
- package/dist/hooks/usePrefersReducedMotion.d.cts +5 -0
- package/dist/hooks/usePrefersReducedMotion.d.ts +5 -0
- package/dist/hooks/usePrefersReducedMotion.js +22 -0
- package/dist/index.cjs +7 -7
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +4 -4
- package/dist/styles/styler.d.cts +4 -4
- package/dist/styles/styler.d.ts +4 -4
- package/dist/tailwind-internal/dist/utils/getShadowStyles.d.cts +2 -2
- package/dist/tailwind-internal/dist/utils/getShadowStyles.d.ts +2 -2
- package/dist/uds/generated/componentData.cjs +372 -381
- package/dist/uds/generated/componentData.js +372 -381
- package/dist/uds/generated/tailwindPurge.cjs +8 -21
- package/dist/uds/generated/tailwindPurge.js +8 -21
- package/dist/uds/package.cjs +12 -2
- package/dist/uds/package.js +12 -2
- package/generated/componentData.json +572 -603
- package/generated/tailwindPurge.ts +3 -3
- package/package.json +13 -3
- package/dist/components/client/Button.cjs +0 -326
- package/dist/components/client/Button.d.cts +0 -86
- package/dist/components/client/Button.d.ts +0 -87
- package/dist/components/client/Button.js +0 -321
- package/dist/components/client/IconButton.cjs +0 -161
- package/dist/components/client/IconButton.d.cts +0 -46
- package/dist/components/client/IconButton.d.ts +0 -47
- package/dist/components/client/IconButton.js +0 -159
- package/dist/components/client/Switch.cjs +0 -225
- package/dist/components/client/Switch.js +0 -222
- package/dist/components/client/buttonConstants.d.cts +0 -7
- package/dist/components/client/buttonConstants.d.ts +0 -8
- package/dist/components/experimental/client/AvoidMotionLibraryProvider.cjs +0 -14
- package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.cts +0 -8
- package/dist/components/experimental/client/AvoidMotionLibraryProvider.d.ts +0 -9
- package/dist/components/experimental/client/AvoidMotionLibraryProvider.js +0 -11
- package/dist/components/experimental/client/SwitchV2.cjs +0 -190
- package/dist/components/experimental/client/SwitchV2.d.cts +0 -46
- package/dist/components/experimental/client/SwitchV2.d.ts +0 -47
- package/dist/components/experimental/client/SwitchV2.js +0 -185
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
const require_index = require("../../css-tokens/dist/index.cjs");
|
|
3
|
+
const require_index$1 = require("../../motion-tokens/dist/index.cjs");
|
|
3
4
|
const require_assertUnreachable = require("../../utils/dist/assertUnreachable.cjs");
|
|
4
5
|
const require_mapTextVariantFixtureToValue = require("./mapTextVariantFixtureToValue.cjs");
|
|
5
6
|
const require_mapColorFixtureToValue = require("./utils/mapColorFixtureToValue.cjs");
|
|
6
|
-
const require_index$1 = require("../../motion-tokens/dist/index.cjs");
|
|
7
7
|
//#region ../automated-config/dist/properties.js
|
|
8
8
|
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
9
9
|
const isInputWrapperCtx = (context) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
import { BACKGROUND_BLUR_COLOR_PREFIX, BACKGROUND_BLUR_FALLBACK_COLOR_PREFIX, BORDER_RADIUS_PREFIX, BUTTON_SCALE_EFFECT, DROP_SHADOW_PREFIX, getShadowLayerValue, textVariantsSafe } from "../../css-tokens/dist/index.js";
|
|
3
|
+
import { SCALE_EFFECTS } from "../../motion-tokens/dist/index.js";
|
|
3
4
|
import { assertUnreachable } from "../../utils/dist/assertUnreachable.js";
|
|
4
5
|
import { mapTextVariantFixtureToValue } from "./mapTextVariantFixtureToValue.js";
|
|
5
6
|
import { mapColorFixtureToValue } from "./utils/mapColorFixtureToValue.js";
|
|
6
|
-
import { SCALE_EFFECTS } from "../../motion-tokens/dist/index.js";
|
|
7
7
|
//#region ../automated-config/dist/properties.js
|
|
8
8
|
/*! © 2026 Yahoo, Inc. UDS Default Config v0.0.0-development */
|
|
9
9
|
const isInputWrapperCtx = (context) => {
|
package/dist/components/Text.cjs
CHANGED
|
@@ -82,7 +82,7 @@ const asMap = {
|
|
|
82
82
|
*
|
|
83
83
|
* @see The {@link https://uds.build/docs/components/text Text Docs} for more info
|
|
84
84
|
*/
|
|
85
|
-
const Text = (0, react.forwardRef)(function Text({ className, asChild, color = "primary", variant = "body1", as = asMap[variant], italic, tabularNumbers, fontFamily, fontSize, fontWeight, lineHeight, textTransform, textAlign, letterSpacing, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, flexBasis, display, overflow, overflowX, overflowY, position, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, ...props }, ref) {
|
|
85
|
+
const Text = (0, react.forwardRef)(function Text({ className, asChild, color = "primary", variant = "body1", as = asMap[variant], italic, tabularNumbers, fontFamily, fontSize, fontWeight, lineHeight, textTransform, textAlign, letterSpacing, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, flexBasis, display, overflow, overflowX, overflowY, position, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, width, height, ...props }, ref) {
|
|
86
86
|
const classNames = require_styles_styler.getStyles({
|
|
87
87
|
className,
|
|
88
88
|
...color && color !== "inherit" ? { color } : {},
|
|
@@ -143,7 +143,9 @@ const Text = (0, react.forwardRef)(function Text({ className, asChild, color = "
|
|
|
143
143
|
offsetStart,
|
|
144
144
|
offsetTop,
|
|
145
145
|
columnGap,
|
|
146
|
-
rowGap
|
|
146
|
+
rowGap,
|
|
147
|
+
width,
|
|
148
|
+
height
|
|
147
149
|
});
|
|
148
150
|
const Comp = asChild ? Slot : as;
|
|
149
151
|
const additionalStyles = {
|
package/dist/components/Text.js
CHANGED
|
@@ -80,7 +80,7 @@ const asMap = {
|
|
|
80
80
|
*
|
|
81
81
|
* @see The {@link https://uds.build/docs/components/text Text Docs} for more info
|
|
82
82
|
*/
|
|
83
|
-
const Text = forwardRef(function Text({ className, asChild, color = "primary", variant = "body1", as = asMap[variant], italic, tabularNumbers, fontFamily, fontSize, fontWeight, lineHeight, textTransform, textAlign, letterSpacing, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, flexBasis, display, overflow, overflowX, overflowY, position, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, ...props }, ref) {
|
|
83
|
+
const Text = forwardRef(function Text({ className, asChild, color = "primary", variant = "body1", as = asMap[variant], italic, tabularNumbers, fontFamily, fontSize, fontWeight, lineHeight, textTransform, textAlign, letterSpacing, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, flexBasis, display, overflow, overflowX, overflowY, position, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, width, height, ...props }, ref) {
|
|
84
84
|
const classNames = getStyles({
|
|
85
85
|
className,
|
|
86
86
|
...color && color !== "inherit" ? { color } : {},
|
|
@@ -141,7 +141,9 @@ const Text = forwardRef(function Text({ className, asChild, color = "primary", v
|
|
|
141
141
|
offsetStart,
|
|
142
142
|
offsetTop,
|
|
143
143
|
columnGap,
|
|
144
|
-
rowGap
|
|
144
|
+
rowGap,
|
|
145
|
+
width,
|
|
146
|
+
height
|
|
145
147
|
});
|
|
146
148
|
const Comp = asChild ? Slot : as;
|
|
147
149
|
const additionalStyles = {
|
|
@@ -0,0 +1,213 @@
|
|
|
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_index = require("../../../css-tokens/dist/index.cjs");
|
|
6
|
+
const require_utils_createSlot = require("../../../utils/createSlot.cjs");
|
|
7
|
+
const require_components_Icon = require("../../Icon.cjs");
|
|
8
|
+
const require_components_IconSlot = require("../../IconSlot.cjs");
|
|
9
|
+
const require_components_client_SpringMotionConfig = require("../SpringMotionConfig.cjs");
|
|
10
|
+
const require_components_client_Button_ButtonBase = require("./ButtonBase.cjs");
|
|
11
|
+
require("./buttonConstants.cjs");
|
|
12
|
+
let _yahoo_uds_icons = require("@yahoo/uds-icons");
|
|
13
|
+
let react = require("react");
|
|
14
|
+
react = require_runtime.__toESM(react);
|
|
15
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
16
|
+
let motion_react = require("motion/react");
|
|
17
|
+
//#region src/components/client/Button/Button.tsx
|
|
18
|
+
const iconContainerMotionVariants = {
|
|
19
|
+
hide: {
|
|
20
|
+
display: "none",
|
|
21
|
+
width: "0px",
|
|
22
|
+
opacity: 0
|
|
23
|
+
},
|
|
24
|
+
loading: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
width: "auto",
|
|
27
|
+
opacity: 1
|
|
28
|
+
},
|
|
29
|
+
icon: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
width: "auto",
|
|
32
|
+
opacity: 1
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const SCALE_DOWN = .7;
|
|
36
|
+
const hiddenState = {
|
|
37
|
+
scale: SCALE_DOWN,
|
|
38
|
+
opacity: 0
|
|
39
|
+
};
|
|
40
|
+
const visibleState = {
|
|
41
|
+
scale: [
|
|
42
|
+
SCALE_DOWN,
|
|
43
|
+
SCALE_DOWN,
|
|
44
|
+
1
|
|
45
|
+
],
|
|
46
|
+
opacity: [
|
|
47
|
+
0,
|
|
48
|
+
0,
|
|
49
|
+
1
|
|
50
|
+
],
|
|
51
|
+
transition: { times: [
|
|
52
|
+
0,
|
|
53
|
+
.5,
|
|
54
|
+
1
|
|
55
|
+
] }
|
|
56
|
+
};
|
|
57
|
+
const iconMotionVariants = {
|
|
58
|
+
hide: hiddenState,
|
|
59
|
+
icon: visibleState,
|
|
60
|
+
loading: hiddenState
|
|
61
|
+
};
|
|
62
|
+
const loadingMotionVariants = {
|
|
63
|
+
hide: hiddenState,
|
|
64
|
+
icon: hiddenState,
|
|
65
|
+
loading: visibleState
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* **🖲️ A button element that can be used to trigger an action**
|
|
69
|
+
*
|
|
70
|
+
* @componentType Client component
|
|
71
|
+
*/
|
|
72
|
+
const Button = (0, react.forwardRef)(function Button(props, forwardedRef) {
|
|
73
|
+
const prefersReducedMotion = (0, motion_react.useReducedMotion)();
|
|
74
|
+
const disableMotion = !!props.disableEffects || !!props.disabled;
|
|
75
|
+
const layoutVariant = prefersReducedMotion ? "smooth" : "subtle";
|
|
76
|
+
const endVariant = props.endIcon ? "icon" : "hide";
|
|
77
|
+
const gapVariant = props.loading || props.startIcon || props.endIcon ? "withIcon" : "withoutIcon";
|
|
78
|
+
const startVariant = props.loading ? "loading" : props.startIcon ? "icon" : "hide";
|
|
79
|
+
const Slot = (0, react.useMemo)(() => require_utils_createSlot.createSlot(), []);
|
|
80
|
+
const MotionSlot = (0, react.useMemo)(() => motion_react.m.create(Slot), [Slot]);
|
|
81
|
+
const buttonVariants = (0, react.useMemo)(() => ({
|
|
82
|
+
rest: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_REST})` },
|
|
83
|
+
hover: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_HOVER})` },
|
|
84
|
+
pressed: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_PRESSED})` },
|
|
85
|
+
withIcon: { columnGap: `var(${require_index.BUTTON_GAP_VAR})` },
|
|
86
|
+
withoutIcon: { columnGap: "0px" }
|
|
87
|
+
}), [disableMotion]);
|
|
88
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_Button_ButtonBase.ButtonBase, {
|
|
89
|
+
...props,
|
|
90
|
+
ref: forwardedRef,
|
|
91
|
+
renderStartContent: ({ iconVariant, loading, startIcon, iconContainerClassName, loadingIconClassName, iconClassName, startIconClassName, startIconSlotProps }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
92
|
+
className: iconContainerClassName,
|
|
93
|
+
initial: false,
|
|
94
|
+
variants: iconContainerMotionVariants,
|
|
95
|
+
animate: startVariant,
|
|
96
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(motion_react.AnimatePresence, {
|
|
97
|
+
initial: false,
|
|
98
|
+
mode: "popLayout",
|
|
99
|
+
children: [loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
100
|
+
variants: loadingMotionVariants,
|
|
101
|
+
initial: "hide",
|
|
102
|
+
animate: "loading",
|
|
103
|
+
exit: "hide",
|
|
104
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
|
|
105
|
+
className: loadingIconClassName,
|
|
106
|
+
size: "sm",
|
|
107
|
+
name: _yahoo_uds_icons.Progress,
|
|
108
|
+
variant: iconVariant,
|
|
109
|
+
color: "current"
|
|
110
|
+
})
|
|
111
|
+
}, "loading"), startIcon && !loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
112
|
+
variants: iconMotionVariants,
|
|
113
|
+
initial: "hide",
|
|
114
|
+
animate: "icon",
|
|
115
|
+
exit: "hide",
|
|
116
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
117
|
+
className: [iconClassName, startIconClassName].filter(Boolean).join(" "),
|
|
118
|
+
icon: startIcon,
|
|
119
|
+
iconProps: {
|
|
120
|
+
size: "sm",
|
|
121
|
+
variant: iconVariant,
|
|
122
|
+
color: "current"
|
|
123
|
+
},
|
|
124
|
+
...startIconSlotProps
|
|
125
|
+
})
|
|
126
|
+
})]
|
|
127
|
+
})
|
|
128
|
+
}),
|
|
129
|
+
renderEndContent: ({ endIcon, iconVariant, iconContainerClassName, iconClassName, endIconClassName, endIconSlotProps }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
130
|
+
className: iconContainerClassName,
|
|
131
|
+
initial: false,
|
|
132
|
+
variants: iconContainerMotionVariants,
|
|
133
|
+
animate: endVariant,
|
|
134
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.AnimatePresence, {
|
|
135
|
+
initial: false,
|
|
136
|
+
mode: "popLayout",
|
|
137
|
+
children: endIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
138
|
+
variants: iconMotionVariants,
|
|
139
|
+
initial: "hide",
|
|
140
|
+
animate: "icon",
|
|
141
|
+
exit: "hide",
|
|
142
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
143
|
+
className: [iconClassName, endIconClassName].filter(Boolean).join(" "),
|
|
144
|
+
icon: endIcon,
|
|
145
|
+
iconProps: {
|
|
146
|
+
size: "sm",
|
|
147
|
+
variant: iconVariant,
|
|
148
|
+
color: "current"
|
|
149
|
+
},
|
|
150
|
+
...endIconSlotProps
|
|
151
|
+
})
|
|
152
|
+
})
|
|
153
|
+
})
|
|
154
|
+
}),
|
|
155
|
+
renderRoot: ({ asChild, children, buttonRef, type, rootClassName, rest, contentClassName, contentSlotProps, startContent, endContent }) => {
|
|
156
|
+
if (asChild && (0, react.isValidElement)(children)) {
|
|
157
|
+
const childProps = children.props;
|
|
158
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
|
|
159
|
+
layoutSpeed: "3",
|
|
160
|
+
layoutVariant,
|
|
161
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MotionSlot, {
|
|
162
|
+
type,
|
|
163
|
+
className: rootClassName,
|
|
164
|
+
initial: ["rest", gapVariant],
|
|
165
|
+
animate: [
|
|
166
|
+
"hide",
|
|
167
|
+
"rest",
|
|
168
|
+
gapVariant
|
|
169
|
+
],
|
|
170
|
+
variants: buttonVariants,
|
|
171
|
+
whileHover: "hover",
|
|
172
|
+
whileTap: "pressed",
|
|
173
|
+
...rest,
|
|
174
|
+
children: require_components_client_Button_ButtonBase.renderButtonChildren(children, childProps, startContent, contentClassName, contentSlotProps, endContent)
|
|
175
|
+
})
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
|
|
179
|
+
layoutSpeed: "3",
|
|
180
|
+
layoutVariant,
|
|
181
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(motion_react.m.button, {
|
|
182
|
+
ref: buttonRef,
|
|
183
|
+
type,
|
|
184
|
+
className: rootClassName,
|
|
185
|
+
initial: ["rest", gapVariant],
|
|
186
|
+
animate: [
|
|
187
|
+
"hide",
|
|
188
|
+
"rest",
|
|
189
|
+
gapVariant
|
|
190
|
+
],
|
|
191
|
+
variants: buttonVariants,
|
|
192
|
+
whileHover: "hover",
|
|
193
|
+
whileTap: "pressed",
|
|
194
|
+
...rest,
|
|
195
|
+
children: [
|
|
196
|
+
startContent,
|
|
197
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
198
|
+
className: contentClassName,
|
|
199
|
+
...contentSlotProps,
|
|
200
|
+
children
|
|
201
|
+
}),
|
|
202
|
+
endContent
|
|
203
|
+
]
|
|
204
|
+
})
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
Button.displayName = "Button";
|
|
210
|
+
//#endregion
|
|
211
|
+
exports.Button = Button;
|
|
212
|
+
exports.iconMotionVariants = iconMotionVariants;
|
|
213
|
+
exports.loadingMotionVariants = loadingMotionVariants;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import { ButtonProps as ButtonProps$1 } from "./ButtonBase.cjs";
|
|
3
|
+
import React, { ForwardRefExoticComponent } from "react";
|
|
4
|
+
import { HTMLMotionProps } from "motion/react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/Button/Button.d.ts
|
|
7
|
+
declare const iconMotionVariants: {
|
|
8
|
+
hide: {
|
|
9
|
+
scale: number;
|
|
10
|
+
opacity: number;
|
|
11
|
+
};
|
|
12
|
+
icon: {
|
|
13
|
+
scale: number[];
|
|
14
|
+
opacity: number[];
|
|
15
|
+
transition: {
|
|
16
|
+
times: number[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
loading: {
|
|
20
|
+
scale: number;
|
|
21
|
+
opacity: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
declare const loadingMotionVariants: {
|
|
25
|
+
hide: {
|
|
26
|
+
scale: number;
|
|
27
|
+
opacity: number;
|
|
28
|
+
};
|
|
29
|
+
icon: {
|
|
30
|
+
scale: number;
|
|
31
|
+
opacity: number;
|
|
32
|
+
};
|
|
33
|
+
loading: {
|
|
34
|
+
scale: number[];
|
|
35
|
+
opacity: number[];
|
|
36
|
+
transition: {
|
|
37
|
+
times: number[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
type HtmlButtonProps = Omit<HTMLMotionProps<'button'>, 'color' | 'name'> & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color'>;
|
|
42
|
+
type ButtonProps = ButtonProps$1 & HtmlButtonProps;
|
|
43
|
+
/**
|
|
44
|
+
* **🖲️ A button element that can be used to trigger an action**
|
|
45
|
+
*
|
|
46
|
+
* @componentType Client component
|
|
47
|
+
*/
|
|
48
|
+
declare const Button: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { Button, type ButtonProps, iconMotionVariants, loadingMotionVariants };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { ButtonProps as ButtonProps$1 } from "./ButtonBase.js";
|
|
4
|
+
import React, { ForwardRefExoticComponent } from "react";
|
|
5
|
+
import { HTMLMotionProps } from "motion/react";
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/Button/Button.d.ts
|
|
8
|
+
declare const iconMotionVariants: {
|
|
9
|
+
hide: {
|
|
10
|
+
scale: number;
|
|
11
|
+
opacity: number;
|
|
12
|
+
};
|
|
13
|
+
icon: {
|
|
14
|
+
scale: number[];
|
|
15
|
+
opacity: number[];
|
|
16
|
+
transition: {
|
|
17
|
+
times: number[];
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
loading: {
|
|
21
|
+
scale: number;
|
|
22
|
+
opacity: number;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
declare const loadingMotionVariants: {
|
|
26
|
+
hide: {
|
|
27
|
+
scale: number;
|
|
28
|
+
opacity: number;
|
|
29
|
+
};
|
|
30
|
+
icon: {
|
|
31
|
+
scale: number;
|
|
32
|
+
opacity: number;
|
|
33
|
+
};
|
|
34
|
+
loading: {
|
|
35
|
+
scale: number[];
|
|
36
|
+
opacity: number[];
|
|
37
|
+
transition: {
|
|
38
|
+
times: number[];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
type HtmlButtonProps = Omit<HTMLMotionProps<'button'>, 'color' | 'name'> & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color'>;
|
|
43
|
+
type ButtonProps = ButtonProps$1 & HtmlButtonProps;
|
|
44
|
+
/**
|
|
45
|
+
* **🖲️ A button element that can be used to trigger an action**
|
|
46
|
+
*
|
|
47
|
+
* @componentType Client component
|
|
48
|
+
*/
|
|
49
|
+
declare const Button: ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { Button, type ButtonProps, iconMotionVariants, loadingMotionVariants };
|
|
@@ -0,0 +1,208 @@
|
|
|
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 { createSlot } from "../../../utils/createSlot.js";
|
|
5
|
+
import { Icon } from "../../Icon.js";
|
|
6
|
+
import { IconSlot } from "../../IconSlot.js";
|
|
7
|
+
import { SpringMotionConfig } from "../SpringMotionConfig.js";
|
|
8
|
+
import { ButtonBase, renderButtonChildren } from "./ButtonBase.js";
|
|
9
|
+
import "./buttonConstants.js";
|
|
10
|
+
import { Progress } from "@yahoo/uds-icons";
|
|
11
|
+
import { forwardRef, isValidElement, useMemo } from "react";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { AnimatePresence, m, useReducedMotion } from "motion/react";
|
|
14
|
+
//#region src/components/client/Button/Button.tsx
|
|
15
|
+
const iconContainerMotionVariants = {
|
|
16
|
+
hide: {
|
|
17
|
+
display: "none",
|
|
18
|
+
width: "0px",
|
|
19
|
+
opacity: 0
|
|
20
|
+
},
|
|
21
|
+
loading: {
|
|
22
|
+
display: "flex",
|
|
23
|
+
width: "auto",
|
|
24
|
+
opacity: 1
|
|
25
|
+
},
|
|
26
|
+
icon: {
|
|
27
|
+
display: "flex",
|
|
28
|
+
width: "auto",
|
|
29
|
+
opacity: 1
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const SCALE_DOWN = .7;
|
|
33
|
+
const hiddenState = {
|
|
34
|
+
scale: SCALE_DOWN,
|
|
35
|
+
opacity: 0
|
|
36
|
+
};
|
|
37
|
+
const visibleState = {
|
|
38
|
+
scale: [
|
|
39
|
+
SCALE_DOWN,
|
|
40
|
+
SCALE_DOWN,
|
|
41
|
+
1
|
|
42
|
+
],
|
|
43
|
+
opacity: [
|
|
44
|
+
0,
|
|
45
|
+
0,
|
|
46
|
+
1
|
|
47
|
+
],
|
|
48
|
+
transition: { times: [
|
|
49
|
+
0,
|
|
50
|
+
.5,
|
|
51
|
+
1
|
|
52
|
+
] }
|
|
53
|
+
};
|
|
54
|
+
const iconMotionVariants = {
|
|
55
|
+
hide: hiddenState,
|
|
56
|
+
icon: visibleState,
|
|
57
|
+
loading: hiddenState
|
|
58
|
+
};
|
|
59
|
+
const loadingMotionVariants = {
|
|
60
|
+
hide: hiddenState,
|
|
61
|
+
icon: hiddenState,
|
|
62
|
+
loading: visibleState
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* **🖲️ A button element that can be used to trigger an action**
|
|
66
|
+
*
|
|
67
|
+
* @componentType Client component
|
|
68
|
+
*/
|
|
69
|
+
const Button = forwardRef(function Button(props, forwardedRef) {
|
|
70
|
+
const prefersReducedMotion = useReducedMotion();
|
|
71
|
+
const disableMotion = !!props.disableEffects || !!props.disabled;
|
|
72
|
+
const layoutVariant = prefersReducedMotion ? "smooth" : "subtle";
|
|
73
|
+
const endVariant = props.endIcon ? "icon" : "hide";
|
|
74
|
+
const gapVariant = props.loading || props.startIcon || props.endIcon ? "withIcon" : "withoutIcon";
|
|
75
|
+
const startVariant = props.loading ? "loading" : props.startIcon ? "icon" : "hide";
|
|
76
|
+
const Slot = useMemo(() => createSlot(), []);
|
|
77
|
+
const MotionSlot = useMemo(() => m.create(Slot), [Slot]);
|
|
78
|
+
const buttonVariants = useMemo(() => ({
|
|
79
|
+
rest: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_REST})` },
|
|
80
|
+
hover: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_HOVER})` },
|
|
81
|
+
pressed: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_PRESSED})` },
|
|
82
|
+
withIcon: { columnGap: `var(${BUTTON_GAP_VAR})` },
|
|
83
|
+
withoutIcon: { columnGap: "0px" }
|
|
84
|
+
}), [disableMotion]);
|
|
85
|
+
return /* @__PURE__ */ jsx(ButtonBase, {
|
|
86
|
+
...props,
|
|
87
|
+
ref: forwardedRef,
|
|
88
|
+
renderStartContent: ({ iconVariant, loading, startIcon, iconContainerClassName, loadingIconClassName, iconClassName, startIconClassName, startIconSlotProps }) => /* @__PURE__ */ jsx(m.span, {
|
|
89
|
+
className: iconContainerClassName,
|
|
90
|
+
initial: false,
|
|
91
|
+
variants: iconContainerMotionVariants,
|
|
92
|
+
animate: startVariant,
|
|
93
|
+
children: /* @__PURE__ */ jsxs(AnimatePresence, {
|
|
94
|
+
initial: false,
|
|
95
|
+
mode: "popLayout",
|
|
96
|
+
children: [loading && /* @__PURE__ */ jsx(m.span, {
|
|
97
|
+
variants: loadingMotionVariants,
|
|
98
|
+
initial: "hide",
|
|
99
|
+
animate: "loading",
|
|
100
|
+
exit: "hide",
|
|
101
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
102
|
+
className: loadingIconClassName,
|
|
103
|
+
size: "sm",
|
|
104
|
+
name: Progress,
|
|
105
|
+
variant: iconVariant,
|
|
106
|
+
color: "current"
|
|
107
|
+
})
|
|
108
|
+
}, "loading"), startIcon && !loading && /* @__PURE__ */ jsx(m.span, {
|
|
109
|
+
variants: iconMotionVariants,
|
|
110
|
+
initial: "hide",
|
|
111
|
+
animate: "icon",
|
|
112
|
+
exit: "hide",
|
|
113
|
+
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
114
|
+
className: [iconClassName, startIconClassName].filter(Boolean).join(" "),
|
|
115
|
+
icon: startIcon,
|
|
116
|
+
iconProps: {
|
|
117
|
+
size: "sm",
|
|
118
|
+
variant: iconVariant,
|
|
119
|
+
color: "current"
|
|
120
|
+
},
|
|
121
|
+
...startIconSlotProps
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
124
|
+
})
|
|
125
|
+
}),
|
|
126
|
+
renderEndContent: ({ endIcon, iconVariant, iconContainerClassName, iconClassName, endIconClassName, endIconSlotProps }) => /* @__PURE__ */ jsx(m.span, {
|
|
127
|
+
className: iconContainerClassName,
|
|
128
|
+
initial: false,
|
|
129
|
+
variants: iconContainerMotionVariants,
|
|
130
|
+
animate: endVariant,
|
|
131
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, {
|
|
132
|
+
initial: false,
|
|
133
|
+
mode: "popLayout",
|
|
134
|
+
children: endIcon && /* @__PURE__ */ jsx(m.span, {
|
|
135
|
+
variants: iconMotionVariants,
|
|
136
|
+
initial: "hide",
|
|
137
|
+
animate: "icon",
|
|
138
|
+
exit: "hide",
|
|
139
|
+
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
140
|
+
className: [iconClassName, endIconClassName].filter(Boolean).join(" "),
|
|
141
|
+
icon: endIcon,
|
|
142
|
+
iconProps: {
|
|
143
|
+
size: "sm",
|
|
144
|
+
variant: iconVariant,
|
|
145
|
+
color: "current"
|
|
146
|
+
},
|
|
147
|
+
...endIconSlotProps
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
})
|
|
151
|
+
}),
|
|
152
|
+
renderRoot: ({ asChild, children, buttonRef, type, rootClassName, rest, contentClassName, contentSlotProps, startContent, endContent }) => {
|
|
153
|
+
if (asChild && isValidElement(children)) {
|
|
154
|
+
const childProps = children.props;
|
|
155
|
+
return /* @__PURE__ */ jsx(SpringMotionConfig, {
|
|
156
|
+
layoutSpeed: "3",
|
|
157
|
+
layoutVariant,
|
|
158
|
+
children: /* @__PURE__ */ jsx(MotionSlot, {
|
|
159
|
+
type,
|
|
160
|
+
className: rootClassName,
|
|
161
|
+
initial: ["rest", gapVariant],
|
|
162
|
+
animate: [
|
|
163
|
+
"hide",
|
|
164
|
+
"rest",
|
|
165
|
+
gapVariant
|
|
166
|
+
],
|
|
167
|
+
variants: buttonVariants,
|
|
168
|
+
whileHover: "hover",
|
|
169
|
+
whileTap: "pressed",
|
|
170
|
+
...rest,
|
|
171
|
+
children: renderButtonChildren(children, childProps, startContent, contentClassName, contentSlotProps, endContent)
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
return /* @__PURE__ */ jsx(SpringMotionConfig, {
|
|
176
|
+
layoutSpeed: "3",
|
|
177
|
+
layoutVariant,
|
|
178
|
+
children: /* @__PURE__ */ jsxs(m.button, {
|
|
179
|
+
ref: buttonRef,
|
|
180
|
+
type,
|
|
181
|
+
className: rootClassName,
|
|
182
|
+
initial: ["rest", gapVariant],
|
|
183
|
+
animate: [
|
|
184
|
+
"hide",
|
|
185
|
+
"rest",
|
|
186
|
+
gapVariant
|
|
187
|
+
],
|
|
188
|
+
variants: buttonVariants,
|
|
189
|
+
whileHover: "hover",
|
|
190
|
+
whileTap: "pressed",
|
|
191
|
+
...rest,
|
|
192
|
+
children: [
|
|
193
|
+
startContent,
|
|
194
|
+
/* @__PURE__ */ jsx("span", {
|
|
195
|
+
className: contentClassName,
|
|
196
|
+
...contentSlotProps,
|
|
197
|
+
children
|
|
198
|
+
}),
|
|
199
|
+
endContent
|
|
200
|
+
]
|
|
201
|
+
})
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
Button.displayName = "Button";
|
|
207
|
+
//#endregion
|
|
208
|
+
export { Button, iconMotionVariants, loadingMotionVariants };
|