@yahoo/uds-mobile 1.3.0-beta.8 → 1.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/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +2 -2
- package/dist/bin/fixtures/dist/index.mjs +25 -1
- package/dist/bin/generateTheme.mjs +5 -5
- package/dist/bin/uds-mobile.mjs +10 -10
- package/dist/components/Avatar.cjs +13 -4
- package/dist/components/Avatar.d.cts +11 -3
- package/dist/components/Avatar.d.cts.map +1 -1
- package/dist/components/Avatar.d.mts +11 -3
- package/dist/components/Avatar.d.mts.map +1 -1
- package/dist/components/Avatar.mjs +11 -3
- package/dist/components/Avatar.mjs.map +1 -1
- package/dist/components/Badge.cjs +15 -4
- package/dist/components/Badge.d.cts +24 -6
- package/dist/components/Badge.d.cts.map +1 -1
- package/dist/components/Badge.d.mts +24 -6
- package/dist/components/Badge.d.mts.map +1 -1
- package/dist/components/Badge.mjs +13 -3
- package/dist/components/Badge.mjs.map +1 -1
- package/dist/components/Box.cjs +15 -11
- package/dist/components/Box.d.cts +15 -10
- package/dist/components/Box.d.cts.map +1 -1
- package/dist/components/Box.d.mts +15 -10
- package/dist/components/Box.d.mts.map +1 -1
- package/dist/components/Box.mjs +13 -10
- package/dist/components/Box.mjs.map +1 -1
- package/dist/components/Button.cjs +15 -5
- package/dist/components/Button.d.cts +21 -6
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.mts +21 -6
- package/dist/components/Button.d.mts.map +1 -1
- package/dist/components/Button.mjs +12 -3
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/Checkbox.cjs +16 -7
- package/dist/components/Checkbox.d.cts +14 -5
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.mts +14 -5
- package/dist/components/Checkbox.d.mts.map +1 -1
- package/dist/components/Checkbox.mjs +13 -5
- package/dist/components/Checkbox.mjs.map +1 -1
- package/dist/components/Chip.cjs +21 -4
- package/dist/components/Chip.d.cts +28 -6
- package/dist/components/Chip.d.cts.map +1 -1
- package/dist/components/Chip.d.mts +28 -6
- package/dist/components/Chip.d.mts.map +1 -1
- package/dist/components/Chip.mjs +19 -3
- package/dist/components/Chip.mjs.map +1 -1
- package/dist/components/HStack.cjs +9 -6
- package/dist/components/HStack.d.cts +9 -5
- package/dist/components/HStack.d.cts.map +1 -1
- package/dist/components/HStack.d.mts +9 -5
- package/dist/components/HStack.d.mts.map +1 -1
- package/dist/components/HStack.mjs +7 -5
- package/dist/components/HStack.mjs.map +1 -1
- package/dist/components/Icon.cjs +17 -6
- package/dist/components/Icon.d.cts +14 -3
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.mts +14 -3
- package/dist/components/Icon.d.mts.map +1 -1
- package/dist/components/Icon.mjs +15 -5
- package/dist/components/Icon.mjs.map +1 -1
- package/dist/components/IconButton.cjs +24 -5
- package/dist/components/IconButton.d.cts +28 -8
- package/dist/components/IconButton.d.cts.map +1 -1
- package/dist/components/IconButton.d.mts +28 -8
- package/dist/components/IconButton.d.mts.map +1 -1
- package/dist/components/IconButton.mjs +22 -4
- package/dist/components/IconButton.mjs.map +1 -1
- package/dist/components/IconSlot.cjs +9 -3
- package/dist/components/IconSlot.d.cts +7 -2
- package/dist/components/IconSlot.d.cts.map +1 -1
- package/dist/components/IconSlot.d.mts +7 -2
- package/dist/components/IconSlot.d.mts.map +1 -1
- package/dist/components/IconSlot.mjs +7 -2
- package/dist/components/IconSlot.mjs.map +1 -1
- package/dist/components/Image.cjs +19 -4
- package/dist/components/Image.d.cts +18 -3
- package/dist/components/Image.d.cts.map +1 -1
- package/dist/components/Image.d.mts +18 -3
- package/dist/components/Image.d.mts.map +1 -1
- package/dist/components/Image.mjs +17 -3
- package/dist/components/Image.mjs.map +1 -1
- package/dist/components/Input.cjs +20 -7
- package/dist/components/Input.d.cts +19 -6
- package/dist/components/Input.d.cts.map +1 -1
- package/dist/components/Input.d.mts +19 -6
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +18 -6
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Link.cjs +20 -5
- package/dist/components/Link.d.cts +21 -4
- package/dist/components/Link.d.cts.map +1 -1
- package/dist/components/Link.d.mts +21 -4
- package/dist/components/Link.d.mts.map +1 -1
- package/dist/components/Link.mjs +17 -3
- package/dist/components/Link.mjs.map +1 -1
- package/dist/components/Pressable.cjs +18 -6
- package/dist/components/Pressable.d.cts +18 -5
- package/dist/components/Pressable.d.cts.map +1 -1
- package/dist/components/Pressable.d.mts +18 -5
- package/dist/components/Pressable.d.mts.map +1 -1
- package/dist/components/Pressable.mjs +15 -4
- package/dist/components/Pressable.mjs.map +1 -1
- package/dist/components/Radio.cjs +16 -7
- package/dist/components/Radio.d.cts +14 -5
- package/dist/components/Radio.d.cts.map +1 -1
- package/dist/components/Radio.d.mts +14 -5
- package/dist/components/Radio.d.mts.map +1 -1
- package/dist/components/Radio.mjs +13 -5
- package/dist/components/Radio.mjs.map +1 -1
- package/dist/components/Screen.cjs +10 -4
- package/dist/components/Screen.d.cts +15 -3
- package/dist/components/Screen.d.cts.map +1 -1
- package/dist/components/Screen.d.mts +15 -3
- package/dist/components/Screen.d.mts.map +1 -1
- package/dist/components/Screen.mjs +8 -3
- package/dist/components/Screen.mjs.map +1 -1
- package/dist/components/Switch.cjs +21 -5
- package/dist/components/Switch.d.cts +18 -3
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.mts +18 -3
- package/dist/components/Switch.d.mts.map +1 -1
- package/dist/components/Switch.mjs +18 -3
- package/dist/components/Switch.mjs.map +1 -1
- package/dist/components/Text.cjs +17 -7
- package/dist/components/Text.d.cts +18 -6
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.mts +18 -6
- package/dist/components/Text.d.mts.map +1 -1
- package/dist/components/Text.mjs +15 -6
- package/dist/components/Text.mjs.map +1 -1
- package/dist/components/VStack.cjs +9 -6
- package/dist/components/VStack.d.cts +9 -5
- package/dist/components/VStack.d.cts.map +1 -1
- package/dist/components/VStack.d.mts +9 -5
- package/dist/components/VStack.d.mts.map +1 -1
- package/dist/components/VStack.mjs +7 -5
- package/dist/components/VStack.mjs.map +1 -1
- package/dist/icons/dist/glyphMap.cjs +2 -2
- package/dist/icons/dist/glyphMap.d.cts +0 -2
- package/dist/icons/dist/glyphMap.d.cts.map +1 -1
- package/dist/icons/dist/glyphMap.d.mts +0 -2
- package/dist/icons/dist/glyphMap.d.mts.map +1 -1
- package/dist/icons/dist/glyphMap.mjs +2 -2
- package/dist/icons/dist/glyphMap.mjs.map +1 -1
- package/dist/icons/dist/svgMap.cjs +2 -2
- package/dist/icons/dist/svgMap.d.cts +0 -2
- package/dist/icons/dist/svgMap.d.cts.map +1 -1
- package/dist/icons/dist/svgMap.d.mts +0 -2
- package/dist/icons/dist/svgMap.d.mts.map +1 -1
- package/dist/icons/dist/svgMap.mjs +2 -2
- package/dist/icons/dist/svgMap.mjs.map +1 -1
- package/dist/icons/dist/tokens.cjs +2 -2
- package/dist/icons/dist/tokens.mjs +2 -2
- package/dist/icons/dist/tokens.mjs.map +1 -1
- package/dist/motion-tokens/dist/index.cjs +1 -1
- package/dist/motion-tokens/dist/index.d.cts +1 -3
- package/dist/motion-tokens/dist/index.d.cts.map +1 -1
- package/dist/motion-tokens/dist/index.d.mts +1 -3
- package/dist/motion-tokens/dist/index.d.mts.map +1 -1
- package/dist/motion-tokens/dist/index.mjs +1 -1
- package/dist/motion.cjs +2 -1
- package/dist/motion.d.cts +0 -1
- package/dist/motion.d.cts.map +1 -1
- package/dist/motion.d.mts +0 -1
- package/dist/motion.d.mts.map +1 -1
- package/dist/motion.mjs +1 -1
- package/dist/types/dist/index.d.cts +1 -3
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.mts +1 -3
- package/dist/types/dist/index.d.mts.map +1 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +0 -3
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +0 -3
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +1 -1
- package/fonts/index.cjs +205 -205
- package/fonts/index.mjs +205 -205
- package/generated/styles.cjs +119 -23
- package/generated/styles.d.ts +48 -1
- package/generated/styles.mjs +119 -23
- package/generated/unistyles.d.ts +97 -18
- package/package.json +1 -41
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { SizeProps } from "../types.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
7
7
|
|
|
8
8
|
//#region src/components/Box.d.ts
|
|
9
9
|
interface BoxProps extends ViewProps, SizeProps {
|
|
10
|
+
/** Ref to the underlying View */
|
|
10
11
|
ref?: Ref<View>;
|
|
12
|
+
/** Background color from the theme palette */
|
|
11
13
|
backgroundColor?: StyleProps['backgroundColor'];
|
|
12
14
|
borderRadius?: StyleProps['borderRadius'];
|
|
13
15
|
borderTopStartRadius?: StyleProps['borderTopStartRadius'];
|
|
@@ -60,13 +62,16 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
60
62
|
* **📦 A layout component that can be used to compose other components**
|
|
61
63
|
*
|
|
62
64
|
* @description
|
|
63
|
-
* The most simple component we ship - a
|
|
65
|
+
* The most simple component we ship - a View. But with all the power of the UDS design system.
|
|
64
66
|
* By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,
|
|
65
|
-
* consider using
|
|
67
|
+
* consider using VStack or HStack respectively.
|
|
68
|
+
*
|
|
69
|
+
* @category Layout
|
|
70
|
+
* @platform mobile
|
|
66
71
|
*
|
|
67
72
|
* @example
|
|
68
73
|
* ```tsx
|
|
69
|
-
* import { Box } from '@yahoo/uds-mobile
|
|
74
|
+
* import { Box } from '@yahoo/uds-mobile';
|
|
70
75
|
*
|
|
71
76
|
* <Box backgroundColor="primary" spacing="6">
|
|
72
77
|
* Any kind of content can go here!
|
|
@@ -74,14 +79,14 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
74
79
|
* ```
|
|
75
80
|
*
|
|
76
81
|
* @usage
|
|
77
|
-
* -
|
|
78
|
-
* -
|
|
79
|
-
*
|
|
80
|
-
* @see The {@link https://uds.build/docs/components/box Box Docs} for more info
|
|
82
|
+
* - Use as a container to apply padding, shapes, or other styling
|
|
83
|
+
* - Use for creating card components
|
|
84
|
+
* - Use HStack/VStack for directional layouts
|
|
81
85
|
*
|
|
82
|
-
* @
|
|
86
|
+
* @see {@link HStack} for horizontal layouts
|
|
87
|
+
* @see {@link VStack} for vertical layouts
|
|
83
88
|
*/
|
|
84
|
-
declare const Box:
|
|
89
|
+
declare const Box: react.NamedExoticComponent<BoxProps>;
|
|
85
90
|
//#endregion
|
|
86
91
|
export { Box, type BoxProps };
|
|
87
92
|
//# sourceMappingURL=Box.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.cts","names":[],"sources":["../../src/components/Box.tsx"],"
|
|
1
|
+
{"version":3,"file":"Box.d.cts","names":[],"sources":["../../src/components/Box.tsx"],"mappings":";;;;;;;;UASU,QAAA,SAAiB,SAAA,EAAW,SAAA;;EAEpC,GAAA,GAAM,GAAA,CAAI,IAAA;EAFO;EAIjB,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,6BAAA;EACA,yBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BI,GAAA,EAAG,KAAA,CAAA,oBAAA,CAAA,QAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { SizeProps } from "../types.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
7
7
|
|
|
8
8
|
//#region src/components/Box.d.ts
|
|
9
9
|
interface BoxProps extends ViewProps, SizeProps {
|
|
10
|
+
/** Ref to the underlying View */
|
|
10
11
|
ref?: Ref<View>;
|
|
12
|
+
/** Background color from the theme palette */
|
|
11
13
|
backgroundColor?: StyleProps['backgroundColor'];
|
|
12
14
|
borderRadius?: StyleProps['borderRadius'];
|
|
13
15
|
borderTopStartRadius?: StyleProps['borderTopStartRadius'];
|
|
@@ -60,13 +62,16 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
60
62
|
* **📦 A layout component that can be used to compose other components**
|
|
61
63
|
*
|
|
62
64
|
* @description
|
|
63
|
-
* The most simple component we ship - a
|
|
65
|
+
* The most simple component we ship - a View. But with all the power of the UDS design system.
|
|
64
66
|
* By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,
|
|
65
|
-
* consider using
|
|
67
|
+
* consider using VStack or HStack respectively.
|
|
68
|
+
*
|
|
69
|
+
* @category Layout
|
|
70
|
+
* @platform mobile
|
|
66
71
|
*
|
|
67
72
|
* @example
|
|
68
73
|
* ```tsx
|
|
69
|
-
* import { Box } from '@yahoo/uds-mobile
|
|
74
|
+
* import { Box } from '@yahoo/uds-mobile';
|
|
70
75
|
*
|
|
71
76
|
* <Box backgroundColor="primary" spacing="6">
|
|
72
77
|
* Any kind of content can go here!
|
|
@@ -74,14 +79,14 @@ interface BoxProps extends ViewProps, SizeProps {
|
|
|
74
79
|
* ```
|
|
75
80
|
*
|
|
76
81
|
* @usage
|
|
77
|
-
* -
|
|
78
|
-
* -
|
|
79
|
-
*
|
|
80
|
-
* @see The {@link https://uds.build/docs/components/box Box Docs} for more info
|
|
82
|
+
* - Use as a container to apply padding, shapes, or other styling
|
|
83
|
+
* - Use for creating card components
|
|
84
|
+
* - Use HStack/VStack for directional layouts
|
|
81
85
|
*
|
|
82
|
-
* @
|
|
86
|
+
* @see {@link HStack} for horizontal layouts
|
|
87
|
+
* @see {@link VStack} for vertical layouts
|
|
83
88
|
*/
|
|
84
|
-
declare const Box:
|
|
89
|
+
declare const Box: react.NamedExoticComponent<BoxProps>;
|
|
85
90
|
//#endregion
|
|
86
91
|
export { Box, type BoxProps };
|
|
87
92
|
//# sourceMappingURL=Box.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.d.mts","names":[],"sources":["../../src/components/Box.tsx"],"
|
|
1
|
+
{"version":3,"file":"Box.d.mts","names":[],"sources":["../../src/components/Box.tsx"],"mappings":";;;;;;;;UASU,QAAA,SAAiB,SAAA,EAAW,SAAA;;EAEpC,GAAA,GAAM,GAAA,CAAI,IAAA;EAFO;EAIjB,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,6BAAA;EACA,yBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BI,GAAA,EAAG,KAAA,CAAA,oBAAA,CAAA,QAAA"}
|
package/dist/components/Box.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { memo, useMemo } from "react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { styles } from "../../generated/styles";
|
|
@@ -9,13 +9,16 @@ import { jsx } from "react/jsx-runtime";
|
|
|
9
9
|
* **📦 A layout component that can be used to compose other components**
|
|
10
10
|
*
|
|
11
11
|
* @description
|
|
12
|
-
* The most simple component we ship - a
|
|
12
|
+
* The most simple component we ship - a View. But with all the power of the UDS design system.
|
|
13
13
|
* By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,
|
|
14
|
-
* consider using
|
|
14
|
+
* consider using VStack or HStack respectively.
|
|
15
|
+
*
|
|
16
|
+
* @category Layout
|
|
17
|
+
* @platform mobile
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```tsx
|
|
18
|
-
* import { Box } from '@yahoo/uds-mobile
|
|
21
|
+
* import { Box } from '@yahoo/uds-mobile';
|
|
19
22
|
*
|
|
20
23
|
* <Box backgroundColor="primary" spacing="6">
|
|
21
24
|
* Any kind of content can go here!
|
|
@@ -23,14 +26,14 @@ import { jsx } from "react/jsx-runtime";
|
|
|
23
26
|
* ```
|
|
24
27
|
*
|
|
25
28
|
* @usage
|
|
26
|
-
* -
|
|
27
|
-
* -
|
|
28
|
-
*
|
|
29
|
-
* @see The {@link https://uds.build/docs/components/box Box Docs} for more info
|
|
29
|
+
* - Use as a container to apply padding, shapes, or other styling
|
|
30
|
+
* - Use for creating card components
|
|
31
|
+
* - Use HStack/VStack for directional layouts
|
|
30
32
|
*
|
|
31
|
-
* @
|
|
33
|
+
* @see {@link HStack} for horizontal layouts
|
|
34
|
+
* @see {@link VStack} for vertical layouts
|
|
32
35
|
*/
|
|
33
|
-
const Box = memo(function Box
|
|
36
|
+
const Box = memo(function Box({ 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, style, ref, ...props }) {
|
|
34
37
|
const variants = {
|
|
35
38
|
backgroundColor,
|
|
36
39
|
borderRadius,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Box.mjs","names":[
|
|
1
|
+
{"version":3,"file":"Box.mjs","names":[],"sources":["../../src/components/Box.tsx"],"sourcesContent":["import type { Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { View } from 'react-native';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport type { SizeProps } from '../types';\n\ninterface BoxProps extends ViewProps, SizeProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Background color from the theme palette */\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 dangerouslySetBackgroundColor?: string;\n dangerouslySetBorderColor?: string;\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 // 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 // // 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 variants = {\n // background\n backgroundColor,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n // nestedBorderRadius,\n // nestedBorderRadiusSize,\n // nestedBorderRadiusSpacing,\n // nestedBorderRadiusWidth,\n borderColor,\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,\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 // 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 styles.foundation,\n style,\n ],\n [\n dangerouslySetBackgroundColor,\n dangerouslySetBorderColor,\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\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 return <View ref={ref} style={boxStyles} {...props} />;\n});\n\nBox.displayName = 'Box';\n\nexport { Box, type BoxProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,MAAM,MAAM,KAAK,SAAS,IAAI,EAE5B,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,WAUA,OACA,KAEA,GAAG,SACQ;CACX,MAAM,WAAW;EAEf;EAEA;EACA;EACA;EACA;EACA;EAKA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAGA;EACA;EAKA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAED;AAED,QAAO,YAAY,SAAS;AAkC5B,QAAO,oBAAC;EAAU;EAAK,OA/BL,cACV;GACJ,gCACI,EAAE,iBAAiB,+BAA+B,GAClD;GACJ,4BAA4B,EAAE,aAAa,2BAA2B,GAAG;GACzE,QAAQ,EAAE,OAAO,GAAG;GACpB,SAAS,EAAE,QAAQ,GAAG;GACtB,WAAW,EAAE,UAAU,GAAG;GAC1B,WAAW,EAAE,UAAU,GAAG;GAC1B,YAAY,EAAE,WAAW,GAAG;GAC5B,YAAY,EAAE,WAAW,GAAG;GAC5B,OAAO;GACP;GACD,EACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;GACP;GACD,CACF;EAIwC,GAAI;GAAS;EACtD;AAEF,IAAI,cAAc"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile
|
|
2
|
-
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
const require_index = require('../motion-tokens/dist/index.cjs');
|
|
4
5
|
const require_motion = require('../motion.cjs');
|
|
5
6
|
const require_components_IconSlot = require('./IconSlot.cjs');
|
|
@@ -10,7 +11,7 @@ let react_native = require("react-native");
|
|
|
10
11
|
let generated_styles = require("../../generated/styles");
|
|
11
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
13
|
let react_native_reanimated = require("react-native-reanimated");
|
|
13
|
-
react_native_reanimated =
|
|
14
|
+
react_native_reanimated = require_runtime.__toESM(react_native_reanimated);
|
|
14
15
|
let react_native_unistyles_reanimated = require("react-native-unistyles/reanimated");
|
|
15
16
|
|
|
16
17
|
//#region src/components/Button.tsx
|
|
@@ -58,6 +59,9 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
58
59
|
* Features animated scale effect on press and smooth icon transitions matching
|
|
59
60
|
* the web UDS Button behavior.
|
|
60
61
|
*
|
|
62
|
+
* @category Interactive
|
|
63
|
+
* @platform mobile
|
|
64
|
+
*
|
|
61
65
|
* @example
|
|
62
66
|
* ```tsx
|
|
63
67
|
* import { Button } from '@yahoo/uds-mobile';
|
|
@@ -68,9 +72,15 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
68
72
|
* <Button loading>Saving...</Button>
|
|
69
73
|
* ```
|
|
70
74
|
*
|
|
71
|
-
* @
|
|
75
|
+
* @accessibility
|
|
76
|
+
* - Sets `accessibilityRole="button"` automatically
|
|
77
|
+
* - Announces loading state to screen readers
|
|
78
|
+
* - Use `accessibilityLabel` for icon-only buttons
|
|
79
|
+
*
|
|
80
|
+
* @see {@link IconButton} for icon-only buttons
|
|
81
|
+
* @see {@link Link} for navigation actions
|
|
72
82
|
*/
|
|
73
|
-
const Button = (0, react.memo)(function Button
|
|
83
|
+
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 }) {
|
|
74
84
|
const shouldAnimate = !disableEffects;
|
|
75
85
|
const [pressed, setPressed] = (0, react.useState)(false);
|
|
76
86
|
generated_styles.buttonStyles.useVariants({
|
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
import { ButtonSize, ButtonVariantFlat, IconVariant } from "../types/dist/index.cjs";
|
|
3
3
|
import { IconSlotType } from "./IconSlot.cjs";
|
|
4
4
|
import { PressableProps as PressableProps$1 } from "./Pressable.cjs";
|
|
5
|
-
import * as
|
|
5
|
+
import * as react from "react";
|
|
6
6
|
import { Ref } from "react";
|
|
7
7
|
import { View } from "react-native";
|
|
8
8
|
|
|
9
9
|
//#region src/components/Button.d.ts
|
|
10
10
|
interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
11
|
-
/** @default 'primary' */
|
|
11
|
+
/** The visual style variant of the button @default 'primary' */
|
|
12
12
|
variant?: ButtonVariantFlat;
|
|
13
|
-
/** @default 'md' */
|
|
13
|
+
/** The size of the button @default 'md' */
|
|
14
14
|
size?: ButtonSize;
|
|
15
|
-
/** @default 'outline' */
|
|
15
|
+
/** The icon style variant @default 'outline' */
|
|
16
16
|
iconVariant?: IconVariant;
|
|
17
|
+
/** Icon displayed before the button label */
|
|
17
18
|
startIcon?: IconSlotType;
|
|
19
|
+
/** Icon displayed after the button label */
|
|
18
20
|
endIcon?: IconSlotType;
|
|
21
|
+
/** Shows a loading spinner and disables the button */
|
|
19
22
|
loading?: boolean;
|
|
23
|
+
/** Whether the button is disabled */
|
|
20
24
|
disabled?: boolean;
|
|
25
|
+
/** Button label content */
|
|
21
26
|
children?: React.ReactNode;
|
|
22
27
|
/**
|
|
23
28
|
* Disable motion effects (scale on press, icon animations)
|
|
24
29
|
* @default false
|
|
25
30
|
*/
|
|
26
31
|
disableEffects?: boolean;
|
|
32
|
+
/** Ref to the underlying View */
|
|
27
33
|
ref?: Ref<View>;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
@@ -37,6 +43,9 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
37
43
|
* Features animated scale effect on press and smooth icon transitions matching
|
|
38
44
|
* the web UDS Button behavior.
|
|
39
45
|
*
|
|
46
|
+
* @category Interactive
|
|
47
|
+
* @platform mobile
|
|
48
|
+
*
|
|
40
49
|
* @example
|
|
41
50
|
* ```tsx
|
|
42
51
|
* import { Button } from '@yahoo/uds-mobile';
|
|
@@ -47,9 +56,15 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
47
56
|
* <Button loading>Saving...</Button>
|
|
48
57
|
* ```
|
|
49
58
|
*
|
|
50
|
-
* @
|
|
59
|
+
* @accessibility
|
|
60
|
+
* - Sets `accessibilityRole="button"` automatically
|
|
61
|
+
* - Announces loading state to screen readers
|
|
62
|
+
* - Use `accessibilityLabel` for icon-only buttons
|
|
63
|
+
*
|
|
64
|
+
* @see {@link IconButton} for icon-only buttons
|
|
65
|
+
* @see {@link Link} for navigation actions
|
|
51
66
|
*/
|
|
52
|
-
declare const Button:
|
|
67
|
+
declare const Button: react.NamedExoticComponent<ButtonProps>;
|
|
53
68
|
//#endregion
|
|
54
69
|
export { Button, type ButtonProps };
|
|
55
70
|
//# sourceMappingURL=Button.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.cts","names":[],"sources":["../../src/components/Button.tsx"],"
|
|
1
|
+
{"version":3,"file":"Button.d.cts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;UA2GU,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"}
|
|
@@ -2,28 +2,34 @@
|
|
|
2
2
|
import { ButtonSize, ButtonVariantFlat, IconVariant } from "../types/dist/index.mjs";
|
|
3
3
|
import { IconSlotType } from "./IconSlot.mjs";
|
|
4
4
|
import { PressableProps as PressableProps$1 } from "./Pressable.mjs";
|
|
5
|
-
import * as
|
|
5
|
+
import * as react from "react";
|
|
6
6
|
import { Ref } from "react";
|
|
7
7
|
import { View } from "react-native";
|
|
8
8
|
|
|
9
9
|
//#region src/components/Button.d.ts
|
|
10
10
|
interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
11
|
-
/** @default 'primary' */
|
|
11
|
+
/** The visual style variant of the button @default 'primary' */
|
|
12
12
|
variant?: ButtonVariantFlat;
|
|
13
|
-
/** @default 'md' */
|
|
13
|
+
/** The size of the button @default 'md' */
|
|
14
14
|
size?: ButtonSize;
|
|
15
|
-
/** @default 'outline' */
|
|
15
|
+
/** The icon style variant @default 'outline' */
|
|
16
16
|
iconVariant?: IconVariant;
|
|
17
|
+
/** Icon displayed before the button label */
|
|
17
18
|
startIcon?: IconSlotType;
|
|
19
|
+
/** Icon displayed after the button label */
|
|
18
20
|
endIcon?: IconSlotType;
|
|
21
|
+
/** Shows a loading spinner and disables the button */
|
|
19
22
|
loading?: boolean;
|
|
23
|
+
/** Whether the button is disabled */
|
|
20
24
|
disabled?: boolean;
|
|
25
|
+
/** Button label content */
|
|
21
26
|
children?: React.ReactNode;
|
|
22
27
|
/**
|
|
23
28
|
* Disable motion effects (scale on press, icon animations)
|
|
24
29
|
* @default false
|
|
25
30
|
*/
|
|
26
31
|
disableEffects?: boolean;
|
|
32
|
+
/** Ref to the underlying View */
|
|
27
33
|
ref?: Ref<View>;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
@@ -37,6 +43,9 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
37
43
|
* Features animated scale effect on press and smooth icon transitions matching
|
|
38
44
|
* the web UDS Button behavior.
|
|
39
45
|
*
|
|
46
|
+
* @category Interactive
|
|
47
|
+
* @platform mobile
|
|
48
|
+
*
|
|
40
49
|
* @example
|
|
41
50
|
* ```tsx
|
|
42
51
|
* import { Button } from '@yahoo/uds-mobile';
|
|
@@ -47,9 +56,15 @@ interface ButtonProps extends Omit<PressableProps$1, 'children' | 'disabled'> {
|
|
|
47
56
|
* <Button loading>Saving...</Button>
|
|
48
57
|
* ```
|
|
49
58
|
*
|
|
50
|
-
* @
|
|
59
|
+
* @accessibility
|
|
60
|
+
* - Sets `accessibilityRole="button"` automatically
|
|
61
|
+
* - Announces loading state to screen readers
|
|
62
|
+
* - Use `accessibilityLabel` for icon-only buttons
|
|
63
|
+
*
|
|
64
|
+
* @see {@link IconButton} for icon-only buttons
|
|
65
|
+
* @see {@link Link} for navigation actions
|
|
51
66
|
*/
|
|
52
|
-
declare const Button:
|
|
67
|
+
declare const Button: react.NamedExoticComponent<ButtonProps>;
|
|
53
68
|
//#endregion
|
|
54
69
|
export { Button, type ButtonProps };
|
|
55
70
|
//# sourceMappingURL=Button.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.mts","names":[],"sources":["../../src/components/Button.tsx"],"
|
|
1
|
+
{"version":3,"file":"Button.d.mts","names":[],"sources":["../../src/components/Button.tsx"],"mappings":";;;;;;;;;UA2GU,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,4 +1,4 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.mjs";
|
|
3
3
|
import { BUTTON_SPRING_CONFIG } from "../motion.mjs";
|
|
4
4
|
import { IconSlot } from "./IconSlot.mjs";
|
|
@@ -56,6 +56,9 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
56
56
|
* Features animated scale effect on press and smooth icon transitions matching
|
|
57
57
|
* the web UDS Button behavior.
|
|
58
58
|
*
|
|
59
|
+
* @category Interactive
|
|
60
|
+
* @platform mobile
|
|
61
|
+
*
|
|
59
62
|
* @example
|
|
60
63
|
* ```tsx
|
|
61
64
|
* import { Button } from '@yahoo/uds-mobile';
|
|
@@ -66,9 +69,15 @@ function AnimatedIconSlot({ children, visible, iconSize, gap }) {
|
|
|
66
69
|
* <Button loading>Saving...</Button>
|
|
67
70
|
* ```
|
|
68
71
|
*
|
|
69
|
-
* @
|
|
72
|
+
* @accessibility
|
|
73
|
+
* - Sets `accessibilityRole="button"` automatically
|
|
74
|
+
* - Announces loading state to screen readers
|
|
75
|
+
* - Use `accessibilityLabel` for icon-only buttons
|
|
76
|
+
*
|
|
77
|
+
* @see {@link IconButton} for icon-only buttons
|
|
78
|
+
* @see {@link Link} for navigation actions
|
|
70
79
|
*/
|
|
71
|
-
const Button = memo(function Button
|
|
80
|
+
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 }) {
|
|
72
81
|
const shouldAnimate = !disableEffects;
|
|
73
82
|
const [pressed, setPressed] = useState(false);
|
|
74
83
|
buttonStyles.useVariants({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.mjs","names":["Button","Text"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonSize, ButtonVariantFlat, 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, alpha: number): string {\n 'worklet';\n if (!shadow || 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 /** @default 'primary' */\n variant?: ButtonVariantFlat;\n /** @default 'md' */\n size?: ButtonSize;\n /** @default 'outline' */\n iconVariant?: IconVariant;\n startIcon?: IconSlotType;\n endIcon?: IconSlotType;\n loading?: boolean;\n disabled?: boolean;\n children?: React.ReactNode;\n /**\n * Disable motion effects (scale on press, icon animations)\n * @default false\n */\n disableEffects?: boolean;\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 * @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 * @see The {@link https://uds.build/docs/components/button Button Docs} for more info\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 // backgroundColor: withTiming(backgroundColor.value, {\n // duration: 220,\n // easing: Easing.bezier(0, 0, 0.2, 1),\n // }),\n // borderColor: withTiming(borderColor.value, {\n // duration: 220,\n // easing: Easing.bezier(0, 0, 0.2, 1),\n // }),\n // Animate shadow by interpolating its color alpha\n boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\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 // 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 icon={startIcon} variant={iconVariant} style={buttonStyles.icon} />\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 icon={endIcon} variant={iconVariant} style={buttonStyles.icon} />\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,QAAgB,OAAuB;AACrE;AACA,KAAI,CAAC,UAAU,SAAS,EACtB,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,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AW;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
|
+
{"version":3,"file":"Button.mjs","names":["Text"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonSize, ButtonVariantFlat, 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, alpha: number): string {\n 'worklet';\n if (!shadow || 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 // backgroundColor: withTiming(backgroundColor.value, {\n // duration: 220,\n // easing: Easing.bezier(0, 0, 0.2, 1),\n // }),\n // borderColor: withTiming(borderColor.value, {\n // duration: 220,\n // easing: Easing.bezier(0, 0, 0.2, 1),\n // }),\n // Animate shadow by interpolating its color alpha\n boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\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 // 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 icon={startIcon} variant={iconVariant} style={buttonStyles.icon} />\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 icon={endIcon} variant={iconVariant} style={buttonStyles.icon} />\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,QAAgB,OAAuB;AACrE;AACA,KAAI,CAAC,UAAU,SAAS,EACtB,QAAO;AAET,KAAI,SAAS,EACX,QAAO;AAGT,QAAO,OAAO,QAAQ,sDAAsD,GAAG,GAAG,GAAG,GAAG,MAAM;AAE5F,SAAO,QAAQ,EAAE,IAAI,EAAE,IA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AAM,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,6 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile
|
|
2
|
-
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
const require_index = require('../motion-tokens/dist/index.cjs');
|
|
4
5
|
const require_motion = require('../motion.cjs');
|
|
5
6
|
const require_components_Icon = require('./Icon.cjs');
|
|
@@ -10,7 +11,7 @@ let react = require("react");
|
|
|
10
11
|
let generated_styles = require("../../generated/styles");
|
|
11
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
13
|
let react_native_reanimated = require("react-native-reanimated");
|
|
13
|
-
react_native_reanimated =
|
|
14
|
+
react_native_reanimated = require_runtime.__toESM(react_native_reanimated);
|
|
14
15
|
|
|
15
16
|
//#region src/components/Checkbox.tsx
|
|
16
17
|
const VARIANT_ERROR_MAP = {
|
|
@@ -20,13 +21,14 @@ const VARIANT_ERROR_MAP = {
|
|
|
20
21
|
/**
|
|
21
22
|
* **⚙️ A checkbox component**
|
|
22
23
|
*
|
|
23
|
-
* @componentType Client component
|
|
24
|
-
*
|
|
25
24
|
* @description
|
|
26
25
|
* A checkbox component allows users to select one or multiple options from a set.
|
|
27
26
|
* It represents a binary state, typically as checked or unchecked, and optionally
|
|
28
27
|
* includes a third "indeterminate" state to indicate partial selection.
|
|
29
28
|
*
|
|
29
|
+
* @category Form
|
|
30
|
+
* @platform mobile
|
|
31
|
+
*
|
|
30
32
|
* @example
|
|
31
33
|
* ```tsx
|
|
32
34
|
* import { Checkbox } from '@yahoo/uds-mobile';
|
|
@@ -41,9 +43,16 @@ const VARIANT_ERROR_MAP = {
|
|
|
41
43
|
* - Settings: For toggling preferences
|
|
42
44
|
* - Filters: For multi-select filtering
|
|
43
45
|
*
|
|
44
|
-
* @
|
|
46
|
+
* @accessibility
|
|
47
|
+
* - Sets `accessibilityRole="checkbox"` automatically
|
|
48
|
+
* - Announces checked/unchecked/mixed state
|
|
49
|
+
* - Label is used as accessibility label
|
|
50
|
+
* - Supports `reduceMotion` for users who prefer reduced motion
|
|
51
|
+
*
|
|
52
|
+
* @see {@link Radio} for single-select options
|
|
53
|
+
* @see {@link Switch} for binary toggles
|
|
45
54
|
*/
|
|
46
|
-
const Checkbox = (0, react.memo)(function Checkbox
|
|
55
|
+
const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, onChange, ref, ...viewProps }) {
|
|
47
56
|
const uid = `uds-checkbox-${(0, react.useId)()}`;
|
|
48
57
|
const isControlled = checkedProp !== void 0;
|
|
49
58
|
const [internalChecked, setInternalChecked] = (0, react.useState)(isControlled ? checkedProp : defaultChecked ?? false);
|