@yahoo/uds-mobile 2.24.0-beta.5 → 2.24.0-beta.7
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 +6 -1
- package/dist/components/Avatar/AvatarIcon.cjs +2 -2
- package/dist/components/Avatar/AvatarIcon.js +2 -2
- package/dist/components/Avatar/AvatarIcon.js.map +1 -1
- package/dist/components/Avatar/AvatarImage.cjs +2 -2
- package/dist/components/Avatar/AvatarImage.js +2 -2
- package/dist/components/Avatar/AvatarImage.js.map +1 -1
- package/dist/components/Avatar/AvatarText.cjs +2 -2
- package/dist/components/Avatar/AvatarText.js +2 -2
- package/dist/components/Avatar/AvatarText.js.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/Button/buttonTheme.cjs +10 -6
- package/dist/components/Button/buttonTheme.d.cts +10 -5
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +10 -5
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +10 -6
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +17 -8
- package/dist/components/Button.js +17 -8
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +4 -2
- package/dist/components/Checkbox.js +4 -2
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +22 -19
- package/dist/components/Chip/ChipBase.js +22 -19
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Icon.cjs +3 -2
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +3 -2
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.cjs +10 -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 +10 -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 +2 -1
- package/dist/components/Radio/Radio.js +2 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Select/Select.cjs +16 -4
- package/dist/components/Select/Select.js +16 -4
- 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 +6 -6
- package/dist/components/Select/SelectItem.js +6 -6
- package/dist/components/Select/SelectItem.js.map +1 -1
- package/dist/components/Select/SelectTrigger.cjs +1 -1
- package/dist/components/Select/SelectTrigger.js +1 -1
- package/dist/components/Select/SelectTrigger.js.map +1 -1
- package/dist/components/Switch.cjs +4 -2
- package/dist/components/Switch.js +4 -2
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +1 -1
- package/dist/components/Tabs/Tab.js +1 -1
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/fontScaling/androidNonlinearFontScaling.cjs +174 -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 +175 -0
- package/dist/fontScaling/androidNonlinearFontScaling.js.map +1 -0
- package/dist/fontScaling/constants.cjs +4 -3
- package/dist/fontScaling/constants.d.cts +4 -3
- package/dist/fontScaling/constants.d.cts.map +1 -1
- package/dist/fontScaling/constants.d.ts +4 -3
- package/dist/fontScaling/constants.d.ts.map +1 -1
- package/dist/fontScaling/constants.js +4 -3
- package/dist/fontScaling/constants.js.map +1 -1
- package/dist/fontScaling/types.d.cts +3 -2
- package/dist/fontScaling/types.d.cts.map +1 -1
- package/dist/fontScaling/types.d.ts +3 -2
- package/dist/fontScaling/types.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.cjs +13 -4
- package/dist/fontScaling/useFontScale.d.cts +8 -3
- package/dist/fontScaling/useFontScale.d.cts.map +1 -1
- package/dist/fontScaling/useFontScale.d.ts +8 -3
- package/dist/fontScaling/useFontScale.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.js +14 -5
- package/dist/fontScaling/useFontScale.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/fontScaling/androidNonlinearFontScaling.ts
|
|
4
|
+
/**
|
|
5
|
+
* Android 14+ converts SP through a size-dependent curve. `Configuration.fontScale`
|
|
6
|
+
* is only the user's preference; multiplying by it directly does not reproduce the
|
|
7
|
+
* size that native Text renders.
|
|
8
|
+
*
|
|
9
|
+
* These lookup tables mirror Android's `FontScaleConverterFactory`. Values between
|
|
10
|
+
* table entries are linearly interpolated, as they are in the platform implementation.
|
|
11
|
+
*
|
|
12
|
+
* @see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/android/content/res/FontScaleConverterFactory.java
|
|
13
|
+
*/
|
|
14
|
+
const COMMON_SP_SIZES = [
|
|
15
|
+
8,
|
|
16
|
+
10,
|
|
17
|
+
12,
|
|
18
|
+
14,
|
|
19
|
+
18,
|
|
20
|
+
20,
|
|
21
|
+
24,
|
|
22
|
+
30,
|
|
23
|
+
100
|
|
24
|
+
];
|
|
25
|
+
const ANDROID_FONT_SCALE_CURVES = [
|
|
26
|
+
{
|
|
27
|
+
scale: 1.05,
|
|
28
|
+
dp: [
|
|
29
|
+
8.4,
|
|
30
|
+
10.5,
|
|
31
|
+
12.6,
|
|
32
|
+
14.8,
|
|
33
|
+
18.6,
|
|
34
|
+
20.6,
|
|
35
|
+
24.4,
|
|
36
|
+
30,
|
|
37
|
+
100
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
scale: 1.1,
|
|
42
|
+
dp: [
|
|
43
|
+
8.8,
|
|
44
|
+
11,
|
|
45
|
+
13.2,
|
|
46
|
+
15.6,
|
|
47
|
+
19.2,
|
|
48
|
+
21.2,
|
|
49
|
+
24.8,
|
|
50
|
+
30,
|
|
51
|
+
100
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
scale: 1.15,
|
|
56
|
+
dp: [
|
|
57
|
+
9.2,
|
|
58
|
+
11.5,
|
|
59
|
+
13.8,
|
|
60
|
+
16.4,
|
|
61
|
+
19.8,
|
|
62
|
+
21.8,
|
|
63
|
+
25.2,
|
|
64
|
+
30,
|
|
65
|
+
100
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
scale: 1.2,
|
|
70
|
+
dp: [
|
|
71
|
+
9.6,
|
|
72
|
+
12,
|
|
73
|
+
14.4,
|
|
74
|
+
17.2,
|
|
75
|
+
20.4,
|
|
76
|
+
22.4,
|
|
77
|
+
25.6,
|
|
78
|
+
30,
|
|
79
|
+
100
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
scale: 1.3,
|
|
84
|
+
dp: [
|
|
85
|
+
10.4,
|
|
86
|
+
13,
|
|
87
|
+
15.6,
|
|
88
|
+
18.8,
|
|
89
|
+
21.6,
|
|
90
|
+
23.6,
|
|
91
|
+
26.4,
|
|
92
|
+
30,
|
|
93
|
+
100
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
scale: 1.5,
|
|
98
|
+
dp: [
|
|
99
|
+
12,
|
|
100
|
+
15,
|
|
101
|
+
18,
|
|
102
|
+
22,
|
|
103
|
+
24,
|
|
104
|
+
26,
|
|
105
|
+
28,
|
|
106
|
+
30,
|
|
107
|
+
100
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
scale: 1.8,
|
|
112
|
+
dp: [
|
|
113
|
+
14.4,
|
|
114
|
+
18,
|
|
115
|
+
21.6,
|
|
116
|
+
24.4,
|
|
117
|
+
27.6,
|
|
118
|
+
30.8,
|
|
119
|
+
32.8,
|
|
120
|
+
34.8,
|
|
121
|
+
100
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
scale: 2,
|
|
126
|
+
dp: [
|
|
127
|
+
16,
|
|
128
|
+
20,
|
|
129
|
+
24,
|
|
130
|
+
26,
|
|
131
|
+
30,
|
|
132
|
+
34,
|
|
133
|
+
36,
|
|
134
|
+
38,
|
|
135
|
+
100
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
function lerp(start, end, amount) {
|
|
140
|
+
return start + (end - start) * amount;
|
|
141
|
+
}
|
|
142
|
+
function interpolateSize(fontSize, dpValues) {
|
|
143
|
+
if (fontSize <= 0) return fontSize;
|
|
144
|
+
for (let index = 0; index < COMMON_SP_SIZES.length; index += 1) {
|
|
145
|
+
const currentSp = COMMON_SP_SIZES[index];
|
|
146
|
+
if (fontSize === currentSp) return dpValues[index];
|
|
147
|
+
if (fontSize < currentSp) {
|
|
148
|
+
const previousSp = index === 0 ? 0 : COMMON_SP_SIZES[index - 1];
|
|
149
|
+
const previousDp = index === 0 ? 0 : dpValues[index - 1];
|
|
150
|
+
const amount = (fontSize - previousSp) / (currentSp - previousSp);
|
|
151
|
+
return lerp(previousDp, dpValues[index], amount);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const lastIndex = COMMON_SP_SIZES.length - 1;
|
|
155
|
+
return fontSize * (dpValues[lastIndex] / COMMON_SP_SIZES[lastIndex]);
|
|
156
|
+
}
|
|
157
|
+
/** Converts an SP value to its Android 14+ nonlinear DP size. */
|
|
158
|
+
function convertAndroidSpToDp(fontSize, fontScale) {
|
|
159
|
+
const firstCurve = ANDROID_FONT_SCALE_CURVES[0];
|
|
160
|
+
const lastCurve = ANDROID_FONT_SCALE_CURVES[ANDROID_FONT_SCALE_CURVES.length - 1];
|
|
161
|
+
if (fontScale < firstCurve.scale || fontScale > lastCurve.scale) return fontSize * fontScale;
|
|
162
|
+
for (let index = 0; index < ANDROID_FONT_SCALE_CURVES.length; index += 1) {
|
|
163
|
+
const curve = ANDROID_FONT_SCALE_CURVES[index];
|
|
164
|
+
if (fontScale === curve.scale) return interpolateSize(fontSize, curve.dp);
|
|
165
|
+
if (fontScale < curve.scale) {
|
|
166
|
+
const previousCurve = ANDROID_FONT_SCALE_CURVES[index - 1];
|
|
167
|
+
const amount = (fontScale - previousCurve.scale) / (curve.scale - previousCurve.scale);
|
|
168
|
+
return lerp(interpolateSize(fontSize, previousCurve.dp), interpolateSize(fontSize, curve.dp), amount);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return fontSize * fontScale;
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
exports.convertAndroidSpToDp = convertAndroidSpToDp;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/fontScaling/androidNonlinearFontScaling.d.ts
|
|
3
|
+
/** Converts an SP value to its Android 14+ nonlinear DP size. */
|
|
4
|
+
declare function convertAndroidSpToDp(fontSize: number, fontScale: number): number;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { convertAndroidSpToDp };
|
|
7
|
+
//# sourceMappingURL=androidNonlinearFontScaling.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"androidNonlinearFontScaling.d.cts","names":[],"sources":["../../src/fontScaling/androidNonlinearFontScaling.ts"],"mappings":";;;iBAmDS,oBAAA,CAAqB,QAAA,UAAkB,SAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/fontScaling/androidNonlinearFontScaling.d.ts
|
|
3
|
+
/** Converts an SP value to its Android 14+ nonlinear DP size. */
|
|
4
|
+
declare function convertAndroidSpToDp(fontSize: number, fontScale: number): number;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { convertAndroidSpToDp };
|
|
7
|
+
//# sourceMappingURL=androidNonlinearFontScaling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"androidNonlinearFontScaling.d.ts","names":[],"sources":["../../src/fontScaling/androidNonlinearFontScaling.ts"],"mappings":";;;iBAmDS,oBAAA,CAAqB,QAAA,UAAkB,SAAA"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
//#region src/fontScaling/androidNonlinearFontScaling.ts
|
|
3
|
+
/**
|
|
4
|
+
* Android 14+ converts SP through a size-dependent curve. `Configuration.fontScale`
|
|
5
|
+
* is only the user's preference; multiplying by it directly does not reproduce the
|
|
6
|
+
* size that native Text renders.
|
|
7
|
+
*
|
|
8
|
+
* These lookup tables mirror Android's `FontScaleConverterFactory`. Values between
|
|
9
|
+
* table entries are linearly interpolated, as they are in the platform implementation.
|
|
10
|
+
*
|
|
11
|
+
* @see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/android/content/res/FontScaleConverterFactory.java
|
|
12
|
+
*/
|
|
13
|
+
const COMMON_SP_SIZES = [
|
|
14
|
+
8,
|
|
15
|
+
10,
|
|
16
|
+
12,
|
|
17
|
+
14,
|
|
18
|
+
18,
|
|
19
|
+
20,
|
|
20
|
+
24,
|
|
21
|
+
30,
|
|
22
|
+
100
|
|
23
|
+
];
|
|
24
|
+
const ANDROID_FONT_SCALE_CURVES = [
|
|
25
|
+
{
|
|
26
|
+
scale: 1.05,
|
|
27
|
+
dp: [
|
|
28
|
+
8.4,
|
|
29
|
+
10.5,
|
|
30
|
+
12.6,
|
|
31
|
+
14.8,
|
|
32
|
+
18.6,
|
|
33
|
+
20.6,
|
|
34
|
+
24.4,
|
|
35
|
+
30,
|
|
36
|
+
100
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
scale: 1.1,
|
|
41
|
+
dp: [
|
|
42
|
+
8.8,
|
|
43
|
+
11,
|
|
44
|
+
13.2,
|
|
45
|
+
15.6,
|
|
46
|
+
19.2,
|
|
47
|
+
21.2,
|
|
48
|
+
24.8,
|
|
49
|
+
30,
|
|
50
|
+
100
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
scale: 1.15,
|
|
55
|
+
dp: [
|
|
56
|
+
9.2,
|
|
57
|
+
11.5,
|
|
58
|
+
13.8,
|
|
59
|
+
16.4,
|
|
60
|
+
19.8,
|
|
61
|
+
21.8,
|
|
62
|
+
25.2,
|
|
63
|
+
30,
|
|
64
|
+
100
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
scale: 1.2,
|
|
69
|
+
dp: [
|
|
70
|
+
9.6,
|
|
71
|
+
12,
|
|
72
|
+
14.4,
|
|
73
|
+
17.2,
|
|
74
|
+
20.4,
|
|
75
|
+
22.4,
|
|
76
|
+
25.6,
|
|
77
|
+
30,
|
|
78
|
+
100
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
scale: 1.3,
|
|
83
|
+
dp: [
|
|
84
|
+
10.4,
|
|
85
|
+
13,
|
|
86
|
+
15.6,
|
|
87
|
+
18.8,
|
|
88
|
+
21.6,
|
|
89
|
+
23.6,
|
|
90
|
+
26.4,
|
|
91
|
+
30,
|
|
92
|
+
100
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
scale: 1.5,
|
|
97
|
+
dp: [
|
|
98
|
+
12,
|
|
99
|
+
15,
|
|
100
|
+
18,
|
|
101
|
+
22,
|
|
102
|
+
24,
|
|
103
|
+
26,
|
|
104
|
+
28,
|
|
105
|
+
30,
|
|
106
|
+
100
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
scale: 1.8,
|
|
111
|
+
dp: [
|
|
112
|
+
14.4,
|
|
113
|
+
18,
|
|
114
|
+
21.6,
|
|
115
|
+
24.4,
|
|
116
|
+
27.6,
|
|
117
|
+
30.8,
|
|
118
|
+
32.8,
|
|
119
|
+
34.8,
|
|
120
|
+
100
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
scale: 2,
|
|
125
|
+
dp: [
|
|
126
|
+
16,
|
|
127
|
+
20,
|
|
128
|
+
24,
|
|
129
|
+
26,
|
|
130
|
+
30,
|
|
131
|
+
34,
|
|
132
|
+
36,
|
|
133
|
+
38,
|
|
134
|
+
100
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
];
|
|
138
|
+
function lerp(start, end, amount) {
|
|
139
|
+
return start + (end - start) * amount;
|
|
140
|
+
}
|
|
141
|
+
function interpolateSize(fontSize, dpValues) {
|
|
142
|
+
if (fontSize <= 0) return fontSize;
|
|
143
|
+
for (let index = 0; index < COMMON_SP_SIZES.length; index += 1) {
|
|
144
|
+
const currentSp = COMMON_SP_SIZES[index];
|
|
145
|
+
if (fontSize === currentSp) return dpValues[index];
|
|
146
|
+
if (fontSize < currentSp) {
|
|
147
|
+
const previousSp = index === 0 ? 0 : COMMON_SP_SIZES[index - 1];
|
|
148
|
+
const previousDp = index === 0 ? 0 : dpValues[index - 1];
|
|
149
|
+
const amount = (fontSize - previousSp) / (currentSp - previousSp);
|
|
150
|
+
return lerp(previousDp, dpValues[index], amount);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const lastIndex = COMMON_SP_SIZES.length - 1;
|
|
154
|
+
return fontSize * (dpValues[lastIndex] / COMMON_SP_SIZES[lastIndex]);
|
|
155
|
+
}
|
|
156
|
+
/** Converts an SP value to its Android 14+ nonlinear DP size. */
|
|
157
|
+
function convertAndroidSpToDp(fontSize, fontScale) {
|
|
158
|
+
const firstCurve = ANDROID_FONT_SCALE_CURVES[0];
|
|
159
|
+
const lastCurve = ANDROID_FONT_SCALE_CURVES[ANDROID_FONT_SCALE_CURVES.length - 1];
|
|
160
|
+
if (fontScale < firstCurve.scale || fontScale > lastCurve.scale) return fontSize * fontScale;
|
|
161
|
+
for (let index = 0; index < ANDROID_FONT_SCALE_CURVES.length; index += 1) {
|
|
162
|
+
const curve = ANDROID_FONT_SCALE_CURVES[index];
|
|
163
|
+
if (fontScale === curve.scale) return interpolateSize(fontSize, curve.dp);
|
|
164
|
+
if (fontScale < curve.scale) {
|
|
165
|
+
const previousCurve = ANDROID_FONT_SCALE_CURVES[index - 1];
|
|
166
|
+
const amount = (fontScale - previousCurve.scale) / (curve.scale - previousCurve.scale);
|
|
167
|
+
return lerp(interpolateSize(fontSize, previousCurve.dp), interpolateSize(fontSize, curve.dp), amount);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return fontSize * fontScale;
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { convertAndroidSpToDp };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=androidNonlinearFontScaling.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"androidNonlinearFontScaling.js","names":[],"sources":["../../src/fontScaling/androidNonlinearFontScaling.ts"],"sourcesContent":["/**\n * Android 14+ converts SP through a size-dependent curve. `Configuration.fontScale`\n * is only the user's preference; multiplying by it directly does not reproduce the\n * size that native Text renders.\n *\n * These lookup tables mirror Android's `FontScaleConverterFactory`. Values between\n * table entries are linearly interpolated, as they are in the platform implementation.\n *\n * @see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/android/content/res/FontScaleConverterFactory.java\n */\nconst COMMON_SP_SIZES = [8, 10, 12, 14, 18, 20, 24, 30, 100] as const;\n\nconst ANDROID_FONT_SCALE_CURVES = [\n { scale: 1.05, dp: [8.4, 10.5, 12.6, 14.8, 18.6, 20.6, 24.4, 30, 100] },\n { scale: 1.1, dp: [8.8, 11, 13.2, 15.6, 19.2, 21.2, 24.8, 30, 100] },\n { scale: 1.15, dp: [9.2, 11.5, 13.8, 16.4, 19.8, 21.8, 25.2, 30, 100] },\n { scale: 1.2, dp: [9.6, 12, 14.4, 17.2, 20.4, 22.4, 25.6, 30, 100] },\n { scale: 1.3, dp: [10.4, 13, 15.6, 18.8, 21.6, 23.6, 26.4, 30, 100] },\n { scale: 1.5, dp: [12, 15, 18, 22, 24, 26, 28, 30, 100] },\n { scale: 1.8, dp: [14.4, 18, 21.6, 24.4, 27.6, 30.8, 32.8, 34.8, 100] },\n { scale: 2, dp: [16, 20, 24, 26, 30, 34, 36, 38, 100] },\n] as const;\n\nfunction lerp(start: number, end: number, amount: number): number {\n return start + (end - start) * amount;\n}\n\nfunction interpolateSize(fontSize: number, dpValues: readonly number[]): number {\n if (fontSize <= 0) {\n return fontSize;\n }\n\n for (let index = 0; index < COMMON_SP_SIZES.length; index += 1) {\n const currentSp = COMMON_SP_SIZES[index];\n if (fontSize === currentSp) {\n return dpValues[index] as number;\n }\n if (fontSize < currentSp) {\n const previousSp = index === 0 ? 0 : COMMON_SP_SIZES[index - 1];\n const previousDp = index === 0 ? 0 : (dpValues[index - 1] as number);\n const amount = (fontSize - previousSp) / (currentSp - previousSp);\n return lerp(previousDp, dpValues[index] as number, amount);\n }\n }\n\n // Android extrapolates beyond the table with the last entry's ratio.\n const lastIndex = COMMON_SP_SIZES.length - 1;\n return fontSize * ((dpValues[lastIndex] as number) / COMMON_SP_SIZES[lastIndex]);\n}\n\n/** Converts an SP value to its Android 14+ nonlinear DP size. */\nfunction convertAndroidSpToDp(fontSize: number, fontScale: number): number {\n const firstCurve = ANDROID_FONT_SCALE_CURVES[0];\n const lastCurve = ANDROID_FONT_SCALE_CURVES[ANDROID_FONT_SCALE_CURVES.length - 1];\n\n // Outside Android's curve range, the platform falls back to a linear table.\n if (fontScale < firstCurve.scale || fontScale > lastCurve.scale) {\n return fontSize * fontScale;\n }\n\n for (let index = 0; index < ANDROID_FONT_SCALE_CURVES.length; index += 1) {\n const curve = ANDROID_FONT_SCALE_CURVES[index];\n if (fontScale === curve.scale) {\n return interpolateSize(fontSize, curve.dp);\n }\n if (fontScale < curve.scale) {\n const previousCurve = ANDROID_FONT_SCALE_CURVES[index - 1];\n const amount = (fontScale - previousCurve.scale) / (curve.scale - previousCurve.scale);\n return lerp(\n interpolateSize(fontSize, previousCurve.dp),\n interpolateSize(fontSize, curve.dp),\n amount,\n );\n }\n }\n\n return fontSize * fontScale;\n}\n\nexport { convertAndroidSpToDp };\n"],"mappings":";;;;;;;;;;;;AAUA,MAAM,kBAAkB;CAAC;CAAG;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;CAAI;AAE5D,MAAM,4BAA4B;CAChC;EAAE,OAAO;EAAM,IAAI;GAAC;GAAK;GAAM;GAAM;GAAM;GAAM;GAAM;GAAM;GAAI;GAAI;EAAE;CACvE;EAAE,OAAO;EAAK,IAAI;GAAC;GAAK;GAAI;GAAM;GAAM;GAAM;GAAM;GAAM;GAAI;GAAI;EAAE;CACpE;EAAE,OAAO;EAAM,IAAI;GAAC;GAAK;GAAM;GAAM;GAAM;GAAM;GAAM;GAAM;GAAI;GAAI;EAAE;CACvE;EAAE,OAAO;EAAK,IAAI;GAAC;GAAK;GAAI;GAAM;GAAM;GAAM;GAAM;GAAM;GAAI;GAAI;EAAE;CACpE;EAAE,OAAO;EAAK,IAAI;GAAC;GAAM;GAAI;GAAM;GAAM;GAAM;GAAM;GAAM;GAAI;GAAI;EAAE;CACrE;EAAE,OAAO;EAAK,IAAI;GAAC;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;EAAE;CACzD;EAAE,OAAO;EAAK,IAAI;GAAC;GAAM;GAAI;GAAM;GAAM;GAAM;GAAM;GAAM;GAAM;GAAI;EAAE;CACvE;EAAE,OAAO;EAAG,IAAI;GAAC;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;GAAI;EAAE;CACxD;AAED,SAAS,KAAK,OAAe,KAAa,QAAwB;CAChE,OAAO,SAAS,MAAM,SAAS;;AAGjC,SAAS,gBAAgB,UAAkB,UAAqC;CAC9E,IAAI,YAAY,GACd,OAAO;CAGT,KAAK,IAAI,QAAQ,GAAG,QAAQ,gBAAgB,QAAQ,SAAS,GAAG;EAC9D,MAAM,YAAY,gBAAgB;EAClC,IAAI,aAAa,WACf,OAAO,SAAS;EAElB,IAAI,WAAW,WAAW;GACxB,MAAM,aAAa,UAAU,IAAI,IAAI,gBAAgB,QAAQ;GAC7D,MAAM,aAAa,UAAU,IAAI,IAAK,SAAS,QAAQ;GACvD,MAAM,UAAU,WAAW,eAAe,YAAY;GACtD,OAAO,KAAK,YAAY,SAAS,QAAkB,OAAO;;;CAK9D,MAAM,YAAY,gBAAgB,SAAS;CAC3C,OAAO,YAAa,SAAS,aAAwB,gBAAgB;;;AAIvE,SAAS,qBAAqB,UAAkB,WAA2B;CACzE,MAAM,aAAa,0BAA0B;CAC7C,MAAM,YAAY,0BAA0B,0BAA0B,SAAS;CAG/E,IAAI,YAAY,WAAW,SAAS,YAAY,UAAU,OACxD,OAAO,WAAW;CAGpB,KAAK,IAAI,QAAQ,GAAG,QAAQ,0BAA0B,QAAQ,SAAS,GAAG;EACxE,MAAM,QAAQ,0BAA0B;EACxC,IAAI,cAAc,MAAM,OACtB,OAAO,gBAAgB,UAAU,MAAM,GAAG;EAE5C,IAAI,YAAY,MAAM,OAAO;GAC3B,MAAM,gBAAgB,0BAA0B,QAAQ;GACxD,MAAM,UAAU,YAAY,cAAc,UAAU,MAAM,QAAQ,cAAc;GAChF,OAAO,KACL,gBAAgB,UAAU,cAAc,GAAG,EAC3C,gBAAgB,UAAU,MAAM,GAAG,EACnC,OACD;;;CAIL,OAAO,WAAW"}
|
|
@@ -60,9 +60,10 @@ const TYPE_SCALE_CURVE = {
|
|
|
60
60
|
*/
|
|
61
61
|
const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = Object.freeze(Object.fromEntries(Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [variant, cap === null ? 2 : Math.min(cap, 2)])));
|
|
62
62
|
/**
|
|
63
|
-
* Default cap for control-internal text and
|
|
64
|
-
* Switch, Chip, Tabs,
|
|
65
|
-
*
|
|
63
|
+
* Default cap for control-internal text, icons, and geometry (Button,
|
|
64
|
+
* Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, Pagination, and
|
|
65
|
+
* Icon). Controls have bounded layouts, so they get the supported ceiling
|
|
66
|
+
* rather than a looser per-variant cap.
|
|
66
67
|
*/
|
|
67
68
|
const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
68
69
|
/**
|
|
@@ -40,9 +40,10 @@ declare const TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScaling
|
|
|
40
40
|
*/
|
|
41
41
|
declare const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
42
42
|
/**
|
|
43
|
-
* Default cap for control-internal text and
|
|
44
|
-
* Switch, Chip, Tabs,
|
|
45
|
-
*
|
|
43
|
+
* Default cap for control-internal text, icons, and geometry (Button,
|
|
44
|
+
* Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, Pagination, and
|
|
45
|
+
* Icon). Controls have bounded layouts, so they get the supported ceiling
|
|
46
|
+
* rather than a looser per-variant cap.
|
|
46
47
|
*/
|
|
47
48
|
declare const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
48
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;;AAGmD;;;;;AAarB;;;;cAAxB,wBAAA;;;;;;;;;;;;;AAgB0E;;cAA1E,gBAAA,EAAkB,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;;cAgCvD,iCAAA,EAAmC,QAAA,CACvC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA
|
|
1
|
+
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;;AAGmD;;;;;AAarB;;;;cAAxB,wBAAA;;;;;;;;;;;;;AAgB0E;;cAA1E,gBAAA,EAAkB,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;;cAgCvD,iCAAA,EAAmC,QAAA,CACvC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;cAgBxB,wCAAA;;;;;AAAwC;;;;cAUxC,0BAAA,EAA4B,QAAA,CAChC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,WAAA,CAAY,SAAA"}
|
|
@@ -40,9 +40,10 @@ declare const TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScaling
|
|
|
40
40
|
*/
|
|
41
41
|
declare const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
42
42
|
/**
|
|
43
|
-
* Default cap for control-internal text and
|
|
44
|
-
* Switch, Chip, Tabs,
|
|
45
|
-
*
|
|
43
|
+
* Default cap for control-internal text, icons, and geometry (Button,
|
|
44
|
+
* Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, Pagination, and
|
|
45
|
+
* Icon). Controls have bounded layouts, so they get the supported ceiling
|
|
46
|
+
* rather than a looser per-variant cap.
|
|
46
47
|
*/
|
|
47
48
|
declare const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
48
49
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;;AAGmD;;;;;AAarB;;;;cAAxB,wBAAA;;;;;;;;;;;;;AAgB0E;;cAA1E,gBAAA,EAAkB,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;;cAgCvD,iCAAA,EAAmC,QAAA,CACvC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;;AAGmD;;;;;AAarB;;;;cAAxB,wBAAA;;;;;;;;;;;;;AAgB0E;;cAA1E,gBAAA,EAAkB,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;;cAgCvD,iCAAA,EAAmC,QAAA,CACvC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;cAgBxB,wCAAA;;;;;AAAwC;;;;cAUxC,0BAAA,EAA4B,QAAA,CAChC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,WAAA,CAAY,SAAA"}
|
|
@@ -59,9 +59,10 @@ const TYPE_SCALE_CURVE = {
|
|
|
59
59
|
*/
|
|
60
60
|
const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = Object.freeze(Object.fromEntries(Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [variant, cap === null ? 2 : Math.min(cap, 2)])));
|
|
61
61
|
/**
|
|
62
|
-
* Default cap for control-internal text and
|
|
63
|
-
* Switch, Chip, Tabs,
|
|
64
|
-
*
|
|
62
|
+
* Default cap for control-internal text, icons, and geometry (Button,
|
|
63
|
+
* Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, Pagination, and
|
|
64
|
+
* Icon). Controls have bounded layouts, so they get the supported ceiling
|
|
65
|
+
* rather than a looser per-variant cap.
|
|
65
66
|
*/
|
|
66
67
|
const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
67
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../../src/fontScaling/constants.ts"],"sourcesContent":["import type { TextProps as RNTextProps } from 'react-native';\n\nimport type { TextVariant } from '../components/Text';\nimport type { FontScalingCapValue } from './types';\n\n/**\n * The largest OS font scale UDS components are designed to support.\n *\n * Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so\n * no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger\n * Text is claimable at \"at least 200% or the maximum font size for the\n * system\", so a 2x ceiling still qualifies. Note that iOS offers scales beyond\n * this (up to 3.571x): with this ceiling in place the top accessibility sizes\n * render alike, and an app that wants to follow the OS further can raise or\n * remove the caps via `UDSFontScalingProvider`.\n */\nconst MAX_SUPPORTED_FONT_SCALE = 2;\n\n/**\n * How far each text style would grow if only legibility mattered, following\n * the shape of Apple's Dynamic Type ramps: the larger a style starts, the less\n * it multiplies. At iOS's largest accessibility size the system grows body\n * (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers\n * are larger than largeTitle, so they taper hardest.\n *\n * Caps are chosen by the size a style starts at rather than by which family it\n * belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`\n * (20pt) matches `title4` (20pt). `null` means \"no cap from the curve\" — those\n * are reading sizes, where legibility argues for following the OS.\n *\n * The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.\n */\nconst TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>> = {\n display1: 1.5,\n display2: 1.6,\n display3: 1.75,\n title1: 1.8,\n title2: 2,\n title3: 2.2,\n title4: 2.4,\n headline1: 2.5,\n ui1: 2.2,\n ui2: 2.4,\n body1: null,\n label1: null,\n label2: null,\n label3: null,\n label4: null,\n caption1: null,\n caption2: null,\n legal1: null,\n ui3: null,\n ui4: null,\n ui5: null,\n ui6: null,\n};\n\n/**\n * Default per-variant caps on OS font scaling, applied by `Text` when no\n * explicit prop or provider config overrides them: the legibility curve in\n * {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.\n *\n * Keys are base variants; `/emphasized` twins resolve to their base.\n */\nconst DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<\n Partial<Record<TextVariant, FontScalingCapValue>>\n> = Object.freeze(\n Object.fromEntries(\n Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [\n variant,\n cap === null ? MAX_SUPPORTED_FONT_SCALE : Math.min(cap, MAX_SUPPORTED_FONT_SCALE),\n ]),\n ) as Partial<Record<TextVariant, FontScalingCapValue>>,\n);\n\n/**\n * Default cap for control-internal text and
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/fontScaling/constants.ts"],"sourcesContent":["import type { TextProps as RNTextProps } from 'react-native';\n\nimport type { TextVariant } from '../components/Text';\nimport type { FontScalingCapValue } from './types';\n\n/**\n * The largest OS font scale UDS components are designed to support.\n *\n * Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so\n * no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger\n * Text is claimable at \"at least 200% or the maximum font size for the\n * system\", so a 2x ceiling still qualifies. Note that iOS offers scales beyond\n * this (up to 3.571x): with this ceiling in place the top accessibility sizes\n * render alike, and an app that wants to follow the OS further can raise or\n * remove the caps via `UDSFontScalingProvider`.\n */\nconst MAX_SUPPORTED_FONT_SCALE = 2;\n\n/**\n * How far each text style would grow if only legibility mattered, following\n * the shape of Apple's Dynamic Type ramps: the larger a style starts, the less\n * it multiplies. At iOS's largest accessibility size the system grows body\n * (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers\n * are larger than largeTitle, so they taper hardest.\n *\n * Caps are chosen by the size a style starts at rather than by which family it\n * belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`\n * (20pt) matches `title4` (20pt). `null` means \"no cap from the curve\" — those\n * are reading sizes, where legibility argues for following the OS.\n *\n * The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.\n */\nconst TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>> = {\n display1: 1.5,\n display2: 1.6,\n display3: 1.75,\n title1: 1.8,\n title2: 2,\n title3: 2.2,\n title4: 2.4,\n headline1: 2.5,\n ui1: 2.2,\n ui2: 2.4,\n body1: null,\n label1: null,\n label2: null,\n label3: null,\n label4: null,\n caption1: null,\n caption2: null,\n legal1: null,\n ui3: null,\n ui4: null,\n ui5: null,\n ui6: null,\n};\n\n/**\n * Default per-variant caps on OS font scaling, applied by `Text` when no\n * explicit prop or provider config overrides them: the legibility curve in\n * {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.\n *\n * Keys are base variants; `/emphasized` twins resolve to their base.\n */\nconst DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<\n Partial<Record<TextVariant, FontScalingCapValue>>\n> = Object.freeze(\n Object.fromEntries(\n Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [\n variant,\n cap === null ? MAX_SUPPORTED_FONT_SCALE : Math.min(cap, MAX_SUPPORTED_FONT_SCALE),\n ]),\n ) as Partial<Record<TextVariant, FontScalingCapValue>>,\n);\n\n/**\n * Default cap for control-internal text, icons, and geometry (Button,\n * Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, Pagination, and\n * Icon). Controls have bounded layouts, so they get the supported ceiling\n * rather than a looser per-variant cap.\n */\nconst DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = MAX_SUPPORTED_FONT_SCALE;\n\n/**\n * iOS Dynamic Type curve used by each UDS typography tier. React Native uses\n * the selected system text style's curve while preserving the configured UDS\n * font size. Android ignores `dynamicTypeRamp` and continues to use its native\n * nonlinear font scaling.\n *\n * Keys are base variants; `/emphasized` twins resolve to their base.\n */\nconst DEFAULT_DYNAMIC_TYPE_RAMPS: Readonly<\n Partial<Record<TextVariant, NonNullable<RNTextProps['dynamicTypeRamp']>>>\n> = {\n display1: 'largeTitle',\n display2: 'largeTitle',\n display3: 'largeTitle',\n title1: 'title1',\n title2: 'title2',\n title3: 'title3',\n title4: 'title3',\n headline1: 'headline',\n body1: 'body',\n label1: 'callout',\n label2: 'subheadline',\n label3: 'footnote',\n label4: 'caption1',\n caption1: 'caption1',\n caption2: 'caption2',\n legal1: 'caption2',\n ui1: 'title3',\n ui2: 'title3',\n ui3: 'callout',\n ui4: 'subheadline',\n ui5: 'footnote',\n ui6: 'caption2',\n};\n\nexport {\n DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER,\n DEFAULT_DYNAMIC_TYPE_RAMPS,\n DEFAULT_MAX_FONT_SIZE_MULTIPLIERS,\n MAX_SUPPORTED_FONT_SCALE,\n TYPE_SCALE_CURVE,\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAM,2BAA2B;;;;;;;;;;;;;;;AAgBjC,MAAM,mBAAgF;CACpF,UAAU;CACV,UAAU;CACV,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,KAAK;CACL,KAAK;CACL,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,UAAU;CACV,QAAQ;CACR,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN;;;;;;;;AASD,MAAM,oCAEF,OAAO,OACT,OAAO,YACL,OAAO,QAAQ,iBAAiB,CAAC,KAAK,CAAC,SAAS,SAAS,CACvD,SACA,QAAQ,OAAA,IAAkC,KAAK,IAAI,KAAA,EAA8B,CAClF,CAAC,CACH,CACF;;;;;;;AAQD,MAAM,2CAAA;;;;;;;;;AAUN,MAAM,6BAEF;CACF,UAAU;CACV,UAAU;CACV,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,UAAU;CACV,QAAQ;CACR,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN"}
|
|
@@ -36,8 +36,9 @@ interface FontScalingConfig {
|
|
|
36
36
|
default?: FontScalingCapValue;
|
|
37
37
|
/**
|
|
38
38
|
* Cap for control-internal text, icons, and geometry in Button, Checkbox,
|
|
39
|
-
* Radio, Switch, Chip,
|
|
40
|
-
* multicolor SVGs.
|
|
39
|
+
* Radio, Switch, Chip, Tabs, Input, Select, Avatar, and Pagination, plus
|
|
40
|
+
* standalone `Icon` glyphs and multicolor SVGs. Link resolves through its
|
|
41
|
+
* typography variant instead of the control cap.
|
|
41
42
|
* @default 2
|
|
42
43
|
*/
|
|
43
44
|
control?: FontScalingCapValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAOR;;;;;;EAAA,OAAA;
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAOR;;;;;;EAAA,OAAA;EAoBmB;;;;;;EAbnB,OAAA,GAAU,mBAAA;;;;;;;;EAQV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
|
|
@@ -36,8 +36,9 @@ interface FontScalingConfig {
|
|
|
36
36
|
default?: FontScalingCapValue;
|
|
37
37
|
/**
|
|
38
38
|
* Cap for control-internal text, icons, and geometry in Button, Checkbox,
|
|
39
|
-
* Radio, Switch, Chip,
|
|
40
|
-
* multicolor SVGs.
|
|
39
|
+
* Radio, Switch, Chip, Tabs, Input, Select, Avatar, and Pagination, plus
|
|
40
|
+
* standalone `Icon` glyphs and multicolor SVGs. Link resolves through its
|
|
41
|
+
* typography variant instead of the control cap.
|
|
41
42
|
* @default 2
|
|
42
43
|
*/
|
|
43
44
|
control?: FontScalingCapValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAOR;;;;;;EAAA,OAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAOR;;;;;;EAAA,OAAA;EAoBmB;;;;;;EAbnB,OAAA,GAAU,mBAAA;;;;;;;;EAQV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
const require_fontScaling_androidNonlinearFontScaling = require("./androidNonlinearFontScaling.cjs");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_native = require("react-native");
|
|
6
7
|
//#region src/fontScaling/useFontScale.ts
|
|
@@ -12,21 +13,29 @@ function getFontScale() {
|
|
|
12
13
|
return react_native.Dimensions.get("window").fontScale;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
|
-
* The
|
|
16
|
-
* around scaled text (e.g. a checkbox box growing with its
|
|
16
|
+
* The effective scale for `fontSize`, clamped to `[1, cap]`, for sizing
|
|
17
|
+
* containers around scaled text (e.g. a checkbox box growing with its
|
|
18
|
+
* checkmark).
|
|
17
19
|
*
|
|
18
20
|
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
19
21
|
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
20
22
|
* is never below 1 so containers never shrink under their token metrics
|
|
21
23
|
* (font scales < 1 shrink text only, as today).
|
|
22
24
|
*
|
|
25
|
+
* Pass the SP size that the geometry accompanies on Android so this mirrors
|
|
26
|
+
* Android 14+'s nonlinear scaling. Omitting `fontSize` preserves the legacy
|
|
27
|
+
* scalar behavior for custom callers that do not know their base size.
|
|
28
|
+
*
|
|
23
29
|
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
24
30
|
* components re-render solely when the user changes the OS text size.
|
|
25
31
|
*/
|
|
26
|
-
function useFontScale(cap) {
|
|
32
|
+
function useFontScale(cap, fontSize) {
|
|
27
33
|
const fontScale = (0, react.useSyncExternalStore)(subscribe, getFontScale, getFontScale);
|
|
28
34
|
const effectiveCap = typeof cap === "number" && cap >= 1 ? cap : Number.POSITIVE_INFINITY;
|
|
29
|
-
|
|
35
|
+
const cappedFontScale = Math.min(fontScale, effectiveCap);
|
|
36
|
+
const platformVersion = Number(react_native.Platform.Version);
|
|
37
|
+
const nativeScale = react_native.Platform.OS === "android" && platformVersion >= 34 && typeof fontSize === "number" && fontSize > 0 ? require_fontScaling_androidNonlinearFontScaling.convertAndroidSpToDp(fontSize, cappedFontScale) / fontSize : cappedFontScale;
|
|
38
|
+
return Math.max(1, nativeScale);
|
|
30
39
|
}
|
|
31
40
|
//#endregion
|
|
32
41
|
exports.useFontScale = useFontScale;
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/fontScaling/useFontScale.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
5
|
-
* around scaled text (e.g. a checkbox box growing with its
|
|
4
|
+
* The effective scale for `fontSize`, clamped to `[1, cap]`, for sizing
|
|
5
|
+
* containers around scaled text (e.g. a checkbox box growing with its
|
|
6
|
+
* checkmark).
|
|
6
7
|
*
|
|
7
8
|
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
8
9
|
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
9
10
|
* is never below 1 so containers never shrink under their token metrics
|
|
10
11
|
* (font scales < 1 shrink text only, as today).
|
|
11
12
|
*
|
|
13
|
+
* Pass the SP size that the geometry accompanies on Android so this mirrors
|
|
14
|
+
* Android 14+'s nonlinear scaling. Omitting `fontSize` preserves the legacy
|
|
15
|
+
* scalar behavior for custom callers that do not know their base size.
|
|
16
|
+
*
|
|
12
17
|
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
13
18
|
* components re-render solely when the user changes the OS text size.
|
|
14
19
|
*/
|
|
15
|
-
declare function useFontScale(cap?: number | null): number;
|
|
20
|
+
declare function useFontScale(cap?: number | null, fontSize?: number): number;
|
|
16
21
|
//#endregion
|
|
17
22
|
export { useFontScale };
|
|
18
23
|
//# sourceMappingURL=useFontScale.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFontScale.d.cts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFontScale.d.cts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBAiCS,YAAA,CAAa,GAAA,kBAAqB,QAAA"}
|
|
@@ -1,18 +1,23 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/fontScaling/useFontScale.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* The
|
|
5
|
-
* around scaled text (e.g. a checkbox box growing with its
|
|
4
|
+
* The effective scale for `fontSize`, clamped to `[1, cap]`, for sizing
|
|
5
|
+
* containers around scaled text (e.g. a checkbox box growing with its
|
|
6
|
+
* checkmark).
|
|
6
7
|
*
|
|
7
8
|
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
8
9
|
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
9
10
|
* is never below 1 so containers never shrink under their token metrics
|
|
10
11
|
* (font scales < 1 shrink text only, as today).
|
|
11
12
|
*
|
|
13
|
+
* Pass the SP size that the geometry accompanies on Android so this mirrors
|
|
14
|
+
* Android 14+'s nonlinear scaling. Omitting `fontSize` preserves the legacy
|
|
15
|
+
* scalar behavior for custom callers that do not know their base size.
|
|
16
|
+
*
|
|
12
17
|
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
13
18
|
* components re-render solely when the user changes the OS text size.
|
|
14
19
|
*/
|
|
15
|
-
declare function useFontScale(cap?: number | null): number;
|
|
20
|
+
declare function useFontScale(cap?: number | null, fontSize?: number): number;
|
|
16
21
|
//#endregion
|
|
17
22
|
export { useFontScale };
|
|
18
23
|
//# sourceMappingURL=useFontScale.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFontScale.d.ts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useFontScale.d.ts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBAiCS,YAAA,CAAa,GAAA,kBAAqB,QAAA"}
|