@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.
- package/dist/automated-config/dist/properties.cjs +1 -1
- package/dist/automated-config/dist/properties.js +1 -1
- 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/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 +308 -317
- package/dist/uds/generated/componentData.js +308 -317
- 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 +458 -489
- 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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
|
|
2
|
+
import { UniversalButtonProps } from "../../../types/dist/index.cjs";
|
|
3
|
+
import { IconPropsWithSVGProps } from "../../../tokens/types.cjs";
|
|
4
|
+
import React, { ForwardRefExoticComponent } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/Button/ButtonBase.d.ts
|
|
7
|
+
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'>;
|
|
8
|
+
type DataAttributes = {
|
|
9
|
+
[name: `data-${string}`]: string;
|
|
10
|
+
};
|
|
11
|
+
interface ButtonProps extends HtmlButtonProps, UniversalButtonProps {
|
|
12
|
+
slotProps?: {
|
|
13
|
+
startIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
14
|
+
endIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
15
|
+
content?: Partial<React.HTMLAttributes<HTMLSpanElement> & DataAttributes>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
type ButtonIconRenderArgs = {
|
|
19
|
+
iconVariant: ButtonProps['iconVariant'];
|
|
20
|
+
loading?: boolean;
|
|
21
|
+
startIcon?: ButtonProps['startIcon'];
|
|
22
|
+
endIcon?: ButtonProps['endIcon'];
|
|
23
|
+
iconClassName: string;
|
|
24
|
+
loadingIconClassName: string;
|
|
25
|
+
iconContainerClassName: string;
|
|
26
|
+
startIconClassName?: string;
|
|
27
|
+
endIconClassName?: string;
|
|
28
|
+
startIconSlotProps: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
29
|
+
endIconSlotProps: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
30
|
+
};
|
|
31
|
+
type ButtonRootRenderArgs = {
|
|
32
|
+
asChild: boolean;
|
|
33
|
+
Slot: ForwardRefExoticComponent<HtmlButtonProps>;
|
|
34
|
+
children: React.ReactNode;
|
|
35
|
+
buttonRef: React.ForwardedRef<HTMLButtonElement>;
|
|
36
|
+
type: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
|
|
37
|
+
rootClassName: string;
|
|
38
|
+
rest: Omit<ButtonProps, 'children' | 'slotProps' | 'asChild' | 'type' | 'className'>;
|
|
39
|
+
contentClassName: string;
|
|
40
|
+
contentSlotProps: Partial<React.HTMLAttributes<HTMLSpanElement> & DataAttributes>;
|
|
41
|
+
startContent: React.ReactNode;
|
|
42
|
+
endContent: React.ReactNode;
|
|
43
|
+
};
|
|
44
|
+
interface ButtonBaseProps extends ButtonProps {
|
|
45
|
+
renderStartContent: (args: ButtonIconRenderArgs) => React.ReactNode;
|
|
46
|
+
renderEndContent: (args: ButtonIconRenderArgs) => React.ReactNode;
|
|
47
|
+
renderRoot: (args: ButtonRootRenderArgs) => React.ReactNode;
|
|
48
|
+
}
|
|
49
|
+
declare const ButtonBase: ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
50
|
+
declare function renderButtonChildren(children: React.ReactNode, childProps: Record<string, unknown>, startContent: React.ReactNode, contentClassName: string, contentSlotProps: Partial<React.HTMLAttributes<HTMLSpanElement> & DataAttributes>, endContent: React.ReactNode): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { ButtonBase, type ButtonProps, type ButtonRootRenderArgs, renderButtonChildren };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { UniversalButtonProps } from "../../../types/dist/index.js";
|
|
4
|
+
import { IconPropsWithSVGProps } from "../../../tokens/types.js";
|
|
5
|
+
import React, { ForwardRefExoticComponent } from "react";
|
|
6
|
+
|
|
7
|
+
//#region src/components/client/Button/ButtonBase.d.ts
|
|
8
|
+
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'>;
|
|
9
|
+
type DataAttributes = {
|
|
10
|
+
[name: `data-${string}`]: string;
|
|
11
|
+
};
|
|
12
|
+
interface ButtonProps extends HtmlButtonProps, UniversalButtonProps {
|
|
13
|
+
slotProps?: {
|
|
14
|
+
startIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
15
|
+
endIcon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
16
|
+
content?: Partial<React.HTMLAttributes<HTMLSpanElement> & DataAttributes>;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
type ButtonIconRenderArgs = {
|
|
20
|
+
iconVariant: ButtonProps['iconVariant'];
|
|
21
|
+
loading?: boolean;
|
|
22
|
+
startIcon?: ButtonProps['startIcon'];
|
|
23
|
+
endIcon?: ButtonProps['endIcon'];
|
|
24
|
+
iconClassName: string;
|
|
25
|
+
loadingIconClassName: string;
|
|
26
|
+
iconContainerClassName: string;
|
|
27
|
+
startIconClassName?: string;
|
|
28
|
+
endIconClassName?: string;
|
|
29
|
+
startIconSlotProps: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
30
|
+
endIconSlotProps: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
31
|
+
};
|
|
32
|
+
type ButtonRootRenderArgs = {
|
|
33
|
+
asChild: boolean;
|
|
34
|
+
Slot: ForwardRefExoticComponent<HtmlButtonProps>;
|
|
35
|
+
children: React.ReactNode;
|
|
36
|
+
buttonRef: React.ForwardedRef<HTMLButtonElement>;
|
|
37
|
+
type: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
|
|
38
|
+
rootClassName: string;
|
|
39
|
+
rest: Omit<ButtonProps, 'children' | 'slotProps' | 'asChild' | 'type' | 'className'>;
|
|
40
|
+
contentClassName: string;
|
|
41
|
+
contentSlotProps: Partial<React.HTMLAttributes<HTMLSpanElement> & DataAttributes>;
|
|
42
|
+
startContent: React.ReactNode;
|
|
43
|
+
endContent: React.ReactNode;
|
|
44
|
+
};
|
|
45
|
+
interface ButtonBaseProps extends ButtonProps {
|
|
46
|
+
renderStartContent: (args: ButtonIconRenderArgs) => React.ReactNode;
|
|
47
|
+
renderEndContent: (args: ButtonIconRenderArgs) => React.ReactNode;
|
|
48
|
+
renderRoot: (args: ButtonRootRenderArgs) => React.ReactNode;
|
|
49
|
+
}
|
|
50
|
+
declare const ButtonBase: ForwardRefExoticComponent<ButtonBaseProps & React.RefAttributes<HTMLButtonElement>>;
|
|
51
|
+
declare function renderButtonChildren(children: React.ReactNode, childProps: Record<string, unknown>, startContent: React.ReactNode, contentClassName: string, contentSlotProps: Partial<React.HTMLAttributes<HTMLSpanElement> & DataAttributes>, endContent: React.ReactNode): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
52
|
+
//#endregion
|
|
53
|
+
export { ButtonBase, type ButtonProps, type ButtonRootRenderArgs, renderButtonChildren };
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/components/client/Button/ButtonBase.tsx
|
|
9
|
+
const defaultVariantRootClass = generateDefaultClassName("button", "variant", "root");
|
|
10
|
+
const defaultVariantIconClass = generateDefaultClassName("button", "variant", "icon");
|
|
11
|
+
const defaultSizeRootClass = generateDefaultClassName("button", "size", "root");
|
|
12
|
+
const defaultSizeIconClass = generateDefaultClassName("button", "size", "icon");
|
|
13
|
+
const ButtonBase = forwardRef(function ButtonBase({ size, variant, startIcon, endIcon, iconVariant, loading, disableEffects, children, asChild = false, slotProps, type = "button", className, width, renderStartContent, renderEndContent, renderRoot, ...rest }, forwardedRef) {
|
|
14
|
+
const { className: startIconClassName, ...startIconSlotProps } = slotProps?.startIcon ?? {};
|
|
15
|
+
const { className: endIconClassName, ...endIconSlotProps } = slotProps?.endIcon ?? {};
|
|
16
|
+
const { className: contentClassName, ...contentSlotProps } = slotProps?.content ?? {};
|
|
17
|
+
const gapVariant = loading || startIcon || endIcon ? "withIcon" : "withoutIcon";
|
|
18
|
+
const Slot = useMemo(() => createSlot(), []);
|
|
19
|
+
const rootSizeClass = useMemo(() => size ? getStyles({ buttonSizeRoot: size }) : defaultSizeRootClass, [size]);
|
|
20
|
+
const rootVariantClass = useMemo(() => variant ? getStyles({ buttonVariantRoot: variant }) : defaultVariantRootClass, [variant]);
|
|
21
|
+
const iconSizeClass = useMemo(() => size ? getStyles({ buttonSizeIcon: size }) : defaultSizeIconClass, [size]);
|
|
22
|
+
const iconVariantClass = useMemo(() => variant ? getStyles({ buttonVariantIcon: variant }) : defaultVariantIconClass, [variant]);
|
|
23
|
+
const styles = useMemo(() => ({
|
|
24
|
+
root: getStyles({
|
|
25
|
+
width,
|
|
26
|
+
className: cx([
|
|
27
|
+
"uds-ring",
|
|
28
|
+
"uds-hit-target",
|
|
29
|
+
"inline-flex max-w-full overflow-hidden justify-center items-center whitespace-nowrap select-none",
|
|
30
|
+
"[transform-origin:center]",
|
|
31
|
+
"[backface-visibility:hidden]",
|
|
32
|
+
"[transition-property:color,background-color,border-color,box-shadow,text-decoration-color,fill,stroke]",
|
|
33
|
+
"[transition-timing-function:cubic-bezier(0,0,0.2,1)]",
|
|
34
|
+
"[transition-duration:220ms]",
|
|
35
|
+
rootSizeClass,
|
|
36
|
+
rootVariantClass,
|
|
37
|
+
rest?.disabled && "cursor-not-allowed",
|
|
38
|
+
loading && "uds-button-loading",
|
|
39
|
+
disableEffects && "uds-button-without-effects",
|
|
40
|
+
gapVariant === "withIcon" && "uds-button-with-gap",
|
|
41
|
+
className
|
|
42
|
+
])
|
|
43
|
+
}),
|
|
44
|
+
iconContainer: cx(["flex shrink-0 overflow-clip uds-button-icon-container"]),
|
|
45
|
+
icon: getStyles({ className: cx([iconSizeClass, iconVariantClass]) }),
|
|
46
|
+
loadingIcon: getStyles({ className: cx([
|
|
47
|
+
"animate-spin",
|
|
48
|
+
iconSizeClass,
|
|
49
|
+
iconVariantClass
|
|
50
|
+
]) }),
|
|
51
|
+
content: cx(["min-w-0 truncate"])
|
|
52
|
+
}), [
|
|
53
|
+
className,
|
|
54
|
+
disableEffects,
|
|
55
|
+
gapVariant,
|
|
56
|
+
iconSizeClass,
|
|
57
|
+
iconVariantClass,
|
|
58
|
+
loading,
|
|
59
|
+
rest?.disabled,
|
|
60
|
+
rootSizeClass,
|
|
61
|
+
rootVariantClass,
|
|
62
|
+
width
|
|
63
|
+
]);
|
|
64
|
+
const iconRenderArgs = useMemo(() => ({
|
|
65
|
+
iconVariant,
|
|
66
|
+
loading,
|
|
67
|
+
startIcon,
|
|
68
|
+
endIcon,
|
|
69
|
+
iconClassName: styles.icon,
|
|
70
|
+
loadingIconClassName: styles.loadingIcon,
|
|
71
|
+
iconContainerClassName: styles.iconContainer,
|
|
72
|
+
startIconClassName,
|
|
73
|
+
endIconClassName,
|
|
74
|
+
startIconSlotProps,
|
|
75
|
+
endIconSlotProps
|
|
76
|
+
}), [
|
|
77
|
+
endIcon,
|
|
78
|
+
endIconClassName,
|
|
79
|
+
endIconSlotProps,
|
|
80
|
+
iconVariant,
|
|
81
|
+
loading,
|
|
82
|
+
startIcon,
|
|
83
|
+
startIconClassName,
|
|
84
|
+
startIconSlotProps,
|
|
85
|
+
styles.icon,
|
|
86
|
+
styles.iconContainer,
|
|
87
|
+
styles.loadingIcon
|
|
88
|
+
]);
|
|
89
|
+
return renderRoot({
|
|
90
|
+
asChild,
|
|
91
|
+
Slot,
|
|
92
|
+
children,
|
|
93
|
+
buttonRef: forwardedRef,
|
|
94
|
+
type,
|
|
95
|
+
rootClassName: styles.root,
|
|
96
|
+
rest,
|
|
97
|
+
contentClassName: cx(styles.content, contentClassName),
|
|
98
|
+
contentSlotProps,
|
|
99
|
+
startContent: renderStartContent(iconRenderArgs),
|
|
100
|
+
endContent: renderEndContent(iconRenderArgs)
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
ButtonBase.displayName = "ButtonBase";
|
|
104
|
+
function renderButtonChildren(children, childProps, startContent, contentClassName, contentSlotProps, endContent) {
|
|
105
|
+
return cloneElement(children, childProps, /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
106
|
+
startContent,
|
|
107
|
+
/* @__PURE__ */ jsx("span", {
|
|
108
|
+
className: contentClassName,
|
|
109
|
+
...contentSlotProps,
|
|
110
|
+
children: children.props.children
|
|
111
|
+
}),
|
|
112
|
+
endContent
|
|
113
|
+
] }));
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { ButtonBase, renderButtonChildren };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
"use client";
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
//#region src/components/client/buttonConstants.ts
|
|
4
|
+
//#region src/components/client/Button/buttonConstants.ts
|
|
5
5
|
/** The icon size used for icons in Button and IconButton components */
|
|
6
6
|
const buttonIconSvgSize = "sm";
|
|
7
7
|
//#endregion
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
import { ButtonSize } from "../../../types/dist/index.cjs";
|
|
3
|
+
//#region src/components/client/Button/buttonConstants.d.ts
|
|
4
|
+
/** The icon size used for icons in Button and IconButton components */
|
|
5
|
+
declare const buttonIconSvgSize: ButtonSize;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { buttonIconSvgSize };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { ButtonSize } from "../../../types/dist/index.js";
|
|
4
|
+
//#region src/components/client/Button/buttonConstants.d.ts
|
|
5
|
+
/** The icon size used for icons in Button and IconButton components */
|
|
6
|
+
declare const buttonIconSvgSize: ButtonSize;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { buttonIconSvgSize };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
2
|
"use client";
|
|
3
|
-
//#region src/components/client/buttonConstants.ts
|
|
3
|
+
//#region src/components/client/Button/buttonConstants.ts
|
|
4
4
|
/** The icon size used for icons in Button and IconButton components */
|
|
5
5
|
const buttonIconSvgSize = "sm";
|
|
6
6
|
//#endregion
|
|
@@ -0,0 +1,10 @@
|
|
|
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_Button_ButtonBase = require("./ButtonBase.cjs");
|
|
5
|
+
const require_components_client_Button_Button = require("./Button.cjs");
|
|
6
|
+
exports.Button = require_components_client_Button_Button.Button;
|
|
7
|
+
exports.ButtonBase = require_components_client_Button_ButtonBase.ButtonBase;
|
|
8
|
+
exports.iconMotionVariants = require_components_client_Button_Button.iconMotionVariants;
|
|
9
|
+
exports.loadingMotionVariants = require_components_client_Button_Button.loadingMotionVariants;
|
|
10
|
+
exports.renderButtonChildren = require_components_client_Button_ButtonBase.renderButtonChildren;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
|
|
2
|
+
import { ButtonBase, ButtonRootRenderArgs, renderButtonChildren } from "./ButtonBase.cjs";
|
|
3
|
+
import { Button, ButtonProps, iconMotionVariants, loadingMotionVariants } from "./Button.cjs";
|
|
4
|
+
export { Button, ButtonBase, type ButtonProps, type ButtonRootRenderArgs, iconMotionVariants, loadingMotionVariants, renderButtonChildren };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { ButtonBase, ButtonRootRenderArgs, renderButtonChildren } from "./ButtonBase.js";
|
|
4
|
+
import { Button, ButtonProps, iconMotionVariants, loadingMotionVariants } from "./Button.js";
|
|
5
|
+
export { Button, ButtonBase, type ButtonProps, type ButtonRootRenderArgs, iconMotionVariants, loadingMotionVariants, renderButtonChildren };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
"use client";
|
|
3
|
+
import { ButtonBase, renderButtonChildren } from "./ButtonBase.js";
|
|
4
|
+
import { Button, iconMotionVariants, loadingMotionVariants } from "./Button.js";
|
|
5
|
+
export { Button, ButtonBase, iconMotionVariants, loadingMotionVariants, renderButtonChildren };
|
|
@@ -0,0 +1,104 @@
|
|
|
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_utils_createSlot = require("../../../utils/createSlot.cjs");
|
|
7
|
+
const require_components_Icon = require("../../Icon.cjs");
|
|
8
|
+
const require_components_client_SpringMotionConfig = require("../SpringMotionConfig.cjs");
|
|
9
|
+
require("../Button/buttonConstants.cjs");
|
|
10
|
+
const require_components_client_Button_Button = require("../Button/Button.cjs");
|
|
11
|
+
const require_components_client_IconButton_IconButtonBase = require("./IconButtonBase.cjs");
|
|
12
|
+
let _yahoo_uds_icons = require("@yahoo/uds-icons");
|
|
13
|
+
let react = require("react");
|
|
14
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
|
+
let motion_react = require("motion/react");
|
|
16
|
+
//#region src/components/client/IconButton/IconButton.tsx
|
|
17
|
+
/**
|
|
18
|
+
* **⚙️️ An icon button element that can be used to trigger an action**
|
|
19
|
+
*
|
|
20
|
+
* @componentType Client component
|
|
21
|
+
*/
|
|
22
|
+
const IconButton = (0, react.forwardRef)(function IconButton(props, forwardedRef) {
|
|
23
|
+
const prefersReducedMotion = (0, motion_react.useReducedMotion)();
|
|
24
|
+
const disableMotion = !!props.disableEffects || !!props.disabled;
|
|
25
|
+
const layoutVariant = (0, react.useMemo)(() => prefersReducedMotion ? "smooth" : "subtle", [prefersReducedMotion]);
|
|
26
|
+
const Slot = (0, react.useMemo)(() => require_utils_createSlot.createSlot(), []);
|
|
27
|
+
const MotionSlot = (0, react.useMemo)(() => motion_react.m.create(Slot), [Slot]);
|
|
28
|
+
const buttonVariants = (0, react.useMemo)(() => ({
|
|
29
|
+
rest: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_REST})` },
|
|
30
|
+
hover: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_HOVER})` },
|
|
31
|
+
pressed: { scale: disableMotion ? 1 : `var(${require_index.BUTTON_SCALE_EFFECT_PRESSED})` }
|
|
32
|
+
}), [disableMotion]);
|
|
33
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_IconButton_IconButtonBase.IconButtonBase, {
|
|
34
|
+
...props,
|
|
35
|
+
ref: forwardedRef,
|
|
36
|
+
renderIconContent: ({ asChild, loading, name, iconVariant, children, iconClassName, loadingIconClassName, iconSlotClassName, iconSlotProps }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(motion_react.AnimatePresence, {
|
|
37
|
+
initial: false,
|
|
38
|
+
mode: "popLayout",
|
|
39
|
+
children: [loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
40
|
+
variants: require_components_client_Button_Button.loadingMotionVariants,
|
|
41
|
+
initial: "loading",
|
|
42
|
+
animate: "loading",
|
|
43
|
+
exit: "hide",
|
|
44
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
|
|
45
|
+
size: "sm",
|
|
46
|
+
name: _yahoo_uds_icons.Progress,
|
|
47
|
+
variant: iconVariant,
|
|
48
|
+
color: "current",
|
|
49
|
+
className: loadingIconClassName
|
|
50
|
+
})
|
|
51
|
+
}, "loading"), name && !loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.span, {
|
|
52
|
+
variants: require_components_client_Button_Button.iconMotionVariants,
|
|
53
|
+
initial: "icon",
|
|
54
|
+
animate: "icon",
|
|
55
|
+
exit: "hide",
|
|
56
|
+
children: !asChild && children || /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
|
|
57
|
+
size: "sm",
|
|
58
|
+
name,
|
|
59
|
+
variant: iconVariant,
|
|
60
|
+
color: "current",
|
|
61
|
+
className: [iconClassName, iconSlotClassName].filter(Boolean).join(" "),
|
|
62
|
+
...iconSlotProps
|
|
63
|
+
})
|
|
64
|
+
}, name.name)]
|
|
65
|
+
}),
|
|
66
|
+
renderRoot: ({ asChild, children, buttonRef, type, htmlName, rootClassName, rest, iconContent }) => {
|
|
67
|
+
if (asChild && (0, react.isValidElement)(children)) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
|
|
68
|
+
layoutSpeed: "3",
|
|
69
|
+
layoutVariant,
|
|
70
|
+
reducedMotion: props.disableEffects ? "always" : "user",
|
|
71
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MotionSlot, {
|
|
72
|
+
type,
|
|
73
|
+
className: rootClassName,
|
|
74
|
+
initial: "icon",
|
|
75
|
+
variants: buttonVariants,
|
|
76
|
+
whileHover: "hover",
|
|
77
|
+
whileTap: "pressed",
|
|
78
|
+
...rest,
|
|
79
|
+
children: require_components_client_IconButton_IconButtonBase.renderIconButtonAsChild(children, iconContent)
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_client_SpringMotionConfig.SpringMotionConfig, {
|
|
83
|
+
layoutSpeed: "3",
|
|
84
|
+
layoutVariant,
|
|
85
|
+
reducedMotion: props.disableEffects ? "always" : "user",
|
|
86
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(motion_react.m.button, {
|
|
87
|
+
ref: buttonRef,
|
|
88
|
+
type,
|
|
89
|
+
className: rootClassName,
|
|
90
|
+
name: htmlName,
|
|
91
|
+
initial: "icon",
|
|
92
|
+
variants: buttonVariants,
|
|
93
|
+
whileHover: "hover",
|
|
94
|
+
whileTap: "pressed",
|
|
95
|
+
...rest,
|
|
96
|
+
children: iconContent
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
IconButton.displayName = "IconButton";
|
|
103
|
+
//#endregion
|
|
104
|
+
exports.IconButton = IconButton;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { IconButtonProps as IconButtonProps$1 } from "./IconButtonBase.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/IconButton.d.ts
|
|
8
|
+
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'> & Omit<HTMLMotionProps<'button'>, 'name'>;
|
|
9
|
+
type IconButtonProps = IconButtonProps$1 & HtmlButtonProps;
|
|
10
|
+
/**
|
|
11
|
+
* **⚙️️ An icon button element that can be used to trigger an action**
|
|
12
|
+
*
|
|
13
|
+
* @componentType Client component
|
|
14
|
+
*/
|
|
15
|
+
declare const IconButton: ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { IconButton, type IconButtonProps };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
"use client";
|
|
3
|
+
import { IconButtonProps as IconButtonProps$1 } from "./IconButtonBase.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/IconButton.d.ts
|
|
9
|
+
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'> & Omit<HTMLMotionProps<'button'>, 'name'>;
|
|
10
|
+
type IconButtonProps = IconButtonProps$1 & HtmlButtonProps;
|
|
11
|
+
/**
|
|
12
|
+
* **⚙️️ An icon button element that can be used to trigger an action**
|
|
13
|
+
*
|
|
14
|
+
* @componentType Client component
|
|
15
|
+
*/
|
|
16
|
+
declare const IconButton: ForwardRefExoticComponent<Omit<IconButtonProps, "ref"> & _$react.RefAttributes<HTMLButtonElement>>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { IconButton, type IconButtonProps };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS v0.0.0-development */
|
|
2
|
+
"use client";
|
|
3
|
+
import { 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 { SpringMotionConfig } from "../SpringMotionConfig.js";
|
|
7
|
+
import "../Button/buttonConstants.js";
|
|
8
|
+
import { iconMotionVariants, loadingMotionVariants } from "../Button/Button.js";
|
|
9
|
+
import { IconButtonBase, renderIconButtonAsChild } from "./IconButtonBase.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/IconButton/IconButton.tsx
|
|
15
|
+
/**
|
|
16
|
+
* **⚙️️ An icon button element that can be used to trigger an action**
|
|
17
|
+
*
|
|
18
|
+
* @componentType Client component
|
|
19
|
+
*/
|
|
20
|
+
const IconButton = forwardRef(function IconButton(props, forwardedRef) {
|
|
21
|
+
const prefersReducedMotion = useReducedMotion();
|
|
22
|
+
const disableMotion = !!props.disableEffects || !!props.disabled;
|
|
23
|
+
const layoutVariant = useMemo(() => prefersReducedMotion ? "smooth" : "subtle", [prefersReducedMotion]);
|
|
24
|
+
const Slot = useMemo(() => createSlot(), []);
|
|
25
|
+
const MotionSlot = useMemo(() => m.create(Slot), [Slot]);
|
|
26
|
+
const buttonVariants = useMemo(() => ({
|
|
27
|
+
rest: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_REST})` },
|
|
28
|
+
hover: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_HOVER})` },
|
|
29
|
+
pressed: { scale: disableMotion ? 1 : `var(${BUTTON_SCALE_EFFECT_PRESSED})` }
|
|
30
|
+
}), [disableMotion]);
|
|
31
|
+
return /* @__PURE__ */ jsx(IconButtonBase, {
|
|
32
|
+
...props,
|
|
33
|
+
ref: forwardedRef,
|
|
34
|
+
renderIconContent: ({ asChild, loading, name, iconVariant, children, iconClassName, loadingIconClassName, iconSlotClassName, iconSlotProps }) => /* @__PURE__ */ jsxs(AnimatePresence, {
|
|
35
|
+
initial: false,
|
|
36
|
+
mode: "popLayout",
|
|
37
|
+
children: [loading && /* @__PURE__ */ jsx(m.span, {
|
|
38
|
+
variants: loadingMotionVariants,
|
|
39
|
+
initial: "loading",
|
|
40
|
+
animate: "loading",
|
|
41
|
+
exit: "hide",
|
|
42
|
+
children: /* @__PURE__ */ jsx(Icon, {
|
|
43
|
+
size: "sm",
|
|
44
|
+
name: Progress,
|
|
45
|
+
variant: iconVariant,
|
|
46
|
+
color: "current",
|
|
47
|
+
className: loadingIconClassName
|
|
48
|
+
})
|
|
49
|
+
}, "loading"), name && !loading && /* @__PURE__ */ jsx(m.span, {
|
|
50
|
+
variants: iconMotionVariants,
|
|
51
|
+
initial: "icon",
|
|
52
|
+
animate: "icon",
|
|
53
|
+
exit: "hide",
|
|
54
|
+
children: !asChild && children || /* @__PURE__ */ jsx(Icon, {
|
|
55
|
+
size: "sm",
|
|
56
|
+
name,
|
|
57
|
+
variant: iconVariant,
|
|
58
|
+
color: "current",
|
|
59
|
+
className: [iconClassName, iconSlotClassName].filter(Boolean).join(" "),
|
|
60
|
+
...iconSlotProps
|
|
61
|
+
})
|
|
62
|
+
}, name.name)]
|
|
63
|
+
}),
|
|
64
|
+
renderRoot: ({ asChild, children, buttonRef, type, htmlName, rootClassName, rest, iconContent }) => {
|
|
65
|
+
if (asChild && isValidElement(children)) return /* @__PURE__ */ jsx(SpringMotionConfig, {
|
|
66
|
+
layoutSpeed: "3",
|
|
67
|
+
layoutVariant,
|
|
68
|
+
reducedMotion: props.disableEffects ? "always" : "user",
|
|
69
|
+
children: /* @__PURE__ */ jsx(MotionSlot, {
|
|
70
|
+
type,
|
|
71
|
+
className: rootClassName,
|
|
72
|
+
initial: "icon",
|
|
73
|
+
variants: buttonVariants,
|
|
74
|
+
whileHover: "hover",
|
|
75
|
+
whileTap: "pressed",
|
|
76
|
+
...rest,
|
|
77
|
+
children: renderIconButtonAsChild(children, iconContent)
|
|
78
|
+
})
|
|
79
|
+
});
|
|
80
|
+
return /* @__PURE__ */ jsx(SpringMotionConfig, {
|
|
81
|
+
layoutSpeed: "3",
|
|
82
|
+
layoutVariant,
|
|
83
|
+
reducedMotion: props.disableEffects ? "always" : "user",
|
|
84
|
+
children: /* @__PURE__ */ jsx(m.button, {
|
|
85
|
+
ref: buttonRef,
|
|
86
|
+
type,
|
|
87
|
+
className: rootClassName,
|
|
88
|
+
name: htmlName,
|
|
89
|
+
initial: "icon",
|
|
90
|
+
variants: buttonVariants,
|
|
91
|
+
whileHover: "hover",
|
|
92
|
+
whileTap: "pressed",
|
|
93
|
+
...rest,
|
|
94
|
+
children: iconContent
|
|
95
|
+
})
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
IconButton.displayName = "IconButton";
|
|
101
|
+
//#endregion
|
|
102
|
+
export { IconButton };
|
|
@@ -0,0 +1,68 @@
|
|
|
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_styles_styler = require("../../../styles/styler.cjs");
|
|
6
|
+
const require_utils_createSlot = require("../../../utils/createSlot.cjs");
|
|
7
|
+
const require_generateDefaultClassName = require("../../../automated-config/dist/utils/generateDefaultClassName.cjs");
|
|
8
|
+
let react = require("react");
|
|
9
|
+
//#region src/components/client/IconButton/IconButtonBase.tsx
|
|
10
|
+
const defaultSizeRootClass = require_generateDefaultClassName.generateDefaultClassName("iconbutton", "size", "root");
|
|
11
|
+
const defaultSizeIconClass = require_generateDefaultClassName.generateDefaultClassName("iconbutton", "size", "icon");
|
|
12
|
+
const defaultVariantRootClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "root");
|
|
13
|
+
const defaultVariantIconClass = require_generateDefaultClassName.generateDefaultClassName("button", "variant", "icon");
|
|
14
|
+
const IconButtonBase = (0, react.forwardRef)(function IconButtonBase({ variant, size, iconVariant, loading, disableEffects, name, asChild = false, slotProps, type = "button", htmlName, className, children, renderIconContent, renderRoot, ...rest }, forwardedRef) {
|
|
15
|
+
const { className: iconSlotClassName, ...iconSlotProps } = slotProps?.icon ?? {};
|
|
16
|
+
const Slot = (0, react.useMemo)(() => require_utils_createSlot.createSlot(), []);
|
|
17
|
+
const rootSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ iconbuttonSizeRoot: size }) : defaultSizeRootClass, [size]);
|
|
18
|
+
const rootVariantClass = (0, react.useMemo)(() => variant ? require_styles_styler.getStyles({ buttonVariantRoot: variant }) : defaultVariantRootClass, [variant]);
|
|
19
|
+
const iconSizeClass = (0, react.useMemo)(() => size ? require_styles_styler.getStyles({ iconbuttonSizeIcon: size }) : defaultSizeIconClass, [size]);
|
|
20
|
+
const iconVariantClass = (0, react.useMemo)(() => variant ? require_styles_styler.getStyles({ buttonVariantIcon: variant }) : defaultVariantIconClass, [variant]);
|
|
21
|
+
const styles = (0, react.useMemo)(() => ({
|
|
22
|
+
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),
|
|
23
|
+
icon: require_styles_styler.getStyles({ className: require_styles_styler.cx(iconSizeClass, iconVariantClass) }),
|
|
24
|
+
loadingIcon: require_styles_styler.getStyles({ className: require_styles_styler.cx([
|
|
25
|
+
"animate-spin",
|
|
26
|
+
iconSizeClass,
|
|
27
|
+
iconVariantClass
|
|
28
|
+
]) })
|
|
29
|
+
}), [
|
|
30
|
+
className,
|
|
31
|
+
disableEffects,
|
|
32
|
+
iconSizeClass,
|
|
33
|
+
iconVariantClass,
|
|
34
|
+
loading,
|
|
35
|
+
rest?.disabled,
|
|
36
|
+
rootSizeClass,
|
|
37
|
+
rootVariantClass
|
|
38
|
+
]);
|
|
39
|
+
return renderRoot({
|
|
40
|
+
asChild,
|
|
41
|
+
Slot,
|
|
42
|
+
children,
|
|
43
|
+
buttonRef: forwardedRef,
|
|
44
|
+
type,
|
|
45
|
+
htmlName,
|
|
46
|
+
rootClassName: styles.root,
|
|
47
|
+
rest,
|
|
48
|
+
iconContent: renderIconContent({
|
|
49
|
+
asChild,
|
|
50
|
+
loading,
|
|
51
|
+
name,
|
|
52
|
+
iconVariant,
|
|
53
|
+
children,
|
|
54
|
+
iconClassName: styles.icon,
|
|
55
|
+
loadingIconClassName: styles.loadingIcon,
|
|
56
|
+
iconSlotClassName,
|
|
57
|
+
iconSlotProps
|
|
58
|
+
})
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
IconButtonBase.displayName = "IconButtonBase";
|
|
62
|
+
function renderIconButtonAsChild(children, content) {
|
|
63
|
+
const childProps = children.props;
|
|
64
|
+
return (0, react.cloneElement)(children, childProps, content);
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
exports.IconButtonBase = IconButtonBase;
|
|
68
|
+
exports.renderIconButtonAsChild = renderIconButtonAsChild;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
import { IconPropsWithSVGProps, UniversalIconButtonProps } from "../../../tokens/types.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { ForwardRefExoticComponent } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/client/IconButton/IconButtonBase.d.ts
|
|
7
|
+
type HtmlButtonProps = Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'color' | 'name'>;
|
|
8
|
+
type DataAttributes = {
|
|
9
|
+
[name: `data-${string}`]: string;
|
|
10
|
+
};
|
|
11
|
+
interface IconButtonProps extends HtmlButtonProps, UniversalIconButtonProps {
|
|
12
|
+
slotProps?: {
|
|
13
|
+
icon?: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
type IconButtonRenderArgs = {
|
|
17
|
+
asChild: boolean;
|
|
18
|
+
loading?: boolean;
|
|
19
|
+
name?: IconButtonProps['name'];
|
|
20
|
+
iconVariant: IconButtonProps['iconVariant'];
|
|
21
|
+
children: React.ReactNode;
|
|
22
|
+
iconClassName: string;
|
|
23
|
+
loadingIconClassName: string;
|
|
24
|
+
iconSlotClassName?: string;
|
|
25
|
+
iconSlotProps: Partial<IconPropsWithSVGProps & DataAttributes>;
|
|
26
|
+
};
|
|
27
|
+
type IconButtonRootRenderArgs = {
|
|
28
|
+
asChild: boolean;
|
|
29
|
+
Slot: ForwardRefExoticComponent<HtmlButtonProps>;
|
|
30
|
+
children: React.ReactNode;
|
|
31
|
+
buttonRef: React.ForwardedRef<HTMLButtonElement>;
|
|
32
|
+
type: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];
|
|
33
|
+
htmlName?: string;
|
|
34
|
+
rootClassName: string;
|
|
35
|
+
rest: Record<string, unknown>;
|
|
36
|
+
iconContent: React.ReactNode;
|
|
37
|
+
};
|
|
38
|
+
interface IconButtonBaseProps extends IconButtonProps {
|
|
39
|
+
renderIconContent: (args: IconButtonRenderArgs) => React.ReactNode;
|
|
40
|
+
renderRoot: (args: IconButtonRootRenderArgs) => React.ReactNode;
|
|
41
|
+
}
|
|
42
|
+
declare const IconButtonBase: ForwardRefExoticComponent<IconButtonBaseProps & _$react.RefAttributes<HTMLButtonElement>>;
|
|
43
|
+
declare function renderIconButtonAsChild(children: React.ReactNode, content: React.ReactNode): _$react.ReactElement<unknown, string | _$react.JSXElementConstructor<any>>;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { IconButtonBase, type IconButtonProps, type IconButtonRootRenderArgs, renderIconButtonAsChild };
|