@yahoo/uds-mobile 2.24.0-beta.7 → 2.24.0-beta.8

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.
Files changed (108) hide show
  1. package/README.md +2 -1
  2. package/dist/components/Avatar/AvatarIcon.cjs +1 -1
  3. package/dist/components/Avatar/AvatarIcon.js +1 -1
  4. package/dist/components/Avatar/AvatarIcon.js.map +1 -1
  5. package/dist/components/Avatar/AvatarImage.cjs +1 -1
  6. package/dist/components/Avatar/AvatarImage.js +1 -1
  7. package/dist/components/Avatar/AvatarImage.js.map +1 -1
  8. package/dist/components/Avatar/AvatarText.cjs +1 -1
  9. package/dist/components/Avatar/AvatarText.js +1 -1
  10. package/dist/components/Avatar/AvatarText.js.map +1 -1
  11. package/dist/components/Avatar/useAvatarFontScale.d.cts +1 -1
  12. package/dist/components/Avatar/useAvatarFontScale.d.ts +1 -1
  13. package/dist/components/Avatar/useAvatarFontScale.js.map +1 -1
  14. package/dist/components/Button/buttonTheme.cjs +6 -1
  15. package/dist/components/Button/buttonTheme.d.cts +3 -1
  16. package/dist/components/Button/buttonTheme.d.cts.map +1 -1
  17. package/dist/components/Button/buttonTheme.d.ts +3 -1
  18. package/dist/components/Button/buttonTheme.d.ts.map +1 -1
  19. package/dist/components/Button/buttonTheme.js +6 -2
  20. package/dist/components/Button/buttonTheme.js.map +1 -1
  21. package/dist/components/Button.cjs +1 -1
  22. package/dist/components/Button.js +1 -1
  23. package/dist/components/Button.js.map +1 -1
  24. package/dist/components/Checkbox.cjs +11 -5
  25. package/dist/components/Checkbox.d.cts.map +1 -1
  26. package/dist/components/Checkbox.d.ts.map +1 -1
  27. package/dist/components/Checkbox.js +11 -5
  28. package/dist/components/Checkbox.js.map +1 -1
  29. package/dist/components/Chip/ChipBase.cjs +1 -1
  30. package/dist/components/Chip/ChipBase.js +1 -1
  31. package/dist/components/Chip/ChipBase.js.map +1 -1
  32. package/dist/components/Icon.cjs +2 -2
  33. package/dist/components/Icon.js +2 -2
  34. package/dist/components/Icon.js.map +1 -1
  35. package/dist/components/IconButton.cjs +17 -6
  36. package/dist/components/IconButton.d.cts +6 -0
  37. package/dist/components/IconButton.d.cts.map +1 -1
  38. package/dist/components/IconButton.d.ts +6 -0
  39. package/dist/components/IconButton.d.ts.map +1 -1
  40. package/dist/components/IconButton.js +18 -7
  41. package/dist/components/IconButton.js.map +1 -1
  42. package/dist/components/Input.cjs +1 -1
  43. package/dist/components/Input.js +1 -1
  44. package/dist/components/Input.js.map +1 -1
  45. package/dist/components/InputHelpText.cjs +1 -1
  46. package/dist/components/InputHelpText.js +1 -1
  47. package/dist/components/InputHelpText.js.map +1 -1
  48. package/dist/components/Link.cjs +3 -1
  49. package/dist/components/Link.d.cts.map +1 -1
  50. package/dist/components/Link.d.ts.map +1 -1
  51. package/dist/components/Link.js +3 -1
  52. package/dist/components/Link.js.map +1 -1
  53. package/dist/components/Pagination/Pagination.cjs +1 -1
  54. package/dist/components/Pagination/Pagination.js +1 -1
  55. package/dist/components/Pagination/Pagination.js.map +1 -1
  56. package/dist/components/Pagination/paginationContext.d.cts +2 -2
  57. package/dist/components/Pagination/paginationContext.d.ts +2 -2
  58. package/dist/components/Pagination/paginationContext.js.map +1 -1
  59. package/dist/components/Radio/Radio.cjs +1 -1
  60. package/dist/components/Radio/Radio.js +1 -1
  61. package/dist/components/Radio/Radio.js.map +1 -1
  62. package/dist/components/Select/Select.cjs +1 -1
  63. package/dist/components/Select/Select.js +1 -1
  64. package/dist/components/Select/Select.js.map +1 -1
  65. package/dist/components/Select/SelectItem.cjs +3 -1
  66. package/dist/components/Select/SelectItem.d.cts.map +1 -1
  67. package/dist/components/Select/SelectItem.d.ts.map +1 -1
  68. package/dist/components/Select/SelectItem.js +3 -1
  69. package/dist/components/Select/SelectItem.js.map +1 -1
  70. package/dist/components/Select/SelectTrigger.cjs +3 -1
  71. package/dist/components/Select/SelectTrigger.d.cts.map +1 -1
  72. package/dist/components/Select/SelectTrigger.d.ts.map +1 -1
  73. package/dist/components/Select/SelectTrigger.js +3 -1
  74. package/dist/components/Select/SelectTrigger.js.map +1 -1
  75. package/dist/components/Select/types.d.cts +1 -1
  76. package/dist/components/Select/types.d.ts +1 -1
  77. package/dist/components/Switch.cjs +18 -3
  78. package/dist/components/Switch.d.cts.map +1 -1
  79. package/dist/components/Switch.d.ts.map +1 -1
  80. package/dist/components/Switch.js +18 -3
  81. package/dist/components/Switch.js.map +1 -1
  82. package/dist/components/Tabs/Tab.cjs +1 -1
  83. package/dist/components/Tabs/Tab.js +1 -1
  84. package/dist/components/Tabs/Tab.js.map +1 -1
  85. package/dist/components/Text.cjs +2 -1
  86. package/dist/components/Text.d.cts.map +1 -1
  87. package/dist/components/Text.d.ts.map +1 -1
  88. package/dist/components/Text.js +2 -1
  89. package/dist/components/Text.js.map +1 -1
  90. package/dist/fontScaling/FontScalingContext.cjs +8 -2
  91. package/dist/fontScaling/FontScalingContext.d.cts +4 -2
  92. package/dist/fontScaling/FontScalingContext.d.cts.map +1 -1
  93. package/dist/fontScaling/FontScalingContext.d.ts +4 -2
  94. package/dist/fontScaling/FontScalingContext.d.ts.map +1 -1
  95. package/dist/fontScaling/FontScalingContext.js +9 -4
  96. package/dist/fontScaling/FontScalingContext.js.map +1 -1
  97. package/dist/fontScaling/types.d.cts +8 -7
  98. package/dist/fontScaling/types.d.cts.map +1 -1
  99. package/dist/fontScaling/types.d.ts +8 -7
  100. package/dist/fontScaling/types.d.ts.map +1 -1
  101. package/dist/fontScaling/useFontScale.cjs +4 -0
  102. package/dist/fontScaling/useFontScale.d.cts +1 -0
  103. package/dist/fontScaling/useFontScale.d.cts.map +1 -1
  104. package/dist/fontScaling/useFontScale.d.ts +1 -0
  105. package/dist/fontScaling/useFontScale.d.ts.map +1 -1
  106. package/dist/fontScaling/useFontScale.js +4 -0
  107. package/dist/fontScaling/useFontScale.js.map +1 -1
  108. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"FontScalingContext.js","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { createContext, memo, useMemo } 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 (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 cap = maxFontSizeMultiplier === 0 ? null : maxFontSizeMultiplier;\n const config = useMemo<FontScalingConfig>(() => ({ default: cap, control: cap }), [cap]);\n\n return <FontScalingContext.Provider value={config}>{children}</FontScalingContext.Provider>;\n});\n\nResolvedControlFontScalingProvider.displayName = 'ResolvedControlFontScalingProvider';\n\nexport {\n FontScalingContext,\n ResolvedControlFontScalingProvider,\n UDSFontScalingProvider,\n type UDSFontScalingProviderProps,\n};\n"],"mappings":";;;;AAMA,MAAM,qBAAqB,cAA6C,KAAA,EAAU;;;;;;;;;;;;;;;;;;;;AA+BlF,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,MAAM,0BAA0B,IAAI,OAAO;CACjD,MAAM,SAAS,eAAkC;EAAE,SAAS;EAAK,SAAS;EAAK,GAAG,CAAC,IAAI,CAAC;CAExF,OAAO,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EAAS;EAAuC,CAAA;EAC3F;AAEF,mCAAmC,cAAc"}
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\n// undefined = no provider mounted; built-in defaults apply.\nconst FontScalingContext = createContext<FontScalingConfig | 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\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<FontScalingConfig>(\n () => (parentConfig?.enabled === false ? { enabled: false } : { default: cap, control: cap }),\n [cap, 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 useFontScalingEnabled,\n};\nexport type { UDSFontScalingProviderProps };\n"],"mappings":";;;;AAMA,MAAM,qBAAqB,cAA6C,KAAA,EAAU;;AAGlF,SAAS,wBAAiC;CACxC,OAAO,WAAW,mBAAmB,EAAE,YAAY;;;;;;;;;;;;;;;;;;;;;AAgCrD,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,cACN,cAAc,YAAY,QAAQ,EAAE,SAAS,OAAO,GAAG;EAAE,SAAS;EAAK,SAAS;EAAK,EAC5F,CAAC,KAAK,cAAc,QAAQ,CAC7B;CAED,OAAO,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EAAS;EAAuC,CAAA;EAC3F;AAEF,mCAAmC,cAAc"}
@@ -21,9 +21,10 @@ type FontScalingCapValue = number | null;
21
21
  */
22
22
  interface FontScalingConfig {
23
23
  /**
24
- * Master switch for UDS-applied caps. When `false`, no caps are applied
25
- * anywhere and text follows native OS scaling. Container-metric fixes
26
- * (Button/Checkbox growing to fit scaled text) remain active.
24
+ * Master switch for UDS-added font-scaling behavior. When `false`, native
25
+ * text keeps its pre-feature scaling behavior while UDS caps, Dynamic Type
26
+ * ramps, multicolor-icon scaling, and scale-aware geometry are disabled.
27
+ * Explicit component and native text props still apply.
27
28
  * @default true
28
29
  */
29
30
  enabled?: boolean;
@@ -35,10 +36,10 @@ interface FontScalingConfig {
35
36
  */
36
37
  default?: FontScalingCapValue;
37
38
  /**
38
- * Cap for control-internal text, icons, and geometry in Button, Checkbox,
39
- * Radio, Switch, Chip, Tabs, Input, Select, Avatar, and Pagination, plus
40
- * standalone `Icon` glyphs and multicolor SVGs. Link resolves through its
41
- * typography variant instead of the control cap.
39
+ * Cap for control-internal text, icons, and geometry in Button, IconButton,
40
+ * Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, and Pagination,
41
+ * plus standalone `Icon` glyphs and multicolor SVGs. Link resolves through
42
+ * its typography variant instead of the control cap.
42
43
  * @default 2
43
44
  */
44
45
  control?: FontScalingCapValue;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAOR;;;;;;EAAA,OAAA;EAoBmB;;;;;;EAbnB,OAAA,GAAU,mBAAA;;;;;;;;EAQV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAQR;;;;;;;EAAA,OAAA;EAoB0B;;;;;;EAb1B,OAAA,GAAU,mBAAA;;;;;;;;EAQV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
@@ -21,9 +21,10 @@ type FontScalingCapValue = number | null;
21
21
  */
22
22
  interface FontScalingConfig {
23
23
  /**
24
- * Master switch for UDS-applied caps. When `false`, no caps are applied
25
- * anywhere and text follows native OS scaling. Container-metric fixes
26
- * (Button/Checkbox growing to fit scaled text) remain active.
24
+ * Master switch for UDS-added font-scaling behavior. When `false`, native
25
+ * text keeps its pre-feature scaling behavior while UDS caps, Dynamic Type
26
+ * ramps, multicolor-icon scaling, and scale-aware geometry are disabled.
27
+ * Explicit component and native text props still apply.
27
28
  * @default true
28
29
  */
29
30
  enabled?: boolean;
@@ -35,10 +36,10 @@ interface FontScalingConfig {
35
36
  */
36
37
  default?: FontScalingCapValue;
37
38
  /**
38
- * Cap for control-internal text, icons, and geometry in Button, Checkbox,
39
- * Radio, Switch, Chip, Tabs, Input, Select, Avatar, and Pagination, plus
40
- * standalone `Icon` glyphs and multicolor SVGs. Link resolves through its
41
- * typography variant instead of the control cap.
39
+ * Cap for control-internal text, icons, and geometry in Button, IconButton,
40
+ * Checkbox, Radio, Switch, Chip, Tabs, Input, Select, Avatar, and Pagination,
41
+ * plus standalone `Icon` glyphs and multicolor SVGs. Link resolves through
42
+ * its typography variant instead of the control cap.
42
43
  * @default 2
43
44
  */
44
45
  control?: FontScalingCapValue;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAOR;;;;;;EAAA,OAAA;EAoBmB;;;;;;EAbnB,OAAA,GAAU,mBAAA;;;;;;;;EAQV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/fontScaling/types.ts"],"mappings":";;;;;;AAAsD;;;;KAQjD,mBAAA;AAAmB;;;;;;;;;;AAAA,UAYd,iBAAA;EAQR;;;;;;;EAAA,OAAA;EAoB0B;;;;;;EAb1B,OAAA,GAAU,mBAAA;;;;;;;;EAQV,OAAA,GAAU,mBAAA;;;;;EAKV,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;AAAA"}
@@ -1,6 +1,7 @@
1
1
  /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  require("../_virtual/_rolldown/runtime.cjs");
4
+ const require_fontScaling_FontScalingContext = require("./FontScalingContext.cjs");
4
5
  const require_fontScaling_androidNonlinearFontScaling = require("./androidNonlinearFontScaling.cjs");
5
6
  let react = require("react");
6
7
  let react_native = require("react-native");
@@ -28,9 +29,12 @@ function getFontScale() {
28
29
  *
29
30
  * Subscribes to font-scale changes only — rotation does not re-render, and
30
31
  * components re-render solely when the user changes the OS text size.
32
+ * Returns 1 when the nearest font-scaling provider has `enabled: false`.
31
33
  */
32
34
  function useFontScale(cap, fontSize) {
35
+ const enabled = require_fontScaling_FontScalingContext.useFontScalingEnabled();
33
36
  const fontScale = (0, react.useSyncExternalStore)(subscribe, getFontScale, getFontScale);
37
+ if (!enabled) return 1;
34
38
  const effectiveCap = typeof cap === "number" && cap >= 1 ? cap : Number.POSITIVE_INFINITY;
35
39
  const cappedFontScale = Math.min(fontScale, effectiveCap);
36
40
  const platformVersion = Number(react_native.Platform.Version);
@@ -16,6 +16,7 @@
16
16
  *
17
17
  * Subscribes to font-scale changes only — rotation does not re-render, and
18
18
  * components re-render solely when the user changes the OS text size.
19
+ * Returns 1 when the nearest font-scaling provider has `enabled: false`.
19
20
  */
20
21
  declare function useFontScale(cap?: number | null, fontSize?: number): number;
21
22
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useFontScale.d.cts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBAiCS,YAAA,CAAa,GAAA,kBAAqB,QAAA"}
1
+ {"version":3,"file":"useFontScale.d.cts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAmCS,YAAA,CAAa,GAAA,kBAAqB,QAAA"}
@@ -16,6 +16,7 @@
16
16
  *
17
17
  * Subscribes to font-scale changes only — rotation does not re-render, and
18
18
  * components re-render solely when the user changes the OS text size.
19
+ * Returns 1 when the nearest font-scaling provider has `enabled: false`.
19
20
  */
20
21
  declare function useFontScale(cap?: number | null, fontSize?: number): number;
21
22
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"useFontScale.d.ts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;;;;;;iBAiCS,YAAA,CAAa,GAAA,kBAAqB,QAAA"}
1
+ {"version":3,"file":"useFontScale.d.ts","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;iBAmCS,YAAA,CAAa,GAAA,kBAAqB,QAAA"}
@@ -1,4 +1,5 @@
1
1
  /*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
2
+ import { useFontScalingEnabled } from "./FontScalingContext.js";
2
3
  import { convertAndroidSpToDp } from "./androidNonlinearFontScaling.js";
3
4
  import { useSyncExternalStore } from "react";
4
5
  import { Dimensions, Platform } from "react-native";
@@ -26,9 +27,12 @@ function getFontScale() {
26
27
  *
27
28
  * Subscribes to font-scale changes only — rotation does not re-render, and
28
29
  * components re-render solely when the user changes the OS text size.
30
+ * Returns 1 when the nearest font-scaling provider has `enabled: false`.
29
31
  */
30
32
  function useFontScale(cap, fontSize) {
33
+ const enabled = useFontScalingEnabled();
31
34
  const fontScale = useSyncExternalStore(subscribe, getFontScale, getFontScale);
35
+ if (!enabled) return 1;
32
36
  const effectiveCap = typeof cap === "number" && cap >= 1 ? cap : Number.POSITIVE_INFINITY;
33
37
  const cappedFontScale = Math.min(fontScale, effectiveCap);
34
38
  const platformVersion = Number(Platform.Version);
@@ -1 +1 @@
1
- {"version":3,"file":"useFontScale.js","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport { Dimensions, Platform } from 'react-native';\n\nimport { convertAndroidSpToDp } from './androidNonlinearFontScaling';\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const subscription = Dimensions.addEventListener('change', onStoreChange);\n return () => subscription.remove();\n}\n\n// Unistyles' rt.fontScale is stale when the OS text size changes while the\n// app is running; Dimensions reflects the live value on both platforms.\nfunction getFontScale(): number {\n return Dimensions.get('window').fontScale;\n}\n\n/**\n * The effective scale for `fontSize`, clamped to `[1, cap]`, for sizing\n * containers around scaled text (e.g. a checkbox box growing with its\n * checkmark).\n *\n * `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1\n * caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result\n * is never below 1 so containers never shrink under their token metrics\n * (font scales < 1 shrink text only, as today).\n *\n * Pass the SP size that the geometry accompanies on Android so this mirrors\n * Android 14+'s nonlinear scaling. Omitting `fontSize` preserves the legacy\n * scalar behavior for custom callers that do not know their base size.\n *\n * Subscribes to font-scale changes only — rotation does not re-render, and\n * components re-render solely when the user changes the OS text size.\n */\nfunction useFontScale(cap?: number | null, fontSize?: number): number {\n const fontScale = useSyncExternalStore(subscribe, getFontScale, getFontScale);\n const effectiveCap = typeof cap === 'number' && cap >= 1 ? cap : Number.POSITIVE_INFINITY;\n const cappedFontScale = Math.min(fontScale, effectiveCap);\n const platformVersion = Number(Platform.Version);\n const nativeScale =\n Platform.OS === 'android' &&\n platformVersion >= 34 &&\n typeof fontSize === 'number' &&\n fontSize > 0\n ? convertAndroidSpToDp(fontSize, cappedFontScale) / fontSize\n : cappedFontScale;\n\n return Math.max(1, nativeScale);\n}\n\nexport { useFontScale };\n"],"mappings":";;;;;AAKA,SAAS,UAAU,eAAuC;CACxD,MAAM,eAAe,WAAW,iBAAiB,UAAU,cAAc;CACzE,aAAa,aAAa,QAAQ;;AAKpC,SAAS,eAAuB;CAC9B,OAAO,WAAW,IAAI,SAAS,CAAC;;;;;;;;;;;;;;;;;;;AAoBlC,SAAS,aAAa,KAAqB,UAA2B;CACpE,MAAM,YAAY,qBAAqB,WAAW,cAAc,aAAa;CAC7E,MAAM,eAAe,OAAO,QAAQ,YAAY,OAAO,IAAI,MAAM,OAAO;CACxE,MAAM,kBAAkB,KAAK,IAAI,WAAW,aAAa;CACzD,MAAM,kBAAkB,OAAO,SAAS,QAAQ;CAChD,MAAM,cACJ,SAAS,OAAO,aAChB,mBAAmB,MACnB,OAAO,aAAa,YACpB,WAAW,IACP,qBAAqB,UAAU,gBAAgB,GAAG,WAClD;CAEN,OAAO,KAAK,IAAI,GAAG,YAAY"}
1
+ {"version":3,"file":"useFontScale.js","names":[],"sources":["../../src/fontScaling/useFontScale.ts"],"sourcesContent":["import { useSyncExternalStore } from 'react';\nimport { Dimensions, Platform } from 'react-native';\n\nimport { convertAndroidSpToDp } from './androidNonlinearFontScaling';\nimport { useFontScalingEnabled } from './FontScalingContext';\n\nfunction subscribe(onStoreChange: () => void): () => void {\n const subscription = Dimensions.addEventListener('change', onStoreChange);\n return () => subscription.remove();\n}\n\n// Unistyles' rt.fontScale is stale when the OS text size changes while the\n// app is running; Dimensions reflects the live value on both platforms.\nfunction getFontScale(): number {\n return Dimensions.get('window').fontScale;\n}\n\n/**\n * The effective scale for `fontSize`, clamped to `[1, cap]`, for sizing\n * containers around scaled text (e.g. a checkbox box growing with its\n * checkmark).\n *\n * `cap` uses the same semantics as `maxFontSizeMultiplier`: a number >= 1\n * caps the scale; `null`, `0`, or `undefined` leave it uncapped. The result\n * is never below 1 so containers never shrink under their token metrics\n * (font scales < 1 shrink text only, as today).\n *\n * Pass the SP size that the geometry accompanies on Android so this mirrors\n * Android 14+'s nonlinear scaling. Omitting `fontSize` preserves the legacy\n * scalar behavior for custom callers that do not know their base size.\n *\n * Subscribes to font-scale changes only — rotation does not re-render, and\n * components re-render solely when the user changes the OS text size.\n * Returns 1 when the nearest font-scaling provider has `enabled: false`.\n */\nfunction useFontScale(cap?: number | null, fontSize?: number): number {\n const enabled = useFontScalingEnabled();\n const fontScale = useSyncExternalStore(subscribe, getFontScale, getFontScale);\n if (!enabled) {\n return 1;\n }\n\n const effectiveCap = typeof cap === 'number' && cap >= 1 ? cap : Number.POSITIVE_INFINITY;\n const cappedFontScale = Math.min(fontScale, effectiveCap);\n const platformVersion = Number(Platform.Version);\n const nativeScale =\n Platform.OS === 'android' &&\n platformVersion >= 34 &&\n typeof fontSize === 'number' &&\n fontSize > 0\n ? convertAndroidSpToDp(fontSize, cappedFontScale) / fontSize\n : cappedFontScale;\n\n return Math.max(1, nativeScale);\n}\n\nexport { useFontScale };\n"],"mappings":";;;;;;AAMA,SAAS,UAAU,eAAuC;CACxD,MAAM,eAAe,WAAW,iBAAiB,UAAU,cAAc;CACzE,aAAa,aAAa,QAAQ;;AAKpC,SAAS,eAAuB;CAC9B,OAAO,WAAW,IAAI,SAAS,CAAC;;;;;;;;;;;;;;;;;;;;AAqBlC,SAAS,aAAa,KAAqB,UAA2B;CACpE,MAAM,UAAU,uBAAuB;CACvC,MAAM,YAAY,qBAAqB,WAAW,cAAc,aAAa;CAC7E,IAAI,CAAC,SACH,OAAO;CAGT,MAAM,eAAe,OAAO,QAAQ,YAAY,OAAO,IAAI,MAAM,OAAO;CACxE,MAAM,kBAAkB,KAAK,IAAI,WAAW,aAAa;CACzD,MAAM,kBAAkB,OAAO,SAAS,QAAQ;CAChD,MAAM,cACJ,SAAS,OAAO,aAChB,mBAAmB,MACnB,OAAO,aAAa,YACpB,WAAW,IACP,qBAAqB,UAAU,gBAAgB,GAAG,WAClD;CAEN,OAAO,KAAK,IAAI,GAAG,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahoo/uds-mobile",
3
- "version": "2.24.0-beta.7",
3
+ "version": "2.24.0-beta.8",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "uds-mobile": "./cli/uds-mobile.js"