@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
|
@@ -2,33 +2,40 @@
|
|
|
2
2
|
import { ButtonVariantFlat, IconButtonSize, IconVariant } from "../types/dist/index.mjs";
|
|
3
3
|
import { IconName } from "./Icon.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/IconButton.d.ts
|
|
10
10
|
interface IconButtonProps extends Omit<PressableProps$1, 'children'> {
|
|
11
|
-
/** Icon to render from the icons package
|
|
11
|
+
/** Icon to render from the icons package */
|
|
12
12
|
name: IconName;
|
|
13
|
-
/** @default 'primary' */
|
|
13
|
+
/** The visual style variant @default 'primary' */
|
|
14
14
|
variant?: ButtonVariantFlat;
|
|
15
|
-
/** @default 'md' */
|
|
15
|
+
/** The size of the button @default 'md' */
|
|
16
16
|
size?: IconButtonSize;
|
|
17
|
-
/** @default 'outline' */
|
|
17
|
+
/** The icon style variant @default 'outline' */
|
|
18
18
|
iconVariant?: IconVariant;
|
|
19
|
+
/** Shows a loading spinner and disables the button */
|
|
19
20
|
loading?: boolean;
|
|
20
21
|
/**
|
|
21
22
|
* Disable motion effects (scale on press, icon animations)
|
|
22
23
|
* @default false
|
|
23
24
|
*/
|
|
24
25
|
disableEffects?: boolean;
|
|
26
|
+
/** Ref to the underlying View */
|
|
25
27
|
ref?: Ref<View>;
|
|
26
28
|
}
|
|
27
29
|
/**
|
|
28
30
|
* **An icon button element that can be used to trigger an action**
|
|
29
31
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
+
* @description
|
|
33
|
+
* An icon-only button for actions where space is limited. Features animated
|
|
34
|
+
* scale effect on press and smooth color transitions matching the web UDS
|
|
35
|
+
* IconButton behavior.
|
|
36
|
+
*
|
|
37
|
+
* @category Interactive
|
|
38
|
+
* @platform mobile
|
|
32
39
|
*
|
|
33
40
|
* @example
|
|
34
41
|
* ```tsx
|
|
@@ -38,8 +45,21 @@ interface IconButtonProps extends Omit<PressableProps$1, 'children'> {
|
|
|
38
45
|
* <IconButton name="Close" variant="secondary" size="sm" />
|
|
39
46
|
* <IconButton name="Settings" loading />
|
|
40
47
|
* ```
|
|
48
|
+
*
|
|
49
|
+
* @usage
|
|
50
|
+
* - Use for toolbar actions
|
|
51
|
+
* - Use for closing modals/dialogs
|
|
52
|
+
* - Always provide accessibilityLabel for screen readers
|
|
53
|
+
*
|
|
54
|
+
* @accessibility
|
|
55
|
+
* - Sets `accessibilityRole="button"` automatically
|
|
56
|
+
* - Announces loading state to screen readers
|
|
57
|
+
* - **Always** provide `accessibilityLabel` since there's no visible text
|
|
58
|
+
*
|
|
59
|
+
* @see {@link Button} for buttons with text labels
|
|
60
|
+
* @see {@link Icon} for non-interactive icons
|
|
41
61
|
*/
|
|
42
|
-
declare const IconButton:
|
|
62
|
+
declare const IconButton: react.NamedExoticComponent<IconButtonProps>;
|
|
43
63
|
//#endregion
|
|
44
64
|
export { IconButton, type IconButtonProps };
|
|
45
65
|
//# sourceMappingURL=IconButton.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.d.mts","names":[],"sources":["../../src/components/IconButton.tsx"],"
|
|
1
|
+
{"version":3,"file":"IconButton.d.mts","names":[],"sources":["../../src/components/IconButton.tsx"],"mappings":";;;;;;;;;UA6CU,eAAA,SAAwB,IAAA,CAAK,gBAAA;;EAErC,IAAA,EAAM,QAAA;EAFE;EAIR,OAAA,GAAU,iBAAA;;EAEV,IAAA,GAAO,cAAA;EAJD;EAMN,WAAA,GAAc,WAAA;EAFP;EAIP,OAAA;EAOU;;;;EAFV,cAAA;EAfgC;EAiBhC,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;;;;;;;;;;;;;;;AAAI;;;;;;;;;;;;;;;;;;;cAwCV,UAAA,EAAU,KAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -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 { Icon } from "./Icon.mjs";
|
|
@@ -22,8 +22,13 @@ function interpolateShadowAlpha(shadow, alpha) {
|
|
|
22
22
|
/**
|
|
23
23
|
* **An icon button element that can be used to trigger an action**
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
25
|
+
* @description
|
|
26
|
+
* An icon-only button for actions where space is limited. Features animated
|
|
27
|
+
* scale effect on press and smooth color transitions matching the web UDS
|
|
28
|
+
* IconButton behavior.
|
|
29
|
+
*
|
|
30
|
+
* @category Interactive
|
|
31
|
+
* @platform mobile
|
|
27
32
|
*
|
|
28
33
|
* @example
|
|
29
34
|
* ```tsx
|
|
@@ -33,8 +38,21 @@ function interpolateShadowAlpha(shadow, alpha) {
|
|
|
33
38
|
* <IconButton name="Close" variant="secondary" size="sm" />
|
|
34
39
|
* <IconButton name="Settings" loading />
|
|
35
40
|
* ```
|
|
41
|
+
*
|
|
42
|
+
* @usage
|
|
43
|
+
* - Use for toolbar actions
|
|
44
|
+
* - Use for closing modals/dialogs
|
|
45
|
+
* - Always provide accessibilityLabel for screen readers
|
|
46
|
+
*
|
|
47
|
+
* @accessibility
|
|
48
|
+
* - Sets `accessibilityRole="button"` automatically
|
|
49
|
+
* - Announces loading state to screen readers
|
|
50
|
+
* - **Always** provide `accessibilityLabel` since there's no visible text
|
|
51
|
+
*
|
|
52
|
+
* @see {@link Button} for buttons with text labels
|
|
53
|
+
* @see {@link Icon} for non-interactive icons
|
|
36
54
|
*/
|
|
37
|
-
const IconButton = memo(function IconButton
|
|
55
|
+
const IconButton = memo(function IconButton({ name, variant = "primary", size = "md", iconVariant = "outline", loading, disabled, style, accessibilityLabel, accessibilityHint, disableEffects = false, onPressIn, onPressOut, ref, ...props }) {
|
|
38
56
|
const isDisabled = disabled || loading;
|
|
39
57
|
const shouldAnimate = !disableEffects && !isDisabled;
|
|
40
58
|
const [pressed, setPressed] = useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconButton.mjs","names":["IconButton","foundationStyles"],"sources":["../../src/components/IconButton.tsx"],"sourcesContent":["import type { ButtonVariantFlat, IconButtonSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useMemo, useState } from 'react';\nimport type { View } from 'react-native';\nimport { ActivityIndicator } from 'react-native';\nimport {\n Easing,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\nimport { useAnimatedTheme, useAnimatedVariantColor } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles, iconButtonStyles, styles as foundationStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport type { IconName } from './Icon';\nimport { Icon } from './Icon';\nimport type { PressableProps } from './Pressable';\nimport { AnimatedPressable } from './Pressable';\n\n/* -------------------------------------------------------------------------- */\n/* Animation Helpers */\n/* -------------------------------------------------------------------------- */\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/* IconButton Props */\n/* -------------------------------------------------------------------------- */\n\ninterface IconButtonProps extends Omit<PressableProps, 'children'> {\n /** Icon to render from the icons package. */\n name: IconName;\n /** @default 'primary' */\n variant?: ButtonVariantFlat;\n /** @default 'md' */\n size?: IconButtonSize;\n /** @default 'outline' */\n iconVariant?: IconVariant;\n loading?: boolean;\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/* IconButton Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **An icon button element that can be used to trigger an action**\n *\n * Features animated scale effect on press and smooth color transitions\n * matching the web UDS IconButton behavior.\n *\n * @example\n * ```tsx\n * import { IconButton } from '@yahoo/uds-mobile';\n *\n * <IconButton name=\"Add\" onPress={() => console.log('pressed')} />\n * <IconButton name=\"Close\" variant=\"secondary\" size=\"sm\" />\n * <IconButton name=\"Settings\" loading />\n * ```\n */\nconst IconButton = memo(function IconButton({\n name,\n variant = 'primary',\n size = 'md',\n iconVariant = 'outline',\n loading,\n disabled,\n style,\n accessibilityLabel,\n accessibilityHint,\n disableEffects = false,\n onPressIn,\n onPressOut,\n ref,\n ...props\n}: IconButtonProps) {\n const isDisabled = disabled || loading;\n const shouldAnimate = !disableEffects && !isDisabled;\n\n /* --------------------------------- State ---------------------------------- */\n const [pressed, setPressed] = useState(false);\n\n // Apply layer-based styles with compound variant support\n iconButtonStyles.useVariants({ size });\n buttonStyles.useVariants({ variant, disabled: isDisabled, pressed });\n\n // Animate colors using Unistyles' useAnimatedVariantColor\n const backgroundColor = useAnimatedVariantColor(buttonStyles.root, 'backgroundColor');\n const borderColor = useAnimatedVariantColor(buttonStyles.root, 'borderColor');\n\n // Get animated theme for boxShadow\n const animatedTheme = useAnimatedTheme();\n\n /* ------------------------------- Animation -------------------------------- */\n const scale = useSharedValue<number>(SCALE_EFFECTS.none);\n\n const handlePressIn = useCallback<NonNullable<PressableProps['onPressIn']>>(\n (event) => {\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<NonNullable<PressableProps['onPressOut']>>(\n (event) => {\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 const a11yState = useMemo(() => ({ disabled: isDisabled, busy: loading }), [isDisabled, loading]);\n\n /* --------------------------------- Styles --------------------------------- */\n // Animate pressed state for shadow\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 animatedRootStyle = useAnimatedStyle(() => {\n // Get boxShadow from theme using flattened path (no camelCase conversion needed!)\n const components = animatedTheme.value.components as unknown as Record<\n string,\n Record<string, unknown>\n >;\n const shadowPressed =\n (components[`button/variant/${variant}/root/pressed`]?.boxShadow as string) ?? '';\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 boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\n };\n });\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <AnimatedPressable\n ref={ref}\n disabled={isDisabled}\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 style={[\n iconButtonStyles.root,\n buttonStyles.root,\n foundationStyles.foundation,\n animatedRootStyle,\n typeof style === 'function' ? style({ pressed }) : style,\n ]}\n {...props}\n >\n {loading ? (\n <ActivityIndicator size={buttonStyles.icon.fontSize} color={buttonStyles.icon.color} />\n ) : (\n <Icon name={name} variant={iconVariant} style={buttonStyles.icon} />\n )}\n </AnimatedPressable>\n );\n});\n\nIconButton.displayName = 'IconButton';\n\nexport { IconButton, type IconButtonProps };\n"],"mappings":";;;;;;;;;;;;;AA0BA,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;;;;;;;;;;;;;;;;;AA4CJ,MAAM,aAAa,KAAK,SAASA,aAAW,EAC1C,MACA,UAAU,WACV,OAAO,MACP,cAAc,WACd,SACA,UACA,OACA,oBACA,mBACA,iBAAiB,OACjB,WACA,YACA,KACA,GAAG,SACe;CAClB,MAAM,aAAa,YAAY;CAC/B,MAAM,gBAAgB,CAAC,kBAAkB,CAAC;CAG1C,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;AAG7C,kBAAiB,YAAY,EAAE,MAAM,CAAC;AACtC,cAAa,YAAY;EAAE;EAAS,UAAU;EAAY;EAAS,CAAC;CAGpE,MAAM,kBAAkB,wBAAwB,aAAa,MAAM,kBAAkB;CACrF,MAAM,cAAc,wBAAwB,aAAa,MAAM,cAAc;CAG7E,MAAM,gBAAgB,kBAAkB;CAGxC,MAAM,QAAQ,eAAuB,cAAc,KAAK;CAExD,MAAM,gBAAgB,aACnB,UAAU;AACT,aAAW,KAAK;AAChB,MAAI,cACF,OAAM,QAAQ,WAAW,cAAc,MAAM,qBAAqB;AAEpE,cAAY,MAAM;IAEpB;EAAC;EAAe;EAAO;EAAU,CAClC;CAED,MAAM,iBAAiB,aACpB,UAAU;AACT,aAAW,MAAM;AACjB,MAAI,cACF,OAAM,QAAQ,WAAW,cAAc,MAAM,qBAAqB;AAEpE,eAAa,MAAM;IAErB;EAAC;EAAe;EAAO;EAAW,CACnC;CAED,MAAM,YAAY,eAAe;EAAE,UAAU;EAAY,MAAM;EAAS,GAAG,CAAC,YAAY,QAAQ,CAAC;CAIjG,MAAM,gBAAgB,sBACd,WAAW,UAAU,IAAI,GAAG;EAAE,UAAU;EAAK,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAK,EAAE;EAAE,CAAC,EACzF,CAAC,QAAQ,CACV;CAGD,MAAM,oBAAoB,uBAAuB;EAM/C,MAAM,gBAJa,cAAc,MAAM,WAKzB,kBAAkB,QAAQ,iBAAiB,aAAwB;AAEjF,SAAO;GACL,WAAW,CAAC,EAAE,OAAO,MAAM,OAAO,CAAC;GACnC,iBAAiB,WAAW,gBAAgB,OAAO;IACjD,UAAU;IACV,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAK,EAAE;IACpC,CAAC;GACF,aAAa,WAAW,YAAY,OAAO;IACzC,UAAU;IACV,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAK,EAAE;IACpC,CAAC;GACF,WAAW,uBAAuB,eAAe,cAAc,MAAM;GACtE;GACD;AAGF,QACE,oBAAC;EACM;EACL,UAAU;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,OAAO;GACL,iBAAiB;GACjB,aAAa;GACbC,OAAiB;GACjB;GACA,OAAO,UAAU,aAAa,MAAM,EAAE,SAAS,CAAC,GAAG;GACpD;EACD,GAAI;YAEH,UACC,oBAAC;GAAkB,MAAM,aAAa,KAAK;GAAU,OAAO,aAAa,KAAK;IAAS,GAEvF,oBAAC;GAAW;GAAM,SAAS;GAAa,OAAO,aAAa;IAAQ;GAEpD;EAEtB;AAEF,WAAW,cAAc"}
|
|
1
|
+
{"version":3,"file":"IconButton.mjs","names":["foundationStyles"],"sources":["../../src/components/IconButton.tsx"],"sourcesContent":["import type { ButtonVariantFlat, IconButtonSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useMemo, useState } from 'react';\nimport type { View } from 'react-native';\nimport { ActivityIndicator } from 'react-native';\nimport {\n Easing,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\nimport { useAnimatedTheme, useAnimatedVariantColor } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles, iconButtonStyles, styles as foundationStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport type { IconName } from './Icon';\nimport { Icon } from './Icon';\nimport type { PressableProps } from './Pressable';\nimport { AnimatedPressable } from './Pressable';\n\n/* -------------------------------------------------------------------------- */\n/* Animation Helpers */\n/* -------------------------------------------------------------------------- */\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/* IconButton Props */\n/* -------------------------------------------------------------------------- */\n\ninterface IconButtonProps extends Omit<PressableProps, 'children'> {\n /** Icon to render from the icons package */\n name: IconName;\n /** The visual style variant @default 'primary' */\n variant?: ButtonVariantFlat;\n /** The size of the button @default 'md' */\n size?: IconButtonSize;\n /** The icon style variant @default 'outline' */\n iconVariant?: IconVariant;\n /** Shows a loading spinner and disables the button */\n loading?: boolean;\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/* IconButton Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **An icon button element that can be used to trigger an action**\n *\n * @description\n * An icon-only button for actions where space is limited. Features animated\n * scale effect on press and smooth color transitions matching the web UDS\n * IconButton behavior.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { IconButton } from '@yahoo/uds-mobile';\n *\n * <IconButton name=\"Add\" onPress={() => console.log('pressed')} />\n * <IconButton name=\"Close\" variant=\"secondary\" size=\"sm\" />\n * <IconButton name=\"Settings\" loading />\n * ```\n *\n * @usage\n * - Use for toolbar actions\n * - Use for closing modals/dialogs\n * - Always provide accessibilityLabel for screen readers\n *\n * @accessibility\n * - Sets `accessibilityRole=\"button\"` automatically\n * - Announces loading state to screen readers\n * - **Always** provide `accessibilityLabel` since there's no visible text\n *\n * @see {@link Button} for buttons with text labels\n * @see {@link Icon} for non-interactive icons\n */\nconst IconButton = memo(function IconButton({\n name,\n variant = 'primary',\n size = 'md',\n iconVariant = 'outline',\n loading,\n disabled,\n style,\n accessibilityLabel,\n accessibilityHint,\n disableEffects = false,\n onPressIn,\n onPressOut,\n ref,\n ...props\n}: IconButtonProps) {\n const isDisabled = disabled || loading;\n const shouldAnimate = !disableEffects && !isDisabled;\n\n /* --------------------------------- State ---------------------------------- */\n const [pressed, setPressed] = useState(false);\n\n // Apply layer-based styles with compound variant support\n iconButtonStyles.useVariants({ size });\n buttonStyles.useVariants({ variant, disabled: isDisabled, pressed });\n\n // Animate colors using Unistyles' useAnimatedVariantColor\n const backgroundColor = useAnimatedVariantColor(buttonStyles.root, 'backgroundColor');\n const borderColor = useAnimatedVariantColor(buttonStyles.root, 'borderColor');\n\n // Get animated theme for boxShadow\n const animatedTheme = useAnimatedTheme();\n\n /* ------------------------------- Animation -------------------------------- */\n const scale = useSharedValue<number>(SCALE_EFFECTS.none);\n\n const handlePressIn = useCallback<NonNullable<PressableProps['onPressIn']>>(\n (event) => {\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<NonNullable<PressableProps['onPressOut']>>(\n (event) => {\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 const a11yState = useMemo(() => ({ disabled: isDisabled, busy: loading }), [isDisabled, loading]);\n\n /* --------------------------------- Styles --------------------------------- */\n // Animate pressed state for shadow\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 animatedRootStyle = useAnimatedStyle(() => {\n // Get boxShadow from theme using flattened path (no camelCase conversion needed!)\n const components = animatedTheme.value.components as unknown as Record<\n string,\n Record<string, unknown>\n >;\n const shadowPressed =\n (components[`button/variant/${variant}/root/pressed`]?.boxShadow as string) ?? '';\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 boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\n };\n });\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <AnimatedPressable\n ref={ref}\n disabled={isDisabled}\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 style={[\n iconButtonStyles.root,\n buttonStyles.root,\n foundationStyles.foundation,\n animatedRootStyle,\n typeof style === 'function' ? style({ pressed }) : style,\n ]}\n {...props}\n >\n {loading ? (\n <ActivityIndicator size={buttonStyles.icon.fontSize} color={buttonStyles.icon.color} />\n ) : (\n <Icon name={name} variant={iconVariant} style={buttonStyles.icon} />\n )}\n </AnimatedPressable>\n );\n});\n\nIconButton.displayName = 'IconButton';\n\nexport { IconButton, type IconButtonProps };\n"],"mappings":";;;;;;;;;;;;;AA0BA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEJ,MAAM,aAAa,KAAK,SAAS,WAAW,EAC1C,MACA,UAAU,WACV,OAAO,MACP,cAAc,WACd,SACA,UACA,OACA,oBACA,mBACA,iBAAiB,OACjB,WACA,YACA,KACA,GAAG,SACe;CAClB,MAAM,aAAa,YAAY;CAC/B,MAAM,gBAAgB,CAAC,kBAAkB,CAAC;CAG1C,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;AAG7C,kBAAiB,YAAY,EAAE,MAAM,CAAC;AACtC,cAAa,YAAY;EAAE;EAAS,UAAU;EAAY;EAAS,CAAC;CAGpE,MAAM,kBAAkB,wBAAwB,aAAa,MAAM,kBAAkB;CACrF,MAAM,cAAc,wBAAwB,aAAa,MAAM,cAAc;CAG7E,MAAM,gBAAgB,kBAAkB;CAGxC,MAAM,QAAQ,eAAuB,cAAc,KAAK;CAExD,MAAM,gBAAgB,aACnB,UAAU;AACT,aAAW,KAAK;AAChB,MAAI,cACF,OAAM,QAAQ,WAAW,cAAc,MAAM,qBAAqB;AAEpE,cAAY,MAAM;IAEpB;EAAC;EAAe;EAAO;EAAU,CAClC;CAED,MAAM,iBAAiB,aACpB,UAAU;AACT,aAAW,MAAM;AACjB,MAAI,cACF,OAAM,QAAQ,WAAW,cAAc,MAAM,qBAAqB;AAEpE,eAAa,MAAM;IAErB;EAAC;EAAe;EAAO;EAAW,CACnC;CAED,MAAM,YAAY,eAAe;EAAE,UAAU;EAAY,MAAM;EAAS,GAAG,CAAC,YAAY,QAAQ,CAAC;CAIjG,MAAM,gBAAgB,sBACd,WAAW,UAAU,IAAI,GAAG;EAAE,UAAU;EAAK,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAK,EAAE;EAAE,CAAC,EACzF,CAAC,QAAQ,CACV;CAGD,MAAM,oBAAoB,uBAAuB;EAM/C,MAAM,gBAJa,cAAc,MAAM,WAKzB,kBAAkB,QAAQ,iBAAiB,aAAwB;AAEjF,SAAO;GACL,WAAW,CAAC,EAAE,OAAO,MAAM,OAAO,CAAC;GACnC,iBAAiB,WAAW,gBAAgB,OAAO;IACjD,UAAU;IACV,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAK,EAAE;IACpC,CAAC;GACF,aAAa,WAAW,YAAY,OAAO;IACzC,UAAU;IACV,QAAQ,OAAO,OAAO,GAAG,GAAG,IAAK,EAAE;IACpC,CAAC;GACF,WAAW,uBAAuB,eAAe,cAAc,MAAM;GACtE;GACD;AAGF,QACE,oBAAC;EACM;EACL,UAAU;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,OAAO;GACL,iBAAiB;GACjB,aAAa;GACbA,OAAiB;GACjB;GACA,OAAO,UAAU,aAAa,MAAM,EAAE,SAAS,CAAC,GAAG;GACpD;EACD,GAAI;YAEH,UACC,oBAAC;GAAkB,MAAM,aAAa,KAAK;GAAU,OAAO,aAAa,KAAK;IAAS,GAEvF,oBAAC;GAAW;GAAM,SAAS;GAAa,OAAO,aAAa;IAAQ;GAEpD;EAEtB;AAEF,WAAW,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_components_Icon = require('./Icon.cjs');
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -14,6 +15,9 @@ let lodash_es = require("lodash-es");
|
|
|
14
15
|
* consumers to pass in a standard UDS icon name, an Icon component, or a render function
|
|
15
16
|
* for custom rendering.
|
|
16
17
|
*
|
|
18
|
+
* @category Utility
|
|
19
|
+
* @platform mobile
|
|
20
|
+
*
|
|
17
21
|
* @example
|
|
18
22
|
* ```tsx
|
|
19
23
|
* import { IconSlot } from '@yahoo/uds-mobile';
|
|
@@ -32,8 +36,10 @@ let lodash_es = require("lodash-es");
|
|
|
32
36
|
* - Pass icon name for simple usage
|
|
33
37
|
* - Pass Icon component for custom props
|
|
34
38
|
* - Pass function for dynamic rendering
|
|
39
|
+
*
|
|
40
|
+
* @see {@link Icon} for direct icon rendering
|
|
35
41
|
*/
|
|
36
|
-
const IconSlot = (0, react.memo)(function IconSlot
|
|
42
|
+
const IconSlot = (0, react.memo)(function IconSlot({ icon, ref, ...props }) {
|
|
37
43
|
if (!icon) return null;
|
|
38
44
|
if (typeof icon === "string") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Icon.Icon, {
|
|
39
45
|
ref,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { IconName, IconProps } from "./Icon.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { ReactElement, Ref } from "react";
|
|
5
5
|
import { Text } from "react-native";
|
|
6
6
|
|
|
@@ -20,6 +20,9 @@ interface IconSlotProps extends IconPropsWithoutName {
|
|
|
20
20
|
* consumers to pass in a standard UDS icon name, an Icon component, or a render function
|
|
21
21
|
* for custom rendering.
|
|
22
22
|
*
|
|
23
|
+
* @category Utility
|
|
24
|
+
* @platform mobile
|
|
25
|
+
*
|
|
23
26
|
* @example
|
|
24
27
|
* ```tsx
|
|
25
28
|
* import { IconSlot } from '@yahoo/uds-mobile';
|
|
@@ -38,8 +41,10 @@ interface IconSlotProps extends IconPropsWithoutName {
|
|
|
38
41
|
* - Pass icon name for simple usage
|
|
39
42
|
* - Pass Icon component for custom props
|
|
40
43
|
* - Pass function for dynamic rendering
|
|
44
|
+
*
|
|
45
|
+
* @see {@link Icon} for direct icon rendering
|
|
41
46
|
*/
|
|
42
|
-
declare const IconSlot:
|
|
47
|
+
declare const IconSlot: react.NamedExoticComponent<IconSlotProps>;
|
|
43
48
|
//#endregion
|
|
44
49
|
export { IconSlot, type IconSlotProps, type IconSlotType };
|
|
45
50
|
//# sourceMappingURL=IconSlot.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconSlot.d.cts","names":[],"sources":["../../src/components/IconSlot.tsx"],"
|
|
1
|
+
{"version":3,"file":"IconSlot.d.cts","names":[],"sources":["../../src/components/IconSlot.tsx"],"mappings":";;;;;;;KAOK,oBAAA,GAAuB,IAAA,CAAK,SAAA;AAAA,KAE5B,YAAA,GACD,QAAA,GACA,YAAA,CAAa,SAAA,MACX,SAAA,EAAW,oBAAA,KAAyB,YAAA,CAAa,SAAA;AAAA,UAE7C,aAAA,SAAsB,oBAAA;EAC9B,GAAA,GAAM,GAAA,CAAI,IAAA;EARa;EAUvB,IAAA,GAAO,YAAA;AAAA;;AAViC;;;;;;;;;;;;;;;;;;;;AAKsB;;;;;;;;;;;cAyC1D,QAAA,EAAQ,KAAA,CAAA,oBAAA,CAAA,aAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { IconName, IconProps } from "./Icon.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { ReactElement, Ref } from "react";
|
|
5
5
|
import { Text } from "react-native";
|
|
6
6
|
|
|
@@ -20,6 +20,9 @@ interface IconSlotProps extends IconPropsWithoutName {
|
|
|
20
20
|
* consumers to pass in a standard UDS icon name, an Icon component, or a render function
|
|
21
21
|
* for custom rendering.
|
|
22
22
|
*
|
|
23
|
+
* @category Utility
|
|
24
|
+
* @platform mobile
|
|
25
|
+
*
|
|
23
26
|
* @example
|
|
24
27
|
* ```tsx
|
|
25
28
|
* import { IconSlot } from '@yahoo/uds-mobile';
|
|
@@ -38,8 +41,10 @@ interface IconSlotProps extends IconPropsWithoutName {
|
|
|
38
41
|
* - Pass icon name for simple usage
|
|
39
42
|
* - Pass Icon component for custom props
|
|
40
43
|
* - Pass function for dynamic rendering
|
|
44
|
+
*
|
|
45
|
+
* @see {@link Icon} for direct icon rendering
|
|
41
46
|
*/
|
|
42
|
-
declare const IconSlot:
|
|
47
|
+
declare const IconSlot: react.NamedExoticComponent<IconSlotProps>;
|
|
43
48
|
//#endregion
|
|
44
49
|
export { IconSlot, type IconSlotProps, type IconSlotType };
|
|
45
50
|
//# sourceMappingURL=IconSlot.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconSlot.d.mts","names":[],"sources":["../../src/components/IconSlot.tsx"],"
|
|
1
|
+
{"version":3,"file":"IconSlot.d.mts","names":[],"sources":["../../src/components/IconSlot.tsx"],"mappings":";;;;;;;KAOK,oBAAA,GAAuB,IAAA,CAAK,SAAA;AAAA,KAE5B,YAAA,GACD,QAAA,GACA,YAAA,CAAa,SAAA,MACX,SAAA,EAAW,oBAAA,KAAyB,YAAA,CAAa,SAAA;AAAA,UAE7C,aAAA,SAAsB,oBAAA;EAC9B,GAAA,GAAM,GAAA,CAAI,IAAA;EARa;EAUvB,IAAA,GAAO,YAAA;AAAA;;AAViC;;;;;;;;;;;;;;;;;;;;AAKsB;;;;;;;;;;;cAyC1D,QAAA,EAAQ,KAAA,CAAA,oBAAA,CAAA,aAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { Icon } from "./Icon.mjs";
|
|
3
3
|
import { cloneElement, isValidElement, memo } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -13,6 +13,9 @@ import { isFunction } from "lodash-es";
|
|
|
13
13
|
* consumers to pass in a standard UDS icon name, an Icon component, or a render function
|
|
14
14
|
* for custom rendering.
|
|
15
15
|
*
|
|
16
|
+
* @category Utility
|
|
17
|
+
* @platform mobile
|
|
18
|
+
*
|
|
16
19
|
* @example
|
|
17
20
|
* ```tsx
|
|
18
21
|
* import { IconSlot } from '@yahoo/uds-mobile';
|
|
@@ -31,8 +34,10 @@ import { isFunction } from "lodash-es";
|
|
|
31
34
|
* - Pass icon name for simple usage
|
|
32
35
|
* - Pass Icon component for custom props
|
|
33
36
|
* - Pass function for dynamic rendering
|
|
37
|
+
*
|
|
38
|
+
* @see {@link Icon} for direct icon rendering
|
|
34
39
|
*/
|
|
35
|
-
const IconSlot = memo(function IconSlot
|
|
40
|
+
const IconSlot = memo(function IconSlot({ icon, ref, ...props }) {
|
|
36
41
|
if (!icon) return null;
|
|
37
42
|
if (typeof icon === "string") return /* @__PURE__ */ jsx(Icon, {
|
|
38
43
|
ref,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconSlot.mjs","names":[
|
|
1
|
+
{"version":3,"file":"IconSlot.mjs","names":[],"sources":["../../src/components/IconSlot.tsx"],"sourcesContent":["import { isFunction } from 'lodash-es';\nimport type { ReactElement, Ref } from 'react';\nimport { cloneElement, isValidElement, memo } from 'react';\nimport type { Text as RNText } from 'react-native';\n\nimport type { IconName, IconProps } from './Icon';\nimport { Icon } from './Icon';\ntype IconPropsWithoutName = Omit<IconProps, 'name'>;\n\ntype IconSlotType =\n | IconName\n | ReactElement<IconProps>\n | ((iconProps: IconPropsWithoutName) => ReactElement<IconProps>);\n\ninterface IconSlotProps extends IconPropsWithoutName {\n ref?: Ref<RNText>;\n /** The icon to render. Can be a UDS icon, an Icon component, ReactNode, or a function that returns a ReactNode. */\n icon?: IconSlotType;\n /** Props to spread onto the icon. */\n}\n\n/**\n * **🔌 A helper container to render icons flexibly**\n *\n * @description\n * Useful in components that use icons and have a startIcon and endIcon. It allows\n * consumers to pass in a standard UDS icon name, an Icon component, or a render function\n * for custom rendering.\n *\n * @category Utility\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { IconSlot } from '@yahoo/uds-mobile';\n *\n * // Using icon name (preferred - stable reference, no useMemo needed)\n * <IconSlot icon=\"Info\" size=\"md\" variant=\"fill\" />\n *\n * // Using Icon component\n * <IconSlot icon={<Icon name=\"Info\" variant=\"fill\" />} />\n *\n * // Using render function\n * <IconSlot icon={(props) => <Icon name=\"Info\" {...props} variant=\"fill\" />} />\n * ```\n *\n * @usage\n * - Pass icon name for simple usage\n * - Pass Icon component for custom props\n * - Pass function for dynamic rendering\n *\n * @see {@link Icon} for direct icon rendering\n */\nconst IconSlot = memo(function IconSlot({ icon, ref, ...props }: IconSlotProps) {\n if (!icon) {\n return null;\n }\n\n if (typeof icon === 'string') {\n return <Icon ref={ref} name={icon} {...props} />;\n }\n\n if (isFunction(icon)) {\n const iconEl = icon(props);\n return isValidElement(iconEl) ? cloneElement(iconEl, { ...props } as Partial<IconProps>) : null;\n }\n\n return isValidElement(icon)\n ? cloneElement(icon, {\n ...props,\n ...icon.props, // user's props on <Icon>\n } as Partial<IconProps>)\n : null;\n});\n\nIconSlot.displayName = 'IconSlot';\n\nexport { IconSlot, type IconSlotProps, type IconSlotType };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAM,WAAW,KAAK,SAAS,SAAS,EAAE,MAAM,KAAK,GAAG,SAAwB;AAC9E,KAAI,CAAC,KACH,QAAO;AAGT,KAAI,OAAO,SAAS,SAClB,QAAO,oBAAC;EAAU;EAAK,MAAM;EAAM,GAAI;GAAS;AAGlD,KAAI,WAAW,KAAK,EAAE;EACpB,MAAM,SAAS,KAAK,MAAM;AAC1B,SAAO,eAAe,OAAO,GAAG,aAAa,QAAQ,EAAE,GAAG,OAAO,CAAuB,GAAG;;AAG7F,QAAO,eAAe,KAAK,GACvB,aAAa,MAAM;EACjB,GAAG;EACH,GAAG,KAAK;EACT,CAAuB,GACxB;EACJ;AAEF,SAAS,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
|
let react = require("react");
|
|
4
5
|
let react_native = require("react-native");
|
|
5
6
|
let generated_styles = require("../../generated/styles");
|
|
@@ -19,15 +20,29 @@ const CONTENT_FIT_TO_RESIZE_MODE = {
|
|
|
19
20
|
* @description
|
|
20
21
|
* Wrapper for the React Native Image component with UDS styling props.
|
|
21
22
|
*
|
|
23
|
+
* @category Display
|
|
24
|
+
* @platform mobile
|
|
25
|
+
*
|
|
22
26
|
* @example
|
|
23
27
|
* ```tsx
|
|
24
|
-
* import { Image } from '
|
|
28
|
+
* import { Image } from '@yahoo/uds-mobile';
|
|
25
29
|
*
|
|
26
30
|
* <Image src="https://example.com/image.png" width={200} height={150} />
|
|
27
31
|
* <Image src={require('./local-image.png')} contentFit="cover" borderRadius="md" />
|
|
28
32
|
* ```
|
|
33
|
+
*
|
|
34
|
+
* @usage
|
|
35
|
+
* - Use for displaying remote or local images
|
|
36
|
+
* - Use contentFit to control how the image fills its container
|
|
37
|
+
* - All Box styling props are supported
|
|
38
|
+
*
|
|
39
|
+
* @accessibility
|
|
40
|
+
* - Always provide `alt` prop for screen reader description
|
|
41
|
+
* - Alt text should describe the image content meaningfully
|
|
42
|
+
*
|
|
43
|
+
* @see {@link Avatar} for user profile images
|
|
29
44
|
*/
|
|
30
|
-
const Image = (0, react.memo)(function Image
|
|
45
|
+
const Image = (0, react.memo)(function Image({ src, alt, width, height, contentFit = "cover", style, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, display, overflow, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, ref, ...props }) {
|
|
31
46
|
generated_styles.styles.useVariants({
|
|
32
47
|
backgroundColor,
|
|
33
48
|
borderRadius,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalImageProps } from "../types/dist/index.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { Image as Image$1, ImageProps as ImageProps$1 } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
@@ -8,6 +8,7 @@ import { StyleProps } from "../../generated/styles";
|
|
|
8
8
|
//#region src/components/Image.d.ts
|
|
9
9
|
type ContentFit = NonNullable<UniversalImageProps['contentFit']>;
|
|
10
10
|
interface ImageProps extends Omit<ImageProps$1, 'source' | 'src' | 'width' | 'height' | 'borderRadius'> {
|
|
11
|
+
/** Ref to the underlying Image element */
|
|
11
12
|
ref?: Ref<Image$1>;
|
|
12
13
|
/** Image source URL or require() */
|
|
13
14
|
src: UniversalImageProps['src'];
|
|
@@ -71,15 +72,29 @@ interface ImageProps extends Omit<ImageProps$1, 'source' | 'src' | 'width' | 'he
|
|
|
71
72
|
* @description
|
|
72
73
|
* Wrapper for the React Native Image component with UDS styling props.
|
|
73
74
|
*
|
|
75
|
+
* @category Display
|
|
76
|
+
* @platform mobile
|
|
77
|
+
*
|
|
74
78
|
* @example
|
|
75
79
|
* ```tsx
|
|
76
|
-
* import { Image } from '
|
|
80
|
+
* import { Image } from '@yahoo/uds-mobile';
|
|
77
81
|
*
|
|
78
82
|
* <Image src="https://example.com/image.png" width={200} height={150} />
|
|
79
83
|
* <Image src={require('./local-image.png')} contentFit="cover" borderRadius="md" />
|
|
80
84
|
* ```
|
|
85
|
+
*
|
|
86
|
+
* @usage
|
|
87
|
+
* - Use for displaying remote or local images
|
|
88
|
+
* - Use contentFit to control how the image fills its container
|
|
89
|
+
* - All Box styling props are supported
|
|
90
|
+
*
|
|
91
|
+
* @accessibility
|
|
92
|
+
* - Always provide `alt` prop for screen reader description
|
|
93
|
+
* - Alt text should describe the image content meaningfully
|
|
94
|
+
*
|
|
95
|
+
* @see {@link Avatar} for user profile images
|
|
81
96
|
*/
|
|
82
|
-
declare const Image:
|
|
97
|
+
declare const Image: react.NamedExoticComponent<ImageProps>;
|
|
83
98
|
//#endregion
|
|
84
99
|
export { Image, type ImageProps };
|
|
85
100
|
//# sourceMappingURL=Image.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.cts","names":[],"sources":["../../src/components/Image.tsx"],"
|
|
1
|
+
{"version":3,"file":"Image.d.cts","names":[],"sources":["../../src/components/Image.tsx"],"mappings":";;;;;;;;KASK,UAAA,GAAa,WAAA,CAAY,mBAAA;AAAA,UAUpB,UAAA,SAAmB,IAAA,CAC3B,YAAA;EAXG;EAeH,GAAA,GAAM,GAAA,CAAI,OAAA;;EAEV,GAAA,EAAK,mBAAA;EAjB0C;EAmB/C,GAAA;EATmB;EAWnB,KAAA;EAVA;EAYA,MAAA;EARM;EAUN,UAAA,GAAa,UAAA;EAEb,eAAA,GAAkB,UAAA;EAElB,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;EAEpB,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;EAEX,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;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BL,KAAA,EAAK,KAAA,CAAA,oBAAA,CAAA,UAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
import { UniversalImageProps } from "../types/dist/index.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { Image as Image$1, ImageProps as ImageProps$1 } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
@@ -8,6 +8,7 @@ import { StyleProps } from "../../generated/styles";
|
|
|
8
8
|
//#region src/components/Image.d.ts
|
|
9
9
|
type ContentFit = NonNullable<UniversalImageProps['contentFit']>;
|
|
10
10
|
interface ImageProps extends Omit<ImageProps$1, 'source' | 'src' | 'width' | 'height' | 'borderRadius'> {
|
|
11
|
+
/** Ref to the underlying Image element */
|
|
11
12
|
ref?: Ref<Image$1>;
|
|
12
13
|
/** Image source URL or require() */
|
|
13
14
|
src: UniversalImageProps['src'];
|
|
@@ -71,15 +72,29 @@ interface ImageProps extends Omit<ImageProps$1, 'source' | 'src' | 'width' | 'he
|
|
|
71
72
|
* @description
|
|
72
73
|
* Wrapper for the React Native Image component with UDS styling props.
|
|
73
74
|
*
|
|
75
|
+
* @category Display
|
|
76
|
+
* @platform mobile
|
|
77
|
+
*
|
|
74
78
|
* @example
|
|
75
79
|
* ```tsx
|
|
76
|
-
* import { Image } from '
|
|
80
|
+
* import { Image } from '@yahoo/uds-mobile';
|
|
77
81
|
*
|
|
78
82
|
* <Image src="https://example.com/image.png" width={200} height={150} />
|
|
79
83
|
* <Image src={require('./local-image.png')} contentFit="cover" borderRadius="md" />
|
|
80
84
|
* ```
|
|
85
|
+
*
|
|
86
|
+
* @usage
|
|
87
|
+
* - Use for displaying remote or local images
|
|
88
|
+
* - Use contentFit to control how the image fills its container
|
|
89
|
+
* - All Box styling props are supported
|
|
90
|
+
*
|
|
91
|
+
* @accessibility
|
|
92
|
+
* - Always provide `alt` prop for screen reader description
|
|
93
|
+
* - Alt text should describe the image content meaningfully
|
|
94
|
+
*
|
|
95
|
+
* @see {@link Avatar} for user profile images
|
|
81
96
|
*/
|
|
82
|
-
declare const Image:
|
|
97
|
+
declare const Image: react.NamedExoticComponent<ImageProps>;
|
|
83
98
|
//#endregion
|
|
84
99
|
export { Image, type ImageProps };
|
|
85
100
|
//# sourceMappingURL=Image.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.d.mts","names":[],"sources":["../../src/components/Image.tsx"],"
|
|
1
|
+
{"version":3,"file":"Image.d.mts","names":[],"sources":["../../src/components/Image.tsx"],"mappings":";;;;;;;;KASK,UAAA,GAAa,WAAA,CAAY,mBAAA;AAAA,UAUpB,UAAA,SAAmB,IAAA,CAC3B,YAAA;EAXG;EAeH,GAAA,GAAM,GAAA,CAAI,OAAA;;EAEV,GAAA,EAAK,mBAAA;EAjB0C;EAmB/C,GAAA;EATmB;EAWnB,KAAA;EAVA;EAYA,MAAA;EARM;EAUN,UAAA,GAAa,UAAA;EAEb,eAAA,GAAkB,UAAA;EAElB,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;EAEpB,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;EAEX,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;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+BL,KAAA,EAAK,KAAA,CAAA,oBAAA,CAAA,UAAA"}
|
|
@@ -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 { Image as Image$1 } from "react-native";
|
|
4
4
|
import { styles } from "../../generated/styles";
|
|
@@ -18,15 +18,29 @@ const CONTENT_FIT_TO_RESIZE_MODE = {
|
|
|
18
18
|
* @description
|
|
19
19
|
* Wrapper for the React Native Image component with UDS styling props.
|
|
20
20
|
*
|
|
21
|
+
* @category Display
|
|
22
|
+
* @platform mobile
|
|
23
|
+
*
|
|
21
24
|
* @example
|
|
22
25
|
* ```tsx
|
|
23
|
-
* import { Image } from '
|
|
26
|
+
* import { Image } from '@yahoo/uds-mobile';
|
|
24
27
|
*
|
|
25
28
|
* <Image src="https://example.com/image.png" width={200} height={150} />
|
|
26
29
|
* <Image src={require('./local-image.png')} contentFit="cover" borderRadius="md" />
|
|
27
30
|
* ```
|
|
31
|
+
*
|
|
32
|
+
* @usage
|
|
33
|
+
* - Use for displaying remote or local images
|
|
34
|
+
* - Use contentFit to control how the image fills its container
|
|
35
|
+
* - All Box styling props are supported
|
|
36
|
+
*
|
|
37
|
+
* @accessibility
|
|
38
|
+
* - Always provide `alt` prop for screen reader description
|
|
39
|
+
* - Alt text should describe the image content meaningfully
|
|
40
|
+
*
|
|
41
|
+
* @see {@link Avatar} for user profile images
|
|
28
42
|
*/
|
|
29
|
-
const Image = memo(function Image
|
|
43
|
+
const Image = memo(function Image({ src, alt, width, height, contentFit = "cover", style, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, alignContent, alignItems, alignSelf, flex, flexDirection, flexGrow, flexShrink, flexWrap, justifyContent, display, overflow, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, columnGap, rowGap, ref, ...props }) {
|
|
30
44
|
styles.useVariants({
|
|
31
45
|
backgroundColor,
|
|
32
46
|
borderRadius,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.mjs","names":["
|
|
1
|
+
{"version":3,"file":"Image.mjs","names":["RNImage"],"sources":["../../src/components/Image.tsx"],"sourcesContent":["import type { UniversalImageProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type { ImageProps as RNImageProps, ImageStyle } from 'react-native';\nimport { Image as RNImage } from 'react-native';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\n\ntype ContentFit = NonNullable<UniversalImageProps['contentFit']>;\n\nconst CONTENT_FIT_TO_RESIZE_MODE: Record<ContentFit, ImageStyle['resizeMode']> = {\n cover: 'cover',\n contain: 'contain',\n fill: 'stretch',\n none: 'center',\n 'scale-down': 'contain',\n};\n\ninterface ImageProps extends Omit<\n RNImageProps,\n 'source' | 'src' | 'width' | 'height' | 'borderRadius'\n> {\n /** Ref to the underlying Image element */\n ref?: Ref<RNImage>;\n /** Image source URL or require() */\n src: UniversalImageProps['src'];\n /** Alt text for accessibility */\n alt?: string;\n /** Image width */\n width?: number;\n /** Image height */\n height?: number;\n /** How to fit the image within its container */\n contentFit?: ContentFit;\n // Background\n backgroundColor?: StyleProps['backgroundColor'];\n // Border\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 // Flex\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 // Layout\n display?: StyleProps['display'];\n overflow?: StyleProps['overflow'];\n // Spacing\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}\n\n/**\n * **A component for displaying images**\n *\n * @description\n * Wrapper for the React Native Image component with UDS styling props.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Image } from '@yahoo/uds-mobile';\n *\n * <Image src=\"https://example.com/image.png\" width={200} height={150} />\n * <Image src={require('./local-image.png')} contentFit=\"cover\" borderRadius=\"md\" />\n * ```\n *\n * @usage\n * - Use for displaying remote or local images\n * - Use contentFit to control how the image fills its container\n * - All Box styling props are supported\n *\n * @accessibility\n * - Always provide `alt` prop for screen reader description\n * - Alt text should describe the image content meaningfully\n *\n * @see {@link Avatar} for user profile images\n */\nconst Image = memo(function Image({\n src,\n alt,\n width,\n height,\n contentFit = 'cover',\n style,\n // background\n backgroundColor,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\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 // layout\n display,\n overflow,\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 ref,\n ...props\n}: ImageProps) {\n // Apply styles using useVariants\n styles.useVariants({\n backgroundColor,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\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 // layout\n display,\n overflow,\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 });\n\n const source = useMemo(() => (typeof src === 'string' ? { uri: src } : src), [src]);\n\n // styles.foundation must be in deps - it returns a new reference when variants change\n const imageStyles = useMemo(\n () => [styles.foundation as ImageStyle, { width, height }, style],\n [styles.foundation, width, height, style],\n );\n\n return (\n <RNImage\n ref={ref}\n source={source}\n accessibilityLabel={alt}\n resizeMode={CONTENT_FIT_TO_RESIZE_MODE[contentFit]}\n style={imageStyles}\n {...props}\n />\n );\n});\n\nImage.displayName = 'Image';\n\nexport { Image, type ImageProps };\n"],"mappings":";;;;;;;AAWA,MAAM,6BAA2E;CAC/E,OAAO;CACP,SAAS;CACT,MAAM;CACN,MAAM;CACN,cAAc;CACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkGD,MAAM,QAAQ,KAAK,SAAS,MAAM,EAChC,KACA,KACA,OACA,QACA,aAAa,SACb,OAEA,iBAEA,cACA,sBACA,oBACA,yBACA,uBACA,aACA,kBACA,gBACA,gBACA,mBACA,aACA,qBACA,uBACA,kBACA,gBACA,gBACA,mBAEA,cACA,YACA,WACA,MACA,eACA,UACA,YACA,UACA,gBAEA,SACA,UAEA,SACA,mBACA,iBACA,eACA,YACA,cACA,YACA,QACA,gBACA,kBACA,cACA,WACA,aACA,WACA,WACA,QACA,KACA,GAAG,SACU;AAEb,QAAO,YAAY;EACjB;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,SAAS,cAAe,OAAO,QAAQ,WAAW,EAAE,KAAK,KAAK,GAAG,KAAM,CAAC,IAAI,CAAC;CAGnF,MAAM,cAAc,cACZ;EAAC,OAAO;EAA0B;GAAE;GAAO;GAAQ;EAAE;EAAM,EACjE;EAAC,OAAO;EAAY;EAAO;EAAQ;EAAM,CAC1C;AAED,QACE,oBAACA;EACM;EACG;EACR,oBAAoB;EACpB,YAAY,2BAA2B;EACvC,OAAO;EACP,GAAI;GACJ;EAEJ;AAEF,MAAM,cAAc"}
|