@yahoo/uds-mobile 2.24.0-beta.1 → 2.24.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/dist/components/Avatar/AvatarIcon.cjs +8 -2
- package/dist/components/Avatar/AvatarIcon.d.cts.map +1 -1
- package/dist/components/Avatar/AvatarIcon.d.ts.map +1 -1
- package/dist/components/Avatar/AvatarIcon.js +9 -3
- package/dist/components/Avatar/AvatarIcon.js.map +1 -1
- package/dist/components/Avatar/AvatarImage.cjs +9 -2
- package/dist/components/Avatar/AvatarImage.d.cts.map +1 -1
- package/dist/components/Avatar/AvatarImage.d.ts.map +1 -1
- package/dist/components/Avatar/AvatarImage.js +10 -3
- package/dist/components/Avatar/AvatarImage.js.map +1 -1
- package/dist/components/Avatar/AvatarText.cjs +8 -2
- package/dist/components/Avatar/AvatarText.d.cts.map +1 -1
- package/dist/components/Avatar/AvatarText.d.ts.map +1 -1
- package/dist/components/Avatar/AvatarText.js +9 -3
- package/dist/components/Avatar/AvatarText.js.map +1 -1
- package/dist/components/Avatar/types.d.cts +7 -3
- package/dist/components/Avatar/types.d.cts.map +1 -1
- package/dist/components/Avatar/types.d.ts +7 -3
- package/dist/components/Avatar/types.d.ts.map +1 -1
- package/dist/components/Avatar/useAvatarFontScale.cjs +16 -0
- package/dist/components/Avatar/useAvatarFontScale.d.cts +7 -0
- package/dist/components/Avatar/useAvatarFontScale.d.cts.map +1 -0
- package/dist/components/Avatar/useAvatarFontScale.d.ts +7 -0
- package/dist/components/Avatar/useAvatarFontScale.d.ts.map +1 -0
- package/dist/components/Avatar/useAvatarFontScale.js +16 -0
- package/dist/components/Avatar/useAvatarFontScale.js.map +1 -0
- package/dist/components/Avatar/utils.cjs +9 -6
- package/dist/components/Avatar/utils.d.cts +2 -2
- package/dist/components/Avatar/utils.d.cts.map +1 -1
- package/dist/components/Avatar/utils.d.ts +2 -2
- package/dist/components/Avatar/utils.d.ts.map +1 -1
- package/dist/components/Avatar/utils.js +9 -6
- package/dist/components/Avatar/utils.js.map +1 -1
- package/dist/components/Button/buttonTheme.cjs +16 -7
- package/dist/components/Button/buttonTheme.d.cts +13 -6
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +13 -6
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +16 -8
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +25 -11
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +25 -11
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +16 -6
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +16 -6
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +24 -21
- package/dist/components/Chip/ChipBase.js +24 -21
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Icon.cjs +22 -6
- package/dist/components/Icon.d.cts +6 -5
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts +6 -5
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +22 -6
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.cjs +17 -6
- package/dist/components/IconButton.d.cts +6 -0
- package/dist/components/IconButton.d.cts.map +1 -1
- package/dist/components/IconButton.d.ts +6 -0
- package/dist/components/IconButton.d.ts.map +1 -1
- package/dist/components/IconButton.js +18 -7
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/Input.cjs +56 -18
- package/dist/components/Input.d.cts +5 -0
- package/dist/components/Input.d.cts.map +1 -1
- package/dist/components/Input.d.ts +5 -0
- package/dist/components/Input.d.ts.map +1 -1
- package/dist/components/Input.js +56 -18
- package/dist/components/Input.js.map +1 -1
- package/dist/components/InputHelpText.cjs +7 -1
- package/dist/components/InputHelpText.d.cts +2 -0
- package/dist/components/InputHelpText.d.cts.map +1 -1
- package/dist/components/InputHelpText.d.ts +2 -0
- package/dist/components/InputHelpText.d.ts.map +1 -1
- package/dist/components/InputHelpText.js +7 -1
- package/dist/components/InputHelpText.js.map +1 -1
- package/dist/components/Link.cjs +13 -1
- package/dist/components/Link.d.cts +7 -0
- package/dist/components/Link.d.cts.map +1 -1
- package/dist/components/Link.d.ts +7 -0
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +13 -1
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs +18 -10
- package/dist/components/Pagination/Pagination.d.cts +2 -0
- package/dist/components/Pagination/Pagination.d.cts.map +1 -1
- package/dist/components/Pagination/Pagination.d.ts +2 -0
- package/dist/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.js +18 -10
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/Pagination/PaginationEllipsis.cjs +8 -2
- package/dist/components/Pagination/PaginationEllipsis.d.cts.map +1 -1
- package/dist/components/Pagination/PaginationEllipsis.d.ts.map +1 -1
- package/dist/components/Pagination/PaginationEllipsis.js +9 -3
- package/dist/components/Pagination/PaginationEllipsis.js.map +1 -1
- package/dist/components/Pagination/PaginationItem.cjs +2 -1
- package/dist/components/Pagination/PaginationItem.js +2 -1
- package/dist/components/Pagination/PaginationItem.js.map +1 -1
- package/dist/components/Pagination/PaginationLink.cjs +2 -1
- package/dist/components/Pagination/PaginationLink.js +2 -1
- package/dist/components/Pagination/PaginationLink.js.map +1 -1
- package/dist/components/Pagination/PaginationNext.cjs +3 -1
- package/dist/components/Pagination/PaginationNext.js +3 -1
- package/dist/components/Pagination/PaginationNext.js.map +1 -1
- package/dist/components/Pagination/PaginationPrev.cjs +3 -1
- package/dist/components/Pagination/PaginationPrev.js +3 -1
- package/dist/components/Pagination/PaginationPrev.js.map +1 -1
- package/dist/components/Pagination/paginationContext.d.cts +2 -0
- package/dist/components/Pagination/paginationContext.d.cts.map +1 -1
- package/dist/components/Pagination/paginationContext.d.ts +2 -0
- package/dist/components/Pagination/paginationContext.d.ts.map +1 -1
- package/dist/components/Pagination/paginationContext.js.map +1 -1
- package/dist/components/Pagination/usePaginationControlStyles.cjs +8 -1
- package/dist/components/Pagination/usePaginationControlStyles.d.cts.map +1 -1
- package/dist/components/Pagination/usePaginationControlStyles.d.ts.map +1 -1
- package/dist/components/Pagination/usePaginationControlStyles.js +9 -2
- package/dist/components/Pagination/usePaginationControlStyles.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +4 -3
- package/dist/components/Radio/Radio.js +4 -3
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Select/Select.cjs +29 -6
- package/dist/components/Select/Select.d.cts +2 -0
- package/dist/components/Select/Select.d.cts.map +1 -1
- package/dist/components/Select/Select.d.ts +2 -0
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/Select.js +29 -6
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectContent.cjs +31 -23
- package/dist/components/Select/SelectContent.d.cts.map +1 -1
- package/dist/components/Select/SelectContent.d.ts.map +1 -1
- package/dist/components/Select/SelectContent.js +32 -24
- package/dist/components/Select/SelectContent.js.map +1 -1
- package/dist/components/Select/SelectItem.cjs +25 -15
- package/dist/components/Select/SelectItem.d.cts.map +1 -1
- package/dist/components/Select/SelectItem.d.ts.map +1 -1
- package/dist/components/Select/SelectItem.js +25 -15
- package/dist/components/Select/SelectItem.js.map +1 -1
- package/dist/components/Select/SelectTrigger.cjs +27 -13
- package/dist/components/Select/SelectTrigger.d.cts.map +1 -1
- package/dist/components/Select/SelectTrigger.d.ts.map +1 -1
- package/dist/components/Select/SelectTrigger.js +27 -13
- package/dist/components/Select/SelectTrigger.js.map +1 -1
- package/dist/components/Select/types.d.cts +2 -0
- package/dist/components/Select/types.d.cts.map +1 -1
- package/dist/components/Select/types.d.ts +2 -0
- package/dist/components/Select/types.d.ts.map +1 -1
- package/dist/components/Switch.cjs +31 -14
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +31 -14
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +8 -4
- package/dist/components/Tabs/Tab.d.cts.map +1 -1
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.js +8 -4
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Text.cjs +5 -0
- package/dist/components/Text.d.cts +6 -5
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts +6 -5
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +5 -0
- package/dist/components/Text.js.map +1 -1
- package/dist/components/UDSProvider.cjs +1 -1
- package/dist/components/UDSProvider.d.cts +4 -3
- package/dist/components/UDSProvider.d.cts.map +1 -1
- package/dist/components/UDSProvider.d.ts +4 -3
- package/dist/components/UDSProvider.d.ts.map +1 -1
- package/dist/components/UDSProvider.js +1 -1
- package/dist/components/UDSProvider.js.map +1 -1
- package/dist/fontScaling/FontScalingContext.cjs +35 -3
- package/dist/fontScaling/FontScalingContext.d.cts +20 -5
- package/dist/fontScaling/FontScalingContext.d.cts.map +1 -1
- package/dist/fontScaling/FontScalingContext.d.ts +20 -5
- package/dist/fontScaling/FontScalingContext.d.ts.map +1 -1
- package/dist/fontScaling/FontScalingContext.js +34 -5
- package/dist/fontScaling/FontScalingContext.js.map +1 -1
- package/dist/fontScaling/androidNonlinearFontScaling.cjs +250 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.cts +7 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.cts.map +1 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.ts +7 -0
- package/dist/fontScaling/androidNonlinearFontScaling.d.ts.map +1 -0
- package/dist/fontScaling/androidNonlinearFontScaling.js +251 -0
- package/dist/fontScaling/androidNonlinearFontScaling.js.map +1 -0
- package/dist/fontScaling/constants.cjs +37 -3
- package/dist/fontScaling/constants.d.cts +15 -4
- package/dist/fontScaling/constants.d.cts.map +1 -1
- package/dist/fontScaling/constants.d.ts +15 -4
- package/dist/fontScaling/constants.d.ts.map +1 -1
- package/dist/fontScaling/constants.js +37 -4
- package/dist/fontScaling/constants.js.map +1 -1
- package/dist/fontScaling/index.cjs +2 -1
- package/dist/fontScaling/index.d.cts +2 -2
- package/dist/fontScaling/index.d.ts +2 -2
- package/dist/fontScaling/index.js +3 -3
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.cjs +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts.map +1 -1
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts.map +1 -1
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js +1 -2
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js.map +1 -1
- package/dist/fontScaling/types.d.cts +11 -8
- package/dist/fontScaling/types.d.cts.map +1 -1
- package/dist/fontScaling/types.d.ts +11 -8
- package/dist/fontScaling/types.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.cjs +30 -4
- package/dist/fontScaling/useFontScale.d.cts +6 -12
- package/dist/fontScaling/useFontScale.d.cts.map +1 -1
- package/dist/fontScaling/useFontScale.d.ts +6 -12
- package/dist/fontScaling/useFontScale.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.js +31 -6
- package/dist/fontScaling/useFontScale.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +14 -1
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +14 -1
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/mobile/generated/fontMetrics.cjs +530 -530
- package/dist/mobile/generated/fontMetrics.js +530 -530
- package/dist/mobile/generated/fontMetrics.js.map +1 -1
- package/dist/portal.cjs +8 -2
- package/dist/portal.d.cts.map +1 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js +8 -2
- package/dist/portal.js.map +1 -1
- package/fonts/index.cjs +214 -214
- package/fonts/index.mjs +214 -214
- package/generated/fontMetrics.ts +530 -530
- package/package.json +1 -1
|
@@ -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';\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"}
|
|
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 { DEFAULT_DYNAMIC_TYPE_RAMPS } from '../fontScaling/constants';\nimport { useDynamicTypeRampEnabled } from '../fontScaling/FontScalingContext';\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. Every text\n * variant is capped at 2x or below by default, with the largest display and\n * title variants tapering further (see DEFAULT_MAX_FONT_SIZE_MULTIPLIERS).\n * Set null to remove the cap (maps to React Native's 0, which also overrides\n * an inherited cap); inherit-variant text inherits its parent's cap.\n * 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 const baseVariant = resolvedVariant?.split('/')[0] as TextVariant | undefined;\n const dynamicTypeRampEnabled = useDynamicTypeRampEnabled();\n const defaultDynamicTypeRamp =\n dynamicTypeRampEnabled && baseVariant ? DEFAULT_DYNAMIC_TYPE_RAMPS[baseVariant] : undefined;\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 dynamicTypeRamp={defaultDynamicTypeRamp}\n {...props}\n >\n {children}\n </RNText>\n );\n});\n\nText.displayName = 'Text';\n\nexport { Text, type TextProps, type TextVariant };\n"],"mappings":";;;;;;;;;AAyBA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoHT,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;CAC/C,MAAM,cAAc,iBAAiB,MAAM,IAAI,CAAC;CAEhD,MAAM,yBADyB,2BAEP,IAAI,cAAc,2BAA2B,eAAe,KAAA;CAEpF,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,iBAAiB;EACjB,GAAI;EAEH;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
4
|
-
const require_portal = require("../portal.cjs");
|
|
5
4
|
const require_fontScaling_FontScalingContext = require("../fontScaling/FontScalingContext.cjs");
|
|
5
|
+
const require_portal = require("../portal.cjs");
|
|
6
6
|
let react = require("react");
|
|
7
7
|
let react_native = require("react-native");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -8,9 +8,10 @@ interface UDSGestureProviderProps {
|
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
/**
|
|
10
10
|
* App-wide font-scaling caps, overriding the built-in defaults. Omit to use
|
|
11
|
-
* the defaults (
|
|
12
|
-
* internals capped at 2x).
|
|
13
|
-
* memoized) — every UDS text
|
|
11
|
+
* the defaults (every text style capped at 2x or below, with the largest
|
|
12
|
+
* display/title tiers tapered further, and control internals capped at 2x).
|
|
13
|
+
* Should be identity-stable (a module constant or memoized) — every UDS text
|
|
14
|
+
* element reads it from context.
|
|
14
15
|
*/
|
|
15
16
|
fontScaling?: FontScalingConfig;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.d.cts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD
|
|
1
|
+
{"version":3,"file":"UDSProvider.d.cts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD;;;;;;EAY5D,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"}
|
|
@@ -8,9 +8,10 @@ interface UDSGestureProviderProps {
|
|
|
8
8
|
children: ReactNode;
|
|
9
9
|
/**
|
|
10
10
|
* App-wide font-scaling caps, overriding the built-in defaults. Omit to use
|
|
11
|
-
* the defaults (
|
|
12
|
-
* internals capped at 2x).
|
|
13
|
-
* memoized) — every UDS text
|
|
11
|
+
* the defaults (every text style capped at 2x or below, with the largest
|
|
12
|
+
* display/title tiers tapered further, and control internals capped at 2x).
|
|
13
|
+
* Should be identity-stable (a module constant or memoized) — every UDS text
|
|
14
|
+
* element reads it from context.
|
|
14
15
|
*/
|
|
15
16
|
fontScaling?: FontScalingConfig;
|
|
16
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.d.ts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD
|
|
1
|
+
{"version":3,"file":"UDSProvider.d.ts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD;;;;;;EAY5D,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,6 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { PortalProvider } from "../portal.js";
|
|
3
2
|
import { UDSFontScalingProvider } from "../fontScaling/FontScalingContext.js";
|
|
3
|
+
import { PortalProvider } from "../portal.js";
|
|
4
4
|
import { memo } from "react";
|
|
5
5
|
import { StyleSheet } from "react-native";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -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 { 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 (
|
|
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 (every text style capped at 2x or below, with the largest\n * display/title tiers tapered further, and control internals capped at 2x).\n * Should be identity-stable (a module constant or memoized) — every UDS text\n * 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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,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"}
|
|
@@ -5,14 +5,24 @@ let react = require("react");
|
|
|
5
5
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
6
|
//#region src/fontScaling/FontScalingContext.tsx
|
|
7
7
|
const FontScalingContext = (0, react.createContext)(void 0);
|
|
8
|
+
/** Whether UDS-added caps, ramps, and scale-aware geometry are enabled. */
|
|
9
|
+
function useFontScalingEnabled() {
|
|
10
|
+
return (0, react.useContext)(FontScalingContext)?.enabled !== false;
|
|
11
|
+
}
|
|
12
|
+
/** Whether Text should supply its variant's default iOS Dynamic Type ramp. */
|
|
13
|
+
function useDynamicTypeRampEnabled() {
|
|
14
|
+
const config = (0, react.useContext)(FontScalingContext);
|
|
15
|
+
return config?.enabled !== false && config?.disableDynamicTypeRamp !== true;
|
|
16
|
+
}
|
|
8
17
|
/**
|
|
9
18
|
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
10
19
|
*
|
|
11
20
|
* @description
|
|
12
21
|
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
13
|
-
* Without a provider, built-in defaults apply (
|
|
14
|
-
*
|
|
15
|
-
* once at the root via the
|
|
22
|
+
* Without a provider, built-in defaults apply (every text style is capped at
|
|
23
|
+
* 2x or below, with the largest display/title tiers tapered further, and
|
|
24
|
+
* control internals capped at 2x). Most apps set this once at the root via the
|
|
25
|
+
* `fontScaling` prop on `UDSGestureProvider`.
|
|
16
26
|
*
|
|
17
27
|
* @example
|
|
18
28
|
* ```tsx
|
|
@@ -30,6 +40,28 @@ const UDSFontScalingProvider = (0, react.memo)(function UDSFontScalingProvider({
|
|
|
30
40
|
});
|
|
31
41
|
});
|
|
32
42
|
UDSFontScalingProvider.displayName = "UDSFontScalingProvider";
|
|
43
|
+
/** Keeps custom UDS content inside a control on the control's resolved cap. */
|
|
44
|
+
const ResolvedControlFontScalingProvider = (0, react.memo)(function ResolvedControlFontScalingProvider({ maxFontSizeMultiplier, children }) {
|
|
45
|
+
const parentConfig = (0, react.useContext)(FontScalingContext);
|
|
46
|
+
const cap = maxFontSizeMultiplier === 0 ? null : maxFontSizeMultiplier;
|
|
47
|
+
const config = (0, react.useMemo)(() => parentConfig?.enabled === false && maxFontSizeMultiplier === void 0 ? { enabled: false } : {
|
|
48
|
+
default: cap,
|
|
49
|
+
control: cap,
|
|
50
|
+
disableDynamicTypeRamp: true
|
|
51
|
+
}, [
|
|
52
|
+
cap,
|
|
53
|
+
maxFontSizeMultiplier,
|
|
54
|
+
parentConfig?.enabled
|
|
55
|
+
]);
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontScalingContext.Provider, {
|
|
57
|
+
value: config,
|
|
58
|
+
children
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
ResolvedControlFontScalingProvider.displayName = "ResolvedControlFontScalingProvider";
|
|
33
62
|
//#endregion
|
|
34
63
|
exports.FontScalingContext = FontScalingContext;
|
|
64
|
+
exports.ResolvedControlFontScalingProvider = ResolvedControlFontScalingProvider;
|
|
35
65
|
exports.UDSFontScalingProvider = UDSFontScalingProvider;
|
|
66
|
+
exports.useDynamicTypeRampEnabled = useDynamicTypeRampEnabled;
|
|
67
|
+
exports.useFontScalingEnabled = useFontScalingEnabled;
|
|
@@ -4,7 +4,15 @@ import * as _$react from "react";
|
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/fontScaling/FontScalingContext.d.ts
|
|
7
|
-
|
|
7
|
+
interface FontScalingContextValue extends FontScalingConfig {
|
|
8
|
+
/** Internal: bounded controls use the global curve for text, icons, and geometry. */
|
|
9
|
+
disableDynamicTypeRamp?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const FontScalingContext: _$react.Context<FontScalingContextValue | undefined>;
|
|
12
|
+
/** Whether UDS-added caps, ramps, and scale-aware geometry are enabled. */
|
|
13
|
+
declare function useFontScalingEnabled(): boolean;
|
|
14
|
+
/** Whether Text should supply its variant's default iOS Dynamic Type ramp. */
|
|
15
|
+
declare function useDynamicTypeRampEnabled(): boolean;
|
|
8
16
|
interface UDSFontScalingProviderProps {
|
|
9
17
|
/**
|
|
10
18
|
* Font-scaling caps for the subtree. Should be identity-stable (a module
|
|
@@ -19,9 +27,10 @@ interface UDSFontScalingProviderProps {
|
|
|
19
27
|
*
|
|
20
28
|
* @description
|
|
21
29
|
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
22
|
-
* Without a provider, built-in defaults apply (
|
|
23
|
-
*
|
|
24
|
-
* once at the root via the
|
|
30
|
+
* Without a provider, built-in defaults apply (every text style is capped at
|
|
31
|
+
* 2x or below, with the largest display/title tiers tapered further, and
|
|
32
|
+
* control internals capped at 2x). Most apps set this once at the root via the
|
|
33
|
+
* `fontScaling` prop on `UDSGestureProvider`.
|
|
25
34
|
*
|
|
26
35
|
* @example
|
|
27
36
|
* ```tsx
|
|
@@ -33,6 +42,12 @@ interface UDSFontScalingProviderProps {
|
|
|
33
42
|
* ```
|
|
34
43
|
*/
|
|
35
44
|
declare const UDSFontScalingProvider: _$react.NamedExoticComponent<UDSFontScalingProviderProps>;
|
|
45
|
+
interface ResolvedControlFontScalingProviderProps {
|
|
46
|
+
maxFontSizeMultiplier?: number;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/** Keeps custom UDS content inside a control on the control's resolved cap. */
|
|
50
|
+
declare const ResolvedControlFontScalingProvider: _$react.NamedExoticComponent<ResolvedControlFontScalingProviderProps>;
|
|
36
51
|
//#endregion
|
|
37
|
-
export { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };
|
|
52
|
+
export { FontScalingContext, ResolvedControlFontScalingProvider, UDSFontScalingProvider, type UDSFontScalingProviderProps, useDynamicTypeRampEnabled, useFontScalingEnabled };
|
|
38
53
|
//# sourceMappingURL=FontScalingContext.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontScalingContext.d.cts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"FontScalingContext.d.cts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;UAKU,uBAAA,SAAgC,iBAAA;;EAExC,sBAAA;AAAA;AAAA,cAII,kBAAA,EAAkB,OAAA,CAAA,OAAA,CAAA,uBAAA;;iBAGf,qBAAA,CAAA;;iBAKA,yBAAA,CAAA;AAAA,UAKC,2BAAA;;;;AAbc;;EAmBtB,MAAA,EAAQ,iBAAA;EACR,QAAA,EAAU,SAAA;AAAA;AAjBkB;;;;;AAKI;;;;;;;;;;AAYb;;;;AAjBS,cAuCxB,sBAAA,EAAsB,OAAA,CAAA,oBAAA,CAAA,2BAAA;AAAA,UASlB,uCAAA;EACR,qBAAA;EACA,QAAA,EAAU,SAAA;AAAA;;cAIN,kCAAA,EAAkC,OAAA,CAAA,oBAAA,CAAA,uCAAA"}
|
|
@@ -4,7 +4,15 @@ import * as _$react from "react";
|
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
|
|
6
6
|
//#region src/fontScaling/FontScalingContext.d.ts
|
|
7
|
-
|
|
7
|
+
interface FontScalingContextValue extends FontScalingConfig {
|
|
8
|
+
/** Internal: bounded controls use the global curve for text, icons, and geometry. */
|
|
9
|
+
disableDynamicTypeRamp?: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare const FontScalingContext: _$react.Context<FontScalingContextValue | undefined>;
|
|
12
|
+
/** Whether UDS-added caps, ramps, and scale-aware geometry are enabled. */
|
|
13
|
+
declare function useFontScalingEnabled(): boolean;
|
|
14
|
+
/** Whether Text should supply its variant's default iOS Dynamic Type ramp. */
|
|
15
|
+
declare function useDynamicTypeRampEnabled(): boolean;
|
|
8
16
|
interface UDSFontScalingProviderProps {
|
|
9
17
|
/**
|
|
10
18
|
* Font-scaling caps for the subtree. Should be identity-stable (a module
|
|
@@ -19,9 +27,10 @@ interface UDSFontScalingProviderProps {
|
|
|
19
27
|
*
|
|
20
28
|
* @description
|
|
21
29
|
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
22
|
-
* Without a provider, built-in defaults apply (
|
|
23
|
-
*
|
|
24
|
-
* once at the root via the
|
|
30
|
+
* Without a provider, built-in defaults apply (every text style is capped at
|
|
31
|
+
* 2x or below, with the largest display/title tiers tapered further, and
|
|
32
|
+
* control internals capped at 2x). Most apps set this once at the root via the
|
|
33
|
+
* `fontScaling` prop on `UDSGestureProvider`.
|
|
25
34
|
*
|
|
26
35
|
* @example
|
|
27
36
|
* ```tsx
|
|
@@ -33,6 +42,12 @@ interface UDSFontScalingProviderProps {
|
|
|
33
42
|
* ```
|
|
34
43
|
*/
|
|
35
44
|
declare const UDSFontScalingProvider: _$react.NamedExoticComponent<UDSFontScalingProviderProps>;
|
|
45
|
+
interface ResolvedControlFontScalingProviderProps {
|
|
46
|
+
maxFontSizeMultiplier?: number;
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
/** Keeps custom UDS content inside a control on the control's resolved cap. */
|
|
50
|
+
declare const ResolvedControlFontScalingProvider: _$react.NamedExoticComponent<ResolvedControlFontScalingProviderProps>;
|
|
36
51
|
//#endregion
|
|
37
|
-
export { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };
|
|
52
|
+
export { FontScalingContext, ResolvedControlFontScalingProvider, UDSFontScalingProvider, type UDSFontScalingProviderProps, useDynamicTypeRampEnabled, useFontScalingEnabled };
|
|
38
53
|
//# sourceMappingURL=FontScalingContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FontScalingContext.d.ts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"FontScalingContext.d.ts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;UAKU,uBAAA,SAAgC,iBAAA;;EAExC,sBAAA;AAAA;AAAA,cAII,kBAAA,EAAkB,OAAA,CAAA,OAAA,CAAA,uBAAA;;iBAGf,qBAAA,CAAA;;iBAKA,yBAAA,CAAA;AAAA,UAKC,2BAAA;;;;AAbc;;EAmBtB,MAAA,EAAQ,iBAAA;EACR,QAAA,EAAU,SAAA;AAAA;AAjBkB;;;;;AAKI;;;;;;;;;;AAYb;;;;AAjBS,cAuCxB,sBAAA,EAAsB,OAAA,CAAA,oBAAA,CAAA,2BAAA;AAAA,UASlB,uCAAA;EACR,qBAAA;EACA,QAAA,EAAU,SAAA;AAAA;;cAIN,kCAAA,EAAkC,OAAA,CAAA,oBAAA,CAAA,uCAAA"}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
import { createContext, memo } from "react";
|
|
2
|
+
import { createContext, memo, useContext, useMemo } from "react";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
//#region src/fontScaling/FontScalingContext.tsx
|
|
5
5
|
const FontScalingContext = createContext(void 0);
|
|
6
|
+
/** Whether UDS-added caps, ramps, and scale-aware geometry are enabled. */
|
|
7
|
+
function useFontScalingEnabled() {
|
|
8
|
+
return useContext(FontScalingContext)?.enabled !== false;
|
|
9
|
+
}
|
|
10
|
+
/** Whether Text should supply its variant's default iOS Dynamic Type ramp. */
|
|
11
|
+
function useDynamicTypeRampEnabled() {
|
|
12
|
+
const config = useContext(FontScalingContext);
|
|
13
|
+
return config?.enabled !== false && config?.disableDynamicTypeRamp !== true;
|
|
14
|
+
}
|
|
6
15
|
/**
|
|
7
16
|
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
8
17
|
*
|
|
9
18
|
* @description
|
|
10
19
|
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
11
|
-
* Without a provider, built-in defaults apply (
|
|
12
|
-
*
|
|
13
|
-
* once at the root via the
|
|
20
|
+
* Without a provider, built-in defaults apply (every text style is capped at
|
|
21
|
+
* 2x or below, with the largest display/title tiers tapered further, and
|
|
22
|
+
* control internals capped at 2x). Most apps set this once at the root via the
|
|
23
|
+
* `fontScaling` prop on `UDSGestureProvider`.
|
|
14
24
|
*
|
|
15
25
|
* @example
|
|
16
26
|
* ```tsx
|
|
@@ -28,7 +38,26 @@ const UDSFontScalingProvider = memo(function UDSFontScalingProvider({ config, ch
|
|
|
28
38
|
});
|
|
29
39
|
});
|
|
30
40
|
UDSFontScalingProvider.displayName = "UDSFontScalingProvider";
|
|
41
|
+
/** Keeps custom UDS content inside a control on the control's resolved cap. */
|
|
42
|
+
const ResolvedControlFontScalingProvider = memo(function ResolvedControlFontScalingProvider({ maxFontSizeMultiplier, children }) {
|
|
43
|
+
const parentConfig = useContext(FontScalingContext);
|
|
44
|
+
const cap = maxFontSizeMultiplier === 0 ? null : maxFontSizeMultiplier;
|
|
45
|
+
const config = useMemo(() => parentConfig?.enabled === false && maxFontSizeMultiplier === void 0 ? { enabled: false } : {
|
|
46
|
+
default: cap,
|
|
47
|
+
control: cap,
|
|
48
|
+
disableDynamicTypeRamp: true
|
|
49
|
+
}, [
|
|
50
|
+
cap,
|
|
51
|
+
maxFontSizeMultiplier,
|
|
52
|
+
parentConfig?.enabled
|
|
53
|
+
]);
|
|
54
|
+
return /* @__PURE__ */ jsx(FontScalingContext.Provider, {
|
|
55
|
+
value: config,
|
|
56
|
+
children
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
ResolvedControlFontScalingProvider.displayName = "ResolvedControlFontScalingProvider";
|
|
31
60
|
//#endregion
|
|
32
|
-
export { FontScalingContext, UDSFontScalingProvider };
|
|
61
|
+
export { FontScalingContext, ResolvedControlFontScalingProvider, UDSFontScalingProvider, useDynamicTypeRampEnabled, useFontScalingEnabled };
|
|
33
62
|
|
|
34
63
|
//# sourceMappingURL=FontScalingContext.js.map
|
|
@@ -1 +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<
|
|
1
|
+
{"version":3,"file":"FontScalingContext.js","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { createContext, memo, useContext, useMemo } from 'react';\n\nimport type { FontScalingConfig } from './types';\n\ninterface FontScalingContextValue extends FontScalingConfig {\n /** Internal: bounded controls use the global curve for text, icons, and geometry. */\n disableDynamicTypeRamp?: boolean;\n}\n\n// undefined = no provider mounted; built-in defaults apply.\nconst FontScalingContext = createContext<FontScalingContextValue | undefined>(undefined);\n\n/** Whether UDS-added caps, ramps, and scale-aware geometry are enabled. */\nfunction useFontScalingEnabled(): boolean {\n return useContext(FontScalingContext)?.enabled !== false;\n}\n\n/** Whether Text should supply its variant's default iOS Dynamic Type ramp. */\nfunction useDynamicTypeRampEnabled(): boolean {\n const config = useContext(FontScalingContext);\n return config?.enabled !== false && config?.disableDynamicTypeRamp !== true;\n}\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 (every text style is capped at\n * 2x or below, with the largest display/title tiers tapered further, and\n * control internals capped at 2x). Most apps set this once at the root via the\n * `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\ninterface ResolvedControlFontScalingProviderProps {\n maxFontSizeMultiplier?: number;\n children: ReactNode;\n}\n\n/** Keeps custom UDS content inside a control on the control's resolved cap. */\nconst ResolvedControlFontScalingProvider = memo(function ResolvedControlFontScalingProvider({\n maxFontSizeMultiplier,\n children,\n}: ResolvedControlFontScalingProviderProps) {\n const parentConfig = useContext(FontScalingContext);\n const cap = maxFontSizeMultiplier === 0 ? null : maxFontSizeMultiplier;\n const config = useMemo<FontScalingContextValue>(\n () =>\n parentConfig?.enabled === false && maxFontSizeMultiplier === undefined\n ? { enabled: false }\n : { default: cap, control: cap, disableDynamicTypeRamp: true },\n [cap, maxFontSizeMultiplier, parentConfig?.enabled],\n );\n\n return <FontScalingContext.Provider value={config}>{children}</FontScalingContext.Provider>;\n});\n\nResolvedControlFontScalingProvider.displayName = 'ResolvedControlFontScalingProvider';\n\nexport {\n FontScalingContext,\n ResolvedControlFontScalingProvider,\n UDSFontScalingProvider,\n useDynamicTypeRampEnabled,\n useFontScalingEnabled,\n};\nexport type { UDSFontScalingProviderProps };\n"],"mappings":";;;;AAWA,MAAM,qBAAqB,cAAmD,KAAA,EAAU;;AAGxF,SAAS,wBAAiC;CACxC,OAAO,WAAW,mBAAmB,EAAE,YAAY;;;AAIrD,SAAS,4BAAqC;CAC5C,MAAM,SAAS,WAAW,mBAAmB;CAC7C,OAAO,QAAQ,YAAY,SAAS,QAAQ,2BAA2B;;;;;;;;;;;;;;;;;;;;;AAgCzE,MAAM,yBAAyB,KAAK,SAAS,uBAAuB,EAClE,QACA,YAC8B;CAC9B,OAAO,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EAAS;EAAuC,CAAA;EAC3F;AAEF,uBAAuB,cAAc;;AAQrC,MAAM,qCAAqC,KAAK,SAAS,mCAAmC,EAC1F,uBACA,YAC0C;CAC1C,MAAM,eAAe,WAAW,mBAAmB;CACnD,MAAM,MAAM,0BAA0B,IAAI,OAAO;CACjD,MAAM,SAAS,cAEX,cAAc,YAAY,SAAS,0BAA0B,KAAA,IACzD,EAAE,SAAS,OAAO,GAClB;EAAE,SAAS;EAAK,SAAS;EAAK,wBAAwB;EAAM,EAClE;EAAC;EAAK;EAAuB,cAAc;EAAQ,CACpD;CAED,OAAO,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EAAS;EAAuC,CAAA;EAC3F;AAEF,mCAAmC,cAAc"}
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/fontScaling/androidNonlinearFontScaling.ts
|
|
4
|
+
/**
|
|
5
|
+
* Android 14+ converts SP through a size-dependent curve. `Configuration.fontScale`
|
|
6
|
+
* is only the user's preference; multiplying by it directly does not reproduce the
|
|
7
|
+
* size that native Text renders.
|
|
8
|
+
*
|
|
9
|
+
* These lookup tables mirror Android's `FontScaleConverterFactory`. Android 14
|
|
10
|
+
* shipped fewer preference curves than Android 15+, so callers must provide the
|
|
11
|
+
* platform version to select the same table native Text uses. Values between
|
|
12
|
+
* table entries are linearly interpolated, as they are in the platform implementation.
|
|
13
|
+
*
|
|
14
|
+
* @see https://android.googlesource.com/platform/frameworks/base/+/refs/heads/main/core/java/android/content/res/FontScaleConverterFactory.java
|
|
15
|
+
* @see https://android.googlesource.com/platform/prebuilts/fullsdk/sources/+/refs/heads/androidx-compose-integration-release/android-34/android/content/res/FontScaleConverterFactory.java
|
|
16
|
+
*/
|
|
17
|
+
const COMMON_SP_SIZES = [
|
|
18
|
+
8,
|
|
19
|
+
10,
|
|
20
|
+
12,
|
|
21
|
+
14,
|
|
22
|
+
18,
|
|
23
|
+
20,
|
|
24
|
+
24,
|
|
25
|
+
30,
|
|
26
|
+
100
|
|
27
|
+
];
|
|
28
|
+
const ANDROID_14_FONT_SCALE_CURVES = [
|
|
29
|
+
{
|
|
30
|
+
scale: 1.15,
|
|
31
|
+
dp: [
|
|
32
|
+
9.2,
|
|
33
|
+
11.5,
|
|
34
|
+
13.8,
|
|
35
|
+
16.4,
|
|
36
|
+
19.8,
|
|
37
|
+
21.8,
|
|
38
|
+
25.2,
|
|
39
|
+
30,
|
|
40
|
+
100
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
scale: 1.3,
|
|
45
|
+
dp: [
|
|
46
|
+
10.4,
|
|
47
|
+
13,
|
|
48
|
+
15.6,
|
|
49
|
+
18.8,
|
|
50
|
+
21.6,
|
|
51
|
+
23.6,
|
|
52
|
+
26.4,
|
|
53
|
+
30,
|
|
54
|
+
100
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
scale: 1.5,
|
|
59
|
+
dp: [
|
|
60
|
+
12,
|
|
61
|
+
15,
|
|
62
|
+
18,
|
|
63
|
+
22,
|
|
64
|
+
24,
|
|
65
|
+
26,
|
|
66
|
+
28,
|
|
67
|
+
30,
|
|
68
|
+
100
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
scale: 1.8,
|
|
73
|
+
dp: [
|
|
74
|
+
14.4,
|
|
75
|
+
18,
|
|
76
|
+
21.6,
|
|
77
|
+
24.4,
|
|
78
|
+
27.6,
|
|
79
|
+
30.8,
|
|
80
|
+
32.8,
|
|
81
|
+
34.8,
|
|
82
|
+
100
|
|
83
|
+
]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
scale: 2,
|
|
87
|
+
dp: [
|
|
88
|
+
16,
|
|
89
|
+
20,
|
|
90
|
+
24,
|
|
91
|
+
26,
|
|
92
|
+
30,
|
|
93
|
+
34,
|
|
94
|
+
36,
|
|
95
|
+
38,
|
|
96
|
+
100
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
const ANDROID_15_FONT_SCALE_CURVES = [
|
|
101
|
+
{
|
|
102
|
+
scale: 1.05,
|
|
103
|
+
dp: [
|
|
104
|
+
8.4,
|
|
105
|
+
10.5,
|
|
106
|
+
12.6,
|
|
107
|
+
14.8,
|
|
108
|
+
18.6,
|
|
109
|
+
20.6,
|
|
110
|
+
24.4,
|
|
111
|
+
30,
|
|
112
|
+
100
|
|
113
|
+
]
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
scale: 1.1,
|
|
117
|
+
dp: [
|
|
118
|
+
8.8,
|
|
119
|
+
11,
|
|
120
|
+
13.2,
|
|
121
|
+
15.6,
|
|
122
|
+
19.2,
|
|
123
|
+
21.2,
|
|
124
|
+
24.8,
|
|
125
|
+
30,
|
|
126
|
+
100
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
scale: 1.15,
|
|
131
|
+
dp: [
|
|
132
|
+
9.2,
|
|
133
|
+
11.5,
|
|
134
|
+
13.8,
|
|
135
|
+
16.4,
|
|
136
|
+
19.8,
|
|
137
|
+
21.8,
|
|
138
|
+
25.2,
|
|
139
|
+
30,
|
|
140
|
+
100
|
|
141
|
+
]
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
scale: 1.2,
|
|
145
|
+
dp: [
|
|
146
|
+
9.6,
|
|
147
|
+
12,
|
|
148
|
+
14.4,
|
|
149
|
+
17.2,
|
|
150
|
+
20.4,
|
|
151
|
+
22.4,
|
|
152
|
+
25.6,
|
|
153
|
+
30,
|
|
154
|
+
100
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
scale: 1.3,
|
|
159
|
+
dp: [
|
|
160
|
+
10.4,
|
|
161
|
+
13,
|
|
162
|
+
15.6,
|
|
163
|
+
18.8,
|
|
164
|
+
21.6,
|
|
165
|
+
23.6,
|
|
166
|
+
26.4,
|
|
167
|
+
30,
|
|
168
|
+
100
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
scale: 1.5,
|
|
173
|
+
dp: [
|
|
174
|
+
12,
|
|
175
|
+
15,
|
|
176
|
+
18,
|
|
177
|
+
22,
|
|
178
|
+
24,
|
|
179
|
+
26,
|
|
180
|
+
28,
|
|
181
|
+
30,
|
|
182
|
+
100
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
scale: 1.8,
|
|
187
|
+
dp: [
|
|
188
|
+
14.4,
|
|
189
|
+
18,
|
|
190
|
+
21.6,
|
|
191
|
+
24.4,
|
|
192
|
+
27.6,
|
|
193
|
+
30.8,
|
|
194
|
+
32.8,
|
|
195
|
+
34.8,
|
|
196
|
+
100
|
|
197
|
+
]
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
scale: 2,
|
|
201
|
+
dp: [
|
|
202
|
+
16,
|
|
203
|
+
20,
|
|
204
|
+
24,
|
|
205
|
+
26,
|
|
206
|
+
30,
|
|
207
|
+
34,
|
|
208
|
+
36,
|
|
209
|
+
38,
|
|
210
|
+
100
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
];
|
|
214
|
+
function lerp(start, end, amount) {
|
|
215
|
+
return start + (end - start) * amount;
|
|
216
|
+
}
|
|
217
|
+
function interpolateSize(fontSize, dpValues) {
|
|
218
|
+
if (fontSize <= 0) return fontSize;
|
|
219
|
+
for (let index = 0; index < COMMON_SP_SIZES.length; index += 1) {
|
|
220
|
+
const currentSp = COMMON_SP_SIZES[index];
|
|
221
|
+
if (fontSize === currentSp) return dpValues[index];
|
|
222
|
+
if (fontSize < currentSp) {
|
|
223
|
+
const previousSp = index === 0 ? 0 : COMMON_SP_SIZES[index - 1];
|
|
224
|
+
const previousDp = index === 0 ? 0 : dpValues[index - 1];
|
|
225
|
+
const amount = (fontSize - previousSp) / (currentSp - previousSp);
|
|
226
|
+
return lerp(previousDp, dpValues[index], amount);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const lastIndex = COMMON_SP_SIZES.length - 1;
|
|
230
|
+
return fontSize * (dpValues[lastIndex] / COMMON_SP_SIZES[lastIndex]);
|
|
231
|
+
}
|
|
232
|
+
/** Converts an SP value to the nonlinear DP size used by this Android API level. */
|
|
233
|
+
function convertAndroidSpToDp(fontSize, fontScale, platformVersion = 35) {
|
|
234
|
+
const curves = platformVersion === 34 ? ANDROID_14_FONT_SCALE_CURVES : ANDROID_15_FONT_SCALE_CURVES;
|
|
235
|
+
const firstCurve = curves[0];
|
|
236
|
+
const lastCurve = curves[curves.length - 1];
|
|
237
|
+
if (fontScale < firstCurve.scale || fontScale > lastCurve.scale) return fontSize * fontScale;
|
|
238
|
+
for (let index = 0; index < curves.length; index += 1) {
|
|
239
|
+
const curve = curves[index];
|
|
240
|
+
if (fontScale === curve.scale) return interpolateSize(fontSize, curve.dp);
|
|
241
|
+
if (fontScale < curve.scale) {
|
|
242
|
+
const previousCurve = curves[index - 1];
|
|
243
|
+
const amount = (fontScale - previousCurve.scale) / (curve.scale - previousCurve.scale);
|
|
244
|
+
return lerp(interpolateSize(fontSize, previousCurve.dp), interpolateSize(fontSize, curve.dp), amount);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return fontSize * fontScale;
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
exports.convertAndroidSpToDp = convertAndroidSpToDp;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/fontScaling/androidNonlinearFontScaling.d.ts
|
|
3
|
+
/** Converts an SP value to the nonlinear DP size used by this Android API level. */
|
|
4
|
+
declare function convertAndroidSpToDp(fontSize: number, fontScale: number, platformVersion?: number): number;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { convertAndroidSpToDp };
|
|
7
|
+
//# sourceMappingURL=androidNonlinearFontScaling.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"androidNonlinearFontScaling.d.cts","names":[],"sources":["../../src/fontScaling/androidNonlinearFontScaling.ts"],"mappings":";;;iBA8DS,oBAAA,CACP,QAAA,UACA,SAAA,UACA,eAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/fontScaling/androidNonlinearFontScaling.d.ts
|
|
3
|
+
/** Converts an SP value to the nonlinear DP size used by this Android API level. */
|
|
4
|
+
declare function convertAndroidSpToDp(fontSize: number, fontScale: number, platformVersion?: number): number;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { convertAndroidSpToDp };
|
|
7
|
+
//# sourceMappingURL=androidNonlinearFontScaling.d.ts.map
|