@yahoo/uds-mobile 2.23.3 → 2.24.0-beta.2
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 +4 -12
- package/dist/bin/automated-config/dist/generated/generatedConfigs.mjs +92 -46
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +1 -1
- package/dist/components/Button/buttonTheme.cjs +21 -8
- package/dist/components/Button/buttonTheme.d.cts +16 -4
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +16 -4
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +21 -8
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +20 -7
- package/dist/components/Button.d.cts +7 -0
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.ts +7 -0
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +20 -7
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +30 -7
- package/dist/components/Checkbox.d.cts +7 -0
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.ts +7 -0
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +30 -7
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +23 -9
- package/dist/components/Chip/ChipBase.d.cts.map +1 -1
- package/dist/components/Chip/ChipBase.d.ts.map +1 -1
- package/dist/components/Chip/ChipBase.js +23 -9
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Chip/ChipDismissible.cjs +3 -1
- package/dist/components/Chip/ChipDismissible.js +3 -1
- package/dist/components/Chip/ChipDismissible.js.map +1 -1
- package/dist/components/Chip/types.d.cts +7 -0
- package/dist/components/Chip/types.d.cts.map +1 -1
- package/dist/components/Chip/types.d.ts +7 -0
- package/dist/components/Chip/types.d.ts.map +1 -1
- package/dist/components/Icon.cjs +4 -1
- package/dist/components/Icon.d.cts +9 -1
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts +9 -1
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +4 -1
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +29 -11
- package/dist/components/Radio/Radio.d.cts +7 -0
- package/dist/components/Radio/Radio.d.cts.map +1 -1
- package/dist/components/Radio/Radio.d.ts +7 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Radio/Radio.js +29 -11
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Switch.cjs +29 -6
- package/dist/components/Switch.d.cts +7 -0
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts +7 -0
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +29 -6
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +12 -2
- 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 +12 -2
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs +8 -3
- package/dist/components/Tabs/Tabs.d.cts +9 -1
- package/dist/components/Tabs/Tabs.d.cts.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +9 -1
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +8 -3
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/tabsContexts.d.cts +2 -0
- package/dist/components/Tabs/tabsContexts.d.cts.map +1 -1
- package/dist/components/Tabs/tabsContexts.d.ts +2 -0
- package/dist/components/Tabs/tabsContexts.d.ts.map +1 -1
- package/dist/components/Tabs/tabsContexts.js.map +1 -1
- package/dist/components/Text.cjs +4 -1
- package/dist/components/Text.d.cts +10 -2
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts +10 -2
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +4 -1
- package/dist/components/Text.js.map +1 -1
- package/dist/components/UDSProvider.cjs +6 -2
- package/dist/components/UDSProvider.d.cts +8 -0
- package/dist/components/UDSProvider.d.cts.map +1 -1
- package/dist/components/UDSProvider.d.ts +8 -0
- package/dist/components/UDSProvider.d.ts.map +1 -1
- package/dist/components/UDSProvider.js +6 -2
- package/dist/components/UDSProvider.js.map +1 -1
- package/dist/components/internal/Overlay/index.cjs +1 -1
- package/dist/components/internal/Overlay/index.js +1 -1
- package/dist/fontScaling/FontScalingContext.cjs +35 -0
- package/dist/fontScaling/FontScalingContext.d.cts +38 -0
- package/dist/fontScaling/FontScalingContext.d.cts.map +1 -0
- package/dist/fontScaling/FontScalingContext.d.ts +38 -0
- package/dist/fontScaling/FontScalingContext.d.ts.map +1 -0
- package/dist/fontScaling/FontScalingContext.js +34 -0
- package/dist/fontScaling/FontScalingContext.js.map +1 -0
- package/dist/fontScaling/constants.cjs +72 -0
- package/dist/fontScaling/constants.d.cts +49 -0
- package/dist/fontScaling/constants.d.cts.map +1 -0
- package/dist/fontScaling/constants.d.ts +49 -0
- package/dist/fontScaling/constants.d.ts.map +1 -0
- package/dist/fontScaling/constants.js +70 -0
- package/dist/fontScaling/constants.js.map +1 -0
- package/dist/fontScaling/index.cjs +13 -0
- package/dist/fontScaling/index.d.cts +8 -0
- package/dist/fontScaling/index.d.ts +8 -0
- package/dist/fontScaling/index.js +6 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.cjs +38 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts +36 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts.map +1 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts +36 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts.map +1 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js +39 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js.map +1 -0
- package/dist/fontScaling/types.cjs +1 -0
- package/dist/fontScaling/types.d.cts +51 -0
- package/dist/fontScaling/types.d.cts.map +1 -0
- package/dist/fontScaling/types.d.ts +51 -0
- package/dist/fontScaling/types.d.ts.map +1 -0
- package/dist/fontScaling/types.js +1 -0
- package/dist/fontScaling/useFontScale.cjs +32 -0
- package/dist/fontScaling/useFontScale.d.cts +18 -0
- package/dist/fontScaling/useFontScale.d.cts.map +1 -0
- package/dist/fontScaling/useFontScale.d.ts +18 -0
- package/dist/fontScaling/useFontScale.d.ts.map +1 -0
- package/dist/fontScaling/useFontScale.js +32 -0
- package/dist/fontScaling/useFontScale.js.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.cjs +24 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.cts +16 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.cts.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.ts +16 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.ts.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.js +24 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +19 -4
- package/dist/jest/mocks/react-native.d.cts +8 -5
- package/dist/jest/mocks/react-native.d.cts.map +1 -1
- package/dist/jest/mocks/react-native.d.ts +8 -5
- package/dist/jest/mocks/react-native.d.ts.map +1 -1
- package/dist/jest/mocks/react-native.js +18 -5
- package/dist/jest/mocks/react-native.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +15 -0
- 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 +15 -0
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/jest/setup.cjs +4 -0
- package/dist/jest/setup.d.cts.map +1 -1
- package/dist/jest/setup.d.ts.map +1 -1
- package/dist/jest/setup.js +4 -0
- package/dist/jest/setup.js.map +1 -1
- package/dist/portal.d.cts.map +1 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js.map +1 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/fonts/uds-icons.ttf +0 -0
- package/generated/styles.d.ts +5 -28
- package/generated/unistyles.d.ts +0 -27
- package/package.json +11 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.js";
|
|
3
|
+
import { FontScalingCapValue } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/fontScaling/constants.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The largest OS font scale UDS components are designed to support.
|
|
8
|
+
*
|
|
9
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
10
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
11
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
12
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
13
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
14
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
15
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
16
|
+
*/
|
|
17
|
+
declare const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
18
|
+
/**
|
|
19
|
+
* How far each text style would grow if only legibility mattered, following
|
|
20
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
21
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
22
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
23
|
+
* are larger than largeTitle, so they taper hardest.
|
|
24
|
+
*
|
|
25
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
26
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
27
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
28
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
29
|
+
*
|
|
30
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
31
|
+
*/
|
|
32
|
+
declare const TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
33
|
+
/**
|
|
34
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
35
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
36
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
37
|
+
*
|
|
38
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
39
|
+
*/
|
|
40
|
+
declare const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
41
|
+
/**
|
|
42
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
43
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
44
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
45
|
+
*/
|
|
46
|
+
declare const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE };
|
|
49
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;AACmD;;;;;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;;;;;;cAexB,wCAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
//#region src/fontScaling/constants.ts
|
|
3
|
+
/**
|
|
4
|
+
* The largest OS font scale UDS components are designed to support.
|
|
5
|
+
*
|
|
6
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
7
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
8
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
9
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
10
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
11
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
12
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
15
|
+
/**
|
|
16
|
+
* How far each text style would grow if only legibility mattered, following
|
|
17
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
18
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
19
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
20
|
+
* are larger than largeTitle, so they taper hardest.
|
|
21
|
+
*
|
|
22
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
23
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
24
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
25
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
26
|
+
*
|
|
27
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
28
|
+
*/
|
|
29
|
+
const TYPE_SCALE_CURVE = {
|
|
30
|
+
display1: 1.5,
|
|
31
|
+
display2: 1.6,
|
|
32
|
+
display3: 1.75,
|
|
33
|
+
title1: 1.8,
|
|
34
|
+
title2: 2,
|
|
35
|
+
title3: 2.2,
|
|
36
|
+
title4: 2.4,
|
|
37
|
+
headline1: 2.5,
|
|
38
|
+
ui1: 2.2,
|
|
39
|
+
ui2: 2.4,
|
|
40
|
+
body1: null,
|
|
41
|
+
label1: null,
|
|
42
|
+
label2: null,
|
|
43
|
+
label3: null,
|
|
44
|
+
label4: null,
|
|
45
|
+
caption1: null,
|
|
46
|
+
caption2: null,
|
|
47
|
+
legal1: null,
|
|
48
|
+
ui3: null,
|
|
49
|
+
ui4: null,
|
|
50
|
+
ui5: null,
|
|
51
|
+
ui6: null
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
55
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
56
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
57
|
+
*
|
|
58
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
59
|
+
*/
|
|
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
|
+
/**
|
|
62
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
63
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
64
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
65
|
+
*/
|
|
66
|
+
const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/fontScaling/constants.ts"],"sourcesContent":["import 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 icons (Button, Checkbox, Radio,\n * Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the\n * supported ceiling rather than a looser per-variant cap.\n */\nconst DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = MAX_SUPPORTED_FONT_SCALE;\n\nexport {\n DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER,\n DEFAULT_MAX_FONT_SIZE_MULTIPLIERS,\n MAX_SUPPORTED_FONT_SCALE,\n TYPE_SCALE_CURVE,\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,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;;;;;;AAOD,MAAM,2CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_fontScaling_FontScalingContext = require("./FontScalingContext.cjs");
|
|
4
|
+
const require_fontScaling_constants = require("./constants.cjs");
|
|
5
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("./useMaxFontSizeMultiplier.cjs");
|
|
6
|
+
const require_fontScaling_useFontScale = require("./useFontScale.cjs");
|
|
7
|
+
exports.DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = require_fontScaling_constants.DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER;
|
|
8
|
+
exports.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = require_fontScaling_constants.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS;
|
|
9
|
+
exports.MAX_SUPPORTED_FONT_SCALE = require_fontScaling_constants.MAX_SUPPORTED_FONT_SCALE;
|
|
10
|
+
exports.TYPE_SCALE_CURVE = require_fontScaling_constants.TYPE_SCALE_CURVE;
|
|
11
|
+
exports.UDSFontScalingProvider = require_fontScaling_FontScalingContext.UDSFontScalingProvider;
|
|
12
|
+
exports.useFontScale = require_fontScaling_useFontScale.useFontScale;
|
|
13
|
+
exports.useMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
import { FontScalingCapValue, FontScalingConfig } from "./types.cjs";
|
|
4
|
+
import { UDSFontScalingProvider, UDSFontScalingProviderProps } from "./FontScalingContext.cjs";
|
|
5
|
+
import { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE } from "./constants.cjs";
|
|
6
|
+
import { useFontScale } from "./useFontScale.cjs";
|
|
7
|
+
import { useMaxFontSizeMultiplier } from "./useMaxFontSizeMultiplier.cjs";
|
|
8
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, type FontScalingCapValue, type FontScalingConfig, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE, type TextVariant, UDSFontScalingProvider, type UDSFontScalingProviderProps, useFontScale, useMaxFontSizeMultiplier };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.js";
|
|
3
|
+
import { FontScalingCapValue, FontScalingConfig } from "./types.js";
|
|
4
|
+
import { UDSFontScalingProvider, UDSFontScalingProviderProps } from "./FontScalingContext.js";
|
|
5
|
+
import { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE } from "./constants.js";
|
|
6
|
+
import { useFontScale } from "./useFontScale.js";
|
|
7
|
+
import { useMaxFontSizeMultiplier } from "./useMaxFontSizeMultiplier.js";
|
|
8
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, type FontScalingCapValue, type FontScalingConfig, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE, type TextVariant, UDSFontScalingProvider, type UDSFontScalingProviderProps, useFontScale, useMaxFontSizeMultiplier };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { UDSFontScalingProvider } from "./FontScalingContext.js";
|
|
3
|
+
import { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE } from "./constants.js";
|
|
4
|
+
import { useMaxFontSizeMultiplier } from "./useMaxFontSizeMultiplier.js";
|
|
5
|
+
import { useFontScale } from "./useFontScale.js";
|
|
6
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE, UDSFontScalingProvider, useFontScale, useMaxFontSizeMultiplier };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_fontScaling_constants = require("./constants.cjs");
|
|
4
|
+
//#region src/fontScaling/resolveMaxFontSizeMultiplier.ts
|
|
5
|
+
const UNCAPPED = 0;
|
|
6
|
+
function toResolved(cap) {
|
|
7
|
+
return cap === null ? UNCAPPED : cap;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the `maxFontSizeMultiplier` to hand to React Native.
|
|
11
|
+
*
|
|
12
|
+
* Precedence: explicit prop > provider config (variant entry, then base-variant
|
|
13
|
+
* entry, then `default`) > built-in default table.
|
|
14
|
+
*
|
|
15
|
+
* Returns `undefined` (native behavior: inherit from parent text or app
|
|
16
|
+
* global) when nothing applies — including for built-in uncapped variants, so
|
|
17
|
+
* body text nested inside capped text still inherits the parent's cap. Only an
|
|
18
|
+
* explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.
|
|
19
|
+
*/
|
|
20
|
+
function resolveMaxFontSizeMultiplier({ explicit, config, variant }) {
|
|
21
|
+
if (explicit !== void 0) return toResolved(explicit);
|
|
22
|
+
if (config?.enabled === false) return;
|
|
23
|
+
if (variant === void 0) return config?.default !== void 0 ? toResolved(config.default) : void 0;
|
|
24
|
+
if (variant === "control") {
|
|
25
|
+
if (config?.control !== void 0) return toResolved(config.control);
|
|
26
|
+
return 2;
|
|
27
|
+
}
|
|
28
|
+
const baseVariant = variant.split("/")[0];
|
|
29
|
+
const variantCap = config?.variants?.[variant];
|
|
30
|
+
if (variantCap !== void 0) return toResolved(variantCap);
|
|
31
|
+
const baseVariantCap = config?.variants?.[baseVariant];
|
|
32
|
+
if (baseVariantCap !== void 0) return toResolved(baseVariantCap);
|
|
33
|
+
if (config?.default !== void 0) return toResolved(config.default);
|
|
34
|
+
const builtIn = require_fontScaling_constants.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[variant] ?? require_fontScaling_constants.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[baseVariant];
|
|
35
|
+
return typeof builtIn === "number" ? builtIn : void 0;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.resolveMaxFontSizeMultiplier = resolveMaxFontSizeMultiplier;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
import { FontScalingConfig } from "./types.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/fontScaling/resolveMaxFontSizeMultiplier.d.ts
|
|
6
|
+
interface ResolveMaxFontSizeMultiplierOptions {
|
|
7
|
+
/** Explicit component prop. `null` = force-uncap. Wins over everything. */
|
|
8
|
+
explicit?: number | null;
|
|
9
|
+
/** Provider config, if any provider is mounted. */
|
|
10
|
+
config?: FontScalingConfig;
|
|
11
|
+
/**
|
|
12
|
+
* The text's resolved variant, `'control'` for control-internal text/icons,
|
|
13
|
+
* or `undefined` for `variant="inherit"` text (no variant opinion — nested
|
|
14
|
+
* text inherits its parent's cap natively).
|
|
15
|
+
*/
|
|
16
|
+
variant?: TextVariant | 'control';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the `maxFontSizeMultiplier` to hand to React Native.
|
|
20
|
+
*
|
|
21
|
+
* Precedence: explicit prop > provider config (variant entry, then base-variant
|
|
22
|
+
* entry, then `default`) > built-in default table.
|
|
23
|
+
*
|
|
24
|
+
* Returns `undefined` (native behavior: inherit from parent text or app
|
|
25
|
+
* global) when nothing applies — including for built-in uncapped variants, so
|
|
26
|
+
* body text nested inside capped text still inherits the parent's cap. Only an
|
|
27
|
+
* explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveMaxFontSizeMultiplier({
|
|
30
|
+
explicit,
|
|
31
|
+
config,
|
|
32
|
+
variant
|
|
33
|
+
}: ResolveMaxFontSizeMultiplierOptions): number | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type ResolveMaxFontSizeMultiplierOptions, resolveMaxFontSizeMultiplier };
|
|
36
|
+
//# sourceMappingURL=resolveMaxFontSizeMultiplier.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMaxFontSizeMultiplier.d.cts","names":[],"sources":["../../src/fontScaling/resolveMaxFontSizeMultiplier.ts"],"mappings":";;;;;UAWU,mCAAA;;EAER,QAAA;EAF2C;EAI3C,MAAA,GAAS,iBAAA;EAMY;;;;;EAArB,OAAA,GAAU,WAAA;AAAA;;AAAW;;;;;;;;;;iBAkBd,4BAAA,CAAA;EACP,QAAA;EACA,MAAA;EACA;AAAA,GACC,mCAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.js";
|
|
3
|
+
import { FontScalingConfig } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/fontScaling/resolveMaxFontSizeMultiplier.d.ts
|
|
6
|
+
interface ResolveMaxFontSizeMultiplierOptions {
|
|
7
|
+
/** Explicit component prop. `null` = force-uncap. Wins over everything. */
|
|
8
|
+
explicit?: number | null;
|
|
9
|
+
/** Provider config, if any provider is mounted. */
|
|
10
|
+
config?: FontScalingConfig;
|
|
11
|
+
/**
|
|
12
|
+
* The text's resolved variant, `'control'` for control-internal text/icons,
|
|
13
|
+
* or `undefined` for `variant="inherit"` text (no variant opinion — nested
|
|
14
|
+
* text inherits its parent's cap natively).
|
|
15
|
+
*/
|
|
16
|
+
variant?: TextVariant | 'control';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the `maxFontSizeMultiplier` to hand to React Native.
|
|
20
|
+
*
|
|
21
|
+
* Precedence: explicit prop > provider config (variant entry, then base-variant
|
|
22
|
+
* entry, then `default`) > built-in default table.
|
|
23
|
+
*
|
|
24
|
+
* Returns `undefined` (native behavior: inherit from parent text or app
|
|
25
|
+
* global) when nothing applies — including for built-in uncapped variants, so
|
|
26
|
+
* body text nested inside capped text still inherits the parent's cap. Only an
|
|
27
|
+
* explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveMaxFontSizeMultiplier({
|
|
30
|
+
explicit,
|
|
31
|
+
config,
|
|
32
|
+
variant
|
|
33
|
+
}: ResolveMaxFontSizeMultiplierOptions): number | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type ResolveMaxFontSizeMultiplierOptions, resolveMaxFontSizeMultiplier };
|
|
36
|
+
//# sourceMappingURL=resolveMaxFontSizeMultiplier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMaxFontSizeMultiplier.d.ts","names":[],"sources":["../../src/fontScaling/resolveMaxFontSizeMultiplier.ts"],"mappings":";;;;;UAWU,mCAAA;;EAER,QAAA;EAF2C;EAI3C,MAAA,GAAS,iBAAA;EAMY;;;;;EAArB,OAAA,GAAU,WAAA;AAAA;;AAAW;;;;;;;;;;iBAkBd,4BAAA,CAAA;EACP,QAAA;EACA,MAAA;EACA;AAAA,GACC,mCAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { DEFAULT_MAX_FONT_SIZE_MULTIPLIERS } from "./constants.js";
|
|
3
|
+
//#region src/fontScaling/resolveMaxFontSizeMultiplier.ts
|
|
4
|
+
const UNCAPPED = 0;
|
|
5
|
+
function toResolved(cap) {
|
|
6
|
+
return cap === null ? UNCAPPED : cap;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the `maxFontSizeMultiplier` to hand to React Native.
|
|
10
|
+
*
|
|
11
|
+
* Precedence: explicit prop > provider config (variant entry, then base-variant
|
|
12
|
+
* entry, then `default`) > built-in default table.
|
|
13
|
+
*
|
|
14
|
+
* Returns `undefined` (native behavior: inherit from parent text or app
|
|
15
|
+
* global) when nothing applies — including for built-in uncapped variants, so
|
|
16
|
+
* body text nested inside capped text still inherits the parent's cap. Only an
|
|
17
|
+
* explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.
|
|
18
|
+
*/
|
|
19
|
+
function resolveMaxFontSizeMultiplier({ explicit, config, variant }) {
|
|
20
|
+
if (explicit !== void 0) return toResolved(explicit);
|
|
21
|
+
if (config?.enabled === false) return;
|
|
22
|
+
if (variant === void 0) return config?.default !== void 0 ? toResolved(config.default) : void 0;
|
|
23
|
+
if (variant === "control") {
|
|
24
|
+
if (config?.control !== void 0) return toResolved(config.control);
|
|
25
|
+
return 2;
|
|
26
|
+
}
|
|
27
|
+
const baseVariant = variant.split("/")[0];
|
|
28
|
+
const variantCap = config?.variants?.[variant];
|
|
29
|
+
if (variantCap !== void 0) return toResolved(variantCap);
|
|
30
|
+
const baseVariantCap = config?.variants?.[baseVariant];
|
|
31
|
+
if (baseVariantCap !== void 0) return toResolved(baseVariantCap);
|
|
32
|
+
if (config?.default !== void 0) return toResolved(config.default);
|
|
33
|
+
const builtIn = DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[variant] ?? DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[baseVariant];
|
|
34
|
+
return typeof builtIn === "number" ? builtIn : void 0;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { resolveMaxFontSizeMultiplier };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=resolveMaxFontSizeMultiplier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMaxFontSizeMultiplier.js","names":[],"sources":["../../src/fontScaling/resolveMaxFontSizeMultiplier.ts"],"sourcesContent":["import type { TextVariant } from '../components/Text';\nimport {\n DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER,\n DEFAULT_MAX_FONT_SIZE_MULTIPLIERS,\n} from './constants';\nimport type { FontScalingCapValue, FontScalingConfig } from './types';\n\n// React Native: maxFontSizeMultiplier of 0 means \"no max, ignore parent/global\n// default\" — the only way to force-uncap text nested inside capped text.\nconst UNCAPPED = 0;\n\ninterface ResolveMaxFontSizeMultiplierOptions {\n /** Explicit component prop. `null` = force-uncap. Wins over everything. */\n explicit?: number | null;\n /** Provider config, if any provider is mounted. */\n config?: FontScalingConfig;\n /**\n * The text's resolved variant, `'control'` for control-internal text/icons,\n * or `undefined` for `variant=\"inherit\"` text (no variant opinion — nested\n * text inherits its parent's cap natively).\n */\n variant?: TextVariant | 'control';\n}\n\nfunction toResolved(cap: FontScalingCapValue): number {\n return cap === null ? UNCAPPED : cap;\n}\n\n/**\n * Resolves the `maxFontSizeMultiplier` to hand to React Native.\n *\n * Precedence: explicit prop > provider config (variant entry, then base-variant\n * entry, then `default`) > built-in default table.\n *\n * Returns `undefined` (native behavior: inherit from parent text or app\n * global) when nothing applies — including for built-in uncapped variants, so\n * body text nested inside capped text still inherits the parent's cap. Only an\n * explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.\n */\nfunction resolveMaxFontSizeMultiplier({\n explicit,\n config,\n variant,\n}: ResolveMaxFontSizeMultiplierOptions): number | undefined {\n if (explicit !== undefined) {\n return toResolved(explicit);\n }\n\n if (config?.enabled === false) {\n return undefined;\n }\n\n if (variant === undefined) {\n return config?.default !== undefined ? toResolved(config.default) : undefined;\n }\n\n if (variant === 'control') {\n if (config?.control !== undefined) {\n return toResolved(config.control);\n }\n return DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER;\n }\n\n const baseVariant = variant.split('/')[0] as TextVariant;\n\n const variantCap = config?.variants?.[variant];\n if (variantCap !== undefined) {\n return toResolved(variantCap);\n }\n const baseVariantCap = config?.variants?.[baseVariant];\n if (baseVariantCap !== undefined) {\n return toResolved(baseVariantCap);\n }\n if (config?.default !== undefined) {\n return toResolved(config.default);\n }\n\n // Future: a theme-level typography[variant].maxFontSizeMultiplier slots here.\n\n const builtIn =\n DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[variant] ?? DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[baseVariant];\n return typeof builtIn === 'number' ? builtIn : undefined;\n}\n\nexport { resolveMaxFontSizeMultiplier, type ResolveMaxFontSizeMultiplierOptions };\n"],"mappings":";;;AASA,MAAM,WAAW;AAejB,SAAS,WAAW,KAAkC;CACpD,OAAO,QAAQ,OAAO,WAAW;;;;;;;;;;;;;AAcnC,SAAS,6BAA6B,EACpC,UACA,QACA,WAC0D;CAC1D,IAAI,aAAa,KAAA,GACf,OAAO,WAAW,SAAS;CAG7B,IAAI,QAAQ,YAAY,OACtB;CAGF,IAAI,YAAY,KAAA,GACd,OAAO,QAAQ,YAAY,KAAA,IAAY,WAAW,OAAO,QAAQ,GAAG,KAAA;CAGtE,IAAI,YAAY,WAAW;EACzB,IAAI,QAAQ,YAAY,KAAA,GACtB,OAAO,WAAW,OAAO,QAAQ;EAEnC,OAAA;;CAGF,MAAM,cAAc,QAAQ,MAAM,IAAI,CAAC;CAEvC,MAAM,aAAa,QAAQ,WAAW;CACtC,IAAI,eAAe,KAAA,GACjB,OAAO,WAAW,WAAW;CAE/B,MAAM,iBAAiB,QAAQ,WAAW;CAC1C,IAAI,mBAAmB,KAAA,GACrB,OAAO,WAAW,eAAe;CAEnC,IAAI,QAAQ,YAAY,KAAA,GACtB,OAAO,WAAW,OAAO,QAAQ;CAKnC,MAAM,UACJ,kCAAkC,YAAY,kCAAkC;CAClF,OAAO,OAAO,YAAY,WAAW,UAAU,KAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/fontScaling/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A cap on OS font scaling for a piece of text.
|
|
7
|
+
*
|
|
8
|
+
* - `number` (>= 1) — text scales with the OS setting up to this multiplier
|
|
9
|
+
* - `null` — explicitly uncapped: text follows the OS setting with no limit
|
|
10
|
+
*/
|
|
11
|
+
type FontScalingCapValue = number | null;
|
|
12
|
+
/**
|
|
13
|
+
* App-level font-scaling configuration, applied via `UDSFontScalingProvider`
|
|
14
|
+
* (or the `fontScaling` prop on `UDSGestureProvider`).
|
|
15
|
+
*
|
|
16
|
+
* Resolution order for any piece of text: explicit component prop, then this
|
|
17
|
+
* config, then the built-in defaults in `DEFAULT_MAX_FONT_SIZE_MULTIPLIERS`.
|
|
18
|
+
*
|
|
19
|
+
* The config object should be identity-stable (a module constant or memoized)
|
|
20
|
+
* — every UDS text element reads it from context.
|
|
21
|
+
*/
|
|
22
|
+
interface FontScalingConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Master switch for UDS-applied caps. When `false`, no caps are applied
|
|
25
|
+
* anywhere and text follows native OS scaling. Container-metric fixes
|
|
26
|
+
* (Button/Checkbox growing to fit scaled text) remain active.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Fallback cap for any variant not listed in `variants`. Takes precedence
|
|
32
|
+
* over the built-in default table, including its uncapped entries — setting
|
|
33
|
+
* `default: 2` caps body/label/caption text that UDS leaves uncapped by
|
|
34
|
+
* default.
|
|
35
|
+
*/
|
|
36
|
+
default?: FontScalingCapValue;
|
|
37
|
+
/**
|
|
38
|
+
* Cap for control-internal text, icons, and geometry in Button, Checkbox,
|
|
39
|
+
* Radio, Switch, Chip, and Tabs, plus standalone `Icon` glyphs.
|
|
40
|
+
* @default 2
|
|
41
|
+
*/
|
|
42
|
+
control?: FontScalingCapValue;
|
|
43
|
+
/**
|
|
44
|
+
* Per-variant caps. A base-variant key (e.g. `display1`) also covers its
|
|
45
|
+
* `/emphasized` twin unless the emphasized key is listed explicitly.
|
|
46
|
+
*/
|
|
47
|
+
variants?: Partial<Record<TextVariant, FontScalingCapValue>>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { type FontScalingCapValue, type FontScalingConfig };
|
|
51
|
+
//# sourceMappingURL=types.d.cts.map
|
|
@@ -0,0 +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;EAkBmB;;;;;;EAXnB,OAAA,GAAU,mBAAA;;;;;;EAMV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.js";
|
|
3
|
+
|
|
4
|
+
//#region src/fontScaling/types.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* A cap on OS font scaling for a piece of text.
|
|
7
|
+
*
|
|
8
|
+
* - `number` (>= 1) — text scales with the OS setting up to this multiplier
|
|
9
|
+
* - `null` — explicitly uncapped: text follows the OS setting with no limit
|
|
10
|
+
*/
|
|
11
|
+
type FontScalingCapValue = number | null;
|
|
12
|
+
/**
|
|
13
|
+
* App-level font-scaling configuration, applied via `UDSFontScalingProvider`
|
|
14
|
+
* (or the `fontScaling` prop on `UDSGestureProvider`).
|
|
15
|
+
*
|
|
16
|
+
* Resolution order for any piece of text: explicit component prop, then this
|
|
17
|
+
* config, then the built-in defaults in `DEFAULT_MAX_FONT_SIZE_MULTIPLIERS`.
|
|
18
|
+
*
|
|
19
|
+
* The config object should be identity-stable (a module constant or memoized)
|
|
20
|
+
* — every UDS text element reads it from context.
|
|
21
|
+
*/
|
|
22
|
+
interface FontScalingConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Master switch for UDS-applied caps. When `false`, no caps are applied
|
|
25
|
+
* anywhere and text follows native OS scaling. Container-metric fixes
|
|
26
|
+
* (Button/Checkbox growing to fit scaled text) remain active.
|
|
27
|
+
* @default true
|
|
28
|
+
*/
|
|
29
|
+
enabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Fallback cap for any variant not listed in `variants`. Takes precedence
|
|
32
|
+
* over the built-in default table, including its uncapped entries — setting
|
|
33
|
+
* `default: 2` caps body/label/caption text that UDS leaves uncapped by
|
|
34
|
+
* default.
|
|
35
|
+
*/
|
|
36
|
+
default?: FontScalingCapValue;
|
|
37
|
+
/**
|
|
38
|
+
* Cap for control-internal text, icons, and geometry in Button, Checkbox,
|
|
39
|
+
* Radio, Switch, Chip, and Tabs, plus standalone `Icon` glyphs.
|
|
40
|
+
* @default 2
|
|
41
|
+
*/
|
|
42
|
+
control?: FontScalingCapValue;
|
|
43
|
+
/**
|
|
44
|
+
* Per-variant caps. A base-variant key (e.g. `display1`) also covers its
|
|
45
|
+
* `/emphasized` twin unless the emphasized key is listed explicitly.
|
|
46
|
+
*/
|
|
47
|
+
variants?: Partial<Record<TextVariant, FontScalingCapValue>>;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { type FontScalingCapValue, type FontScalingConfig };
|
|
51
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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;EAkBmB;;;;;;EAXnB,OAAA,GAAU,mBAAA;;;;;;EAMV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
let react = require("react");
|
|
5
|
+
let react_native = require("react-native");
|
|
6
|
+
//#region src/fontScaling/useFontScale.ts
|
|
7
|
+
function subscribe(onStoreChange) {
|
|
8
|
+
const subscription = react_native.Dimensions.addEventListener("change", onStoreChange);
|
|
9
|
+
return () => subscription.remove();
|
|
10
|
+
}
|
|
11
|
+
function getFontScale() {
|
|
12
|
+
return react_native.Dimensions.get("window").fontScale;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The current OS font scale, clamped to `[1, cap]`, for sizing containers
|
|
16
|
+
* around scaled text (e.g. a checkbox box growing with its checkmark).
|
|
17
|
+
*
|
|
18
|
+
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
19
|
+
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
20
|
+
* is never below 1 so containers never shrink under their token metrics
|
|
21
|
+
* (font scales < 1 shrink text only, as today).
|
|
22
|
+
*
|
|
23
|
+
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
24
|
+
* components re-render solely when the user changes the OS text size.
|
|
25
|
+
*/
|
|
26
|
+
function useFontScale(cap) {
|
|
27
|
+
const fontScale = (0, react.useSyncExternalStore)(subscribe, getFontScale, getFontScale);
|
|
28
|
+
const effectiveCap = typeof cap === "number" && cap >= 1 ? cap : Number.POSITIVE_INFINITY;
|
|
29
|
+
return Math.max(1, Math.min(fontScale, effectiveCap));
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.useFontScale = useFontScale;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/fontScaling/useFontScale.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The current OS font scale, clamped to `[1, cap]`, for sizing containers
|
|
5
|
+
* around scaled text (e.g. a checkbox box growing with its checkmark).
|
|
6
|
+
*
|
|
7
|
+
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
8
|
+
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
9
|
+
* is never below 1 so containers never shrink under their token metrics
|
|
10
|
+
* (font scales < 1 shrink text only, as today).
|
|
11
|
+
*
|
|
12
|
+
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
13
|
+
* components re-render solely when the user changes the OS text size.
|
|
14
|
+
*/
|
|
15
|
+
declare function useFontScale(cap?: number | null): number;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useFontScale };
|
|
18
|
+
//# sourceMappingURL=useFontScale.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFontScale.d.cts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;iBA0BS,YAAA,CAAa,GAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/fontScaling/useFontScale.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The current OS font scale, clamped to `[1, cap]`, for sizing containers
|
|
5
|
+
* around scaled text (e.g. a checkbox box growing with its checkmark).
|
|
6
|
+
*
|
|
7
|
+
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
8
|
+
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
9
|
+
* is never below 1 so containers never shrink under their token metrics
|
|
10
|
+
* (font scales < 1 shrink text only, as today).
|
|
11
|
+
*
|
|
12
|
+
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
13
|
+
* components re-render solely when the user changes the OS text size.
|
|
14
|
+
*/
|
|
15
|
+
declare function useFontScale(cap?: number | null): number;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { useFontScale };
|
|
18
|
+
//# sourceMappingURL=useFontScale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFontScale.d.ts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;iBA0BS,YAAA,CAAa,GAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useSyncExternalStore } from "react";
|
|
3
|
+
import { Dimensions } from "react-native";
|
|
4
|
+
//#region src/fontScaling/useFontScale.ts
|
|
5
|
+
function subscribe(onStoreChange) {
|
|
6
|
+
const subscription = Dimensions.addEventListener("change", onStoreChange);
|
|
7
|
+
return () => subscription.remove();
|
|
8
|
+
}
|
|
9
|
+
function getFontScale() {
|
|
10
|
+
return Dimensions.get("window").fontScale;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The current OS font scale, clamped to `[1, cap]`, for sizing containers
|
|
14
|
+
* around scaled text (e.g. a checkbox box growing with its checkmark).
|
|
15
|
+
*
|
|
16
|
+
* `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1
|
|
17
|
+
* caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result
|
|
18
|
+
* is never below 1 so containers never shrink under their token metrics
|
|
19
|
+
* (font scales < 1 shrink text only, as today).
|
|
20
|
+
*
|
|
21
|
+
* Subscribes to font-scale changes only — rotation does not re-render, and
|
|
22
|
+
* components re-render solely when the user changes the OS text size.
|
|
23
|
+
*/
|
|
24
|
+
function useFontScale(cap) {
|
|
25
|
+
const fontScale = useSyncExternalStore(subscribe, getFontScale, getFontScale);
|
|
26
|
+
const effectiveCap = typeof cap === "number" && cap >= 1 ? cap : Number.POSITIVE_INFINITY;
|
|
27
|
+
return Math.max(1, Math.min(fontScale, effectiveCap));
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { useFontScale };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=useFontScale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFontScale.js","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport { Dimensions } from 'react-native';\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const subscription = Dimensions.addEventListener('change', onStoreChange);\n return () => subscription.remove();\n}\n\n// Unistyles' rt.fontScale is stale when the OS text size changes while the\n// app is running; Dimensions reflects the live value on both platforms.\nfunction getFontScale(): number {\n return Dimensions.get('window').fontScale;\n}\n\n/**\n * The current OS font scale, clamped to `[1, cap]`, for sizing containers\n * around scaled text (e.g. a checkbox box growing with its checkmark).\n *\n * `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1\n * caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result\n * is never below 1 so containers never shrink under their token metrics\n * (font scales < 1 shrink text only, as today).\n *\n * Subscribes to font-scale changes only — rotation does not re-render, and\n * components re-render solely when the user changes the OS text size.\n */\nfunction useFontScale(cap?: number | null): number {\n const fontScale = useSyncExternalStore(subscribe, getFontScale, getFontScale);\n const effectiveCap = typeof cap === 'number' && cap >= 1 ? cap : Number.POSITIVE_INFINITY;\n return Math.max(1, Math.min(fontScale, effectiveCap));\n}\n\nexport { useFontScale };\n"],"mappings":";;;;AAGA,SAAS,UAAU,eAAuC;CACxD,MAAM,eAAe,WAAW,iBAAiB,UAAU,cAAc;CACzE,aAAa,aAAa,QAAQ;;AAKpC,SAAS,eAAuB;CAC9B,OAAO,WAAW,IAAI,SAAS,CAAC;;;;;;;;;;;;;;AAelC,SAAS,aAAa,KAA6B;CACjD,MAAM,YAAY,qBAAqB,WAAW,cAAc,aAAa;CAC7E,MAAM,eAAe,OAAO,QAAQ,YAAY,OAAO,IAAI,MAAM,OAAO;CACxE,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,WAAW,aAAa,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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_FontScalingContext = require("./FontScalingContext.cjs");
|
|
5
|
+
const require_fontScaling_resolveMaxFontSizeMultiplier = require("./resolveMaxFontSizeMultiplier.cjs");
|
|
6
|
+
let react = require("react");
|
|
7
|
+
//#region src/fontScaling/useMaxFontSizeMultiplier.ts
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the `maxFontSizeMultiplier` for a text variant (or `'control'` for
|
|
10
|
+
* control-internal text/icons), combining an explicit prop value, the nearest
|
|
11
|
+
* `UDSFontScalingProvider` config, and the built-in defaults.
|
|
12
|
+
*
|
|
13
|
+
* Returns a value to pass directly to React Native: a cap (>= 1), `0`
|
|
14
|
+
* (force-uncap), or `undefined` (native default / inherit).
|
|
15
|
+
*/
|
|
16
|
+
function useMaxFontSizeMultiplier(variant, explicit) {
|
|
17
|
+
return require_fontScaling_resolveMaxFontSizeMultiplier.resolveMaxFontSizeMultiplier({
|
|
18
|
+
explicit,
|
|
19
|
+
config: (0, react.useContext)(require_fontScaling_FontScalingContext.FontScalingContext),
|
|
20
|
+
variant
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
exports.useMaxFontSizeMultiplier = useMaxFontSizeMultiplier;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/fontScaling/useMaxFontSizeMultiplier.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Resolves the `maxFontSizeMultiplier` for a text variant (or `'control'` for
|
|
7
|
+
* control-internal text/icons), combining an explicit prop value, the nearest
|
|
8
|
+
* `UDSFontScalingProvider` config, and the built-in defaults.
|
|
9
|
+
*
|
|
10
|
+
* Returns a value to pass directly to React Native: a cap (>= 1), `0`
|
|
11
|
+
* (force-uncap), or `undefined` (native default / inherit).
|
|
12
|
+
*/
|
|
13
|
+
declare function useMaxFontSizeMultiplier(variant?: TextVariant | 'control', explicit?: number | null): number | undefined;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { useMaxFontSizeMultiplier };
|
|
16
|
+
//# sourceMappingURL=useMaxFontSizeMultiplier.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMaxFontSizeMultiplier.d.cts","names":[],"sources":["../../src/fontScaling/useMaxFontSizeMultiplier.ts"],"mappings":";;;;;;AAEsD;;;;;;iBAY7C,wBAAA,CACP,OAAA,GAAU,WAAA,cACV,QAAA"}
|