@yahoo/uds-mobile 2.24.0-beta.4 → 2.24.0-beta.6
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/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 +10 -6
- package/dist/components/Button/buttonTheme.d.cts +10 -5
- package/dist/components/Button/buttonTheme.d.cts.map +1 -1
- package/dist/components/Button/buttonTheme.d.ts +10 -5
- package/dist/components/Button/buttonTheme.d.ts.map +1 -1
- package/dist/components/Button/buttonTheme.js +10 -6
- package/dist/components/Button/buttonTheme.js.map +1 -1
- package/dist/components/Button.cjs +22 -9
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.ts.map +1 -1
- package/dist/components/Button.js +22 -9
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +7 -3
- package/dist/components/Checkbox.js +7 -3
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip/ChipBase.cjs +22 -19
- package/dist/components/Chip/ChipBase.js +22 -19
- package/dist/components/Chip/ChipBase.js.map +1 -1
- package/dist/components/Icon.cjs +5 -4
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.ts.map +1 -1
- package/dist/components/Icon.js +5 -4
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/Input.cjs +54 -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 +54 -18
- package/dist/components/Input.js.map +1 -1
- package/dist/components/InputHelpText.cjs +6 -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 +6 -1
- package/dist/components/InputHelpText.js.map +1 -1
- package/dist/components/Link.cjs +10 -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 +10 -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 +2 -1
- package/dist/components/Radio/Radio.js +2 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Select/Select.cjs +11 -2
- 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 +11 -2
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/SelectItem.cjs +26 -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 +26 -15
- package/dist/components/Select/SelectItem.js.map +1 -1
- package/dist/components/Select/SelectTrigger.cjs +28 -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 +28 -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 +5 -3
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.ts.map +1 -1
- package/dist/components/Switch.js +5 -3
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +6 -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 +6 -2
- package/dist/components/Tabs/Tab.js.map +1 -1
- package/dist/components/Text.cjs +4 -0
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.ts.map +1 -1
- package/dist/components/Text.js +4 -0
- package/dist/components/Text.js.map +1 -1
- package/dist/components/UDSProvider.cjs +1 -1
- package/dist/components/UDSProvider.js +1 -1
- package/dist/fontScaling/FontScalingContext.cjs +14 -0
- package/dist/fontScaling/FontScalingContext.d.cts +7 -1
- package/dist/fontScaling/FontScalingContext.d.cts.map +1 -1
- package/dist/fontScaling/FontScalingContext.d.ts +7 -1
- package/dist/fontScaling/FontScalingContext.d.ts.map +1 -1
- package/dist/fontScaling/FontScalingContext.js +15 -2
- package/dist/fontScaling/FontScalingContext.js.map +1 -1
- package/dist/fontScaling/androidNonlinearFontScaling.cjs +174 -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 +175 -0
- package/dist/fontScaling/androidNonlinearFontScaling.js.map +1 -0
- package/dist/fontScaling/constants.cjs +33 -0
- package/dist/fontScaling/constants.d.cts +11 -1
- package/dist/fontScaling/constants.d.cts.map +1 -1
- package/dist/fontScaling/constants.d.ts +11 -1
- package/dist/fontScaling/constants.d.ts.map +1 -1
- package/dist/fontScaling/constants.js +33 -1
- 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/useFontScale.cjs +13 -4
- package/dist/fontScaling/useFontScale.d.cts +8 -3
- package/dist/fontScaling/useFontScale.d.cts.map +1 -1
- package/dist/fontScaling/useFontScale.d.ts +8 -3
- package/dist/fontScaling/useFontScale.d.ts.map +1 -1
- package/dist/fontScaling/useFontScale.js +14 -5
- package/dist/fontScaling/useFontScale.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +13 -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 +13 -1
- package/dist/jest/mocks/styles.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/package.json +1 -1
|
@@ -20,14 +20,29 @@ const ChipBase = (0, react.memo)(function ChipBase({ kind, toggleState = DEFAULT
|
|
|
20
20
|
const [pressed, setPressed] = (0, react.useState)(false);
|
|
21
21
|
const interactionState = pressed ? "pressed" : "rest";
|
|
22
22
|
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier) ?? 0;
|
|
23
|
-
const
|
|
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.useFontScale(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,
|
|
@@ -18,14 +18,29 @@ const ChipBase = memo(function ChipBase({ kind, toggleState = DEFAULT_TOGGLE_STA
|
|
|
18
18
|
const [pressed, setPressed] = useState(false);
|
|
19
19
|
const interactionState = pressed ? "pressed" : "rest";
|
|
20
20
|
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier) ?? 0;
|
|
21
|
-
const
|
|
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 = useFontScale(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 { useFontScale } 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 =\n useMaxFontSizeMultiplier('control', maxFontSizeMultiplier) ?? 0;\n const
|
|
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 { useFontScale } 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 =\n useMaxFontSizeMultiplier('control', maxFontSizeMultiplier) ?? 0;\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 = useFontScale(\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":";;;;;;;;;;;AAaA,MAAM,oBAA8B;AACpC,MAAM,uBAAoC;AAC1C,MAAM,oBAAoB;AAC1B,MAAM,uBAAuB;AAE7B,MAAM,WAAW,KAAK,SAAS,SAAS,EACtC,MACA,cAAc,sBACd,UAAU,sBACV,OAAA,MACA,UACA,WAAA,KACA,WACA,SACA,YACA,WAAW,OACX,YAAY,OACZ,uBACA,SACA,mBACA,oBACA,UACA,OACA,KACA,GAAG,aACa;CAChB,MAAM,EAAE,UAAU,cAAc;CAChC,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAC7C,MAAM,mBAAyC,UAAU,YAAY;CAGrE,MAAM,gCACJ,yBAAyB,WAAW,sBAAsB,IAAI;CAChE,MAAM,iBAAiB,cAEnB,wBACE,OACA,MACA,SACA,MACA,aACA,QACA,iBACD,EACH;EAAC;EAAkB;EAAM;EAAM;EAAO;EAAa;EAAQ,CAC5D;CACD,MAAM,iBAAiB,cAEnB,wBACE,OACA,MACA,SACA,MACA,aACA,YACA,iBACD,EACH;EAAC;EAAkB;EAAM;EAAM;EAAO;EAAa;EAAQ,CAC5D;CACD,MAAM,kBAAkB,aACtB,gCACC,OAAO,eAAe,eAAe,WAAW,eAAe,aAAa,KAAA,OAC1E,OAAO,eAAe,aAAa,WAAW,eAAe,WAAW,KAAA,GAC5E;CAED,MAAM,YAAY,cAAoC;EAIpD,MAAM,cACJ,oBAAoB,KAAK,OAAO,eAAe,WAAW,WACtD,EAAE,QAAQ,KAAK,MAAM,eAAe,SAAS,gBAAgB,EAAE,GAC/D,KAAA;EACN,MAAM,mBACJ,aAAA,MAAiC,KAAK,MAAM,WAAW,gBAAgB,GAAG;EAE5E,OAAO;GACL,iBAAiB;GACjB;GACA;GACA,aAA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AW;EACZ;CACF,CAAC"}
|
package/dist/components/Icon.cjs
CHANGED
|
@@ -29,9 +29,10 @@ const MulticolorIcon = (0, react.memo)(function MulticolorIcon({ name, size = DE
|
|
|
29
29
|
const { rt } = (0, react_native_unistyles.useUnistyles)();
|
|
30
30
|
const colorScheme = rt.themeName === "dark" ? "dark" : "light";
|
|
31
31
|
const pixelSize = _yahoo_uds_icons_tokens.ICON_SIZE_MAP[size];
|
|
32
|
+
const baseSize = dangerouslySetSize ?? pixelSize;
|
|
32
33
|
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
33
|
-
const fontScaleFactor = require_fontScaling_useFontScale.useFontScale(allowFontScaling ? resolvedMaxFontSizeMultiplier : 1);
|
|
34
|
-
const renderedSize = Math.round(
|
|
34
|
+
const fontScaleFactor = require_fontScaling_useFontScale.useFontScale(allowFontScaling ? resolvedMaxFontSizeMultiplier : 1, baseSize);
|
|
35
|
+
const renderedSize = Math.round(baseSize * fontScaleFactor);
|
|
35
36
|
const svgKey = `${name}-${colorScheme}-${pixelSize}`;
|
|
36
37
|
const svgContent = _yahoo_uds_icons_svgMap.svgMap[svgKey];
|
|
37
38
|
if (!svgContent) {
|
|
@@ -114,12 +115,12 @@ const OutlineOrFillIcon = (0, react.memo)(function OutlineOrFillIcon({ name, siz
|
|
|
114
115
|
lineHeight: require_components_Button_buttonTheme.getSafeIconCell(pixelSize)
|
|
115
116
|
},
|
|
116
117
|
generated_styles.styles.foundation,
|
|
118
|
+
style,
|
|
117
119
|
dangerouslySetColor ? { color: dangerouslySetColor } : void 0,
|
|
118
120
|
dangerouslySetSize ? {
|
|
119
121
|
fontSize: dangerouslySetSize,
|
|
120
122
|
lineHeight: require_components_Button_buttonTheme.getSafeIconCell(dangerouslySetSize)
|
|
121
|
-
} : void 0
|
|
122
|
-
style
|
|
123
|
+
} : void 0
|
|
123
124
|
], [
|
|
124
125
|
dangerouslySetCol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Aa,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;EAMD;EAJR,mBAAA;EAzD8B;EA2D9B,kBAAA;EA3D0B;EA6D1B,KAAA,GAAQ,SAAA,CAAU,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoPd,IAAA,EAAI,OAAA,CAAA,oBAAA,CAAA,SAAA;AAAA,cAaG,SAAA;AAAA,cACA,mBAAA"}
|
package/dist/components/Icon.js
CHANGED
|
@@ -27,9 +27,10 @@ const MulticolorIcon = memo(function MulticolorIcon({ name, size = DEFAULT_PROPS
|
|
|
27
27
|
const { rt } = useUnistyles();
|
|
28
28
|
const colorScheme = rt.themeName === "dark" ? "dark" : "light";
|
|
29
29
|
const pixelSize = ICON_SIZE_MAP[size];
|
|
30
|
+
const baseSize = dangerouslySetSize ?? pixelSize;
|
|
30
31
|
const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier("control", maxFontSizeMultiplier);
|
|
31
|
-
const fontScaleFactor = useFontScale(allowFontScaling ? resolvedMaxFontSizeMultiplier : 1);
|
|
32
|
-
const renderedSize = Math.round(
|
|
32
|
+
const fontScaleFactor = useFontScale(allowFontScaling ? resolvedMaxFontSizeMultiplier : 1, baseSize);
|
|
33
|
+
const renderedSize = Math.round(baseSize * fontScaleFactor);
|
|
33
34
|
const svgKey = `${name}-${colorScheme}-${pixelSize}`;
|
|
34
35
|
const svgContent = svgMap[svgKey];
|
|
35
36
|
if (!svgContent) {
|
|
@@ -112,12 +113,12 @@ const OutlineOrFillIcon = memo(function OutlineOrFillIcon({ name, size = DEFAULT
|
|
|
112
113
|
lineHeight: getSafeIconCell(pixelSize)
|
|
113
114
|
},
|
|
114
115
|
styles.foundation,
|
|
116
|
+
style,
|
|
115
117
|
dangerouslySetColor ? { color: dangerouslySetColor } : void 0,
|
|
116
118
|
dangerouslySetSize ? {
|
|
117
119
|
fontSize: dangerouslySetSize,
|
|
118
120
|
lineHeight: getSafeIconCell(dangerouslySetSize)
|
|
119
|
-
} : void 0
|
|
120
|
-
style
|
|
121
|
+
} : void 0
|
|
121
122
|
], [
|
|
122
123
|
dangerouslySetColor,
|
|
123
124
|
dangerouslySetSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Icon.js","names":[],"sources":["../../src/components/Icon.tsx"],"sourcesContent":["import type { GlyphName } from '@yahoo/uds-icons/glyphMap';\nimport { glyphMap, glyphNames } from '@yahoo/uds-icons/glyphMap';\nimport type { SvgGlyphKey, SvgGlyphName } from '@yahoo/uds-icons/svgMap';\nimport { svgGlyphNames, svgMap } from '@yahoo/uds-icons/svgMap';\nimport { ICON_SIZE_MAP } from '@yahoo/uds-icons/tokens';\nimport type { IconSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type {\n StyleProp,\n Text as RNText,\n TextProps as RNTextProps,\n TextStyle,\n ViewProps,\n} from 'react-native';\nimport { Text, View } from 'react-native';\nimport { SvgXml } from 'react-native-svg';\n// eslint-disable-next-line uds/no-use-unistyles\nimport { useUnistyles } from 'react-native-unistyles';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport { useFontScale } from '../fontScaling/useFontScale';\nimport { useMaxFontSizeMultiplier } from '../fontScaling/useMaxFontSizeMultiplier';\nimport { getSafeIconCell } from './Button/buttonTheme';\n\nconst DEFAULT_PROPS = {\n size: 'md',\n color: 'primary',\n variant: 'outline',\n flexShrink: '0',\n} as const;\n\n/* -------------------------------------------------------------------------- */\n/* Icon Props */\n/* -------------------------------------------------------------------------- */\n\ntype IconName = GlyphName | SvgGlyphName;\n\ninterface IconProps extends Omit<RNTextProps, 'style'> {\n /** Ref to the underlying Text element */\n ref?: Ref<RNText>;\n /** The icon name */\n name: IconName;\n /** Icon size */\n size?: IconSize;\n /** Icon color */\n color?: StyleProps['color'];\n /** Icon variant (outline, fill, multicolor) */\n variant?: IconVariant;\n /**\n * Caps how far the icon grows with the OS text-size setting. Applies to both\n * font glyphs and multicolor SVGs. Set null to remove the cap; override\n * app-wide via UDSFontScalingProvider.\n * @default 2\n */\n maxFontSizeMultiplier?: number | null;\n // Background\n backgroundColor?: StyleProps['backgroundColor'];\n // Border\n borderRadius?: StyleProps['borderRadius'];\n borderTopStartRadius?: StyleProps['borderTopStartRadius'];\n borderTopEndRadius?: StyleProps['borderTopEndRadius'];\n borderBottomStartRadius?: StyleProps['borderBottomStartRadius'];\n borderBottomEndRadius?: StyleProps['borderBottomEndRadius'];\n borderColor?: StyleProps['borderColor'];\n borderStartColor?: StyleProps['borderStartColor'];\n borderEndColor?: StyleProps['borderEndColor'];\n borderTopColor?: StyleProps['borderTopColor'];\n borderBottomColor?: StyleProps['borderBottomColor'];\n borderWidth?: StyleProps['borderWidth'];\n borderVerticalWidth?: StyleProps['borderVerticalWidth'];\n borderHorizontalWidth?: StyleProps['borderHorizontalWidth'];\n borderStartWidth?: StyleProps['borderStartWidth'];\n borderEndWidth?: StyleProps['borderEndWidth'];\n borderTopWidth?: StyleProps['borderTopWidth'];\n borderBottomWidth?: StyleProps['borderBottomWidth'];\n // Flex\n flexShrink?: StyleProps['flexShrink'];\n // Spacing\n spacingStart?: StyleProps['spacingStart'];\n spacingEnd?: StyleProps['spacingEnd'];\n spacingTop?: StyleProps['spacingTop'];\n spacingBottom?: StyleProps['spacingBottom'];\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n spacingVertical?: StyleProps['spacingVertical'];\n spacing?: StyleProps['spacing'];\n // Offset\n offsetStart?: StyleProps['offsetStart'];\n offsetEnd?: StyleProps['offsetEnd'];\n offsetTop?: StyleProps['offsetTop'];\n offsetBottom?: StyleProps['offsetBottom'];\n offsetHorizontal?: StyleProps['offsetHorizontal'];\n offsetVertical?: StyleProps['offsetVertical'];\n offset?: StyleProps['offset'];\n /** Icon color override */\n dangerouslySetColor?: string;\n /** Icon font size override */\n dangerouslySetSize?: number;\n /** Optional style override */\n style?: StyleProp<TextStyle>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Multicolor Icon */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Separate component for multicolor SVG icons.\n * Uses useUnistyles() for reactive theme access - isolated here so\n * glyph-based icons don't pay the hook overhead.\n */\nconst MulticolorIcon = memo(function MulticolorIcon({\n name,\n size = DEFAULT_PROPS.size,\n flexShrink = DEFAULT_PROPS.flexShrink,\n backgroundColor,\n dangerouslySetSize,\n maxFontSizeMultiplier,\n allowFontScaling = true,\n accessible,\n accessibilityElementsHidden,\n accessibilityHint,\n accessibilityLabel = name,\n accessibilityRole = 'image',\n accessibilityState,\n accessibilityValue,\n importantForAccessibility,\n testID,\n}: Omit<IconProps, 'variant'>) {\n // Reactive theme subscription - only multicolor icons need this\n const { rt } = useUnistyles();\n const colorScheme = rt.themeName === 'dark' ? 'dark' : 'light';\n\n const pixelSize = ICON_SIZE_MAP[size];\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n const fontScaleFactor = useFontScale(allowFontScaling ? resolvedMaxFontSizeMultiplier : 1);\n const renderedSize = Math.round((dangerouslySetSize ?? pixelSize) * fontScaleFactor);\n const svgKey = `${name}-${colorScheme}-${pixelSize}` as SvgGlyphKey;\n const svgContent = svgMap[svgKey];\n\n if (!svgContent) {\n console.warn(`Multicolor icon \"${svgKey}\" not found`);\n return null;\n }\n\n styles.useVariants({\n flexShrink,\n backgroundColor,\n });\n\n return (\n <View\n accessible={accessible}\n accessibilityElementsHidden={accessibilityElementsHidden}\n accessibilityHint={accessibilityHint}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole={accessibilityRole}\n accessibilityState={accessibilityState}\n accessibilityValue={accessibilityValue}\n importantForAccessibility={importantForAccessibility}\n testID={testID}\n style={styles.foundation as ViewProps['style']}\n >\n <SvgXml\n xml={svgContent}\n width={renderedSize}\n height={renderedSize}\n viewBox={`0 0 ${pixelSize} ${pixelSize}`}\n />\n </View>\n );\n});\n\nconst OutlineOrFillIcon = memo(function OutlineOrFillIcon({\n name,\n size = DEFAULT_PROPS.size,\n color = DEFAULT_PROPS.color,\n variant = DEFAULT_PROPS.variant,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Flex\n flexShrink = '0',\n // Spacing\n spacingStart,\n spacingEnd,\n spacingTop,\n spacingBottom,\n spacingHorizontal,\n spacingVertical,\n spacing,\n // Offset\n offsetStart,\n offsetEnd,\n offsetTop,\n offsetBottom,\n offsetHorizontal,\n offsetVertical,\n offset,\n // Dangerously set props\n dangerouslySetColor,\n dangerouslySetSize,\n maxFontSizeMultiplier,\n style,\n ref,\n ...props\n}: Omit<IconProps, 'variant'> & { variant?: 'outline' | 'fill' }) {\n const pixelSize = ICON_SIZE_MAP[size];\n // Native scales fontSize and lineHeight together under the cap, so the\n // glyph cell grows proportionally; glyph selection stays at pixelSize.\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n // Glyph-based icons - no useUnistyles needed, styles.useVariants is reactive\n styles.useVariants({\n color,\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Flex\n flexShrink,\n // Spacing\n spacingStart,\n spacingEnd,\n spacingTop,\n spacingBottom,\n spacingHorizontal,\n spacingVertical,\n spacing,\n // Offset\n offsetStart,\n offsetEnd,\n offsetTop,\n offsetBottom,\n offsetHorizontal,\n offsetVertical,\n offset,\n });\n const glyphName = `${name}-${variant}-${pixelSize}`;\n const glyph = (glyphMap as Record<string, string>)[glyphName];\n const textStyles: StyleProp<TextStyle> = useMemo(\n () => [\n {\n fontFamily: 'uds-icons',\n textAlign: 'center',\n textAlignVertical: 'center',\n fontSize: pixelSize,\n lineHeight: getSafeIconCell(pixelSize),\n },\n styles.foundation,\n dangerouslySetColor ? { color: dangerouslySetColor } : undefined,\n dangerouslySetSize\n ? {\n fontSize: dangerouslySetSize,\n lineHeight: getSafeIconCell(dangerouslySetSize),\n }\n : undefined,\n style,\n ],\n [dangerouslySetColor, dangerouslySetSize, style, styles.foundation, pixelSize],\n );\n\n return (\n <Text\n ref={ref}\n accessibilityRole=\"image\"\n accessibilityLabel={name}\n style={textStyles}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n {...props}\n >\n {glyph}\n </Text>\n );\n});\n\n/**\n * **🎨 An icon component using UDS icon fonts and multicolor SVGs**\n *\n * @description\n * Renders icons from the UDS icon library. Supports multiple variants\n * (outline, fill, multicolor) and sizes.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Icon } from '@yahoo/uds-mobile/Icon';\n *\n * <Icon name=\"ChevronRight\" size=\"md\" color=\"primary\" />\n * <Icon name=\"Star\" variant=\"fill\" color=\"accent\" />\n * <Icon name=\"Yahoo\" variant=\"multicolor\" />\n * ```\n *\n * @usage\n * - Use name prop to specify the icon\n * - Use variant prop for outline/fill/multicolor\n * - Use size prop for icon size (xs, sm, md, lg, xl)\n *\n * @accessibility\n * - Sets `accessibilityRole=\"image\"` automatically\n * - Icon name is used as accessibility label\n * - For decorative icons, set `accessibilityElementsHidden`\n *\n * @see {@link IconButton} for clickable icons\n * @see {@link IconSlot} for flexible icon rendering in components\n */\nconst Icon = memo(function Icon({ variant, ...props }: IconProps) {\n // Delegate to MulticolorIcon for SVG-based icons (has its own useUnistyles)\n if (variant === 'multicolor') {\n return <MulticolorIcon {...props} />;\n }\n\n return <OutlineOrFillIcon variant={variant} {...props} />;\n});\n\nIcon.displayName = 'Icon';\n\nexport { Icon };\nexport type { IconName, IconProps };\nexport const iconNames = glyphNames;\nexport const multicolorIconNames = svgGlyphNames;\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,gBAAgB;CACpB,MAAM;CACN,OAAO;CACP,SAAS;CACT,YAAY;CACb;;;;;;AAiFD,MAAM,iBAAiB,KAAK,SAAS,eAAe,EAClD,MACA,OAAO,cAAc,MACrB,aAAa,cAAc,YAC3B,iBACA,oBACA,uBACA,mBAAmB,MACnB,YACA,6BACA,mBACA,qBAAqB,MACrB,oBAAoB,SACpB,oBACA,oBACA,2BACA,UAC6B;CAE7B,MAAM,EAAE,OAAO,cAAc;CAC7B,MAAM,cAAc,GAAG,cAAc,SAAS,SAAS;CAEvD,MAAM,YAAY,cAAc;CAChC,MAAM,gCAAgC,yBAAyB,WAAW,sBAAsB;CAChG,MAAM,kBAAkB,aAAa,mBAAmB,gCAAgC,EAAE;CAC1F,MAAM,eAAe,KAAK,OAAO,sBAAsB,aAAa,gBAAgB;CACpF,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG;CACzC,MAAM,aAAa,OAAO;CAE1B,IAAI,CAAC,YAAY;EACf,QAAQ,KAAK,oBAAoB,OAAO,aAAa;EACrD,OAAO;;CAGT,OAAO,YAAY;EACjB;EACA;EACD,CAAC;CAEF,OACE,oBAAC,MAAD;EACc;EACiB;EACV;EACC;EACD;EACC;EACA;EACO;EACnB;EACR,OAAO,OAAO;YAEd,oBAAC,QAAD;GACE,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AK,EAAE,SAAS,GAAG,SAAoB;CAEhE,IAAI,YAAY,cACd,OAAO,oBAAC,gBAAD,EAAgB,GAAI,OAAS,CAAA;CAGtC,OAAO,oBAAC,mBAAD;EAA4B;EAAS,GAAI;EAAS,CAAA;EACzD;AAEF,KAAK,cAAc;AAInB,MAAa,YAAY;AACzB,MAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"Icon.js","names":[],"sources":["../../src/components/Icon.tsx"],"sourcesContent":["import type { GlyphName } from '@yahoo/uds-icons/glyphMap';\nimport { glyphMap, glyphNames } from '@yahoo/uds-icons/glyphMap';\nimport type { SvgGlyphKey, SvgGlyphName } from '@yahoo/uds-icons/svgMap';\nimport { svgGlyphNames, svgMap } from '@yahoo/uds-icons/svgMap';\nimport { ICON_SIZE_MAP } from '@yahoo/uds-icons/tokens';\nimport type { IconSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type {\n StyleProp,\n Text as RNText,\n TextProps as RNTextProps,\n TextStyle,\n ViewProps,\n} from 'react-native';\nimport { Text, View } from 'react-native';\nimport { SvgXml } from 'react-native-svg';\n// eslint-disable-next-line uds/no-use-unistyles\nimport { useUnistyles } from 'react-native-unistyles';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport { useFontScale } from '../fontScaling/useFontScale';\nimport { useMaxFontSizeMultiplier } from '../fontScaling/useMaxFontSizeMultiplier';\nimport { getSafeIconCell } from './Button/buttonTheme';\n\nconst DEFAULT_PROPS = {\n size: 'md',\n color: 'primary',\n variant: 'outline',\n flexShrink: '0',\n} as const;\n\n/* -------------------------------------------------------------------------- */\n/* Icon Props */\n/* -------------------------------------------------------------------------- */\n\ntype IconName = GlyphName | SvgGlyphName;\n\ninterface IconProps extends Omit<RNTextProps, 'style'> {\n /** Ref to the underlying Text element */\n ref?: Ref<RNText>;\n /** The icon name */\n name: IconName;\n /** Icon size */\n size?: IconSize;\n /** Icon color */\n color?: StyleProps['color'];\n /** Icon variant (outline, fill, multicolor) */\n variant?: IconVariant;\n /**\n * Caps how far the icon grows with the OS text-size setting. Applies to both\n * font glyphs and multicolor SVGs. Set null to remove the cap; override\n * app-wide via UDSFontScalingProvider.\n * @default 2\n */\n maxFontSizeMultiplier?: number | null;\n // Background\n backgroundColor?: StyleProps['backgroundColor'];\n // Border\n borderRadius?: StyleProps['borderRadius'];\n borderTopStartRadius?: StyleProps['borderTopStartRadius'];\n borderTopEndRadius?: StyleProps['borderTopEndRadius'];\n borderBottomStartRadius?: StyleProps['borderBottomStartRadius'];\n borderBottomEndRadius?: StyleProps['borderBottomEndRadius'];\n borderColor?: StyleProps['borderColor'];\n borderStartColor?: StyleProps['borderStartColor'];\n borderEndColor?: StyleProps['borderEndColor'];\n borderTopColor?: StyleProps['borderTopColor'];\n borderBottomColor?: StyleProps['borderBottomColor'];\n borderWidth?: StyleProps['borderWidth'];\n borderVerticalWidth?: StyleProps['borderVerticalWidth'];\n borderHorizontalWidth?: StyleProps['borderHorizontalWidth'];\n borderStartWidth?: StyleProps['borderStartWidth'];\n borderEndWidth?: StyleProps['borderEndWidth'];\n borderTopWidth?: StyleProps['borderTopWidth'];\n borderBottomWidth?: StyleProps['borderBottomWidth'];\n // Flex\n flexShrink?: StyleProps['flexShrink'];\n // Spacing\n spacingStart?: StyleProps['spacingStart'];\n spacingEnd?: StyleProps['spacingEnd'];\n spacingTop?: StyleProps['spacingTop'];\n spacingBottom?: StyleProps['spacingBottom'];\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n spacingVertical?: StyleProps['spacingVertical'];\n spacing?: StyleProps['spacing'];\n // Offset\n offsetStart?: StyleProps['offsetStart'];\n offsetEnd?: StyleProps['offsetEnd'];\n offsetTop?: StyleProps['offsetTop'];\n offsetBottom?: StyleProps['offsetBottom'];\n offsetHorizontal?: StyleProps['offsetHorizontal'];\n offsetVertical?: StyleProps['offsetVertical'];\n offset?: StyleProps['offset'];\n /** Icon color override */\n dangerouslySetColor?: string;\n /** Icon font size override */\n dangerouslySetSize?: number;\n /** Optional style override */\n style?: StyleProp<TextStyle>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Multicolor Icon */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Separate component for multicolor SVG icons.\n * Uses useUnistyles() for reactive theme access - isolated here so\n * glyph-based icons don't pay the hook overhead.\n */\nconst MulticolorIcon = memo(function MulticolorIcon({\n name,\n size = DEFAULT_PROPS.size,\n flexShrink = DEFAULT_PROPS.flexShrink,\n backgroundColor,\n dangerouslySetSize,\n maxFontSizeMultiplier,\n allowFontScaling = true,\n accessible,\n accessibilityElementsHidden,\n accessibilityHint,\n accessibilityLabel = name,\n accessibilityRole = 'image',\n accessibilityState,\n accessibilityValue,\n importantForAccessibility,\n testID,\n}: Omit<IconProps, 'variant'>) {\n // Reactive theme subscription - only multicolor icons need this\n const { rt } = useUnistyles();\n const colorScheme = rt.themeName === 'dark' ? 'dark' : 'light';\n\n const pixelSize = ICON_SIZE_MAP[size];\n const baseSize = dangerouslySetSize ?? pixelSize;\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n const fontScaleFactor = useFontScale(\n allowFontScaling ? resolvedMaxFontSizeMultiplier : 1,\n baseSize,\n );\n const renderedSize = Math.round(baseSize * fontScaleFactor);\n const svgKey = `${name}-${colorScheme}-${pixelSize}` as SvgGlyphKey;\n const svgContent = svgMap[svgKey];\n\n if (!svgContent) {\n console.warn(`Multicolor icon \"${svgKey}\" not found`);\n return null;\n }\n\n styles.useVariants({\n flexShrink,\n backgroundColor,\n });\n\n return (\n <View\n accessible={accessible}\n accessibilityElementsHidden={accessibilityElementsHidden}\n accessibilityHint={accessibilityHint}\n accessibilityLabel={accessibilityLabel}\n accessibilityRole={accessibilityRole}\n accessibilityState={accessibilityState}\n accessibilityValue={accessibilityValue}\n importantForAccessibility={importantForAccessibility}\n testID={testID}\n style={styles.foundation as ViewProps['style']}\n >\n <SvgXml\n xml={svgContent}\n width={renderedSize}\n height={renderedSize}\n viewBox={`0 0 ${pixelSize} ${pixelSize}`}\n />\n </View>\n );\n});\n\nconst OutlineOrFillIcon = memo(function OutlineOrFillIcon({\n name,\n size = DEFAULT_PROPS.size,\n color = DEFAULT_PROPS.color,\n variant = DEFAULT_PROPS.variant,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Flex\n flexShrink = '0',\n // Spacing\n spacingStart,\n spacingEnd,\n spacingTop,\n spacingBottom,\n spacingHorizontal,\n spacingVertical,\n spacing,\n // Offset\n offsetStart,\n offsetEnd,\n offsetTop,\n offsetBottom,\n offsetHorizontal,\n offsetVertical,\n offset,\n // Dangerously set props\n dangerouslySetColor,\n dangerouslySetSize,\n maxFontSizeMultiplier,\n style,\n ref,\n ...props\n}: Omit<IconProps, 'variant'> & { variant?: 'outline' | 'fill' }) {\n const pixelSize = ICON_SIZE_MAP[size];\n // Native scales fontSize and lineHeight together under the cap, so the\n // glyph cell grows proportionally; glyph selection stays at pixelSize.\n const resolvedMaxFontSizeMultiplier = useMaxFontSizeMultiplier('control', maxFontSizeMultiplier);\n // Glyph-based icons - no useUnistyles needed, styles.useVariants is reactive\n styles.useVariants({\n color,\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Flex\n flexShrink,\n // Spacing\n spacingStart,\n spacingEnd,\n spacingTop,\n spacingBottom,\n spacingHorizontal,\n spacingVertical,\n spacing,\n // Offset\n offsetStart,\n offsetEnd,\n offsetTop,\n offsetBottom,\n offsetHorizontal,\n offsetVertical,\n offset,\n });\n const glyphName = `${name}-${variant}-${pixelSize}`;\n const glyph = (glyphMap as Record<string, string>)[glyphName];\n const textStyles: StyleProp<TextStyle> = useMemo(\n () => [\n {\n fontFamily: 'uds-icons',\n textAlign: 'center',\n textAlignVertical: 'center',\n fontSize: pixelSize,\n lineHeight: getSafeIconCell(pixelSize),\n },\n styles.foundation,\n style,\n dangerouslySetColor ? { color: dangerouslySetColor } : undefined,\n dangerouslySetSize\n ? {\n fontSize: dangerouslySetSize,\n lineHeight: getSafeIconCell(dangerouslySetSize),\n }\n : undefined,\n ],\n [dangerouslySetColor, dangerouslySetSize, style, styles.foundation, pixelSize],\n );\n\n return (\n <Text\n ref={ref}\n accessibilityRole=\"image\"\n accessibilityLabel={name}\n style={textStyles}\n maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}\n {...props}\n >\n {glyph}\n </Text>\n );\n});\n\n/**\n * **🎨 An icon component using UDS icon fonts and multicolor SVGs**\n *\n * @description\n * Renders icons from the UDS icon library. Supports multiple variants\n * (outline, fill, multicolor) and sizes.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Icon } from '@yahoo/uds-mobile/Icon';\n *\n * <Icon name=\"ChevronRight\" size=\"md\" color=\"primary\" />\n * <Icon name=\"Star\" variant=\"fill\" color=\"accent\" />\n * <Icon name=\"Yahoo\" variant=\"multicolor\" />\n * ```\n *\n * @usage\n * - Use name prop to specify the icon\n * - Use variant prop for outline/fill/multicolor\n * - Use size prop for icon size (xs, sm, md, lg, xl)\n *\n * @accessibility\n * - Sets `accessibilityRole=\"image\"` automatically\n * - Icon name is used as accessibility label\n * - For decorative icons, set `accessibilityElementsHidden`\n *\n * @see {@link IconButton} for clickable icons\n * @see {@link IconSlot} for flexible icon rendering in components\n */\nconst Icon = memo(function Icon({ variant, ...props }: IconProps) {\n // Delegate to MulticolorIcon for SVG-based icons (has its own useUnistyles)\n if (variant === 'multicolor') {\n return <MulticolorIcon {...props} />;\n }\n\n return <OutlineOrFillIcon variant={variant} {...props} />;\n});\n\nIcon.displayName = 'Icon';\n\nexport { Icon };\nexport type { IconName, IconProps };\nexport const iconNames = glyphNames;\nexport const multicolorIconNames = svgGlyphNames;\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,gBAAgB;CACpB,MAAM;CACN,OAAO;CACP,SAAS;CACT,YAAY;CACb;;;;;;AAiFD,MAAM,iBAAiB,KAAK,SAAS,eAAe,EAClD,MACA,OAAO,cAAc,MACrB,aAAa,cAAc,YAC3B,iBACA,oBACA,uBACA,mBAAmB,MACnB,YACA,6BACA,mBACA,qBAAqB,MACrB,oBAAoB,SACpB,oBACA,oBACA,2BACA,UAC6B;CAE7B,MAAM,EAAE,OAAO,cAAc;CAC7B,MAAM,cAAc,GAAG,cAAc,SAAS,SAAS;CAEvD,MAAM,YAAY,cAAc;CAChC,MAAM,WAAW,sBAAsB;CACvC,MAAM,gCAAgC,yBAAyB,WAAW,sBAAsB;CAChG,MAAM,kBAAkB,aACtB,mBAAmB,gCAAgC,GACnD,SACD;CACD,MAAM,eAAe,KAAK,MAAM,WAAW,gBAAgB;CAC3D,MAAM,SAAS,GAAG,KAAK,GAAG,YAAY,GAAG;CACzC,MAAM,aAAa,OAAO;CAE1B,IAAI,CAAC,YAAY;EACf,QAAQ,KAAK,oBAAoB,OAAO,aAAa;EACrD,OAAO;;CAGT,OAAO,YAAY;EACjB;EACA;EACD,CAAC;CAEF,OACE,oBAAC,MAAD;EACc;EACiB;EACV;EACC;EACD;EACC;EACA;EACO;EACnB;EACR,OAAO,OAAO;YAEd,oBAAC,QAAD;GACE,KAAK;GACL,OAAO;GACP,QAAQ;GACR,SAAS,OAAO,UAAU,GAAG;GAC7B,CAAA;EACG,CAAA;EAET;AAEF,MAAM,oBAAoB,KAAK,SAAS,kBAAk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EAA4B;EAAS,GAAI;EAAS,CAAA;EACzD;AAEF,KAAK,cAAc;AAInB,MAAa,YAAY;AACzB,MAAa,sBAAsB"}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
require("../_virtual/_rolldown/runtime.cjs");
|
|
4
4
|
const require_components_HStack = require("./HStack.cjs");
|
|
5
|
+
const require_fontScaling_useFontScale = require("../fontScaling/useFontScale.cjs");
|
|
6
|
+
const require_fontScaling_useMaxFontSizeMultiplier = require("../fontScaling/useMaxFontSizeMultiplier.cjs");
|
|
5
7
|
const require_components_IconSlot = require("./IconSlot.cjs");
|
|
6
8
|
const require_components_Text = require("./Text.cjs");
|
|
7
9
|
const require_components_InputHelpText = require("./InputHelpText.cjs");
|
|
@@ -47,8 +49,9 @@ let lodash_es = require("lodash-es");
|
|
|
47
49
|
* @see {@link Checkbox} for boolean selections
|
|
48
50
|
* @see {@link Radio} for single-select options
|
|
49
51
|
*/
|
|
50
|
-
const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, endIcon, helpText, helperTextIcon, hasError, disabled, readOnly, required, width = "100%", defaultValue, value: controlledValue, onChangeText, onFocus, onBlur, placeholder, placeholderTextColor, ref, ...textInputProps }) {
|
|
52
|
+
const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, endIcon, helpText, helperTextIcon, hasError, disabled, readOnly, required, width = "100%", defaultValue, value: controlledValue, onChangeText, onFocus, onBlur, placeholder, placeholderTextColor, maxFontSizeMultiplier, ref, ...textInputProps }) {
|
|
51
53
|
const uid = `uds-input-${(0, react.useId)()}`;
|
|
54
|
+
const resolvedMaxFontSizeMultiplier = require_fontScaling_useMaxFontSizeMultiplier.useMaxFontSizeMultiplier("control", maxFontSizeMultiplier) ?? 0;
|
|
52
55
|
const [internalValue, setInternalValue] = (0, react.useState)(defaultValue ?? "");
|
|
53
56
|
const [isFocused, setIsFocused] = (0, react.useState)(false);
|
|
54
57
|
const isControlled = controlledValue !== void 0;
|
|
@@ -73,30 +76,47 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
73
76
|
readonly: readOnly,
|
|
74
77
|
invalid: hasError
|
|
75
78
|
});
|
|
79
|
+
const fontScaleFactor = require_fontScaling_useFontScale.useFontScale(resolvedMaxFontSizeMultiplier, (typeof generated_styles.inputStyles.inputWrapperStatic.lineHeight === "number" ? generated_styles.inputStyles.inputWrapperStatic.lineHeight : void 0) ?? (typeof generated_styles.inputStyles.inputWrapperStatic.fontSize === "number" ? generated_styles.inputStyles.inputWrapperStatic.fontSize : void 0));
|
|
76
80
|
const computedPlaceholderColor = placeholderTextColor ?? generated_styles.inputStyles.inputPlaceholder.color;
|
|
77
81
|
const rootStyle = (0, react.useMemo)(() => [{
|
|
78
82
|
width,
|
|
79
83
|
opacity: disabled ? .5 : 1
|
|
80
84
|
}], [width, disabled]);
|
|
81
|
-
const inputWrapperStyle = (0, react.useMemo)(() =>
|
|
82
|
-
generated_styles.inputStyles.
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
const inputWrapperStyle = (0, react.useMemo)(() => {
|
|
86
|
+
const { gap, paddingVertical } = generated_styles.inputStyles.inputWrapperStatic;
|
|
87
|
+
const scaledMetrics = fontScaleFactor === 1 ? void 0 : {
|
|
88
|
+
...typeof gap === "number" && { gap: Math.round(gap * fontScaleFactor) },
|
|
89
|
+
...typeof paddingVertical === "number" && { paddingVertical: Math.round(paddingVertical * fontScaleFactor) }
|
|
90
|
+
};
|
|
91
|
+
return [
|
|
92
|
+
generated_styles.inputStyles.inputWrapper,
|
|
93
|
+
generated_styles.inputStyles.inputWrapperStatic,
|
|
94
|
+
generated_styles.inputStyles.inputWrapperDynamic,
|
|
95
|
+
scaledMetrics,
|
|
96
|
+
{
|
|
97
|
+
flexDirection: "row",
|
|
98
|
+
alignItems: "center"
|
|
99
|
+
}
|
|
100
|
+
];
|
|
101
|
+
}, [
|
|
102
|
+
fontScaleFactor,
|
|
90
103
|
generated_styles.inputStyles.inputWrapper,
|
|
91
104
|
generated_styles.inputStyles.inputWrapperStatic,
|
|
92
105
|
generated_styles.inputStyles.inputWrapperDynamic
|
|
93
106
|
]);
|
|
94
|
-
const textInputStyle = (0, react.useMemo)(() =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
const textInputStyle = (0, react.useMemo)(() => {
|
|
108
|
+
const inputHeight = generated_styles.inputStyles.input.height;
|
|
109
|
+
return [
|
|
110
|
+
generated_styles.inputStyles.input,
|
|
111
|
+
typeof inputHeight === "number" ? { height: Math.round(inputHeight * fontScaleFactor) } : void 0,
|
|
112
|
+
{
|
|
113
|
+
flex: 1,
|
|
114
|
+
includeFontPadding: false,
|
|
115
|
+
textAlignVertical: "center",
|
|
116
|
+
paddingVertical: 0
|
|
117
|
+
}
|
|
118
|
+
];
|
|
119
|
+
}, [fontScaleFactor, generated_styles.inputStyles.input]);
|
|
100
120
|
const labelContent = (0, react.useMemo)(() => {
|
|
101
121
|
if (!label) return null;
|
|
102
122
|
const content = (0, lodash_es.isFunction)(label) ? label() : label;
|
|
@@ -105,9 +125,11 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
105
125
|
alignItems: "flex-end",
|
|
106
126
|
spacingBottom: "2",
|
|
107
127
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
128
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
108
129
|
style: generated_styles.inputStyles.label,
|
|
109
130
|
children: content
|
|
110
131
|
}), required && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
132
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
111
133
|
style: generated_styles.inputStyles.labelRequired,
|
|
112
134
|
children: "*"
|
|
113
135
|
})]
|
|
@@ -115,6 +137,7 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
115
137
|
}, [
|
|
116
138
|
label,
|
|
117
139
|
required,
|
|
140
|
+
resolvedMaxFontSizeMultiplier,
|
|
118
141
|
generated_styles.inputStyles.label,
|
|
119
142
|
generated_styles.inputStyles.labelRequired
|
|
120
143
|
]);
|
|
@@ -123,17 +146,27 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
123
146
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
124
147
|
icon: startIcon,
|
|
125
148
|
variant: "outline",
|
|
149
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
126
150
|
style: generated_styles.inputStyles.startIcon
|
|
127
151
|
});
|
|
128
|
-
}, [
|
|
152
|
+
}, [
|
|
153
|
+
startIcon,
|
|
154
|
+
resolvedMaxFontSizeMultiplier,
|
|
155
|
+
generated_styles.inputStyles.startIcon
|
|
156
|
+
]);
|
|
129
157
|
const endIconContent = (0, react.useMemo)(() => {
|
|
130
158
|
if (!endIcon) return null;
|
|
131
159
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_IconSlot.IconSlot, {
|
|
132
160
|
icon: endIcon,
|
|
133
161
|
variant: "outline",
|
|
162
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
134
163
|
style: generated_styles.inputStyles.endIcon
|
|
135
164
|
});
|
|
136
|
-
}, [
|
|
165
|
+
}, [
|
|
166
|
+
endIcon,
|
|
167
|
+
resolvedMaxFontSizeMultiplier,
|
|
168
|
+
generated_styles.inputStyles.endIcon
|
|
169
|
+
]);
|
|
137
170
|
const helpTextContent = (0, react.useMemo)(() => {
|
|
138
171
|
if (!helpText) return null;
|
|
139
172
|
const content = (0, lodash_es.isFunction)(helpText) ? helpText() : helpText;
|
|
@@ -145,6 +178,7 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
145
178
|
readOnly,
|
|
146
179
|
hasError,
|
|
147
180
|
pressed: isFocused,
|
|
181
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
148
182
|
children: content
|
|
149
183
|
});
|
|
150
184
|
}, [
|
|
@@ -154,6 +188,7 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
154
188
|
helperTextIcon,
|
|
155
189
|
isFocused,
|
|
156
190
|
readOnly,
|
|
191
|
+
resolvedMaxFontSizeMultiplier,
|
|
157
192
|
size,
|
|
158
193
|
valueState
|
|
159
194
|
]);
|
|
@@ -178,6 +213,7 @@ const Input = (0, react.memo)(function Input({ label, size = "md", startIcon, en
|
|
|
178
213
|
placeholder,
|
|
179
214
|
placeholderTextColor: computedPlaceholderColor,
|
|
180
215
|
editable: !disabled && !readOnly,
|
|
216
|
+
maxFontSizeMultiplier: resolvedMaxFontSizeMultiplier,
|
|
181
217
|
style: textInputStyle,
|
|
182
218
|
accessibilityLabel: typeof label === "string" ? label : void 0,
|
|
183
219
|
accessibilityHint: typeof helpText === "string" ? helpText : void 0,
|
|
@@ -10,6 +10,11 @@ import { TextInput, TextInputProps } from "react-native";
|
|
|
10
10
|
interface InputProps extends Omit<UniversalInputProps<IconSlotType>, 'width'>, Omit<TextInputProps, 'style' | 'editable'>, Pick<SizeProps, 'width'> {
|
|
11
11
|
/** Ref to the underlying TextInput element */
|
|
12
12
|
ref?: Ref<TextInput>;
|
|
13
|
+
/**
|
|
14
|
+
* Caps the field text, labels, icons, and geometry at the control scale.
|
|
15
|
+
* Set null to remove the cap. @default 2
|
|
16
|
+
*/
|
|
17
|
+
maxFontSizeMultiplier?: number | null;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* **📦 An input that allows users to enter text and collect data.**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.cts","names":[],"sources":["../../src/components/Input.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Input.d.cts","names":[],"sources":["../../src/components/Input.tsx"],"mappings":";;;;;;;;;UAsBU,UAAA,SAEN,IAAA,CAAK,mBAAA,CAAoB,YAAA,aACzB,IAAA,CAAK,cAAA,yBACL,IAAA,CAAK,SAAA;;EAEP,GAAA,GAAM,GAAA,CAAI,SAAA;EALV;;;;EAUA,qBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;AAAqB;;;;;;;;;;;;;;;cA0CjB,KAAA,EAAK,OAAA,CAAA,oBAAA,CAAA,UAAA"}
|
|
@@ -10,6 +10,11 @@ import { TextInput, TextInputProps } from "react-native";
|
|
|
10
10
|
interface InputProps extends Omit<UniversalInputProps<IconSlotType>, 'width'>, Omit<TextInputProps, 'style' | 'editable'>, Pick<SizeProps, 'width'> {
|
|
11
11
|
/** Ref to the underlying TextInput element */
|
|
12
12
|
ref?: Ref<TextInput>;
|
|
13
|
+
/**
|
|
14
|
+
* Caps the field text, labels, icons, and geometry at the control scale.
|
|
15
|
+
* Set null to remove the cap. @default 2
|
|
16
|
+
*/
|
|
17
|
+
maxFontSizeMultiplier?: number | null;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
15
20
|
* **📦 An input that allows users to enter text and collect data.**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.d.ts","names":[],"sources":["../../src/components/Input.tsx"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Input.d.ts","names":[],"sources":["../../src/components/Input.tsx"],"mappings":";;;;;;;;;UAsBU,UAAA,SAEN,IAAA,CAAK,mBAAA,CAAoB,YAAA,aACzB,IAAA,CAAK,cAAA,yBACL,IAAA,CAAK,SAAA;;EAEP,GAAA,GAAM,GAAA,CAAI,SAAA;EALV;;;;EAUA,qBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;AAAqB;;;;;;;;;;;;;;;cA0CjB,KAAA,EAAK,OAAA,CAAA,oBAAA,CAAA,UAAA"}
|