@yahoo/uds-mobile 2.23.2 → 2.24.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -12
- package/dist/bin/automated-config/dist/generated/generatedConfigs.mjs +92 -46
- package/dist/components/Button/buttonTheme.cjs +63 -23
- package/dist/components/Button/buttonTheme.d.cts +29 -12
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +29 -12
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +62 -23
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +34 -13
- package/dist/components/Button.d.cts +7 -0
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.ts +7 -0
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +34 -13
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +30 -7
- package/dist/components/Checkbox.d.cts +7 -0
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.ts +7 -0
- package/dist/components/Checkbox.d.ts.map +1 -1
- package/dist/components/Checkbox.js +30 -7
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +23 -9
- package/dist/components/Chip/ChipBase.d.cts.map +1 -1
- package/dist/components/Chip/ChipBase.d.ts.map +1 -1
- package/dist/components/Chip/ChipBase.js +23 -9
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Chip/ChipDismissible.cjs +3 -1
- package/dist/components/Chip/ChipDismissible.js +3 -1
- package/dist/components/Chip/ChipDismissible.js.map +1 -1
- package/dist/components/Chip/types.d.cts +7 -0
- package/dist/components/Chip/types.d.cts.map +1 -1
- package/dist/components/Chip/types.d.ts +7 -0
- package/dist/components/Chip/types.d.ts.map +1 -1
- package/dist/components/Icon.cjs +7 -3
- package/dist/components/Icon.d.cts +9 -1
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts +9 -1
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +7 -3
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.cjs +18 -8
- package/dist/components/IconButton.js +18 -8
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/Radio/Radio.cjs +29 -11
- package/dist/components/Radio/Radio.d.cts +7 -0
- package/dist/components/Radio/Radio.d.cts.map +1 -1
- package/dist/components/Radio/Radio.d.ts +7 -0
- package/dist/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Radio/Radio.js +29 -11
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Switch.cjs +25 -2
- package/dist/components/Switch.d.cts +7 -0
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts +7 -0
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +25 -2
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +12 -2
- package/dist/components/Tabs/Tab.d.cts.map +1 -1
- package/dist/components/Tabs/Tab.d.ts.map +1 -1
- package/dist/components/Tabs/Tab.js +12 -2
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs +8 -3
- package/dist/components/Tabs/Tabs.d.cts +9 -1
- package/dist/components/Tabs/Tabs.d.cts.map +1 -1
- package/dist/components/Tabs/Tabs.d.ts +9 -1
- package/dist/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/components/Tabs/Tabs.js +8 -3
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/tabsContexts.d.cts +2 -0
- package/dist/components/Tabs/tabsContexts.d.cts.map +1 -1
- package/dist/components/Tabs/tabsContexts.d.ts +2 -0
- package/dist/components/Tabs/tabsContexts.d.ts.map +1 -1
- package/dist/components/Tabs/tabsContexts.js.map +1 -1
- package/dist/components/Text.cjs +4 -1
- package/dist/components/Text.d.cts +10 -2
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts +10 -2
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +4 -1
- package/dist/components/Text.js.map +1 -1
- package/dist/components/UDSProvider.cjs +6 -2
- package/dist/components/UDSProvider.d.cts +8 -0
- package/dist/components/UDSProvider.d.cts.map +1 -1
- package/dist/components/UDSProvider.d.ts +8 -0
- package/dist/components/UDSProvider.d.ts.map +1 -1
- package/dist/components/UDSProvider.js +6 -2
- package/dist/components/UDSProvider.js.map +1 -1
- package/dist/fontScaling/FontScalingContext.cjs +35 -0
- package/dist/fontScaling/FontScalingContext.d.cts +38 -0
- package/dist/fontScaling/FontScalingContext.d.cts.map +1 -0
- package/dist/fontScaling/FontScalingContext.d.ts +38 -0
- package/dist/fontScaling/FontScalingContext.d.ts.map +1 -0
- package/dist/fontScaling/FontScalingContext.js +34 -0
- package/dist/fontScaling/FontScalingContext.js.map +1 -0
- package/dist/fontScaling/constants.cjs +72 -0
- package/dist/fontScaling/constants.d.cts +49 -0
- package/dist/fontScaling/constants.d.cts.map +1 -0
- package/dist/fontScaling/constants.d.ts +49 -0
- package/dist/fontScaling/constants.d.ts.map +1 -0
- package/dist/fontScaling/constants.js +70 -0
- package/dist/fontScaling/constants.js.map +1 -0
- package/dist/fontScaling/index.cjs +13 -0
- package/dist/fontScaling/index.d.cts +8 -0
- package/dist/fontScaling/index.d.ts +8 -0
- package/dist/fontScaling/index.js +6 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.cjs +38 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts +36 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.cts.map +1 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts +36 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.d.ts.map +1 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js +39 -0
- package/dist/fontScaling/resolveMaxFontSizeMultiplier.js.map +1 -0
- package/dist/fontScaling/types.cjs +1 -0
- package/dist/fontScaling/types.d.cts +51 -0
- package/dist/fontScaling/types.d.cts.map +1 -0
- package/dist/fontScaling/types.d.ts +51 -0
- package/dist/fontScaling/types.d.ts.map +1 -0
- package/dist/fontScaling/types.js +1 -0
- package/dist/fontScaling/useFontScale.cjs +32 -0
- package/dist/fontScaling/useFontScale.d.cts +18 -0
- package/dist/fontScaling/useFontScale.d.cts.map +1 -0
- package/dist/fontScaling/useFontScale.d.ts +18 -0
- package/dist/fontScaling/useFontScale.d.ts.map +1 -0
- package/dist/fontScaling/useFontScale.js +32 -0
- package/dist/fontScaling/useFontScale.js.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.cjs +24 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.cts +16 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.cts.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.ts +16 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.d.ts.map +1 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.js +24 -0
- package/dist/fontScaling/useMaxFontSizeMultiplier.js.map +1 -0
- package/dist/jest/mocks/react-native.cjs +19 -4
- package/dist/jest/mocks/react-native.d.cts +8 -5
- package/dist/jest/mocks/react-native.d.cts.map +1 -1
- package/dist/jest/mocks/react-native.d.ts +8 -5
- package/dist/jest/mocks/react-native.d.ts.map +1 -1
- package/dist/jest/mocks/react-native.js +18 -5
- package/dist/jest/mocks/react-native.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +14 -0
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +14 -0
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/jest/setup.cjs +4 -0
- package/dist/jest/setup.d.cts.map +1 -1
- package/dist/jest/setup.d.ts.map +1 -1
- package/dist/jest/setup.js +4 -0
- package/dist/jest/setup.js.map +1 -1
- package/dist/mobile/generated/fontMetrics.cjs +1166 -0
- package/dist/mobile/generated/fontMetrics.js +1168 -0
- package/dist/mobile/generated/fontMetrics.js.map +1 -0
- package/dist/portal.d.cts.map +1 -1
- package/dist/portal.d.ts.map +1 -1
- package/dist/portal.js.map +1 -1
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts.map +1 -1
- package/fonts/uds-icons.ttf +0 -0
- package/generated/fontMetrics.ts +1173 -0
- package/generated/styles.d.ts +5 -28
- package/generated/unistyles.d.ts +0 -27
- package/package.json +11 -1
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
import { FontScalingConfig } from "../fontScaling/types.cjs";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/components/UDSProvider.d.ts
|
|
6
7
|
interface UDSGestureProviderProps {
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* App-wide font-scaling caps, overriding the built-in defaults. Omit to use
|
|
11
|
+
* the defaults (display/title tiers capped, reading sizes uncapped, control
|
|
12
|
+
* internals capped at 2x). Should be identity-stable (a module constant or
|
|
13
|
+
* memoized) — every UDS text element reads it from context.
|
|
14
|
+
*/
|
|
15
|
+
fontScaling?: FontScalingConfig;
|
|
8
16
|
}
|
|
9
17
|
/**
|
|
10
18
|
* Root gesture and portal provider for UDS Mobile overlays.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.d.cts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UDSProvider.d.cts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD;;;;;EAW5D,WAAA,GAAc,iBAAA;AAAA;;;;AAAiB;;;;;AAqBT;;;;;AAiCxB;;;;;cAjCM,kBAAA,EAAkB,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;cAoBlB,WAAA,EAAW,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;KAaL,gBAAA,GAAmB,uBAAA"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
import { FontScalingConfig } from "../fontScaling/types.js";
|
|
2
3
|
import * as _$react from "react";
|
|
3
4
|
import { ReactNode } from "react";
|
|
4
5
|
|
|
5
6
|
//#region src/components/UDSProvider.d.ts
|
|
6
7
|
interface UDSGestureProviderProps {
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
/**
|
|
10
|
+
* App-wide font-scaling caps, overriding the built-in defaults. Omit to use
|
|
11
|
+
* the defaults (display/title tiers capped, reading sizes uncapped, control
|
|
12
|
+
* internals capped at 2x). Should be identity-stable (a module constant or
|
|
13
|
+
* memoized) — every UDS text element reads it from context.
|
|
14
|
+
*/
|
|
15
|
+
fontScaling?: FontScalingConfig;
|
|
8
16
|
}
|
|
9
17
|
/**
|
|
10
18
|
* Root gesture and portal provider for UDS Mobile overlays.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.d.ts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"UDSProvider.d.ts","names":[],"sources":["../../src/components/UDSProvider.tsx"],"mappings":";;;;;;UASU,uBAAA;EACR,QAAA,EAAU,SAAA;;AAJkD;;;;;EAW5D,WAAA,GAAc,iBAAA;AAAA;;;;AAAiB;;;;;AAqBT;;;;;AAiCxB;;;;;cAjCM,kBAAA,EAAkB,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;cAoBlB,WAAA,EAAW,OAAA,CAAA,oBAAA,CAAA,uBAAA;;;;KAaL,gBAAA,GAAmB,uBAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { PortalProvider } from "../portal.js";
|
|
3
|
+
import { UDSFontScalingProvider } from "../fontScaling/FontScalingContext.js";
|
|
3
4
|
import { memo } from "react";
|
|
4
5
|
import { StyleSheet } from "react-native";
|
|
5
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -23,10 +24,13 @@ import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
|
23
24
|
* }
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
const UDSGestureProvider = memo(function UDSGestureProvider({ children }) {
|
|
27
|
+
const UDSGestureProvider = memo(function UDSGestureProvider({ children, fontScaling }) {
|
|
27
28
|
return /* @__PURE__ */ jsx(GestureHandlerRootView, {
|
|
28
29
|
style: styles.root,
|
|
29
|
-
children: /* @__PURE__ */ jsx(PortalProvider, { children
|
|
30
|
+
children: /* @__PURE__ */ jsx(PortalProvider, { children: fontScaling ? /* @__PURE__ */ jsx(UDSFontScalingProvider, {
|
|
31
|
+
config: fontScaling,
|
|
32
|
+
children
|
|
33
|
+
}) : children })
|
|
30
34
|
});
|
|
31
35
|
});
|
|
32
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UDSProvider.js","names":[],"sources":["../../src/components/UDSProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { memo } from 'react';\nimport { StyleSheet } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\nimport { PortalProvider } from '../portal';\n\ninterface UDSGestureProviderProps {\n children: ReactNode;\n}\n\n/**\n * Root gesture and portal provider for UDS Mobile overlays.\n *\n * Place this at the top of your app layout:\n *\n * @example\n * ```tsx\n * import { UDSGestureProvider } from '@yahoo/uds-mobile/UDSGestureProvider';\n *\n * export default function RootLayout() {\n * return (\n * <UDSGestureProvider>\n * <Stack />\n * </UDSGestureProvider>\n * );\n * }\n * ```\n */\nconst UDSGestureProvider = memo(function UDSGestureProvider({
|
|
1
|
+
{"version":3,"file":"UDSProvider.js","names":[],"sources":["../../src/components/UDSProvider.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { memo } from 'react';\nimport { StyleSheet } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\nimport { UDSFontScalingProvider } from '../fontScaling/FontScalingContext';\nimport type { FontScalingConfig } from '../fontScaling/types';\nimport { PortalProvider } from '../portal';\n\ninterface UDSGestureProviderProps {\n children: ReactNode;\n /**\n * App-wide font-scaling caps, overriding the built-in defaults. Omit to use\n * the defaults (display/title tiers capped, reading sizes uncapped, control\n * internals capped at 2x). Should be identity-stable (a module constant or\n * memoized) — every UDS text element reads it from context.\n */\n fontScaling?: FontScalingConfig;\n}\n\n/**\n * Root gesture and portal provider for UDS Mobile overlays.\n *\n * Place this at the top of your app layout:\n *\n * @example\n * ```tsx\n * import { UDSGestureProvider } from '@yahoo/uds-mobile/UDSGestureProvider';\n *\n * export default function RootLayout() {\n * return (\n * <UDSGestureProvider>\n * <Stack />\n * </UDSGestureProvider>\n * );\n * }\n * ```\n */\nconst UDSGestureProvider = memo(function UDSGestureProvider({\n children,\n fontScaling,\n}: UDSGestureProviderProps) {\n return (\n <GestureHandlerRootView style={styles.root}>\n <PortalProvider>\n {fontScaling ? (\n <UDSFontScalingProvider config={fontScaling}>{children}</UDSFontScalingProvider>\n ) : (\n children\n )}\n </PortalProvider>\n </GestureHandlerRootView>\n );\n});\n\n/**\n * @deprecated Use {@link UDSGestureProvider} from `@yahoo/uds-mobile/UDSGestureProvider`.\n */\nconst UDSProvider = UDSGestureProvider;\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n },\n});\n\nexport { UDSGestureProvider, UDSProvider };\nexport type { UDSGestureProviderProps };\n/**\n * @deprecated Use {@link UDSGestureProviderProps}.\n */\nexport type UDSProviderProps = UDSGestureProviderProps;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,qBAAqB,KAAK,SAAS,mBAAmB,EAC1D,UACA,eAC0B;CAC1B,OACE,oBAAC,wBAAD;EAAwB,OAAO,OAAO;YACpC,oBAAC,gBAAD,EAAA,UACG,cACC,oBAAC,wBAAD;GAAwB,QAAQ;GAAc;GAAkC,CAAA,GAEhF,UAEa,CAAA;EACM,CAAA;EAE3B;;;;AAKF,MAAM,cAAc;AAEpB,MAAM,SAAS,WAAW,OAAO,EAC/B,MAAM,EACJ,MAAM,GACP,EACF,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
let react = require("react");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
//#region src/fontScaling/FontScalingContext.tsx
|
|
7
|
+
const FontScalingContext = (0, react.createContext)(void 0);
|
|
8
|
+
/**
|
|
9
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
10
|
+
*
|
|
11
|
+
* @description
|
|
12
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
13
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
14
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
15
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
20
|
+
*
|
|
21
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
22
|
+
* <App />
|
|
23
|
+
* </UDSFontScalingProvider>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const UDSFontScalingProvider = (0, react.memo)(function UDSFontScalingProvider({ config, children }) {
|
|
27
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FontScalingContext.Provider, {
|
|
28
|
+
value: config,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
UDSFontScalingProvider.displayName = "UDSFontScalingProvider";
|
|
33
|
+
//#endregion
|
|
34
|
+
exports.FontScalingContext = FontScalingContext;
|
|
35
|
+
exports.UDSFontScalingProvider = UDSFontScalingProvider;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { FontScalingConfig } from "./types.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/fontScaling/FontScalingContext.d.ts
|
|
7
|
+
declare const FontScalingContext: _$react.Context<FontScalingConfig | undefined>;
|
|
8
|
+
interface UDSFontScalingProviderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Font-scaling caps for the subtree. Should be identity-stable (a module
|
|
11
|
+
* constant or memoized) — every UDS text element reads it from context.
|
|
12
|
+
* The nearest provider wins wholesale; configs are not merged.
|
|
13
|
+
*/
|
|
14
|
+
config: FontScalingConfig;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
19
|
+
*
|
|
20
|
+
* @description
|
|
21
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
22
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
23
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
24
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
29
|
+
*
|
|
30
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
31
|
+
* <App />
|
|
32
|
+
* </UDSFontScalingProvider>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const UDSFontScalingProvider: _$react.NamedExoticComponent<UDSFontScalingProviderProps>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };
|
|
38
|
+
//# sourceMappingURL=FontScalingContext.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontScalingContext.d.cts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;cAMM,kBAAA,EAAkB,OAAA,CAAA,OAAA,CAAA,iBAAA;AAAA,UAEd,2BAAA;;AALuC;;;;EAW/C,MAAA,EAAQ,iBAAA;EACR,QAAA,EAAU,SAAA;AAAA;;;;;;;;;AAAS;;;;;;;;;;cAqBf,sBAAA,EAAsB,OAAA,CAAA,oBAAA,CAAA,2BAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { FontScalingConfig } from "./types.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/fontScaling/FontScalingContext.d.ts
|
|
7
|
+
declare const FontScalingContext: _$react.Context<FontScalingConfig | undefined>;
|
|
8
|
+
interface UDSFontScalingProviderProps {
|
|
9
|
+
/**
|
|
10
|
+
* Font-scaling caps for the subtree. Should be identity-stable (a module
|
|
11
|
+
* constant or memoized) — every UDS text element reads it from context.
|
|
12
|
+
* The nearest provider wins wholesale; configs are not merged.
|
|
13
|
+
*/
|
|
14
|
+
config: FontScalingConfig;
|
|
15
|
+
children: ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
19
|
+
*
|
|
20
|
+
* @description
|
|
21
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
22
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
23
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
24
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
29
|
+
*
|
|
30
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
31
|
+
* <App />
|
|
32
|
+
* </UDSFontScalingProvider>
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
declare const UDSFontScalingProvider: _$react.NamedExoticComponent<UDSFontScalingProviderProps>;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };
|
|
38
|
+
//# sourceMappingURL=FontScalingContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontScalingContext.d.ts","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"mappings":";;;;;;cAMM,kBAAA,EAAkB,OAAA,CAAA,OAAA,CAAA,iBAAA;AAAA,UAEd,2BAAA;;AALuC;;;;EAW/C,MAAA,EAAQ,iBAAA;EACR,QAAA,EAAU,SAAA;AAAA;;;;;;;;;AAAS;;;;;;;;;;cAqBf,sBAAA,EAAsB,OAAA,CAAA,oBAAA,CAAA,2BAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { createContext, memo } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
//#region src/fontScaling/FontScalingContext.tsx
|
|
5
|
+
const FontScalingContext = createContext(void 0);
|
|
6
|
+
/**
|
|
7
|
+
* **🔠 Overrides UDS font-scaling caps for a subtree**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Configures how UDS text and controls respond to the OS text-size setting.
|
|
11
|
+
* Without a provider, built-in defaults apply (display/title tiers capped,
|
|
12
|
+
* reading sizes uncapped, control internals capped at 2x). Most apps set this
|
|
13
|
+
* once at the root via the `fontScaling` prop on `UDSGestureProvider`.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };
|
|
18
|
+
*
|
|
19
|
+
* <UDSFontScalingProvider config={FONT_SCALING}>
|
|
20
|
+
* <App />
|
|
21
|
+
* </UDSFontScalingProvider>
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
const UDSFontScalingProvider = memo(function UDSFontScalingProvider({ config, children }) {
|
|
25
|
+
return /* @__PURE__ */ jsx(FontScalingContext.Provider, {
|
|
26
|
+
value: config,
|
|
27
|
+
children
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
UDSFontScalingProvider.displayName = "UDSFontScalingProvider";
|
|
31
|
+
//#endregion
|
|
32
|
+
export { FontScalingContext, UDSFontScalingProvider };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=FontScalingContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FontScalingContext.js","names":[],"sources":["../../src/fontScaling/FontScalingContext.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { createContext, memo } from 'react';\n\nimport type { FontScalingConfig } from './types';\n\n// undefined = no provider mounted; built-in defaults apply.\nconst FontScalingContext = createContext<FontScalingConfig | undefined>(undefined);\n\ninterface UDSFontScalingProviderProps {\n /**\n * Font-scaling caps for the subtree. Should be identity-stable (a module\n * constant or memoized) — every UDS text element reads it from context.\n * The nearest provider wins wholesale; configs are not merged.\n */\n config: FontScalingConfig;\n children: ReactNode;\n}\n\n/**\n * **🔠 Overrides UDS font-scaling caps for a subtree**\n *\n * @description\n * Configures how UDS text and controls respond to the OS text-size setting.\n * Without a provider, built-in defaults apply (display/title tiers capped,\n * reading sizes uncapped, control internals capped at 2x). Most apps set this\n * once at the root via the `fontScaling` prop on `UDSGestureProvider`.\n *\n * @example\n * ```tsx\n * const FONT_SCALING = { default: 2, variants: { display1: 1.75 } };\n *\n * <UDSFontScalingProvider config={FONT_SCALING}>\n * <App />\n * </UDSFontScalingProvider>\n * ```\n */\nconst UDSFontScalingProvider = memo(function UDSFontScalingProvider({\n config,\n children,\n}: UDSFontScalingProviderProps) {\n return <FontScalingContext.Provider value={config}>{children}</FontScalingContext.Provider>;\n});\n\nUDSFontScalingProvider.displayName = 'UDSFontScalingProvider';\n\nexport { FontScalingContext, UDSFontScalingProvider, type UDSFontScalingProviderProps };\n"],"mappings":";;;;AAMA,MAAM,qBAAqB,cAA6C,KAAA,EAAU;;;;;;;;;;;;;;;;;;;AA8BlF,MAAM,yBAAyB,KAAK,SAAS,uBAAuB,EAClE,QACA,YAC8B;CAC9B,OAAO,oBAAC,mBAAmB,UAApB;EAA6B,OAAO;EAAS;EAAuC,CAAA;EAC3F;AAEF,uBAAuB,cAAc"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
//#region src/fontScaling/constants.ts
|
|
4
|
+
/**
|
|
5
|
+
* The largest OS font scale UDS components are designed to support.
|
|
6
|
+
*
|
|
7
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
8
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
9
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
10
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
11
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
12
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
13
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
14
|
+
*/
|
|
15
|
+
const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
16
|
+
/**
|
|
17
|
+
* How far each text style would grow if only legibility mattered, following
|
|
18
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
19
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
20
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
21
|
+
* are larger than largeTitle, so they taper hardest.
|
|
22
|
+
*
|
|
23
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
24
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
25
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
26
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
27
|
+
*
|
|
28
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
29
|
+
*/
|
|
30
|
+
const TYPE_SCALE_CURVE = {
|
|
31
|
+
display1: 1.5,
|
|
32
|
+
display2: 1.6,
|
|
33
|
+
display3: 1.75,
|
|
34
|
+
title1: 1.8,
|
|
35
|
+
title2: 2,
|
|
36
|
+
title3: 2.2,
|
|
37
|
+
title4: 2.4,
|
|
38
|
+
headline1: 2.5,
|
|
39
|
+
ui1: 2.2,
|
|
40
|
+
ui2: 2.4,
|
|
41
|
+
body1: null,
|
|
42
|
+
label1: null,
|
|
43
|
+
label2: null,
|
|
44
|
+
label3: null,
|
|
45
|
+
label4: null,
|
|
46
|
+
caption1: null,
|
|
47
|
+
caption2: null,
|
|
48
|
+
legal1: null,
|
|
49
|
+
ui3: null,
|
|
50
|
+
ui4: null,
|
|
51
|
+
ui5: null,
|
|
52
|
+
ui6: null
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
56
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
57
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
58
|
+
*
|
|
59
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
60
|
+
*/
|
|
61
|
+
const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = Object.freeze(Object.fromEntries(Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [variant, cap === null ? 2 : Math.min(cap, 2)])));
|
|
62
|
+
/**
|
|
63
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
64
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
65
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
66
|
+
*/
|
|
67
|
+
const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
68
|
+
//#endregion
|
|
69
|
+
exports.DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER;
|
|
70
|
+
exports.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = DEFAULT_MAX_FONT_SIZE_MULTIPLIERS;
|
|
71
|
+
exports.MAX_SUPPORTED_FONT_SCALE = MAX_SUPPORTED_FONT_SCALE;
|
|
72
|
+
exports.TYPE_SCALE_CURVE = TYPE_SCALE_CURVE;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
import { FontScalingCapValue } from "./types.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/fontScaling/constants.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The largest OS font scale UDS components are designed to support.
|
|
8
|
+
*
|
|
9
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
10
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
11
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
12
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
13
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
14
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
15
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
16
|
+
*/
|
|
17
|
+
declare const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
18
|
+
/**
|
|
19
|
+
* How far each text style would grow if only legibility mattered, following
|
|
20
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
21
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
22
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
23
|
+
* are larger than largeTitle, so they taper hardest.
|
|
24
|
+
*
|
|
25
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
26
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
27
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
28
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
29
|
+
*
|
|
30
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
31
|
+
*/
|
|
32
|
+
declare const TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
33
|
+
/**
|
|
34
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
35
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
36
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
37
|
+
*
|
|
38
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
39
|
+
*/
|
|
40
|
+
declare const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
41
|
+
/**
|
|
42
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
43
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
44
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
45
|
+
*/
|
|
46
|
+
declare const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE };
|
|
49
|
+
//# sourceMappingURL=constants.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.cts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;AACmD;;;;;AAarB;;;;cAAxB,wBAAA;;;;;;;;;;;;;AAgB0E;;cAA1E,gBAAA,EAAkB,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;;cAgCvD,iCAAA,EAAmC,QAAA,CACvC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;cAexB,wCAAA"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.js";
|
|
3
|
+
import { FontScalingCapValue } from "./types.js";
|
|
4
|
+
|
|
5
|
+
//#region src/fontScaling/constants.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* The largest OS font scale UDS components are designed to support.
|
|
8
|
+
*
|
|
9
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
10
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
11
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
12
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
13
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
14
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
15
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
16
|
+
*/
|
|
17
|
+
declare const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
18
|
+
/**
|
|
19
|
+
* How far each text style would grow if only legibility mattered, following
|
|
20
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
21
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
22
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
23
|
+
* are larger than largeTitle, so they taper hardest.
|
|
24
|
+
*
|
|
25
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
26
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
27
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
28
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
29
|
+
*
|
|
30
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
31
|
+
*/
|
|
32
|
+
declare const TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
33
|
+
/**
|
|
34
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
35
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
36
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
37
|
+
*
|
|
38
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
39
|
+
*/
|
|
40
|
+
declare const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>>;
|
|
41
|
+
/**
|
|
42
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
43
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
44
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
45
|
+
*/
|
|
46
|
+
declare const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
47
|
+
//#endregion
|
|
48
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE };
|
|
49
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","names":[],"sources":["../../src/fontScaling/constants.ts"],"mappings":";;;;;;;AACmD;;;;;AAarB;;;;cAAxB,wBAAA;;;;;;;;;;;;;AAgB0E;;cAA1E,gBAAA,EAAkB,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;;;cAgCvD,iCAAA,EAAmC,QAAA,CACvC,OAAA,CAAQ,MAAA,CAAO,WAAA,EAAa,mBAAA;;;;;;cAexB,wCAAA"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
//#region src/fontScaling/constants.ts
|
|
3
|
+
/**
|
|
4
|
+
* The largest OS font scale UDS components are designed to support.
|
|
5
|
+
*
|
|
6
|
+
* Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so
|
|
7
|
+
* no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger
|
|
8
|
+
* Text is claimable at "at least 200% or the maximum font size for the
|
|
9
|
+
* system", so a 2x ceiling still qualifies. Note that iOS offers scales beyond
|
|
10
|
+
* this (up to 3.571x): with this ceiling in place the top accessibility sizes
|
|
11
|
+
* render alike, and an app that wants to follow the OS further can raise or
|
|
12
|
+
* remove the caps via `UDSFontScalingProvider`.
|
|
13
|
+
*/
|
|
14
|
+
const MAX_SUPPORTED_FONT_SCALE = 2;
|
|
15
|
+
/**
|
|
16
|
+
* How far each text style would grow if only legibility mattered, following
|
|
17
|
+
* the shape of Apple's Dynamic Type ramps: the larger a style starts, the less
|
|
18
|
+
* it multiplies. At iOS's largest accessibility size the system grows body
|
|
19
|
+
* (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers
|
|
20
|
+
* are larger than largeTitle, so they taper hardest.
|
|
21
|
+
*
|
|
22
|
+
* Caps are chosen by the size a style starts at rather than by which family it
|
|
23
|
+
* belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`
|
|
24
|
+
* (20pt) matches `title4` (20pt). `null` means "no cap from the curve" — those
|
|
25
|
+
* are reading sizes, where legibility argues for following the OS.
|
|
26
|
+
*
|
|
27
|
+
* The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.
|
|
28
|
+
*/
|
|
29
|
+
const TYPE_SCALE_CURVE = {
|
|
30
|
+
display1: 1.5,
|
|
31
|
+
display2: 1.6,
|
|
32
|
+
display3: 1.75,
|
|
33
|
+
title1: 1.8,
|
|
34
|
+
title2: 2,
|
|
35
|
+
title3: 2.2,
|
|
36
|
+
title4: 2.4,
|
|
37
|
+
headline1: 2.5,
|
|
38
|
+
ui1: 2.2,
|
|
39
|
+
ui2: 2.4,
|
|
40
|
+
body1: null,
|
|
41
|
+
label1: null,
|
|
42
|
+
label2: null,
|
|
43
|
+
label3: null,
|
|
44
|
+
label4: null,
|
|
45
|
+
caption1: null,
|
|
46
|
+
caption2: null,
|
|
47
|
+
legal1: null,
|
|
48
|
+
ui3: null,
|
|
49
|
+
ui4: null,
|
|
50
|
+
ui5: null,
|
|
51
|
+
ui6: null
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Default per-variant caps on OS font scaling, applied by `Text` when no
|
|
55
|
+
* explicit prop or provider config overrides them: the legibility curve in
|
|
56
|
+
* {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.
|
|
57
|
+
*
|
|
58
|
+
* Keys are base variants; `/emphasized` twins resolve to their base.
|
|
59
|
+
*/
|
|
60
|
+
const DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = Object.freeze(Object.fromEntries(Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [variant, cap === null ? 2 : Math.min(cap, 2)])));
|
|
61
|
+
/**
|
|
62
|
+
* Default cap for control-internal text and icons (Button, Checkbox, Radio,
|
|
63
|
+
* Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the
|
|
64
|
+
* supported ceiling rather than a looser per-variant cap.
|
|
65
|
+
*/
|
|
66
|
+
const DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = 2;
|
|
67
|
+
//#endregion
|
|
68
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE };
|
|
69
|
+
|
|
70
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../../src/fontScaling/constants.ts"],"sourcesContent":["import type { TextVariant } from '../components/Text';\nimport type { FontScalingCapValue } from './types';\n\n/**\n * The largest OS font scale UDS components are designed to support.\n *\n * Yahoo's inclusive-design guidance is to solve for text scaling up to 2x, so\n * no default cap exceeds it. Apple's Accessibility Nutrition Label for Larger\n * Text is claimable at \"at least 200% or the maximum font size for the\n * system\", so a 2x ceiling still qualifies. Note that iOS offers scales beyond\n * this (up to 3.571x): with this ceiling in place the top accessibility sizes\n * render alike, and an app that wants to follow the OS further can raise or\n * remove the caps via `UDSFontScalingProvider`.\n */\nconst MAX_SUPPORTED_FONT_SCALE = 2;\n\n/**\n * How far each text style would grow if only legibility mattered, following\n * the shape of Apple's Dynamic Type ramps: the larger a style starts, the less\n * it multiplies. At iOS's largest accessibility size the system grows body\n * (17pt) by 3.12x but largeTitle (34pt) by only ~1.71x, and UDS display tiers\n * are larger than largeTitle, so they taper hardest.\n *\n * Caps are chosen by the size a style starts at rather than by which family it\n * belongs to, which is why `ui1` (24pt) matches `title3` (24pt) and `ui2`\n * (20pt) matches `title4` (20pt). `null` means \"no cap from the curve\" — those\n * are reading sizes, where legibility argues for following the OS.\n *\n * The exported defaults are this curve clamped to {@link MAX_SUPPORTED_FONT_SCALE}.\n */\nconst TYPE_SCALE_CURVE: Readonly<Partial<Record<TextVariant, FontScalingCapValue>>> = {\n display1: 1.5,\n display2: 1.6,\n display3: 1.75,\n title1: 1.8,\n title2: 2,\n title3: 2.2,\n title4: 2.4,\n headline1: 2.5,\n ui1: 2.2,\n ui2: 2.4,\n body1: null,\n label1: null,\n label2: null,\n label3: null,\n label4: null,\n caption1: null,\n caption2: null,\n legal1: null,\n ui3: null,\n ui4: null,\n ui5: null,\n ui6: null,\n};\n\n/**\n * Default per-variant caps on OS font scaling, applied by `Text` when no\n * explicit prop or provider config overrides them: the legibility curve in\n * {@link TYPE_SCALE_CURVE}, clamped to the 2x we support.\n *\n * Keys are base variants; `/emphasized` twins resolve to their base.\n */\nconst DEFAULT_MAX_FONT_SIZE_MULTIPLIERS: Readonly<\n Partial<Record<TextVariant, FontScalingCapValue>>\n> = Object.freeze(\n Object.fromEntries(\n Object.entries(TYPE_SCALE_CURVE).map(([variant, cap]) => [\n variant,\n cap === null ? MAX_SUPPORTED_FONT_SCALE : Math.min(cap, MAX_SUPPORTED_FONT_SCALE),\n ]),\n ) as Partial<Record<TextVariant, FontScalingCapValue>>,\n);\n\n/**\n * Default cap for control-internal text and icons (Button, Checkbox, Radio,\n * Switch, Chip, Tabs, Icon). Controls have bounded layouts, so they get the\n * supported ceiling rather than a looser per-variant cap.\n */\nconst DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = MAX_SUPPORTED_FONT_SCALE;\n\nexport {\n DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER,\n DEFAULT_MAX_FONT_SIZE_MULTIPLIERS,\n MAX_SUPPORTED_FONT_SCALE,\n TYPE_SCALE_CURVE,\n};\n"],"mappings":";;;;;;;;;;;;;AAcA,MAAM,2BAA2B;;;;;;;;;;;;;;;AAgBjC,MAAM,mBAAgF;CACpF,UAAU;CACV,UAAU;CACV,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,WAAW;CACX,KAAK;CACL,KAAK;CACL,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,UAAU;CACV,QAAQ;CACR,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN;;;;;;;;AASD,MAAM,oCAEF,OAAO,OACT,OAAO,YACL,OAAO,QAAQ,iBAAiB,CAAC,KAAK,CAAC,SAAS,SAAS,CACvD,SACA,QAAQ,OAAA,IAAkC,KAAK,IAAI,KAAA,EAA8B,CAClF,CAAC,CACH,CACF;;;;;;AAOD,MAAM,2CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_fontScaling_FontScalingContext = require("./FontScalingContext.cjs");
|
|
4
|
+
const require_fontScaling_constants = require("./constants.cjs");
|
|
5
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("./useMaxFontSizeMultiplier.cjs");
|
|
6
|
+
const require_fontScaling_useFontScale = require("./useFontScale.cjs");
|
|
7
|
+
exports.DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER = require_fontScaling_constants.DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER;
|
|
8
|
+
exports.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS = require_fontScaling_constants.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS;
|
|
9
|
+
exports.MAX_SUPPORTED_FONT_SCALE = require_fontScaling_constants.MAX_SUPPORTED_FONT_SCALE;
|
|
10
|
+
exports.TYPE_SCALE_CURVE = require_fontScaling_constants.TYPE_SCALE_CURVE;
|
|
11
|
+
exports.UDSFontScalingProvider = require_fontScaling_FontScalingContext.UDSFontScalingProvider;
|
|
12
|
+
exports.useFontScale = require_fontScaling_useFontScale.useFontScale;
|
|
13
|
+
exports.useMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
import { FontScalingCapValue, FontScalingConfig } from "./types.cjs";
|
|
4
|
+
import { UDSFontScalingProvider, UDSFontScalingProviderProps } from "./FontScalingContext.cjs";
|
|
5
|
+
import { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE } from "./constants.cjs";
|
|
6
|
+
import { useFontScale } from "./useFontScale.cjs";
|
|
7
|
+
import { useMaxFontSizeMultiplier } from "./useMaxFontSizeMultiplier.cjs";
|
|
8
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, type FontScalingCapValue, type FontScalingConfig, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE, type TextVariant, UDSFontScalingProvider, type UDSFontScalingProviderProps, useFontScale, useMaxFontSizeMultiplier };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.js";
|
|
3
|
+
import { FontScalingCapValue, FontScalingConfig } from "./types.js";
|
|
4
|
+
import { UDSFontScalingProvider, UDSFontScalingProviderProps } from "./FontScalingContext.js";
|
|
5
|
+
import { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE } from "./constants.js";
|
|
6
|
+
import { useFontScale } from "./useFontScale.js";
|
|
7
|
+
import { useMaxFontSizeMultiplier } from "./useMaxFontSizeMultiplier.js";
|
|
8
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, type FontScalingCapValue, type FontScalingConfig, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE, type TextVariant, UDSFontScalingProvider, type UDSFontScalingProviderProps, useFontScale, useMaxFontSizeMultiplier };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { UDSFontScalingProvider } from "./FontScalingContext.js";
|
|
3
|
+
import { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE } from "./constants.js";
|
|
4
|
+
import { useMaxFontSizeMultiplier } from "./useMaxFontSizeMultiplier.js";
|
|
5
|
+
import { useFontScale } from "./useFontScale.js";
|
|
6
|
+
export { DEFAULT_CONTROL_MAX_FONT_SIZE_MULTIPLIER, DEFAULT_MAX_FONT_SIZE_MULTIPLIERS, MAX_SUPPORTED_FONT_SCALE, TYPE_SCALE_CURVE, UDSFontScalingProvider, useFontScale, useMaxFontSizeMultiplier };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const require_fontScaling_constants = require("./constants.cjs");
|
|
4
|
+
//#region src/fontScaling/resolveMaxFontSizeMultiplier.ts
|
|
5
|
+
const UNCAPPED = 0;
|
|
6
|
+
function toResolved(cap) {
|
|
7
|
+
return cap === null ? UNCAPPED : cap;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Resolves the `maxFontSizeMultiplier` to hand to React Native.
|
|
11
|
+
*
|
|
12
|
+
* Precedence: explicit prop > provider config (variant entry, then base-variant
|
|
13
|
+
* entry, then `default`) > built-in default table.
|
|
14
|
+
*
|
|
15
|
+
* Returns `undefined` (native behavior: inherit from parent text or app
|
|
16
|
+
* global) when nothing applies — including for built-in uncapped variants, so
|
|
17
|
+
* body text nested inside capped text still inherits the parent's cap. Only an
|
|
18
|
+
* explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.
|
|
19
|
+
*/
|
|
20
|
+
function resolveMaxFontSizeMultiplier({ explicit, config, variant }) {
|
|
21
|
+
if (explicit !== void 0) return toResolved(explicit);
|
|
22
|
+
if (config?.enabled === false) return;
|
|
23
|
+
if (variant === void 0) return config?.default !== void 0 ? toResolved(config.default) : void 0;
|
|
24
|
+
if (variant === "control") {
|
|
25
|
+
if (config?.control !== void 0) return toResolved(config.control);
|
|
26
|
+
return 2;
|
|
27
|
+
}
|
|
28
|
+
const baseVariant = variant.split("/")[0];
|
|
29
|
+
const variantCap = config?.variants?.[variant];
|
|
30
|
+
if (variantCap !== void 0) return toResolved(variantCap);
|
|
31
|
+
const baseVariantCap = config?.variants?.[baseVariant];
|
|
32
|
+
if (baseVariantCap !== void 0) return toResolved(baseVariantCap);
|
|
33
|
+
if (config?.default !== void 0) return toResolved(config.default);
|
|
34
|
+
const builtIn = require_fontScaling_constants.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[variant] ?? require_fontScaling_constants.DEFAULT_MAX_FONT_SIZE_MULTIPLIERS[baseVariant];
|
|
35
|
+
return typeof builtIn === "number" ? builtIn : void 0;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.resolveMaxFontSizeMultiplier = resolveMaxFontSizeMultiplier;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
|
|
2
|
+
import { TextVariant } from "../components/Text.cjs";
|
|
3
|
+
import { FontScalingConfig } from "./types.cjs";
|
|
4
|
+
|
|
5
|
+
//#region src/fontScaling/resolveMaxFontSizeMultiplier.d.ts
|
|
6
|
+
interface ResolveMaxFontSizeMultiplierOptions {
|
|
7
|
+
/** Explicit component prop. `null` = force-uncap. Wins over everything. */
|
|
8
|
+
explicit?: number | null;
|
|
9
|
+
/** Provider config, if any provider is mounted. */
|
|
10
|
+
config?: FontScalingConfig;
|
|
11
|
+
/**
|
|
12
|
+
* The text's resolved variant, `'control'` for control-internal text/icons,
|
|
13
|
+
* or `undefined` for `variant="inherit"` text (no variant opinion — nested
|
|
14
|
+
* text inherits its parent's cap natively).
|
|
15
|
+
*/
|
|
16
|
+
variant?: TextVariant | 'control';
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Resolves the `maxFontSizeMultiplier` to hand to React Native.
|
|
20
|
+
*
|
|
21
|
+
* Precedence: explicit prop > provider config (variant entry, then base-variant
|
|
22
|
+
* entry, then `default`) > built-in default table.
|
|
23
|
+
*
|
|
24
|
+
* Returns `undefined` (native behavior: inherit from parent text or app
|
|
25
|
+
* global) when nothing applies — including for built-in uncapped variants, so
|
|
26
|
+
* body text nested inside capped text still inherits the parent's cap. Only an
|
|
27
|
+
* explicit `null` (prop or provider) maps to `0`, RN's force-uncap value.
|
|
28
|
+
*/
|
|
29
|
+
declare function resolveMaxFontSizeMultiplier({
|
|
30
|
+
explicit,
|
|
31
|
+
config,
|
|
32
|
+
variant
|
|
33
|
+
}: ResolveMaxFontSizeMultiplierOptions): number | undefined;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { type ResolveMaxFontSizeMultiplierOptions, resolveMaxFontSizeMultiplier };
|
|
36
|
+
//# sourceMappingURL=resolveMaxFontSizeMultiplier.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMaxFontSizeMultiplier.d.cts","names":[],"sources":["../../src/fontScaling/resolveMaxFontSizeMultiplier.ts"],"mappings":";;;;;UAWU,mCAAA;;EAER,QAAA;EAF2C;EAI3C,MAAA,GAAS,iBAAA;EAMY;;;;;EAArB,OAAA,GAAU,WAAA;AAAA;;AAAW;;;;;;;;;;iBAkBd,4BAAA,CAAA;EACP,QAAA;EACA,MAAA;EACA;AAAA,GACC,mCAAA"}
|