@yahoo/uds-mobile 2.14.0 → 2.15.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/components/Avatar/Avatar.cjs +45 -0
- package/dist/components/Avatar/Avatar.d.cts +19 -0
- package/dist/components/Avatar/Avatar.d.cts.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +19 -0
- package/dist/components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/components/Avatar/Avatar.js +45 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Avatar/AvatarIcon.cjs +47 -0
- package/dist/components/Avatar/AvatarIcon.d.cts +9 -0
- package/dist/components/Avatar/AvatarIcon.d.cts.map +1 -0
- package/dist/components/Avatar/AvatarIcon.d.ts +9 -0
- package/dist/components/Avatar/AvatarIcon.d.ts.map +1 -0
- package/dist/components/Avatar/AvatarIcon.js +47 -0
- package/dist/components/Avatar/AvatarIcon.js.map +1 -0
- package/dist/components/Avatar/AvatarImage.cjs +81 -0
- package/dist/components/Avatar/AvatarImage.d.cts +9 -0
- package/dist/components/Avatar/AvatarImage.d.cts.map +1 -0
- package/dist/components/Avatar/AvatarImage.d.ts +9 -0
- package/dist/components/Avatar/AvatarImage.d.ts.map +1 -0
- package/dist/components/Avatar/AvatarImage.js +81 -0
- package/dist/components/Avatar/AvatarImage.js.map +1 -0
- package/dist/components/Avatar/AvatarText.cjs +49 -0
- package/dist/components/Avatar/AvatarText.d.cts +9 -0
- package/dist/components/Avatar/AvatarText.d.cts.map +1 -0
- package/dist/components/Avatar/AvatarText.d.ts +9 -0
- package/dist/components/Avatar/AvatarText.d.ts.map +1 -0
- package/dist/components/Avatar/AvatarText.js +49 -0
- package/dist/components/Avatar/AvatarText.js.map +1 -0
- package/dist/components/Avatar/index.cjs +10 -0
- package/dist/components/Avatar/index.d.cts +7 -0
- package/dist/components/Avatar/index.d.ts +7 -0
- package/dist/components/Avatar/index.js +6 -0
- package/dist/components/Avatar/types.cjs +1 -0
- package/dist/components/Avatar/types.d.cts +28 -0
- package/dist/components/Avatar/types.d.cts.map +1 -0
- package/dist/components/Avatar/types.d.ts +28 -0
- package/dist/components/Avatar/types.d.ts.map +1 -0
- package/dist/components/Avatar/types.js +1 -0
- package/dist/components/Avatar/utils.cjs +38 -0
- package/dist/components/Avatar/utils.d.cts +14 -0
- package/dist/components/Avatar/utils.d.cts.map +1 -0
- package/dist/components/Avatar/utils.d.ts +14 -0
- package/dist/components/Avatar/utils.d.ts.map +1 -0
- package/dist/components/Avatar/utils.js +35 -0
- package/dist/components/Avatar/utils.js.map +1 -0
- package/dist/components/Badge.cjs +1 -1
- package/dist/components/Badge.js +1 -1
- package/dist/components/Chip/Chip.cjs +54 -0
- package/dist/components/Chip/Chip.d.cts +19 -0
- package/dist/components/Chip/Chip.d.cts.map +1 -0
- package/dist/components/Chip/Chip.d.ts +19 -0
- package/dist/components/Chip/Chip.d.ts.map +1 -0
- package/dist/components/Chip/Chip.js +54 -0
- package/dist/components/Chip/Chip.js.map +1 -0
- package/dist/components/Chip/ChipBase.cjs +119 -0
- package/dist/components/Chip/ChipBase.d.cts +13 -0
- package/dist/components/Chip/ChipBase.d.cts.map +1 -0
- package/dist/components/Chip/ChipBase.d.ts +13 -0
- package/dist/components/Chip/ChipBase.d.ts.map +1 -0
- package/dist/components/Chip/ChipBase.js +116 -0
- package/dist/components/Chip/ChipBase.js.map +1 -0
- package/dist/components/Chip/ChipButton.cjs +18 -0
- package/dist/components/Chip/ChipButton.d.cts +9 -0
- package/dist/components/Chip/ChipButton.d.cts.map +1 -0
- package/dist/components/Chip/ChipButton.d.ts +9 -0
- package/dist/components/Chip/ChipButton.d.ts.map +1 -0
- package/dist/components/Chip/ChipButton.js +18 -0
- package/dist/components/Chip/ChipButton.js.map +1 -0
- package/dist/components/Chip/ChipDismissible.cjs +49 -0
- package/dist/components/Chip/ChipDismissible.d.cts +9 -0
- package/dist/components/Chip/ChipDismissible.d.cts.map +1 -0
- package/dist/components/Chip/ChipDismissible.d.ts +9 -0
- package/dist/components/Chip/ChipDismissible.d.ts.map +1 -0
- package/dist/components/Chip/ChipDismissible.js +49 -0
- package/dist/components/Chip/ChipDismissible.js.map +1 -0
- package/dist/components/Chip/ChipToggle.cjs +32 -0
- package/dist/components/Chip/ChipToggle.d.cts +9 -0
- package/dist/components/Chip/ChipToggle.d.cts.map +1 -0
- package/dist/components/Chip/ChipToggle.d.ts +9 -0
- package/dist/components/Chip/ChipToggle.d.ts.map +1 -0
- package/dist/components/Chip/ChipToggle.js +32 -0
- package/dist/components/Chip/ChipToggle.js.map +1 -0
- package/dist/components/Chip/chipTheme.cjs +23 -0
- package/dist/components/Chip/chipTheme.d.cts +14 -0
- package/dist/components/Chip/chipTheme.d.cts.map +1 -0
- package/dist/components/Chip/chipTheme.d.ts +14 -0
- package/dist/components/Chip/chipTheme.d.ts.map +1 -0
- package/dist/components/Chip/chipTheme.js +24 -0
- package/dist/components/Chip/chipTheme.js.map +1 -0
- package/dist/components/Chip/index.cjs +10 -0
- package/dist/components/Chip/index.d.cts +7 -0
- package/dist/components/Chip/index.d.ts +7 -0
- package/dist/components/Chip/index.js +6 -0
- package/dist/components/Chip/types.cjs +1 -0
- package/dist/components/Chip/types.d.cts +76 -0
- package/dist/components/Chip/types.d.cts.map +1 -0
- package/dist/components/Chip/types.d.ts +76 -0
- package/dist/components/Chip/types.d.ts.map +1 -0
- package/dist/components/Chip/types.js +1 -0
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/types/dist/index.d.cts +36 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts +36 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/dist/components/Avatar.cjs +0 -116
- package/dist/components/Avatar.d.cts +0 -68
- package/dist/components/Avatar.d.cts.map +0 -1
- package/dist/components/Avatar.d.ts +0 -68
- package/dist/components/Avatar.d.ts.map +0 -1
- package/dist/components/Avatar.js +0 -116
- package/dist/components/Avatar.js.map +0 -1
- package/dist/components/Chip.cjs +0 -139
- package/dist/components/Chip.d.cts +0 -82
- package/dist/components/Chip.d.cts.map +0 -1
- package/dist/components/Chip.d.ts +0 -82
- package/dist/components/Chip.d.ts.map +0 -1
- package/dist/components/Chip.js +0 -139
- package/dist/components/Chip.js.map +0 -1
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IconSlotType } from "./IconSlot.js";
|
|
3
|
-
import * as _$react from "react";
|
|
4
|
-
import { View, ViewProps } from "react-native";
|
|
5
|
-
|
|
6
|
-
//#region src/components/Avatar.d.ts
|
|
7
|
-
/** Avatar size options */
|
|
8
|
-
type AvatarSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';
|
|
9
|
-
/** Avatar variant options */
|
|
10
|
-
type AvatarVariant = 'primary' | 'secondary';
|
|
11
|
-
/** Abbreviation strategy for generating initials */
|
|
12
|
-
type AbbreviationStrategy = 'first' | 'last' | 'firstAndLast' | 'firstTwo' | 'firstThree' | 'firstOfEach' | ((name: string) => string);
|
|
13
|
-
interface AvatarProps extends ViewProps {
|
|
14
|
-
/** Image source URL */
|
|
15
|
-
src?: string;
|
|
16
|
-
/** Alt text for the image, also used for generating initials */
|
|
17
|
-
alt?: string;
|
|
18
|
-
/** Explicit initials to display (overrides auto-generated from alt) */
|
|
19
|
-
fallback?: string;
|
|
20
|
-
/** Size of the avatar @default 'md' */
|
|
21
|
-
size?: AvatarSize;
|
|
22
|
-
/** Variant style @default 'primary' */
|
|
23
|
-
variant?: AvatarVariant;
|
|
24
|
-
/** Custom icon to display when no image or text fallback */
|
|
25
|
-
icon?: IconSlotType;
|
|
26
|
-
/** Strategy for generating initials from name @default 'firstAndLast' */
|
|
27
|
-
abbreviationStrategy?: AbbreviationStrategy;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* **Avatar component for user representation**
|
|
31
|
-
*
|
|
32
|
-
* @description
|
|
33
|
-
* Displays a user avatar with image, initials fallback, or icon fallback.
|
|
34
|
-
*
|
|
35
|
-
* @category Display
|
|
36
|
-
* @platform mobile
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* import { Avatar } from '@yahoo/uds-mobile/Avatar';
|
|
41
|
-
*
|
|
42
|
-
* // With image
|
|
43
|
-
* <Avatar
|
|
44
|
-
* src="https://example.com/photo.jpg"
|
|
45
|
-
* alt="Jane Doe"
|
|
46
|
-
* />
|
|
47
|
-
*
|
|
48
|
-
* // With initials fallback
|
|
49
|
-
* <Avatar alt="Jane Doe" />
|
|
50
|
-
*
|
|
51
|
-
* // With explicit initials
|
|
52
|
-
* <Avatar fallback="JD" />
|
|
53
|
-
*
|
|
54
|
-
* // With custom icon
|
|
55
|
-
* <Avatar icon="Person" variant="secondary" />
|
|
56
|
-
* ```
|
|
57
|
-
*
|
|
58
|
-
* @accessibility
|
|
59
|
-
* - Sets `accessibilityRole="image"` automatically
|
|
60
|
-
* - Uses `alt` prop as accessibility label
|
|
61
|
-
* - Always provide meaningful `alt` text for user identification
|
|
62
|
-
*
|
|
63
|
-
* @see {@link Image} for general image display
|
|
64
|
-
*/
|
|
65
|
-
declare const Avatar: _$react.ForwardRefExoticComponent<AvatarProps & _$react.RefAttributes<View>>;
|
|
66
|
-
//#endregion
|
|
67
|
-
export { Avatar, type AvatarProps };
|
|
68
|
-
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.ts","names":[],"sources":["../../src/components/Avatar.tsx"],"mappings":";;;;;;;KAWK,UAAA;;KAGA,aAAA;;KAGA,oBAAA,qFAOC,IAAA;AAAA,UAEI,WAAA,SAAoB,SAAA;EAff;EAiBb,GAAA;EAdgB;EAgBhB,GAAA;EAhBgB;EAkBhB,QAAA;EAfG;EAiBH,IAAA,GAAO,UAAA;;EAEP,OAAA,GAAU,aAAA;EAZM;EAchB,IAAA,GAAO,YAAA;EAZa;EAcpB,oBAAA,GAAuB,oBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;AAAoB;;;;;;;;;;;;;;;;cAoEvC,MAAA,EAAM,OAAA,CAAA,yBAAA,CAAA,WAAA,GAAA,OAAA,CAAA,aAAA,CAAA,IAAA"}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { Box } from "./Box.js";
|
|
3
|
-
import { IconSlot } from "./IconSlot.js";
|
|
4
|
-
import { Text as Text$1 } from "./Text.js";
|
|
5
|
-
import { forwardRef, useState } from "react";
|
|
6
|
-
import { Image } from "react-native";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { avatarStyles } from "../../generated/styles";
|
|
9
|
-
//#region src/components/Avatar.tsx
|
|
10
|
-
const abbreviationStrategies = {
|
|
11
|
-
first: (initials) => initials[0] ?? "",
|
|
12
|
-
last: (initials) => initials[initials.length - 1] ?? "",
|
|
13
|
-
firstAndLast: (initials) => initials.length === 1 ? initials[0] ?? "" : `${initials[0]}${initials[initials.length - 1]}`,
|
|
14
|
-
firstTwo: (initials) => initials.slice(0, 2).join(""),
|
|
15
|
-
firstThree: (initials) => initials.slice(0, 3).join(""),
|
|
16
|
-
firstOfEach: (initials) => initials.join("")
|
|
17
|
-
};
|
|
18
|
-
/** Generate initials from a name */
|
|
19
|
-
function generateInitials(name, strategy = "firstAndLast") {
|
|
20
|
-
if (!name) return "";
|
|
21
|
-
if (typeof strategy === "function") return strategy(name);
|
|
22
|
-
const initials = name.trim().split(/\s+/).map((word) => word[0]?.toUpperCase() ?? "");
|
|
23
|
-
return abbreviationStrategies[strategy](initials);
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* **Avatar component for user representation**
|
|
27
|
-
*
|
|
28
|
-
* @description
|
|
29
|
-
* Displays a user avatar with image, initials fallback, or icon fallback.
|
|
30
|
-
*
|
|
31
|
-
* @category Display
|
|
32
|
-
* @platform mobile
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```tsx
|
|
36
|
-
* import { Avatar } from '@yahoo/uds-mobile/Avatar';
|
|
37
|
-
*
|
|
38
|
-
* // With image
|
|
39
|
-
* <Avatar
|
|
40
|
-
* src="https://example.com/photo.jpg"
|
|
41
|
-
* alt="Jane Doe"
|
|
42
|
-
* />
|
|
43
|
-
*
|
|
44
|
-
* // With initials fallback
|
|
45
|
-
* <Avatar alt="Jane Doe" />
|
|
46
|
-
*
|
|
47
|
-
* // With explicit initials
|
|
48
|
-
* <Avatar fallback="JD" />
|
|
49
|
-
*
|
|
50
|
-
* // With custom icon
|
|
51
|
-
* <Avatar icon="Person" variant="secondary" />
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* @accessibility
|
|
55
|
-
* - Sets `accessibilityRole="image"` automatically
|
|
56
|
-
* - Uses `alt` prop as accessibility label
|
|
57
|
-
* - Always provide meaningful `alt` text for user identification
|
|
58
|
-
*
|
|
59
|
-
* @see {@link Image} for general image display
|
|
60
|
-
*/
|
|
61
|
-
const Avatar = forwardRef(function Avatar({ src, alt, fallback, size = "md", variant = "primary", icon, abbreviationStrategy = "firstAndLast", style, ...props }, ref) {
|
|
62
|
-
const [imageError, setImageError] = useState(false);
|
|
63
|
-
const initials = fallback || generateInitials(alt, abbreviationStrategy);
|
|
64
|
-
const hasImage = src && !imageError;
|
|
65
|
-
const hasText = initials.length > 0;
|
|
66
|
-
const showImage = hasImage;
|
|
67
|
-
const showText = !hasImage && hasText;
|
|
68
|
-
const showIcon = !hasImage && !hasText;
|
|
69
|
-
avatarStyles.useVariants({
|
|
70
|
-
size,
|
|
71
|
-
...showImage && { image: variant },
|
|
72
|
-
...showText && { text: variant },
|
|
73
|
-
...showIcon && { icon: variant }
|
|
74
|
-
});
|
|
75
|
-
return /* @__PURE__ */ jsxs(Box, {
|
|
76
|
-
ref,
|
|
77
|
-
style: [
|
|
78
|
-
avatarStyles.root,
|
|
79
|
-
{
|
|
80
|
-
alignItems: "center",
|
|
81
|
-
justifyContent: "center",
|
|
82
|
-
overflow: "hidden"
|
|
83
|
-
},
|
|
84
|
-
style
|
|
85
|
-
],
|
|
86
|
-
accessibilityRole: "image",
|
|
87
|
-
accessibilityLabel: alt,
|
|
88
|
-
...props,
|
|
89
|
-
children: [
|
|
90
|
-
showImage && /* @__PURE__ */ jsx(Image, {
|
|
91
|
-
source: { uri: src },
|
|
92
|
-
style: {
|
|
93
|
-
width: "100%",
|
|
94
|
-
height: "100%"
|
|
95
|
-
},
|
|
96
|
-
onError: () => setImageError(true),
|
|
97
|
-
accessibilityLabel: alt
|
|
98
|
-
}),
|
|
99
|
-
showText && /* @__PURE__ */ jsx(Text$1, {
|
|
100
|
-
style: avatarStyles.text,
|
|
101
|
-
numberOfLines: 1,
|
|
102
|
-
children: initials
|
|
103
|
-
}),
|
|
104
|
-
showIcon && /* @__PURE__ */ jsx(IconSlot, {
|
|
105
|
-
icon: icon ?? "Person",
|
|
106
|
-
variant: "fill",
|
|
107
|
-
style: avatarStyles.icon
|
|
108
|
-
})
|
|
109
|
-
]
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
Avatar.displayName = "Avatar";
|
|
113
|
-
//#endregion
|
|
114
|
-
export { Avatar };
|
|
115
|
-
|
|
116
|
-
//# sourceMappingURL=Avatar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","names":["RNImage","Text"],"sources":["../../src/components/Avatar.tsx"],"sourcesContent":["import { forwardRef, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport { Image as RNImage } from 'react-native';\n\nimport { avatarStyles } from '../../generated/styles';\nimport { Box } from './Box';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Text } from './Text';\n\n/** Avatar size options */\ntype AvatarSize = '2xs' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl';\n\n/** Avatar variant options */\ntype AvatarVariant = 'primary' | 'secondary';\n\n/** Abbreviation strategy for generating initials */\ntype AbbreviationStrategy =\n | 'first'\n | 'last'\n | 'firstAndLast'\n | 'firstTwo'\n | 'firstThree'\n | 'firstOfEach'\n | ((name: string) => string);\n\ninterface AvatarProps extends ViewProps {\n /** Image source URL */\n src?: string;\n /** Alt text for the image, also used for generating initials */\n alt?: string;\n /** Explicit initials to display (overrides auto-generated from alt) */\n fallback?: string;\n /** Size of the avatar @default 'md' */\n size?: AvatarSize;\n /** Variant style @default 'primary' */\n variant?: AvatarVariant;\n /** Custom icon to display when no image or text fallback */\n icon?: IconSlotType;\n /** Strategy for generating initials from name @default 'firstAndLast' */\n abbreviationStrategy?: AbbreviationStrategy;\n}\n\nconst abbreviationStrategies: Record<\n Exclude<AbbreviationStrategy, (name: string) => string>,\n (initials: string[]) => string\n> = {\n first: (initials) => initials[0] ?? '',\n last: (initials) => initials[initials.length - 1] ?? '',\n firstAndLast: (initials) =>\n initials.length === 1 ? (initials[0] ?? '') : `${initials[0]}${initials[initials.length - 1]}`,\n firstTwo: (initials) => initials.slice(0, 2).join(''),\n firstThree: (initials) => initials.slice(0, 3).join(''),\n firstOfEach: (initials) => initials.join(''),\n};\n\n/** Generate initials from a name */\nfunction generateInitials(name?: string, strategy: AbbreviationStrategy = 'firstAndLast'): string {\n if (!name) {\n return '';\n }\n\n if (typeof strategy === 'function') {\n return strategy(name);\n }\n\n const words = name.trim().split(/\\s+/);\n const initials = words.map((word) => word[0]?.toUpperCase() ?? '');\n\n return abbreviationStrategies[strategy](initials);\n}\n\n/**\n * **Avatar component for user representation**\n *\n * @description\n * Displays a user avatar with image, initials fallback, or icon fallback.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Avatar } from '@yahoo/uds-mobile/Avatar';\n *\n * // With image\n * <Avatar\n * src=\"https://example.com/photo.jpg\"\n * alt=\"Jane Doe\"\n * />\n *\n * // With initials fallback\n * <Avatar alt=\"Jane Doe\" />\n *\n * // With explicit initials\n * <Avatar fallback=\"JD\" />\n *\n * // With custom icon\n * <Avatar icon=\"Person\" variant=\"secondary\" />\n * ```\n *\n * @accessibility\n * - Sets `accessibilityRole=\"image\"` automatically\n * - Uses `alt` prop as accessibility label\n * - Always provide meaningful `alt` text for user identification\n *\n * @see {@link Image} for general image display\n */\nconst Avatar = forwardRef<View, AvatarProps>(function Avatar(\n {\n src,\n alt,\n fallback,\n size = 'md',\n variant = 'primary',\n icon,\n abbreviationStrategy = 'firstAndLast',\n style,\n ...props\n },\n ref,\n) {\n const [imageError, setImageError] = useState(false);\n\n const initials = fallback || generateInitials(alt, abbreviationStrategy);\n\n const hasImage = src && !imageError;\n const hasText = initials.length > 0;\n const showImage = hasImage;\n const showText = !hasImage && hasText;\n const showIcon = !hasImage && !hasText;\n\n avatarStyles.useVariants({\n size,\n ...(showImage && { image: variant }),\n ...(showText && { text: variant }),\n ...(showIcon && { icon: variant }),\n });\n\n return (\n <Box\n ref={ref}\n style={[\n avatarStyles.root,\n { alignItems: 'center', justifyContent: 'center', overflow: 'hidden' },\n style,\n ]}\n accessibilityRole=\"image\"\n accessibilityLabel={alt}\n {...props}\n >\n {showImage && (\n <RNImage\n source={{ uri: src }}\n style={{ width: '100%', height: '100%' }}\n onError={() => setImageError(true)}\n accessibilityLabel={alt}\n />\n )}\n\n {showText && (\n <Text style={avatarStyles.text} numberOfLines={1}>\n {initials}\n </Text>\n )}\n\n {showIcon && <IconSlot icon={icon ?? 'Person'} variant=\"fill\" style={avatarStyles.icon} />}\n </Box>\n );\n});\n\nAvatar.displayName = 'Avatar';\n\nexport { Avatar, type AvatarProps };\n"],"mappings":";;;;;;;;;AA2CA,MAAM,yBAGF;CACF,QAAQ,aAAa,SAAS,MAAM;CACpC,OAAO,aAAa,SAAS,SAAS,SAAS,MAAM;CACrD,eAAe,aACb,SAAS,WAAW,IAAK,SAAS,MAAM,KAAM,GAAG,SAAS,KAAK,SAAS,SAAS,SAAS;CAC5F,WAAW,aAAa,SAAS,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG;CACrD,aAAa,aAAa,SAAS,MAAM,GAAG,EAAE,CAAC,KAAK,GAAG;CACvD,cAAc,aAAa,SAAS,KAAK,GAAG;CAC7C;;AAGD,SAAS,iBAAiB,MAAe,WAAiC,gBAAwB;CAChG,IAAI,CAAC,MACH,OAAO;CAGT,IAAI,OAAO,aAAa,YACtB,OAAO,SAAS,KAAK;CAIvB,MAAM,WADQ,KAAK,MAAM,CAAC,MAAM,MACV,CAAC,KAAK,SAAS,KAAK,IAAI,aAAa,IAAI,GAAG;CAElE,OAAO,uBAAuB,UAAU,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCnD,MAAM,SAAS,WAA8B,SAAS,OACpD,EACE,KACA,KACA,UACA,OAAO,MACP,UAAU,WACV,MACA,uBAAuB,gBACvB,OACA,GAAG,SAEL,KACA;CACA,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CAEnD,MAAM,WAAW,YAAY,iBAAiB,KAAK,qBAAqB;CAExE,MAAM,WAAW,OAAO,CAAC;CACzB,MAAM,UAAU,SAAS,SAAS;CAClC,MAAM,YAAY;CAClB,MAAM,WAAW,CAAC,YAAY;CAC9B,MAAM,WAAW,CAAC,YAAY,CAAC;CAE/B,aAAa,YAAY;EACvB;EACA,GAAI,aAAa,EAAE,OAAO,SAAS;EACnC,GAAI,YAAY,EAAE,MAAM,SAAS;EACjC,GAAI,YAAY,EAAE,MAAM,SAAS;EAClC,CAAC;CAEF,OACE,qBAAC,KAAD;EACO;EACL,OAAO;GACL,aAAa;GACb;IAAE,YAAY;IAAU,gBAAgB;IAAU,UAAU;IAAU;GACtE;GACD;EACD,mBAAkB;EAClB,oBAAoB;EACpB,GAAI;YATN;GAWG,aACC,oBAACA,OAAD;IACE,QAAQ,EAAE,KAAK,KAAK;IACpB,OAAO;KAAE,OAAO;KAAQ,QAAQ;KAAQ;IACxC,eAAe,cAAc,KAAK;IAClC,oBAAoB;IACpB,CAAA;GAGH,YACC,oBAACC,QAAD;IAAM,OAAO,aAAa;IAAM,eAAe;cAC5C;IACI,CAAA;GAGR,YAAY,oBAAC,UAAD;IAAU,MAAM,QAAQ;IAAU,SAAQ;IAAO,OAAO,aAAa;IAAQ,CAAA;GACtF;;EAER;AAEF,OAAO,cAAc"}
|
package/dist/components/Chip.cjs
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
4
|
-
const require_components_IconSlot = require("./IconSlot.cjs");
|
|
5
|
-
const require_components_Text = require("./Text.cjs");
|
|
6
|
-
const require_components_HStack = require("./HStack.cjs");
|
|
7
|
-
const require_components_Pressable = require("./Pressable.cjs");
|
|
8
|
-
let react = require("react");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let generated_styles = require("../../generated/styles");
|
|
11
|
-
//#region src/components/Chip.tsx
|
|
12
|
-
/**
|
|
13
|
-
* **A chip component for selections, filters, or actions**
|
|
14
|
-
*
|
|
15
|
-
* @description
|
|
16
|
-
* Chips help people make selections, filter content, or trigger actions.
|
|
17
|
-
* They can be toggleable, dismissible, or simple pressable elements.
|
|
18
|
-
*
|
|
19
|
-
* @category Interactive
|
|
20
|
-
* @platform mobile
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```tsx
|
|
24
|
-
* import { Chip } from '@yahoo/uds-mobile/Chip';
|
|
25
|
-
*
|
|
26
|
-
* // Basic chip
|
|
27
|
-
* <Chip>Label</Chip>
|
|
28
|
-
*
|
|
29
|
-
* // Toggle chip
|
|
30
|
-
* <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>
|
|
31
|
-
*
|
|
32
|
-
* // Dismissible chip
|
|
33
|
-
* <Chip onDismiss={() => removeChip()}>Tag</Chip>
|
|
34
|
-
*
|
|
35
|
-
* // With icons
|
|
36
|
-
* <Chip startIcon="Star" variant="brand">Favorite</Chip>
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @usage
|
|
40
|
-
* - Filters: For multi-select filtering options
|
|
41
|
-
* - Tags: For displaying and removing tags
|
|
42
|
-
* - Actions: For quick contextual actions
|
|
43
|
-
*
|
|
44
|
-
* @accessibility
|
|
45
|
-
* - Toggle chips use `accessibilityRole="checkbox"` with checked state
|
|
46
|
-
* - Action chips use `accessibilityRole="button"`
|
|
47
|
-
* - Dismiss button has customizable `dismissButtonAriaLabel`
|
|
48
|
-
*
|
|
49
|
-
* @see {@link Badge} for non-interactive status indicators
|
|
50
|
-
* @see {@link Button} for primary actions
|
|
51
|
-
*/
|
|
52
|
-
const Chip = (0, react.memo)(function Chip({ variant = "primary", size = "md", minWidth, maxWidth = 200, startIcon, endIcon, disabled = false, isToggled = false, onPress, onToggle, onDismiss, dismissButtonAriaLabel = "Dismiss", children, style, ref, ...rest }) {
|
|
53
|
-
const isInteractive = Boolean(onPress || onToggle);
|
|
54
|
-
const isDismissible = Boolean(onDismiss);
|
|
55
|
-
const isDisabled = disabled;
|
|
56
|
-
const toggleState = isToggled ? "on" : "off";
|
|
57
|
-
generated_styles.chipStyles.useVariants({
|
|
58
|
-
size,
|
|
59
|
-
link: variant,
|
|
60
|
-
dismissible: variant,
|
|
61
|
-
toggle: toggleState
|
|
62
|
-
});
|
|
63
|
-
const handlePress = (0, react.useCallback)(() => {
|
|
64
|
-
if (isDisabled) return;
|
|
65
|
-
if (onToggle) onToggle(!isToggled);
|
|
66
|
-
else if (onPress) onPress();
|
|
67
|
-
}, [
|
|
68
|
-
isDisabled,
|
|
69
|
-
onToggle,
|
|
70
|
-
isToggled,
|
|
71
|
-
onPress
|
|
72
|
-
]);
|
|
73
|
-
const handleDismiss = (0, react.useCallback)(() => {
|
|
74
|
-
if (isDisabled) return;
|
|
75
|
-
onDismiss?.();
|
|
76
|
-
}, [isDisabled, onDismiss]);
|
|
77
|
-
const content = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
78
|
-
startIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
79
|
-
icon: startIcon,
|
|
80
|
-
variant: "fill",
|
|
81
|
-
style: generated_styles.chipStyles.icon
|
|
82
|
-
}),
|
|
83
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
84
|
-
numberOfLines: 1,
|
|
85
|
-
textAlign: "center",
|
|
86
|
-
flexShrink: "1",
|
|
87
|
-
style: generated_styles.chipStyles.text,
|
|
88
|
-
children
|
|
89
|
-
}),
|
|
90
|
-
isDismissible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Pressable.Pressable, {
|
|
91
|
-
onPress: isDisabled ? void 0 : handleDismiss,
|
|
92
|
-
disabled: isDisabled,
|
|
93
|
-
accessibilityLabel: dismissButtonAriaLabel,
|
|
94
|
-
accessibilityRole: "button",
|
|
95
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
96
|
-
icon: endIcon ?? "Cross",
|
|
97
|
-
variant: "fill",
|
|
98
|
-
style: generated_styles.chipStyles.icon
|
|
99
|
-
})
|
|
100
|
-
}) : endIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
101
|
-
icon: endIcon,
|
|
102
|
-
variant: "fill",
|
|
103
|
-
style: generated_styles.chipStyles.icon
|
|
104
|
-
})
|
|
105
|
-
] });
|
|
106
|
-
const a11yState = {
|
|
107
|
-
disabled: isDisabled,
|
|
108
|
-
checked: onToggle ? isToggled : void 0
|
|
109
|
-
};
|
|
110
|
-
const sharedProps = {
|
|
111
|
-
ref,
|
|
112
|
-
style: (0, react.useMemo)(() => [generated_styles.chipStyles.root, style], [generated_styles.chipStyles.root, style]),
|
|
113
|
-
flexDirection: "row",
|
|
114
|
-
alignItems: "center",
|
|
115
|
-
overflow: "hidden",
|
|
116
|
-
alignSelf: "flex-start",
|
|
117
|
-
maxWidth,
|
|
118
|
-
minWidth,
|
|
119
|
-
disabled: isDisabled,
|
|
120
|
-
opacity: isDisabled ? .5 : void 0,
|
|
121
|
-
accessibilityState: a11yState,
|
|
122
|
-
...rest
|
|
123
|
-
};
|
|
124
|
-
if (isInteractive) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Pressable.Pressable, {
|
|
125
|
-
onPress: handlePress,
|
|
126
|
-
accessibilityRole: onToggle ? "checkbox" : "button",
|
|
127
|
-
...sharedProps,
|
|
128
|
-
children: content
|
|
129
|
-
});
|
|
130
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_HStack.HStack, {
|
|
131
|
-
accessibilityRole: isDismissible ? "button" : void 0,
|
|
132
|
-
...sharedProps,
|
|
133
|
-
...rest,
|
|
134
|
-
children: content
|
|
135
|
-
});
|
|
136
|
-
});
|
|
137
|
-
Chip.displayName = "Chip";
|
|
138
|
-
//#endregion
|
|
139
|
-
exports.Chip = Chip;
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { ChipSize, ChipVariant } from "../types/dist/index.cjs";
|
|
3
|
-
import { IconSlotType } from "./IconSlot.cjs";
|
|
4
|
-
import * as _$react from "react";
|
|
5
|
-
import { Ref } from "react";
|
|
6
|
-
import { View, ViewProps } from "react-native";
|
|
7
|
-
|
|
8
|
-
//#region src/components/Chip.d.ts
|
|
9
|
-
interface ChipProps extends Omit<ViewProps, 'children'> {
|
|
10
|
-
/** Ref to the underlying View */
|
|
11
|
-
ref?: Ref<View>;
|
|
12
|
-
/** The visual style variant @default 'primary' */
|
|
13
|
-
variant?: ChipVariant;
|
|
14
|
-
/** The size of the chip @default 'md' */
|
|
15
|
-
size?: ChipSize;
|
|
16
|
-
/** Minimum width of the chip in pixels */
|
|
17
|
-
minWidth?: number;
|
|
18
|
-
/** Maximum width of the chip in pixels @default 200 */
|
|
19
|
-
maxWidth?: number;
|
|
20
|
-
/** Icon displayed at the start of the chip */
|
|
21
|
-
startIcon?: IconSlotType;
|
|
22
|
-
/** Icon displayed at the end of the chip */
|
|
23
|
-
endIcon?: IconSlotType;
|
|
24
|
-
/** Whether the chip is disabled */
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
/** Called when the chip is pressed. Makes the chip interactive. */
|
|
27
|
-
onPress?: () => void;
|
|
28
|
-
/** Whether the chip is toggled/selected. */
|
|
29
|
-
isToggled?: boolean;
|
|
30
|
-
/** Called when the chip toggle state changes. */
|
|
31
|
-
onToggle?: (toggled: boolean) => void;
|
|
32
|
-
/** Called when the dismiss button is pressed. Shows a dismiss icon. */
|
|
33
|
-
onDismiss?: () => void;
|
|
34
|
-
/** Accessibility label for the dismiss button. */
|
|
35
|
-
dismissButtonAriaLabel?: string;
|
|
36
|
-
/** Chip label content */
|
|
37
|
-
children?: React.ReactNode;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* **A chip component for selections, filters, or actions**
|
|
41
|
-
*
|
|
42
|
-
* @description
|
|
43
|
-
* Chips help people make selections, filter content, or trigger actions.
|
|
44
|
-
* They can be toggleable, dismissible, or simple pressable elements.
|
|
45
|
-
*
|
|
46
|
-
* @category Interactive
|
|
47
|
-
* @platform mobile
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```tsx
|
|
51
|
-
* import { Chip } from '@yahoo/uds-mobile/Chip';
|
|
52
|
-
*
|
|
53
|
-
* // Basic chip
|
|
54
|
-
* <Chip>Label</Chip>
|
|
55
|
-
*
|
|
56
|
-
* // Toggle chip
|
|
57
|
-
* <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>
|
|
58
|
-
*
|
|
59
|
-
* // Dismissible chip
|
|
60
|
-
* <Chip onDismiss={() => removeChip()}>Tag</Chip>
|
|
61
|
-
*
|
|
62
|
-
* // With icons
|
|
63
|
-
* <Chip startIcon="Star" variant="brand">Favorite</Chip>
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @usage
|
|
67
|
-
* - Filters: For multi-select filtering options
|
|
68
|
-
* - Tags: For displaying and removing tags
|
|
69
|
-
* - Actions: For quick contextual actions
|
|
70
|
-
*
|
|
71
|
-
* @accessibility
|
|
72
|
-
* - Toggle chips use `accessibilityRole="checkbox"` with checked state
|
|
73
|
-
* - Action chips use `accessibilityRole="button"`
|
|
74
|
-
* - Dismiss button has customizable `dismissButtonAriaLabel`
|
|
75
|
-
*
|
|
76
|
-
* @see {@link Badge} for non-interactive status indicators
|
|
77
|
-
* @see {@link Button} for primary actions
|
|
78
|
-
*/
|
|
79
|
-
declare const Chip: _$react.NamedExoticComponent<ChipProps>;
|
|
80
|
-
//#endregion
|
|
81
|
-
export { Chip, type ChipProps };
|
|
82
|
-
//# sourceMappingURL=Chip.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.cts","names":[],"sources":["../../src/components/Chip.tsx"],"mappings":";;;;;;;;UAYU,SAAA,SAAkB,IAAA,CAAK,SAAA;;EAE/B,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,OAAA,GAAU,WAAA;;EAEV,IAAA,GAAO,QAAA;EAJG;EAMV,QAAA;EAJU;EAMV,QAAA;EAEY;EAAZ,SAAA,GAAY,YAAA;EAgBD;EAdX,OAAA,GAAU,YAAA;EAdoB;EAgB9B,QAAA;EAhB0B;EAkB1B,OAAA;EAhBA;EAkBA,SAAA;EAlBU;EAoBV,QAAA,IAAY,OAAA;EAlBF;EAoBV,SAAA;EAlBO;EAoBP,sBAAA;EAhBA;EAkBA,QAAA,GAAW,KAAA,CAAM,SAAA;AAAA;;;;;;;;;;;;;;;AAAS;;;;;;;;;;;;;;;;;;;;;;;;;;cA2CtB,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA"}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { ChipSize, ChipVariant } from "../types/dist/index.js";
|
|
3
|
-
import { IconSlotType } from "./IconSlot.js";
|
|
4
|
-
import * as _$react from "react";
|
|
5
|
-
import { Ref } from "react";
|
|
6
|
-
import { View, ViewProps } from "react-native";
|
|
7
|
-
|
|
8
|
-
//#region src/components/Chip.d.ts
|
|
9
|
-
interface ChipProps extends Omit<ViewProps, 'children'> {
|
|
10
|
-
/** Ref to the underlying View */
|
|
11
|
-
ref?: Ref<View>;
|
|
12
|
-
/** The visual style variant @default 'primary' */
|
|
13
|
-
variant?: ChipVariant;
|
|
14
|
-
/** The size of the chip @default 'md' */
|
|
15
|
-
size?: ChipSize;
|
|
16
|
-
/** Minimum width of the chip in pixels */
|
|
17
|
-
minWidth?: number;
|
|
18
|
-
/** Maximum width of the chip in pixels @default 200 */
|
|
19
|
-
maxWidth?: number;
|
|
20
|
-
/** Icon displayed at the start of the chip */
|
|
21
|
-
startIcon?: IconSlotType;
|
|
22
|
-
/** Icon displayed at the end of the chip */
|
|
23
|
-
endIcon?: IconSlotType;
|
|
24
|
-
/** Whether the chip is disabled */
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
/** Called when the chip is pressed. Makes the chip interactive. */
|
|
27
|
-
onPress?: () => void;
|
|
28
|
-
/** Whether the chip is toggled/selected. */
|
|
29
|
-
isToggled?: boolean;
|
|
30
|
-
/** Called when the chip toggle state changes. */
|
|
31
|
-
onToggle?: (toggled: boolean) => void;
|
|
32
|
-
/** Called when the dismiss button is pressed. Shows a dismiss icon. */
|
|
33
|
-
onDismiss?: () => void;
|
|
34
|
-
/** Accessibility label for the dismiss button. */
|
|
35
|
-
dismissButtonAriaLabel?: string;
|
|
36
|
-
/** Chip label content */
|
|
37
|
-
children?: React.ReactNode;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* **A chip component for selections, filters, or actions**
|
|
41
|
-
*
|
|
42
|
-
* @description
|
|
43
|
-
* Chips help people make selections, filter content, or trigger actions.
|
|
44
|
-
* They can be toggleable, dismissible, or simple pressable elements.
|
|
45
|
-
*
|
|
46
|
-
* @category Interactive
|
|
47
|
-
* @platform mobile
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```tsx
|
|
51
|
-
* import { Chip } from '@yahoo/uds-mobile/Chip';
|
|
52
|
-
*
|
|
53
|
-
* // Basic chip
|
|
54
|
-
* <Chip>Label</Chip>
|
|
55
|
-
*
|
|
56
|
-
* // Toggle chip
|
|
57
|
-
* <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>
|
|
58
|
-
*
|
|
59
|
-
* // Dismissible chip
|
|
60
|
-
* <Chip onDismiss={() => removeChip()}>Tag</Chip>
|
|
61
|
-
*
|
|
62
|
-
* // With icons
|
|
63
|
-
* <Chip startIcon="Star" variant="brand">Favorite</Chip>
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @usage
|
|
67
|
-
* - Filters: For multi-select filtering options
|
|
68
|
-
* - Tags: For displaying and removing tags
|
|
69
|
-
* - Actions: For quick contextual actions
|
|
70
|
-
*
|
|
71
|
-
* @accessibility
|
|
72
|
-
* - Toggle chips use `accessibilityRole="checkbox"` with checked state
|
|
73
|
-
* - Action chips use `accessibilityRole="button"`
|
|
74
|
-
* - Dismiss button has customizable `dismissButtonAriaLabel`
|
|
75
|
-
*
|
|
76
|
-
* @see {@link Badge} for non-interactive status indicators
|
|
77
|
-
* @see {@link Button} for primary actions
|
|
78
|
-
*/
|
|
79
|
-
declare const Chip: _$react.NamedExoticComponent<ChipProps>;
|
|
80
|
-
//#endregion
|
|
81
|
-
export { Chip, type ChipProps };
|
|
82
|
-
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","names":[],"sources":["../../src/components/Chip.tsx"],"mappings":";;;;;;;;UAYU,SAAA,SAAkB,IAAA,CAAK,SAAA;;EAE/B,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,OAAA,GAAU,WAAA;;EAEV,IAAA,GAAO,QAAA;EAJG;EAMV,QAAA;EAJU;EAMV,QAAA;EAEY;EAAZ,SAAA,GAAY,YAAA;EAgBD;EAdX,OAAA,GAAU,YAAA;EAdoB;EAgB9B,QAAA;EAhB0B;EAkB1B,OAAA;EAhBA;EAkBA,SAAA;EAlBU;EAoBV,QAAA,IAAY,OAAA;EAlBF;EAoBV,SAAA;EAlBO;EAoBP,sBAAA;EAhBA;EAkBA,QAAA,GAAW,KAAA,CAAM,SAAA;AAAA;;;;;;;;;;;;;;;AAAS;;;;;;;;;;;;;;;;;;;;;;;;;;cA2CtB,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA"}
|
package/dist/components/Chip.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { IconSlot } from "./IconSlot.js";
|
|
3
|
-
import { Text } from "./Text.js";
|
|
4
|
-
import { HStack } from "./HStack.js";
|
|
5
|
-
import { Pressable } from "./Pressable.js";
|
|
6
|
-
import { memo, useCallback, useMemo } from "react";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
-
import { chipStyles } from "../../generated/styles";
|
|
9
|
-
//#region src/components/Chip.tsx
|
|
10
|
-
/**
|
|
11
|
-
* **A chip component for selections, filters, or actions**
|
|
12
|
-
*
|
|
13
|
-
* @description
|
|
14
|
-
* Chips help people make selections, filter content, or trigger actions.
|
|
15
|
-
* They can be toggleable, dismissible, or simple pressable elements.
|
|
16
|
-
*
|
|
17
|
-
* @category Interactive
|
|
18
|
-
* @platform mobile
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* import { Chip } from '@yahoo/uds-mobile/Chip';
|
|
23
|
-
*
|
|
24
|
-
* // Basic chip
|
|
25
|
-
* <Chip>Label</Chip>
|
|
26
|
-
*
|
|
27
|
-
* // Toggle chip
|
|
28
|
-
* <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>
|
|
29
|
-
*
|
|
30
|
-
* // Dismissible chip
|
|
31
|
-
* <Chip onDismiss={() => removeChip()}>Tag</Chip>
|
|
32
|
-
*
|
|
33
|
-
* // With icons
|
|
34
|
-
* <Chip startIcon="Star" variant="brand">Favorite</Chip>
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @usage
|
|
38
|
-
* - Filters: For multi-select filtering options
|
|
39
|
-
* - Tags: For displaying and removing tags
|
|
40
|
-
* - Actions: For quick contextual actions
|
|
41
|
-
*
|
|
42
|
-
* @accessibility
|
|
43
|
-
* - Toggle chips use `accessibilityRole="checkbox"` with checked state
|
|
44
|
-
* - Action chips use `accessibilityRole="button"`
|
|
45
|
-
* - Dismiss button has customizable `dismissButtonAriaLabel`
|
|
46
|
-
*
|
|
47
|
-
* @see {@link Badge} for non-interactive status indicators
|
|
48
|
-
* @see {@link Button} for primary actions
|
|
49
|
-
*/
|
|
50
|
-
const Chip = memo(function Chip({ variant = "primary", size = "md", minWidth, maxWidth = 200, startIcon, endIcon, disabled = false, isToggled = false, onPress, onToggle, onDismiss, dismissButtonAriaLabel = "Dismiss", children, style, ref, ...rest }) {
|
|
51
|
-
const isInteractive = Boolean(onPress || onToggle);
|
|
52
|
-
const isDismissible = Boolean(onDismiss);
|
|
53
|
-
const isDisabled = disabled;
|
|
54
|
-
const toggleState = isToggled ? "on" : "off";
|
|
55
|
-
chipStyles.useVariants({
|
|
56
|
-
size,
|
|
57
|
-
link: variant,
|
|
58
|
-
dismissible: variant,
|
|
59
|
-
toggle: toggleState
|
|
60
|
-
});
|
|
61
|
-
const handlePress = useCallback(() => {
|
|
62
|
-
if (isDisabled) return;
|
|
63
|
-
if (onToggle) onToggle(!isToggled);
|
|
64
|
-
else if (onPress) onPress();
|
|
65
|
-
}, [
|
|
66
|
-
isDisabled,
|
|
67
|
-
onToggle,
|
|
68
|
-
isToggled,
|
|
69
|
-
onPress
|
|
70
|
-
]);
|
|
71
|
-
const handleDismiss = useCallback(() => {
|
|
72
|
-
if (isDisabled) return;
|
|
73
|
-
onDismiss?.();
|
|
74
|
-
}, [isDisabled, onDismiss]);
|
|
75
|
-
const content = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
76
|
-
startIcon && /* @__PURE__ */ jsx(IconSlot, {
|
|
77
|
-
icon: startIcon,
|
|
78
|
-
variant: "fill",
|
|
79
|
-
style: chipStyles.icon
|
|
80
|
-
}),
|
|
81
|
-
/* @__PURE__ */ jsx(Text, {
|
|
82
|
-
numberOfLines: 1,
|
|
83
|
-
textAlign: "center",
|
|
84
|
-
flexShrink: "1",
|
|
85
|
-
style: chipStyles.text,
|
|
86
|
-
children
|
|
87
|
-
}),
|
|
88
|
-
isDismissible ? /* @__PURE__ */ jsx(Pressable, {
|
|
89
|
-
onPress: isDisabled ? void 0 : handleDismiss,
|
|
90
|
-
disabled: isDisabled,
|
|
91
|
-
accessibilityLabel: dismissButtonAriaLabel,
|
|
92
|
-
accessibilityRole: "button",
|
|
93
|
-
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
94
|
-
icon: endIcon ?? "Cross",
|
|
95
|
-
variant: "fill",
|
|
96
|
-
style: chipStyles.icon
|
|
97
|
-
})
|
|
98
|
-
}) : endIcon && /* @__PURE__ */ jsx(IconSlot, {
|
|
99
|
-
icon: endIcon,
|
|
100
|
-
variant: "fill",
|
|
101
|
-
style: chipStyles.icon
|
|
102
|
-
})
|
|
103
|
-
] });
|
|
104
|
-
const a11yState = {
|
|
105
|
-
disabled: isDisabled,
|
|
106
|
-
checked: onToggle ? isToggled : void 0
|
|
107
|
-
};
|
|
108
|
-
const sharedProps = {
|
|
109
|
-
ref,
|
|
110
|
-
style: useMemo(() => [chipStyles.root, style], [chipStyles.root, style]),
|
|
111
|
-
flexDirection: "row",
|
|
112
|
-
alignItems: "center",
|
|
113
|
-
overflow: "hidden",
|
|
114
|
-
alignSelf: "flex-start",
|
|
115
|
-
maxWidth,
|
|
116
|
-
minWidth,
|
|
117
|
-
disabled: isDisabled,
|
|
118
|
-
opacity: isDisabled ? .5 : void 0,
|
|
119
|
-
accessibilityState: a11yState,
|
|
120
|
-
...rest
|
|
121
|
-
};
|
|
122
|
-
if (isInteractive) return /* @__PURE__ */ jsx(Pressable, {
|
|
123
|
-
onPress: handlePress,
|
|
124
|
-
accessibilityRole: onToggle ? "checkbox" : "button",
|
|
125
|
-
...sharedProps,
|
|
126
|
-
children: content
|
|
127
|
-
});
|
|
128
|
-
return /* @__PURE__ */ jsx(HStack, {
|
|
129
|
-
accessibilityRole: isDismissible ? "button" : void 0,
|
|
130
|
-
...sharedProps,
|
|
131
|
-
...rest,
|
|
132
|
-
children: content
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
Chip.displayName = "Chip";
|
|
136
|
-
//#endregion
|
|
137
|
-
export { Chip };
|
|
138
|
-
|
|
139
|
-
//# sourceMappingURL=Chip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","names":[],"sources":["../../src/components/Chip.tsx"],"sourcesContent":["import type { ChipSize, ChipVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useMemo } from 'react';\nimport type { View, ViewProps } from 'react-native';\n\nimport { chipStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\ninterface ChipProps extends Omit<ViewProps, 'children'> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** The visual style variant @default 'primary' */\n variant?: ChipVariant;\n /** The size of the chip @default 'md' */\n size?: ChipSize;\n /** Minimum width of the chip in pixels */\n minWidth?: number;\n /** Maximum width of the chip in pixels @default 200 */\n maxWidth?: number;\n /** Icon displayed at the start of the chip */\n startIcon?: IconSlotType;\n /** Icon displayed at the end of the chip */\n endIcon?: IconSlotType;\n /** Whether the chip is disabled */\n disabled?: boolean;\n /** Called when the chip is pressed. Makes the chip interactive. */\n onPress?: () => void;\n /** Whether the chip is toggled/selected. */\n isToggled?: boolean;\n /** Called when the chip toggle state changes. */\n onToggle?: (toggled: boolean) => void;\n /** Called when the dismiss button is pressed. Shows a dismiss icon. */\n onDismiss?: () => void;\n /** Accessibility label for the dismiss button. */\n dismissButtonAriaLabel?: string;\n /** Chip label content */\n children?: React.ReactNode;\n}\n\n/**\n * **A chip component for selections, filters, or actions**\n *\n * @description\n * Chips help people make selections, filter content, or trigger actions.\n * They can be toggleable, dismissible, or simple pressable elements.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Chip } from '@yahoo/uds-mobile/Chip';\n *\n * // Basic chip\n * <Chip>Label</Chip>\n *\n * // Toggle chip\n * <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>\n *\n * // Dismissible chip\n * <Chip onDismiss={() => removeChip()}>Tag</Chip>\n *\n * // With icons\n * <Chip startIcon=\"Star\" variant=\"brand\">Favorite</Chip>\n * ```\n *\n * @usage\n * - Filters: For multi-select filtering options\n * - Tags: For displaying and removing tags\n * - Actions: For quick contextual actions\n *\n * @accessibility\n * - Toggle chips use `accessibilityRole=\"checkbox\"` with checked state\n * - Action chips use `accessibilityRole=\"button\"`\n * - Dismiss button has customizable `dismissButtonAriaLabel`\n *\n * @see {@link Badge} for non-interactive status indicators\n * @see {@link Button} for primary actions\n */\nconst Chip = memo(function Chip({\n variant = 'primary',\n size = 'md',\n minWidth,\n maxWidth = 200,\n startIcon,\n endIcon,\n disabled = false,\n isToggled = false,\n onPress,\n onToggle,\n onDismiss,\n dismissButtonAriaLabel = 'Dismiss',\n children,\n style,\n ref,\n ...rest\n}: ChipProps) {\n const isInteractive = Boolean(onPress || onToggle);\n const isDismissible = Boolean(onDismiss);\n const isDisabled = disabled;\n // Determine which variant type to use for styling\n const toggleState = isToggled ? 'on' : 'off';\n\n // Apply layer-based styles\n // Note: Chip doesn't have disabled variants in theme - handled via opacity\n // Note: pressed state is applied dynamically via Pressable's style callback\n chipStyles.useVariants({\n size,\n link: variant,\n dismissible: variant,\n toggle: toggleState,\n });\n\n const handlePress = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (onToggle) {\n onToggle(!isToggled);\n } else if (onPress) {\n onPress();\n }\n }, [isDisabled, onToggle, isToggled, onPress]);\n\n const handleDismiss = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onDismiss?.();\n }, [isDisabled, onDismiss]);\n\n const content = (\n <>\n {startIcon && <IconSlot icon={startIcon} variant=\"fill\" style={chipStyles.icon} />}\n <Text numberOfLines={1} textAlign=\"center\" flexShrink=\"1\" style={chipStyles.text}>\n {children}\n </Text>\n {isDismissible ? (\n <Pressable\n onPress={isDisabled ? undefined : handleDismiss}\n disabled={isDisabled}\n accessibilityLabel={dismissButtonAriaLabel}\n accessibilityRole=\"button\"\n >\n <IconSlot icon={endIcon ?? 'Cross'} variant=\"fill\" style={chipStyles.icon} />\n </Pressable>\n ) : (\n endIcon && <IconSlot icon={endIcon} variant=\"fill\" style={chipStyles.icon} />\n )}\n </>\n );\n\n const a11yState = {\n disabled: isDisabled,\n checked: onToggle ? isToggled : undefined,\n };\n\n const rootStyles = useMemo(() => [chipStyles.root, style], [chipStyles.root, style]);\n const sharedProps = {\n ref,\n style: rootStyles,\n flexDirection: 'row',\n alignItems: 'center',\n overflow: 'hidden',\n alignSelf: 'flex-start',\n maxWidth,\n minWidth,\n disabled: isDisabled,\n opacity: isDisabled ? 0.5 : undefined,\n accessibilityState: a11yState,\n ...rest,\n } as const;\n\n // Interactive chip (toggle or button)\n if (isInteractive) {\n return (\n <Pressable\n onPress={handlePress}\n accessibilityRole={onToggle ? 'checkbox' : 'button'}\n {...sharedProps}\n >\n {content}\n </Pressable>\n );\n }\n\n // Non-interactive chip (display only or dismissible)\n return (\n <HStack accessibilityRole={isDismissible ? 'button' : undefined} {...sharedProps} {...rest}>\n {content}\n </HStack>\n );\n});\n\nChip.displayName = 'Chip';\n\nexport { Chip, type ChipProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,MAAM,OAAO,KAAK,SAAS,KAAK,EAC9B,UAAU,WACV,OAAO,MACP,UACA,WAAW,KACX,WACA,SACA,WAAW,OACX,YAAY,OACZ,SACA,UACA,WACA,yBAAyB,WACzB,UACA,OACA,KACA,GAAG,QACS;CACZ,MAAM,gBAAgB,QAAQ,WAAW,SAAS;CAClD,MAAM,gBAAgB,QAAQ,UAAU;CACxC,MAAM,aAAa;CAEnB,MAAM,cAAc,YAAY,OAAO;CAKvC,WAAW,YAAY;EACrB;EACA,MAAM;EACN,aAAa;EACb,QAAQ;EACT,CAAC;CAEF,MAAM,cAAc,kBAAkB;EACpC,IAAI,YACF;EAGF,IAAI,UACF,SAAS,CAAC,UAAU;OACf,IAAI,SACT,SAAS;IAEV;EAAC;EAAY;EAAU;EAAW;EAAQ,CAAC;CAE9C,MAAM,gBAAgB,kBAAkB;EACtC,IAAI,YACF;EAEF,aAAa;IACZ,CAAC,YAAY,UAAU,CAAC;CAE3B,MAAM,UACJ,qBAAA,UAAA,EAAA,UAAA;EACG,aAAa,oBAAC,UAAD;GAAU,MAAM;GAAW,SAAQ;GAAO,OAAO,WAAW;GAAQ,CAAA;EAClF,oBAAC,MAAD;GAAM,eAAe;GAAG,WAAU;GAAS,YAAW;GAAI,OAAO,WAAW;GACzE;GACI,CAAA;EACN,gBACC,oBAAC,WAAD;GACE,SAAS,aAAa,KAAA,IAAY;GAClC,UAAU;GACV,oBAAoB;GACpB,mBAAkB;aAElB,oBAAC,UAAD;IAAU,MAAM,WAAW;IAAS,SAAQ;IAAO,OAAO,WAAW;IAAQ,CAAA;GACnE,CAAA,GAEZ,WAAW,oBAAC,UAAD;GAAU,MAAM;GAAS,SAAQ;GAAO,OAAO,WAAW;GAAQ,CAAA;EAE9E,EAAA,CAAA;CAGL,MAAM,YAAY;EAChB,UAAU;EACV,SAAS,WAAW,YAAY,KAAA;EACjC;CAGD,MAAM,cAAc;EAClB;EACA,OAHiB,cAAc,CAAC,WAAW,MAAM,MAAM,EAAE,CAAC,WAAW,MAAM,MAAM,CAGhE;EACjB,eAAe;EACf,YAAY;EACZ,UAAU;EACV,WAAW;EACX;EACA;EACA,UAAU;EACV,SAAS,aAAa,KAAM,KAAA;EAC5B,oBAAoB;EACpB,GAAG;EACJ;CAGD,IAAI,eACF,OACE,oBAAC,WAAD;EACE,SAAS;EACT,mBAAmB,WAAW,aAAa;EAC3C,GAAI;YAEH;EACS,CAAA;CAKhB,OACE,oBAAC,QAAD;EAAQ,mBAAmB,gBAAgB,WAAW,KAAA;EAAW,GAAI;EAAa,GAAI;YACnF;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
|