@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
|
@@ -5,7 +5,7 @@ import { Text as Text$1, TextProps as TextProps$1, TextStyle } from "react-nativ
|
|
|
5
5
|
import { StyleProps } from "../../generated/styles";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Text.d.ts
|
|
8
|
-
type TextVariant = Exclude<StyleProps['fontFamily']
|
|
8
|
+
type TextVariant = Exclude<NonNullable<StyleProps['fontFamily']>, 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'>;
|
|
9
9
|
type TextVariantProp = TextVariant | 'inherit';
|
|
10
10
|
type TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';
|
|
11
11
|
interface TextProps extends TextProps$1 {
|
|
@@ -15,6 +15,14 @@ interface TextProps extends TextProps$1 {
|
|
|
15
15
|
color?: StyleProps['color'] | 'inherit';
|
|
16
16
|
/** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */
|
|
17
17
|
variant?: TextVariantProp;
|
|
18
|
+
/**
|
|
19
|
+
* Caps how far this text grows with the OS text-size setting. Display and
|
|
20
|
+
* title variants are capped by default (see DEFAULT_MAX_FONT_SIZE_MULTIPLIERS);
|
|
21
|
+
* reading sizes are uncapped. Set null to remove the cap (maps to React
|
|
22
|
+
* Native's 0, which also overrides an inherited cap); inherit-variant text
|
|
23
|
+
* inherits its parent's cap. Override app-wide via UDSFontScalingProvider.
|
|
24
|
+
*/
|
|
25
|
+
maxFontSizeMultiplier?: number | null;
|
|
18
26
|
/** Override the fontFamily independently */
|
|
19
27
|
fontFamily?: StyleProps['fontFamily'];
|
|
20
28
|
/** Override the fontSize independently */
|
|
@@ -105,5 +113,5 @@ interface TextProps extends TextProps$1 {
|
|
|
105
113
|
*/
|
|
106
114
|
declare const Text: _$react.NamedExoticComponent<TextProps>;
|
|
107
115
|
//#endregion
|
|
108
|
-
export { Text, type TextProps };
|
|
116
|
+
export { Text, type TextProps, type TextVariant };
|
|
109
117
|
//# sourceMappingURL=Text.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.cts","names":[],"sources":["../../src/components/Text.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Text.d.cts","names":[],"sources":["../../src/components/Text.tsx"],"mappings":";;;;;;;KAUK,WAAA,GAAc,OAAA,CACjB,WAAA,CAAY,UAAA;AAAA,KAGT,eAAA,GAAkB,WAAA;AAAA,KAIlB,kBAAA;AAAA,UAuBK,SAAA,SAAkB,WAAA;;EAE1B,GAAA,GAAM,GAAA,CAAI,MAAA;EAhCV;EAkCA,KAAA,GAAQ,UAAA;EAnCgB;EAqCxB,OAAA,GAAU,eAAA;EArCO;;;;;AACK;;EA4CtB,qBAAA;EAzCqB;EA2CrB,UAAA,GAAa,UAAA;EAvCV;EAyCH,QAAA,GAAW,UAAA;;EAEX,UAAA,GAAa,UAAA;EA3CQ;EA6CrB,UAAA,GAAa,UAAA;EAtBK;EAwBlB,aAAA,GAAgB,UAAA;EAtBN;EAwBV,SAAA,GAAY,UAAA;EAtBJ;EAwBR,aAAA,GAAgB,UAAA;EAZH;EAcb,kBAAA,GAAqB,kBAAA;EAErB,eAAA,GAAkB,UAAA;EAElB,YAAA,GAAe,UAAA;EACf,oBAAA,GAAuB,UAAA;EACvB,kBAAA,GAAqB,UAAA;EACrB,uBAAA,GAA0B,UAAA;EAC1B,qBAAA,GAAwB,UAAA;EACxB,WAAA,GAAc,UAAA;EACd,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EACpB,WAAA,GAAc,UAAA;EACd,mBAAA,GAAsB,UAAA;EACtB,qBAAA,GAAwB,UAAA;EACxB,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EAEpB,OAAA,GAAU,UAAA;EACV,iBAAA,GAAoB,UAAA;EACpB,eAAA,GAAkB,UAAA;EAClB,aAAA,GAAgB,UAAA;EAChB,UAAA,GAAa,UAAA;EACb,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EAEb,MAAA,GAAS,UAAA;EACT,cAAA,GAAiB,UAAA;EACjB,gBAAA,GAAmB,UAAA;EACnB,YAAA,GAAe,UAAA;EACf,SAAA,GAAY,UAAA;EACZ,WAAA,GAAc,UAAA;EACd,SAAA,GAAY,UAAA;EAEZ,UAAA,GAAa,UAAA;EAEb,aAAA,GAAgB,SAAA;EAEhB,MAAA;EACA,KAAA;EACA,SAAA;EACA,SAAA;EACA,QAAA;EACA,QAAA;EAEA,mBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCI,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA"}
|
|
@@ -5,7 +5,7 @@ import { Text as Text$1, TextProps as TextProps$1, TextStyle } from "react-nativ
|
|
|
5
5
|
import { StyleProps } from "../../generated/styles";
|
|
6
6
|
|
|
7
7
|
//#region src/components/Text.d.ts
|
|
8
|
-
type TextVariant = Exclude<StyleProps['fontFamily']
|
|
8
|
+
type TextVariant = Exclude<NonNullable<StyleProps['fontFamily']>, 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'>;
|
|
9
9
|
type TextVariantProp = TextVariant | 'inherit';
|
|
10
10
|
type TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';
|
|
11
11
|
interface TextProps extends TextProps$1 {
|
|
@@ -15,6 +15,14 @@ interface TextProps extends TextProps$1 {
|
|
|
15
15
|
color?: StyleProps['color'] | 'inherit';
|
|
16
16
|
/** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */
|
|
17
17
|
variant?: TextVariantProp;
|
|
18
|
+
/**
|
|
19
|
+
* Caps how far this text grows with the OS text-size setting. Display and
|
|
20
|
+
* title variants are capped by default (see DEFAULT_MAX_FONT_SIZE_MULTIPLIERS);
|
|
21
|
+
* reading sizes are uncapped. Set null to remove the cap (maps to React
|
|
22
|
+
* Native's 0, which also overrides an inherited cap); inherit-variant text
|
|
23
|
+
* inherits its parent's cap. Override app-wide via UDSFontScalingProvider.
|
|
24
|
+
*/
|
|
25
|
+
maxFontSizeMultiplier?: number | null;
|
|
18
26
|
/** Override the fontFamily independently */
|
|
19
27
|
fontFamily?: StyleProps['fontFamily'];
|
|
20
28
|
/** Override the fontSize independently */
|
|
@@ -105,5 +113,5 @@ interface TextProps extends TextProps$1 {
|
|
|
105
113
|
*/
|
|
106
114
|
declare const Text: _$react.NamedExoticComponent<TextProps>;
|
|
107
115
|
//#endregion
|
|
108
|
-
export { Text, type TextProps };
|
|
116
|
+
export { Text, type TextProps, type TextVariant };
|
|
109
117
|
//# sourceMappingURL=Text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.ts","names":[],"sources":["../../src/components/Text.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Text.d.ts","names":[],"sources":["../../src/components/Text.tsx"],"mappings":";;;;;;;KAUK,WAAA,GAAc,OAAA,CACjB,WAAA,CAAY,UAAA;AAAA,KAGT,eAAA,GAAkB,WAAA;AAAA,KAIlB,kBAAA;AAAA,UAuBK,SAAA,SAAkB,WAAA;;EAE1B,GAAA,GAAM,GAAA,CAAI,MAAA;EAhCV;EAkCA,KAAA,GAAQ,UAAA;EAnCgB;EAqCxB,OAAA,GAAU,eAAA;EArCO;;;;;AACK;;EA4CtB,qBAAA;EAzCqB;EA2CrB,UAAA,GAAa,UAAA;EAvCV;EAyCH,QAAA,GAAW,UAAA;;EAEX,UAAA,GAAa,UAAA;EA3CQ;EA6CrB,UAAA,GAAa,UAAA;EAtBK;EAwBlB,aAAA,GAAgB,UAAA;EAtBN;EAwBV,SAAA,GAAY,UAAA;EAtBJ;EAwBR,aAAA,GAAgB,UAAA;EAZH;EAcb,kBAAA,GAAqB,kBAAA;EAErB,eAAA,GAAkB,UAAA;EAElB,YAAA,GAAe,UAAA;EACf,oBAAA,GAAuB,UAAA;EACvB,kBAAA,GAAqB,UAAA;EACrB,uBAAA,GAA0B,UAAA;EAC1B,qBAAA,GAAwB,UAAA;EACxB,WAAA,GAAc,UAAA;EACd,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EACpB,WAAA,GAAc,UAAA;EACd,mBAAA,GAAsB,UAAA;EACtB,qBAAA,GAAwB,UAAA;EACxB,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EAEpB,OAAA,GAAU,UAAA;EACV,iBAAA,GAAoB,UAAA;EACpB,eAAA,GAAkB,UAAA;EAClB,aAAA,GAAgB,UAAA;EAChB,UAAA,GAAa,UAAA;EACb,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EAEb,MAAA,GAAS,UAAA;EACT,cAAA,GAAiB,UAAA;EACjB,gBAAA,GAAmB,UAAA;EACnB,YAAA,GAAe,UAAA;EACf,SAAA,GAAY,UAAA;EACZ,WAAA,GAAc,UAAA;EACd,SAAA,GAAY,UAAA;EAEZ,UAAA,GAAa,UAAA;EAEb,aAAA,GAAgB,SAAA;EAEhB,MAAA;EACA,KAAA;EACA,SAAA;EACA,SAAA;EACA,QAAA;EACA,QAAA;EAEA,mBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCI,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA"}
|
package/dist/components/Text.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useMaxFontSizeMultiplier } from "../fontScaling/useMaxFontSizeMultiplier.js";
|
|
2
3
|
import { memo, useMemo } from "react";
|
|
3
4
|
import { Text as Text$1 } from "react-native";
|
|
4
5
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -45,13 +46,14 @@ function hasCJKContent(children) {
|
|
|
45
46
|
*
|
|
46
47
|
* @see {@link Link} for interactive text links
|
|
47
48
|
*/
|
|
48
|
-
const Text = memo(function Text({ color = "primary", variant = "body1", fontFamily, fontSize, fontWeight, lineHeight, letterSpacing, textAlign, textTransform, textDecorationLine, style, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, flexShrink, verticalAlign, height, minHeight, maxHeight, width, minWidth, maxWidth, dangerouslySetColor, ref, children, ...props }) {
|
|
49
|
+
const Text = memo(function Text({ color = "primary", variant = "body1", fontFamily, fontSize, fontWeight, lineHeight, letterSpacing, maxFontSizeMultiplier, textAlign, textTransform, textDecorationLine, style, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, flexShrink, verticalAlign, height, minHeight, maxHeight, width, minWidth, maxWidth, dangerouslySetColor, ref, children, ...props }) {
|
|
49
50
|
const resolvedColor = color === "inherit" ? void 0 : color;
|
|
50
51
|
const resolvedVariant = variant === "inherit" ? void 0 : variant;
|
|
51
52
|
const resolvedFontFamily = fontFamily ?? resolvedVariant;
|
|
52
53
|
const resolvedFontSize = fontSize ?? resolvedVariant;
|
|
53
54
|
const resolvedLineHeight = lineHeight === "none" ? void 0 : lineHeight ?? (hasCJKContent(children) ? void 0 : resolvedVariant);
|
|
54
55
|
const resolvedLetterSpacing = letterSpacing ?? resolvedVariant;
|
|
56
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier(resolvedVariant, maxFontSizeMultiplier);
|
|
55
57
|
styles.useVariants({
|
|
56
58
|
color: resolvedColor,
|
|
57
59
|
fontFamily: resolvedFontFamily,
|
|
@@ -122,6 +124,7 @@ const Text = memo(function Text({ color = "primary", variant = "body1", fontFami
|
|
|
122
124
|
style,
|
|
123
125
|
styles.foundation
|
|
124
126
|
]),
|
|
127
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
125
128
|
...props,
|
|
126
129
|
children
|
|
127
130
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.js","names":["RNText"],"sources":["../../src/components/Text.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type { StyleProp, TextProps as RNTextProps, TextStyle } from 'react-native';\nimport { Text as RNText } from 'react-native';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\n\n// TextVariant is a subset of fontFamily that represents typography variants\ntype TextVariant = Exclude<\n StyleProps['fontFamily'],\n 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'\n>;\ntype TextVariantProp = TextVariant | 'inherit';\n\n// React Native text decoration line values\n// See: https://reactnative.dev/docs/text-style-props#textdecorationline\ntype TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';\n\n// Chinese/Japanese/Korean scripts: Hangul Jamo, CJK radicals + punctuation,\n// Kana, Han ideographs, Hangul syllables, compatibility ideographs, and\n// full/half-width forms.\nconst CJK_RE =\n /[\\u1100-\\u11FF\\u2E80-\\u303F\\u3040-\\u30FF\\u31C0-\\u9FFF\\uAC00-\\uD7AF\\uF900-\\uFAFF\\uFF00-\\uFFEF]/;\n\n/**\n * Detects CJK characters in string children (including strings inside a\n * children array, e.g. from `{city}` interpolation). Nested elements are not\n * inspected - a nested <Text> runs its own detection.\n */\nfunction hasCJKContent(children: ReactNode): boolean {\n if (typeof children === 'string') {\n return CJK_RE.test(children);\n }\n if (Array.isArray(children)) {\n return children.some((child) => typeof child === 'string' && CJK_RE.test(child));\n }\n return false;\n}\n\ninterface TextProps extends RNTextProps {\n /** Ref to the underlying Text element */\n ref?: Ref<RNText>;\n /** Text color from the theme palette */\n color?: StyleProps['color'] | 'inherit';\n /** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */\n variant?: TextVariantProp;\n /** Override the fontFamily independently */\n fontFamily?: StyleProps['fontFamily'];\n /** Override the fontSize independently */\n fontSize?: StyleProps['fontSize'];\n /** Set font weight (not derived from variant) */\n fontWeight?: StyleProps['fontWeight'];\n /** Override the lineHeight independently. Use 'none' to remove the variant lineHeight and let the font's natural line height apply */\n lineHeight?: StyleProps['lineHeight'] | 'none';\n /** Override the letterSpacing independently */\n letterSpacing?: StyleProps['letterSpacing'];\n /** Text alignment (left, center, right) */\n textAlign?: StyleProps['textAlign'];\n /** Set text transform (not derived from variant) */\n textTransform?: StyleProps['textTransform'];\n /** Text decoration (underline, line-through, etc.) */\n textDecorationLine?: TextDecorationLine;\n // Background\n backgroundColor?: StyleProps['backgroundColor'];\n // Border\n borderRadius?: StyleProps['borderRadius'];\n borderTopStartRadius?: StyleProps['borderTopStartRadius'];\n borderTopEndRadius?: StyleProps['borderTopEndRadius'];\n borderBottomStartRadius?: StyleProps['borderBottomStartRadius'];\n borderBottomEndRadius?: StyleProps['borderBottomEndRadius'];\n borderColor?: StyleProps['borderColor'];\n borderStartColor?: StyleProps['borderStartColor'];\n borderEndColor?: StyleProps['borderEndColor'];\n borderTopColor?: StyleProps['borderTopColor'];\n borderBottomColor?: StyleProps['borderBottomColor'];\n borderWidth?: StyleProps['borderWidth'];\n borderVerticalWidth?: StyleProps['borderVerticalWidth'];\n borderHorizontalWidth?: StyleProps['borderHorizontalWidth'];\n borderStartWidth?: StyleProps['borderStartWidth'];\n borderEndWidth?: StyleProps['borderEndWidth'];\n borderTopWidth?: StyleProps['borderTopWidth'];\n borderBottomWidth?: StyleProps['borderBottomWidth'];\n // Spacing\n spacing?: StyleProps['spacing'];\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n spacingVertical?: StyleProps['spacingVertical'];\n spacingBottom?: StyleProps['spacingBottom'];\n spacingEnd?: StyleProps['spacingEnd'];\n spacingStart?: StyleProps['spacingStart'];\n spacingTop?: StyleProps['spacingTop'];\n // Offset\n offset?: StyleProps['offset'];\n offsetVertical?: StyleProps['offsetVertical'];\n offsetHorizontal?: StyleProps['offsetHorizontal'];\n offsetBottom?: StyleProps['offsetBottom'];\n offsetEnd?: StyleProps['offsetEnd'];\n offsetStart?: StyleProps['offsetStart'];\n offsetTop?: StyleProps['offsetTop'];\n // Flex\n flexShrink?: StyleProps['flexShrink'];\n // Vertical Alignment\n verticalAlign?: TextStyle['textAlignVertical'];\n // Size\n height?: number | `${number}%`;\n width?: number | `${number}%`;\n minHeight?: number | `${number}%`;\n maxHeight?: number | `${number}%`;\n minWidth?: number | `${number}%`;\n maxWidth?: number | `${number}%`;\n // Dangerously set props\n dangerouslySetColor?: string;\n}\n\n/**\n * **📝 A text component with UDS styling**\n *\n * @description\n * A styled text component that supports UDS typography variants and colors.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Text } from '@yahoo/uds-mobile/Text';\n *\n * <Text variant=\"body1\" color=\"primary\">Hello, World!</Text>\n * <Text variant=\"display1\" fontWeight=\"bold\">Heading</Text>\n * <Text variant=\"label1\" color=\"secondary\">Caption text</Text>\n * ```\n *\n * @usage\n * - Use variant prop to set typography (display1, body1, label1, etc.)\n * - Use color prop to set text color from the palette\n * - Use fontWeight to override the variant's default weight\n *\n * @accessibility\n * - Text is readable by screen readers by default\n * - Use appropriate variant sizes for readability\n * - Ensure sufficient color contrast with background\n *\n * @see {@link Link} for interactive text links\n */\nconst Text = memo(function Text({\n // Text-specific\n color = 'primary',\n variant = 'body1',\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n textAlign,\n textTransform,\n textDecorationLine,\n style,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n // Offset\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n // Flex\n flexShrink,\n // Vertical Alignment\n verticalAlign,\n // Size\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n // Dangerously set props\n dangerouslySetColor,\n ref,\n children,\n // Rest\n ...props\n}: TextProps) {\n const resolvedColor = color === 'inherit' ? undefined : color;\n const resolvedVariant = variant === 'inherit' ? undefined : variant;\n const resolvedFontFamily = fontFamily ?? resolvedVariant;\n const resolvedFontSize = fontSize ?? resolvedVariant;\n // React Native clips glyphs when lineHeight is smaller than the font's\n // natural line box. CJK fallback fonts are ~1.4x taller than Latin ones, so\n // Latin-tuned variant lineHeights clip CJK text - drop the variant lineHeight\n // for CJK content so the line grows to fit.\n const resolvedLineHeight =\n lineHeight === 'none'\n ? undefined\n : (lineHeight ?? (hasCJKContent(children) ? undefined : resolvedVariant));\n const resolvedLetterSpacing = letterSpacing ?? resolvedVariant;\n\n styles.useVariants({\n // Text styles\n color: resolvedColor,\n fontFamily: resolvedFontFamily,\n fontSize: resolvedFontSize,\n fontWeight,\n lineHeight: resolvedLineHeight,\n letterSpacing: resolvedLetterSpacing,\n textAlign,\n textTransform,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n // Offset\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n // Flex\n flexShrink,\n });\n\n // styles.foundation must be in deps - it returns a new reference when variants change.\n const computedStyle: StyleProp<TextStyle> = useMemo(\n () => [\n textDecorationLine ? { textDecorationLine } : undefined,\n dangerouslySetColor ? { color: dangerouslySetColor } : undefined,\n verticalAlign ? { textAlignVertical: verticalAlign } : undefined,\n height ? { height } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n width ? { width } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n styles.foundation,\n style,\n ],\n [\n textDecorationLine,\n dangerouslySetColor,\n verticalAlign,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n style,\n styles.foundation,\n ],\n );\n\n return (\n <RNText ref={ref} style={computedStyle} {...props}>\n {children}\n </RNText>\n );\n});\n\nText.displayName = 'Text';\n\nexport { Text, type TextProps };\n"],"mappings":";;;;;;AAsBA,MAAM,SACJ;;;;;;AAOF,SAAS,cAAc,UAA8B;CACnD,IAAI,OAAO,aAAa,UACtB,OAAO,OAAO,KAAK,SAAS;CAE9B,IAAI,MAAM,QAAQ,SAAS,EACzB,OAAO,SAAS,MAAM,UAAU,OAAO,UAAU,YAAY,OAAO,KAAK,MAAM,CAAC;CAElF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2GT,MAAM,OAAO,KAAK,SAAS,KAAK,EAE9B,QAAQ,WACR,UAAU,SACV,YACA,UACA,YACA,YACA,eACA,WACA,eACA,oBACA,OAEA,iBAEA,cACA,sBACA,oBACA,yBACA,uBACA,aACA,kBACA,gBACA,gBACA,mBACA,aACA,qBACA,uBACA,kBACA,gBACA,gBACA,mBAEA,SACA,mBACA,iBACA,eACA,YACA,cACA,YAEA,QACA,gBACA,kBACA,cACA,WACA,aACA,WAEA,YAEA,eAEA,QACA,WACA,WACA,OACA,UACA,UAEA,qBACA,KACA,UAEA,GAAG,SACS;CACZ,MAAM,gBAAgB,UAAU,YAAY,KAAA,IAAY;CACxD,MAAM,kBAAkB,YAAY,YAAY,KAAA,IAAY;CAC5D,MAAM,qBAAqB,cAAc;CACzC,MAAM,mBAAmB,YAAY;CAKrC,MAAM,qBACJ,eAAe,SACX,KAAA,IACC,eAAe,cAAc,SAAS,GAAG,KAAA,IAAY;CAC5D,MAAM,wBAAwB,iBAAiB;CAE/C,OAAO,YAAY;EAEjB,OAAO;EACP,YAAY;EACZ,UAAU;EACV;EACA,YAAY;EACZ,eAAe;EACf;EACA;EAEA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACD,CAAC;CAgCF,OACE,oBAACA,QAAD;EAAa;EAAK,OA9BwB,cACpC;GACJ,qBAAqB,EAAE,oBAAoB,GAAG,KAAA;GAC9C,sBAAsB,EAAE,OAAO,qBAAqB,GAAG,KAAA;GACvD,gBAAgB,EAAE,mBAAmB,eAAe,GAAG,KAAA;GACvD,SAAS,EAAE,QAAQ,GAAG,KAAA;GACtB,YAAY,EAAE,WAAW,GAAG,KAAA;GAC5B,YAAY,EAAE,WAAW,GAAG,KAAA;GAC5B,QAAQ,EAAE,OAAO,GAAG,KAAA;GACpB,WAAW,EAAE,UAAU,GAAG,KAAA;GAC1B,WAAW,EAAE,UAAU,GAAG,KAAA;GAC1B,OAAO;GACP;GACD,EACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;GACR,CAIqC;EAAE,GAAI;EACzC;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
|
|
1
|
+
{"version":3,"file":"Text.js","names":["RNText"],"sources":["../../src/components/Text.tsx"],"sourcesContent":["import type { ReactNode, Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type { StyleProp, TextProps as RNTextProps, TextStyle } from 'react-native';\nimport { Text as RNText } from 'react-native';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport { useMaxFontSizeMultiplier } from '../fontScaling/useMaxFontSizeMultiplier';\n\n// TextVariant is a subset of fontFamily that represents typography variants\ntype TextVariant = Exclude<\n NonNullable<StyleProps['fontFamily']>,\n 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'\n>;\ntype TextVariantProp = TextVariant | 'inherit';\n\n// React Native text decoration line values\n// See: https://reactnative.dev/docs/text-style-props#textdecorationline\ntype TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';\n\n// Chinese/Japanese/Korean scripts: Hangul Jamo, CJK radicals + punctuation,\n// Kana, Han ideographs, Hangul syllables, compatibility ideographs, and\n// full/half-width forms.\nconst CJK_RE =\n /[\\u1100-\\u11FF\\u2E80-\\u303F\\u3040-\\u30FF\\u31C0-\\u9FFF\\uAC00-\\uD7AF\\uF900-\\uFAFF\\uFF00-\\uFFEF]/;\n\n/**\n * Detects CJK characters in string children (including strings inside a\n * children array, e.g. from `{city}` interpolation). Nested elements are not\n * inspected - a nested <Text> runs its own detection.\n */\nfunction hasCJKContent(children: ReactNode): boolean {\n if (typeof children === 'string') {\n return CJK_RE.test(children);\n }\n if (Array.isArray(children)) {\n return children.some((child) => typeof child === 'string' && CJK_RE.test(child));\n }\n return false;\n}\n\ninterface TextProps extends RNTextProps {\n /** Ref to the underlying Text element */\n ref?: Ref<RNText>;\n /** Text color from the theme palette */\n color?: StyleProps['color'] | 'inherit';\n /** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */\n variant?: TextVariantProp;\n /**\n * Caps how far this text grows with the OS text-size setting. Display and\n * title variants are capped by default (see DEFAULT_MAX_FONT_SIZE_MULTIPLIERS);\n * reading sizes are uncapped. Set null to remove the cap (maps to React\n * Native's 0, which also overrides an inherited cap); inherit-variant text\n * inherits its parent's cap. Override app-wide via UDSFontScalingProvider.\n */\n maxFontSizeMultiplier?: number | null;\n /** Override the fontFamily independently */\n fontFamily?: StyleProps['fontFamily'];\n /** Override the fontSize independently */\n fontSize?: StyleProps['fontSize'];\n /** Set font weight (not derived from variant) */\n fontWeight?: StyleProps['fontWeight'];\n /** Override the lineHeight independently. Use 'none' to remove the variant lineHeight and let the font's natural line height apply */\n lineHeight?: StyleProps['lineHeight'] | 'none';\n /** Override the letterSpacing independently */\n letterSpacing?: StyleProps['letterSpacing'];\n /** Text alignment (left, center, right) */\n textAlign?: StyleProps['textAlign'];\n /** Set text transform (not derived from variant) */\n textTransform?: StyleProps['textTransform'];\n /** Text decoration (underline, line-through, etc.) */\n textDecorationLine?: TextDecorationLine;\n // Background\n backgroundColor?: StyleProps['backgroundColor'];\n // Border\n borderRadius?: StyleProps['borderRadius'];\n borderTopStartRadius?: StyleProps['borderTopStartRadius'];\n borderTopEndRadius?: StyleProps['borderTopEndRadius'];\n borderBottomStartRadius?: StyleProps['borderBottomStartRadius'];\n borderBottomEndRadius?: StyleProps['borderBottomEndRadius'];\n borderColor?: StyleProps['borderColor'];\n borderStartColor?: StyleProps['borderStartColor'];\n borderEndColor?: StyleProps['borderEndColor'];\n borderTopColor?: StyleProps['borderTopColor'];\n borderBottomColor?: StyleProps['borderBottomColor'];\n borderWidth?: StyleProps['borderWidth'];\n borderVerticalWidth?: StyleProps['borderVerticalWidth'];\n borderHorizontalWidth?: StyleProps['borderHorizontalWidth'];\n borderStartWidth?: StyleProps['borderStartWidth'];\n borderEndWidth?: StyleProps['borderEndWidth'];\n borderTopWidth?: StyleProps['borderTopWidth'];\n borderBottomWidth?: StyleProps['borderBottomWidth'];\n // Spacing\n spacing?: StyleProps['spacing'];\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n spacingVertical?: StyleProps['spacingVertical'];\n spacingBottom?: StyleProps['spacingBottom'];\n spacingEnd?: StyleProps['spacingEnd'];\n spacingStart?: StyleProps['spacingStart'];\n spacingTop?: StyleProps['spacingTop'];\n // Offset\n offset?: StyleProps['offset'];\n offsetVertical?: StyleProps['offsetVertical'];\n offsetHorizontal?: StyleProps['offsetHorizontal'];\n offsetBottom?: StyleProps['offsetBottom'];\n offsetEnd?: StyleProps['offsetEnd'];\n offsetStart?: StyleProps['offsetStart'];\n offsetTop?: StyleProps['offsetTop'];\n // Flex\n flexShrink?: StyleProps['flexShrink'];\n // Vertical Alignment\n verticalAlign?: TextStyle['textAlignVertical'];\n // Size\n height?: number | `${number}%`;\n width?: number | `${number}%`;\n minHeight?: number | `${number}%`;\n maxHeight?: number | `${number}%`;\n minWidth?: number | `${number}%`;\n maxWidth?: number | `${number}%`;\n // Dangerously set props\n dangerouslySetColor?: string;\n}\n\n/**\n * **📝 A text component with UDS styling**\n *\n * @description\n * A styled text component that supports UDS typography variants and colors.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Text } from '@yahoo/uds-mobile/Text';\n *\n * <Text variant=\"body1\" color=\"primary\">Hello, World!</Text>\n * <Text variant=\"display1\" fontWeight=\"bold\">Heading</Text>\n * <Text variant=\"label1\" color=\"secondary\">Caption text</Text>\n * ```\n *\n * @usage\n * - Use variant prop to set typography (display1, body1, label1, etc.)\n * - Use color prop to set text color from the palette\n * - Use fontWeight to override the variant's default weight\n *\n * @accessibility\n * - Text is readable by screen readers by default\n * - Use appropriate variant sizes for readability\n * - Ensure sufficient color contrast with background\n *\n * @see {@link Link} for interactive text links\n */\nconst Text = memo(function Text({\n // Text-specific\n color = 'primary',\n variant = 'body1',\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n maxFontSizeMultiplier,\n textAlign,\n textTransform,\n textDecorationLine,\n style,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n // Offset\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n // Flex\n flexShrink,\n // Vertical Alignment\n verticalAlign,\n // Size\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n // Dangerously set props\n dangerouslySetColor,\n ref,\n children,\n // Rest\n ...props\n}: TextProps) {\n const resolvedColor = color === 'inherit' ? undefined : color;\n const resolvedVariant = variant === 'inherit' ? undefined : variant;\n const resolvedFontFamily = fontFamily ?? resolvedVariant;\n const resolvedFontSize = fontSize ?? resolvedVariant;\n // React Native clips glyphs when lineHeight is smaller than the font's\n // natural line box. CJK fallback fonts are ~1.4x taller than Latin ones, so\n // Latin-tuned variant lineHeights clip CJK text - drop the variant lineHeight\n // for CJK content so the line grows to fit.\n const resolvedLineHeight =\n lineHeight === 'none'\n ? undefined\n : (lineHeight ?? (hasCJKContent(children) ? undefined : resolvedVariant));\n const resolvedLetterSpacing = letterSpacing ?? resolvedVariant;\n // Explicit prop wins, including explicit null (?? would swallow it).\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier(\n resolvedVariant,\n maxFontSizeMultiplier,\n );\n\n styles.useVariants({\n // Text styles\n color: resolvedColor,\n fontFamily: resolvedFontFamily,\n fontSize: resolvedFontSize,\n fontWeight,\n lineHeight: resolvedLineHeight,\n letterSpacing: resolvedLetterSpacing,\n textAlign,\n textTransform,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n // Offset\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n // Flex\n flexShrink,\n });\n\n // styles.foundation must be in deps - it returns a new reference when variants change.\n const computedStyle: StyleProp<TextStyle> = useMemo(\n () => [\n textDecorationLine ? { textDecorationLine } : undefined,\n dangerouslySetColor ? { color: dangerouslySetColor } : undefined,\n verticalAlign ? { textAlignVertical: verticalAlign } : undefined,\n height ? { height } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n width ? { width } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n styles.foundation,\n style,\n ],\n [\n textDecorationLine,\n dangerouslySetColor,\n verticalAlign,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n style,\n styles.foundation,\n ],\n );\n\n return (\n <RNText\n ref={ref}\n style={computedStyle}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n {...props}\n >\n {children}\n </RNText>\n );\n});\n\nText.displayName = 'Text';\n\nexport { Text, type TextProps, type TextVariant };\n"],"mappings":";;;;;;;AAuBA,MAAM,SACJ;;;;;;AAOF,SAAS,cAAc,UAA8B;CACnD,IAAI,OAAO,aAAa,UACtB,OAAO,OAAO,KAAK,SAAS;CAE9B,IAAI,MAAM,QAAQ,SAAS,EACzB,OAAO,SAAS,MAAM,UAAU,OAAO,UAAU,YAAY,OAAO,KAAK,MAAM,CAAC;CAElF,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmHT,MAAM,OAAO,KAAK,SAAS,KAAK,EAE9B,QAAQ,WACR,UAAU,SACV,YACA,UACA,YACA,YACA,eACA,uBACA,WACA,eACA,oBACA,OAEA,iBAEA,cACA,sBACA,oBACA,yBACA,uBACA,aACA,kBACA,gBACA,gBACA,mBACA,aACA,qBACA,uBACA,kBACA,gBACA,gBACA,mBAEA,SACA,mBACA,iBACA,eACA,YACA,cACA,YAEA,QACA,gBACA,kBACA,cACA,WACA,aACA,WAEA,YAEA,eAEA,QACA,WACA,WACA,OACA,UACA,UAEA,qBACA,KACA,UAEA,GAAG,SACS;CACZ,MAAM,gBAAgB,UAAU,YAAY,KAAA,IAAY;CACxD,MAAM,kBAAkB,YAAY,YAAY,KAAA,IAAY;CAC5D,MAAM,qBAAqB,cAAc;CACzC,MAAM,mBAAmB,YAAY;CAKrC,MAAM,qBACJ,eAAe,SACX,KAAA,IACC,eAAe,cAAc,SAAS,GAAG,KAAA,IAAY;CAC5D,MAAM,wBAAwB,iBAAiB;CAE/C,MAAM,gCAAgC,yBACpC,iBACA,sBACD;CAED,OAAO,YAAY;EAEjB,OAAO;EACP,YAAY;EACZ,UAAU;EACV;EACA,YAAY;EACZ,eAAe;EACf;EACA;EAEA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACD,CAAC;CAgCF,OACE,oBAACA,QAAD;EACO;EACL,OAhCwC,cACpC;GACJ,qBAAqB,EAAE,oBAAoB,GAAG,KAAA;GAC9C,sBAAsB,EAAE,OAAO,qBAAqB,GAAG,KAAA;GACvD,gBAAgB,EAAE,mBAAmB,eAAe,GAAG,KAAA;GACvD,SAAS,EAAE,QAAQ,GAAG,KAAA;GACtB,YAAY,EAAE,WAAW,GAAG,KAAA;GAC5B,YAAY,EAAE,WAAW,GAAG,KAAA;GAC5B,QAAQ,EAAE,OAAO,GAAG,KAAA;GACpB,WAAW,EAAE,UAAU,GAAG,KAAA;GAC1B,WAAW,EAAE,UAAU,GAAG,KAAA;GAC1B,OAAO;GACP;GACD,EACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;GACR,CAMqB;EACpB,uBAAuB;EACvB,GAAI;EAEH;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_portal = require("../portal.cjs");
|
|
5
|
+
const require_fontScaling_FontScalingContext = require("../fontScaling/FontScalingContext.cjs");
|
|
5
6
|
let react = require("react");
|
|
6
7
|
let react_native = require("react-native");
|
|
7
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -25,10 +26,13 @@ let react_native_gesture_handler = require("react-native-gesture-handler");
|
|
|
25
26
|
* }
|
|
26
27
|
* ```
|
|
27
28
|
*/
|
|
28
|
-
const UDSGestureProvider = (0, react.memo)(function UDSGestureProvider({ children }) {
|
|
29
|
+
const UDSGestureProvider = (0, react.memo)(function UDSGestureProvider({ children, fontScaling }) {
|
|
29
30
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_gesture_handler.GestureHandlerRootView, {
|
|
30
31
|
style: styles.root,
|
|
31
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal.PortalProvider, { children
|
|
32
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_portal.PortalProvider, { children: fontScaling ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_fontScaling_FontScalingContext.UDSFontScalingProvider, {
|
|
33
|
+
config: fontScaling,
|
|
34
|
+
children
|
|
35
|
+
}) : children })
|
|
32
36
|
});
|
|
33
37
|
});
|
|
34
38
|
/**
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
import { FontScalingConfig } from "../fontScaling/types.cjs";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/components/UDSProvider.d.ts
|
|
6
7
|
interface UDSGestureProviderProps {
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* App-wide font-scaling caps, overriding the built-in defaults. Omit to use
|
|
11
|
+
* the defaults (display/title tiers capped, reading sizes uncapped, control
|
|
12
|
+
* internals capped at 2x). Should be identity-stable (a module constant or
|
|
13
|
+
* memoized) — every UDS text element reads it from context.
|
|
14
|
+
*/
|
|
15
|
+
fontScaling?: FontScalingConfig;
|
|
8
16
|
}
|
|
9
17
|
/**
|
|
10
18
|
* Root gesture and portal provider for UDS Mobile overlays.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.d.cts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UDSProvider.d.cts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD;;;;;EAW5D,WAAA,GAAc,iBAAA;AAAA;;;;AAAiB;;;;;AAqBT;;;;;AAiCxB;;;;;cAjCM,kBAAA,EAAkB,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;cAoBlB,WAAA,EAAW,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;KAaL,gBAAA,GAAmB,uBAAA"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
import { FontScalingConfig } from "../fontScaling/types.js";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/components/UDSProvider.d.ts
|
|
6
7
|
interface UDSGestureProviderProps {
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* App-wide font-scaling caps, overriding the built-in defaults. Omit to use
|
|
11
|
+
* the defaults (display/title tiers capped, reading sizes uncapped, control
|
|
12
|
+
* internals capped at 2x). Should be identity-stable (a module constant or
|
|
13
|
+
* memoized) — every UDS text element reads it from context.
|
|
14
|
+
*/
|
|
15
|
+
fontScaling?: FontScalingConfig;
|
|
8
16
|
}
|
|
9
17
|
/**
|
|
10
18
|
* Root gesture and portal provider for UDS Mobile overlays.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.d.ts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UDSProvider.d.ts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD;;;;;EAW5D,WAAA,GAAc,iBAAA;AAAA;;;;AAAiB;;;;;AAqBT;;;;;AAiCxB;;;;;cAjCM,kBAAA,EAAkB,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;cAoBlB,WAAA,EAAW,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;KAaL,gBAAA,GAAmB,uBAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { PortalProvider } from "../portal.js";
|
|
3
|
+
import { UDSFontScalingProvider } from "../fontScaling/FontScalingContext.js";
|
|
3
4
|
import { memo } from "react";
|
|
4
5
|
import { StyleSheet } from "react-native";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -23,10 +24,13 @@ import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
|
23
24
|
* }
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
const UDSGestureProvider = memo(function UDSGestureProvider({ children }) {
|
|
27
|
+
const UDSGestureProvider = memo(function UDSGestureProvider({ children, fontScaling }) {
|
|
27
28
|
return /* @__PURE__ */ jsx(GestureHandlerRootView, {
|
|
28
29
|
style: styles.root,
|
|
29
|
-
children: /* @__PURE__ */ jsx(PortalProvider, { children
|
|
30
|
+
children: /* @__PURE__ */ jsx(PortalProvider, { children: fontScaling ? /* @__PURE__ */ jsx(UDSFontScalingProvider, {
|
|
31
|
+
config: fontScaling,
|
|
32
|
+
children
|
|
33
|
+
}) : children })
|
|
30
34
|
});
|
|
31
35
|
});
|
|
32
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.js","names":[],"sources":["../../src/components/UDSProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { memo } from 'react';\nimport { StyleSheet } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\nimport { PortalProvider } from '../portal';\n\ninterface UDSGestureProviderProps {\n children: ReactNode;\n}\n\n/**\n * Root gesture and portal provider for UDS Mobile overlays.\n *\n * Place this at the top of your app layout:\n *\n * @example\n * ```tsx\n * import { UDSGestureProvider } from '@yahoo/uds-mobile/UDSGestureProvider';\n *\n * export default function RootLayout() {\n * return (\n * <UDSGestureProvider>\n * <Stack />\n * </UDSGestureProvider>\n * );\n * }\n * ```\n */\nconst UDSGestureProvider = memo(function UDSGestureProvider({
|
|
1
|
+
{"version":3,"file":"UDSProvider.js","names":[],"sources":["../../src/components/UDSProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { memo } from 'react';\nimport { StyleSheet } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\nimport { UDSFontScalingProvider } from '../fontScaling/FontScalingContext';\nimport type { FontScalingConfig } from '../fontScaling/types';\nimport { PortalProvider } from '../portal';\n\ninterface UDSGestureProviderProps {\n children: ReactNode;\n /**\n * App-wide font-scaling caps, overriding the built-in defaults. Omit to use\n * the defaults (display/title tiers capped, reading sizes uncapped, control\n * internals capped at 2x). Should be identity-stable (a module constant or\n * memoized) — every UDS text element reads it from context.\n */\n fontScaling?: FontScalingConfig;\n}\n\n/**\n * Root gesture and portal provider for UDS Mobile overlays.\n *\n * Place this at the top of your app layout:\n *\n * @example\n * ```tsx\n * import { UDSGestureProvider } from '@yahoo/uds-mobile/UDSGestureProvider';\n *\n * export default function RootLayout() {\n * return (\n * <UDSGestureProvider>\n * <Stack />\n * </UDSGestureProvider>\n * );\n * }\n * ```\n */\nconst UDSGestureProvider = memo(function UDSGestureProvider({\n children,\n fontScaling,\n}: UDSGestureProviderProps) {\n return (\n <GestureHandlerRootView style={styles.root}>\n <PortalProvider>\n {fontScaling ? (\n <UDSFontScalingProvider config={fontScaling}>{children}</UDSFontScalingProvider>\n ) : (\n children\n )}\n </PortalProvider>\n </GestureHandlerRootView>\n );\n});\n\n/**\n * @deprecated Use {@link UDSGestureProvider} from `@yahoo/uds-mobile/UDSGestureProvider`.\n */\nconst UDSProvider = UDSGestureProvider;\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n },\n});\n\nexport { UDSGestureProvider, UDSProvider };\nexport type { UDSGestureProviderProps };\n/**\n * @deprecated Use {@link UDSGestureProviderProps}.\n */\nexport type UDSProviderProps = UDSGestureProviderProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,qBAAqB,KAAK,SAAS,mBAAmB,EAC1D,UACA,eAC0B;CAC1B,OACE,oBAAC,wBAAD;EAAwB,OAAO,OAAO;YACpC,oBAAC,gBAAD,EAAA,UACG,cACC,oBAAC,wBAAD;GAAwB,QAAQ;GAAc;GAAkC,CAAA,GAEhF,UAEa,CAAA;EACM,CAAA;EAE3B;;;;AAKF,MAAM,cAAc;AAEpB,MAAM,SAAS,WAAW,OAAO,EAC/B,MAAM,EACJ,MAAM,GACP,EACF,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require_components_internal_Overlay_measureTrigger = require("./measureTrigger.cjs");
|
|
4
3
|
const require_components_internal_Overlay_OverlayPortal = require("./OverlayPortal.cjs");
|
|
4
|
+
const require_components_internal_Overlay_measureTrigger = require("./measureTrigger.cjs");
|
|
5
5
|
const require_components_internal_Overlay_useAnchoredPosition = require("./useAnchoredPosition.cjs");
|
|
6
6
|
const require_components_internal_Overlay_useControllableState = require("./useControllableState.cjs");
|
|
7
7
|
const require_components_internal_Overlay_useOverlayDismiss = require("./useOverlayDismiss.cjs");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { measureTrigger } from "./measureTrigger.js";
|
|
3
2
|
import { OverlayPortal } from "./OverlayPortal.js";
|
|
3
|
+
import { measureTrigger } from "./measureTrigger.js";
|
|
4
4
|
import { useAnchoredPosition } from "./useAnchoredPosition.js";
|
|
5
5
|
import { useControllableState } from "./useControllableState.js";
|
|
6
6
|
import { useOverlayDismiss } from "./useOverlayDismiss.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
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_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
//#region src/fontScaling/FontScalingContext.tsx
|
|
7
|
+
const FontScalingContext = (0, react.createContext)(void 0);
|
|
8
|
+
/**
|
|
9
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
10
|
+
*
|
|
11
|
+
* @description
|
|
12
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
13
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
14
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
15
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
20
|
+
*
|
|
21
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
22
|
+
* <App />
|
|
23
|
+
* </UDSFontScalingProvider>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const UDSFontScalingProvider = (0, react.memo)(function UDSFontScalingProvider({ config, children }) {
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontScalingContext.Provider, {
|
|
28
|
+
value: config,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
UDSFontScalingProvider.displayName = "UDSFontScalingProvider";
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.FontScalingContext = FontScalingContext;
|
|
35
|
+
exports.UDSFontScalingProvider = UDSFontScalingProvider;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { FontScalingConfig } from "./types.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/fontScaling/FontScalingContext.d.ts
|
|
7
|
+
declare const FontScalingContext: _$react.Context<FontScalingConfig | undefined>;
|
|
8
|
+
interface UDSFontScalingProviderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Font-scaling caps for the subtree. Should be identity-stable (a module
|
|
11
|
+
* constant or memoized) — every UDS text element reads it from context.
|
|
12
|
+
* The nearest provider wins wholesale; configs are not merged.
|
|
13
|
+
*/
|
|
14
|
+
config: FontScalingConfig;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
19
|
+
*
|
|
20
|
+
* @description
|
|
21
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
22
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
23
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
24
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
29
|
+
*
|
|
30
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
31
|
+
* <App />
|
|
32
|
+
* </UDSFontScalingProvider>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const UDSFontScalingProvider: _$react.NamedExoticComponent<UDSFontScalingProviderProps>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };
|
|
38
|
+
//# sourceMappingURL=FontScalingContext.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontScalingContext.d.cts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;cAMM,kBAAA,EAAkB,OAAA,CAAA,OAAA,CAAA,iBAAA;AAAA,UAEd,2BAAA;;AALuC;;;;EAW/C,MAAA,EAAQ,iBAAA;EACR,QAAA,EAAU,SAAA;AAAA;;;;;;;;;AAAS;;;;;;;;;;cAqBf,sBAAA,EAAsB,OAAA,CAAA,oBAAA,CAAA,2BAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { FontScalingConfig } from "./types.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/fontScaling/FontScalingContext.d.ts
|
|
7
|
+
declare const FontScalingContext: _$react.Context<FontScalingConfig | undefined>;
|
|
8
|
+
interface UDSFontScalingProviderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Font-scaling caps for the subtree. Should be identity-stable (a module
|
|
11
|
+
* constant or memoized) — every UDS text element reads it from context.
|
|
12
|
+
* The nearest provider wins wholesale; configs are not merged.
|
|
13
|
+
*/
|
|
14
|
+
config: FontScalingConfig;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
19
|
+
*
|
|
20
|
+
* @description
|
|
21
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
22
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
23
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
24
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
29
|
+
*
|
|
30
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
31
|
+
* <App />
|
|
32
|
+
* </UDSFontScalingProvider>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const UDSFontScalingProvider: _$react.NamedExoticComponent<UDSFontScalingProviderProps>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };
|
|
38
|
+
//# sourceMappingURL=FontScalingContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontScalingContext.d.ts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;cAMM,kBAAA,EAAkB,OAAA,CAAA,OAAA,CAAA,iBAAA;AAAA,UAEd,2BAAA;;AALuC;;;;EAW/C,MAAA,EAAQ,iBAAA;EACR,QAAA,EAAU,SAAA;AAAA;;;;;;;;;AAAS;;;;;;;;;;cAqBf,sBAAA,EAAsB,OAAA,CAAA,oBAAA,CAAA,2BAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { createContext, memo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/fontScaling/FontScalingContext.tsx
|
|
5
|
+
const FontScalingContext = createContext(void 0);
|
|
6
|
+
/**
|
|
7
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
11
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
12
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
13
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
18
|
+
*
|
|
19
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
20
|
+
* <App />
|
|
21
|
+
* </UDSFontScalingProvider>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const UDSFontScalingProvider = memo(function UDSFontScalingProvider({ config, children }) {
|
|
25
|
+
return /* @__PURE__ */ jsx(FontScalingContext.Provider, {
|
|
26
|
+
value: config,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
UDSFontScalingProvider.displayName = "UDSFontScalingProvider";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { FontScalingContext, UDSFontScalingProvider };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=FontScalingContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontScalingContext.js","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { createContext, memo } from 'react';\n\nimport type { FontScalingConfig } from './types';\n\n// undefined = no provider mounted; built-in defaults apply.\nconst FontScalingContext = createContext<FontScalingConfig | undefined>(undefined);\n\ninterface UDSFontScalingProviderProps {\n /**\n * Font-scaling caps for the subtree. Should be identity-stable (a module\n * constant or memoized) — every UDS text element reads it from context.\n * The nearest provider wins wholesale; configs are not merged.\n */\n config: FontScalingConfig;\n children: ReactNode;\n}\n\n/**\n * **🔠 Overrides UDS font-scaling caps for a subtree**\n *\n * @description\n * Configures how UDS text and controls respond to the OS text-size setting.\n * Without a provider, built-in defaults apply (display/title tiers capped,\n * reading sizes uncapped, control internals capped at 2x). Most apps set this\n * once at the root via the `fontScaling` prop on `UDSGestureProvider`.\n *\n * @example\n * ```tsx\n * const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };\n *\n * <UDSFontScalingProvider config={FONT_SCALING}>\n * <App />\n * </UDSFontScalingProvider>\n * ```\n */\nconst UDSFontScalingProvider = memo(function UDSFontScalingProvider({\n config,\n children,\n}: UDSFontScalingProviderProps) {\n return <FontScalingContext.Provider value={config}>{children}</FontScalingContext.Provider>;\n});\n\nUDSFontScalingProvider.displayName = 'UDSFontScalingProvider';\n\nexport { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };\n"],"mappings":";;;;AAMA,MAAM,qBAAqB,cAA6C,KAAA,EAAU;;;;;;;;;;;;;;;;;;;AA8BlF,MAAM,yBAAyB,KAAK,SAAS,uBAAuB,EAClE,QACA,YAC8B;CAC9B,OAAO,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EAAS;EAAuC,CAAA;EAC3F;AAEF,uBAAuB,cAAc"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/fontScaling/constants.ts
|
|
4
|
+
/**
|
|
5
|
+
* The largest OS font scale UDS components are designed to support.
|
|
6
|
+
*
|
|
7
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
8
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
9
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
10
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
11
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
12
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
13
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
14
|
+
*/
|
|
15
|
+
const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
16
|
+
/**
|
|
17
|
+
* How far each text style would grow if only legibility mattered, following
|
|
18
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
19
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
20
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
21
|
+
* are larger than largeTitle, so they taper hardest.
|
|
22
|
+
*
|
|
23
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
24
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
25
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
26
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
27
|
+
*
|
|
28
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
29
|
+
*/
|
|
30
|
+
const TYPE_SCALE_CURVE = {
|
|
31
|
+
display1: 1.5,
|
|
32
|
+
display2: 1.6,
|
|
33
|
+
display3: 1.75,
|
|
34
|
+
title1: 1.8,
|
|
35
|
+
title2: 2,
|
|
36
|
+
title3: 2.2,
|
|
37
|
+
title4: 2.4,
|
|
38
|
+
headline1: 2.5,
|
|
39
|
+
ui1: 2.2,
|
|
40
|
+
ui2: 2.4,
|
|
41
|
+
body1: null,
|
|
42
|
+
label1: null,
|
|
43
|
+
label2: null,
|
|
44
|
+
label3: null,
|
|
45
|
+
label4: null,
|
|
46
|
+
caption1: null,
|
|
47
|
+
caption2: null,
|
|
48
|
+
legal1: null,
|
|
49
|
+
ui3: null,
|
|
50
|
+
ui4: null,
|
|
51
|
+
ui5: null,
|
|
52
|
+
ui6: null
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
56
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
57
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
58
|
+
*
|
|
59
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
60
|
+
*/
|
|
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
|
+
/**
|
|
63
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
64
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
65
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
66
|
+
*/
|
|
67
|
+
const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER;
|
|
70
|
+
exports.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = DEFAULT_MAX_FONT_SIZE_MULTIPLIERS;
|
|
71
|
+
exports.MAX_SUPPORTED_FONT_SCALE = MAX_SUPPORTED_FONT_SCALE;
|
|
72
|
+
exports.TYPE_SCALE_CURVE = TYPE_SCALE_CURVE;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
import { FontScalingCapValue } from "./types.cjs";
|
|
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.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","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"}
|