@yahoo/uds-mobile 2.1.0 → 2.3.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/README.md +92 -0
- package/dist/_virtual/_rolldown/runtime.cjs +14 -0
- package/dist/_virtual/_rolldown/runtime.js +19 -0
- package/dist/bin/generateTheme.mjs +14 -0
- package/dist/components/{Avatar.d.mts → Avatar.d.ts} +2 -2
- package/dist/components/Avatar.d.ts.map +1 -0
- package/dist/components/{Avatar.mjs → Avatar.js} +4 -4
- package/dist/components/Avatar.js.map +1 -0
- package/dist/components/{Badge.d.mts → Badge.d.ts} +3 -3
- package/dist/components/Badge.d.ts.map +1 -0
- package/dist/components/{Badge.mjs → Badge.js} +4 -4
- package/dist/components/Badge.js.map +1 -0
- package/dist/components/BlurTarget.cjs +89 -0
- package/dist/components/BlurTarget.d.cts +52 -0
- package/dist/components/BlurTarget.d.cts.map +1 -0
- package/dist/components/BlurTarget.d.ts +52 -0
- package/dist/components/BlurTarget.d.ts.map +1 -0
- package/dist/components/BlurTarget.js +88 -0
- package/dist/components/BlurTarget.js.map +1 -0
- package/dist/components/Box.cjs +117 -20
- package/dist/components/Box.d.cts +11 -1
- package/dist/components/Box.d.cts.map +1 -1
- package/dist/components/{Box.d.mts → Box.d.ts} +14 -4
- package/dist/components/{Box.d.mts.map → Box.d.ts.map} +1 -1
- package/dist/components/Box.js +228 -0
- package/dist/components/Box.js.map +1 -0
- package/dist/components/{Button.d.mts → Button.d.ts} +4 -4
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/{Button.mjs → Button.js} +6 -6
- package/dist/components/Button.js.map +1 -0
- package/dist/components/{Checkbox.d.mts → Checkbox.d.ts} +2 -2
- package/dist/components/Checkbox.d.ts.map +1 -0
- package/dist/components/{Checkbox.mjs → Checkbox.js} +7 -7
- package/dist/components/Checkbox.js.map +1 -0
- package/dist/components/{Chip.d.mts → Chip.d.ts} +3 -3
- package/dist/components/Chip.d.ts.map +1 -0
- package/dist/components/{Chip.mjs → Chip.js} +5 -5
- package/dist/components/Chip.js.map +1 -0
- package/dist/components/{HStack.d.mts → HStack.d.ts} +2 -2
- package/dist/components/HStack.d.ts.map +1 -0
- package/dist/components/{HStack.mjs → HStack.js} +2 -2
- package/dist/components/HStack.js.map +1 -0
- package/dist/components/{Icon.d.mts → Icon.d.ts} +2 -2
- package/dist/components/Icon.d.ts.map +1 -0
- package/dist/components/{Icon.mjs → Icon.js} +1 -1
- package/dist/components/Icon.js.map +1 -0
- package/dist/components/{IconButton.d.mts → IconButton.d.ts} +4 -4
- package/dist/components/IconButton.d.ts.map +1 -0
- package/dist/components/{IconButton.mjs → IconButton.js} +5 -5
- package/dist/components/IconButton.js.map +1 -0
- package/dist/components/{IconSlot.d.mts → IconSlot.d.ts} +2 -2
- package/dist/components/IconSlot.d.ts.map +1 -0
- package/dist/components/{IconSlot.mjs → IconSlot.js} +2 -2
- package/dist/components/IconSlot.js.map +1 -0
- package/dist/components/{Image.d.mts → Image.d.ts} +2 -2
- package/dist/components/Image.d.ts.map +1 -0
- package/dist/components/{Image.mjs → Image.js} +1 -1
- package/dist/components/Image.js.map +1 -0
- package/dist/components/{Input.d.mts → Input.d.ts} +4 -4
- package/dist/components/Input.d.ts.map +1 -0
- package/dist/components/{Input.mjs → Input.js} +5 -5
- package/dist/components/Input.js.map +1 -0
- package/dist/components/{Link.d.mts → Link.d.ts} +4 -4
- package/dist/components/Link.d.ts.map +1 -0
- package/dist/components/{Link.mjs → Link.js} +2 -2
- package/dist/components/Link.js.map +1 -0
- package/dist/components/{Pressable.d.mts → Pressable.d.ts} +2 -2
- package/dist/components/Pressable.d.ts.map +1 -0
- package/dist/components/{Pressable.mjs → Pressable.js} +1 -1
- package/dist/components/Pressable.js.map +1 -0
- package/dist/components/{Radio.d.mts → Radio.d.ts} +2 -2
- package/dist/components/Radio.d.ts.map +1 -0
- package/dist/components/{Radio.mjs → Radio.js} +6 -6
- package/dist/components/Radio.js.map +1 -0
- package/dist/components/{Screen.d.mts → Screen.d.ts} +2 -2
- package/dist/components/Screen.d.ts.map +1 -0
- package/dist/components/{Screen.mjs → Screen.js} +5 -5
- package/dist/components/Screen.js.map +1 -0
- package/dist/components/{Switch.d.mts → Switch.d.ts} +3 -3
- package/dist/components/Switch.d.ts.map +1 -0
- package/dist/components/{Switch.mjs → Switch.js} +6 -6
- package/dist/components/Switch.js.map +1 -0
- package/dist/components/{Text.d.mts → Text.d.ts} +1 -1
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/{Text.mjs → Text.js} +1 -1
- package/dist/components/Text.js.map +1 -0
- package/dist/components/{VStack.d.mts → VStack.d.ts} +2 -2
- package/dist/components/VStack.d.ts.map +1 -0
- package/dist/components/{VStack.mjs → VStack.js} +2 -2
- package/dist/components/VStack.js.map +1 -0
- package/dist/jest/index.cjs +27 -0
- package/dist/jest/index.d.cts +19 -0
- package/dist/jest/index.d.cts.map +1 -0
- package/dist/jest/index.d.ts +19 -0
- package/dist/jest/index.d.ts.map +1 -0
- package/dist/jest/index.js +25 -0
- package/dist/jest/index.js.map +1 -0
- package/dist/jest/mocks/icons.cjs +56 -0
- package/dist/jest/mocks/icons.d.cts +24 -0
- package/dist/jest/mocks/icons.d.cts.map +1 -0
- package/dist/jest/mocks/icons.d.ts +24 -0
- package/dist/jest/mocks/icons.d.ts.map +1 -0
- package/dist/jest/mocks/icons.js +46 -0
- package/dist/jest/mocks/icons.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +212 -0
- package/dist/jest/mocks/react-native.d.cts +293 -0
- package/dist/jest/mocks/react-native.d.cts.map +1 -0
- package/dist/jest/mocks/react-native.d.ts +293 -0
- package/dist/jest/mocks/react-native.d.ts.map +1 -0
- package/dist/jest/mocks/react-native.js +180 -0
- package/dist/jest/mocks/react-native.js.map +1 -0
- package/dist/jest/mocks/reanimated.cjs +249 -0
- package/dist/jest/mocks/reanimated.d.cts +150 -0
- package/dist/jest/mocks/reanimated.d.cts.map +1 -0
- package/dist/jest/mocks/reanimated.d.ts +150 -0
- package/dist/jest/mocks/reanimated.d.ts.map +1 -0
- package/dist/jest/mocks/reanimated.js +210 -0
- package/dist/jest/mocks/reanimated.js.map +1 -0
- package/dist/jest/mocks/styles.cjs +327 -0
- package/dist/jest/mocks/styles.d.cts +33 -0
- package/dist/jest/mocks/styles.d.cts.map +1 -0
- package/dist/jest/mocks/styles.d.ts +33 -0
- package/dist/jest/mocks/styles.d.ts.map +1 -0
- package/dist/jest/mocks/styles.js +310 -0
- package/dist/jest/mocks/styles.js.map +1 -0
- package/dist/jest/mocks/svg.cjs +133 -0
- package/dist/jest/mocks/svg.d.cts +137 -0
- package/dist/jest/mocks/svg.d.cts.map +1 -0
- package/dist/jest/mocks/svg.d.ts +137 -0
- package/dist/jest/mocks/svg.d.ts.map +1 -0
- package/dist/jest/mocks/svg.js +100 -0
- package/dist/jest/mocks/svg.js.map +1 -0
- package/dist/jest/mocks/unistyles.cjs +143 -0
- package/dist/jest/mocks/unistyles.d.cts +197 -0
- package/dist/jest/mocks/unistyles.d.cts.map +1 -0
- package/dist/jest/mocks/unistyles.d.ts +197 -0
- package/dist/jest/mocks/unistyles.d.ts.map +1 -0
- package/dist/jest/mocks/unistyles.js +132 -0
- package/dist/jest/mocks/unistyles.js.map +1 -0
- package/dist/jest/setup.cjs +40 -0
- package/dist/jest/setup.d.cts +11 -0
- package/dist/jest/setup.d.cts.map +1 -0
- package/dist/jest/setup.d.ts +11 -0
- package/dist/jest/setup.d.ts.map +1 -0
- package/dist/jest/setup.js +39 -0
- package/dist/jest/setup.js.map +1 -0
- package/dist/motion-tokens/dist/{index.d.mts → index.d.ts} +2 -2
- package/dist/motion-tokens/dist/index.d.ts.map +1 -0
- package/dist/motion-tokens/dist/{index.mjs → index.js} +1 -1
- package/dist/motion-tokens/dist/index.js.map +1 -0
- package/dist/{motion.d.mts → motion.d.ts} +3 -3
- package/dist/motion.d.ts.map +1 -0
- package/dist/{motion.mjs → motion.js} +2 -2
- package/dist/motion.js.map +1 -0
- package/dist/types/dist/{index.d.mts → index.d.ts} +1 -1
- package/dist/types/dist/index.d.ts.map +1 -0
- package/dist/{types.d.mts → types.d.ts} +1 -1
- package/dist/types.d.ts.map +1 -0
- package/dist/{types.mjs → types.js} +0 -1
- package/fonts/index.cjs +205 -205
- package/fonts/index.mjs +205 -205
- package/generated/unistyles.d.ts +9 -0
- package/package.json +65 -41
- package/dist/components/Avatar.d.mts.map +0 -1
- package/dist/components/Avatar.mjs.map +0 -1
- package/dist/components/Badge.d.mts.map +0 -1
- package/dist/components/Badge.mjs.map +0 -1
- package/dist/components/Box.mjs +0 -131
- package/dist/components/Box.mjs.map +0 -1
- package/dist/components/Button.d.mts.map +0 -1
- package/dist/components/Button.mjs.map +0 -1
- package/dist/components/Checkbox.d.mts.map +0 -1
- package/dist/components/Checkbox.mjs.map +0 -1
- package/dist/components/Chip.d.mts.map +0 -1
- package/dist/components/Chip.mjs.map +0 -1
- package/dist/components/HStack.d.mts.map +0 -1
- package/dist/components/HStack.mjs.map +0 -1
- package/dist/components/Icon.d.mts.map +0 -1
- package/dist/components/Icon.mjs.map +0 -1
- package/dist/components/IconButton.d.mts.map +0 -1
- package/dist/components/IconButton.mjs.map +0 -1
- package/dist/components/IconSlot.d.mts.map +0 -1
- package/dist/components/IconSlot.mjs.map +0 -1
- package/dist/components/Image.d.mts.map +0 -1
- package/dist/components/Image.mjs.map +0 -1
- package/dist/components/Input.d.mts.map +0 -1
- package/dist/components/Input.mjs.map +0 -1
- package/dist/components/Link.d.mts.map +0 -1
- package/dist/components/Link.mjs.map +0 -1
- package/dist/components/Pressable.d.mts.map +0 -1
- package/dist/components/Pressable.mjs.map +0 -1
- package/dist/components/Radio.d.mts.map +0 -1
- package/dist/components/Radio.mjs.map +0 -1
- package/dist/components/Screen.d.mts.map +0 -1
- package/dist/components/Screen.mjs.map +0 -1
- package/dist/components/Switch.d.mts.map +0 -1
- package/dist/components/Switch.mjs.map +0 -1
- package/dist/components/Text.d.mts.map +0 -1
- package/dist/components/Text.mjs.map +0 -1
- package/dist/components/VStack.d.mts.map +0 -1
- package/dist/components/VStack.mjs.map +0 -1
- package/dist/motion-tokens/dist/index.d.mts.map +0 -1
- package/dist/motion-tokens/dist/index.mjs.map +0 -1
- package/dist/motion.d.mts.map +0 -1
- package/dist/motion.mjs.map +0 -1
- package/dist/types/dist/index.d.mts.map +0 -1
- package/dist/types.d.mts.map +0 -1
package/dist/components/Box.cjs
CHANGED
|
@@ -8,6 +8,36 @@ let react_native_unistyles = require("react-native-unistyles");
|
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
|
|
10
10
|
//#region src/components/Box.tsx
|
|
11
|
+
let BlurView = null;
|
|
12
|
+
let blurLoadState = "pending";
|
|
13
|
+
const blurLoadListeners = [];
|
|
14
|
+
import("expo-blur").then((mod) => {
|
|
15
|
+
BlurView = mod.BlurView;
|
|
16
|
+
blurLoadState = "loaded";
|
|
17
|
+
blurLoadListeners.forEach((cb) => cb());
|
|
18
|
+
}).catch(() => {
|
|
19
|
+
blurLoadState = "failed";
|
|
20
|
+
blurLoadListeners.forEach((cb) => cb());
|
|
21
|
+
});
|
|
22
|
+
/** Hook to get BlurView component, re-renders when loaded */
|
|
23
|
+
function useBlurView() {
|
|
24
|
+
const [, forceUpdate] = (0, react.useState)(0);
|
|
25
|
+
(0, react.useEffect)(() => {
|
|
26
|
+
if (blurLoadState === "pending") {
|
|
27
|
+
const listener = () => forceUpdate((n) => n + 1);
|
|
28
|
+
blurLoadListeners.push(listener);
|
|
29
|
+
return () => {
|
|
30
|
+
const idx = blurLoadListeners.indexOf(listener);
|
|
31
|
+
if (idx >= 0) blurLoadListeners.splice(idx, 1);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
return {
|
|
36
|
+
BlurView,
|
|
37
|
+
isLoaded: blurLoadState !== "pending",
|
|
38
|
+
isFailed: blurLoadState === "failed"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
11
41
|
/**
|
|
12
42
|
* **📦 A layout component that can be used to compose other components**
|
|
13
43
|
*
|
|
@@ -36,8 +66,39 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
36
66
|
* @see {@link HStack} for horizontal layouts
|
|
37
67
|
* @see {@link VStack} for vertical layouts
|
|
38
68
|
*/
|
|
39
|
-
const Box = (0, react.memo)(function Box({ elevation, backgroundColor, dangerouslySetBackgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, dangerouslySetBorderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, display = "flex", overflow, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, width, height, minWidth, maxWidth, minHeight, maxHeight, dropShadow, insetShadow, style, ref, ...props }) {
|
|
69
|
+
const Box = (0, react.memo)(function Box({ elevation, backgroundColor, dangerouslySetBackgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, dangerouslySetBorderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, display = "flex", overflow, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, width, height, minWidth, maxWidth, minHeight, maxHeight, dropShadow, insetShadow, blur, blurTarget, style, ref, ...props }) {
|
|
70
|
+
const { theme, rt } = (0, react_native_unistyles.useUnistyles)();
|
|
71
|
+
const { BlurView: BlurViewComponent, isLoaded: blurIsLoaded, isFailed: blurFailed } = useBlurView();
|
|
40
72
|
const elevationAlias = elevation !== void 0 ? `elevation-${elevation}` : void 0;
|
|
73
|
+
const blurExplicitlySet = blur !== void 0;
|
|
74
|
+
const blurIntensity = (0, react.useMemo)(() => {
|
|
75
|
+
if (blur !== void 0) return blur;
|
|
76
|
+
if (elevation === void 0 || !theme.blur) return 0;
|
|
77
|
+
const blurKey = `elevation-${elevation}`;
|
|
78
|
+
return theme.blur[blurKey] ?? 0;
|
|
79
|
+
}, [
|
|
80
|
+
blur,
|
|
81
|
+
elevation,
|
|
82
|
+
theme
|
|
83
|
+
]);
|
|
84
|
+
const hasWarnedRef = (0, react.useRef)("none");
|
|
85
|
+
(0, react.useEffect)(() => {
|
|
86
|
+
if (!__DEV__ || blurIntensity === 0 || !blurIsLoaded) return;
|
|
87
|
+
if (blurFailed && hasWarnedRef.current !== "no-expo-blur") {
|
|
88
|
+
hasWarnedRef.current = "no-expo-blur";
|
|
89
|
+
console.warn("[UDS Mobile] Box: Blur effect requested but expo-blur is not installed. ");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (!blurTarget && hasWarnedRef.current !== "no-blur-target") {
|
|
93
|
+
hasWarnedRef.current = "no-blur-target";
|
|
94
|
+
console.warn("[UDS Mobile] Box: Blur effect requires a blurTarget ref. Wrap the content to blur in <BlurTarget ref={ref}> and pass the ref to blurTarget prop. See BACKGROUND_BLUR.md for details.");
|
|
95
|
+
}
|
|
96
|
+
}, [
|
|
97
|
+
blurIntensity,
|
|
98
|
+
blurTarget,
|
|
99
|
+
blurIsLoaded,
|
|
100
|
+
blurFailed
|
|
101
|
+
]);
|
|
41
102
|
const variants = {
|
|
42
103
|
backgroundColor: backgroundColor ?? elevationAlias,
|
|
43
104
|
borderRadius,
|
|
@@ -88,10 +149,35 @@ const Box = (0, react.memo)(function Box({ elevation, backgroundColor, dangerous
|
|
|
88
149
|
generated_styles.styles.useVariants(variants);
|
|
89
150
|
const effectiveDropShadow = dropShadow ?? elevationAlias;
|
|
90
151
|
const shadowStyle = effectiveDropShadow || insetShadow ? shadowSheet.shadow(effectiveDropShadow, insetShadow) : void 0;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
152
|
+
const boxStyles = (0, react.useMemo)(() => [
|
|
153
|
+
dangerouslySetBackgroundColor ? { backgroundColor: dangerouslySetBackgroundColor } : void 0,
|
|
154
|
+
dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : void 0,
|
|
155
|
+
width ? { width } : void 0,
|
|
156
|
+
height ? { height } : void 0,
|
|
157
|
+
minWidth ? { minWidth } : void 0,
|
|
158
|
+
maxWidth ? { maxWidth } : void 0,
|
|
159
|
+
minHeight ? { minHeight } : void 0,
|
|
160
|
+
maxHeight ? { maxHeight } : void 0,
|
|
161
|
+
shadowStyle,
|
|
162
|
+
generated_styles.styles.foundation,
|
|
163
|
+
style
|
|
164
|
+
], [
|
|
165
|
+
dangerouslySetBackgroundColor,
|
|
166
|
+
dangerouslySetBorderColor,
|
|
167
|
+
width,
|
|
168
|
+
height,
|
|
169
|
+
minWidth,
|
|
170
|
+
maxWidth,
|
|
171
|
+
minHeight,
|
|
172
|
+
maxHeight,
|
|
173
|
+
shadowStyle,
|
|
174
|
+
generated_styles.styles.foundation,
|
|
175
|
+
style
|
|
176
|
+
]);
|
|
177
|
+
if (BlurViewComponent && (blurIntensity > 0 || blurExplicitlySet)) {
|
|
178
|
+
const isAndroid = react_native.Platform.OS === "android";
|
|
179
|
+
const blurTint = rt.themeName === "dark" ? "dark" : "light";
|
|
180
|
+
const blurStyles = isAndroid ? boxStyles : [
|
|
95
181
|
dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : void 0,
|
|
96
182
|
width ? { width } : void 0,
|
|
97
183
|
height ? { height } : void 0,
|
|
@@ -100,21 +186,32 @@ const Box = (0, react.memo)(function Box({ elevation, backgroundColor, dangerous
|
|
|
100
186
|
minHeight ? { minHeight } : void 0,
|
|
101
187
|
maxHeight ? { maxHeight } : void 0,
|
|
102
188
|
shadowStyle,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
189
|
+
{
|
|
190
|
+
...generated_styles.styles.foundation,
|
|
191
|
+
backgroundColor: void 0
|
|
192
|
+
},
|
|
193
|
+
style ? Array.isArray(style) ? style.map((s) => s && typeof s === "object" ? {
|
|
194
|
+
...s,
|
|
195
|
+
backgroundColor: void 0
|
|
196
|
+
} : s) : typeof style === "object" ? {
|
|
197
|
+
...style,
|
|
198
|
+
backgroundColor: void 0
|
|
199
|
+
} : style : void 0
|
|
200
|
+
];
|
|
201
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BlurViewComponent, {
|
|
202
|
+
ref,
|
|
203
|
+
intensity: isAndroid ? Math.min(blurIntensity * .4, 40) : blurIntensity,
|
|
204
|
+
tint: blurTint,
|
|
205
|
+
blurTarget: isAndroid ? blurTarget : void 0,
|
|
206
|
+
blurMethod: isAndroid ? "dimezisBlurView" : void 0,
|
|
207
|
+
style: blurStyles,
|
|
208
|
+
...props,
|
|
209
|
+
children: props.children
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
213
|
+
ref,
|
|
214
|
+
style: boxStyles,
|
|
118
215
|
...props
|
|
119
216
|
});
|
|
120
217
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ElevationLevel } from "../types/dist/index.cjs";
|
|
3
3
|
import { SizeProps } from "../types.cjs";
|
|
4
4
|
import * as react from "react";
|
|
5
|
-
import { Ref } from "react";
|
|
5
|
+
import { Ref, RefObject } from "react";
|
|
6
6
|
import { View, ViewProps } from "react-native";
|
|
7
7
|
import { StyleProps } from "../../generated/styles";
|
|
8
8
|
|
|
@@ -59,6 +59,16 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
59
59
|
insetShadow?: StyleProps['insetShadow'];
|
|
60
60
|
dangerouslySetBackgroundColor?: string;
|
|
61
61
|
dangerouslySetBorderColor?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Manual blur intensity (0-100). When set, renders as a BlurView.
|
|
64
|
+
* Requires `blurTarget` pointing to a BlurTarget ref wrapping the content to blur.
|
|
65
|
+
*/
|
|
66
|
+
blur?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Reference to a BlurTarget component wrapping the content to blur.
|
|
69
|
+
* Required when using `blur` prop or elevation with blur configured.
|
|
70
|
+
*/
|
|
71
|
+
blurTarget?: RefObject<View | null>;
|
|
62
72
|
}
|
|
63
73
|
/**
|
|
64
74
|
* **📦 A layout component that can be used to compose other components**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.cts","names":[],"sources":["../../src/components/Box.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Box.d.cts","names":[],"sources":["../../src/components/Box.tsx"],"mappings":";;;;;;;;;UAmDU,QAAA,SAAiB,SAAA,EAAW,SAAA;EACpC,GAAA,GAAM,GAAA,CAAI,IAAA;EACV,SAAA,GAAY,cAAA;EACZ,eAAA,GAAkB,UAAA;EAClB,YAAA,GAAe,UAAA;EACf,oBAAA,GAAuB,UAAA;EACvB,kBAAA,GAAqB,UAAA;EACrB,uBAAA,GAA0B,UAAA;EAC1B,qBAAA,GAAwB,UAAA;EACxB,WAAA,GAAc,UAAA;EACd,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EACpB,WAAA,GAAc,UAAA;EACd,mBAAA,GAAsB,UAAA;EACtB,qBAAA,GAAwB,UAAA;EACxB,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EACpB,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EACb,SAAA,GAAY,UAAA;EACZ,IAAA,GAAO,UAAA;EACP,aAAA,GAAgB,UAAA;EAChB,QAAA,GAAW,UAAA;EACX,UAAA,GAAa,UAAA;EACb,QAAA,GAAW,UAAA;EACX,cAAA,GAAiB,UAAA;EAEjB,OAAA,GAAU,UAAA;EACV,QAAA,GAAW,UAAA;EAIX,OAAA,GAAU,UAAA;EACV,iBAAA,GAAoB,UAAA;EACpB,eAAA,GAAkB,UAAA;EAClB,aAAA,GAAgB,UAAA;EAChB,UAAA,GAAa,UAAA;EACb,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EACb,MAAA,GAAS,UAAA;EACT,cAAA,GAAiB,UAAA;EACjB,gBAAA,GAAmB,UAAA;EACnB,YAAA,GAAe,UAAA;EACf,SAAA,GAAY,UAAA;EACZ,WAAA,GAAc,UAAA;EACd,SAAA,GAAY,UAAA;EACZ,SAAA,GAAY,UAAA;EACZ,MAAA,GAAS,UAAA;EACT,UAAA,GAAa,UAAA;EACb,WAAA,GAAc,UAAA;EACd,6BAAA;EACA,yBAAA;EAJS;;;;EAST,IAAA;EA5DyB;;;;EAiEzB,UAAA,GAAa,SAAA,CAAU,IAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BnB,GAAA,EAAG,KAAA,CAAA,oBAAA,CAAA,QAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
import { ElevationLevel } from "../types/dist/index.
|
|
3
|
-
import { SizeProps } from "../types.
|
|
2
|
+
import { ElevationLevel } from "../types/dist/index.js";
|
|
3
|
+
import { SizeProps } from "../types.js";
|
|
4
4
|
import * as react from "react";
|
|
5
|
-
import { Ref } from "react";
|
|
5
|
+
import { Ref, RefObject } from "react";
|
|
6
6
|
import { View, ViewProps } from "react-native";
|
|
7
7
|
import { StyleProps } from "../../generated/styles";
|
|
8
8
|
|
|
@@ -59,6 +59,16 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
59
59
|
insetShadow?: StyleProps['insetShadow'];
|
|
60
60
|
dangerouslySetBackgroundColor?: string;
|
|
61
61
|
dangerouslySetBorderColor?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Manual blur intensity (0-100). When set, renders as a BlurView.
|
|
64
|
+
* Requires `blurTarget` pointing to a BlurTarget ref wrapping the content to blur.
|
|
65
|
+
*/
|
|
66
|
+
blur?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Reference to a BlurTarget component wrapping the content to blur.
|
|
69
|
+
* Required when using `blur` prop or elevation with blur configured.
|
|
70
|
+
*/
|
|
71
|
+
blurTarget?: RefObject<View | null>;
|
|
62
72
|
}
|
|
63
73
|
/**
|
|
64
74
|
* **📦 A layout component that can be used to compose other components**
|
|
@@ -91,4 +101,4 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
91
101
|
declare const Box: react.NamedExoticComponent<BoxProps>;
|
|
92
102
|
//#endregion
|
|
93
103
|
export { Box, type BoxProps };
|
|
94
|
-
//# sourceMappingURL=Box.d.
|
|
104
|
+
//# sourceMappingURL=Box.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.
|
|
1
|
+
{"version":3,"file":"Box.d.ts","names":[],"sources":["../../src/components/Box.tsx"],"mappings":";;;;;;;;;UAmDU,QAAA,SAAiB,SAAA,EAAW,SAAA;EACpC,GAAA,GAAM,GAAA,CAAI,IAAA;EACV,SAAA,GAAY,cAAA;EACZ,eAAA,GAAkB,UAAA;EAClB,YAAA,GAAe,UAAA;EACf,oBAAA,GAAuB,UAAA;EACvB,kBAAA,GAAqB,UAAA;EACrB,uBAAA,GAA0B,UAAA;EAC1B,qBAAA,GAAw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/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { Platform, View } from "react-native";
|
|
4
|
+
import { styles } from "../../generated/styles";
|
|
5
|
+
import { StyleSheet as StyleSheet$1, useUnistyles } from "react-native-unistyles";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
|
|
8
|
+
//#region src/components/Box.tsx
|
|
9
|
+
let BlurView = null;
|
|
10
|
+
let blurLoadState = "pending";
|
|
11
|
+
const blurLoadListeners = [];
|
|
12
|
+
import("expo-blur").then((mod) => {
|
|
13
|
+
BlurView = mod.BlurView;
|
|
14
|
+
blurLoadState = "loaded";
|
|
15
|
+
blurLoadListeners.forEach((cb) => cb());
|
|
16
|
+
}).catch(() => {
|
|
17
|
+
blurLoadState = "failed";
|
|
18
|
+
blurLoadListeners.forEach((cb) => cb());
|
|
19
|
+
});
|
|
20
|
+
/** Hook to get BlurView component, re-renders when loaded */
|
|
21
|
+
function useBlurView() {
|
|
22
|
+
const [, forceUpdate] = useState(0);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (blurLoadState === "pending") {
|
|
25
|
+
const listener = () => forceUpdate((n) => n + 1);
|
|
26
|
+
blurLoadListeners.push(listener);
|
|
27
|
+
return () => {
|
|
28
|
+
const idx = blurLoadListeners.indexOf(listener);
|
|
29
|
+
if (idx >= 0) blurLoadListeners.splice(idx, 1);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}, []);
|
|
33
|
+
return {
|
|
34
|
+
BlurView,
|
|
35
|
+
isLoaded: blurLoadState !== "pending",
|
|
36
|
+
isFailed: blurLoadState === "failed"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* **📦 A layout component that can be used to compose other components**
|
|
41
|
+
*
|
|
42
|
+
* @description
|
|
43
|
+
* The most simple component we ship - a View. But with all the power of the UDS design system.
|
|
44
|
+
* By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,
|
|
45
|
+
* consider using VStack or HStack respectively.
|
|
46
|
+
*
|
|
47
|
+
* @category Layout
|
|
48
|
+
* @platform mobile
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* import { Box } from '@yahoo/uds-mobile';
|
|
53
|
+
*
|
|
54
|
+
* <Box backgroundColor="primary" spacing="6">
|
|
55
|
+
* Any kind of content can go here!
|
|
56
|
+
* </Box>
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @usage
|
|
60
|
+
* - Use as a container to apply padding, shapes, or other styling
|
|
61
|
+
* - Use for creating card components
|
|
62
|
+
* - Use HStack/VStack for directional layouts
|
|
63
|
+
*
|
|
64
|
+
* @see {@link HStack} for horizontal layouts
|
|
65
|
+
* @see {@link VStack} for vertical layouts
|
|
66
|
+
*/
|
|
67
|
+
const Box = memo(function Box({ elevation, backgroundColor, dangerouslySetBackgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, dangerouslySetBorderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, display = "flex", overflow, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, width, height, minWidth, maxWidth, minHeight, maxHeight, dropShadow, insetShadow, blur, blurTarget, style, ref, ...props }) {
|
|
68
|
+
const { theme, rt } = useUnistyles();
|
|
69
|
+
const { BlurView: BlurViewComponent, isLoaded: blurIsLoaded, isFailed: blurFailed } = useBlurView();
|
|
70
|
+
const elevationAlias = elevation !== void 0 ? `elevation-${elevation}` : void 0;
|
|
71
|
+
const blurExplicitlySet = blur !== void 0;
|
|
72
|
+
const blurIntensity = useMemo(() => {
|
|
73
|
+
if (blur !== void 0) return blur;
|
|
74
|
+
if (elevation === void 0 || !theme.blur) return 0;
|
|
75
|
+
const blurKey = `elevation-${elevation}`;
|
|
76
|
+
return theme.blur[blurKey] ?? 0;
|
|
77
|
+
}, [
|
|
78
|
+
blur,
|
|
79
|
+
elevation,
|
|
80
|
+
theme
|
|
81
|
+
]);
|
|
82
|
+
const hasWarnedRef = useRef("none");
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!__DEV__ || blurIntensity === 0 || !blurIsLoaded) return;
|
|
85
|
+
if (blurFailed && hasWarnedRef.current !== "no-expo-blur") {
|
|
86
|
+
hasWarnedRef.current = "no-expo-blur";
|
|
87
|
+
console.warn("[UDS Mobile] Box: Blur effect requested but expo-blur is not installed. ");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (!blurTarget && hasWarnedRef.current !== "no-blur-target") {
|
|
91
|
+
hasWarnedRef.current = "no-blur-target";
|
|
92
|
+
console.warn("[UDS Mobile] Box: Blur effect requires a blurTarget ref. Wrap the content to blur in <BlurTarget ref={ref}> and pass the ref to blurTarget prop. See BACKGROUND_BLUR.md for details.");
|
|
93
|
+
}
|
|
94
|
+
}, [
|
|
95
|
+
blurIntensity,
|
|
96
|
+
blurTarget,
|
|
97
|
+
blurIsLoaded,
|
|
98
|
+
blurFailed
|
|
99
|
+
]);
|
|
100
|
+
const variants = {
|
|
101
|
+
backgroundColor: backgroundColor ?? elevationAlias,
|
|
102
|
+
borderRadius,
|
|
103
|
+
borderTopStartRadius,
|
|
104
|
+
borderTopEndRadius,
|
|
105
|
+
borderBottomStartRadius,
|
|
106
|
+
borderBottomEndRadius,
|
|
107
|
+
borderColor: borderColor ?? elevationAlias,
|
|
108
|
+
borderStartColor,
|
|
109
|
+
borderEndColor,
|
|
110
|
+
borderTopColor,
|
|
111
|
+
borderBottomColor,
|
|
112
|
+
borderWidth: borderWidth ?? elevationAlias,
|
|
113
|
+
borderVerticalWidth,
|
|
114
|
+
borderHorizontalWidth,
|
|
115
|
+
borderStartWidth,
|
|
116
|
+
borderEndWidth,
|
|
117
|
+
borderTopWidth,
|
|
118
|
+
borderBottomWidth,
|
|
119
|
+
alignContent,
|
|
120
|
+
alignItems,
|
|
121
|
+
alignSelf,
|
|
122
|
+
flex,
|
|
123
|
+
flexDirection,
|
|
124
|
+
flexGrow,
|
|
125
|
+
flexShrink,
|
|
126
|
+
flexWrap,
|
|
127
|
+
justifyContent,
|
|
128
|
+
display,
|
|
129
|
+
overflow,
|
|
130
|
+
spacing,
|
|
131
|
+
spacingHorizontal,
|
|
132
|
+
spacingVertical,
|
|
133
|
+
spacingBottom,
|
|
134
|
+
spacingEnd,
|
|
135
|
+
spacingStart,
|
|
136
|
+
spacingTop,
|
|
137
|
+
offset,
|
|
138
|
+
offsetVertical,
|
|
139
|
+
offsetHorizontal,
|
|
140
|
+
offsetBottom,
|
|
141
|
+
offsetEnd,
|
|
142
|
+
offsetStart,
|
|
143
|
+
offsetTop,
|
|
144
|
+
columnGap,
|
|
145
|
+
rowGap
|
|
146
|
+
};
|
|
147
|
+
styles.useVariants(variants);
|
|
148
|
+
const effectiveDropShadow = dropShadow ?? elevationAlias;
|
|
149
|
+
const shadowStyle = effectiveDropShadow || insetShadow ? shadowSheet.shadow(effectiveDropShadow, insetShadow) : void 0;
|
|
150
|
+
const boxStyles = useMemo(() => [
|
|
151
|
+
dangerouslySetBackgroundColor ? { backgroundColor: dangerouslySetBackgroundColor } : void 0,
|
|
152
|
+
dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : void 0,
|
|
153
|
+
width ? { width } : void 0,
|
|
154
|
+
height ? { height } : void 0,
|
|
155
|
+
minWidth ? { minWidth } : void 0,
|
|
156
|
+
maxWidth ? { maxWidth } : void 0,
|
|
157
|
+
minHeight ? { minHeight } : void 0,
|
|
158
|
+
maxHeight ? { maxHeight } : void 0,
|
|
159
|
+
shadowStyle,
|
|
160
|
+
styles.foundation,
|
|
161
|
+
style
|
|
162
|
+
], [
|
|
163
|
+
dangerouslySetBackgroundColor,
|
|
164
|
+
dangerouslySetBorderColor,
|
|
165
|
+
width,
|
|
166
|
+
height,
|
|
167
|
+
minWidth,
|
|
168
|
+
maxWidth,
|
|
169
|
+
minHeight,
|
|
170
|
+
maxHeight,
|
|
171
|
+
shadowStyle,
|
|
172
|
+
styles.foundation,
|
|
173
|
+
style
|
|
174
|
+
]);
|
|
175
|
+
if (BlurViewComponent && (blurIntensity > 0 || blurExplicitlySet)) {
|
|
176
|
+
const isAndroid = Platform.OS === "android";
|
|
177
|
+
const blurTint = rt.themeName === "dark" ? "dark" : "light";
|
|
178
|
+
const blurStyles = isAndroid ? boxStyles : [
|
|
179
|
+
dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : void 0,
|
|
180
|
+
width ? { width } : void 0,
|
|
181
|
+
height ? { height } : void 0,
|
|
182
|
+
minWidth ? { minWidth } : void 0,
|
|
183
|
+
maxWidth ? { maxWidth } : void 0,
|
|
184
|
+
minHeight ? { minHeight } : void 0,
|
|
185
|
+
maxHeight ? { maxHeight } : void 0,
|
|
186
|
+
shadowStyle,
|
|
187
|
+
{
|
|
188
|
+
...styles.foundation,
|
|
189
|
+
backgroundColor: void 0
|
|
190
|
+
},
|
|
191
|
+
style ? Array.isArray(style) ? style.map((s) => s && typeof s === "object" ? {
|
|
192
|
+
...s,
|
|
193
|
+
backgroundColor: void 0
|
|
194
|
+
} : s) : typeof style === "object" ? {
|
|
195
|
+
...style,
|
|
196
|
+
backgroundColor: void 0
|
|
197
|
+
} : style : void 0
|
|
198
|
+
];
|
|
199
|
+
return /* @__PURE__ */ jsx(BlurViewComponent, {
|
|
200
|
+
ref,
|
|
201
|
+
intensity: isAndroid ? Math.min(blurIntensity * .4, 40) : blurIntensity,
|
|
202
|
+
tint: blurTint,
|
|
203
|
+
blurTarget: isAndroid ? blurTarget : void 0,
|
|
204
|
+
blurMethod: isAndroid ? "dimezisBlurView" : void 0,
|
|
205
|
+
style: blurStyles,
|
|
206
|
+
...props,
|
|
207
|
+
children: props.children
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
return /* @__PURE__ */ jsx(View, {
|
|
211
|
+
ref,
|
|
212
|
+
style: boxStyles,
|
|
213
|
+
...props
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
Box.displayName = "Box";
|
|
217
|
+
/**
|
|
218
|
+
* Dynamic shadow stylesheet that merges drop and inset shadows into a single
|
|
219
|
+
* boxShadow CSS string. Theme-reactive so shadows update on color mode change.
|
|
220
|
+
*/
|
|
221
|
+
const shadowSheet = StyleSheet$1.create((theme) => ({ shadow: (drop, inset) => {
|
|
222
|
+
const parts = [drop ? theme.boxShadow.drop[drop] : "", inset ? theme.boxShadow.inset[inset] : ""].filter(Boolean);
|
|
223
|
+
return parts.length > 0 ? { boxShadow: parts.join(", ") } : {};
|
|
224
|
+
} }));
|
|
225
|
+
|
|
226
|
+
//#endregion
|
|
227
|
+
export { Box };
|
|
228
|
+
//# sourceMappingURL=Box.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Box.js","names":["StyleSheet"],"sources":["../../src/components/Box.tsx"],"sourcesContent":["import type { ElevationLevel } from '@yahoo/uds-types';\nimport type { ComponentType, Ref, RefObject } from 'react';\nimport { memo, useEffect, useMemo, useRef, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Platform, View } from 'react-native';\n// eslint-disable-next-line uds/no-use-unistyles -- blur intensity is not a style property, requires direct theme access\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport type { SizeProps } from '../types';\n\n// Optional expo-blur dependency - loaded via dynamic import for Metro compatibility\n// Metro can statically analyze import() and will include expo-blur in the bundle if installed\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet BlurView: ComponentType<any> | null = null;\nlet blurLoadState: 'pending' | 'loaded' | 'failed' = 'pending';\nconst blurLoadListeners: (() => void)[] = [];\n\n// Start loading expo-blur immediately (Metro will bundle it if installed)\nimport('expo-blur')\n .then((mod) => {\n BlurView = mod.BlurView;\n blurLoadState = 'loaded';\n blurLoadListeners.forEach((cb) => cb());\n })\n .catch(() => {\n blurLoadState = 'failed';\n blurLoadListeners.forEach((cb) => cb());\n });\n\n/** Hook to get BlurView component, re-renders when loaded */\nfunction useBlurView() {\n const [, forceUpdate] = useState(0);\n\n useEffect(() => {\n if (blurLoadState === 'pending') {\n const listener = () => forceUpdate((n) => n + 1);\n blurLoadListeners.push(listener);\n return () => {\n const idx = blurLoadListeners.indexOf(listener);\n if (idx >= 0) {\n blurLoadListeners.splice(idx, 1);\n }\n };\n }\n }, []);\n\n return { BlurView, isLoaded: blurLoadState !== 'pending', isFailed: blurLoadState === 'failed' };\n}\n\ninterface BoxProps extends ViewProps, SizeProps {\n ref?: Ref<View>;\n elevation?: ElevationLevel;\n backgroundColor?: StyleProps['backgroundColor'];\n borderRadius?: StyleProps['borderRadius'];\n borderTopStartRadius?: StyleProps['borderTopStartRadius'];\n borderTopEndRadius?: StyleProps['borderTopEndRadius'];\n borderBottomStartRadius?: StyleProps['borderBottomStartRadius'];\n borderBottomEndRadius?: StyleProps['borderBottomEndRadius'];\n borderColor?: StyleProps['borderColor'];\n borderStartColor?: StyleProps['borderStartColor'];\n borderEndColor?: StyleProps['borderEndColor'];\n borderTopColor?: StyleProps['borderTopColor'];\n borderBottomColor?: StyleProps['borderBottomColor'];\n borderWidth?: StyleProps['borderWidth'];\n borderVerticalWidth?: StyleProps['borderVerticalWidth'];\n borderHorizontalWidth?: StyleProps['borderHorizontalWidth'];\n borderStartWidth?: StyleProps['borderStartWidth'];\n borderEndWidth?: StyleProps['borderEndWidth'];\n borderTopWidth?: StyleProps['borderTopWidth'];\n borderBottomWidth?: StyleProps['borderBottomWidth'];\n alignContent?: StyleProps['alignContent'];\n alignItems?: StyleProps['alignItems'];\n alignSelf?: StyleProps['alignSelf'];\n flex?: StyleProps['flex'];\n flexDirection?: StyleProps['flexDirection'];\n flexGrow?: StyleProps['flexGrow'];\n flexShrink?: StyleProps['flexShrink'];\n flexWrap?: StyleProps['flexWrap'];\n justifyContent?: StyleProps['justifyContent'];\n // flexBasis?: StyleProps['flexBasis'];\n display?: StyleProps['display'];\n overflow?: StyleProps['overflow'];\n // overflowX?: StyleProps['overflowX'];\n // overflowY?: StyleProps['overflowY'];\n // position?: StyleProps['position'];\n spacing?: StyleProps['spacing'];\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n spacingVertical?: StyleProps['spacingVertical'];\n spacingBottom?: StyleProps['spacingBottom'];\n spacingEnd?: StyleProps['spacingEnd'];\n spacingStart?: StyleProps['spacingStart'];\n spacingTop?: StyleProps['spacingTop'];\n offset?: StyleProps['offset'];\n offsetVertical?: StyleProps['offsetVertical'];\n offsetHorizontal?: StyleProps['offsetHorizontal'];\n offsetBottom?: StyleProps['offsetBottom'];\n offsetEnd?: StyleProps['offsetEnd'];\n offsetStart?: StyleProps['offsetStart'];\n offsetTop?: StyleProps['offsetTop'];\n columnGap?: StyleProps['columnGap'];\n rowGap?: StyleProps['rowGap'];\n dropShadow?: StyleProps['dropShadow'];\n insetShadow?: StyleProps['insetShadow'];\n dangerouslySetBackgroundColor?: string;\n dangerouslySetBorderColor?: string;\n /**\n * Manual blur intensity (0-100). When set, renders as a BlurView.\n * Requires `blurTarget` pointing to a BlurTarget ref wrapping the content to blur.\n */\n blur?: number;\n /**\n * Reference to a BlurTarget component wrapping the content to blur.\n * Required when using `blur` prop or elevation with blur configured.\n */\n blurTarget?: RefObject<View | null>;\n}\n\n/**\n * **📦 A layout component that can be used to compose other components**\n *\n * @description\n * The most simple component we ship - a View. But with all the power of the UDS design system.\n * By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,\n * consider using VStack or HStack respectively.\n *\n * @category Layout\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Box } from '@yahoo/uds-mobile';\n *\n * <Box backgroundColor=\"primary\" spacing=\"6\">\n * Any kind of content can go here!\n * </Box>\n * ```\n *\n * @usage\n * - Use as a container to apply padding, shapes, or other styling\n * - Use for creating card components\n * - Use HStack/VStack for directional layouts\n *\n * @see {@link HStack} for horizontal layouts\n * @see {@link VStack} for vertical layouts\n */\nconst Box = memo(function Box({\n // elevation\n elevation,\n // background\n backgroundColor,\n dangerouslySetBackgroundColor,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n dangerouslySetBorderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // flex\n alignContent,\n alignItems,\n alignSelf,\n flex,\n flexDirection,\n flexGrow,\n flexShrink,\n flexWrap,\n justifyContent,\n // flexBasis,\n // layout\n display = 'flex',\n overflow,\n // overflowX,\n // overflowY,\n // position,\n // spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n columnGap,\n rowGap,\n // size\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n // shadow\n dropShadow,\n insetShadow,\n // blur\n blur,\n blurTarget,\n // // nested border radius\n // nestedBorderRadius,\n // nestedBorderRadiusSize = nestedBorderRadius ? borderRadius : undefined,\n // nestedBorderRadiusSpacing = nestedBorderRadius ? spacing : undefined,\n // nestedBorderRadiusWidth = nestedBorderRadius ? borderWidth : undefined,\n // style - extracted to merge with variants\n style,\n ref,\n // rest\n ...props\n}: BoxProps) {\n const { theme, rt } = useUnistyles();\n const {\n BlurView: BlurViewComponent,\n isLoaded: blurIsLoaded,\n isFailed: blurFailed,\n } = useBlurView();\n const elevationAlias = elevation !== undefined ? (`elevation-${elevation}` as const) : undefined;\n\n // Track if blur prop was explicitly set (even to 0) vs derived from elevation\n const blurExplicitlySet = blur !== undefined;\n\n // Get blur intensity from manual blur prop or elevation config\n const blurIntensity = useMemo(() => {\n // Manual blur prop takes precedence (including 0)\n if (blur !== undefined) {\n return blur;\n }\n // Fall back to elevation-based blur\n if (elevation === undefined || !theme.blur) {\n return 0;\n }\n const blurKey = `elevation-${elevation}` as keyof typeof theme.blur;\n return theme.blur[blurKey] ?? 0;\n }, [blur, elevation, theme]);\n\n // Warn in development about blur issues (once per mount)\n const hasWarnedRef = useRef<'none' | 'no-expo-blur' | 'no-blur-target'>('none');\n useEffect(() => {\n if (!__DEV__ || blurIntensity === 0 || !blurIsLoaded) {\n return;\n }\n\n // Warn if expo-blur is not installed\n if (blurFailed && hasWarnedRef.current !== 'no-expo-blur') {\n hasWarnedRef.current = 'no-expo-blur';\n console.warn('[UDS Mobile] Box: Blur effect requested but expo-blur is not installed. ');\n return;\n }\n\n // Warn if blur is used without blurTarget\n if (!blurTarget && hasWarnedRef.current !== 'no-blur-target') {\n hasWarnedRef.current = 'no-blur-target';\n console.warn(\n '[UDS Mobile] Box: Blur effect requires a blurTarget ref. ' +\n 'Wrap the content to blur in <BlurTarget ref={ref}> and pass the ref to blurTarget prop. ' +\n 'See BACKGROUND_BLUR.md for details.',\n );\n }\n }, [blurIntensity, blurTarget, blurIsLoaded, blurFailed]);\n\n const variants = {\n // background\n backgroundColor: backgroundColor ?? elevationAlias,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n // nestedBorderRadius,\n // nestedBorderRadiusSize,\n // nestedBorderRadiusSpacing,\n // nestedBorderRadiusWidth,\n borderColor: borderColor ?? elevationAlias,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth: borderWidth ?? elevationAlias,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // flex\n alignContent,\n alignItems,\n alignSelf,\n flex,\n flexDirection,\n flexGrow,\n flexShrink,\n flexWrap,\n justifyContent,\n // flexBasis,\n // layout\n display,\n overflow,\n // overflowX,\n // overflowY,\n // position,\n // spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n columnGap,\n rowGap,\n // rest\n };\n\n styles.useVariants(variants);\n\n const effectiveDropShadow = dropShadow ?? elevationAlias;\n const shadowStyle =\n effectiveDropShadow || insetShadow\n ? shadowSheet.shadow(effectiveDropShadow, insetShadow)\n : undefined;\n\n // styles.foundation must be in deps - it returns a new reference when variants change\n const boxStyles = useMemo(\n () => [\n dangerouslySetBackgroundColor\n ? { backgroundColor: dangerouslySetBackgroundColor }\n : undefined,\n dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : undefined,\n width ? { width } : undefined,\n height ? { height } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n shadowStyle,\n styles.foundation,\n style,\n ],\n [\n dangerouslySetBackgroundColor,\n dangerouslySetBorderColor,\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n shadowStyle,\n styles.foundation,\n style,\n ],\n );\n\n // Merge variant styles with user-provided style prop\n // User styles come last so they can override variant styles if needed\n\n // If blur is configured (manual or via elevation), render BlurView instead of View\n // Note: On Android, blur requires BlurTarget setup by the developer\n // See BACKGROUND_BLUR.md for Android-specific instructions\n // When blur prop is explicitly set (even to 0), use BlurView so blur=0 is transparent, not solid\n const shouldUseBlurView = BlurViewComponent && (blurIntensity > 0 || blurExplicitlySet);\n if (shouldUseBlurView) {\n const isAndroid = Platform.OS === 'android';\n // Match blur tint to the app's theme (from unistyles runtime)\n const blurTint = rt.themeName === 'dark' ? 'dark' : 'light';\n\n // On iOS, BlurView provides its own frosted background via the tint prop.\n // We must NOT apply an opaque backgroundColor or it will cover the blur effect.\n // On Android, the blur is applied to the blurTarget, so backgroundColor is fine.\n const blurStyles = isAndroid\n ? boxStyles\n : [\n // Exclude backgroundColor for iOS - the blur tint provides the visual background\n dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : undefined,\n width ? { width } : undefined,\n height ? { height } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n shadowStyle,\n // Filter out backgroundColor from foundation styles\n {\n ...styles.foundation,\n backgroundColor: undefined,\n },\n // Also filter backgroundColor from user style if provided (handles both object and array styles)\n style\n ? Array.isArray(style)\n ? style.map((s) =>\n s && typeof s === 'object' ? { ...s, backgroundColor: undefined } : s,\n )\n : typeof style === 'object'\n ? { ...style, backgroundColor: undefined }\n : style\n : undefined,\n ];\n\n // Scale Android intensity to keep tint overlay subtle (Android overlays become\n // too opaque at high intensities). 0.4 scale maps intensity=100 to effective ~40.\n const effectiveIntensity = isAndroid ? Math.min(blurIntensity * 0.4, 40) : blurIntensity;\n\n return (\n <BlurViewComponent\n ref={ref}\n intensity={effectiveIntensity}\n tint={blurTint}\n blurTarget={isAndroid ? blurTarget : undefined}\n blurMethod={isAndroid ? 'dimezisBlurView' : undefined}\n style={blurStyles}\n {...props}\n >\n {props.children}\n </BlurViewComponent>\n );\n }\n\n // Fallback to regular View (blur not available or not requested)\n\n return <View ref={ref} style={boxStyles} {...props} />;\n});\n\nBox.displayName = 'Box';\n\n/**\n * Dynamic shadow stylesheet that merges drop and inset shadows into a single\n * boxShadow CSS string. Theme-reactive so shadows update on color mode change.\n */\nconst shadowSheet = StyleSheet.create((theme) => ({\n shadow: (drop?: string, inset?: string) => {\n const parts = [\n drop ? theme.boxShadow.drop[drop as keyof typeof theme.boxShadow.drop] : '',\n inset ? theme.boxShadow.inset[inset as keyof typeof theme.boxShadow.inset] : '',\n ].filter(Boolean);\n return parts.length > 0 ? { boxShadow: parts.join(', ') } : {};\n },\n}));\n\nexport { Box, type BoxProps };\n"],"mappings":";;;;;;;;AAeA,IAAI,WAAsC;AAC1C,IAAI,gBAAiD;AACrD,MAAM,oBAAoC,EAAE;AAG5C,OAAO,aACJ,MAAM,QAAQ;AACb,YAAW,IAAI;AACf,iBAAgB;AAChB,mBAAkB,SAAS,OAAO,IAAI,CAAC;EACvC,CACD,YAAY;AACX,iBAAgB;AAChB,mBAAkB,SAAS,OAAO,IAAI,CAAC;EACvC;;AAGJ,SAAS,cAAc;CACrB,MAAM,GAAG,eAAe,SAAS,EAAE;AAEnC,iBAAgB;AACd,MAAI,kBAAkB,WAAW;GAC/B,MAAM,iBAAiB,aAAa,MAAM,IAAI,EAAE;AAChD,qBAAkB,KAAK,SAAS;AAChC,gBAAa;IACX,MAAM,MAAM,kBAAkB,QAAQ,SAAS;AAC/C,QAAI,OAAO,EACT,mBAAkB,OAAO,KAAK,EAAE;;;IAIrC,EAAE,CAAC;AAEN,QAAO;EAAE;EAAU,UAAU,kBAAkB;EAAW,UAAU,kBAAkB;EAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGlG,MAAM,MAAM,KAAK,SAAS,IAAI,EAE5B,WAEA,iBACA,+BAEA,cACA,sBACA,oBACA,yBACA,uBACA,aACA,2BACA,kBACA,gBACA,gBACA,mBACA,aACA,qBACA,uBACA,kBACA,gBACA,gBACA,mBAEA,cACA,YACA,WACA,MACA,eACA,UACA,YACA,UACA,gBAGA,UAAU,QACV,UAKA,SACA,mBACA,iBACA,eACA,YACA,cACA,YACA,QACA,gBACA,kBACA,cACA,WACA,aACA,WACA,WACA,QAEA,OACA,QACA,UACA,UACA,WACA,WAEA,YACA,aAEA,MACA,YAOA,OACA,KAEA,GAAG,SACQ;CACX,MAAM,EAAE,OAAO,O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6C,IACzE,QAAQ,MAAM,UAAU,MAAM,SAA+C,GAC9E,CAAC,OAAO,QAAQ;AACjB,QAAO,MAAM,SAAS,IAAI,EAAE,WAAW,MAAM,KAAK,KAAK,EAAE,GAAG,EAAE;GAEjE,EAAE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
import { ButtonSize, ButtonVariantFlat, IconVariant } from "../types/dist/index.
|
|
3
|
-
import { IconSlotType } from "./IconSlot.
|
|
4
|
-
import { PressableProps as PressableProps$1 } from "./Pressable.
|
|
2
|
+
import { ButtonSize, ButtonVariantFlat, IconVariant } from "../types/dist/index.js";
|
|
3
|
+
import { IconSlotType } from "./IconSlot.js";
|
|
4
|
+
import { PressableProps as PressableProps$1 } from "./Pressable.js";
|
|
5
5
|
import * as react from "react";
|
|
6
6
|
import { Ref } from "react";
|
|
7
7
|
import { View } from "react-native";
|
|
@@ -67,4 +67,4 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
67
67
|
declare const Button: react.NamedExoticComponent<ButtonProps>;
|
|
68
68
|
//#endregion
|
|
69
69
|
export { Button, type ButtonProps };
|
|
70
|
-
//# sourceMappingURL=Button.d.
|
|
70
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;UA8GU,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;EAWU;EATV,QAAA;EAd4B;EAgB5B,QAAA,GAAW,KAAA,CAAM,SAAA;EAhBe;;;;EAqBhC,cAAA;EAjBA;EAmBA,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;;;;;;;;;;;;;;;;;AAAI;;;;;;;;;;;;;;;;cAuCV,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.
|
|
3
|
-
import { BUTTON_SPRING_CONFIG } from "../motion.
|
|
4
|
-
import { IconSlot } from "./IconSlot.
|
|
5
|
-
import { Text as Text$1 } from "./Text.
|
|
6
|
-
import { AnimatedPressable } from "./Pressable.
|
|
2
|
+
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.js";
|
|
3
|
+
import { BUTTON_SPRING_CONFIG } from "../motion.js";
|
|
4
|
+
import { IconSlot } from "./IconSlot.js";
|
|
5
|
+
import { Text as Text$1 } from "./Text.js";
|
|
6
|
+
import { AnimatedPressable } from "./Pressable.js";
|
|
7
7
|
import { isValidElement, memo, useCallback, useMemo, useState } from "react";
|
|
8
8
|
import { ActivityIndicator } from "react-native";
|
|
9
9
|
import { buttonStyles } from "../../generated/styles";
|
|
@@ -196,4 +196,4 @@ Button.displayName = "Button";
|
|
|
196
196
|
|
|
197
197
|
//#endregion
|
|
198
198
|
export { Button };
|
|
199
|
-
//# sourceMappingURL=Button.
|
|
199
|
+
//# sourceMappingURL=Button.js.map
|
|
@@ -0,0 +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';\nimport { useAnimatedTheme } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\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';\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 /* --------------------------------- 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 numberOfLines={1} textAlign=\"center\" style={buttonStyles.text}>\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 animatedStyles,\n typeof style === 'function' ? style({ pressed }) : style,\n ],\n [buttonStyles.root, 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":";;;;;;;;;;;;;;;;;;AAgCA,SAAS,uBAAuB,QAA4B,OAAuB;AACjF;AACA,KAAI,CAAC,OACH,QAAO;AAET,KAAI,SAAS,EACX,QAAO;AAET,KAAI,SAAS,EACX,QAAO;AAGT,QAAO,OAAO,QAAQ,sDAAsD,GAAG,GAAG,GAAG,GAAG,MAAM;AAE5F,SAAO,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KADZ,WAAW,EAAE,GAAG,OACS,QAAQ,EAAE,CAAC;GACrD;;;;;;;AAYJ,SAAS,iBAAiB,EACxB,UACA,SACA,UACA,OAMC;CAGD,MAAM,WAAW,sBACT,WAAW,UAAU,IAAI,GAAG,qBAAqB,EACvD,CAAC,QAAQ,CACV;CAED,MAAM,gBAAgB,uBAAuB;EAE3C,MAAM,aAAa,WAAW;AAS9B,SAAO;GACL,OATY,YAAY,SAAS,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,WAAW,CAAC;GAUhE,SALc,YAAY,SAAS,OAAO,CAAC,IAAK,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,QAAQ;GAMpE,WAAW,CAAC,EAAE,OALF,YAAY,SAAS,OAAO,CAAC,IAAK,EAAE,EAAE,CAAC,IAAK,EAAE,EAAE,QAAQ,EAK/C,CAAC;GACtB,UAAU;GACX;GACD;AAEF,QAAO,o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BAAkB,QAAQ,iBACC;AAErD,SAAO;GACL,WAAW,CAAC,EAAE,OAAO,MAAM,OAAO,CAAC;GAEnC,GAAI,iBAAiB,EACnB,WAAW,uBAAuB,eAAe,cAAc,MAAM,EACtE;GACF;GACD;CAGF,MAAM,cAAc,CAAC,CAAC;CACtB,MAAM,gBAAgB,CAAC,CAAC,aAAa,CAAC;CACtC,MAAM,cAAc,CAAC,CAAC,WAAW,CAAC;CAElC,MAAM,gBAAiB,aAAa,KAAK,iBAA8B;CAGvE,MAAM,eACJ,oBAAC;EAAiB,SAAS,eAAe;EAAyB;EAAU,KAAK;YAC/E,cACC,oBAAC;GAAkB,MAAM,aAAa,KAAK;GAAU,OAAO,aAAa,KAAK;IAAS,GAEvF,oBAAC;GACC,MAAM;GACN,MAAM;GACN,SAAS;GACT,OAAO,aAAa;IACpB;GAEa;CAIrB,MAAM,aACJ,oBAAC;EAAiB,SAAS;EAAuB;EAAU,KAAK;YAC/D,oBAAC;GACC,MAAM;GACN,MAAM;GACN,SAAS;GACT,OAAO,aAAa;IACpB;GACe;CAGrB,MAAM,aAAa,cACX;EACJ,aAAa;EACb;EACA,OAAO,UAAU,aAAa,MAAM,EAAE,SAAS,CAAC,GAAG;EACpD,EACD;EAAC,aAAa;EAAM;EAAgB;EAAO;EAAQ,CACpD;AAGD,QACE,qBAAC;EACM;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;;GAEH;GACA;GACA;;GACiB;EAEtB;AAEF,OAAO,cAAc"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { UniversalCheckboxProps } from "../types/dist/index.
|
|
2
|
+
import { UniversalCheckboxProps } from "../types/dist/index.js";
|
|
3
3
|
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
@@ -54,4 +54,4 @@ interface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps
|
|
|
54
54
|
declare const Checkbox: react.NamedExoticComponent<CheckboxProps>;
|
|
55
55
|
//#endregion
|
|
56
56
|
export { Checkbox, type CheckboxProps };
|
|
57
|
-
//# sourceMappingURL=Checkbox.d.
|
|
57
|
+
//# sourceMappingURL=Checkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAyBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;EAU9B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,KAAA,CAAA,oBAAA,CAAA,aAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.
|
|
3
|
-
import { BUTTON_SPRING_CONFIG } from "../motion.
|
|
4
|
-
import { Icon } from "./Icon.
|
|
5
|
-
import { Text } from "./Text.
|
|
6
|
-
import { HStack } from "./HStack.
|
|
7
|
-
import { Pressable } from "./Pressable.
|
|
2
|
+
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.js";
|
|
3
|
+
import { BUTTON_SPRING_CONFIG } from "../motion.js";
|
|
4
|
+
import { Icon } from "./Icon.js";
|
|
5
|
+
import { Text } from "./Text.js";
|
|
6
|
+
import { HStack } from "./HStack.js";
|
|
7
|
+
import { Pressable } from "./Pressable.js";
|
|
8
8
|
import { isValidElement, memo, useCallback, useId, useMemo, useState } from "react";
|
|
9
9
|
import { checkboxStyles } from "../../generated/styles";
|
|
10
10
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -161,4 +161,4 @@ Checkbox.displayName = "Checkbox";
|
|
|
161
161
|
|
|
162
162
|
//#endregion
|
|
163
163
|
export { Checkbox };
|
|
164
|
-
//# sourceMappingURL=Checkbox.
|
|
164
|
+
//# sourceMappingURL=Checkbox.js.map
|