@yahoo/uds-mobile 2.24.0-beta.1 → 2.24.0-beta.11
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 +16 -1
- package/dist/components/Link.d.cts +6 -0
- package/dist/components/Link.d.cts.map +1 -1
- package/dist/components/Link.d.ts +6 -0
- package/dist/components/Link.d.ts.map +1 -1
- package/dist/components/Link.js +16 -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 +534 -534
- package/dist/mobile/generated/fontMetrics.js +534 -534
- 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/fonts/uds-icons.ttf +0 -0
- package/generated/fontMetrics.ts +534 -534
- package/package.json +2 -2
|
@@ -3,9 +3,10 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
3
3
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_index = require("../motion-tokens/dist/index.cjs");
|
|
5
5
|
const require_motion = require("../motion.cjs");
|
|
6
|
+
const require_fontScaling_useFontScale = require("../fontScaling/useFontScale.cjs");
|
|
6
7
|
const require_fontScaling_useMaxFontSizeMultiplier = require("../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
8
|
+
const require_components_Button_buttonTheme = require("./Button/buttonTheme.cjs");
|
|
7
9
|
const require_components_Icon = require("./Icon.cjs");
|
|
8
|
-
const require_fontScaling_useFontScale = require("../fontScaling/useFontScale.cjs");
|
|
9
10
|
const require_components_Pressable = require("./Pressable.cjs");
|
|
10
11
|
const require_components_FormLabel = require("./FormLabel.cjs");
|
|
11
12
|
let react = require("react");
|
|
@@ -55,9 +56,7 @@ const VARIANT_ERROR_MAP = {
|
|
|
55
56
|
*/
|
|
56
57
|
const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, maxFontSizeMultiplier, onChange, ref, ...viewProps }) {
|
|
57
58
|
const uid = `uds-checkbox-${(0, react.useId)()}`;
|
|
58
|
-
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier)
|
|
59
|
-
const fontScaleFactor = require_fontScaling_useFontScale.useFontScale(resolvedMaxFontSizeMultiplier);
|
|
60
|
-
const scaledMarkSize = Math.round(_yahoo_uds_icons_tokens.ICON_SIZE_MAP.sm * fontScaleFactor);
|
|
59
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
61
60
|
const isControlled = checkedProp !== void 0;
|
|
62
61
|
const [internalChecked, setInternalChecked] = (0, react.useState)(isControlled ? checkedProp : defaultChecked ?? false);
|
|
63
62
|
const [pressed, setPressed] = (0, react.useState)(false);
|
|
@@ -96,6 +95,11 @@ const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "sta
|
|
|
96
95
|
disabled,
|
|
97
96
|
pressed
|
|
98
97
|
});
|
|
98
|
+
const boxBaseSize = generated_styles.checkboxStyles.checkbox.width;
|
|
99
|
+
const fontScaleFactor = require_fontScaling_useFontScale.useComponentFontScale(resolvedMaxFontSizeMultiplier, typeof boxBaseSize === "number" ? boxBaseSize : void 0);
|
|
100
|
+
const markScaleFactor = require_fontScaling_useFontScale.useComponentFontScale(resolvedMaxFontSizeMultiplier, _yahoo_uds_icons_tokens.ICON_SIZE_MAP.sm);
|
|
101
|
+
const scaledMarkSize = Math.round(_yahoo_uds_icons_tokens.ICON_SIZE_MAP.sm * markScaleFactor);
|
|
102
|
+
const hasScaledLayout = fontScaleFactor !== 1;
|
|
99
103
|
const rootStyle = (0, react.useMemo)(() => [generated_styles.checkboxStyles.root, { opacity: disabled ? .5 : 1 }], [generated_styles.checkboxStyles.root, disabled]);
|
|
100
104
|
const checkboxBoxStyle = (0, react.useMemo)(() => {
|
|
101
105
|
const { width, height, borderRadius } = generated_styles.checkboxStyles.checkbox;
|
|
@@ -127,6 +131,7 @@ const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "sta
|
|
|
127
131
|
required,
|
|
128
132
|
showRequiredAsterisk: required,
|
|
129
133
|
hasError,
|
|
134
|
+
flexShrink: hasScaledLayout ? "1" : void 0,
|
|
130
135
|
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
131
136
|
style: generated_styles.checkboxStyles.text
|
|
132
137
|
});
|
|
@@ -134,6 +139,7 @@ const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "sta
|
|
|
134
139
|
label,
|
|
135
140
|
required,
|
|
136
141
|
hasError,
|
|
142
|
+
hasScaledLayout,
|
|
137
143
|
resolvedMaxFontSizeMultiplier,
|
|
138
144
|
generated_styles.checkboxStyles.text
|
|
139
145
|
]);
|
|
@@ -150,7 +156,8 @@ const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "sta
|
|
|
150
156
|
disabled,
|
|
151
157
|
flexDirection: labelPosition === "start" ? "row" : "row-reverse",
|
|
152
158
|
alignItems: "center",
|
|
153
|
-
alignSelf: "flex-start",
|
|
159
|
+
alignSelf: hasScaledLayout ? "stretch" : "flex-start",
|
|
160
|
+
minHeight: hasScaledLayout ? 52 : void 0,
|
|
154
161
|
accessibilityRole: "checkbox",
|
|
155
162
|
accessibilityState: a11yState,
|
|
156
163
|
accessibilityLabel: typeof label === "string" ? label : void 0,
|
|
@@ -163,7 +170,10 @@ const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "sta
|
|
|
163
170
|
size: "sm",
|
|
164
171
|
dangerouslySetSize: scaledMarkSize,
|
|
165
172
|
allowFontScaling: false,
|
|
166
|
-
style: generated_styles.checkboxStyles.checkboxIcon
|
|
173
|
+
style: [generated_styles.checkboxStyles.checkboxIcon, markScaleFactor !== 1 ? {
|
|
174
|
+
fontSize: scaledMarkSize,
|
|
175
|
+
lineHeight: require_components_Button_buttonTheme.getSafeIconCell(scaledMarkSize)
|
|
176
|
+
} : void 0]
|
|
167
177
|
})
|
|
168
178
|
}), labelContent]
|
|
169
179
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.cts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.cts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAuBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;;;;;;EAe9B,qBAAA;EAbA;EAeA,QAAA,IAAY,OAAA;AAAA;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,OAAA,CAAA,oBAAA,CAAA,aAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAuBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;;;;;;EAe9B,qBAAA;EAbA;EAeA,QAAA,IAAY,OAAA;AAAA;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,OAAA,CAAA,oBAAA,CAAA,aAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
2
|
import { SCALE_EFFECTS } from "../motion-tokens/dist/index.js";
|
|
3
3
|
import { BUTTON_SPRING_CONFIG } from "../motion.js";
|
|
4
|
+
import { useComponentFontScale } from "../fontScaling/useFontScale.js";
|
|
4
5
|
import { useMaxFontSizeMultiplier } from "../fontScaling/useMaxFontSizeMultiplier.js";
|
|
6
|
+
import { getSafeIconCell } from "./Button/buttonTheme.js";
|
|
5
7
|
import { Icon } from "./Icon.js";
|
|
6
|
-
import { useFontScale } from "../fontScaling/useFontScale.js";
|
|
7
8
|
import { Pressable } from "./Pressable.js";
|
|
8
9
|
import { FormLabel } from "./FormLabel.js";
|
|
9
10
|
import { memo, useCallback, useId, useMemo, useState } from "react";
|
|
@@ -52,9 +53,7 @@ const VARIANT_ERROR_MAP = {
|
|
|
52
53
|
*/
|
|
53
54
|
const Checkbox = memo(function Checkbox({ label, labelPosition = "start", variant: variantProp = "primary", size = "md", checked: checkedProp, hasError, reduceMotion, defaultChecked, disabled, required, maxFontSizeMultiplier, onChange, ref, ...viewProps }) {
|
|
54
55
|
const uid = `uds-checkbox-${useId()}`;
|
|
55
|
-
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier)
|
|
56
|
-
const fontScaleFactor = useFontScale(resolvedMaxFontSizeMultiplier);
|
|
57
|
-
const scaledMarkSize = Math.round(ICON_SIZE_MAP.sm * fontScaleFactor);
|
|
56
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
58
57
|
const isControlled = checkedProp !== void 0;
|
|
59
58
|
const [internalChecked, setInternalChecked] = useState(isControlled ? checkedProp : defaultChecked ?? false);
|
|
60
59
|
const [pressed, setPressed] = useState(false);
|
|
@@ -93,6 +92,11 @@ const Checkbox = memo(function Checkbox({ label, labelPosition = "start", varian
|
|
|
93
92
|
disabled,
|
|
94
93
|
pressed
|
|
95
94
|
});
|
|
95
|
+
const boxBaseSize = checkboxStyles.checkbox.width;
|
|
96
|
+
const fontScaleFactor = useComponentFontScale(resolvedMaxFontSizeMultiplier, typeof boxBaseSize === "number" ? boxBaseSize : void 0);
|
|
97
|
+
const markScaleFactor = useComponentFontScale(resolvedMaxFontSizeMultiplier, ICON_SIZE_MAP.sm);
|
|
98
|
+
const scaledMarkSize = Math.round(ICON_SIZE_MAP.sm * markScaleFactor);
|
|
99
|
+
const hasScaledLayout = fontScaleFactor !== 1;
|
|
96
100
|
const rootStyle = useMemo(() => [checkboxStyles.root, { opacity: disabled ? .5 : 1 }], [checkboxStyles.root, disabled]);
|
|
97
101
|
const checkboxBoxStyle = useMemo(() => {
|
|
98
102
|
const { width, height, borderRadius } = checkboxStyles.checkbox;
|
|
@@ -124,6 +128,7 @@ const Checkbox = memo(function Checkbox({ label, labelPosition = "start", varian
|
|
|
124
128
|
required,
|
|
125
129
|
showRequiredAsterisk: required,
|
|
126
130
|
hasError,
|
|
131
|
+
flexShrink: hasScaledLayout ? "1" : void 0,
|
|
127
132
|
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
128
133
|
style: checkboxStyles.text
|
|
129
134
|
});
|
|
@@ -131,6 +136,7 @@ const Checkbox = memo(function Checkbox({ label, labelPosition = "start", varian
|
|
|
131
136
|
label,
|
|
132
137
|
required,
|
|
133
138
|
hasError,
|
|
139
|
+
hasScaledLayout,
|
|
134
140
|
resolvedMaxFontSizeMultiplier,
|
|
135
141
|
checkboxStyles.text
|
|
136
142
|
]);
|
|
@@ -147,7 +153,8 @@ const Checkbox = memo(function Checkbox({ label, labelPosition = "start", varian
|
|
|
147
153
|
disabled,
|
|
148
154
|
flexDirection: labelPosition === "start" ? "row" : "row-reverse",
|
|
149
155
|
alignItems: "center",
|
|
150
|
-
alignSelf: "flex-start",
|
|
156
|
+
alignSelf: hasScaledLayout ? "stretch" : "flex-start",
|
|
157
|
+
minHeight: hasScaledLayout ? 52 : void 0,
|
|
151
158
|
accessibilityRole: "checkbox",
|
|
152
159
|
accessibilityState: a11yState,
|
|
153
160
|
accessibilityLabel: typeof label === "string" ? label : void 0,
|
|
@@ -160,7 +167,10 @@ const Checkbox = memo(function Checkbox({ label, labelPosition = "start", varian
|
|
|
160
167
|
size: "sm",
|
|
161
168
|
dangerouslySetSize: scaledMarkSize,
|
|
162
169
|
allowFontScaling: false,
|
|
163
|
-
style: checkboxStyles.checkboxIcon
|
|
170
|
+
style: [checkboxStyles.checkboxIcon, markScaleFactor !== 1 ? {
|
|
171
|
+
fontSize: scaledMarkSize,
|
|
172
|
+
lineHeight: getSafeIconCell(scaledMarkSize)
|
|
173
|
+
} : void 0]
|
|
164
174
|
})
|
|
165
175
|
}), labelContent]
|
|
166
176
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import { ICON_SIZE_MAP } from '@yahoo/uds-icons/tokens';\nimport type { CheckboxValue, CheckboxVariant, UniversalCheckboxProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withSpring } from 'react-native-reanimated';\n\nimport { checkboxStyles } from '../../generated/styles';\nimport { useFontScale } from '../fontScaling/useFontScale';\nimport { useMaxFontSizeMultiplier } from '../fontScaling/useMaxFontSizeMultiplier';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { FormLabel } from './FormLabel';\nimport { Icon } from './Icon';\nimport { Pressable } from './Pressable';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from CheckboxValue - maps boolean to 'checked'/'unchecked' string literals */\ntype CheckboxValueState = Exclude<CheckboxValue, boolean> | 'checked' | 'unchecked';\n\ninterface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the checkbox is required */\n required?: boolean;\n /**\n * Caps how far the box, checkmark, and label grow with the OS text-size\n * setting; all three scale by the same factor. Set null to remove the cap;\n * override app-wide via UDSFontScalingProvider.\n * @default 2\n */\n maxFontSizeMultiplier?: number | null;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype CheckboxStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<CheckboxVariant, CheckboxStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Checkbox Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A checkbox component**\n *\n * @description\n * A checkbox component allows users to select one or multiple options from a set.\n * It represents a binary state, typically as checked or unchecked, and optionally\n * includes a third \"indeterminate\" state to indicate partial selection.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Checkbox } from '@yahoo/uds-mobile/Checkbox';\n *\n * <Checkbox label=\"Agree to terms\" />\n * <Checkbox label=\"Subscribe\" checked={true} onChange={setChecked} />\n * <Checkbox label=\"Partial\" checked=\"indeterminate\" />\n * ```\n *\n * @usage\n * - Forms: For selecting options\n * - Settings: For toggling preferences\n * - Filters: For multi-select filtering\n *\n * @accessibility\n * - Sets `accessibilityRole=\"checkbox\"` automatically\n * - Announces checked/unchecked/mixed state\n * - Label is used as accessibility label\n * - Supports `reduceMotion` for users who prefer reduced motion\n *\n * @see {@link Radio} for single-select options\n * @see {@link Switch} for binary toggles\n */\nconst Checkbox = memo(function Checkbox({\n // Checkbox props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n maxFontSizeMultiplier,\n onChange,\n ref,\n ...viewProps\n}: CheckboxProps) {\n const generatedId = useId();\n const uid = `uds-checkbox-${generatedId}`;\n\n // One capped factor governs box, checkmark, and label so they stay cohesive.\n const resolvedMaxFontSizeMultiplier =\n useMaxFontSizeMultiplier('control', maxFontSizeMultiplier) ?? 0;\n const fontScaleFactor = useFontScale(resolvedMaxFontSizeMultiplier);\n // The check/minus glyph is drawn at the 'sm' icon size; scale it in step with\n // the box rather than letting native font scaling size it independently.\n const scaledMarkSize = Math.round(ICON_SIZE_MAP.sm * fontScaleFactor);\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<CheckboxValue>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: CheckboxValueState = useMemo(() => {\n if (checked === 'indeterminate') {\n return 'indeterminate';\n }\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n const iconName = valueState === 'indeterminate' ? 'Minus' : 'Check';\n const showIcon = valueState !== 'unchecked';\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n const checkboxAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = checked === 'indeterminate' ? true : !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: CheckboxStyleVariant = hasError\n ? VARIANT_ERROR_MAP[variantProp]\n : variantProp;\n\n checkboxStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked, indeterminate\n disabled,\n pressed,\n });\n\n const rootStyle = useMemo(\n () => [checkboxStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [checkboxStyles.root, disabled],\n );\n\n const checkboxBoxStyle = useMemo(() => {\n // The box grows by the capped factor to keep containing the checkmark.\n // borderWidth stays fixed (stroke weight doesn't scale in the OS's own\n // controls either).\n const { width, height, borderRadius } = checkboxStyles.checkbox;\n const scaledBox =\n fontScaleFactor !== 1 && typeof width === 'number' && typeof height === 'number'\n ? {\n width: Math.round(width * fontScaleFactor),\n height: Math.round(height * fontScaleFactor),\n ...(typeof borderRadius === 'number' && {\n borderRadius: Math.round(borderRadius * fontScaleFactor),\n }),\n }\n : undefined;\n\n return [\n checkboxStyles.checkbox,\n scaledBox,\n { alignItems: 'center' as const, justifyContent: 'center' as const },\n checkboxAnimatedStyle,\n ];\n }, [checkboxStyles.checkbox, fontScaleFactor, checkboxAnimatedStyle]);\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n return (\n <FormLabel\n color=\"inherit\"\n variant=\"inherit\"\n label={label}\n required={required}\n showRequiredAsterisk={required}\n hasError={hasError}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={checkboxStyles.text}\n />\n );\n }, [label, required, hasError, resolvedMaxFontSizeMultiplier, checkboxStyles.text]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked:\n valueState === 'checked'\n ? true\n : valueState === 'indeterminate'\n ? ('mixed' as const)\n : false,\n }),\n [disabled, valueState],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf=\"flex-start\"\n accessibilityRole=\"checkbox\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={checkboxBoxStyle}>\n {showIcon && (\n <Icon\n name={iconName}\n size=\"sm\"\n // Size the mark from the same factor that scaled the box, with\n // native scaling off: letting the box scale in JS while the glyph\n // scaled natively left the two to round independently (and to\n // disagree outright under Android's non-linear scaling), which\n // drifted the mark off-centre as sizes grew.\n dangerouslySetSize={scaledMarkSize}\n allowFontScaling={false}\n style={checkboxStyles.checkboxIcon}\n />\n )}\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport { Checkbox, type CheckboxProps };\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import { ICON_SIZE_MAP } from '@yahoo/uds-icons/tokens';\nimport type { CheckboxValue, CheckboxVariant, UniversalCheckboxProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withSpring } from 'react-native-reanimated';\n\nimport { checkboxStyles } from '../../generated/styles';\nimport { useComponentFontScale } from '../fontScaling/useFontScale';\nimport { useMaxFontSizeMultiplier } from '../fontScaling/useMaxFontSizeMultiplier';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { getSafeIconCell } from './Button/buttonTheme';\nimport { FormLabel } from './FormLabel';\nimport { Icon } from './Icon';\nimport { Pressable } from './Pressable';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from CheckboxValue - maps boolean to 'checked'/'unchecked' string literals */\ntype CheckboxValueState = Exclude<CheckboxValue, boolean> | 'checked' | 'unchecked';\n\ninterface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the checkbox is required */\n required?: boolean;\n /**\n * Caps how far the box, checkmark, and label grow with the OS text-size\n * setting; all three scale by the same factor. Set null to remove the cap;\n * override app-wide via UDSFontScalingProvider.\n * @default 2\n */\n maxFontSizeMultiplier?: number | null;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype CheckboxStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<CheckboxVariant, CheckboxStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Checkbox Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A checkbox component**\n *\n * @description\n * A checkbox component allows users to select one or multiple options from a set.\n * It represents a binary state, typically as checked or unchecked, and optionally\n * includes a third \"indeterminate\" state to indicate partial selection.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Checkbox } from '@yahoo/uds-mobile/Checkbox';\n *\n * <Checkbox label=\"Agree to terms\" />\n * <Checkbox label=\"Subscribe\" checked={true} onChange={setChecked} />\n * <Checkbox label=\"Partial\" checked=\"indeterminate\" />\n * ```\n *\n * @usage\n * - Forms: For selecting options\n * - Settings: For toggling preferences\n * - Filters: For multi-select filtering\n *\n * @accessibility\n * - Sets `accessibilityRole=\"checkbox\"` automatically\n * - Announces checked/unchecked/mixed state\n * - Label is used as accessibility label\n * - Supports `reduceMotion` for users who prefer reduced motion\n *\n * @see {@link Radio} for single-select options\n * @see {@link Switch} for binary toggles\n */\nconst Checkbox = memo(function Checkbox({\n // Checkbox props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n maxFontSizeMultiplier,\n onChange,\n ref,\n ...viewProps\n}: CheckboxProps) {\n const generatedId = useId();\n const uid = `uds-checkbox-${generatedId}`;\n\n // One resolved cap governs box, checkmark, and label. Android may resolve a\n // slightly different nonlinear factor for each base size.\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<CheckboxValue>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: CheckboxValueState = useMemo(() => {\n if (checked === 'indeterminate') {\n return 'indeterminate';\n }\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n const iconName = valueState === 'indeterminate' ? 'Minus' : 'Check';\n const showIcon = valueState !== 'unchecked';\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n const checkboxAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = checked === 'indeterminate' ? true : !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: CheckboxStyleVariant = hasError\n ? VARIANT_ERROR_MAP[variantProp]\n : variantProp;\n\n checkboxStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked, indeterminate\n disabled,\n pressed,\n });\n\n const boxBaseSize = checkboxStyles.checkbox.width;\n const fontScaleFactor = useComponentFontScale(\n resolvedMaxFontSizeMultiplier,\n typeof boxBaseSize === 'number' ? boxBaseSize : undefined,\n );\n // The check/minus glyph is drawn at the 'sm' icon size; use its own native\n // Android curve before disabling native scaling on the manually-sized glyph.\n const markScaleFactor = useComponentFontScale(resolvedMaxFontSizeMultiplier, ICON_SIZE_MAP.sm);\n const scaledMarkSize = Math.round(ICON_SIZE_MAP.sm * markScaleFactor);\n const hasScaledLayout = fontScaleFactor !== 1;\n\n const rootStyle = useMemo(\n () => [checkboxStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [checkboxStyles.root, disabled],\n );\n\n const checkboxBoxStyle = useMemo(() => {\n // The box grows by the capped factor to keep containing the checkmark.\n // borderWidth stays fixed (stroke weight doesn't scale in the OS's own\n // controls either).\n const { width, height, borderRadius } = checkboxStyles.checkbox;\n const scaledBox =\n fontScaleFactor !== 1 && typeof width === 'number' && typeof height === 'number'\n ? {\n width: Math.round(width * fontScaleFactor),\n height: Math.round(height * fontScaleFactor),\n ...(typeof borderRadius === 'number' && {\n borderRadius: Math.round(borderRadius * fontScaleFactor),\n }),\n }\n : undefined;\n\n return [\n checkboxStyles.checkbox,\n scaledBox,\n { alignItems: 'center' as const, justifyContent: 'center' as const },\n checkboxAnimatedStyle,\n ];\n }, [checkboxStyles.checkbox, fontScaleFactor, checkboxAnimatedStyle]);\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n return (\n <FormLabel\n color=\"inherit\"\n variant=\"inherit\"\n label={label}\n required={required}\n showRequiredAsterisk={required}\n hasError={hasError}\n flexShrink={hasScaledLayout ? '1' : undefined}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={checkboxStyles.text}\n />\n );\n }, [\n label,\n required,\n hasError,\n hasScaledLayout,\n resolvedMaxFontSizeMultiplier,\n checkboxStyles.text,\n ]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked:\n valueState === 'checked'\n ? true\n : valueState === 'indeterminate'\n ? ('mixed' as const)\n : false,\n }),\n [disabled, valueState],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf={hasScaledLayout ? 'stretch' : 'flex-start'}\n minHeight={hasScaledLayout ? 52 : undefined}\n accessibilityRole=\"checkbox\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={checkboxBoxStyle}>\n {showIcon && (\n <Icon\n name={iconName}\n size=\"sm\"\n // Size the mark from the same factor that scaled the box, with\n // native scaling off: letting the box scale in JS while the glyph\n // scaled natively left the two to round independently (and to\n // disagree outright under Android's non-linear scaling), which\n // drifted the mark off-centre as sizes grew.\n dangerouslySetSize={scaledMarkSize}\n allowFontScaling={false}\n style={[\n checkboxStyles.checkboxIcon,\n markScaleFactor !== 1\n ? {\n fontSize: scaledMarkSize,\n lineHeight: getSafeIconCell(scaledMarkSize),\n }\n : undefined,\n ]}\n />\n )}\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport { Checkbox, type CheckboxProps };\n"],"mappings":"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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
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_useFontScale = require("../../fontScaling/useFontScale.cjs");
|
|
4
5
|
const require_fontScaling_useMaxFontSizeMultiplier = require("../../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
5
6
|
const require_components_IconSlot = require("../IconSlot.cjs");
|
|
6
7
|
const require_components_Text = require("../Text.cjs");
|
|
7
|
-
const require_fontScaling_useFontScale = require("../../fontScaling/useFontScale.cjs");
|
|
8
8
|
const require_components_Chip_chipTheme = require("./chipTheme.cjs");
|
|
9
9
|
let react = require("react");
|
|
10
10
|
let react_native = require("react-native");
|
|
@@ -19,15 +19,30 @@ const ChipBase = (0, react.memo)(function ChipBase({ kind, toggleState = DEFAULT
|
|
|
19
19
|
const { theme } = (0, react_native_unistyles.useUnistyles)();
|
|
20
20
|
const [pressed, setPressed] = (0, react.useState)(false);
|
|
21
21
|
const interactionState = pressed ? "pressed" : "rest";
|
|
22
|
-
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier)
|
|
23
|
-
const
|
|
22
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
23
|
+
const rootLayerStyle = (0, react.useMemo)(() => require_components_Chip_chipTheme.getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "root", interactionState), [
|
|
24
|
+
interactionState,
|
|
25
|
+
kind,
|
|
26
|
+
size,
|
|
27
|
+
theme,
|
|
28
|
+
toggleState,
|
|
29
|
+
variant
|
|
30
|
+
]);
|
|
31
|
+
const textLayerStyle = (0, react.useMemo)(() => require_components_Chip_chipTheme.getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "rootText", interactionState), [
|
|
32
|
+
interactionState,
|
|
33
|
+
kind,
|
|
34
|
+
size,
|
|
35
|
+
theme,
|
|
36
|
+
toggleState,
|
|
37
|
+
variant
|
|
38
|
+
]);
|
|
39
|
+
const fontScaleFactor = require_fontScaling_useFontScale.useComponentFontScale(resolvedMaxFontSizeMultiplier, (typeof textLayerStyle.lineHeight === "number" ? textLayerStyle.lineHeight : void 0) ?? (typeof textLayerStyle.fontSize === "number" ? textLayerStyle.fontSize : void 0));
|
|
24
40
|
const rootStyle = (0, react.useMemo)(() => {
|
|
25
|
-
const
|
|
26
|
-
const scaledLayer = fontScaleFactor !== 1 && typeof layerStyle.height === "number" ? { height: Math.round(layerStyle.height * fontScaleFactor) } : void 0;
|
|
41
|
+
const scaledLayer = fontScaleFactor !== 1 && typeof rootLayerStyle.height === "number" ? { height: Math.round(rootLayerStyle.height * fontScaleFactor) } : void 0;
|
|
27
42
|
const resolvedMaxWidth = maxWidth === 200 ? Math.round(maxWidth * fontScaleFactor) : maxWidth;
|
|
28
43
|
return [
|
|
29
44
|
chipStaticStyles.root,
|
|
30
|
-
|
|
45
|
+
rootLayerStyle,
|
|
31
46
|
scaledLayer,
|
|
32
47
|
minWidth === void 0 ? void 0 : { minWidth },
|
|
33
48
|
resolvedMaxWidth === void 0 ? void 0 : { maxWidth: resolvedMaxWidth },
|
|
@@ -37,24 +52,12 @@ const ChipBase = (0, react.memo)(function ChipBase({ kind, toggleState = DEFAULT
|
|
|
37
52
|
}, [
|
|
38
53
|
disabled,
|
|
39
54
|
fontScaleFactor,
|
|
40
|
-
interactionState,
|
|
41
|
-
kind,
|
|
42
55
|
maxWidth,
|
|
43
56
|
minWidth,
|
|
44
|
-
|
|
45
|
-
style
|
|
46
|
-
theme,
|
|
47
|
-
toggleState,
|
|
48
|
-
variant
|
|
49
|
-
]);
|
|
50
|
-
const textStyle = (0, react.useMemo)(() => [chipStaticStyles.text, require_components_Chip_chipTheme.getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "rootText", interactionState)], [
|
|
51
|
-
interactionState,
|
|
52
|
-
kind,
|
|
53
|
-
size,
|
|
54
|
-
theme,
|
|
55
|
-
toggleState,
|
|
56
|
-
variant
|
|
57
|
+
rootLayerStyle,
|
|
58
|
+
style
|
|
57
59
|
]);
|
|
60
|
+
const textStyle = (0, react.useMemo)(() => [chipStaticStyles.text, textLayerStyle], [textLayerStyle]);
|
|
58
61
|
const iconStyle = (0, react.useMemo)(() => require_components_Chip_chipTheme.getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "icon", interactionState), [
|
|
59
62
|
interactionState,
|
|
60
63
|
kind,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { useComponentFontScale } from "../../fontScaling/useFontScale.js";
|
|
2
3
|
import { useMaxFontSizeMultiplier } from "../../fontScaling/useMaxFontSizeMultiplier.js";
|
|
3
4
|
import { IconSlot } from "../IconSlot.js";
|
|
4
5
|
import { Text as Text$1 } from "../Text.js";
|
|
5
|
-
import { useFontScale } from "../../fontScaling/useFontScale.js";
|
|
6
6
|
import { getMergedChipLayerStyle } from "./chipTheme.js";
|
|
7
7
|
import { memo, useMemo, useState } from "react";
|
|
8
8
|
import { Pressable, StyleSheet, View } from "react-native";
|
|
@@ -17,15 +17,30 @@ const ChipBase = memo(function ChipBase({ kind, toggleState = DEFAULT_TOGGLE_STA
|
|
|
17
17
|
const { theme } = useUnistyles();
|
|
18
18
|
const [pressed, setPressed] = useState(false);
|
|
19
19
|
const interactionState = pressed ? "pressed" : "rest";
|
|
20
|
-
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier)
|
|
21
|
-
const
|
|
20
|
+
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
21
|
+
const rootLayerStyle = useMemo(() => getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "root", interactionState), [
|
|
22
|
+
interactionState,
|
|
23
|
+
kind,
|
|
24
|
+
size,
|
|
25
|
+
theme,
|
|
26
|
+
toggleState,
|
|
27
|
+
variant
|
|
28
|
+
]);
|
|
29
|
+
const textLayerStyle = useMemo(() => getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "rootText", interactionState), [
|
|
30
|
+
interactionState,
|
|
31
|
+
kind,
|
|
32
|
+
size,
|
|
33
|
+
theme,
|
|
34
|
+
toggleState,
|
|
35
|
+
variant
|
|
36
|
+
]);
|
|
37
|
+
const fontScaleFactor = useComponentFontScale(resolvedMaxFontSizeMultiplier, (typeof textLayerStyle.lineHeight === "number" ? textLayerStyle.lineHeight : void 0) ?? (typeof textLayerStyle.fontSize === "number" ? textLayerStyle.fontSize : void 0));
|
|
22
38
|
const rootStyle = useMemo(() => {
|
|
23
|
-
const
|
|
24
|
-
const scaledLayer = fontScaleFactor !== 1 && typeof layerStyle.height === "number" ? { height: Math.round(layerStyle.height * fontScaleFactor) } : void 0;
|
|
39
|
+
const scaledLayer = fontScaleFactor !== 1 && typeof rootLayerStyle.height === "number" ? { height: Math.round(rootLayerStyle.height * fontScaleFactor) } : void 0;
|
|
25
40
|
const resolvedMaxWidth = maxWidth === 200 ? Math.round(maxWidth * fontScaleFactor) : maxWidth;
|
|
26
41
|
return [
|
|
27
42
|
chipStaticStyles.root,
|
|
28
|
-
|
|
43
|
+
rootLayerStyle,
|
|
29
44
|
scaledLayer,
|
|
30
45
|
minWidth === void 0 ? void 0 : { minWidth },
|
|
31
46
|
resolvedMaxWidth === void 0 ? void 0 : { maxWidth: resolvedMaxWidth },
|
|
@@ -35,24 +50,12 @@ const ChipBase = memo(function ChipBase({ kind, toggleState = DEFAULT_TOGGLE_STA
|
|
|
35
50
|
}, [
|
|
36
51
|
disabled,
|
|
37
52
|
fontScaleFactor,
|
|
38
|
-
interactionState,
|
|
39
|
-
kind,
|
|
40
53
|
maxWidth,
|
|
41
54
|
minWidth,
|
|
42
|
-
|
|
43
|
-
style
|
|
44
|
-
theme,
|
|
45
|
-
toggleState,
|
|
46
|
-
variant
|
|
47
|
-
]);
|
|
48
|
-
const textStyle = useMemo(() => [chipStaticStyles.text, getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "rootText", interactionState)], [
|
|
49
|
-
interactionState,
|
|
50
|
-
kind,
|
|
51
|
-
size,
|
|
52
|
-
theme,
|
|
53
|
-
toggleState,
|
|
54
|
-
variant
|
|
55
|
+
rootLayerStyle,
|
|
56
|
+
style
|
|
55
57
|
]);
|
|
58
|
+
const textStyle = useMemo(() => [chipStaticStyles.text, textLayerStyle], [textLayerStyle]);
|
|
56
59
|
const iconStyle = useMemo(() => getMergedChipLayerStyle(theme, kind, variant, size, toggleState, "icon", interactionState), [
|
|
57
60
|
interactionState,
|
|
58
61
|
kind,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChipBase.js","names":["Text"],"sources":["../../../src/components/Chip/ChipBase.tsx"],"sourcesContent":["import { memo, useMemo, useState } from 'react';\nimport type { StyleProp, TextStyle, ViewStyle } from 'react-native';\nimport { Pressable, StyleSheet, View } from 'react-native';\n// eslint-disable-next-line uds/no-use-unistyles -- chip toggle styles need variant + active token lookups\nimport { useUnistyles } from 'react-native-unistyles';\n\nimport {
|
|
1
|
+
{"version":3,"file":"ChipBase.js","names":["Text"],"sources":["../../../src/components/Chip/ChipBase.tsx"],"sourcesContent":["import { memo, useMemo, useState } from 'react';\nimport type { StyleProp, TextStyle, ViewStyle } from 'react-native';\nimport { Pressable, StyleSheet, View } from 'react-native';\n// eslint-disable-next-line uds/no-use-unistyles -- chip toggle styles need variant + active token lookups\nimport { useUnistyles } from 'react-native-unistyles';\n\nimport { useComponentFontScale } from '../../fontScaling/useFontScale';\nimport { useMaxFontSizeMultiplier } from '../../fontScaling/useMaxFontSizeMultiplier';\nimport { IconSlot } from '../IconSlot';\nimport { Text } from '../Text';\nimport { getMergedChipLayerStyle } from './chipTheme';\nimport type { ChipBaseProps, ChipInteractionState, ChipSize, ChipVariant } from './types';\n\nconst DEFAULT_CHIP_SIZE: ChipSize = 'md';\nconst DEFAULT_CHIP_VARIANT: ChipVariant = 'primary';\nconst DEFAULT_MAX_WIDTH = 200;\nconst DEFAULT_TOGGLE_STATE = 'off';\n\nconst ChipBase = memo(function ChipBase({\n kind,\n toggleState = DEFAULT_TOGGLE_STATE,\n variant = DEFAULT_CHIP_VARIANT,\n size = DEFAULT_CHIP_SIZE,\n minWidth,\n maxWidth = DEFAULT_MAX_WIDTH,\n startIcon,\n endIcon,\n endContent,\n disabled = false,\n pressable = false,\n maxFontSizeMultiplier,\n onPress,\n accessibilityRole,\n accessibilityState,\n children,\n style,\n ref,\n ...viewProps\n}: ChipBaseProps) {\n const { theme } = useUnistyles();\n const [pressed, setPressed] = useState(false);\n const interactionState: ChipInteractionState = pressed ? 'pressed' : 'rest';\n\n // One capped factor governs the label, icons, and the chip's fixed height.\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n const rootLayerStyle = useMemo(\n () =>\n getMergedChipLayerStyle(\n theme,\n kind,\n variant,\n size,\n toggleState,\n 'root',\n interactionState,\n ) as ViewStyle,\n [interactionState, kind, size, theme, toggleState, variant],\n );\n const textLayerStyle = useMemo(\n () =>\n getMergedChipLayerStyle(\n theme,\n kind,\n variant,\n size,\n toggleState,\n 'rootText',\n interactionState,\n ) as TextStyle,\n [interactionState, kind, size, theme, toggleState, variant],\n );\n const fontScaleFactor = useComponentFontScale(\n resolvedMaxFontSizeMultiplier,\n (typeof textLayerStyle.lineHeight === 'number' ? textLayerStyle.lineHeight : undefined) ??\n (typeof textLayerStyle.fontSize === 'number' ? textLayerStyle.fontSize : undefined),\n );\n\n const rootStyle = useMemo<StyleProp<ViewStyle>>(() => {\n // The chip's fixed height grows with its capped content; the default max\n // width grows too so capped labels don't truncate earlier than today. An\n // explicit maxWidth/minWidth from the consumer is respected as-is.\n const scaledLayer =\n fontScaleFactor !== 1 && typeof rootLayerStyle.height === 'number'\n ? { height: Math.round(rootLayerStyle.height * fontScaleFactor) }\n : undefined;\n const resolvedMaxWidth =\n maxWidth === DEFAULT_MAX_WIDTH ? Math.round(maxWidth * fontScaleFactor) : maxWidth;\n\n return [\n chipStaticStyles.root,\n rootLayerStyle,\n scaledLayer,\n minWidth === undefined ? undefined : { minWidth },\n resolvedMaxWidth === undefined ? undefined : { maxWidth: resolvedMaxWidth },\n disabled ? chipStaticStyles.disabled : undefined,\n style,\n ];\n }, [disabled, fontScaleFactor, maxWidth, minWidth, rootLayerStyle, style]);\n\n const textStyle = useMemo<StyleProp<TextStyle>>(\n () => [chipStaticStyles.text, textLayerStyle],\n [textLayerStyle],\n );\n\n const iconStyle = useMemo<StyleProp<TextStyle>>(\n () =>\n getMergedChipLayerStyle(\n theme,\n kind,\n variant,\n size,\n toggleState,\n 'icon',\n interactionState,\n ) as TextStyle,\n [interactionState, kind, size, theme, toggleState, variant],\n );\n\n const content = (\n <>\n {startIcon ? (\n <IconSlot\n icon={startIcon}\n variant=\"fill\"\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={iconStyle}\n />\n ) : null}\n <Text\n color=\"inherit\"\n variant=\"inherit\"\n numberOfLines={1}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={textStyle}\n >\n {children}\n </Text>\n {endContent ??\n (endIcon ? (\n <IconSlot\n icon={endIcon}\n variant=\"fill\"\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n style={iconStyle}\n />\n ) : null)}\n </>\n );\n\n if (pressable) {\n return (\n <Pressable\n ref={ref}\n accessibilityRole={accessibilityRole}\n accessibilityState={{ disabled, ...accessibilityState }}\n disabled={disabled}\n onPress={disabled ? undefined : onPress}\n onPressIn={() => setPressed(true)}\n onPressOut={() => setPressed(false)}\n {...viewProps}\n style={rootStyle}\n >\n {content}\n </Pressable>\n );\n }\n\n return (\n <View\n ref={ref}\n accessibilityRole={accessibilityRole}\n accessibilityState={{ disabled, ...accessibilityState }}\n {...viewProps}\n style={rootStyle}\n >\n {content}\n </View>\n );\n});\n\nChipBase.displayName = 'ChipBase';\n\nconst chipStaticStyles = StyleSheet.create({\n disabled: {\n opacity: 0.5,\n },\n root: {\n alignItems: 'center',\n alignSelf: 'flex-start',\n flexDirection: 'row',\n overflow: 'hidden',\n },\n text: {\n flexShrink: 1,\n textAlign: 'center',\n },\n});\n\nexport { ChipBase, DEFAULT_CHIP_SIZE, DEFAULT_CHIP_VARIANT, DEFAULT_MAX_WIDTH };\n"],"mappings":"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"}
|
package/dist/components/Icon.cjs
CHANGED
|
@@ -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_useFontScale = require("../fontScaling/useFontScale.cjs");
|
|
4
5
|
const require_fontScaling_useMaxFontSizeMultiplier = require("../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
5
6
|
const require_components_Button_buttonTheme = require("./Button/buttonTheme.cjs");
|
|
6
7
|
let react = require("react");
|
|
@@ -24,10 +25,14 @@ const DEFAULT_PROPS = {
|
|
|
24
25
|
* Uses useUnistyles() for reactive theme access - isolated here so
|
|
25
26
|
* glyph-based icons don't pay the hook overhead.
|
|
26
27
|
*/
|
|
27
|
-
const MulticolorIcon = (0, react.memo)(function MulticolorIcon({ name, size = DEFAULT_PROPS.size, flexShrink = DEFAULT_PROPS.flexShrink, backgroundColor, dangerouslySetSize }) {
|
|
28
|
+
const MulticolorIcon = (0, react.memo)(function MulticolorIcon({ name, size = DEFAULT_PROPS.size, flexShrink = DEFAULT_PROPS.flexShrink, backgroundColor, dangerouslySetSize, maxFontSizeMultiplier, inheritFontScaling = false, allowFontScaling = true, accessible, accessibilityElementsHidden, accessibilityHint, accessibilityLabel = name, accessibilityRole = "image", accessibilityState, accessibilityValue, importantForAccessibility, testID }) {
|
|
28
29
|
const { rt } = (0, react_native_unistyles.useUnistyles)();
|
|
29
30
|
const colorScheme = rt.themeName === "dark" ? "dark" : "light";
|
|
30
31
|
const pixelSize = _yahoo_uds_icons_tokens.ICON_SIZE_MAP[size];
|
|
32
|
+
const baseSize = dangerouslySetSize ?? pixelSize;
|
|
33
|
+
const controlMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
34
|
+
const fontScaleFactor = require_fontScaling_useFontScale.useComponentFontScale(allowFontScaling ? inheritFontScaling && maxFontSizeMultiplier === void 0 ? void 0 : controlMaxFontSizeMultiplier : 1, baseSize);
|
|
35
|
+
const renderedSize = Math.round(baseSize * fontScaleFactor);
|
|
31
36
|
const svgKey = `${name}-${colorScheme}-${pixelSize}`;
|
|
32
37
|
const svgContent = _yahoo_uds_icons_svgMap.svgMap[svgKey];
|
|
33
38
|
if (!svgContent) {
|
|
@@ -39,17 +44,28 @@ const MulticolorIcon = (0, react.memo)(function MulticolorIcon({ name, size = DE
|
|
|
39
44
|
backgroundColor
|
|
40
45
|
});
|
|
41
46
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native.View, {
|
|
47
|
+
accessible,
|
|
48
|
+
accessibilityElementsHidden,
|
|
49
|
+
accessibilityHint,
|
|
50
|
+
accessibilityLabel,
|
|
51
|
+
accessibilityRole,
|
|
52
|
+
accessibilityState,
|
|
53
|
+
accessibilityValue,
|
|
54
|
+
importantForAccessibility,
|
|
55
|
+
testID,
|
|
42
56
|
style: generated_styles.styles.foundation,
|
|
43
57
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_native_svg.SvgXml, {
|
|
44
58
|
xml: svgContent,
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
59
|
+
width: renderedSize,
|
|
60
|
+
height: renderedSize,
|
|
61
|
+
viewBox: `0 0 ${pixelSize} ${pixelSize}`
|
|
47
62
|
})
|
|
48
63
|
});
|
|
49
64
|
});
|
|
50
|
-
const OutlineOrFillIcon = (0, react.memo)(function OutlineOrFillIcon({ name, size = DEFAULT_PROPS.size, color = DEFAULT_PROPS.color, variant = DEFAULT_PROPS.variant, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, flexShrink = "0", spacingStart, spacingEnd, spacingTop, spacingBottom, spacingHorizontal, spacingVertical, spacing, offsetStart, offsetEnd, offsetTop, offsetBottom, offsetHorizontal, offsetVertical, offset, dangerouslySetColor, dangerouslySetSize, maxFontSizeMultiplier, style, ref, ...props }) {
|
|
65
|
+
const OutlineOrFillIcon = (0, react.memo)(function OutlineOrFillIcon({ name, size = DEFAULT_PROPS.size, color = DEFAULT_PROPS.color, variant = DEFAULT_PROPS.variant, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, flexShrink = "0", spacingStart, spacingEnd, spacingTop, spacingBottom, spacingHorizontal, spacingVertical, spacing, offsetStart, offsetEnd, offsetTop, offsetBottom, offsetHorizontal, offsetVertical, offset, dangerouslySetColor, dangerouslySetSize, maxFontSizeMultiplier, inheritFontScaling = false, style, ref, ...props }) {
|
|
51
66
|
const pixelSize = _yahoo_uds_icons_tokens.ICON_SIZE_MAP[size];
|
|
52
|
-
const
|
|
67
|
+
const controlMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
68
|
+
const resolvedMaxFontSizeMultiplier = inheritFontScaling && maxFontSizeMultiplier === void 0 ? void 0 : controlMaxFontSizeMultiplier;
|
|
53
69
|
generated_styles.styles.useVariants({
|
|
54
70
|
color,
|
|
55
71
|
backgroundColor,
|
|
@@ -119,7 +135,7 @@ const OutlineOrFillIcon = (0, react.memo)(function OutlineOrFillIcon({ name, siz
|
|
|
119
135
|
});
|
|
120
136
|
});
|
|
121
137
|
/**
|
|
122
|
-
* **🎨 An icon component using UDS icon fonts**
|
|
138
|
+
* **🎨 An icon component using UDS icon fonts and multicolor SVGs**
|
|
123
139
|
*
|
|
124
140
|
* @description
|
|
125
141
|
* Renders icons from the UDS icon library. Supports multiple variants
|
|
@@ -21,13 +21,14 @@ interface IconProps extends Omit<TextProps, 'style'> {
|
|
|
21
21
|
/** Icon variant (outline, fill, multicolor) */
|
|
22
22
|
variant?: IconVariant;
|
|
23
23
|
/**
|
|
24
|
-
* Caps how far the
|
|
25
|
-
* remove the cap; override
|
|
26
|
-
*
|
|
27
|
-
* with useFontScale if needed.
|
|
24
|
+
* Caps how far the icon grows with the OS text-size setting. Applies to both
|
|
25
|
+
* font glyphs and multicolor SVGs. Set null to remove the cap; override
|
|
26
|
+
* app-wide via UDSFontScalingProvider.
|
|
28
27
|
* @default 2
|
|
29
28
|
*/
|
|
30
29
|
maxFontSizeMultiplier?: number | null;
|
|
30
|
+
/** @internal Inherit a containing Text node's scaling when no cap is supplied. */
|
|
31
|
+
inheritFontScaling?: boolean;
|
|
31
32
|
backgroundColor?: StyleProps['backgroundColor'];
|
|
32
33
|
borderRadius?: StyleProps['borderRadius'];
|
|
33
34
|
borderTopStartRadius?: StyleProps['borderTopStartRadius'];
|
|
@@ -69,7 +70,7 @@ interface IconProps extends Omit<TextProps, 'style'> {
|
|
|
69
70
|
style?: StyleProp<TextStyle>;
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
|
-
* **🎨 An icon component using UDS icon fonts**
|
|
73
|
+
* **🎨 An icon component using UDS icon fonts and multicolor SVGs**
|
|
73
74
|
*
|
|
74
75
|
* @description
|
|
75
76
|
* Renders icons from the UDS icon library. Supports multiple variants
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.cts","names":[],"sources":["../../src/components/Icon.tsx"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Icon.d.cts","names":[],"sources":["../../src/components/Icon.tsx"],"mappings":";;;;;;;;;;KAqCK,QAAA,GAAW,SAAA,GAAY,YAAA;AAAA,UAElB,SAAA,SAAkB,IAAA,CAAK,SAAA;;EAE/B,GAAA,GAAM,GAAA,CAAI,IAAA;EAJC;EAMX,IAAA,EAAM,QAAA;EANQ;EAQd,IAAA,GAAO,QAAA;EANC;EAQR,KAAA,GAAQ,UAAA;;EAER,OAAA,GAAU,WAAA;EARA;;;;;;EAeV,qBAAA;EAMe;EAJf,kBAAA;EAEA,eAAA,GAAkB,UAAA;EAElB,YAAA,GAAe,UAAA;EACf,oBAAA,GAAuB,UAAA;EACvB,kBAAA,GAAqB,UAAA;EACrB,uBAAA,GAA0B,UAAA;EAC1B,qBAAA,GAAwB,UAAA;EACxB,WAAA,GAAc,UAAA;EACd,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EACpB,WAAA,GAAc,UAAA;EACd,mBAAA,GAAsB,UAAA;EACtB,qBAAA,GAAwB,UAAA;EACxB,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EAEpB,UAAA,GAAa,UAAA;EAEb,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EACb,UAAA,GAAa,UAAA;EACb,aAAA,GAAgB,UAAA;EAChB,iBAAA,GAAoB,UAAA;EACpB,eAAA,GAAkB,UAAA;EAClB,OAAA,GAAU,UAAA;EAEV,WAAA,GAAc,UAAA;EACd,SAAA,GAAY,UAAA;EACZ,SAAA,GAAY,UAAA;EACZ,YAAA,GAAe,UAAA;EACf,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,MAAA,GAAS,UAAA;EAzDqB;EA2D9B,mBAAA;EA3D0B;EA6D1B,kBAAA;EA3DA;EA6DA,KAAA,GAAQ,SAAA,CAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8Pd,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA;AAAA,cAaG,SAAA;AAAA,cACA,mBAAA"}
|
|
@@ -21,13 +21,14 @@ interface IconProps extends Omit<TextProps, 'style'> {
|
|
|
21
21
|
/** Icon variant (outline, fill, multicolor) */
|
|
22
22
|
variant?: IconVariant;
|
|
23
23
|
/**
|
|
24
|
-
* Caps how far the
|
|
25
|
-
* remove the cap; override
|
|
26
|
-
*
|
|
27
|
-
* with useFontScale if needed.
|
|
24
|
+
* Caps how far the icon grows with the OS text-size setting. Applies to both
|
|
25
|
+
* font glyphs and multicolor SVGs. Set null to remove the cap; override
|
|
26
|
+
* app-wide via UDSFontScalingProvider.
|
|
28
27
|
* @default 2
|
|
29
28
|
*/
|
|
30
29
|
maxFontSizeMultiplier?: number | null;
|
|
30
|
+
/** @internal Inherit a containing Text node's scaling when no cap is supplied. */
|
|
31
|
+
inheritFontScaling?: boolean;
|
|
31
32
|
backgroundColor?: StyleProps['backgroundColor'];
|
|
32
33
|
borderRadius?: StyleProps['borderRadius'];
|
|
33
34
|
borderTopStartRadius?: StyleProps['borderTopStartRadius'];
|
|
@@ -69,7 +70,7 @@ interface IconProps extends Omit<TextProps, 'style'> {
|
|
|
69
70
|
style?: StyleProp<TextStyle>;
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
|
-
* **🎨 An icon component using UDS icon fonts**
|
|
73
|
+
* **🎨 An icon component using UDS icon fonts and multicolor SVGs**
|
|
73
74
|
*
|
|
74
75
|
* @description
|
|
75
76
|
* Renders icons from the UDS icon library. Supports multiple variants
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.d.ts","names":[],"sources":["../../src/components/Icon.tsx"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Icon.d.ts","names":[],"sources":["../../src/components/Icon.tsx"],"mappings":";;;;;;;;;;KAqCK,QAAA,GAAW,SAAA,GAAY,YAAA;AAAA,UAElB,SAAA,SAAkB,IAAA,CAAK,SAAA;;EAE/B,GAAA,GAAM,GAAA,CAAI,IAAA;EAJC;EAMX,IAAA,EAAM,QAAA;EANQ;EAQd,IAAA,GAAO,QAAA;EANC;EAQR,KAAA,GAAQ,UAAA;;EAER,OAAA,GAAU,WAAA;EARA;;;;;;EAeV,qBAAA;EAMe;EAJf,kBAAA;EAEA,eAAA,GAAkB,UAAA;EAElB,YAAA,GAAe,UAAA;EACf,oBAAA,GAAuB,UAAA;EACvB,kBAAA,GAAqB,UAAA;EACrB,uBAAA,GAA0B,UAAA;EAC1B,qBAAA,GAAwB,UAAA;EACxB,WAAA,GAAc,UAAA;EACd,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EACpB,WAAA,GAAc,UAAA;EACd,mBAAA,GAAsB,UAAA;EACtB,qBAAA,GAAwB,UAAA;EACxB,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,cAAA,GAAiB,UAAA;EACjB,iBAAA,GAAoB,UAAA;EAEpB,UAAA,GAAa,UAAA;EAEb,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EACb,UAAA,GAAa,UAAA;EACb,aAAA,GAAgB,UAAA;EAChB,iBAAA,GAAoB,UAAA;EACpB,eAAA,GAAkB,UAAA;EAClB,OAAA,GAAU,UAAA;EAEV,WAAA,GAAc,UAAA;EACd,SAAA,GAAY,UAAA;EACZ,SAAA,GAAY,UAAA;EACZ,YAAA,GAAe,UAAA;EACf,gBAAA,GAAmB,UAAA;EACnB,cAAA,GAAiB,UAAA;EACjB,MAAA,GAAS,UAAA;EAzDqB;EA2D9B,mBAAA;EA3D0B;EA6D1B,kBAAA;EA3DA;EA6DA,KAAA,GAAQ,SAAA,CAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8Pd,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA;AAAA,cAaG,SAAA;AAAA,cACA,mBAAA"}
|