@yahoo/uds-mobile 2.24.0-beta.1 → 2.24.0-beta.11
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 +37 -1
- package/dist/components/Avatar/AvatarIcon.cjs +8 -2
- package/dist/components/Avatar/AvatarIcon.d.cts.map +1 -1
- package/dist/components/Avatar/AvatarIcon.d.ts.map +1 -1
- package/dist/components/Avatar/AvatarIcon.js +9 -3
- package/dist/components/Avatar/AvatarIcon.js.map +1 -1
- package/dist/components/Avatar/AvatarImage.cjs +9 -2
- package/dist/components/Avatar/AvatarImage.d.cts.map +1 -1
- package/dist/components/Avatar/AvatarImage.d.ts.map +1 -1
- package/dist/components/Avatar/AvatarImage.js +10 -3
- package/dist/components/Avatar/AvatarImage.js.map +1 -1
- package/dist/components/Avatar/AvatarText.cjs +8 -2
- package/dist/components/Avatar/AvatarText.d.cts.map +1 -1
- package/dist/components/Avatar/AvatarText.d.ts.map +1 -1
- package/dist/components/Avatar/AvatarText.js +9 -3
- package/dist/components/Avatar/AvatarText.js.map +1 -1
- package/dist/components/Avatar/types.d.cts +7 -3
- package/dist/components/Avatar/types.d.cts.map +1 -1
- package/dist/components/Avatar/types.d.ts +7 -3
- package/dist/components/Avatar/types.d.ts.map +1 -1
- package/dist/components/Avatar/useAvatarFontScale.cjs +16 -0
- package/dist/components/Avatar/useAvatarFontScale.d.cts +7 -0
- package/dist/components/Avatar/useAvatarFontScale.d.cts.map +1 -0
- package/dist/components/Avatar/useAvatarFontScale.d.ts +7 -0
- package/dist/components/Avatar/useAvatarFontScale.d.ts.map +1 -0
- package/dist/components/Avatar/useAvatarFontScale.js +16 -0
- package/dist/components/Avatar/useAvatarFontScale.js.map +1 -0
- package/dist/components/Avatar/utils.cjs +9 -6
- package/dist/components/Avatar/utils.d.cts +2 -2
- package/dist/components/Avatar/utils.d.cts.map +1 -1
- package/dist/components/Avatar/utils.d.ts +2 -2
- package/dist/components/Avatar/utils.d.ts.map +1 -1
- package/dist/components/Avatar/utils.js +9 -6
- package/dist/components/Avatar/utils.js.map +1 -1
- package/dist/components/Button/buttonTheme.cjs +16 -7
- package/dist/components/Button/buttonTheme.d.cts +13 -6
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +13 -6
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +16 -8
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +25 -11
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +25 -11
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +16 -6
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +16 -6
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +24 -21
- package/dist/components/Chip/ChipBase.js +24 -21
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Icon.cjs +22 -6
- package/dist/components/Icon.d.cts +6 -5
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts +6 -5
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +22 -6
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.cjs +17 -6
- package/dist/components/IconButton.d.cts +6 -0
- package/dist/components/IconButton.d.cts.map +1 -1
- package/dist/components/IconButton.d.ts +6 -0
- package/dist/components/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton.js +18 -7
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/Input.cjs +56 -18
- package/dist/components/Input.d.cts +5 -0
- package/dist/components/Input.d.cts.map +1 -1
- package/dist/components/Input.d.ts +5 -0
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +56 -18
- package/dist/components/Input.js.map +1 -1
- package/dist/components/InputHelpText.cjs +7 -1
- package/dist/components/InputHelpText.d.cts +2 -0
- package/dist/components/InputHelpText.d.cts.map +1 -1
- package/dist/components/InputHelpText.d.ts +2 -0
- package/dist/components/InputHelpText.d.ts.map +1 -1
- package/dist/components/InputHelpText.js +7 -1
- package/dist/components/InputHelpText.js.map +1 -1
- package/dist/components/Link.cjs +16 -1
- package/dist/components/Link.d.cts +6 -0
- package/dist/components/Link.d.cts.map +1 -1
- package/dist/components/Link.d.ts +6 -0
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +16 -1
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs +18 -10
- package/dist/components/Pagination/Pagination.d.cts +2 -0
- package/dist/components/Pagination/Pagination.d.cts.map +1 -1
- package/dist/components/Pagination/Pagination.d.ts +2 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.js +18 -10
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/Pagination/PaginationEllipsis.cjs +8 -2
- package/dist/components/Pagination/PaginationEllipsis.d.cts.map +1 -1
- package/dist/components/Pagination/PaginationEllipsis.d.ts.map +1 -1
- package/dist/components/Pagination/PaginationEllipsis.js +9 -3
- package/dist/components/Pagination/PaginationEllipsis.js.map +1 -1
- package/dist/components/Pagination/PaginationItem.cjs +2 -1
- package/dist/components/Pagination/PaginationItem.js +2 -1
- package/dist/components/Pagination/PaginationItem.js.map +1 -1
- package/dist/components/Pagination/PaginationLink.cjs +2 -1
- package/dist/components/Pagination/PaginationLink.js +2 -1
- package/dist/components/Pagination/PaginationLink.js.map +1 -1
- package/dist/components/Pagination/PaginationNext.cjs +3 -1
- package/dist/components/Pagination/PaginationNext.js +3 -1
- package/dist/components/Pagination/PaginationNext.js.map +1 -1
- package/dist/components/Pagination/PaginationPrev.cjs +3 -1
- package/dist/components/Pagination/PaginationPrev.js +3 -1
- package/dist/components/Pagination/PaginationPrev.js.map +1 -1
- package/dist/components/Pagination/paginationContext.d.cts +2 -0
- package/dist/components/Pagination/paginationContext.d.cts.map +1 -1
- package/dist/components/Pagination/paginationContext.d.ts +2 -0
- package/dist/components/Pagination/paginationContext.d.ts.map +1 -1
- package/dist/components/Pagination/paginationContext.js.map +1 -1
- package/dist/components/Pagination/usePaginationControlStyles.cjs +8 -1
- package/dist/components/Pagination/usePaginationControlStyles.d.cts.map +1 -1
- package/dist/components/Pagination/usePaginationControlStyles.d.ts.map +1 -1
- package/dist/components/Pagination/usePaginationControlStyles.js +9 -2
- package/dist/components/Pagination/usePaginationControlStyles.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +4 -3
- package/dist/components/Radio/Radio.js +4 -3
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Select/Select.cjs +29 -6
- package/dist/components/Select/Select.d.cts +2 -0
- package/dist/components/Select/Select.d.cts.map +1 -1
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.js +29 -6
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectContent.cjs +31 -23
- package/dist/components/Select/SelectContent.d.cts.map +1 -1
- package/dist/components/Select/SelectContent.d.ts.map +1 -1
- package/dist/components/Select/SelectContent.js +32 -24
- package/dist/components/Select/SelectContent.js.map +1 -1
- package/dist/components/Select/SelectItem.cjs +25 -15
- package/dist/components/Select/SelectItem.d.cts.map +1 -1
- package/dist/components/Select/SelectItem.d.ts.map +1 -1
- package/dist/components/Select/SelectItem.js +25 -15
- package/dist/components/Select/SelectItem.js.map +1 -1
- package/dist/components/Select/SelectTrigger.cjs +27 -13
- package/dist/components/Select/SelectTrigger.d.cts.map +1 -1
- package/dist/components/Select/SelectTrigger.d.ts.map +1 -1
- package/dist/components/Select/SelectTrigger.js +27 -13
- package/dist/components/Select/SelectTrigger.js.map +1 -1
- package/dist/components/Select/types.d.cts +2 -0
- package/dist/components/Select/types.d.cts.map +1 -1
- package/dist/components/Select/types.d.ts +2 -0
- package/dist/components/Select/types.d.ts.map +1 -1
- package/dist/components/Switch.cjs +31 -14
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +31 -14
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +8 -4
- package/dist/components/Tabs/Tab.d.cts.map +1 -1
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.js +8 -4
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Text.cjs +5 -0
- package/dist/components/Text.d.cts +6 -5
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts +6 -5
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +5 -0
- package/dist/components/Text.js.map +1 -1
- package/dist/components/UDSProvider.cjs +1 -1
- package/dist/components/UDSProvider.d.cts +4 -3
- package/dist/components/UDSProvider.d.cts.map +1 -1
- package/dist/components/UDSProvider.d.ts +4 -3
- package/dist/components/UDSProvider.d.ts.map +1 -1
- package/dist/components/UDSProvider.js +1 -1
- package/dist/components/UDSProvider.js.map +1 -1
- package/dist/fontScaling/FontScalingContext.cjs +35 -3
- package/dist/fontScaling/FontScalingContext.d.cts +20 -5
- package/dist/fontScaling/FontScalingContext.d.cts.map +1 -1
- package/dist/fontScaling/FontScalingContext.d.ts +20 -5
- package/dist/fontScaling/FontScalingContext.d.ts.map +1 -1
- package/dist/fontScaling/FontScalingContext.js +34 -5
- package/dist/fontScaling/FontScalingContext.js.map +1 -1
- package/dist/fontScaling/androidNonlinearFontScaling.cjs +250 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.cts +7 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.cts.map +1 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.ts +7 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.ts.map +1 -0
- package/dist/fontScaling/androidNonlinearFontScaling.js +251 -0
- package/dist/fontScaling/androidNonlinearFontScaling.js.map +1 -0
- package/dist/fontScaling/constants.cjs +37 -3
- package/dist/fontScaling/constants.d.cts +15 -4
- package/dist/fontScaling/constants.d.cts.map +1 -1
- package/dist/fontScaling/constants.d.ts +15 -4
- package/dist/fontScaling/constants.d.ts.map +1 -1
- package/dist/fontScaling/constants.js +37 -4
- package/dist/fontScaling/constants.js.map +1 -1
- package/dist/fontScaling/index.cjs +2 -1
- package/dist/fontScaling/index.d.cts +2 -2
- package/dist/fontScaling/index.d.ts +2 -2
- package/dist/fontScaling/index.js +3 -3
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.cjs +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts.map +1 -1
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts.map +1 -1
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js.map +1 -1
- package/dist/fontScaling/types.d.cts +11 -8
- package/dist/fontScaling/types.d.cts.map +1 -1
- package/dist/fontScaling/types.d.ts +11 -8
- package/dist/fontScaling/types.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.cjs +30 -4
- package/dist/fontScaling/useFontScale.d.cts +6 -12
- package/dist/fontScaling/useFontScale.d.cts.map +1 -1
- package/dist/fontScaling/useFontScale.d.ts +6 -12
- package/dist/fontScaling/useFontScale.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.js +31 -6
- package/dist/fontScaling/useFontScale.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +14 -1
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +14 -1
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/mobile/generated/fontMetrics.cjs +534 -534
- package/dist/mobile/generated/fontMetrics.js +534 -534
- package/dist/mobile/generated/fontMetrics.js.map +1 -1
- package/dist/portal.cjs +8 -2
- package/dist/portal.d.cts.map +1 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js +8 -2
- package/dist/portal.js.map +1 -1
- package/fonts/index.cjs +214 -214
- package/fonts/index.mjs +214 -214
- package/fonts/uds-icons.ttf +0 -0
- package/generated/fontMetrics.ts +534 -534
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
- [Quick Start](#quick-start)
|
|
8
8
|
- [Components](#components)
|
|
9
9
|
- [Icons](#icons)
|
|
10
|
+
- [Accessibility and Text Scaling](#accessibility-and-text-scaling)
|
|
10
11
|
- [Fonts](#fonts)
|
|
11
12
|
- [CLI](#cli)
|
|
12
13
|
- [Testing](#testing)
|
|
@@ -17,11 +18,12 @@
|
|
|
17
18
|
|
|
18
19
|
`@yahoo/uds-mobile` brings UDS to React Native. It provides:
|
|
19
20
|
|
|
20
|
-
- **Pre-built Components**: Avatar, Badge, Button, Checkbox, Chip, Divider, Icon, IconButton, Image, Input, InputHelpText, Link, Radio, RadioGroup, Switch, Tabs, Text, and layout primitives (Box, VStack, HStack, Screen)
|
|
21
|
+
- **Pre-built Components**: Avatar, Badge, Button, Checkbox, Chip, Divider, Icon, IconButton, Image, Input, InputHelpText, Link, Pagination, Radio, RadioGroup, Select, Switch, Tabs, Text, and layout primitives (Box, VStack, HStack, Screen)
|
|
21
22
|
- **Theming**: Full light/dark mode support with automatic system preference detection
|
|
22
23
|
- **Design Token Integration**: Colors, typography, spacing, and motion configs synced from UDS tokens
|
|
23
24
|
- **Animations**: Smooth, physics-based animations using Reanimated with motion parity to web
|
|
24
25
|
- **Icon Support**: Icon font and SVG icon rendering with full UDS icon library
|
|
26
|
+
- **Dynamic Type**: Text, icons, and bounded controls respond to system text-size settings
|
|
25
27
|
|
|
26
28
|
### Key Dependencies
|
|
27
29
|
|
|
@@ -476,6 +478,40 @@ const animatedStyle = useAnimatedStyle(() => ({
|
|
|
476
478
|
}));
|
|
477
479
|
```
|
|
478
480
|
|
|
481
|
+
## Accessibility and Text Scaling
|
|
482
|
+
|
|
483
|
+
UDS Mobile automatically scales text, font icons, multicolor SVG icons, and supported control
|
|
484
|
+
geometry with the iOS and Android system text-size settings. Every text style caps at 2x or below by
|
|
485
|
+
default, with the largest display and title styles tapering further.
|
|
486
|
+
|
|
487
|
+
Most apps need no configuration. To override the defaults, pass a stable configuration object to
|
|
488
|
+
`UDSGestureProvider`:
|
|
489
|
+
|
|
490
|
+
```tsx
|
|
491
|
+
import type { FontScalingConfig } from '@yahoo/uds-mobile/fontScaling';
|
|
492
|
+
import { UDSGestureProvider } from '@yahoo/uds-mobile/UDSGestureProvider';
|
|
493
|
+
|
|
494
|
+
const FONT_SCALING: FontScalingConfig = {
|
|
495
|
+
variants: { body1: null }, // Let body text follow the system without a cap
|
|
496
|
+
control: 2,
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
<UDSGestureProvider fontScaling={FONT_SCALING}>
|
|
500
|
+
<App />
|
|
501
|
+
</UDSGestureProvider>;
|
|
502
|
+
```
|
|
503
|
+
|
|
504
|
+
See the [Accessibility and text scaling guide](https://uds.build/docs/mobile/accessibility) for the
|
|
505
|
+
default cap table, per-component overrides, custom-component hooks, known limits, and device test
|
|
506
|
+
matrix.
|
|
507
|
+
|
|
508
|
+
When upgrading from manual scaling workarounds, remove app-level geometry multiplication only after
|
|
509
|
+
comparing the screen with UDS defaults; applying both can make controls oversized. App-owned
|
|
510
|
+
composite controls should use `useFontScale(cap, baseSize)`. As a temporary rollback,
|
|
511
|
+
`fontScaling={{ enabled: false }}` restores the pre-feature behavior: native text scaling remains,
|
|
512
|
+
while UDS-added caps, ramps, multicolor-icon scaling, and control geometry growth are disabled.
|
|
513
|
+
An explicit `maxFontSizeMultiplier` on a component still opts that component back into scaling.
|
|
514
|
+
|
|
479
515
|
## Fonts
|
|
480
516
|
|
|
481
517
|
### Font Handling
|
|
@@ -2,26 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_components_Box = require("../Box.cjs");
|
|
5
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("../../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
5
6
|
const require_components_IconSlot = require("../IconSlot.cjs");
|
|
7
|
+
const require_components_Avatar_useAvatarFontScale = require("./useAvatarFontScale.cjs");
|
|
6
8
|
const require_components_Avatar_utils = require("./utils.cjs");
|
|
7
9
|
let react = require("react");
|
|
8
10
|
let react_native = require("react-native");
|
|
9
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
12
|
let generated_styles = require("../../../generated/styles");
|
|
11
13
|
//#region src/components/Avatar/AvatarIcon.tsx
|
|
12
|
-
const AvatarIcon = (0, react.memo)(function AvatarIcon({ size = "md", variant = require_components_Avatar_utils.DEFAULT_AVATAR_VARIANT, icon, customSize, style, accessibilityLabel, alt, ref, ...viewProps }) {
|
|
14
|
+
const AvatarIcon = (0, react.memo)(function AvatarIcon({ size = "md", variant = require_components_Avatar_utils.DEFAULT_AVATAR_VARIANT, icon, customSize, maxFontSizeMultiplier, style, accessibilityLabel, alt, ref, ...viewProps }) {
|
|
15
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
13
16
|
generated_styles.avatarStyles.useVariants({
|
|
14
17
|
size,
|
|
15
18
|
icon: variant
|
|
16
19
|
});
|
|
20
|
+
const fontScaleFactor = require_components_Avatar_useAvatarFontScale.useAvatarFontScale(resolvedMaxFontSizeMultiplier);
|
|
17
21
|
const rootStyle = (0, react.useMemo)(() => [
|
|
18
22
|
generated_styles.avatarStyles.root,
|
|
19
23
|
avatarStaticStyles.root,
|
|
20
|
-
require_components_Avatar_utils.
|
|
24
|
+
require_components_Avatar_utils.getAvatarSizeStyle(generated_styles.avatarStyles.root, customSize, fontScaleFactor),
|
|
21
25
|
style
|
|
22
26
|
], [
|
|
23
27
|
generated_styles.avatarStyles.root,
|
|
24
28
|
customSize,
|
|
29
|
+
fontScaleFactor,
|
|
25
30
|
style
|
|
26
31
|
]);
|
|
27
32
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
|
|
@@ -33,6 +38,7 @@ const AvatarIcon = (0, react.memo)(function AvatarIcon({ size = "md", variant =
|
|
|
33
38
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
34
39
|
icon: icon ?? require_components_Avatar_utils.getDefaultAvatarIcon(variant),
|
|
35
40
|
variant: "fill",
|
|
41
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
36
42
|
style: generated_styles.avatarStyles.icon
|
|
37
43
|
})
|
|
38
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarIcon.d.cts","names":[],"sources":["../../../src/components/Avatar/AvatarIcon.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AvatarIcon.d.cts","names":[],"sources":["../../../src/components/Avatar/AvatarIcon.tsx"],"mappings":";;;;;cAgBM,UAAA,EAAU,OAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarIcon.d.ts","names":[],"sources":["../../../src/components/Avatar/AvatarIcon.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AvatarIcon.d.ts","names":[],"sources":["../../../src/components/Avatar/AvatarIcon.tsx"],"mappings":";;;;;cAgBM,UAAA,EAAU,OAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { Box } from "../Box.js";
|
|
3
|
+
import { useMaxFontSizeMultiplier } from "../../fontScaling/useMaxFontSizeMultiplier.js";
|
|
3
4
|
import { IconSlot } from "../IconSlot.js";
|
|
4
|
-
import {
|
|
5
|
+
import { useAvatarFontScale } from "./useAvatarFontScale.js";
|
|
6
|
+
import { DEFAULT_AVATAR_VARIANT, getAvatarSizeStyle, getDefaultAvatarIcon } from "./utils.js";
|
|
5
7
|
import { memo, useMemo } from "react";
|
|
6
8
|
import { StyleSheet } from "react-native";
|
|
7
9
|
import { jsx } from "react/jsx-runtime";
|
|
8
10
|
import { avatarStyles } from "../../../generated/styles";
|
|
9
11
|
//#region src/components/Avatar/AvatarIcon.tsx
|
|
10
|
-
const AvatarIcon = memo(function AvatarIcon({ size = "md", variant = DEFAULT_AVATAR_VARIANT, icon, customSize, style, accessibilityLabel, alt, ref, ...viewProps }) {
|
|
12
|
+
const AvatarIcon = memo(function AvatarIcon({ size = "md", variant = DEFAULT_AVATAR_VARIANT, icon, customSize, maxFontSizeMultiplier, style, accessibilityLabel, alt, ref, ...viewProps }) {
|
|
13
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
11
14
|
avatarStyles.useVariants({
|
|
12
15
|
size,
|
|
13
16
|
icon: variant
|
|
14
17
|
});
|
|
18
|
+
const fontScaleFactor = useAvatarFontScale(resolvedMaxFontSizeMultiplier);
|
|
15
19
|
const rootStyle = useMemo(() => [
|
|
16
20
|
avatarStyles.root,
|
|
17
21
|
avatarStaticStyles.root,
|
|
18
|
-
|
|
22
|
+
getAvatarSizeStyle(avatarStyles.root, customSize, fontScaleFactor),
|
|
19
23
|
style
|
|
20
24
|
], [
|
|
21
25
|
avatarStyles.root,
|
|
22
26
|
customSize,
|
|
27
|
+
fontScaleFactor,
|
|
23
28
|
style
|
|
24
29
|
]);
|
|
25
30
|
return /* @__PURE__ */ jsx(Box, {
|
|
@@ -31,6 +36,7 @@ const AvatarIcon = memo(function AvatarIcon({ size = "md", variant = DEFAULT_AVA
|
|
|
31
36
|
children: /* @__PURE__ */ jsx(IconSlot, {
|
|
32
37
|
icon: icon ?? getDefaultAvatarIcon(variant),
|
|
33
38
|
variant: "fill",
|
|
39
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
34
40
|
style: avatarStyles.icon
|
|
35
41
|
})
|
|
36
42
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarIcon.js","names":[],"sources":["../../../src/components/Avatar/AvatarIcon.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { Box } from '../Box';\nimport { IconSlot } from '../IconSlot';\nimport type { AvatarIconProps } from './types';\nimport {\n DEFAULT_AVATAR_SIZE,\n DEFAULT_AVATAR_VARIANT,\n
|
|
1
|
+
{"version":3,"file":"AvatarIcon.js","names":[],"sources":["../../../src/components/Avatar/AvatarIcon.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { useMaxFontSizeMultiplier } from '../../fontScaling/useMaxFontSizeMultiplier';\nimport { Box } from '../Box';\nimport { IconSlot } from '../IconSlot';\nimport type { AvatarIconProps } from './types';\nimport { useAvatarFontScale } from './useAvatarFontScale';\nimport {\n DEFAULT_AVATAR_SIZE,\n DEFAULT_AVATAR_VARIANT,\n getAvatarSizeStyle,\n getDefaultAvatarIcon,\n} from './utils';\n\nconst AvatarIcon = memo(function AvatarIcon({\n size = DEFAULT_AVATAR_SIZE,\n variant = DEFAULT_AVATAR_VARIANT,\n icon,\n customSize,\n maxFontSizeMultiplier,\n style,\n accessibilityLabel,\n alt,\n ref,\n ...viewProps\n}: AvatarIconProps) {\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n avatarStyles.useVariants({ size, icon: variant });\n const fontScaleFactor = useAvatarFontScale(resolvedMaxFontSizeMultiplier);\n\n const rootStyle = useMemo(\n () => [\n avatarStyles.root,\n avatarStaticStyles.root,\n getAvatarSizeStyle(avatarStyles.root, customSize, fontScaleFactor),\n style,\n ],\n [avatarStyles.root, customSize, fontScaleFactor, style],\n );\n\n return (\n <Box\n ref={ref}\n accessibilityRole=\"image\"\n accessibilityLabel={accessibilityLabel ?? alt}\n {...viewProps}\n style={rootStyle}\n >\n <IconSlot\n icon={icon ?? getDefaultAvatarIcon(variant)}\n variant=\"fill\"\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={avatarStyles.icon}\n />\n </Box>\n );\n});\n\nAvatarIcon.displayName = 'AvatarIcon';\n\nconst avatarStaticStyles = StyleSheet.create({\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n },\n});\n\nexport { AvatarIcon };\n"],"mappings":";;;;;;;;;;;AAgBA,MAAM,aAAa,KAAK,SAAS,WAAW,EAC1C,OAAA,MACA,UAAU,wBACV,MACA,YACA,uBACA,OACA,oBACA,KACA,KACA,GAAG,aACe;CAClB,MAAM,gCAAgC,yBAAyB,WAAW,sBAAsB;CAChG,aAAa,YAAY;EAAE;EAAM,MAAM;EAAS,CAAC;CACjD,MAAM,kBAAkB,mBAAmB,8BAA8B;CAEzE,MAAM,YAAY,cACV;EACJ,aAAa;EACb,mBAAmB;EACnB,mBAAmB,aAAa,MAAM,YAAY,gBAAgB;EAClE;EACD,EACD;EAAC,aAAa;EAAM;EAAY;EAAiB;EAAM,CACxD;CAED,OACE,oBAAC,KAAD;EACO;EACL,mBAAkB;EAClB,oBAAoB,sBAAsB;EAC1C,GAAI;EACJ,OAAO;YAEP,oBAAC,UAAD;GACE,MAAM,QAAQ,qBAAqB,QAAQ;GAC3C,SAAQ;GACR,uBAAuB;GACvB,OAAO,aAAa;GACpB,CAAA;EACE,CAAA;EAER;AAEF,WAAW,cAAc;AAEzB,MAAM,qBAAqB,WAAW,OAAO,EAC3C,MAAM;CACJ,YAAY;CACZ,gBAAgB;CAChB,UAAU;CACX,EACF,CAAC"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_components_Box = require("../Box.cjs");
|
|
5
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("../../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
6
|
+
const require_components_Avatar_useAvatarFontScale = require("./useAvatarFontScale.cjs");
|
|
5
7
|
const require_components_Avatar_utils = require("./utils.cjs");
|
|
6
8
|
const require_components_Avatar_AvatarIcon = require("./AvatarIcon.cjs");
|
|
7
9
|
const require_components_Avatar_AvatarText = require("./AvatarText.cjs");
|
|
@@ -10,21 +12,24 @@ let react_native = require("react-native");
|
|
|
10
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
13
|
let generated_styles = require("../../../generated/styles");
|
|
12
14
|
//#region src/components/Avatar/AvatarImage.tsx
|
|
13
|
-
const AvatarImage = (0, react.memo)(function AvatarImage({ size = "md", variant = require_components_Avatar_utils.DEFAULT_AVATAR_VARIANT, src, alt, fallback, icon, abbreviationStrategy, customSize, style, accessibilityLabel, ref, ...viewProps }) {
|
|
15
|
+
const AvatarImage = (0, react.memo)(function AvatarImage({ size = "md", variant = require_components_Avatar_utils.DEFAULT_AVATAR_VARIANT, src, alt, fallback, icon, abbreviationStrategy, customSize, maxFontSizeMultiplier, style, accessibilityLabel, ref, ...viewProps }) {
|
|
16
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
14
17
|
const [imageError, setImageError] = (0, react.useState)(false);
|
|
15
18
|
const shouldShowImage = Boolean(src) && !imageError;
|
|
16
19
|
generated_styles.avatarStyles.useVariants({
|
|
17
20
|
size,
|
|
18
21
|
image: variant
|
|
19
22
|
});
|
|
23
|
+
const fontScaleFactor = require_components_Avatar_useAvatarFontScale.useAvatarFontScale(resolvedMaxFontSizeMultiplier);
|
|
20
24
|
const rootStyle = (0, react.useMemo)(() => [
|
|
21
25
|
generated_styles.avatarStyles.root,
|
|
22
26
|
avatarStaticStyles.root,
|
|
23
|
-
require_components_Avatar_utils.
|
|
27
|
+
require_components_Avatar_utils.getAvatarSizeStyle(generated_styles.avatarStyles.root, customSize, fontScaleFactor),
|
|
24
28
|
style
|
|
25
29
|
], [
|
|
26
30
|
generated_styles.avatarStyles.root,
|
|
27
31
|
customSize,
|
|
32
|
+
fontScaleFactor,
|
|
28
33
|
style
|
|
29
34
|
]);
|
|
30
35
|
if (!shouldShowImage) {
|
|
@@ -36,6 +41,7 @@ const AvatarImage = (0, react.memo)(function AvatarImage({ size = "md", variant
|
|
|
36
41
|
initials: fallback,
|
|
37
42
|
abbreviationStrategy,
|
|
38
43
|
customSize,
|
|
44
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
39
45
|
accessibilityLabel: accessibilityLabel ?? alt ?? fallback,
|
|
40
46
|
style,
|
|
41
47
|
...viewProps
|
|
@@ -46,6 +52,7 @@ const AvatarImage = (0, react.memo)(function AvatarImage({ size = "md", variant
|
|
|
46
52
|
variant,
|
|
47
53
|
icon,
|
|
48
54
|
customSize,
|
|
55
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
49
56
|
accessibilityLabel: accessibilityLabel ?? alt,
|
|
50
57
|
style,
|
|
51
58
|
...viewProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarImage.d.cts","names":[],"sources":["../../../src/components/Avatar/AvatarImage.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AvatarImage.d.cts","names":[],"sources":["../../../src/components/Avatar/AvatarImage.tsx"],"mappings":";;;;;cAYM,WAAA,EAAW,OAAA,CAAA,oBAAA,CAAA,gBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarImage.d.ts","names":[],"sources":["../../../src/components/Avatar/AvatarImage.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AvatarImage.d.ts","names":[],"sources":["../../../src/components/Avatar/AvatarImage.tsx"],"mappings":";;;;;cAYM,WAAA,EAAW,OAAA,CAAA,oBAAA,CAAA,gBAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { Box } from "../Box.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useMaxFontSizeMultiplier } from "../../fontScaling/useMaxFontSizeMultiplier.js";
|
|
4
|
+
import { useAvatarFontScale } from "./useAvatarFontScale.js";
|
|
5
|
+
import { DEFAULT_AVATAR_VARIANT, getAvatarSizeStyle } from "./utils.js";
|
|
4
6
|
import { AvatarIcon } from "./AvatarIcon.js";
|
|
5
7
|
import { AvatarText } from "./AvatarText.js";
|
|
6
8
|
import { memo, useMemo, useState } from "react";
|
|
@@ -8,21 +10,24 @@ import { Image, StyleSheet } from "react-native";
|
|
|
8
10
|
import { jsx } from "react/jsx-runtime";
|
|
9
11
|
import { avatarStyles } from "../../../generated/styles";
|
|
10
12
|
//#region src/components/Avatar/AvatarImage.tsx
|
|
11
|
-
const AvatarImage = memo(function AvatarImage({ size = "md", variant = DEFAULT_AVATAR_VARIANT, src, alt, fallback, icon, abbreviationStrategy, customSize, style, accessibilityLabel, ref, ...viewProps }) {
|
|
13
|
+
const AvatarImage = memo(function AvatarImage({ size = "md", variant = DEFAULT_AVATAR_VARIANT, src, alt, fallback, icon, abbreviationStrategy, customSize, maxFontSizeMultiplier, style, accessibilityLabel, ref, ...viewProps }) {
|
|
14
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
12
15
|
const [imageError, setImageError] = useState(false);
|
|
13
16
|
const shouldShowImage = Boolean(src) && !imageError;
|
|
14
17
|
avatarStyles.useVariants({
|
|
15
18
|
size,
|
|
16
19
|
image: variant
|
|
17
20
|
});
|
|
21
|
+
const fontScaleFactor = useAvatarFontScale(resolvedMaxFontSizeMultiplier);
|
|
18
22
|
const rootStyle = useMemo(() => [
|
|
19
23
|
avatarStyles.root,
|
|
20
24
|
avatarStaticStyles.root,
|
|
21
|
-
|
|
25
|
+
getAvatarSizeStyle(avatarStyles.root, customSize, fontScaleFactor),
|
|
22
26
|
style
|
|
23
27
|
], [
|
|
24
28
|
avatarStyles.root,
|
|
25
29
|
customSize,
|
|
30
|
+
fontScaleFactor,
|
|
26
31
|
style
|
|
27
32
|
]);
|
|
28
33
|
if (!shouldShowImage) {
|
|
@@ -34,6 +39,7 @@ const AvatarImage = memo(function AvatarImage({ size = "md", variant = DEFAULT_A
|
|
|
34
39
|
initials: fallback,
|
|
35
40
|
abbreviationStrategy,
|
|
36
41
|
customSize,
|
|
42
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
37
43
|
accessibilityLabel: accessibilityLabel ?? alt ?? fallback,
|
|
38
44
|
style,
|
|
39
45
|
...viewProps
|
|
@@ -44,6 +50,7 @@ const AvatarImage = memo(function AvatarImage({ size = "md", variant = DEFAULT_A
|
|
|
44
50
|
variant,
|
|
45
51
|
icon,
|
|
46
52
|
customSize,
|
|
53
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
47
54
|
accessibilityLabel: accessibilityLabel ?? alt,
|
|
48
55
|
style,
|
|
49
56
|
...viewProps
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarImage.js","names":["RNImage"],"sources":["../../../src/components/Avatar/AvatarImage.tsx"],"sourcesContent":["import { memo, useMemo, useState } from 'react';\nimport { Image as RNImage, StyleSheet } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { Box } from '../Box';\nimport { AvatarIcon } from './AvatarIcon';\nimport { AvatarText } from './AvatarText';\nimport type { AvatarImageProps } from './types';\nimport { DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_VARIANT,
|
|
1
|
+
{"version":3,"file":"AvatarImage.js","names":["RNImage"],"sources":["../../../src/components/Avatar/AvatarImage.tsx"],"sourcesContent":["import { memo, useMemo, useState } from 'react';\nimport { Image as RNImage, StyleSheet } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { useMaxFontSizeMultiplier } from '../../fontScaling/useMaxFontSizeMultiplier';\nimport { Box } from '../Box';\nimport { AvatarIcon } from './AvatarIcon';\nimport { AvatarText } from './AvatarText';\nimport type { AvatarImageProps } from './types';\nimport { useAvatarFontScale } from './useAvatarFontScale';\nimport { DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_VARIANT, getAvatarSizeStyle } from './utils';\n\nconst AvatarImage = memo(function AvatarImage({\n size = DEFAULT_AVATAR_SIZE,\n variant = DEFAULT_AVATAR_VARIANT,\n src,\n alt,\n fallback,\n icon,\n abbreviationStrategy,\n customSize,\n maxFontSizeMultiplier,\n style,\n accessibilityLabel,\n ref,\n ...viewProps\n}: AvatarImageProps) {\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n const [imageError, setImageError] = useState(false);\n const shouldShowImage = Boolean(src) && !imageError;\n\n avatarStyles.useVariants({ size, image: variant });\n const fontScaleFactor = useAvatarFontScale(resolvedMaxFontSizeMultiplier);\n\n const rootStyle = useMemo(\n () => [\n avatarStyles.root,\n avatarStaticStyles.root,\n getAvatarSizeStyle(avatarStyles.root, customSize, fontScaleFactor),\n style,\n ],\n [avatarStyles.root, customSize, fontScaleFactor, style],\n );\n\n if (!shouldShowImage) {\n if (fallback || alt) {\n return (\n <AvatarText\n ref={ref}\n size={size}\n variant={variant}\n name={alt}\n initials={fallback}\n abbreviationStrategy={abbreviationStrategy}\n customSize={customSize}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n accessibilityLabel={accessibilityLabel ?? alt ?? fallback}\n style={style}\n {...viewProps}\n />\n );\n }\n\n return (\n <AvatarIcon\n ref={ref}\n size={size}\n variant={variant}\n icon={icon}\n customSize={customSize}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n accessibilityLabel={accessibilityLabel ?? alt}\n style={style}\n {...viewProps}\n />\n );\n }\n\n return (\n <Box\n ref={ref}\n accessibilityRole=\"image\"\n accessibilityLabel={accessibilityLabel ?? alt}\n {...viewProps}\n style={rootStyle}\n >\n <RNImage\n source={{ uri: src }}\n accessibilityLabel={alt}\n onError={() => setImageError(true)}\n style={avatarStaticStyles.image}\n />\n </Box>\n );\n});\n\nAvatarImage.displayName = 'AvatarImage';\n\nconst avatarStaticStyles = StyleSheet.create({\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n },\n image: {\n height: '100%',\n width: '100%',\n },\n});\n\nexport { AvatarImage };\n"],"mappings":";;;;;;;;;;;;AAYA,MAAM,cAAc,KAAK,SAAS,YAAY,EAC5C,OAAA,MACA,UAAU,wBACV,KACA,KACA,UACA,MACA,sBACA,YACA,uBACA,OACA,oBACA,KACA,GAAG,aACgB;CACnB,MAAM,gCAAgC,yBAAyB,WAAW,sBAAsB;CAChG,MAAM,CAAC,YAAY,iBAAiB,SAAS,MAAM;CACnD,MAAM,kBAAkB,QAAQ,IAAI,IAAI,CAAC;CAEzC,aAAa,YAAY;EAAE;EAAM,OAAO;EAAS,CAAC;CAClD,MAAM,kBAAkB,mBAAmB,8BAA8B;CAEzE,MAAM,YAAY,cACV;EACJ,aAAa;EACb,mBAAmB;EACnB,mBAAmB,aAAa,MAAM,YAAY,gBAAgB;EAClE;EACD,EACD;EAAC,aAAa;EAAM;EAAY;EAAiB;EAAM,CACxD;CAED,IAAI,CAAC,iBAAiB;EACpB,IAAI,YAAY,KACd,OACE,oBAAC,YAAD;GACO;GACC;GACG;GACT,MAAM;GACN,UAAU;GACY;GACV;GACZ,uBAAuB;GACvB,oBAAoB,sBAAsB,OAAO;GAC1C;GACP,GAAI;GACJ,CAAA;EAIN,OACE,oBAAC,YAAD;GACO;GACC;GACG;GACH;GACM;GACZ,uBAAuB;GACvB,oBAAoB,sBAAsB;GACnC;GACP,GAAI;GACJ,CAAA;;CAIN,OACE,oBAAC,KAAD;EACO;EACL,mBAAkB;EAClB,oBAAoB,sBAAsB;EAC1C,GAAI;EACJ,OAAO;YAEP,oBAACA,OAAD;GACE,QAAQ,EAAE,KAAK,KAAK;GACpB,oBAAoB;GACpB,eAAe,cAAc,KAAK;GAClC,OAAO,mBAAmB;GAC1B,CAAA;EACE,CAAA;EAER;AAEF,YAAY,cAAc;AAE1B,MAAM,qBAAqB,WAAW,OAAO;CAC3C,MAAM;EACJ,YAAY;EACZ,gBAAgB;EAChB,UAAU;EACX;CACD,OAAO;EACL,QAAQ;EACR,OAAO;EACR;CACF,CAAC"}
|
|
@@ -2,26 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_components_Box = require("../Box.cjs");
|
|
5
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("../../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
5
6
|
const require_components_Text = require("../Text.cjs");
|
|
7
|
+
const require_components_Avatar_useAvatarFontScale = require("./useAvatarFontScale.cjs");
|
|
6
8
|
const require_components_Avatar_utils = require("./utils.cjs");
|
|
7
9
|
let react = require("react");
|
|
8
10
|
let react_native = require("react-native");
|
|
9
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
10
12
|
let generated_styles = require("../../../generated/styles");
|
|
11
13
|
//#region src/components/Avatar/AvatarText.tsx
|
|
12
|
-
const AvatarText = (0, react.memo)(function AvatarText({ size = "md", variant = require_components_Avatar_utils.DEFAULT_AVATAR_VARIANT, name, initials, abbreviationStrategy, customSize, style, accessibilityLabel, ref, ...viewProps }) {
|
|
14
|
+
const AvatarText = (0, react.memo)(function AvatarText({ size = "md", variant = require_components_Avatar_utils.DEFAULT_AVATAR_VARIANT, name, initials, abbreviationStrategy, customSize, maxFontSizeMultiplier, style, accessibilityLabel, ref, ...viewProps }) {
|
|
15
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
13
16
|
generated_styles.avatarStyles.useVariants({
|
|
14
17
|
size,
|
|
15
18
|
text: variant
|
|
16
19
|
});
|
|
20
|
+
const fontScaleFactor = require_components_Avatar_useAvatarFontScale.useAvatarFontScale(resolvedMaxFontSizeMultiplier);
|
|
17
21
|
const rootStyle = (0, react.useMemo)(() => [
|
|
18
22
|
generated_styles.avatarStyles.root,
|
|
19
23
|
avatarStaticStyles.root,
|
|
20
|
-
require_components_Avatar_utils.
|
|
24
|
+
require_components_Avatar_utils.getAvatarSizeStyle(generated_styles.avatarStyles.root, customSize, fontScaleFactor),
|
|
21
25
|
style
|
|
22
26
|
], [
|
|
23
27
|
generated_styles.avatarStyles.root,
|
|
24
28
|
customSize,
|
|
29
|
+
fontScaleFactor,
|
|
25
30
|
style
|
|
26
31
|
]);
|
|
27
32
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
|
|
@@ -34,6 +39,7 @@ const AvatarText = (0, react.memo)(function AvatarText({ size = "md", variant =
|
|
|
34
39
|
color: "inherit",
|
|
35
40
|
variant: "inherit",
|
|
36
41
|
numberOfLines: 1,
|
|
42
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
37
43
|
style: generated_styles.avatarStyles.text,
|
|
38
44
|
children: initials || require_components_Avatar_utils.generateAvatarAbbreviation(name, abbreviationStrategy)
|
|
39
45
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarText.d.cts","names":[],"sources":["../../../src/components/Avatar/AvatarText.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AvatarText.d.cts","names":[],"sources":["../../../src/components/Avatar/AvatarText.tsx"],"mappings":";;;;;cAgBM,UAAA,EAAU,OAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarText.d.ts","names":[],"sources":["../../../src/components/Avatar/AvatarText.tsx"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"AvatarText.d.ts","names":[],"sources":["../../../src/components/Avatar/AvatarText.tsx"],"mappings":";;;;;cAgBM,UAAA,EAAU,OAAA,CAAA,oBAAA,CAAA,eAAA"}
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { Box } from "../Box.js";
|
|
3
|
+
import { useMaxFontSizeMultiplier } from "../../fontScaling/useMaxFontSizeMultiplier.js";
|
|
3
4
|
import { Text as Text$1 } from "../Text.js";
|
|
4
|
-
import {
|
|
5
|
+
import { useAvatarFontScale } from "./useAvatarFontScale.js";
|
|
6
|
+
import { DEFAULT_AVATAR_VARIANT, generateAvatarAbbreviation, getAvatarSizeStyle } from "./utils.js";
|
|
5
7
|
import { memo, useMemo } from "react";
|
|
6
8
|
import { StyleSheet } from "react-native";
|
|
7
9
|
import { jsx } from "react/jsx-runtime";
|
|
8
10
|
import { avatarStyles } from "../../../generated/styles";
|
|
9
11
|
//#region src/components/Avatar/AvatarText.tsx
|
|
10
|
-
const AvatarText = memo(function AvatarText({ size = "md", variant = DEFAULT_AVATAR_VARIANT, name, initials, abbreviationStrategy, customSize, style, accessibilityLabel, ref, ...viewProps }) {
|
|
12
|
+
const AvatarText = memo(function AvatarText({ size = "md", variant = DEFAULT_AVATAR_VARIANT, name, initials, abbreviationStrategy, customSize, maxFontSizeMultiplier, style, accessibilityLabel, ref, ...viewProps }) {
|
|
13
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
11
14
|
avatarStyles.useVariants({
|
|
12
15
|
size,
|
|
13
16
|
text: variant
|
|
14
17
|
});
|
|
18
|
+
const fontScaleFactor = useAvatarFontScale(resolvedMaxFontSizeMultiplier);
|
|
15
19
|
const rootStyle = useMemo(() => [
|
|
16
20
|
avatarStyles.root,
|
|
17
21
|
avatarStaticStyles.root,
|
|
18
|
-
|
|
22
|
+
getAvatarSizeStyle(avatarStyles.root, customSize, fontScaleFactor),
|
|
19
23
|
style
|
|
20
24
|
], [
|
|
21
25
|
avatarStyles.root,
|
|
22
26
|
customSize,
|
|
27
|
+
fontScaleFactor,
|
|
23
28
|
style
|
|
24
29
|
]);
|
|
25
30
|
return /* @__PURE__ */ jsx(Box, {
|
|
@@ -32,6 +37,7 @@ const AvatarText = memo(function AvatarText({ size = "md", variant = DEFAULT_AVA
|
|
|
32
37
|
color: "inherit",
|
|
33
38
|
variant: "inherit",
|
|
34
39
|
numberOfLines: 1,
|
|
40
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
35
41
|
style: avatarStyles.text,
|
|
36
42
|
children: initials || generateAvatarAbbreviation(name, abbreviationStrategy)
|
|
37
43
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AvatarText.js","names":["Text"],"sources":["../../../src/components/Avatar/AvatarText.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { Box } from '../Box';\nimport { Text } from '../Text';\nimport type { AvatarTextProps } from './types';\nimport {\n DEFAULT_AVATAR_SIZE,\n DEFAULT_AVATAR_VARIANT,\n generateAvatarAbbreviation,\n
|
|
1
|
+
{"version":3,"file":"AvatarText.js","names":["Text"],"sources":["../../../src/components/Avatar/AvatarText.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport { StyleSheet } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { useMaxFontSizeMultiplier } from '../../fontScaling/useMaxFontSizeMultiplier';\nimport { Box } from '../Box';\nimport { Text } from '../Text';\nimport type { AvatarTextProps } from './types';\nimport { useAvatarFontScale } from './useAvatarFontScale';\nimport {\n DEFAULT_AVATAR_SIZE,\n DEFAULT_AVATAR_VARIANT,\n generateAvatarAbbreviation,\n getAvatarSizeStyle,\n} from './utils';\n\nconst AvatarText = memo(function AvatarText({\n size = DEFAULT_AVATAR_SIZE,\n variant = DEFAULT_AVATAR_VARIANT,\n name,\n initials,\n abbreviationStrategy,\n customSize,\n maxFontSizeMultiplier,\n style,\n accessibilityLabel,\n ref,\n ...viewProps\n}: AvatarTextProps) {\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n avatarStyles.useVariants({ size, text: variant });\n const fontScaleFactor = useAvatarFontScale(resolvedMaxFontSizeMultiplier);\n\n const rootStyle = useMemo(\n () => [\n avatarStyles.root,\n avatarStaticStyles.root,\n getAvatarSizeStyle(avatarStyles.root, customSize, fontScaleFactor),\n style,\n ],\n [avatarStyles.root, customSize, fontScaleFactor, style],\n );\n\n return (\n <Box\n ref={ref}\n accessibilityRole=\"image\"\n accessibilityLabel={accessibilityLabel ?? name ?? initials}\n {...viewProps}\n style={rootStyle}\n >\n <Text\n color=\"inherit\"\n variant=\"inherit\"\n numberOfLines={1}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={avatarStyles.text}\n >\n {initials || generateAvatarAbbreviation(name, abbreviationStrategy)}\n </Text>\n </Box>\n );\n});\n\nAvatarText.displayName = 'AvatarText';\n\nconst avatarStaticStyles = StyleSheet.create({\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'hidden',\n },\n});\n\nexport { AvatarText };\n"],"mappings":";;;;;;;;;;;AAgBA,MAAM,aAAa,KAAK,SAAS,WAAW,EAC1C,OAAA,MACA,UAAU,wBACV,MACA,UACA,sBACA,YACA,uBACA,OACA,oBACA,KACA,GAAG,aACe;CAClB,MAAM,gCAAgC,yBAAyB,WAAW,sBAAsB;CAChG,aAAa,YAAY;EAAE;EAAM,MAAM;EAAS,CAAC;CACjD,MAAM,kBAAkB,mBAAmB,8BAA8B;CAEzE,MAAM,YAAY,cACV;EACJ,aAAa;EACb,mBAAmB;EACnB,mBAAmB,aAAa,MAAM,YAAY,gBAAgB;EAClE;EACD,EACD;EAAC,aAAa;EAAM;EAAY;EAAiB;EAAM,CACxD;CAED,OACE,oBAAC,KAAD;EACO;EACL,mBAAkB;EAClB,oBAAoB,sBAAsB,QAAQ;EAClD,GAAI;EACJ,OAAO;YAEP,oBAACA,QAAD;GACE,OAAM;GACN,SAAQ;GACR,eAAe;GACf,uBAAuB;GACvB,OAAO,aAAa;aAEnB,YAAY,2BAA2B,MAAM,qBAAqB;GAC9D,CAAA;EACH,CAAA;EAER;AAEF,WAAW,cAAc;AAEzB,MAAM,qBAAqB,WAAW,OAAO,EAC3C,MAAM;CACJ,YAAY;CACZ,gBAAgB;CAChB,UAAU;CACX,EACF,CAAC"}
|
|
@@ -5,17 +5,21 @@ import { Ref } from "react";
|
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Avatar/types.d.ts
|
|
8
|
-
interface
|
|
8
|
+
interface AvatarFontScalingProps {
|
|
9
|
+
/** Caps avatar content and geometry at the control scale. Set null to remove the cap. @default 2 */
|
|
10
|
+
maxFontSizeMultiplier?: number | null;
|
|
11
|
+
}
|
|
12
|
+
interface AvatarImageProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarImageProps, 'className' | 'srcSet'>, AvatarFontScalingProps {
|
|
9
13
|
/** Ref to the underlying View. */
|
|
10
14
|
ref?: Ref<View>;
|
|
11
15
|
/** Custom icon to display if the image fails and no text fallback is available. */
|
|
12
16
|
icon?: IconSlotType;
|
|
13
17
|
}
|
|
14
|
-
interface AvatarTextProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarTextProps, 'className'
|
|
18
|
+
interface AvatarTextProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarTextProps, 'className'>, AvatarFontScalingProps {
|
|
15
19
|
/** Ref to the underlying View. */
|
|
16
20
|
ref?: Ref<View>;
|
|
17
21
|
}
|
|
18
|
-
interface AvatarIconProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarIconProps<IconSlotType>, 'className'
|
|
22
|
+
interface AvatarIconProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarIconProps<IconSlotType>, 'className'>, AvatarFontScalingProps {
|
|
19
23
|
/** Ref to the underlying View. */
|
|
20
24
|
ref?: Ref<View>;
|
|
21
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/components/Avatar/types.ts"],"mappings":";;;;;;;UAaU,gBAAA,
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../../src/components/Avatar/types.ts"],"mappings":";;;;;;;UAaU,sBAAA;;EAER,qBAAA;AAAA;AAAA,UAGQ,gBAAA,SAEN,IAAA,CAAK,SAAA,eACL,IAAA,CAAK,yBAAA,2BACL,sBAAA;EAPF;EASA,GAAA,GAAM,GAAA,CAAI,IAAA;EANF;EAQR,IAAA,GAAO,YAAA;AAAA;AAAA,UAGC,eAAA,SAEN,IAAA,CAAK,SAAA,eACL,IAAA,CAAK,wBAAA,gBACL,sBAAA;EAZK;EAcP,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;AAAA,UAGF,eAAA,SAEN,IAAA,CAAK,SAAA,eACL,IAAA,CAAK,wBAAA,CAAyB,YAAA,iBAC9B,sBAAA;EAtBA;EAwBF,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;AAAA,UAGF,WAAA,SAAoB,IAAA,CAAK,gBAAA;EAzBT;EA2BxB,GAAA;AAAA"}
|
|
@@ -5,17 +5,21 @@ import { Ref } from "react";
|
|
|
5
5
|
import { View, ViewProps } from "react-native";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Avatar/types.d.ts
|
|
8
|
-
interface
|
|
8
|
+
interface AvatarFontScalingProps {
|
|
9
|
+
/** Caps avatar content and geometry at the control scale. Set null to remove the cap. @default 2 */
|
|
10
|
+
maxFontSizeMultiplier?: number | null;
|
|
11
|
+
}
|
|
12
|
+
interface AvatarImageProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarImageProps, 'className' | 'srcSet'>, AvatarFontScalingProps {
|
|
9
13
|
/** Ref to the underlying View. */
|
|
10
14
|
ref?: Ref<View>;
|
|
11
15
|
/** Custom icon to display if the image fails and no text fallback is available. */
|
|
12
16
|
icon?: IconSlotType;
|
|
13
17
|
}
|
|
14
|
-
interface AvatarTextProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarTextProps, 'className'
|
|
18
|
+
interface AvatarTextProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarTextProps, 'className'>, AvatarFontScalingProps {
|
|
15
19
|
/** Ref to the underlying View. */
|
|
16
20
|
ref?: Ref<View>;
|
|
17
21
|
}
|
|
18
|
-
interface AvatarIconProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarIconProps<IconSlotType>, 'className'
|
|
22
|
+
interface AvatarIconProps extends Omit<ViewProps, 'children'>, Omit<UniversalAvatarIconProps<IconSlotType>, 'className'>, AvatarFontScalingProps {
|
|
19
23
|
/** Ref to the underlying View. */
|
|
20
24
|
ref?: Ref<View>;
|
|
21
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/components/Avatar/types.ts"],"mappings":";;;;;;;UAaU,gBAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../../src/components/Avatar/types.ts"],"mappings":";;;;;;;UAaU,sBAAA;;EAER,qBAAA;AAAA;AAAA,UAGQ,gBAAA,SAEN,IAAA,CAAK,SAAA,eACL,IAAA,CAAK,yBAAA,2BACL,sBAAA;EAPF;EASA,GAAA,GAAM,GAAA,CAAI,IAAA;EANF;EAQR,IAAA,GAAO,YAAA;AAAA;AAAA,UAGC,eAAA,SAEN,IAAA,CAAK,SAAA,eACL,IAAA,CAAK,wBAAA,gBACL,sBAAA;EAZK;EAcP,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;AAAA,UAGF,eAAA,SAEN,IAAA,CAAK,SAAA,eACL,IAAA,CAAK,wBAAA,CAAyB,YAAA,iBAC9B,sBAAA;EAtBA;EAwBF,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;AAAA,UAGF,WAAA,SAAoB,IAAA,CAAK,gBAAA;EAzBT;EA2BxB,GAAA;AAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
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_fontScaling_useFontScale = require("../../fontScaling/useFontScale.cjs");
|
|
5
|
+
let generated_styles = require("../../../generated/styles");
|
|
6
|
+
//#region src/components/Avatar/useAvatarFontScale.ts
|
|
7
|
+
/** Keep every avatar content type on one size-aware scale that contains text and icons. */
|
|
8
|
+
function useAvatarFontScale(maxFontSizeMultiplier) {
|
|
9
|
+
const textStyle = generated_styles.avatarStyles.text;
|
|
10
|
+
const iconStyle = generated_styles.avatarStyles.icon;
|
|
11
|
+
const textScaleFactor = require_fontScaling_useFontScale.useComponentFontScale(maxFontSizeMultiplier, (typeof textStyle.lineHeight === "number" ? textStyle.lineHeight : void 0) ?? (typeof textStyle.fontSize === "number" ? textStyle.fontSize : void 0));
|
|
12
|
+
const iconScaleFactor = require_fontScaling_useFontScale.useComponentFontScale(maxFontSizeMultiplier, (typeof iconStyle.fontSize === "number" ? iconStyle.fontSize : void 0) ?? (typeof iconStyle.lineHeight === "number" ? iconStyle.lineHeight : void 0));
|
|
13
|
+
return Math.max(textScaleFactor, iconScaleFactor);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.useAvatarFontScale = useAvatarFontScale;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/Avatar/useAvatarFontScale.d.ts
|
|
3
|
+
/** Keep every avatar content type on one size-aware scale that contains text and icons. */
|
|
4
|
+
declare function useAvatarFontScale(maxFontSizeMultiplier?: number): number;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { useAvatarFontScale };
|
|
7
|
+
//# sourceMappingURL=useAvatarFontScale.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvatarFontScale.d.cts","names":[],"sources":["../../../src/components/Avatar/useAvatarFontScale.ts"],"mappings":";;;iBAMS,kBAAA,CAAmB,qBAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/components/Avatar/useAvatarFontScale.d.ts
|
|
3
|
+
/** Keep every avatar content type on one size-aware scale that contains text and icons. */
|
|
4
|
+
declare function useAvatarFontScale(maxFontSizeMultiplier?: number): number;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { useAvatarFontScale };
|
|
7
|
+
//# sourceMappingURL=useAvatarFontScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvatarFontScale.d.ts","names":[],"sources":["../../../src/components/Avatar/useAvatarFontScale.ts"],"mappings":";;;iBAMS,kBAAA,CAAmB,qBAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useComponentFontScale } from "../../fontScaling/useFontScale.js";
|
|
3
|
+
import { avatarStyles } from "../../../generated/styles";
|
|
4
|
+
//#region src/components/Avatar/useAvatarFontScale.ts
|
|
5
|
+
/** Keep every avatar content type on one size-aware scale that contains text and icons. */
|
|
6
|
+
function useAvatarFontScale(maxFontSizeMultiplier) {
|
|
7
|
+
const textStyle = avatarStyles.text;
|
|
8
|
+
const iconStyle = avatarStyles.icon;
|
|
9
|
+
const textScaleFactor = useComponentFontScale(maxFontSizeMultiplier, (typeof textStyle.lineHeight === "number" ? textStyle.lineHeight : void 0) ?? (typeof textStyle.fontSize === "number" ? textStyle.fontSize : void 0));
|
|
10
|
+
const iconScaleFactor = useComponentFontScale(maxFontSizeMultiplier, (typeof iconStyle.fontSize === "number" ? iconStyle.fontSize : void 0) ?? (typeof iconStyle.lineHeight === "number" ? iconStyle.lineHeight : void 0));
|
|
11
|
+
return Math.max(textScaleFactor, iconScaleFactor);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { useAvatarFontScale };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=useAvatarFontScale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvatarFontScale.js","names":[],"sources":["../../../src/components/Avatar/useAvatarFontScale.ts"],"sourcesContent":["import type { TextStyle } from 'react-native';\n\nimport { avatarStyles } from '../../../generated/styles';\nimport { useComponentFontScale } from '../../fontScaling/useFontScale';\n\n/** Keep every avatar content type on one size-aware scale that contains text and icons. */\nfunction useAvatarFontScale(maxFontSizeMultiplier?: number): number {\n const textStyle = avatarStyles.text as TextStyle;\n const iconStyle = avatarStyles.icon as TextStyle;\n const textScaleFactor = useComponentFontScale(\n maxFontSizeMultiplier,\n (typeof textStyle.lineHeight === 'number' ? textStyle.lineHeight : undefined) ??\n (typeof textStyle.fontSize === 'number' ? textStyle.fontSize : undefined),\n );\n const iconScaleFactor = useComponentFontScale(\n maxFontSizeMultiplier,\n (typeof iconStyle.fontSize === 'number' ? iconStyle.fontSize : undefined) ??\n (typeof iconStyle.lineHeight === 'number' ? iconStyle.lineHeight : undefined),\n );\n\n return Math.max(textScaleFactor, iconScaleFactor);\n}\n\nexport { useAvatarFontScale };\n"],"mappings":";;;;;AAMA,SAAS,mBAAmB,uBAAwC;CAClE,MAAM,YAAY,aAAa;CAC/B,MAAM,YAAY,aAAa;CAC/B,MAAM,kBAAkB,sBACtB,wBACC,OAAO,UAAU,eAAe,WAAW,UAAU,aAAa,KAAA,OAChE,OAAO,UAAU,aAAa,WAAW,UAAU,WAAW,KAAA,GAClE;CACD,MAAM,kBAAkB,sBACtB,wBACC,OAAO,UAAU,aAAa,WAAW,UAAU,WAAW,KAAA,OAC5D,OAAO,UAAU,eAAe,WAAW,UAAU,aAAa,KAAA,GACtE;CAED,OAAO,KAAK,IAAI,iBAAiB,gBAAgB"}
|
|
@@ -21,11 +21,14 @@ function generateAvatarAbbreviation(name, strategy = "firstAndLast") {
|
|
|
21
21
|
const initials = name.trim().split(/\s+/).filter(Boolean).map((word) => word[0]?.toUpperCase() ?? "");
|
|
22
22
|
return abbreviationStrategies[strategy](initials);
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
function getAvatarSizeStyle(rootStyle, customSize, fontScaleFactor) {
|
|
25
|
+
if (customSize === void 0 && fontScaleFactor === 1) return;
|
|
26
|
+
const width = customSize ?? rootStyle.width;
|
|
27
|
+
const height = customSize ?? rootStyle.height;
|
|
28
|
+
return typeof width === "number" && typeof height === "number" ? {
|
|
29
|
+
width: Math.round(width * fontScaleFactor),
|
|
30
|
+
height: Math.round(height * fontScaleFactor)
|
|
31
|
+
} : void 0;
|
|
29
32
|
}
|
|
30
33
|
function getDefaultAvatarIcon(variant) {
|
|
31
34
|
return DEFAULT_AVATAR_ICON[variant];
|
|
@@ -34,5 +37,5 @@ function getDefaultAvatarIcon(variant) {
|
|
|
34
37
|
exports.DEFAULT_AVATAR_SIZE = DEFAULT_AVATAR_SIZE;
|
|
35
38
|
exports.DEFAULT_AVATAR_VARIANT = DEFAULT_AVATAR_VARIANT;
|
|
36
39
|
exports.generateAvatarAbbreviation = generateAvatarAbbreviation;
|
|
37
|
-
exports.
|
|
40
|
+
exports.getAvatarSizeStyle = getAvatarSizeStyle;
|
|
38
41
|
exports.getDefaultAvatarIcon = getDefaultAvatarIcon;
|
|
@@ -7,8 +7,8 @@ import { ViewStyle } from "react-native";
|
|
|
7
7
|
declare const DEFAULT_AVATAR_SIZE: AvatarSize;
|
|
8
8
|
declare const DEFAULT_AVATAR_VARIANT: AvatarVariant;
|
|
9
9
|
declare function generateAvatarAbbreviation(name?: string, strategy?: AvatarAbbreviationStrategy): string;
|
|
10
|
-
declare function
|
|
10
|
+
declare function getAvatarSizeStyle(rootStyle: ViewStyle, customSize: number | undefined, fontScaleFactor: number): ViewStyle | undefined;
|
|
11
11
|
declare function getDefaultAvatarIcon(variant: AvatarVariant): IconSlotType;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_VARIANT, generateAvatarAbbreviation,
|
|
13
|
+
export { DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_VARIANT, generateAvatarAbbreviation, getAvatarSizeStyle, getDefaultAvatarIcon };
|
|
14
14
|
//# sourceMappingURL=utils.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../../src/components/Avatar/utils.ts"],"mappings":";;;;;;cAKM,mBAAA,EAAqB,UAAA;AAAA,cACrB,sBAAA,EAAwB,aAAA;AAAA,iBAoBrB,0BAAA,CACP,IAAA,WACA,QAAA,GAAU,0BAAA;AAAA,iBAgBH,
|
|
1
|
+
{"version":3,"file":"utils.d.cts","names":[],"sources":["../../../src/components/Avatar/utils.ts"],"mappings":";;;;;;cAKM,mBAAA,EAAqB,UAAA;AAAA,cACrB,sBAAA,EAAwB,aAAA;AAAA,iBAoBrB,0BAAA,CACP,IAAA,WACA,QAAA,GAAU,0BAAA;AAAA,iBAgBH,kBAAA,CACP,SAAA,EAAW,SAAA,EACX,UAAA,sBACA,eAAA,WACC,SAAA;AAAA,iBAgBM,oBAAA,CAAqB,OAAA,EAAS,aAAA,GAAgB,YAAA"}
|
|
@@ -7,8 +7,8 @@ import { ViewStyle } from "react-native";
|
|
|
7
7
|
declare const DEFAULT_AVATAR_SIZE: AvatarSize;
|
|
8
8
|
declare const DEFAULT_AVATAR_VARIANT: AvatarVariant;
|
|
9
9
|
declare function generateAvatarAbbreviation(name?: string, strategy?: AvatarAbbreviationStrategy): string;
|
|
10
|
-
declare function
|
|
10
|
+
declare function getAvatarSizeStyle(rootStyle: ViewStyle, customSize: number | undefined, fontScaleFactor: number): ViewStyle | undefined;
|
|
11
11
|
declare function getDefaultAvatarIcon(variant: AvatarVariant): IconSlotType;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_VARIANT, generateAvatarAbbreviation,
|
|
13
|
+
export { DEFAULT_AVATAR_SIZE, DEFAULT_AVATAR_VARIANT, generateAvatarAbbreviation, getAvatarSizeStyle, getDefaultAvatarIcon };
|
|
14
14
|
//# sourceMappingURL=utils.d.ts.map
|