@yahoo/uds-mobile 2.13.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/README.md +3 -1
- 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/components/{Radio.cjs → Radio/Radio.cjs} +32 -10
- package/dist/components/{Radio.d.cts → Radio/Radio.d.cts} +2 -2
- package/dist/components/Radio/Radio.d.cts.map +1 -0
- package/dist/components/{Radio.d.ts → Radio/Radio.d.ts} +2 -2
- package/dist/components/Radio/Radio.d.ts.map +1 -0
- package/dist/components/{Radio.js → Radio/Radio.js} +32 -10
- package/dist/components/Radio/Radio.js.map +1 -0
- package/dist/components/Radio/RadioGroup.cjs +84 -0
- package/dist/components/Radio/RadioGroup.d.cts +52 -0
- package/dist/components/Radio/RadioGroup.d.cts.map +1 -0
- package/dist/components/Radio/RadioGroup.d.ts +52 -0
- package/dist/components/Radio/RadioGroup.d.ts.map +1 -0
- package/dist/components/Radio/RadioGroup.js +84 -0
- package/dist/components/Radio/RadioGroup.js.map +1 -0
- package/dist/components/Radio/RadioGroupContext.cjs +12 -0
- package/dist/components/Radio/RadioGroupContext.d.cts +20 -0
- package/dist/components/Radio/RadioGroupContext.d.cts.map +1 -0
- package/dist/components/Radio/RadioGroupContext.d.ts +20 -0
- package/dist/components/Radio/RadioGroupContext.d.ts.map +1 -0
- package/dist/components/Radio/RadioGroupContext.js +11 -0
- package/dist/components/Radio/RadioGroupContext.js.map +1 -0
- package/dist/components/Radio/index.cjs +6 -0
- package/dist/components/Radio/index.d.cts +4 -0
- package/dist/components/Radio/index.d.ts +4 -0
- package/dist/components/Radio/index.js +4 -0
- package/dist/types/dist/index.d.cts +49 -2
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts +49 -2
- package/dist/types/dist/index.d.ts.map +1 -1
- package/package.json +23 -13
- 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
- package/dist/components/Radio.d.cts.map +0 -1
- package/dist/components/Radio.d.ts.map +0 -1
- package/dist/components/Radio.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yahoo/uds-mobile",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"uds-mobile": "./cli/uds-mobile.js"
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
"./Avatar": {
|
|
24
24
|
"import": {
|
|
25
|
-
"types": "./dist/components/Avatar.d.ts",
|
|
26
|
-
"default": "./dist/components/Avatar.js"
|
|
25
|
+
"types": "./dist/components/Avatar/index.d.ts",
|
|
26
|
+
"default": "./dist/components/Avatar/index.js"
|
|
27
27
|
},
|
|
28
28
|
"require": {
|
|
29
|
-
"types": "./dist/components/Avatar.d.cts",
|
|
30
|
-
"default": "./dist/components/Avatar.cjs"
|
|
29
|
+
"types": "./dist/components/Avatar/index.d.cts",
|
|
30
|
+
"default": "./dist/components/Avatar/index.cjs"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"./Badge": {
|
|
@@ -102,12 +102,12 @@
|
|
|
102
102
|
},
|
|
103
103
|
"./Chip": {
|
|
104
104
|
"import": {
|
|
105
|
-
"types": "./dist/components/Chip.d.ts",
|
|
106
|
-
"default": "./dist/components/Chip.js"
|
|
105
|
+
"types": "./dist/components/Chip/index.d.ts",
|
|
106
|
+
"default": "./dist/components/Chip/index.js"
|
|
107
107
|
},
|
|
108
108
|
"require": {
|
|
109
|
-
"types": "./dist/components/Chip.d.cts",
|
|
110
|
-
"default": "./dist/components/Chip.cjs"
|
|
109
|
+
"types": "./dist/components/Chip/index.d.cts",
|
|
110
|
+
"default": "./dist/components/Chip/index.cjs"
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"./Divider": {
|
|
@@ -212,12 +212,22 @@
|
|
|
212
212
|
},
|
|
213
213
|
"./Radio": {
|
|
214
214
|
"import": {
|
|
215
|
-
"types": "./dist/components/Radio.d.ts",
|
|
216
|
-
"default": "./dist/components/Radio.js"
|
|
215
|
+
"types": "./dist/components/Radio/Radio.d.ts",
|
|
216
|
+
"default": "./dist/components/Radio/Radio.js"
|
|
217
217
|
},
|
|
218
218
|
"require": {
|
|
219
|
-
"types": "./dist/components/Radio.d.cts",
|
|
220
|
-
"default": "./dist/components/Radio.cjs"
|
|
219
|
+
"types": "./dist/components/Radio/Radio.d.cts",
|
|
220
|
+
"default": "./dist/components/Radio/Radio.cjs"
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
"./RadioGroup": {
|
|
224
|
+
"import": {
|
|
225
|
+
"types": "./dist/components/Radio/RadioGroup.d.ts",
|
|
226
|
+
"default": "./dist/components/Radio/RadioGroup.js"
|
|
227
|
+
},
|
|
228
|
+
"require": {
|
|
229
|
+
"types": "./dist/components/Radio/RadioGroup.d.cts",
|
|
230
|
+
"default": "./dist/components/Radio/RadioGroup.cjs"
|
|
221
231
|
}
|
|
222
232
|
},
|
|
223
233
|
"./Screen": {
|
|
@@ -1,116 +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_Box = require("./Box.cjs");
|
|
5
|
-
const require_components_IconSlot = require("./IconSlot.cjs");
|
|
6
|
-
const require_components_Text = require("./Text.cjs");
|
|
7
|
-
let react = require("react");
|
|
8
|
-
let react_native = require("react-native");
|
|
9
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
|
-
let generated_styles = require("../../generated/styles");
|
|
11
|
-
//#region src/components/Avatar.tsx
|
|
12
|
-
const abbreviationStrategies = {
|
|
13
|
-
first: (initials) => initials[0] ?? "",
|
|
14
|
-
last: (initials) => initials[initials.length - 1] ?? "",
|
|
15
|
-
firstAndLast: (initials) => initials.length === 1 ? initials[0] ?? "" : `${initials[0]}${initials[initials.length - 1]}`,
|
|
16
|
-
firstTwo: (initials) => initials.slice(0, 2).join(""),
|
|
17
|
-
firstThree: (initials) => initials.slice(0, 3).join(""),
|
|
18
|
-
firstOfEach: (initials) => initials.join("")
|
|
19
|
-
};
|
|
20
|
-
/** Generate initials from a name */
|
|
21
|
-
function generateInitials(name, strategy = "firstAndLast") {
|
|
22
|
-
if (!name) return "";
|
|
23
|
-
if (typeof strategy === "function") return strategy(name);
|
|
24
|
-
const initials = name.trim().split(/\s+/).map((word) => word[0]?.toUpperCase() ?? "");
|
|
25
|
-
return abbreviationStrategies[strategy](initials);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* **Avatar component for user representation**
|
|
29
|
-
*
|
|
30
|
-
* @description
|
|
31
|
-
* Displays a user avatar with image, initials fallback, or icon fallback.
|
|
32
|
-
*
|
|
33
|
-
* @category Display
|
|
34
|
-
* @platform mobile
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* ```tsx
|
|
38
|
-
* import { Avatar } from '@yahoo/uds-mobile/Avatar';
|
|
39
|
-
*
|
|
40
|
-
* // With image
|
|
41
|
-
* <Avatar
|
|
42
|
-
* src="https://example.com/photo.jpg"
|
|
43
|
-
* alt="Jane Doe"
|
|
44
|
-
* />
|
|
45
|
-
*
|
|
46
|
-
* // With initials fallback
|
|
47
|
-
* <Avatar alt="Jane Doe" />
|
|
48
|
-
*
|
|
49
|
-
* // With explicit initials
|
|
50
|
-
* <Avatar fallback="JD" />
|
|
51
|
-
*
|
|
52
|
-
* // With custom icon
|
|
53
|
-
* <Avatar icon="Person" variant="secondary" />
|
|
54
|
-
* ```
|
|
55
|
-
*
|
|
56
|
-
* @accessibility
|
|
57
|
-
* - Sets `accessibilityRole="image"` automatically
|
|
58
|
-
* - Uses `alt` prop as accessibility label
|
|
59
|
-
* - Always provide meaningful `alt` text for user identification
|
|
60
|
-
*
|
|
61
|
-
* @see {@link Image} for general image display
|
|
62
|
-
*/
|
|
63
|
-
const Avatar = (0, react.forwardRef)(function Avatar({ src, alt, fallback, size = "md", variant = "primary", icon, abbreviationStrategy = "firstAndLast", style, ...props }, ref) {
|
|
64
|
-
const [imageError, setImageError] = (0, react.useState)(false);
|
|
65
|
-
const initials = fallback || generateInitials(alt, abbreviationStrategy);
|
|
66
|
-
const hasImage = src && !imageError;
|
|
67
|
-
const hasText = initials.length > 0;
|
|
68
|
-
const showImage = hasImage;
|
|
69
|
-
const showText = !hasImage && hasText;
|
|
70
|
-
const showIcon = !hasImage && !hasText;
|
|
71
|
-
generated_styles.avatarStyles.useVariants({
|
|
72
|
-
size,
|
|
73
|
-
...showImage && { image: variant },
|
|
74
|
-
...showText && { text: variant },
|
|
75
|
-
...showIcon && { icon: variant }
|
|
76
|
-
});
|
|
77
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_Box.Box, {
|
|
78
|
-
ref,
|
|
79
|
-
style: [
|
|
80
|
-
generated_styles.avatarStyles.root,
|
|
81
|
-
{
|
|
82
|
-
alignItems: "center",
|
|
83
|
-
justifyContent: "center",
|
|
84
|
-
overflow: "hidden"
|
|
85
|
-
},
|
|
86
|
-
style
|
|
87
|
-
],
|
|
88
|
-
accessibilityRole: "image",
|
|
89
|
-
accessibilityLabel: alt,
|
|
90
|
-
...props,
|
|
91
|
-
children: [
|
|
92
|
-
showImage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.Image, {
|
|
93
|
-
source: { uri: src },
|
|
94
|
-
style: {
|
|
95
|
-
width: "100%",
|
|
96
|
-
height: "100%"
|
|
97
|
-
},
|
|
98
|
-
onError: () => setImageError(true),
|
|
99
|
-
accessibilityLabel: alt
|
|
100
|
-
}),
|
|
101
|
-
showText && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
102
|
-
style: generated_styles.avatarStyles.text,
|
|
103
|
-
numberOfLines: 1,
|
|
104
|
-
children: initials
|
|
105
|
-
}),
|
|
106
|
-
showIcon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
107
|
-
icon: icon ?? "Person",
|
|
108
|
-
variant: "fill",
|
|
109
|
-
style: generated_styles.avatarStyles.icon
|
|
110
|
-
})
|
|
111
|
-
]
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
Avatar.displayName = "Avatar";
|
|
115
|
-
//#endregion
|
|
116
|
-
exports.Avatar = Avatar;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { IconSlotType } from "./IconSlot.cjs";
|
|
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.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.d.cts","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,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
|