@yahoo/uds-mobile 2.23.2 → 2.24.0-beta.1
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/README.md +4 -12
- package/dist/bin/automated-config/dist/generated/generatedConfigs.mjs +92 -46
- package/dist/components/Button/buttonTheme.cjs +63 -23
- package/dist/components/Button/buttonTheme.d.cts +29 -12
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +29 -12
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +62 -23
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +34 -13
- package/dist/components/Button.d.cts +7 -0
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.ts +7 -0
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +34 -13
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +30 -7
- package/dist/components/Checkbox.d.cts +7 -0
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.ts +7 -0
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +30 -7
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +23 -9
- package/dist/components/Chip/ChipBase.d.cts.map +1 -1
- package/dist/components/Chip/ChipBase.d.ts.map +1 -1
- package/dist/components/Chip/ChipBase.js +23 -9
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Chip/ChipDismissible.cjs +3 -1
- package/dist/components/Chip/ChipDismissible.js +3 -1
- package/dist/components/Chip/ChipDismissible.js.map +1 -1
- package/dist/components/Chip/types.d.cts +7 -0
- package/dist/components/Chip/types.d.cts.map +1 -1
- package/dist/components/Chip/types.d.ts +7 -0
- package/dist/components/Chip/types.d.ts.map +1 -1
- package/dist/components/Icon.cjs +7 -3
- package/dist/components/Icon.d.cts +9 -1
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts +9 -1
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +7 -3
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.cjs +18 -8
- package/dist/components/IconButton.js +18 -8
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +29 -11
- package/dist/components/Radio/Radio.d.cts +7 -0
- package/dist/components/Radio/Radio.d.cts.map +1 -1
- package/dist/components/Radio/Radio.d.ts +7 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Radio/Radio.js +29 -11
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Switch.cjs +25 -2
- package/dist/components/Switch.d.cts +7 -0
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts +7 -0
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +25 -2
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +12 -2
- package/dist/components/Tabs/Tab.d.cts.map +1 -1
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.js +12 -2
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs +8 -3
- package/dist/components/Tabs/Tabs.d.cts +9 -1
- package/dist/components/Tabs/Tabs.d.cts.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +9 -1
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +8 -3
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/tabsContexts.d.cts +2 -0
- package/dist/components/Tabs/tabsContexts.d.cts.map +1 -1
- package/dist/components/Tabs/tabsContexts.d.ts +2 -0
- package/dist/components/Tabs/tabsContexts.d.ts.map +1 -1
- package/dist/components/Tabs/tabsContexts.js.map +1 -1
- package/dist/components/Text.cjs +4 -1
- package/dist/components/Text.d.cts +10 -2
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts +10 -2
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +4 -1
- package/dist/components/Text.js.map +1 -1
- package/dist/components/UDSProvider.cjs +6 -2
- package/dist/components/UDSProvider.d.cts +8 -0
- package/dist/components/UDSProvider.d.cts.map +1 -1
- package/dist/components/UDSProvider.d.ts +8 -0
- package/dist/components/UDSProvider.d.ts.map +1 -1
- package/dist/components/UDSProvider.js +6 -2
- package/dist/components/UDSProvider.js.map +1 -1
- package/dist/fontScaling/FontScalingContext.cjs +35 -0
- package/dist/fontScaling/FontScalingContext.d.cts +38 -0
- package/dist/fontScaling/FontScalingContext.d.cts.map +1 -0
- package/dist/fontScaling/FontScalingContext.d.ts +38 -0
- package/dist/fontScaling/FontScalingContext.d.ts.map +1 -0
- package/dist/fontScaling/FontScalingContext.js +34 -0
- package/dist/fontScaling/FontScalingContext.js.map +1 -0
- package/dist/fontScaling/constants.cjs +72 -0
- package/dist/fontScaling/constants.d.cts +49 -0
- package/dist/fontScaling/constants.d.cts.map +1 -0
- package/dist/fontScaling/constants.d.ts +49 -0
- package/dist/fontScaling/constants.d.ts.map +1 -0
- package/dist/fontScaling/constants.js +70 -0
- package/dist/fontScaling/constants.js.map +1 -0
- package/dist/fontScaling/index.cjs +13 -0
- package/dist/fontScaling/index.d.cts +8 -0
- package/dist/fontScaling/index.d.ts +8 -0
- package/dist/fontScaling/index.js +6 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.cjs +38 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts +36 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts.map +1 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts +36 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts.map +1 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js +39 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js.map +1 -0
- package/dist/fontScaling/types.cjs +1 -0
- package/dist/fontScaling/types.d.cts +51 -0
- package/dist/fontScaling/types.d.cts.map +1 -0
- package/dist/fontScaling/types.d.ts +51 -0
- package/dist/fontScaling/types.d.ts.map +1 -0
- package/dist/fontScaling/types.js +1 -0
- package/dist/fontScaling/useFontScale.cjs +32 -0
- package/dist/fontScaling/useFontScale.d.cts +18 -0
- package/dist/fontScaling/useFontScale.d.cts.map +1 -0
- package/dist/fontScaling/useFontScale.d.ts +18 -0
- package/dist/fontScaling/useFontScale.d.ts.map +1 -0
- package/dist/fontScaling/useFontScale.js +32 -0
- package/dist/fontScaling/useFontScale.js.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.cjs +24 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.cts +16 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.cts.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.ts +16 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.ts.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.js +24 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +19 -4
- package/dist/jest/mocks/react-native.d.cts +8 -5
- package/dist/jest/mocks/react-native.d.cts.map +1 -1
- package/dist/jest/mocks/react-native.d.ts +8 -5
- package/dist/jest/mocks/react-native.d.ts.map +1 -1
- package/dist/jest/mocks/react-native.js +18 -5
- package/dist/jest/mocks/react-native.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +14 -0
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +14 -0
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/jest/setup.cjs +4 -0
- package/dist/jest/setup.d.cts.map +1 -1
- package/dist/jest/setup.d.ts.map +1 -1
- package/dist/jest/setup.js +4 -0
- package/dist/jest/setup.js.map +1 -1
- package/dist/mobile/generated/fontMetrics.cjs +1166 -0
- package/dist/mobile/generated/fontMetrics.js +1168 -0
- package/dist/mobile/generated/fontMetrics.js.map +1 -0
- package/dist/portal.d.cts.map +1 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js.map +1 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/fonts/uds-icons.ttf +0 -0
- package/generated/fontMetrics.ts +1173 -0
- package/generated/styles.d.ts +5 -28
- package/generated/unistyles.d.ts +0 -27
- package/package.json +11 -1
|
@@ -6,19 +6,36 @@ import { TextStyle } from "react-native";
|
|
|
6
6
|
type ButtonTheme = {
|
|
7
7
|
components: Record<string, any>;
|
|
8
8
|
};
|
|
9
|
-
/**
|
|
10
|
-
declare function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
/** Safe line box for the icon font's em square plus any bbox overflow. */
|
|
10
|
+
declare function getSafeIconCell(fontSize: number): number;
|
|
11
|
+
/**
|
|
12
|
+
* Safe native content metrics while retaining the token-derived target control height.
|
|
13
|
+
*
|
|
14
|
+
* `fontScaleFactor` (the capped OS font scale, >= 1) pre-scales container
|
|
15
|
+
* metrics only. The returned `labelLineHeight`/`iconCellHeight` stay unscaled
|
|
16
|
+
* because they go into Text/Icon styles, which native multiplies by the same
|
|
17
|
+
* capped factor — container math must mirror that, not double-apply it.
|
|
18
|
+
*/
|
|
19
|
+
declare function getButtonControlMetrics(theme: ButtonTheme, size: ButtonSize, fontScaleFactor?: number): {
|
|
20
|
+
minHeight: number;
|
|
21
|
+
labelLineHeight: number;
|
|
22
|
+
iconCellHeight: number;
|
|
23
|
+
paddingVertical: number;
|
|
14
24
|
};
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Safe icon cell within the token-derived control size; explicit token height (match-button-height opt-in) wins as the target.
|
|
27
|
+
*
|
|
28
|
+
* `fontScaleFactor` behaves as in {@link getButtonControlMetrics}; an explicit
|
|
29
|
+
* token height stays fixed, with padding absorbing the scaled content.
|
|
30
|
+
*/
|
|
31
|
+
declare function getIconButtonControlMetrics(theme: ButtonTheme, size: IconButtonSize, fontScaleFactor?: number): {
|
|
32
|
+
minHeight: number;
|
|
33
|
+
iconCellHeight: number;
|
|
34
|
+
paddingVertical: number;
|
|
35
|
+
hasExplicitHeight: boolean;
|
|
19
36
|
};
|
|
20
|
-
/**
|
|
21
|
-
declare function
|
|
37
|
+
/** Apply the metric-safe line height after the token typography styles. */
|
|
38
|
+
declare function getButtonTextStyle(textStyle: TextStyle, labelLineHeight: number): TextStyle;
|
|
22
39
|
//#endregion
|
|
23
|
-
export { getButtonControlMetrics,
|
|
40
|
+
export { getButtonControlMetrics, getButtonTextStyle, getIconButtonControlMetrics, getSafeIconCell };
|
|
24
41
|
//# sourceMappingURL=buttonTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttonTheme.d.ts","names":[],"sources":["../../../src/components/Button/buttonTheme.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"buttonTheme.d.ts","names":[],"sources":["../../../src/components/Button/buttonTheme.ts"],"mappings":";;;;;KAKK,WAAA;EAEH,UAAA,EAAY,MAAA;AAAA;;iBA4DE,eAAA,CAAgB,QAAA;;;AAAhC;;;;;AAwBA;iBAAgB,uBAAA,CACd,KAAA,EAAO,WAAA,EACP,IAAA,EAAM,UAAA,EACN,eAAA;EAEA,SAAA;EACA,eAAA;EACA,cAAA;EACA,eAAA;AAAA;;;;;;;iBA8Bc,2BAAA,CACd,KAAA,EAAO,WAAA,EACP,IAAA,EAAM,cAAA,EACN,eAAA;EAEA,SAAA;EACA,cAAA;EACA,eAAA;EACA,iBAAA;AAAA;;iBA4Bc,kBAAA,CAAmB,SAAA,EAAW,SAAA,EAAW,eAAA,WAA0B,SAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { fontMetrics } from "../../mobile/generated/fontMetrics.js";
|
|
2
3
|
//#region src/components/Button/buttonTheme.ts
|
|
3
4
|
const SHARED_BUTTON_ICONBUTTON_SIZES = new Set([
|
|
4
5
|
"xs",
|
|
@@ -6,6 +7,7 @@ const SHARED_BUTTON_ICONBUTTON_SIZES = new Set([
|
|
|
6
7
|
"md",
|
|
7
8
|
"lg"
|
|
8
9
|
]);
|
|
10
|
+
const UNKNOWN_FONT_LINE_HEIGHT_RATIO = 1.3;
|
|
9
11
|
function buttonSizePath(size, layer) {
|
|
10
12
|
return `button/size/${size}/${layer}/rest`;
|
|
11
13
|
}
|
|
@@ -22,47 +24,84 @@ function getIconSize(iconStyle) {
|
|
|
22
24
|
function getVerticalPadding(rootStyle) {
|
|
23
25
|
return (typeof rootStyle.paddingVertical === "number" ? rootStyle.paddingVertical : void 0) ?? (typeof rootStyle.padding === "number" ? rootStyle.padding : void 0) ?? 0;
|
|
24
26
|
}
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
function getMetricHeight(value, unitsPerEm, fontSize) {
|
|
28
|
+
return Math.ceil(Math.max(0, value) / unitsPerEm * fontSize);
|
|
29
|
+
}
|
|
30
|
+
function getSafeLabelLineHeight(textStyle, fallbackFontSize) {
|
|
31
|
+
const fontSize = typeof textStyle.fontSize === "number" ? textStyle.fontSize : fallbackFontSize;
|
|
32
|
+
const tokenLineHeight = typeof textStyle.lineHeight === "number" ? textStyle.lineHeight : fontSize;
|
|
33
|
+
const metrics = typeof textStyle.fontFamily === "string" ? fontMetrics[textStyle.fontFamily] : void 0;
|
|
34
|
+
if (!metrics || metrics.unitsPerEm <= 0) return Math.max(tokenLineHeight, Math.ceil(fontSize * UNKNOWN_FONT_LINE_HEIGHT_RATIO));
|
|
35
|
+
const metricsLineHeight = getMetricHeight(metrics.ascent, metrics.unitsPerEm, fontSize) + getMetricHeight(-metrics.descent, metrics.unitsPerEm, fontSize) + getMetricHeight(metrics.lineGap, metrics.unitsPerEm, fontSize);
|
|
36
|
+
return Math.max(tokenLineHeight, metricsLineHeight);
|
|
29
37
|
}
|
|
30
|
-
/**
|
|
31
|
-
function
|
|
38
|
+
/** Safe line box for the icon font's em square plus any bbox overflow. */
|
|
39
|
+
function getSafeIconCell(fontSize) {
|
|
40
|
+
const metrics = fontMetrics["uds-icons"];
|
|
41
|
+
if (!metrics || metrics.unitsPerEm <= 0) return Math.ceil(fontSize * UNKNOWN_FONT_LINE_HEIGHT_RATIO);
|
|
42
|
+
const overflowAboveEm = Math.max(0, metrics.bbox.maxY - metrics.unitsPerEm);
|
|
43
|
+
const overflowBelowEm = Math.max(0, -metrics.bbox.minY);
|
|
44
|
+
return Math.ceil(fontSize) + getMetricHeight(overflowAboveEm, metrics.unitsPerEm, fontSize) + getMetricHeight(overflowBelowEm, metrics.unitsPerEm, fontSize);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Safe native content metrics while retaining the token-derived target control height.
|
|
48
|
+
*
|
|
49
|
+
* `fontScaleFactor` (the capped OS font scale, >= 1) pre-scales container
|
|
50
|
+
* metrics only. The returned `labelLineHeight`/`iconCellHeight` stay unscaled
|
|
51
|
+
* because they go into Text/Icon styles, which native multiplies by the same
|
|
52
|
+
* capped factor — container math must mirror that, not double-apply it.
|
|
53
|
+
*/
|
|
54
|
+
function getButtonControlMetrics(theme, size, fontScaleFactor = 1) {
|
|
32
55
|
const rootStyle = getLayerStyle(theme, buttonSizePath(size, "root"));
|
|
33
56
|
const iconStyle = getLayerStyle(theme, buttonSizePath(size, "icon"));
|
|
34
57
|
const textStyle = getLayerStyle(theme, buttonSizePath(size, "rootText"));
|
|
35
58
|
const paddingVertical = getVerticalPadding(rootStyle);
|
|
36
59
|
const iconSize = getIconSize(iconStyle);
|
|
37
|
-
const
|
|
60
|
+
const fontSize = typeof textStyle.fontSize === "number" ? textStyle.fontSize : iconSize;
|
|
61
|
+
const tokenLineHeight = typeof textStyle.lineHeight === "number" ? textStyle.lineHeight : fontSize;
|
|
62
|
+
const targetContentHeight = Math.max(iconSize, tokenLineHeight) * fontScaleFactor;
|
|
63
|
+
const minHeight = Math.ceil(paddingVertical * 2 + targetContentHeight);
|
|
64
|
+
const labelLineHeight = getSafeLabelLineHeight(textStyle, iconSize);
|
|
65
|
+
const iconCellHeight = getSafeIconCell(iconSize);
|
|
66
|
+
const safeContentHeight = Math.max(labelLineHeight, iconCellHeight) * fontScaleFactor;
|
|
38
67
|
return {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
minHeight,
|
|
69
|
+
labelLineHeight,
|
|
70
|
+
iconCellHeight,
|
|
71
|
+
paddingVertical: Math.max(0, (minHeight - safeContentHeight) / 2)
|
|
42
72
|
};
|
|
43
73
|
}
|
|
44
|
-
/**
|
|
45
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Safe icon cell within the token-derived control size; explicit token height (match-button-height opt-in) wins as the target.
|
|
76
|
+
*
|
|
77
|
+
* `fontScaleFactor` behaves as in {@link getButtonControlMetrics}; an explicit
|
|
78
|
+
* token height stays fixed, with padding absorbing the scaled content.
|
|
79
|
+
*/
|
|
80
|
+
function getIconButtonControlMetrics(theme, size, fontScaleFactor = 1) {
|
|
46
81
|
const rootStyle = getLayerStyle(theme, iconButtonSizePath(size, "root"));
|
|
47
|
-
const
|
|
82
|
+
const iconStyle = getLayerStyle(theme, iconButtonSizePath(size, "icon"));
|
|
83
|
+
const iconSize = getIconSize(iconStyle);
|
|
84
|
+
const tokenLineHeight = typeof iconStyle.lineHeight === "number" ? iconStyle.lineHeight : iconSize;
|
|
85
|
+
const paddingVertical = getVerticalPadding(rootStyle);
|
|
48
86
|
const explicitHeight = typeof rootStyle.height === "number" ? rootStyle.height : void 0;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
87
|
+
const hasExplicitHeight = SHARED_BUTTON_ICONBUTTON_SIZES.has(size) && explicitHeight !== void 0;
|
|
88
|
+
const minHeight = hasExplicitHeight ? explicitHeight : Math.ceil(paddingVertical * 2 + Math.max(iconSize, tokenLineHeight) * fontScaleFactor);
|
|
89
|
+
const iconCellHeight = getSafeIconCell(iconSize);
|
|
53
90
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
91
|
+
minHeight,
|
|
92
|
+
iconCellHeight,
|
|
93
|
+
paddingVertical: Math.max(0, (minHeight - Math.max(iconSize, iconCellHeight) * fontScaleFactor) / 2),
|
|
94
|
+
hasExplicitHeight
|
|
56
95
|
};
|
|
57
96
|
}
|
|
58
|
-
/**
|
|
59
|
-
function
|
|
97
|
+
/** Apply the metric-safe line height after the token typography styles. */
|
|
98
|
+
function getButtonTextStyle(textStyle, labelLineHeight) {
|
|
60
99
|
return {
|
|
61
100
|
...textStyle,
|
|
62
|
-
lineHeight:
|
|
101
|
+
lineHeight: labelLineHeight
|
|
63
102
|
};
|
|
64
103
|
}
|
|
65
104
|
//#endregion
|
|
66
|
-
export { getButtonControlMetrics,
|
|
105
|
+
export { getButtonControlMetrics, getButtonTextStyle, getIconButtonControlMetrics, getSafeIconCell };
|
|
67
106
|
|
|
68
107
|
//# sourceMappingURL=buttonTheme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buttonTheme.js","names":[],"sources":["../../../src/components/Button/buttonTheme.ts"],"sourcesContent":["import type { ButtonSize, IconButtonSize } from '@yahoo/uds-types';\nimport type { TextStyle, ViewStyle } from 'react-native';\n\ntype ButtonTheme = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components: Record<string, any>;\n};\n\nconst SHARED_BUTTON_ICONBUTTON_SIZES = new Set<IconButtonSize>(['xs', 'sm', 'md', 'lg']);\n\nfunction buttonSizePath(size: ButtonSize, layer: 'root' | 'icon' | 'rootText'): string {\n return `button/size/${size}/${layer}/rest`;\n}\n\nfunction iconButtonSizePath(size: IconButtonSize, layer: 'root' | 'icon'): string {\n return `iconButton/size/${size}/${layer}/rest`;\n}\n\nfunction getLayerStyle(theme: ButtonTheme, path: string): ViewStyle | TextStyle {\n const style = theme.components[path];\n return style && typeof style === 'object' ? style : {};\n}\n\nfunction getIconSize(iconStyle: TextStyle): number {\n return (\n (typeof iconStyle.fontSize === 'number' ? iconStyle.fontSize : undefined) ??\n (typeof iconStyle.lineHeight === 'number' ? iconStyle.lineHeight : undefined) ??\n 16\n );\n}\n\nfunction getVerticalPadding(rootStyle: ViewStyle): number {\n return (\n (typeof rootStyle.paddingVertical === 'number' ? rootStyle.paddingVertical : undefined) ??\n (typeof rootStyle.padding === 'number' ? rootStyle.padding : undefined) ??\n 0\n );\n}\n\nfunction
|
|
1
|
+
{"version":3,"file":"buttonTheme.js","names":[],"sources":["../../../src/components/Button/buttonTheme.ts"],"sourcesContent":["import type { ButtonSize, IconButtonSize } from '@yahoo/uds-types';\nimport type { TextStyle, ViewStyle } from 'react-native';\n\nimport { fontMetrics } from '../../../generated/fontMetrics';\n\ntype ButtonTheme = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n components: Record<string, any>;\n};\n\nconst SHARED_BUTTON_ICONBUTTON_SIZES = new Set<IconButtonSize>(['xs', 'sm', 'md', 'lg']);\n// Covers common native font boxes (roughly 1.2em) plus pixel-rounding headroom.\nconst UNKNOWN_FONT_LINE_HEIGHT_RATIO = 1.3;\n\nfunction buttonSizePath(size: ButtonSize, layer: 'root' | 'icon' | 'rootText'): string {\n return `button/size/${size}/${layer}/rest`;\n}\n\nfunction iconButtonSizePath(size: IconButtonSize, layer: 'root' | 'icon'): string {\n return `iconButton/size/${size}/${layer}/rest`;\n}\n\nfunction getLayerStyle(theme: ButtonTheme, path: string): ViewStyle | TextStyle {\n const style = theme.components[path];\n return style && typeof style === 'object' ? style : {};\n}\n\nfunction getIconSize(iconStyle: TextStyle): number {\n return (\n (typeof iconStyle.fontSize === 'number' ? iconStyle.fontSize : undefined) ??\n (typeof iconStyle.lineHeight === 'number' ? iconStyle.lineHeight : undefined) ??\n 16\n );\n}\n\nfunction getVerticalPadding(rootStyle: ViewStyle): number {\n return (\n (typeof rootStyle.paddingVertical === 'number' ? rootStyle.paddingVertical : undefined) ??\n (typeof rootStyle.padding === 'number' ? rootStyle.padding : undefined) ??\n 0\n );\n}\n\nfunction getMetricHeight(value: number, unitsPerEm: number, fontSize: number): number {\n return Math.ceil((Math.max(0, value) / unitsPerEm) * fontSize);\n}\n\nfunction getSafeLabelLineHeight(textStyle: TextStyle, fallbackFontSize: number): number {\n const fontSize = typeof textStyle.fontSize === 'number' ? textStyle.fontSize : fallbackFontSize;\n const tokenLineHeight =\n typeof textStyle.lineHeight === 'number' ? textStyle.lineHeight : fontSize;\n const metrics =\n typeof textStyle.fontFamily === 'string' ? fontMetrics[textStyle.fontFamily] : undefined;\n\n if (!metrics || metrics.unitsPerEm <= 0) {\n return Math.max(tokenLineHeight, Math.ceil(fontSize * UNKNOWN_FONT_LINE_HEIGHT_RATIO));\n }\n\n const metricsLineHeight =\n getMetricHeight(metrics.ascent, metrics.unitsPerEm, fontSize) +\n getMetricHeight(-metrics.descent, metrics.unitsPerEm, fontSize) +\n getMetricHeight(metrics.lineGap, metrics.unitsPerEm, fontSize);\n\n return Math.max(tokenLineHeight, metricsLineHeight);\n}\n\n/** Safe line box for the icon font's em square plus any bbox overflow. */\nexport function getSafeIconCell(fontSize: number): number {\n const metrics = fontMetrics['uds-icons'];\n if (!metrics || metrics.unitsPerEm <= 0) {\n return Math.ceil(fontSize * UNKNOWN_FONT_LINE_HEIGHT_RATIO);\n }\n\n const overflowAboveEm = Math.max(0, metrics.bbox.maxY - metrics.unitsPerEm);\n const overflowBelowEm = Math.max(0, -metrics.bbox.minY);\n\n return (\n Math.ceil(fontSize) +\n getMetricHeight(overflowAboveEm, metrics.unitsPerEm, fontSize) +\n getMetricHeight(overflowBelowEm, metrics.unitsPerEm, fontSize)\n );\n}\n\n/**\n * Safe native content metrics while retaining the token-derived target control height.\n *\n * `fontScaleFactor` (the capped OS font scale, >= 1) pre-scales container\n * metrics only. The returned `labelLineHeight`/`iconCellHeight` stay unscaled\n * because they go into Text/Icon styles, which native multiplies by the same\n * capped factor — container math must mirror that, not double-apply it.\n */\nexport function getButtonControlMetrics(\n theme: ButtonTheme,\n size: ButtonSize,\n fontScaleFactor = 1,\n): {\n minHeight: number;\n labelLineHeight: number;\n iconCellHeight: number;\n paddingVertical: number;\n} {\n const rootStyle = getLayerStyle(theme, buttonSizePath(size, 'root')) as ViewStyle;\n const iconStyle = getLayerStyle(theme, buttonSizePath(size, 'icon')) as TextStyle;\n const textStyle = getLayerStyle(theme, buttonSizePath(size, 'rootText')) as TextStyle;\n const paddingVertical = getVerticalPadding(rootStyle);\n const iconSize = getIconSize(iconStyle);\n const fontSize = typeof textStyle.fontSize === 'number' ? textStyle.fontSize : iconSize;\n const tokenLineHeight =\n typeof textStyle.lineHeight === 'number' ? textStyle.lineHeight : fontSize;\n const targetContentHeight = Math.max(iconSize, tokenLineHeight) * fontScaleFactor;\n const minHeight = Math.ceil(paddingVertical * 2 + targetContentHeight);\n const labelLineHeight = getSafeLabelLineHeight(textStyle, iconSize);\n const iconCellHeight = getSafeIconCell(iconSize);\n const safeContentHeight = Math.max(labelLineHeight, iconCellHeight) * fontScaleFactor;\n\n return {\n minHeight,\n labelLineHeight,\n iconCellHeight,\n paddingVertical: Math.max(0, (minHeight - safeContentHeight) / 2),\n };\n}\n\n/**\n * Safe icon cell within the token-derived control size; explicit token height (match-button-height opt-in) wins as the target.\n *\n * `fontScaleFactor` behaves as in {@link getButtonControlMetrics}; an explicit\n * token height stays fixed, with padding absorbing the scaled content.\n */\nexport function getIconButtonControlMetrics(\n theme: ButtonTheme,\n size: IconButtonSize,\n fontScaleFactor = 1,\n): {\n minHeight: number;\n iconCellHeight: number;\n paddingVertical: number;\n hasExplicitHeight: boolean;\n} {\n const rootStyle = getLayerStyle(theme, iconButtonSizePath(size, 'root')) as ViewStyle;\n const iconStyle = getLayerStyle(theme, iconButtonSizePath(size, 'icon')) as TextStyle;\n const iconSize = getIconSize(iconStyle);\n const tokenLineHeight =\n typeof iconStyle.lineHeight === 'number' ? iconStyle.lineHeight : iconSize;\n const paddingVertical = getVerticalPadding(rootStyle);\n const explicitHeight = typeof rootStyle.height === 'number' ? rootStyle.height : undefined;\n const hasExplicitHeight =\n SHARED_BUTTON_ICONBUTTON_SIZES.has(size) && explicitHeight !== undefined;\n const minHeight = hasExplicitHeight\n ? (explicitHeight as number)\n : Math.ceil(paddingVertical * 2 + Math.max(iconSize, tokenLineHeight) * fontScaleFactor);\n const iconCellHeight = getSafeIconCell(iconSize);\n\n return {\n minHeight,\n iconCellHeight,\n paddingVertical: Math.max(\n 0,\n (minHeight - Math.max(iconSize, iconCellHeight) * fontScaleFactor) / 2,\n ),\n hasExplicitHeight,\n };\n}\n\n/** Apply the metric-safe line height after the token typography styles. */\nexport function getButtonTextStyle(textStyle: TextStyle, labelLineHeight: number): TextStyle {\n return {\n ...textStyle,\n lineHeight: labelLineHeight,\n };\n}\n"],"mappings":";;;AAUA,MAAM,iCAAiC,IAAI,IAAoB;CAAC;CAAM;CAAM;CAAM;CAAK,CAAC;AAExF,MAAM,iCAAiC;AAEvC,SAAS,eAAe,MAAkB,OAA6C;CACrF,OAAO,eAAe,KAAK,GAAG,MAAM;;AAGtC,SAAS,mBAAmB,MAAsB,OAAgC;CAChF,OAAO,mBAAmB,KAAK,GAAG,MAAM;;AAG1C,SAAS,cAAc,OAAoB,MAAqC;CAC9E,MAAM,QAAQ,MAAM,WAAW;CAC/B,OAAO,SAAS,OAAO,UAAU,WAAW,QAAQ,EAAE;;AAGxD,SAAS,YAAY,WAA8B;CACjD,QACG,OAAO,UAAU,aAAa,WAAW,UAAU,WAAW,KAAA,OAC9D,OAAO,UAAU,eAAe,WAAW,UAAU,aAAa,KAAA,MACnE;;AAIJ,SAAS,mBAAmB,WAA8B;CACxD,QACG,OAAO,UAAU,oBAAoB,WAAW,UAAU,kBAAkB,KAAA,OAC5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WAAsB,iBAAoC;CAC3F,OAAO;EACL,GAAG;EACH,YAAY;EACb"}
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_index = require("../motion-tokens/dist/index.cjs");
|
|
5
5
|
const require_motion = require("../motion.cjs");
|
|
6
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
7
|
+
const require_components_Button_buttonTheme = require("./Button/buttonTheme.cjs");
|
|
6
8
|
const require_components_IconSlot = require("./IconSlot.cjs");
|
|
7
9
|
const require_components_Text = require("./Text.cjs");
|
|
8
|
-
const
|
|
10
|
+
const require_fontScaling_useFontScale = require("../fontScaling/useFontScale.cjs");
|
|
9
11
|
const require_components_Pressable = require("./Pressable.cjs");
|
|
10
12
|
let react = require("react");
|
|
11
13
|
let react_native = require("react-native");
|
|
@@ -34,7 +36,7 @@ function interpolateShadowAlpha(shadow, alpha) {
|
|
|
34
36
|
* Matches web Button icon animation: scale 0.7→1, opacity 0→1, width 0→auto
|
|
35
37
|
* Uses staggered animation: opacity waits until halfway through width animation.
|
|
36
38
|
*/
|
|
37
|
-
function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
39
|
+
function AnimatedIconSlot({ children, visible, iconSize, iconCellHeight, gap }) {
|
|
38
40
|
const progress = (0, react_native_reanimated.useDerivedValue)(() => (0, react_native_reanimated.withSpring)(visible ? 1 : 0, require_motion.BUTTON_SPRING_CONFIG), [visible]);
|
|
39
41
|
const animatedStyle = (0, react_native_reanimated.useAnimatedStyle)(() => {
|
|
40
42
|
const totalWidth = iconSize + gap;
|
|
@@ -42,7 +44,9 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
42
44
|
width: (0, react_native_reanimated.interpolate)(progress.value, [0, 1], [0, totalWidth]),
|
|
43
45
|
opacity: (0, react_native_reanimated.interpolate)(progress.value, [.5, 1], [0, 1], "clamp"),
|
|
44
46
|
transform: [{ scale: (0, react_native_reanimated.interpolate)(progress.value, [.5, 1], [.7, 1], "clamp") }],
|
|
45
|
-
overflow: "hidden"
|
|
47
|
+
overflow: "hidden",
|
|
48
|
+
minHeight: iconCellHeight,
|
|
49
|
+
justifyContent: "center"
|
|
46
50
|
};
|
|
47
51
|
});
|
|
48
52
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_reanimated.default.View, {
|
|
@@ -82,10 +86,16 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
82
86
|
* @see {@link IconButton} for icon-only buttons
|
|
83
87
|
* @see {@link Link} for navigation actions
|
|
84
88
|
*/
|
|
85
|
-
const Button = (0, react.memo)(function Button({ variant = "primary", size = "md", iconVariant = "outline", startIcon, endIcon, loading, disabled, width: _width, children, style, accessibilityLabel, accessibilityHint, disableEffects = false, onPressIn, onPressOut, ref, ...props }) {
|
|
89
|
+
const Button = (0, react.memo)(function Button({ variant = "primary", size = "md", iconVariant = "outline", startIcon, endIcon, loading, disabled, width: _width, children, style, accessibilityLabel, accessibilityHint, disableEffects = false, maxFontSizeMultiplier, onPressIn, onPressOut, ref, ...props }) {
|
|
86
90
|
const shouldAnimate = !disableEffects;
|
|
91
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier) ?? 0;
|
|
92
|
+
const fontScaleFactor = require_fontScaling_useFontScale.useFontScale(resolvedMaxFontSizeMultiplier);
|
|
87
93
|
const { theme } = (0, react_native_unistyles.useUnistyles)();
|
|
88
|
-
const {
|
|
94
|
+
const { minHeight, labelLineHeight, iconCellHeight, paddingVertical } = (0, react.useMemo)(() => require_components_Button_buttonTheme.getButtonControlMetrics(theme, size, fontScaleFactor), [
|
|
95
|
+
theme,
|
|
96
|
+
size,
|
|
97
|
+
fontScaleFactor
|
|
98
|
+
]);
|
|
89
99
|
const [pressed, setPressed] = (0, react.useState)(false);
|
|
90
100
|
generated_styles.buttonStyles.useVariants({
|
|
91
101
|
size,
|
|
@@ -118,7 +128,8 @@ const Button = (0, react.memo)(function Button({ variant = "primary", size = "md
|
|
|
118
128
|
const childrenNode = children && ((0, react.isValidElement)(children) ? children : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
119
129
|
numberOfLines: 1,
|
|
120
130
|
textAlign: "center",
|
|
121
|
-
|
|
131
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
132
|
+
style: require_components_Button_buttonTheme.getButtonTextStyle(generated_styles.buttonStyles.text, labelLineHeight),
|
|
122
133
|
children
|
|
123
134
|
}));
|
|
124
135
|
const a11yState = (0, react.useMemo)(() => ({
|
|
@@ -140,39 +151,49 @@ const Button = (0, react.memo)(function Button({ variant = "primary", size = "md
|
|
|
140
151
|
const showStartIcon = !!startIcon && !loading;
|
|
141
152
|
const showEndIcon = !!endIcon && !loading;
|
|
142
153
|
const iconSizeToken = generated_styles.buttonStyles.icon.iconSizeToken ?? "sm";
|
|
154
|
+
const scaledIconSize = Math.round(iconSize * fontScaleFactor);
|
|
155
|
+
const scaledIconCellHeight = Math.ceil(iconCellHeight * fontScaleFactor);
|
|
143
156
|
const startContent = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnimatedIconSlot, {
|
|
144
157
|
visible: showLoading || showStartIcon,
|
|
145
|
-
iconSize,
|
|
158
|
+
iconSize: scaledIconSize,
|
|
159
|
+
iconCellHeight: scaledIconCellHeight,
|
|
146
160
|
gap: buttonGap,
|
|
147
161
|
children: showLoading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.ActivityIndicator, {
|
|
148
|
-
size:
|
|
162
|
+
size: scaledIconSize,
|
|
149
163
|
color: generated_styles.buttonStyles.icon.color
|
|
150
164
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
151
165
|
icon: startIcon,
|
|
152
166
|
size: iconSizeToken,
|
|
153
167
|
variant: iconVariant,
|
|
154
|
-
|
|
168
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
169
|
+
style: [generated_styles.buttonStyles.icon, { lineHeight: iconCellHeight }]
|
|
155
170
|
})
|
|
156
171
|
});
|
|
157
172
|
const endContent = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnimatedIconSlot, {
|
|
158
173
|
visible: showEndIcon,
|
|
159
|
-
iconSize,
|
|
174
|
+
iconSize: scaledIconSize,
|
|
175
|
+
iconCellHeight: scaledIconCellHeight,
|
|
160
176
|
gap: buttonGap,
|
|
161
177
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
162
178
|
icon: endIcon,
|
|
163
179
|
size: iconSizeToken,
|
|
164
180
|
variant: iconVariant,
|
|
165
|
-
|
|
181
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
182
|
+
style: [generated_styles.buttonStyles.icon, { lineHeight: iconCellHeight }]
|
|
166
183
|
})
|
|
167
184
|
});
|
|
168
185
|
const rootStyles = (0, react.useMemo)(() => [
|
|
169
186
|
generated_styles.buttonStyles.root,
|
|
170
|
-
{
|
|
187
|
+
{
|
|
188
|
+
minHeight,
|
|
189
|
+
paddingVertical
|
|
190
|
+
},
|
|
171
191
|
animatedStyles,
|
|
172
192
|
typeof style === "function" ? style({ pressed }) : style
|
|
173
193
|
], [
|
|
174
194
|
generated_styles.buttonStyles.root,
|
|
175
|
-
|
|
195
|
+
minHeight,
|
|
196
|
+
paddingVertical,
|
|
176
197
|
animatedStyles,
|
|
177
198
|
style,
|
|
178
199
|
pressed
|
|
@@ -29,6 +29,13 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
29
29
|
* @default false
|
|
30
30
|
*/
|
|
31
31
|
disableEffects?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Caps how far the label and icons grow with the OS text-size setting; the
|
|
34
|
+
* button grows to fit the scaled content. Set null to remove the cap;
|
|
35
|
+
* override app-wide via UDSFontScalingProvider.
|
|
36
|
+
* @default 2
|
|
37
|
+
*/
|
|
38
|
+
maxFontSizeMultiplier?: number | null;
|
|
32
39
|
/** Ref to the underlying View */
|
|
33
40
|
ref?: Ref<View>;
|
|
34
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.cts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Button.d.cts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;UAuHU,WAAA,SAAoB,IAAA,CAAK,gBAAA;;EAEjC,OAAA,GAAU,iBAAA;EAFF;EAIR,IAAA,GAAO,UAAA;;EAEP,WAAA,GAAc,WAAA;EAJJ;EAMV,SAAA,GAAY,YAAA;EAFE;EAId,OAAA,GAAU,YAAA;EAAA;EAEV,OAAA;EAkBU;EAhBV,QAAA;EAd4B;EAgB5B,QAAA,GAAW,KAAA,CAAM,SAAA;EAhBe;;;;EAqBhC,cAAA;EAjBA;;;;;;EAwBA,qBAAA;EAlBU;EAoBV,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;;;;;;;;;;;AAAI;;;;;;;;;;;;;;;;;;;;;;cAuCV,MAAA,EAAM,OAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -29,6 +29,13 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
29
29
|
* @default false
|
|
30
30
|
*/
|
|
31
31
|
disableEffects?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Caps how far the label and icons grow with the OS text-size setting; the
|
|
34
|
+
* button grows to fit the scaled content. Set null to remove the cap;
|
|
35
|
+
* override app-wide via UDSFontScalingProvider.
|
|
36
|
+
* @default 2
|
|
37
|
+
*/
|
|
38
|
+
maxFontSizeMultiplier?: number | null;
|
|
32
39
|
/** Ref to the underlying View */
|
|
33
40
|
ref?: Ref<View>;
|
|
34
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Button.d.ts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;UAuHU,WAAA,SAAoB,IAAA,CAAK,gBAAA;;EAEjC,OAAA,GAAU,iBAAA;EAFF;EAIR,IAAA,GAAO,UAAA;;EAEP,WAAA,GAAc,WAAA;EAJJ;EAMV,SAAA,GAAY,YAAA;EAFE;EAId,OAAA,GAAU,YAAA;EAAA;EAEV,OAAA;EAkBU;EAhBV,QAAA;EAd4B;EAgB5B,QAAA,GAAW,KAAA,CAAM,SAAA;EAhBe;;;;EAqBhC,cAAA;EAjBA;;;;;;EAwBA,qBAAA;EAlBU;EAoBV,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;;;;;;;;;;;AAAI;;;;;;;;;;;;;;;;;;;;;;cAuCV,MAAA,EAAM,OAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.js";
|
|
3
3
|
import { BUTTON_SPRING_CONFIG } from "../motion.js";
|
|
4
|
+
import { useMaxFontSizeMultiplier } from "../fontScaling/useMaxFontSizeMultiplier.js";
|
|
5
|
+
import { getButtonControlMetrics, getButtonTextStyle } from "./Button/buttonTheme.js";
|
|
4
6
|
import { IconSlot } from "./IconSlot.js";
|
|
5
7
|
import { Text as Text$1 } from "./Text.js";
|
|
6
|
-
import {
|
|
8
|
+
import { useFontScale } from "../fontScaling/useFontScale.js";
|
|
7
9
|
import { AnimatedPressable } from "./Pressable.js";
|
|
8
10
|
import { isValidElement, memo, useCallback, useMemo, useState } from "react";
|
|
9
11
|
import { ActivityIndicator } from "react-native";
|
|
@@ -31,7 +33,7 @@ function interpolateShadowAlpha(shadow, alpha) {
|
|
|
31
33
|
* Matches web Button icon animation: scale 0.7→1, opacity 0→1, width 0→auto
|
|
32
34
|
* Uses staggered animation: opacity waits until halfway through width animation.
|
|
33
35
|
*/
|
|
34
|
-
function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
36
|
+
function AnimatedIconSlot({ children, visible, iconSize, iconCellHeight, gap }) {
|
|
35
37
|
const progress = useDerivedValue(() => withSpring(visible ? 1 : 0, BUTTON_SPRING_CONFIG), [visible]);
|
|
36
38
|
const animatedStyle = useAnimatedStyle(() => {
|
|
37
39
|
const totalWidth = iconSize + gap;
|
|
@@ -39,7 +41,9 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
39
41
|
width: interpolate(progress.value, [0, 1], [0, totalWidth]),
|
|
40
42
|
opacity: interpolate(progress.value, [.5, 1], [0, 1], "clamp"),
|
|
41
43
|
transform: [{ scale: interpolate(progress.value, [.5, 1], [.7, 1], "clamp") }],
|
|
42
|
-
overflow: "hidden"
|
|
44
|
+
overflow: "hidden",
|
|
45
|
+
minHeight: iconCellHeight,
|
|
46
|
+
justifyContent: "center"
|
|
43
47
|
};
|
|
44
48
|
});
|
|
45
49
|
return /* @__PURE__ */ jsx(Animated.View, {
|
|
@@ -79,10 +83,16 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
79
83
|
* @see {@link IconButton} for icon-only buttons
|
|
80
84
|
* @see {@link Link} for navigation actions
|
|
81
85
|
*/
|
|
82
|
-
const Button = memo(function Button({ variant = "primary", size = "md", iconVariant = "outline", startIcon, endIcon, loading, disabled, width: _width, children, style, accessibilityLabel, accessibilityHint, disableEffects = false, onPressIn, onPressOut, ref, ...props }) {
|
|
86
|
+
const Button = memo(function Button({ variant = "primary", size = "md", iconVariant = "outline", startIcon, endIcon, loading, disabled, width: _width, children, style, accessibilityLabel, accessibilityHint, disableEffects = false, maxFontSizeMultiplier, onPressIn, onPressOut, ref, ...props }) {
|
|
83
87
|
const shouldAnimate = !disableEffects;
|
|
88
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier) ?? 0;
|
|
89
|
+
const fontScaleFactor = useFontScale(resolvedMaxFontSizeMultiplier);
|
|
84
90
|
const { theme } = useUnistyles();
|
|
85
|
-
const {
|
|
91
|
+
const { minHeight, labelLineHeight, iconCellHeight, paddingVertical } = useMemo(() => getButtonControlMetrics(theme, size, fontScaleFactor), [
|
|
92
|
+
theme,
|
|
93
|
+
size,
|
|
94
|
+
fontScaleFactor
|
|
95
|
+
]);
|
|
86
96
|
const [pressed, setPressed] = useState(false);
|
|
87
97
|
buttonStyles.useVariants({
|
|
88
98
|
size,
|
|
@@ -115,7 +125,8 @@ const Button = memo(function Button({ variant = "primary", size = "md", iconVari
|
|
|
115
125
|
const childrenNode = children && (isValidElement(children) ? children : /* @__PURE__ */ jsx(Text$1, {
|
|
116
126
|
numberOfLines: 1,
|
|
117
127
|
textAlign: "center",
|
|
118
|
-
|
|
128
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
129
|
+
style: getButtonTextStyle(buttonStyles.text, labelLineHeight),
|
|
119
130
|
children
|
|
120
131
|
}));
|
|
121
132
|
const a11yState = useMemo(() => ({
|
|
@@ -137,39 +148,49 @@ const Button = memo(function Button({ variant = "primary", size = "md", iconVari
|
|
|
137
148
|
const showStartIcon = !!startIcon && !loading;
|
|
138
149
|
const showEndIcon = !!endIcon && !loading;
|
|
139
150
|
const iconSizeToken = buttonStyles.icon.iconSizeToken ?? "sm";
|
|
151
|
+
const scaledIconSize = Math.round(iconSize * fontScaleFactor);
|
|
152
|
+
const scaledIconCellHeight = Math.ceil(iconCellHeight * fontScaleFactor);
|
|
140
153
|
const startContent = /* @__PURE__ */ jsx(AnimatedIconSlot, {
|
|
141
154
|
visible: showLoading || showStartIcon,
|
|
142
|
-
iconSize,
|
|
155
|
+
iconSize: scaledIconSize,
|
|
156
|
+
iconCellHeight: scaledIconCellHeight,
|
|
143
157
|
gap: buttonGap,
|
|
144
158
|
children: showLoading ? /* @__PURE__ */ jsx(ActivityIndicator, {
|
|
145
|
-
size:
|
|
159
|
+
size: scaledIconSize,
|
|
146
160
|
color: buttonStyles.icon.color
|
|
147
161
|
}) : /* @__PURE__ */ jsx(IconSlot, {
|
|
148
162
|
icon: startIcon,
|
|
149
163
|
size: iconSizeToken,
|
|
150
164
|
variant: iconVariant,
|
|
151
|
-
|
|
165
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
166
|
+
style: [buttonStyles.icon, { lineHeight: iconCellHeight }]
|
|
152
167
|
})
|
|
153
168
|
});
|
|
154
169
|
const endContent = /* @__PURE__ */ jsx(AnimatedIconSlot, {
|
|
155
170
|
visible: showEndIcon,
|
|
156
|
-
iconSize,
|
|
171
|
+
iconSize: scaledIconSize,
|
|
172
|
+
iconCellHeight: scaledIconCellHeight,
|
|
157
173
|
gap: buttonGap,
|
|
158
174
|
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
159
175
|
icon: endIcon,
|
|
160
176
|
size: iconSizeToken,
|
|
161
177
|
variant: iconVariant,
|
|
162
|
-
|
|
178
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
179
|
+
style: [buttonStyles.icon, { lineHeight: iconCellHeight }]
|
|
163
180
|
})
|
|
164
181
|
});
|
|
165
182
|
const rootStyles = useMemo(() => [
|
|
166
183
|
buttonStyles.root,
|
|
167
|
-
{
|
|
184
|
+
{
|
|
185
|
+
minHeight,
|
|
186
|
+
paddingVertical
|
|
187
|
+
},
|
|
168
188
|
animatedStyles,
|
|
169
189
|
typeof style === "function" ? style({ pressed }) : style
|
|
170
190
|
], [
|
|
171
191
|
buttonStyles.root,
|
|
172
|
-
|
|
192
|
+
minHeight,
|
|
193
|
+
paddingVertical,
|
|
173
194
|
animatedStyles,
|
|
174
195
|
style,
|
|
175
196
|
pressed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["Text"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonSize, ButtonVariantFlat, IconSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useMemo, useState } from 'react';\nimport type { View } from 'react-native';\nimport { ActivityIndicator } from 'react-native';\nimport Animated, {\n Easing,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\n// eslint-disable-next-line uds/no-use-unistyles -- button control height from theme size layers\nimport { useUnistyles } from 'react-native-unistyles';\nimport { useAnimatedTheme } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { getButtonControlMetrics, getButtonTextStyleForControlHeight } from './Button/buttonTheme';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport type { PressableProps } from './Pressable';\nimport { AnimatedPressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Animation Helpers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Interpolates a boxShadow string by scaling the alpha of all colors.\n * This allows smooth fade-in/out of shadows.\n */\nfunction interpolateShadowAlpha(shadow: string | undefined, alpha: number): string {\n 'worklet';\n if (!shadow) {\n return '';\n }\n if (alpha >= 1) {\n return shadow;\n }\n if (alpha <= 0) {\n return '';\n }\n\n return shadow.replace(/rgba\\(([^,]+),\\s*([^,]+),\\s*([^,]+),\\s*([^)]+)\\)/g, (_, r, g, b, a) => {\n const newAlpha = parseFloat(a) * alpha;\n return `rgba(${r}, ${g}, ${b}, ${newAlpha.toFixed(3)})`;\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* Animated Icon Slot */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Animated wrapper for icon/loading content.\n * Matches web Button icon animation: scale 0.7→1, opacity 0→1, width 0→auto\n * Uses staggered animation: opacity waits until halfway through width animation.\n */\nfunction AnimatedIconSlot({\n children,\n visible,\n iconSize,\n gap,\n}: {\n children: React.ReactNode;\n visible: boolean;\n iconSize: number;\n gap: number;\n}) {\n // Use useDerivedValue instead of useEffect + useSharedValue\n // This is the idiomatic Reanimated pattern for deriving animated values from React state\n const progress = useDerivedValue(\n () => withSpring(visible ? 1 : 0, BUTTON_SPRING_CONFIG),\n [visible],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n // Total width includes icon + gap when visible\n const totalWidth = iconSize + gap;\n const width = interpolate(progress.value, [0, 1], [0, totalWidth]);\n\n // Staggered animation: opacity starts at 50% of width animation\n // On enter: width expands first, then icon fades in\n // On exit: icon fades out first, then width collapses\n const opacity = interpolate(progress.value, [0.5, 1], [0, 1], 'clamp');\n const scale = interpolate(progress.value, [0.5, 1], [0.7, 1], 'clamp');\n\n return {\n width,\n opacity,\n transform: [{ scale }],\n overflow: 'hidden' as const,\n };\n });\n\n return <Animated.View style={animatedStyle}>{children}</Animated.View>;\n}\n\n// function LoadingIcon({ size, variant }: { size: ButtonSize, variant: ButtonVariantFlat }) {\n// const { theme } = useUnistyles();\n// const themeKey = `buttonVariant${variantToCapitalMap[variant]}IconRest` as const;\n// const iconSize = theme.components.buttonSizeLgIconRest.fontSize;\n// return <ActivityIndicator size={iconSize} color={theme.colors.text.primary} />;\n// }\n\n/* -------------------------------------------------------------------------- */\n/* Button Props */\n/* -------------------------------------------------------------------------- */\n\ninterface ButtonProps extends Omit<PressableProps, 'children' | 'disabled'> {\n /** The visual style variant of the button @default 'primary' */\n variant?: ButtonVariantFlat;\n /** The size of the button @default 'md' */\n size?: ButtonSize;\n /** The icon style variant @default 'outline' */\n iconVariant?: IconVariant;\n /** Icon displayed before the button label */\n startIcon?: IconSlotType;\n /** Icon displayed after the button label */\n endIcon?: IconSlotType;\n /** Shows a loading spinner and disables the button */\n loading?: boolean;\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Button label content */\n children?: React.ReactNode;\n /**\n * Disable motion effects (scale on press, icon animations)\n * @default false\n */\n disableEffects?: boolean;\n /** Ref to the underlying View */\n ref?: Ref<View>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Button Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **🖲️ A button element that can be used to trigger an action**\n *\n * @description\n * A button is a fundamental component used to trigger an action or event.\n * Buttons are interactive elements that users can click, tap, or otherwise\n * engage with to submit forms, open dialogues, or perform any other interaction.\n *\n * Features animated scale effect on press and smooth icon transitions matching\n * the web UDS Button behavior.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Button } from '@yahoo/uds-mobile/Button';\n *\n * <Button onPress={() => console.log('pressed')}>Save</Button>\n * <Button variant=\"secondary\">Cancel</Button>\n * <Button startIcon=\"Add\" variant=\"brand\">Add Item</Button>\n * <Button loading>Saving...</Button>\n * ```\n *\n * @accessibility\n * - Sets `accessibilityRole=\"button\"` automatically\n * - Announces loading state to screen readers\n * - Use `accessibilityLabel` for icon-only buttons\n *\n * @see {@link IconButton} for icon-only buttons\n * @see {@link Link} for navigation actions\n */\nconst Button = memo(function Button({\n variant = 'primary',\n size = 'md',\n iconVariant = 'outline',\n startIcon,\n endIcon,\n loading,\n disabled,\n width: _width,\n children,\n style,\n accessibilityLabel,\n accessibilityHint,\n disableEffects = false,\n onPressIn,\n onPressOut,\n ref,\n ...props\n}: ButtonProps) {\n const shouldAnimate = !disableEffects;\n\n const { theme } = useUnistyles();\n const { controlHeight, contentLineHeight } = useMemo(\n () => getButtonControlMetrics(theme, size),\n [theme, size],\n );\n\n /* --------------------------------- State ---------------------------------- */\n const [pressed, setPressed] = useState(false);\n\n buttonStyles.useVariants({ size, variant, disabled, pressed });\n\n // Get gap and icon size from current variant styles\n const buttonGap = buttonStyles.root.gap;\n const iconSize = buttonStyles.icon.fontSize;\n\n // Get animated theme for boxShadow (useAnimatedVariantColor doesn't support non-color props)\n const animatedTheme = useAnimatedTheme();\n\n /* ------------------------------- Animation -------------------------------- */\n const scale = useSharedValue<number>(SCALE_EFFECTS.none);\n\n const handlePressIn = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressIn']>>[0]) => {\n setPressed(true);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.down, BUTTON_SPRING_CONFIG);\n }\n onPressIn?.(event);\n },\n [shouldAnimate, scale, onPressIn],\n );\n\n const handlePressOut = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressOut']>>[0]) => {\n setPressed(false);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG);\n }\n onPressOut?.(event);\n },\n [shouldAnimate, scale, onPressOut],\n );\n\n /* -------------------------------- Content --------------------------------- */\n const childrenNode =\n children &&\n (isValidElement(children) ? (\n children\n ) : (\n <Text\n numberOfLines={1}\n textAlign=\"center\"\n style={getButtonTextStyleForControlHeight(buttonStyles.text, contentLineHeight)}\n >\n {children}\n </Text>\n ));\n\n const a11yState = useMemo(() => ({ disabled, busy: loading }), [disabled, loading]);\n\n /* --------------------------------- Styles --------------------------------- */\n // Animate pressed state for shadow (0 = rest, 1 = pressed)\n const pressProgress = useDerivedValue(\n () => withTiming(pressed ? 1 : 0, { duration: 220, easing: Easing.bezier(0, 0, 0.2, 1) }),\n [pressed],\n );\n\n // Animate using Unistyles' variant color system + boxShadow from theme\n const animatedStyles = useAnimatedStyle(() => {\n // Get boxShadow from theme using flattened path (no camelCase conversion needed!)\n const components = animatedTheme.value.components;\n const buttonVariantPath = `button/variant/${variant}/root/pressed` as const;\n const shadowPressed = components[buttonVariantPath]?.boxShadow;\n\n return {\n transform: [{ scale: scale.value }],\n // Only animate shadow if the theme defines one for this variant\n ...(shadowPressed && {\n boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\n }),\n };\n });\n\n // Determine what should be visible in start slot\n const showLoading = !!loading;\n const showStartIcon = !!startIcon && !loading;\n const showEndIcon = !!endIcon && !loading;\n\n const iconSizeToken = (buttonStyles.icon.iconSizeToken as IconSize) ?? 'sm';\n\n // Start slot: either loading spinner or start icon\n const startContent = (\n <AnimatedIconSlot visible={showLoading || showStartIcon} iconSize={iconSize} gap={buttonGap}>\n {showLoading ? (\n <ActivityIndicator size={buttonStyles.icon.fontSize} color={buttonStyles.icon.color} />\n ) : (\n <IconSlot\n icon={startIcon}\n size={iconSizeToken}\n variant={iconVariant}\n style={buttonStyles.icon}\n />\n )}\n </AnimatedIconSlot>\n );\n\n // End slot: only end icon (no loading here)\n const endContent = (\n <AnimatedIconSlot visible={showEndIcon} iconSize={iconSize} gap={buttonGap}>\n <IconSlot\n icon={endIcon}\n size={iconSizeToken}\n variant={iconVariant}\n style={buttonStyles.icon}\n />\n </AnimatedIconSlot>\n );\n\n const rootStyles = useMemo(\n () => [\n buttonStyles.root,\n { height: controlHeight },\n animatedStyles,\n typeof style === 'function' ? style({ pressed }) : style,\n ],\n [buttonStyles.root, controlHeight, animatedStyles, style, pressed],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <AnimatedPressable\n ref={ref}\n disabled={disabled}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n overflow=\"hidden\"\n accessibilityLabel={loading ? `${accessibilityLabel ?? ''}, loading` : accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole=\"button\"\n accessibilityState={a11yState}\n alignContent=\"center\"\n style={rootStyles}\n {...props}\n >\n {startContent}\n {childrenNode}\n {endContent}\n </AnimatedPressable>\n );\n});\n\nButton.displayName = 'Button';\n\nexport { Button, type ButtonProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmCA,SAAS,uBAAuB,QAA4B,OAAuB;AACjF;CACA,IAAI,CAAC,QACH,OAAO;CAET,IAAI,SAAS,GACX,OAAO;CAET,IAAI,SAAS,GACX,OAAO;CAGT,OAAO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,mBAAD;GAAmB,MAAM,aAAa,KAAK;GAAU,OAAO,aAAa,KAAK;GAAS,CAAA,GAEvF,oBAAC,UAAD;GACE,MAAM;GACN,MAAM;GACN,SAAS;GACT,OAAO,aAAa;GACpB,CAAA;EAEa,CAAA;CAIrB,MAAM,aACJ,oBAAC,kBAAD;EAAkB,SAAS;EAAuB;EAAU,KAAK;YAC/D,oBAAC,UAAD;GACE,MAAM;GACN,MAAM;GACN,SAAS;GACT,OAAO,aAAa;GACpB,CAAA;EACe,CAAA;CAGrB,MAAM,aAAa,cACX;EACJ,aAAa;EACb,EAAE,QAAQ,eAAe;EACzB;EACA,OAAO,UAAU,aAAa,MAAM,EAAE,SAAS,CAAC,GAAG;EACpD,EACD;EAAC,aAAa;EAAM;EAAe;EAAgB;EAAO;EAAQ,CACnE;CAGD,OACE,qBAAC,mBAAD;EACO;EACK;EACV,WAAW;EACX,YAAY;EACZ,eAAc;EACd,YAAW;EACX,gBAAe;EACf,UAAS;EACT,oBAAoB,UAAU,GAAG,sBAAsB,GAAG,aAAa;EACpD;EACnB,mBAAkB;EAClB,oBAAoB;EACpB,cAAa;EACb,OAAO;EACP,GAAI;YAfN;GAiBG;GACA;GACA;GACiB;;EAEtB;AAEF,OAAO,cAAc"}
|
|
1
|
+
{"version":3,"file":"Button.js","names":["Text"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonSize, ButtonVariantFlat, IconSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useMemo, useState } from 'react';\nimport type { View } from 'react-native';\nimport { ActivityIndicator } from 'react-native';\nimport Animated, {\n Easing,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\n// eslint-disable-next-line uds/no-use-unistyles -- button control height from theme size layers\nimport { useUnistyles } from 'react-native-unistyles';\nimport { useAnimatedTheme } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles } from '../../generated/styles';\nimport { useFontScale } from '../fontScaling/useFontScale';\nimport { useMaxFontSizeMultiplier } from '../fontScaling/useMaxFontSizeMultiplier';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { getButtonControlMetrics, getButtonTextStyle } from './Button/buttonTheme';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport type { PressableProps } from './Pressable';\nimport { AnimatedPressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Animation Helpers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Interpolates a boxShadow string by scaling the alpha of all colors.\n * This allows smooth fade-in/out of shadows.\n */\nfunction interpolateShadowAlpha(shadow: string | undefined, alpha: number): string {\n 'worklet';\n if (!shadow) {\n return '';\n }\n if (alpha >= 1) {\n return shadow;\n }\n if (alpha <= 0) {\n return '';\n }\n\n return shadow.replace(/rgba\\(([^,]+),\\s*([^,]+),\\s*([^,]+),\\s*([^)]+)\\)/g, (_, r, g, b, a) => {\n const newAlpha = parseFloat(a) * alpha;\n return `rgba(${r}, ${g}, ${b}, ${newAlpha.toFixed(3)})`;\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* Animated Icon Slot */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Animated wrapper for icon/loading content.\n * Matches web Button icon animation: scale 0.7→1, opacity 0→1, width 0→auto\n * Uses staggered animation: opacity waits until halfway through width animation.\n */\nfunction AnimatedIconSlot({\n children,\n visible,\n iconSize,\n iconCellHeight,\n gap,\n}: {\n children: React.ReactNode;\n visible: boolean;\n iconSize: number;\n iconCellHeight: number;\n gap: number;\n}) {\n // Use useDerivedValue instead of useEffect + useSharedValue\n // This is the idiomatic Reanimated pattern for deriving animated values from React state\n const progress = useDerivedValue(\n () => withSpring(visible ? 1 : 0, BUTTON_SPRING_CONFIG),\n [visible],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n // Total width includes icon + gap when visible\n const totalWidth = iconSize + gap;\n const width = interpolate(progress.value, [0, 1], [0, totalWidth]);\n\n // Staggered animation: opacity starts at 50% of width animation\n // On enter: width expands first, then icon fades in\n // On exit: icon fades out first, then width collapses\n const opacity = interpolate(progress.value, [0.5, 1], [0, 1], 'clamp');\n const scale = interpolate(progress.value, [0.5, 1], [0.7, 1], 'clamp');\n\n return {\n width,\n opacity,\n transform: [{ scale }],\n overflow: 'hidden' as const,\n minHeight: iconCellHeight,\n justifyContent: 'center' as const,\n };\n });\n\n return <Animated.View style={animatedStyle}>{children}</Animated.View>;\n}\n\n// function LoadingIcon({ size, variant }: { size: ButtonSize, variant: ButtonVariantFlat }) {\n// const { theme } = useUnistyles();\n// const themeKey = `buttonVariant${variantToCapitalMap[variant]}IconRest` as const;\n// const iconSize = theme.components.buttonSizeLgIconRest.fontSize;\n// return <ActivityIndicator size={iconSize} color={theme.colors.text.primary} />;\n// }\n\n/* -------------------------------------------------------------------------- */\n/* Button Props */\n/* -------------------------------------------------------------------------- */\n\ninterface ButtonProps extends Omit<PressableProps, 'children' | 'disabled'> {\n /** The visual style variant of the button @default 'primary' */\n variant?: ButtonVariantFlat;\n /** The size of the button @default 'md' */\n size?: ButtonSize;\n /** The icon style variant @default 'outline' */\n iconVariant?: IconVariant;\n /** Icon displayed before the button label */\n startIcon?: IconSlotType;\n /** Icon displayed after the button label */\n endIcon?: IconSlotType;\n /** Shows a loading spinner and disables the button */\n loading?: boolean;\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Button label content */\n children?: React.ReactNode;\n /**\n * Disable motion effects (scale on press, icon animations)\n * @default false\n */\n disableEffects?: boolean;\n /**\n * Caps how far the label and icons grow with the OS text-size setting; the\n * button grows to fit the scaled content. Set null to remove the cap;\n * override app-wide via UDSFontScalingProvider.\n * @default 2\n */\n maxFontSizeMultiplier?: number | null;\n /** Ref to the underlying View */\n ref?: Ref<View>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Button Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **🖲️ A button element that can be used to trigger an action**\n *\n * @description\n * A button is a fundamental component used to trigger an action or event.\n * Buttons are interactive elements that users can click, tap, or otherwise\n * engage with to submit forms, open dialogues, or perform any other interaction.\n *\n * Features animated scale effect on press and smooth icon transitions matching\n * the web UDS Button behavior.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Button } from '@yahoo/uds-mobile/Button';\n *\n * <Button onPress={() => console.log('pressed')}>Save</Button>\n * <Button variant=\"secondary\">Cancel</Button>\n * <Button startIcon=\"Add\" variant=\"brand\">Add Item</Button>\n * <Button loading>Saving...</Button>\n * ```\n *\n * @accessibility\n * - Sets `accessibilityRole=\"button\"` automatically\n * - Announces loading state to screen readers\n * - Use `accessibilityLabel` for icon-only buttons\n *\n * @see {@link IconButton} for icon-only buttons\n * @see {@link Link} for navigation actions\n */\nconst Button = memo(function Button({\n variant = 'primary',\n size = 'md',\n iconVariant = 'outline',\n startIcon,\n endIcon,\n loading,\n disabled,\n width: _width,\n children,\n style,\n accessibilityLabel,\n accessibilityHint,\n disableEffects = false,\n maxFontSizeMultiplier,\n onPressIn,\n onPressOut,\n ref,\n ...props\n}: ButtonProps) {\n const shouldAnimate = !disableEffects;\n\n // Inside a control, \"no cap resolved\" must force-uncap (0) rather than let\n // the label's own variant default or an inherited cap apply.\n const resolvedMaxFontSizeMultiplier =\n useMaxFontSizeMultiplier('control', maxFontSizeMultiplier) ?? 0;\n const fontScaleFactor = useFontScale(resolvedMaxFontSizeMultiplier);\n\n const { theme } = useUnistyles();\n const { minHeight, labelLineHeight, iconCellHeight, paddingVertical } = useMemo(\n () => getButtonControlMetrics(theme, size, fontScaleFactor),\n [theme, size, fontScaleFactor],\n );\n\n /* --------------------------------- State ---------------------------------- */\n const [pressed, setPressed] = useState(false);\n\n buttonStyles.useVariants({ size, variant, disabled, pressed });\n\n // Get gap and icon size from current variant styles\n const buttonGap = buttonStyles.root.gap;\n const iconSize = buttonStyles.icon.fontSize;\n\n // Get animated theme for boxShadow (useAnimatedVariantColor doesn't support non-color props)\n const animatedTheme = useAnimatedTheme();\n\n /* ------------------------------- Animation -------------------------------- */\n const scale = useSharedValue<number>(SCALE_EFFECTS.none);\n\n const handlePressIn = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressIn']>>[0]) => {\n setPressed(true);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.down, BUTTON_SPRING_CONFIG);\n }\n onPressIn?.(event);\n },\n [shouldAnimate, scale, onPressIn],\n );\n\n const handlePressOut = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressOut']>>[0]) => {\n setPressed(false);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG);\n }\n onPressOut?.(event);\n },\n [shouldAnimate, scale, onPressOut],\n );\n\n /* -------------------------------- Content --------------------------------- */\n const childrenNode =\n children &&\n (isValidElement(children) ? (\n children\n ) : (\n <Text\n numberOfLines={1}\n textAlign=\"center\"\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={getButtonTextStyle(buttonStyles.text, labelLineHeight)}\n >\n {children}\n </Text>\n ));\n\n const a11yState = useMemo(() => ({ disabled, busy: loading }), [disabled, loading]);\n\n /* --------------------------------- Styles --------------------------------- */\n // Animate pressed state for shadow (0 = rest, 1 = pressed)\n const pressProgress = useDerivedValue(\n () => withTiming(pressed ? 1 : 0, { duration: 220, easing: Easing.bezier(0, 0, 0.2, 1) }),\n [pressed],\n );\n\n // Animate using Unistyles' variant color system + boxShadow from theme\n const animatedStyles = useAnimatedStyle(() => {\n // Get boxShadow from theme using flattened path (no camelCase conversion needed!)\n const components = animatedTheme.value.components;\n const buttonVariantPath = `button/variant/${variant}/root/pressed` as const;\n const shadowPressed = components[buttonVariantPath]?.boxShadow;\n\n return {\n transform: [{ scale: scale.value }],\n // Only animate shadow if the theme defines one for this variant\n ...(shadowPressed && {\n boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\n }),\n };\n });\n\n // Determine what should be visible in start slot\n const showLoading = !!loading;\n const showStartIcon = !!startIcon && !loading;\n const showEndIcon = !!endIcon && !loading;\n\n const iconSizeToken = (buttonStyles.icon.iconSizeToken as IconSize) ?? 'sm';\n\n // Containers pre-scale by the capped factor; icon styles stay unscaled and\n // native grows them by the same capped multiplier.\n const scaledIconSize = Math.round(iconSize * fontScaleFactor);\n const scaledIconCellHeight = Math.ceil(iconCellHeight * fontScaleFactor);\n\n // Start slot: either loading spinner or start icon\n const startContent = (\n <AnimatedIconSlot\n visible={showLoading || showStartIcon}\n iconSize={scaledIconSize}\n iconCellHeight={scaledIconCellHeight}\n gap={buttonGap}\n >\n {showLoading ? (\n <ActivityIndicator size={scaledIconSize} color={buttonStyles.icon.color} />\n ) : (\n <IconSlot\n icon={startIcon}\n size={iconSizeToken}\n variant={iconVariant}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={[buttonStyles.icon, { lineHeight: iconCellHeight }]}\n />\n )}\n </AnimatedIconSlot>\n );\n\n // End slot: only end icon (no loading here)\n const endContent = (\n <AnimatedIconSlot\n visible={showEndIcon}\n iconSize={scaledIconSize}\n iconCellHeight={scaledIconCellHeight}\n gap={buttonGap}\n >\n <IconSlot\n icon={endIcon}\n size={iconSizeToken}\n variant={iconVariant}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={[buttonStyles.icon, { lineHeight: iconCellHeight }]}\n />\n </AnimatedIconSlot>\n );\n\n const rootStyles = useMemo(\n () => [\n buttonStyles.root,\n { minHeight, paddingVertical },\n animatedStyles,\n typeof style === 'function' ? style({ pressed }) : style,\n ],\n [buttonStyles.root, minHeight, paddingVertical, animatedStyles, style, pressed],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <AnimatedPressable\n ref={ref}\n disabled={disabled}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n overflow=\"hidden\"\n accessibilityLabel={loading ? `${accessibilityLabel ?? ''}, loading` : accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole=\"button\"\n accessibilityState={a11yState}\n alignContent=\"center\"\n style={rootStyles}\n {...props}\n >\n {startContent}\n {childrenNode}\n {endContent}\n </AnimatedPressable>\n );\n});\n\nButton.displayName = 'Button';\n\nexport { Button, type ButtonProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqCA,SAAS,uBAAuB,QAA4B,OAAuB;AACjF;CACA,IAAI,CAAC,QACH,OAAO;CAET,IAAI,SAAS,GACX,OAAO;CAET,IAAI,SAAS,GACX,OAAO;CAGT,OAAO,OAAO,QAAQ,sDAAsD,GAAG,GAAG,GAAG,GAAG,MAAM;EAE5F,OAAO,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KADZ,WAAW,EAAE,GAAG,OACS,QAAQ,EAAE,CAAC;GACrD;;;;;;;AAYJ,SAAS,iBAAiB,EACxB,UACA,SACA,UACA,gBACA,OAOC;CAGD,MAAM,WAAW,sBACT,WAAW,UAAU,IAAI,GAAG,qBAAqB,EACvD,CAAC,QAAQ,CACV;CAED,MAAM,gBAAgB,uBAAuB;EAE3C,MAAM,aAAa,WAAW;EAS9B,OAAO;GACL,OATY,YAAY,SAAS,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,WAAW,CAS1D;GACL,SALc,YAAY,SAAS,OAAO,CAAC,IAAK,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,QAKrD;GACP,WAAW,CAAC,EAAE,OALF,YAAY,SAAS,OAAO,CAAC,IAAK,EAAE,EAAE,CAAC,IAAK,EAAE,EAAE,QAKzC,EAAE,CAAC;GACtB,UAAU;GACV,WAAW;GACX,gBAAgB;GACjB;GACD;CAEF,OAAO,oBAAC,SAAS,MAAV;EAAe,OAAO;EAAgB;EAAyB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFxE,MAAM,SAAS,KAAK,SAAS,OAAO,EAClC,UAAU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