@yahoo/uds-mobile 1.3.0-beta.9 → 1.4.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/bin/fixtures/dist/index.mjs +25 -1
- package/dist/bin/generateTheme.mjs +5 -5
- package/dist/bin/uds-mobile.mjs +10 -10
- package/dist/components/Avatar.cjs +12 -3
- package/dist/components/Avatar.d.cts +11 -3
- package/dist/components/Avatar.d.cts.map +1 -1
- package/dist/components/Avatar.d.mts +11 -3
- package/dist/components/Avatar.d.mts.map +1 -1
- package/dist/components/Avatar.mjs +10 -2
- package/dist/components/Avatar.mjs.map +1 -1
- package/dist/components/Badge.cjs +14 -3
- package/dist/components/Badge.d.cts +24 -6
- package/dist/components/Badge.d.cts.map +1 -1
- package/dist/components/Badge.d.mts +24 -6
- package/dist/components/Badge.d.mts.map +1 -1
- package/dist/components/Badge.mjs +12 -2
- package/dist/components/Badge.mjs.map +1 -1
- package/dist/components/Box.cjs +14 -10
- package/dist/components/Box.d.cts +15 -10
- package/dist/components/Box.d.cts.map +1 -1
- package/dist/components/Box.d.mts +15 -10
- package/dist/components/Box.d.mts.map +1 -1
- package/dist/components/Box.mjs +12 -9
- package/dist/components/Box.mjs.map +1 -1
- package/dist/components/Button.cjs +14 -4
- package/dist/components/Button.d.cts +21 -6
- package/dist/components/Button.d.cts.map +1 -1
- package/dist/components/Button.d.mts +21 -6
- package/dist/components/Button.d.mts.map +1 -1
- package/dist/components/Button.mjs +11 -2
- package/dist/components/Button.mjs.map +1 -1
- package/dist/components/Checkbox.cjs +15 -6
- package/dist/components/Checkbox.d.cts +14 -5
- package/dist/components/Checkbox.d.cts.map +1 -1
- package/dist/components/Checkbox.d.mts +14 -5
- package/dist/components/Checkbox.d.mts.map +1 -1
- package/dist/components/Checkbox.mjs +12 -4
- package/dist/components/Checkbox.mjs.map +1 -1
- package/dist/components/Chip.cjs +20 -3
- package/dist/components/Chip.d.cts +28 -6
- package/dist/components/Chip.d.cts.map +1 -1
- package/dist/components/Chip.d.mts +28 -6
- package/dist/components/Chip.d.mts.map +1 -1
- package/dist/components/Chip.mjs +18 -2
- package/dist/components/Chip.mjs.map +1 -1
- package/dist/components/HStack.cjs +8 -5
- package/dist/components/HStack.d.cts +9 -5
- package/dist/components/HStack.d.cts.map +1 -1
- package/dist/components/HStack.d.mts +9 -5
- package/dist/components/HStack.d.mts.map +1 -1
- package/dist/components/HStack.mjs +6 -4
- package/dist/components/HStack.mjs.map +1 -1
- package/dist/components/Icon.cjs +16 -5
- package/dist/components/Icon.d.cts +14 -3
- package/dist/components/Icon.d.cts.map +1 -1
- package/dist/components/Icon.d.mts +14 -3
- package/dist/components/Icon.d.mts.map +1 -1
- package/dist/components/Icon.mjs +14 -4
- package/dist/components/Icon.mjs.map +1 -1
- package/dist/components/IconButton.cjs +23 -4
- package/dist/components/IconButton.d.cts +28 -8
- package/dist/components/IconButton.d.cts.map +1 -1
- package/dist/components/IconButton.d.mts +28 -8
- package/dist/components/IconButton.d.mts.map +1 -1
- package/dist/components/IconButton.mjs +21 -3
- package/dist/components/IconButton.mjs.map +1 -1
- package/dist/components/IconSlot.cjs +8 -2
- package/dist/components/IconSlot.d.cts +7 -2
- package/dist/components/IconSlot.d.cts.map +1 -1
- package/dist/components/IconSlot.d.mts +7 -2
- package/dist/components/IconSlot.d.mts.map +1 -1
- package/dist/components/IconSlot.mjs +6 -1
- package/dist/components/IconSlot.mjs.map +1 -1
- package/dist/components/Image.cjs +18 -3
- package/dist/components/Image.d.cts +18 -3
- package/dist/components/Image.d.cts.map +1 -1
- package/dist/components/Image.d.mts +18 -3
- package/dist/components/Image.d.mts.map +1 -1
- package/dist/components/Image.mjs +16 -2
- package/dist/components/Image.mjs.map +1 -1
- package/dist/components/Input.cjs +19 -6
- package/dist/components/Input.d.cts +19 -6
- package/dist/components/Input.d.cts.map +1 -1
- package/dist/components/Input.d.mts +19 -6
- package/dist/components/Input.d.mts.map +1 -1
- package/dist/components/Input.mjs +17 -5
- package/dist/components/Input.mjs.map +1 -1
- package/dist/components/Link.cjs +19 -4
- package/dist/components/Link.d.cts +21 -4
- package/dist/components/Link.d.cts.map +1 -1
- package/dist/components/Link.d.mts +21 -4
- package/dist/components/Link.d.mts.map +1 -1
- package/dist/components/Link.mjs +16 -2
- package/dist/components/Link.mjs.map +1 -1
- package/dist/components/Pressable.cjs +17 -5
- package/dist/components/Pressable.d.cts +18 -5
- package/dist/components/Pressable.d.cts.map +1 -1
- package/dist/components/Pressable.d.mts +18 -5
- package/dist/components/Pressable.d.mts.map +1 -1
- package/dist/components/Pressable.mjs +14 -3
- package/dist/components/Pressable.mjs.map +1 -1
- package/dist/components/Radio.cjs +15 -6
- package/dist/components/Radio.d.cts +14 -5
- package/dist/components/Radio.d.cts.map +1 -1
- package/dist/components/Radio.d.mts +14 -5
- package/dist/components/Radio.d.mts.map +1 -1
- package/dist/components/Radio.mjs +12 -4
- package/dist/components/Radio.mjs.map +1 -1
- package/dist/components/Screen.cjs +9 -3
- package/dist/components/Screen.d.cts +15 -3
- package/dist/components/Screen.d.cts.map +1 -1
- package/dist/components/Screen.d.mts +15 -3
- package/dist/components/Screen.d.mts.map +1 -1
- package/dist/components/Screen.mjs +7 -2
- package/dist/components/Screen.mjs.map +1 -1
- package/dist/components/Switch.cjs +20 -4
- package/dist/components/Switch.d.cts +18 -3
- package/dist/components/Switch.d.cts.map +1 -1
- package/dist/components/Switch.d.mts +18 -3
- package/dist/components/Switch.d.mts.map +1 -1
- package/dist/components/Switch.mjs +17 -2
- package/dist/components/Switch.mjs.map +1 -1
- package/dist/components/Text.cjs +16 -6
- package/dist/components/Text.d.cts +18 -6
- package/dist/components/Text.d.cts.map +1 -1
- package/dist/components/Text.d.mts +18 -6
- package/dist/components/Text.d.mts.map +1 -1
- package/dist/components/Text.mjs +14 -5
- package/dist/components/Text.mjs.map +1 -1
- package/dist/components/VStack.cjs +8 -5
- package/dist/components/VStack.d.cts +9 -5
- package/dist/components/VStack.d.cts.map +1 -1
- package/dist/components/VStack.d.mts +9 -5
- package/dist/components/VStack.d.mts.map +1 -1
- package/dist/components/VStack.mjs +6 -4
- package/dist/components/VStack.mjs.map +1 -1
- package/dist/icons/dist/glyphMap.d.cts +0 -1
- package/dist/icons/dist/glyphMap.d.cts.map +1 -1
- package/dist/icons/dist/glyphMap.d.mts +0 -1
- package/dist/icons/dist/glyphMap.d.mts.map +1 -1
- package/dist/icons/dist/svgMap.d.cts +0 -1
- package/dist/icons/dist/svgMap.d.cts.map +1 -1
- package/dist/icons/dist/svgMap.d.mts +0 -1
- package/dist/icons/dist/svgMap.d.mts.map +1 -1
- package/dist/motion-tokens/dist/index.d.cts +1 -3
- package/dist/motion-tokens/dist/index.d.cts.map +1 -1
- package/dist/motion-tokens/dist/index.d.mts +1 -3
- package/dist/motion-tokens/dist/index.d.mts.map +1 -1
- package/dist/motion.cjs +1 -0
- package/dist/motion.d.cts +0 -1
- package/dist/motion.d.cts.map +1 -1
- package/dist/motion.d.mts +0 -1
- package/dist/motion.d.mts.map +1 -1
- package/dist/types/dist/index.d.cts +1 -3
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.mts +1 -3
- package/dist/types/dist/index.d.mts.map +1 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts.map +1 -1
- package/generated/styles.cjs +96 -0
- package/generated/styles.d.ts +47 -0
- package/generated/styles.mjs +96 -0
- package/generated/unistyles.d.ts +79 -0
- package/package.json +1 -1
|
@@ -23,6 +23,9 @@ const ANIMATION_DURATION = 120;
|
|
|
23
23
|
* A switch (also called a toggle) is a binary on/off input control.
|
|
24
24
|
* It allows users to pick between two clearly opposite choices.
|
|
25
25
|
*
|
|
26
|
+
* @category Form
|
|
27
|
+
* @platform mobile
|
|
28
|
+
*
|
|
26
29
|
* @example
|
|
27
30
|
* ```tsx
|
|
28
31
|
* import { Switch } from '@yahoo/uds-mobile';
|
|
@@ -32,9 +35,21 @@ const ANIMATION_DURATION = 120;
|
|
|
32
35
|
* <Switch onIcon="Check" offIcon="Cross" label="Sync" />
|
|
33
36
|
* ```
|
|
34
37
|
*
|
|
35
|
-
* @
|
|
38
|
+
* @usage
|
|
39
|
+
* - Settings: For toggling preferences on/off
|
|
40
|
+
* - Feature flags: For enabling/disabling features
|
|
41
|
+
* - Immediate effect toggles (no submit button needed)
|
|
42
|
+
*
|
|
43
|
+
* @accessibility
|
|
44
|
+
* - Sets `accessibilityRole="switch"` automatically
|
|
45
|
+
* - Announces on/off state to screen readers
|
|
46
|
+
* - Respects system reduce motion preference
|
|
47
|
+
* - Supports `reduceMotion` prop to disable animations
|
|
48
|
+
*
|
|
49
|
+
* @see {@link Checkbox} for forms with submit actions
|
|
50
|
+
* @see {@link Radio} for single-select options
|
|
36
51
|
*/
|
|
37
|
-
const Switch = memo(function Switch
|
|
52
|
+
const Switch = memo(function Switch({ isOn: isOnProp, defaultIsOn = false, onChange, label, labelPosition = "start", size = "md", onIcon, offIcon, disabled = false, required, accessibilityHint, reduceMotion = false, ref }) {
|
|
38
53
|
const isControlled = isOnProp !== void 0;
|
|
39
54
|
const [internalIsOn, setInternalIsOn] = useState(defaultIsOn);
|
|
40
55
|
const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.mjs","names":["HANDLE_TRAVEL: Record<SwitchSize, number>","Switch","rootStyle: StyleProp<ViewStyle>","trackStyle: StyleProp<ViewStyle>","handleStyle: StyleProp<ViewStyle>","Text"],"sources":["../../src/components/Switch.tsx"],"sourcesContent":["import type { SwitchSize, UniversalSwitchProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport type { AccessibilityProps, StyleProp, View, ViewStyle } from 'react-native';\nimport { AccessibilityInfo, Pressable } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withTiming } from 'react-native-reanimated';\nimport { StyleSheet } from 'react-native-unistyles';\nimport { useAnimatedVariantColor } from 'react-native-unistyles/reanimated';\n\nimport { switchStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Text } from './Text';\n\ninterface SwitchProps extends UniversalSwitchProps<IconSlotType> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Callback when the switch value changes */\n onChange?: (value: boolean) => void;\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Whether the switch is required (shows asterisk with label) */\n required?: boolean;\n /** Accessibility hint describing what happens when activated */\n accessibilityHint?: AccessibilityProps['accessibilityHint'];\n}\n\nconst HANDLE_TRAVEL: Record<SwitchSize, number> = {\n md: 20,\n sm: 12,\n};\n\nconst ANIMATION_DURATION = 120;\n\n/**\n * **Switch component for toggling options**\n *\n * @description\n * A switch (also called a toggle) is a binary on/off input control.\n * It allows users to pick between two clearly opposite choices.\n *\n * @example\n * ```tsx\n * import { Switch } from '@yahoo/uds-mobile';\n *\n * <Switch label=\"Notifications\" />\n * <Switch isOn={enabled} onChange={setEnabled} label=\"Dark mode\" />\n * <Switch onIcon=\"Check\" offIcon=\"Cross\" label=\"Sync\" />\n * ```\n *\n * @see The {@link https://uds.build/docs/components/switch Switch Docs} for more info\n */\nconst Switch = memo(function Switch({\n isOn: isOnProp,\n defaultIsOn = false,\n onChange,\n label,\n labelPosition = 'start',\n size = 'md',\n onIcon,\n offIcon,\n disabled = false,\n required,\n accessibilityHint,\n reduceMotion = false,\n ref,\n}: SwitchProps) {\n const isControlled = isOnProp !== undefined;\n const [internalIsOn, setInternalIsOn] = useState(defaultIsOn);\n const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);\n const isOn = isControlled ? isOnProp : internalIsOn;\n\n // Check system reduced motion preference\n useEffect(() => {\n const checkReducedMotion = async () => {\n const isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();\n setPrefersReducedMotion(isReduceMotionEnabled);\n };\n checkReducedMotion();\n\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n setPrefersReducedMotion,\n );\n return () => subscription.remove();\n }, []);\n\n const shouldReduceMotion = reduceMotion || prefersReducedMotion;\n const animationDuration = shouldReduceMotion ? 0 : ANIMATION_DURATION;\n\n const progress = useDerivedValue(\n () => withTiming(isOn ? 1 : 0, { duration: animationDuration }),\n [isOn, animationDuration],\n );\n\n const travelDistance = HANDLE_TRAVEL[size];\n\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newValue = !isOn;\n\n if (!isControlled) {\n setInternalIsOn(newValue);\n }\n\n onChange?.(newValue);\n }, [disabled, isOn, isControlled, onChange]);\n\n switchStyles.useVariants({\n size,\n variant: isOn ? 'on' : 'off',\n });\n\n // Get animated track color from design tokens (changes when variant changes)\n const trackBackgroundColor = useAnimatedVariantColor(switchStyles.switch, 'backgroundColor');\n\n const animatedTrackStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n backgroundColor: withTiming(trackBackgroundColor.value, { duration: animationDuration }),\n };\n });\n\n const animatedHandleStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n transform: [{ translateX: progress.value * travelDistance }],\n };\n });\n\n const rootStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.root, switchStaticStyles.root({ disabled })],\n [switchStyles.root, disabled],\n );\n\n const trackStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.switch, switchStaticStyles.track, animatedTrackStyle],\n [switchStyles.switch, animatedTrackStyle],\n );\n\n const handleStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.handle, switchStaticStyles.handle, animatedHandleStyle],\n [switchStyles.handle, animatedHandleStyle],\n );\n\n const accessibilityLabel = typeof label === 'string' ? label : undefined;\n const resolvedAccessibilityHint = accessibilityHint ?? 'Double tap to toggle';\n\n const resolvedLabel = typeof label === 'function' ? label() : label;\n const labelContent = resolvedLabel && (\n <HStack gap=\"2\" alignItems=\"center\">\n <Text style={switchStyles.text}>{resolvedLabel}</Text>\n {required && <Text color=\"alert\">*</Text>}\n </HStack>\n );\n\n const a11yValue = useMemo(() => ({ text: isOn ? 'On' : 'Off' }), [isOn]);\n\n return (\n <Pressable\n ref={ref}\n onPress={handlePress}\n disabled={disabled}\n accessible\n accessibilityRole=\"switch\"\n accessibilityState={{ checked: isOn, disabled }}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={resolvedAccessibilityHint}\n accessibilityValue={a11yValue}\n style={rootStyle}\n >\n {labelPosition === 'end' && labelContent}\n\n <Animated.View style={trackStyle} importantForAccessibility=\"no-hide-descendants\">\n <Animated.View style={handleStyle}>\n {onIcon && isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={onIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n {offIcon && !isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={offIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n </Animated.View>\n </Animated.View>\n\n {labelPosition === 'start' && labelContent}\n </Pressable>\n );\n});\n\nSwitch.displayName = 'Switch';\n\nconst switchStaticStyles = StyleSheet.create((theme) => ({\n handle: {\n borderRadius: theme.borderRadius.full,\n alignItems: 'center',\n justifyContent: 'center',\n },\n iconContainer: {\n position: 'absolute',\n alignItems: 'center',\n justifyContent: 'center',\n },\n track: {\n justifyContent: 'center',\n borderRadius: theme.borderRadius.full,\n },\n root: ({ disabled }: { disabled: boolean }) => ({\n flexDirection: 'row',\n alignItems: 'center',\n alignSelf: 'flex-start',\n opacity: disabled ? 0.5 : 1,\n }),\n}));\n\nexport { Switch, type SwitchProps };\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAMA,gBAA4C;CAChD,IAAI;CACJ,IAAI;CACL;AAED,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;AAoB3B,MAAM,SAAS,KAAK,SAASC,S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Aa;EACjC,YAAY;EACZ,gBAAgB;EACjB;CACD,eAAe;EACb,UAAU;EACV,YAAY;EACZ,gBAAgB;EACjB;CACD,OAAO;EACL,gBAAgB;EAChB,cAAc,MAAM,aAAa;EAClC;CACD,OAAO,EAAE,gBAAuC;EAC9C,eAAe;EACf,YAAY;EACZ,WAAW;EACX,SAAS,WAAW,KAAM;EAC3B;CACF,EAAE"}
|
|
1
|
+
{"version":3,"file":"Switch.mjs","names":["Text"],"sources":["../../src/components/Switch.tsx"],"sourcesContent":["import type { SwitchSize, UniversalSwitchProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useEffect, useMemo, useState } from 'react';\nimport type { AccessibilityProps, StyleProp, View, ViewStyle } from 'react-native';\nimport { AccessibilityInfo, Pressable } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withTiming } from 'react-native-reanimated';\nimport { StyleSheet } from 'react-native-unistyles';\nimport { useAnimatedVariantColor } from 'react-native-unistyles/reanimated';\n\nimport { switchStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Text } from './Text';\n\ninterface SwitchProps extends UniversalSwitchProps<IconSlotType> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Callback when the switch value changes */\n onChange?: (value: boolean) => void;\n /** Whether the switch is disabled */\n disabled?: boolean;\n /** Whether the switch is required (shows asterisk with label) */\n required?: boolean;\n /** Accessibility hint describing what happens when activated */\n accessibilityHint?: AccessibilityProps['accessibilityHint'];\n}\n\nconst HANDLE_TRAVEL: Record<SwitchSize, number> = {\n md: 20,\n sm: 12,\n};\n\nconst ANIMATION_DURATION = 120;\n\n/**\n * **Switch component for toggling options**\n *\n * @description\n * A switch (also called a toggle) is a binary on/off input control.\n * It allows users to pick between two clearly opposite choices.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Switch } from '@yahoo/uds-mobile';\n *\n * <Switch label=\"Notifications\" />\n * <Switch isOn={enabled} onChange={setEnabled} label=\"Dark mode\" />\n * <Switch onIcon=\"Check\" offIcon=\"Cross\" label=\"Sync\" />\n * ```\n *\n * @usage\n * - Settings: For toggling preferences on/off\n * - Feature flags: For enabling/disabling features\n * - Immediate effect toggles (no submit button needed)\n *\n * @accessibility\n * - Sets `accessibilityRole=\"switch\"` automatically\n * - Announces on/off state to screen readers\n * - Respects system reduce motion preference\n * - Supports `reduceMotion` prop to disable animations\n *\n * @see {@link Checkbox} for forms with submit actions\n * @see {@link Radio} for single-select options\n */\nconst Switch = memo(function Switch({\n isOn: isOnProp,\n defaultIsOn = false,\n onChange,\n label,\n labelPosition = 'start',\n size = 'md',\n onIcon,\n offIcon,\n disabled = false,\n required,\n accessibilityHint,\n reduceMotion = false,\n ref,\n}: SwitchProps) {\n const isControlled = isOnProp !== undefined;\n const [internalIsOn, setInternalIsOn] = useState(defaultIsOn);\n const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);\n const isOn = isControlled ? isOnProp : internalIsOn;\n\n // Check system reduced motion preference\n useEffect(() => {\n const checkReducedMotion = async () => {\n const isReduceMotionEnabled = await AccessibilityInfo.isReduceMotionEnabled();\n setPrefersReducedMotion(isReduceMotionEnabled);\n };\n checkReducedMotion();\n\n const subscription = AccessibilityInfo.addEventListener(\n 'reduceMotionChanged',\n setPrefersReducedMotion,\n );\n return () => subscription.remove();\n }, []);\n\n const shouldReduceMotion = reduceMotion || prefersReducedMotion;\n const animationDuration = shouldReduceMotion ? 0 : ANIMATION_DURATION;\n\n const progress = useDerivedValue(\n () => withTiming(isOn ? 1 : 0, { duration: animationDuration }),\n [isOn, animationDuration],\n );\n\n const travelDistance = HANDLE_TRAVEL[size];\n\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newValue = !isOn;\n\n if (!isControlled) {\n setInternalIsOn(newValue);\n }\n\n onChange?.(newValue);\n }, [disabled, isOn, isControlled, onChange]);\n\n switchStyles.useVariants({\n size,\n variant: isOn ? 'on' : 'off',\n });\n\n // Get animated track color from design tokens (changes when variant changes)\n const trackBackgroundColor = useAnimatedVariantColor(switchStyles.switch, 'backgroundColor');\n\n const animatedTrackStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n backgroundColor: withTiming(trackBackgroundColor.value, { duration: animationDuration }),\n };\n });\n\n const animatedHandleStyle = useAnimatedStyle(() => {\n 'worklet';\n return {\n transform: [{ translateX: progress.value * travelDistance }],\n };\n });\n\n const rootStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.root, switchStaticStyles.root({ disabled })],\n [switchStyles.root, disabled],\n );\n\n const trackStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.switch, switchStaticStyles.track, animatedTrackStyle],\n [switchStyles.switch, animatedTrackStyle],\n );\n\n const handleStyle: StyleProp<ViewStyle> = useMemo(\n () => [switchStyles.handle, switchStaticStyles.handle, animatedHandleStyle],\n [switchStyles.handle, animatedHandleStyle],\n );\n\n const accessibilityLabel = typeof label === 'string' ? label : undefined;\n const resolvedAccessibilityHint = accessibilityHint ?? 'Double tap to toggle';\n\n const resolvedLabel = typeof label === 'function' ? label() : label;\n const labelContent = resolvedLabel && (\n <HStack gap=\"2\" alignItems=\"center\">\n <Text style={switchStyles.text}>{resolvedLabel}</Text>\n {required && <Text color=\"alert\">*</Text>}\n </HStack>\n );\n\n const a11yValue = useMemo(() => ({ text: isOn ? 'On' : 'Off' }), [isOn]);\n\n return (\n <Pressable\n ref={ref}\n onPress={handlePress}\n disabled={disabled}\n accessible\n accessibilityRole=\"switch\"\n accessibilityState={{ checked: isOn, disabled }}\n accessibilityLabel={accessibilityLabel}\n accessibilityHint={resolvedAccessibilityHint}\n accessibilityValue={a11yValue}\n style={rootStyle}\n >\n {labelPosition === 'end' && labelContent}\n\n <Animated.View style={trackStyle} importantForAccessibility=\"no-hide-descendants\">\n <Animated.View style={handleStyle}>\n {onIcon && isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={onIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n {offIcon && !isOn && (\n <Animated.View style={switchStaticStyles.iconContainer}>\n <IconSlot icon={offIcon} variant=\"fill\" style={switchStyles.handleIcon} />\n </Animated.View>\n )}\n </Animated.View>\n </Animated.View>\n\n {labelPosition === 'start' && labelContent}\n </Pressable>\n );\n});\n\nSwitch.displayName = 'Switch';\n\nconst switchStaticStyles = StyleSheet.create((theme) => ({\n handle: {\n borderRadius: theme.borderRadius.full,\n alignItems: 'center',\n justifyContent: 'center',\n },\n iconContainer: {\n position: 'absolute',\n alignItems: 'center',\n justifyContent: 'center',\n },\n track: {\n justifyContent: 'center',\n borderRadius: theme.borderRadius.full,\n },\n root: ({ disabled }: { disabled: boolean }) => ({\n flexDirection: 'row',\n alignItems: 'center',\n alignSelf: 'flex-start',\n opacity: disabled ? 0.5 : 1,\n }),\n}));\n\nexport { Switch, type SwitchProps };\n"],"mappings":";;;;;;;;;;;;;AA4BA,MAAM,gBAA4C;CAChD,IAAI;CACJ,IAAI;CACL;AAED,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmC3B,MAAM,SAAS,KAAK,SAAS,OAAO,EAClC,MAAM,UACN,cAAc,OACd,UACA,OACA,gBAAgB,SAChB,OAAO,MACP,QACA,SACA,WAAW,OACX,UACA,mBACA,eAAe,OACf,OACc;CACd,MAAM,eAAe,aAAa;CAClC,MAAM,CAAC,cAAc,mBAAmB,SAAS,YAAY;CAC7D,MAAM,CAAC,sBAAsB,2BAA2B,SAAS,MAAM;CACvE,MAAM,OAAO,eAAe,WAAW;AAGvC,iBAAgB;EACd,MAAM,qBAAqB,YAAY;AAErC,2BAD8B,MAAM,kBAAkB,uBAAuB,CAC/B;;AAEhD,sBAAoB;EAEpB,MAAM,eAAe,kBAAkB,iBACrC,uBACA,wBACD;AACD,eAAa,aAAa,QAAQ;IACjC,EAAE,CAAC;CAGN,MAAM,oBADqB,gBAA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Y,oBAACA;GAAK,OAAM;aAAQ;IAAQ;GAClC;CAGX,MAAM,YAAY,eAAe,EAAE,MAAM,OAAO,OAAO,OAAO,GAAG,CAAC,KAAK,CAAC;AAExE,QACE,qBAAC;EACM;EACL,SAAS;EACC;EACV;EACA,mBAAkB;EAClB,oBAAoB;GAAE,SAAS;GAAM;GAAU;EAC3B;EACpB,mBAAmB;EACnB,oBAAoB;EACpB,OAAO;;GAEN,kBAAkB,SAAS;GAE5B,oBAAC,SAAS;IAAK,OAAO;IAAY,2BAA0B;cAC1D,qBAAC,SAAS;KAAK,OAAO;gBACnB,UAAU,QACT,oBAAC,SAAS;MAAK,OAAO,mBAAmB;gBACvC,oBAAC;OAAS,MAAM;OAAQ,SAAQ;OAAO,OAAO,aAAa;QAAc;OAC3D,EAEjB,WAAW,CAAC,QACX,oBAAC,SAAS;MAAK,OAAO,mBAAmB;gBACvC,oBAAC;OAAS,MAAM;OAAS,SAAQ;OAAO,OAAO,aAAa;QAAc;OAC5D;MAEJ;KACF;GAEf,kBAAkB,WAAW;;GACpB;EAEd;AAEF,OAAO,cAAc;AAErB,MAAM,qBAAqB,WAAW,QAAQ,WAAW;CACvD,QAAQ;EACN,cAAc,MAAM,aAAa;EACjC,YAAY;EACZ,gBAAgB;EACjB;CACD,eAAe;EACb,UAAU;EACV,YAAY;EACZ,gBAAgB;EACjB;CACD,OAAO;EACL,gBAAgB;EAChB,cAAc,MAAM,aAAa;EAClC;CACD,OAAO,EAAE,gBAAuC;EAC9C,eAAe;EACf,YAAY;EACZ,WAAW;EACX,SAAS,WAAW,KAAM;EAC3B;CACF,EAAE"}
|
package/dist/components/Text.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
let react = require("react");
|
|
4
5
|
let react_native = require("react-native");
|
|
5
6
|
let generated_styles = require("../../generated/styles");
|
|
@@ -12,22 +13,31 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
12
13
|
* @description
|
|
13
14
|
* A styled text component that supports UDS typography variants and colors.
|
|
14
15
|
*
|
|
16
|
+
* @category Display
|
|
17
|
+
* @platform mobile
|
|
18
|
+
*
|
|
15
19
|
* @example
|
|
16
20
|
* ```tsx
|
|
17
21
|
* import { Text } from '@yahoo/uds-mobile';
|
|
18
22
|
*
|
|
19
|
-
* <Text variant="body1" color="primary">
|
|
20
|
-
*
|
|
21
|
-
* </Text>
|
|
23
|
+
* <Text variant="body1" color="primary">Hello, World!</Text>
|
|
24
|
+
* <Text variant="display1" fontWeight="bold">Heading</Text>
|
|
25
|
+
* <Text variant="label1" color="secondary">Caption text</Text>
|
|
22
26
|
* ```
|
|
23
27
|
*
|
|
24
28
|
* @usage
|
|
25
29
|
* - Use variant prop to set typography (display1, body1, label1, etc.)
|
|
26
30
|
* - Use color prop to set text color from the palette
|
|
31
|
+
* - Use fontWeight to override the variant's default weight
|
|
32
|
+
*
|
|
33
|
+
* @accessibility
|
|
34
|
+
* - Text is readable by screen readers by default
|
|
35
|
+
* - Use appropriate variant sizes for readability
|
|
36
|
+
* - Ensure sufficient color contrast with background
|
|
27
37
|
*
|
|
28
|
-
* @see
|
|
38
|
+
* @see {@link Link} for interactive text links
|
|
29
39
|
*/
|
|
30
|
-
const Text = (0, react.memo)(function Text
|
|
40
|
+
const Text = (0, react.memo)(function Text({ color = "primary", variant = "body1", fontFamily = variant, fontSize = variant, fontWeight, lineHeight = variant, letterSpacing = variant, textAlign, textTransform, textDecorationLine, style, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, flexShrink, verticalAlign, height, minHeight, maxHeight, width, minWidth, maxWidth, dangerouslySetColor, ref, ...props }) {
|
|
31
41
|
generated_styles.styles.useVariants({
|
|
32
42
|
color,
|
|
33
43
|
fontFamily,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import * as
|
|
2
|
+
import * as react from "react";
|
|
3
3
|
import { Ref } from "react";
|
|
4
4
|
import { Text as Text$1, TextProps as TextProps$1, TextStyle } from "react-native";
|
|
5
5
|
import { StyleProps } from "../../generated/styles";
|
|
@@ -8,7 +8,9 @@ import { StyleProps } from "../../generated/styles";
|
|
|
8
8
|
type TextVariant = Exclude<StyleProps['fontFamily'], 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'>;
|
|
9
9
|
type TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';
|
|
10
10
|
interface TextProps extends TextProps$1 {
|
|
11
|
+
/** Ref to the underlying Text element */
|
|
11
12
|
ref?: Ref<Text$1>;
|
|
13
|
+
/** Text color from the theme palette */
|
|
12
14
|
color?: StyleProps['color'];
|
|
13
15
|
/** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */
|
|
14
16
|
variant?: TextVariant;
|
|
@@ -22,6 +24,7 @@ interface TextProps extends TextProps$1 {
|
|
|
22
24
|
lineHeight?: StyleProps['lineHeight'];
|
|
23
25
|
/** Override the letterSpacing independently */
|
|
24
26
|
letterSpacing?: StyleProps['letterSpacing'];
|
|
27
|
+
/** Text alignment (left, center, right) */
|
|
25
28
|
textAlign?: StyleProps['textAlign'];
|
|
26
29
|
/** Set text transform (not derived from variant) */
|
|
27
30
|
textTransform?: StyleProps['textTransform'];
|
|
@@ -75,22 +78,31 @@ interface TextProps extends TextProps$1 {
|
|
|
75
78
|
* @description
|
|
76
79
|
* A styled text component that supports UDS typography variants and colors.
|
|
77
80
|
*
|
|
81
|
+
* @category Display
|
|
82
|
+
* @platform mobile
|
|
83
|
+
*
|
|
78
84
|
* @example
|
|
79
85
|
* ```tsx
|
|
80
86
|
* import { Text } from '@yahoo/uds-mobile';
|
|
81
87
|
*
|
|
82
|
-
* <Text variant="body1" color="primary">
|
|
83
|
-
*
|
|
84
|
-
* </Text>
|
|
88
|
+
* <Text variant="body1" color="primary">Hello, World!</Text>
|
|
89
|
+
* <Text variant="display1" fontWeight="bold">Heading</Text>
|
|
90
|
+
* <Text variant="label1" color="secondary">Caption text</Text>
|
|
85
91
|
* ```
|
|
86
92
|
*
|
|
87
93
|
* @usage
|
|
88
94
|
* - Use variant prop to set typography (display1, body1, label1, etc.)
|
|
89
95
|
* - Use color prop to set text color from the palette
|
|
96
|
+
* - Use fontWeight to override the variant's default weight
|
|
97
|
+
*
|
|
98
|
+
* @accessibility
|
|
99
|
+
* - Text is readable by screen readers by default
|
|
100
|
+
* - Use appropriate variant sizes for readability
|
|
101
|
+
* - Ensure sufficient color contrast with background
|
|
90
102
|
*
|
|
91
|
-
* @see
|
|
103
|
+
* @see {@link Link} for interactive text links
|
|
92
104
|
*/
|
|
93
|
-
declare const Text:
|
|
105
|
+
declare const Text: react.NamedExoticComponent<TextProps>;
|
|
94
106
|
//#endregion
|
|
95
107
|
export { Text, type TextProps };
|
|
96
108
|
//# sourceMappingURL=Text.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.cts","names":[],"sources":["../../src/components/Text.tsx"],"
|
|
1
|
+
{"version":3,"file":"Text.d.cts","names":[],"sources":["../../src/components/Text.tsx"],"mappings":";;;;;;;KASK,WAAA,GAAc,OAAA,CACjB,UAAA;AAAA,KAMG,kBAAA;AAAA,UAEK,SAAA,SAAkB,WAAA;EATZ;EAWd,GAAA,GAAM,GAAA,CAAI,MAAA;EAXO;EAajB,KAAA,GAAQ,UAAA;EANL;EAQH,OA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;cAiCI,IAAA,EAAI,KAAA,CAAA,oBAAA,CAAA,SAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import * as
|
|
2
|
+
import * as react from "react";
|
|
3
3
|
import { Ref } from "react";
|
|
4
4
|
import { Text as Text$1, TextProps as TextProps$1, TextStyle } from "react-native";
|
|
5
5
|
import { StyleProps } from "../../generated/styles";
|
|
@@ -8,7 +8,9 @@ import { StyleProps } from "../../generated/styles";
|
|
|
8
8
|
type TextVariant = Exclude<StyleProps['fontFamily'], 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'>;
|
|
9
9
|
type TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';
|
|
10
10
|
interface TextProps extends TextProps$1 {
|
|
11
|
+
/** Ref to the underlying Text element */
|
|
11
12
|
ref?: Ref<Text$1>;
|
|
13
|
+
/** Text color from the theme palette */
|
|
12
14
|
color?: StyleProps['color'];
|
|
13
15
|
/** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */
|
|
14
16
|
variant?: TextVariant;
|
|
@@ -22,6 +24,7 @@ interface TextProps extends TextProps$1 {
|
|
|
22
24
|
lineHeight?: StyleProps['lineHeight'];
|
|
23
25
|
/** Override the letterSpacing independently */
|
|
24
26
|
letterSpacing?: StyleProps['letterSpacing'];
|
|
27
|
+
/** Text alignment (left, center, right) */
|
|
25
28
|
textAlign?: StyleProps['textAlign'];
|
|
26
29
|
/** Set text transform (not derived from variant) */
|
|
27
30
|
textTransform?: StyleProps['textTransform'];
|
|
@@ -75,22 +78,31 @@ interface TextProps extends TextProps$1 {
|
|
|
75
78
|
* @description
|
|
76
79
|
* A styled text component that supports UDS typography variants and colors.
|
|
77
80
|
*
|
|
81
|
+
* @category Display
|
|
82
|
+
* @platform mobile
|
|
83
|
+
*
|
|
78
84
|
* @example
|
|
79
85
|
* ```tsx
|
|
80
86
|
* import { Text } from '@yahoo/uds-mobile';
|
|
81
87
|
*
|
|
82
|
-
* <Text variant="body1" color="primary">
|
|
83
|
-
*
|
|
84
|
-
* </Text>
|
|
88
|
+
* <Text variant="body1" color="primary">Hello, World!</Text>
|
|
89
|
+
* <Text variant="display1" fontWeight="bold">Heading</Text>
|
|
90
|
+
* <Text variant="label1" color="secondary">Caption text</Text>
|
|
85
91
|
* ```
|
|
86
92
|
*
|
|
87
93
|
* @usage
|
|
88
94
|
* - Use variant prop to set typography (display1, body1, label1, etc.)
|
|
89
95
|
* - Use color prop to set text color from the palette
|
|
96
|
+
* - Use fontWeight to override the variant's default weight
|
|
97
|
+
*
|
|
98
|
+
* @accessibility
|
|
99
|
+
* - Text is readable by screen readers by default
|
|
100
|
+
* - Use appropriate variant sizes for readability
|
|
101
|
+
* - Ensure sufficient color contrast with background
|
|
90
102
|
*
|
|
91
|
-
* @see
|
|
103
|
+
* @see {@link Link} for interactive text links
|
|
92
104
|
*/
|
|
93
|
-
declare const Text:
|
|
105
|
+
declare const Text: react.NamedExoticComponent<TextProps>;
|
|
94
106
|
//#endregion
|
|
95
107
|
export { Text, type TextProps };
|
|
96
108
|
//# sourceMappingURL=Text.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.d.mts","names":[],"sources":["../../src/components/Text.tsx"],"
|
|
1
|
+
{"version":3,"file":"Text.d.mts","names":[],"sources":["../../src/components/Text.tsx"],"mappings":";;;;;;;KASK,WAAA,GAAc,OAAA,CACjB,UAAA;AAAA,KAMG,kBAAA;AAAA,UAEK,SAAA,SAAkB,WAAA;EATZ;EAWd,GAAA,GAAM,GAAA,CAAI,MAAA;EAXO;EAajB,KAAA,GAAQ,UAAA;EANL;EAQH,OAAA,GAAU,WAAA;;EAEV,UAAA,GAAa,UAAA;EAVQ;EAYrB,QAAA,GAAW,UAAA;EAVO;EAYlB,UAAA,GAAa,UAAA;EAVH;EAYV,UAAA,GAAa,UAAA;EAVL;EAYR,aAAA,GAAgB,UAAA;EARH;EAUb,SAAA,GAAY,UAAA;EANC;EAQb,aAAA,GAAgB,UAAA;EAJA;EAMhB,kBAAA,GAAqB,kBAAA;EAErB,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,OAAA,GAAU,UAAA;EACV,iBAAA,GAAoB,UAAA;EACpB,eAAA,GAAkB,UAAA;EAClB,aAAA,GAAgB,UAAA;EAChB,UAAA,GAAa,UAAA;EACb,YAAA,GAAe,UAAA;EACf,UAAA,GAAa,UAAA;EAEb,MAAA,GAAS,UAAA;EACT,cAAA,GAAiB,UAAA;EACjB,gBAAA,GAAmB,UAAA;EACnB,YAAA,GAAe,UAAA;EACf,SAAA,GAAY,UAAA;EACZ,WAAA,GAAc,UAAA;EACd,SAAA,GAAY,UAAA;EAEZ,UAAA,GAAa,UAAA;EAEb,aAAA,GAAgB,SAAA;EAEhB,MAAA;EACA,KAAA;EACA,SAAA;EACA,SAAA;EACA,QAAA;EACA,QAAA;EAEA,mBAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCI,IAAA,EAAI,KAAA,CAAA,oBAAA,CAAA,SAAA"}
|
package/dist/components/Text.mjs
CHANGED
|
@@ -11,22 +11,31 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
* @description
|
|
12
12
|
* A styled text component that supports UDS typography variants and colors.
|
|
13
13
|
*
|
|
14
|
+
* @category Display
|
|
15
|
+
* @platform mobile
|
|
16
|
+
*
|
|
14
17
|
* @example
|
|
15
18
|
* ```tsx
|
|
16
19
|
* import { Text } from '@yahoo/uds-mobile';
|
|
17
20
|
*
|
|
18
|
-
* <Text variant="body1" color="primary">
|
|
19
|
-
*
|
|
20
|
-
* </Text>
|
|
21
|
+
* <Text variant="body1" color="primary">Hello, World!</Text>
|
|
22
|
+
* <Text variant="display1" fontWeight="bold">Heading</Text>
|
|
23
|
+
* <Text variant="label1" color="secondary">Caption text</Text>
|
|
21
24
|
* ```
|
|
22
25
|
*
|
|
23
26
|
* @usage
|
|
24
27
|
* - Use variant prop to set typography (display1, body1, label1, etc.)
|
|
25
28
|
* - Use color prop to set text color from the palette
|
|
29
|
+
* - Use fontWeight to override the variant's default weight
|
|
30
|
+
*
|
|
31
|
+
* @accessibility
|
|
32
|
+
* - Text is readable by screen readers by default
|
|
33
|
+
* - Use appropriate variant sizes for readability
|
|
34
|
+
* - Ensure sufficient color contrast with background
|
|
26
35
|
*
|
|
27
|
-
* @see
|
|
36
|
+
* @see {@link Link} for interactive text links
|
|
28
37
|
*/
|
|
29
|
-
const Text = memo(function Text
|
|
38
|
+
const Text = memo(function Text({ color = "primary", variant = "body1", fontFamily = variant, fontSize = variant, fontWeight, lineHeight = variant, letterSpacing = variant, textAlign, textTransform, textDecorationLine, style, backgroundColor, borderRadius, borderTopStartRadius, borderTopEndRadius, borderBottomStartRadius, borderBottomEndRadius, borderColor, borderStartColor, borderEndColor, borderTopColor, borderBottomColor, borderWidth, borderVerticalWidth, borderHorizontalWidth, borderStartWidth, borderEndWidth, borderTopWidth, borderBottomWidth, spacing, spacingHorizontal, spacingVertical, spacingBottom, spacingEnd, spacingStart, spacingTop, offset, offsetVertical, offsetHorizontal, offsetBottom, offsetEnd, offsetStart, offsetTop, flexShrink, verticalAlign, height, minHeight, maxHeight, width, minWidth, maxWidth, dangerouslySetColor, ref, ...props }) {
|
|
30
39
|
styles.useVariants({
|
|
31
40
|
color,
|
|
32
41
|
fontFamily,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Text.mjs","names":["
|
|
1
|
+
{"version":3,"file":"Text.mjs","names":["RNText"],"sources":["../../src/components/Text.tsx"],"sourcesContent":["import type { Ref } from 'react';\nimport { memo, useMemo } from 'react';\nimport type { StyleProp, TextProps as RNTextProps, TextStyle } from 'react-native';\nimport { Text as RNText } from 'react-native';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\n\n// TextVariant is a subset of fontFamily that represents typography variants\ntype TextVariant = Exclude<\n StyleProps['fontFamily'],\n 'sans' | 'sans-alt' | 'serif' | 'serif-alt' | 'mono' | 'icons'\n>;\n\n// React Native text decoration line values\n// See: https://reactnative.dev/docs/text-style-props#textdecorationline\ntype TextDecorationLine = 'none' | 'underline' | 'line-through' | 'underline line-through';\n\ninterface TextProps extends RNTextProps {\n /** Ref to the underlying Text element */\n ref?: Ref<RNText>;\n /** Text color from the theme palette */\n color?: StyleProps['color'];\n /** Typography variant - sets fontSize, lineHeight, letterSpacing, and fontFamily together */\n variant?: TextVariant;\n /** Override the fontFamily independently */\n fontFamily?: StyleProps['fontFamily'];\n /** Override the fontSize independently */\n fontSize?: StyleProps['fontSize'];\n /** Set font weight (not derived from variant) */\n fontWeight?: StyleProps['fontWeight'];\n /** Override the lineHeight independently */\n lineHeight?: StyleProps['lineHeight'];\n /** Override the letterSpacing independently */\n letterSpacing?: StyleProps['letterSpacing'];\n /** Text alignment (left, center, right) */\n textAlign?: StyleProps['textAlign'];\n /** Set text transform (not derived from variant) */\n textTransform?: StyleProps['textTransform'];\n /** Text decoration (underline, line-through, etc.) */\n textDecorationLine?: TextDecorationLine;\n // Background\n backgroundColor?: StyleProps['backgroundColor'];\n // Border\n borderRadius?: StyleProps['borderRadius'];\n borderTopStartRadius?: StyleProps['borderTopStartRadius'];\n borderTopEndRadius?: StyleProps['borderTopEndRadius'];\n borderBottomStartRadius?: StyleProps['borderBottomStartRadius'];\n borderBottomEndRadius?: StyleProps['borderBottomEndRadius'];\n borderColor?: StyleProps['borderColor'];\n borderStartColor?: StyleProps['borderStartColor'];\n borderEndColor?: StyleProps['borderEndColor'];\n borderTopColor?: StyleProps['borderTopColor'];\n borderBottomColor?: StyleProps['borderBottomColor'];\n borderWidth?: StyleProps['borderWidth'];\n borderVerticalWidth?: StyleProps['borderVerticalWidth'];\n borderHorizontalWidth?: StyleProps['borderHorizontalWidth'];\n borderStartWidth?: StyleProps['borderStartWidth'];\n borderEndWidth?: StyleProps['borderEndWidth'];\n borderTopWidth?: StyleProps['borderTopWidth'];\n borderBottomWidth?: StyleProps['borderBottomWidth'];\n // Spacing\n spacing?: StyleProps['spacing'];\n spacingHorizontal?: StyleProps['spacingHorizontal'];\n spacingVertical?: StyleProps['spacingVertical'];\n spacingBottom?: StyleProps['spacingBottom'];\n spacingEnd?: StyleProps['spacingEnd'];\n spacingStart?: StyleProps['spacingStart'];\n spacingTop?: StyleProps['spacingTop'];\n // Offset\n offset?: StyleProps['offset'];\n offsetVertical?: StyleProps['offsetVertical'];\n offsetHorizontal?: StyleProps['offsetHorizontal'];\n offsetBottom?: StyleProps['offsetBottom'];\n offsetEnd?: StyleProps['offsetEnd'];\n offsetStart?: StyleProps['offsetStart'];\n offsetTop?: StyleProps['offsetTop'];\n // Flex\n flexShrink?: StyleProps['flexShrink'];\n // Vertical Alignment\n verticalAlign?: TextStyle['textAlignVertical'];\n // Size\n height?: number | `${number}%`;\n width?: number | `${number}%`;\n minHeight?: number | `${number}%`;\n maxHeight?: number | `${number}%`;\n minWidth?: number | `${number}%`;\n maxWidth?: number | `${number}%`;\n // Dangerously set props\n dangerouslySetColor?: string;\n}\n\n/**\n * **📝 A text component with UDS styling**\n *\n * @description\n * A styled text component that supports UDS typography variants and colors.\n *\n * @category Display\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Text } from '@yahoo/uds-mobile';\n *\n * <Text variant=\"body1\" color=\"primary\">Hello, World!</Text>\n * <Text variant=\"display1\" fontWeight=\"bold\">Heading</Text>\n * <Text variant=\"label1\" color=\"secondary\">Caption text</Text>\n * ```\n *\n * @usage\n * - Use variant prop to set typography (display1, body1, label1, etc.)\n * - Use color prop to set text color from the palette\n * - Use fontWeight to override the variant's default weight\n *\n * @accessibility\n * - Text is readable by screen readers by default\n * - Use appropriate variant sizes for readability\n * - Ensure sufficient color contrast with background\n *\n * @see {@link Link} for interactive text links\n */\nconst Text = memo(function Text({\n // Text-specific\n color = 'primary',\n variant = 'body1',\n fontFamily = variant,\n fontSize = variant,\n fontWeight,\n lineHeight = variant,\n letterSpacing = variant,\n textAlign,\n textTransform,\n textDecorationLine,\n style,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n // Offset\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n // Flex\n flexShrink,\n // Vertical Alignment\n verticalAlign,\n // Size\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n // Dangerously set props\n dangerouslySetColor,\n ref,\n // Rest\n ...props\n}: TextProps) {\n styles.useVariants({\n // Text styles\n color,\n fontFamily,\n fontSize,\n fontWeight,\n lineHeight,\n letterSpacing,\n textAlign,\n textTransform,\n // Background\n backgroundColor,\n // Border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // Spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n // Offset\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n // Flex\n flexShrink,\n });\n\n // styles.foundation must be in deps - it returns a new reference when variants change.\n const computedStyle: StyleProp<TextStyle> = useMemo(\n () => [\n textDecorationLine ? { textDecorationLine } : undefined,\n dangerouslySetColor ? { color: dangerouslySetColor } : undefined,\n verticalAlign ? { textAlignVertical: verticalAlign } : undefined,\n height ? { height } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n width ? { width } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n styles.foundation,\n style,\n ],\n [\n textDecorationLine,\n dangerouslySetColor,\n verticalAlign,\n height,\n minHeight,\n maxHeight,\n width,\n minWidth,\n maxWidth,\n style,\n styles.foundation,\n ],\n );\n\n return <RNText ref={ref} style={computedStyle} {...props} />;\n});\n\nText.displayName = 'Text';\n\nexport { Text, type TextProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0HA,MAAM,OAAO,KAAK,SAAS,KAAK,EAE9B,QAAQ,WACR,UAAU,SACV,aAAa,SACb,WAAW,SACX,YACA,aAAa,SACb,gBAAgB,SAChB,WACA,eACA,oBACA,OAEA,iBAEA,cACA,sBACA,oBACA,yBACA,uBACA,aACA,kBACA,gBACA,gBACA,mBACA,aACA,qBACA,uBACA,kBACA,gBACA,gBACA,mBAEA,SACA,mBACA,iBACA,eACA,YACA,cACA,YAEA,QACA,gBACA,kBACA,cACA,WACA,aACA,WAEA,YAEA,eAEA,QACA,WACA,WACA,OACA,UACA,UAEA,qBACA,KAEA,GAAG,SACS;AACZ,QAAO,YAAY;EAEjB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;EAEA;EACD,CAAC;AAgCF,QAAO,oBAACA;EAAY;EAAK,OA7BmB,cACpC;GACJ,qBAAqB,EAAE,oBAAoB,GAAG;GAC9C,sBAAsB,EAAE,OAAO,qBAAqB,GAAG;GACvD,gBAAgB,EAAE,mBAAmB,eAAe,GAAG;GACvD,SAAS,EAAE,QAAQ,GAAG;GACtB,YAAY,EAAE,WAAW,GAAG;GAC5B,YAAY,EAAE,WAAW,GAAG;GAC5B,QAAQ,EAAE,OAAO,GAAG;GACpB,WAAW,EAAE,UAAU,GAAG;GAC1B,WAAW,EAAE,UAAU,GAAG;GAC1B,OAAO;GACP;GACD,EACD;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA,OAAO;GACR,CACF;EAE8C,GAAI;GAAS;EAC5D;AAEF,KAAK,cAAc"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
3
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
4
|
const require_components_Box = require('./Box.cjs');
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -12,6 +13,9 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
12
13
|
* A convenience component for creating vertical layouts. It's a Box with
|
|
13
14
|
* `flexDirection="column"` preset.
|
|
14
15
|
*
|
|
16
|
+
* @category Layout
|
|
17
|
+
* @platform mobile
|
|
18
|
+
*
|
|
15
19
|
* @example
|
|
16
20
|
* ```tsx
|
|
17
21
|
* import { VStack } from '@yahoo/uds-mobile';
|
|
@@ -26,11 +30,10 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
26
30
|
* - Use for vertical arrangements of elements
|
|
27
31
|
* - Use gap prop for consistent spacing between children
|
|
28
32
|
*
|
|
29
|
-
* @see
|
|
30
|
-
*
|
|
31
|
-
* @related [HStack](https://uds.build/docs/components/h-stack), [Box](https://uds.build/docs/components/box)
|
|
33
|
+
* @see {@link HStack} for horizontal layouts
|
|
34
|
+
* @see {@link Box} for custom flex layouts
|
|
32
35
|
*/
|
|
33
|
-
const VStack = (0, react.memo)(function VStack
|
|
36
|
+
const VStack = (0, react.memo)(function VStack({ gap, children, ref, ...props }) {
|
|
34
37
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
|
|
35
38
|
ref,
|
|
36
39
|
flexDirection: "column",
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { BoxProps } from "./Box.cjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
7
7
|
|
|
8
8
|
//#region src/components/VStack.d.ts
|
|
9
9
|
interface VStackProps extends Omit<BoxProps, 'ref'> {
|
|
10
|
+
/** Gap between child elements */
|
|
10
11
|
gap?: StyleProps['rowGap'];
|
|
12
|
+
/** Ref to the underlying View */
|
|
11
13
|
ref?: Ref<View>;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
@@ -17,6 +19,9 @@ interface VStackProps extends Omit<BoxProps, 'ref'> {
|
|
|
17
19
|
* A convenience component for creating vertical layouts. It's a Box with
|
|
18
20
|
* `flexDirection="column"` preset.
|
|
19
21
|
*
|
|
22
|
+
* @category Layout
|
|
23
|
+
* @platform mobile
|
|
24
|
+
*
|
|
20
25
|
* @example
|
|
21
26
|
* ```tsx
|
|
22
27
|
* import { VStack } from '@yahoo/uds-mobile';
|
|
@@ -31,11 +36,10 @@ interface VStackProps extends Omit<BoxProps, 'ref'> {
|
|
|
31
36
|
* - Use for vertical arrangements of elements
|
|
32
37
|
* - Use gap prop for consistent spacing between children
|
|
33
38
|
*
|
|
34
|
-
* @see
|
|
35
|
-
*
|
|
36
|
-
* @related [HStack](https://uds.build/docs/components/h-stack), [Box](https://uds.build/docs/components/box)
|
|
39
|
+
* @see {@link HStack} for horizontal layouts
|
|
40
|
+
* @see {@link Box} for custom flex layouts
|
|
37
41
|
*/
|
|
38
|
-
declare const VStack:
|
|
42
|
+
declare const VStack: react.NamedExoticComponent<VStackProps>;
|
|
39
43
|
//#endregion
|
|
40
44
|
export { VStack, type VStackProps };
|
|
41
45
|
//# sourceMappingURL=VStack.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VStack.d.cts","names":[],"sources":["../../src/components/VStack.tsx"],"
|
|
1
|
+
{"version":3,"file":"VStack.d.cts","names":[],"sources":["../../src/components/VStack.tsx"],"mappings":";;;;;;;;UAQU,WAAA,SAAoB,IAAA,CAAK,QAAA;;EAEjC,GAAA,GAAM,UAAA;EAFE;EAIR,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;;;;;;;;;;;;;;;;;AAAI;;;;;;;;;;;cA8BV,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
|
|
2
2
|
import { BoxProps } from "./Box.mjs";
|
|
3
|
-
import * as
|
|
3
|
+
import * as react from "react";
|
|
4
4
|
import { Ref } from "react";
|
|
5
5
|
import { View } from "react-native";
|
|
6
6
|
import { StyleProps } from "../../generated/styles";
|
|
7
7
|
|
|
8
8
|
//#region src/components/VStack.d.ts
|
|
9
9
|
interface VStackProps extends Omit<BoxProps, 'ref'> {
|
|
10
|
+
/** Gap between child elements */
|
|
10
11
|
gap?: StyleProps['rowGap'];
|
|
12
|
+
/** Ref to the underlying View */
|
|
11
13
|
ref?: Ref<View>;
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
@@ -17,6 +19,9 @@ interface VStackProps extends Omit<BoxProps, 'ref'> {
|
|
|
17
19
|
* A convenience component for creating vertical layouts. It's a Box with
|
|
18
20
|
* `flexDirection="column"` preset.
|
|
19
21
|
*
|
|
22
|
+
* @category Layout
|
|
23
|
+
* @platform mobile
|
|
24
|
+
*
|
|
20
25
|
* @example
|
|
21
26
|
* ```tsx
|
|
22
27
|
* import { VStack } from '@yahoo/uds-mobile';
|
|
@@ -31,11 +36,10 @@ interface VStackProps extends Omit<BoxProps, 'ref'> {
|
|
|
31
36
|
* - Use for vertical arrangements of elements
|
|
32
37
|
* - Use gap prop for consistent spacing between children
|
|
33
38
|
*
|
|
34
|
-
* @see
|
|
35
|
-
*
|
|
36
|
-
* @related [HStack](https://uds.build/docs/components/h-stack), [Box](https://uds.build/docs/components/box)
|
|
39
|
+
* @see {@link HStack} for horizontal layouts
|
|
40
|
+
* @see {@link Box} for custom flex layouts
|
|
37
41
|
*/
|
|
38
|
-
declare const VStack:
|
|
42
|
+
declare const VStack: react.NamedExoticComponent<VStackProps>;
|
|
39
43
|
//#endregion
|
|
40
44
|
export { VStack, type VStackProps };
|
|
41
45
|
//# sourceMappingURL=VStack.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VStack.d.mts","names":[],"sources":["../../src/components/VStack.tsx"],"
|
|
1
|
+
{"version":3,"file":"VStack.d.mts","names":[],"sources":["../../src/components/VStack.tsx"],"mappings":";;;;;;;;UAQU,WAAA,SAAoB,IAAA,CAAK,QAAA;;EAEjC,GAAA,GAAM,UAAA;EAFE;EAIR,GAAA,GAAM,GAAA,CAAI,IAAA;AAAA;;;;;;;;;;;;;;;;;AAAI;;;;;;;;;;;cA8BV,MAAA,EAAM,KAAA,CAAA,oBAAA,CAAA,WAAA"}
|
|
@@ -11,6 +11,9 @@ import { jsx } from "react/jsx-runtime";
|
|
|
11
11
|
* A convenience component for creating vertical layouts. It's a Box with
|
|
12
12
|
* `flexDirection="column"` preset.
|
|
13
13
|
*
|
|
14
|
+
* @category Layout
|
|
15
|
+
* @platform mobile
|
|
16
|
+
*
|
|
14
17
|
* @example
|
|
15
18
|
* ```tsx
|
|
16
19
|
* import { VStack } from '@yahoo/uds-mobile';
|
|
@@ -25,11 +28,10 @@ import { jsx } from "react/jsx-runtime";
|
|
|
25
28
|
* - Use for vertical arrangements of elements
|
|
26
29
|
* - Use gap prop for consistent spacing between children
|
|
27
30
|
*
|
|
28
|
-
* @see
|
|
29
|
-
*
|
|
30
|
-
* @related [HStack](https://uds.build/docs/components/h-stack), [Box](https://uds.build/docs/components/box)
|
|
31
|
+
* @see {@link HStack} for horizontal layouts
|
|
32
|
+
* @see {@link Box} for custom flex layouts
|
|
31
33
|
*/
|
|
32
|
-
const VStack = memo(function VStack
|
|
34
|
+
const VStack = memo(function VStack({ gap, children, ref, ...props }) {
|
|
33
35
|
return /* @__PURE__ */ jsx(Box, {
|
|
34
36
|
ref,
|
|
35
37
|
flexDirection: "column",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VStack.mjs","names":[
|
|
1
|
+
{"version":3,"file":"VStack.mjs","names":[],"sources":["../../src/components/VStack.tsx"],"sourcesContent":["import type { Ref } from 'react';\nimport { memo } from 'react';\nimport type { View } from 'react-native';\n\nimport type { StyleProps } from '../../generated/styles';\nimport type { BoxProps } from './Box';\nimport { Box } from './Box';\n\ninterface VStackProps extends Omit<BoxProps, 'ref'> {\n /** Gap between child elements */\n gap?: StyleProps['rowGap'];\n /** Ref to the underlying View */\n ref?: Ref<View>;\n}\n\n/**\n * **📦 A vertical stack layout component**\n *\n * @description\n * A convenience component for creating vertical layouts. It's a Box with\n * `flexDirection=\"column\"` preset.\n *\n * @category Layout\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { VStack } from '@yahoo/uds-mobile';\n *\n * <VStack gap=\"4\" alignItems=\"stretch\">\n * <Text>Item 1</Text>\n * <Text>Item 2</Text>\n * </VStack>\n * ```\n *\n * @usage\n * - Use for vertical arrangements of elements\n * - Use gap prop for consistent spacing between children\n *\n * @see {@link HStack} for horizontal layouts\n * @see {@link Box} for custom flex layouts\n */\nconst VStack = memo(function VStack({ gap, children, ref, ...props }: VStackProps) {\n return (\n <Box ref={ref} flexDirection=\"column\" columnGap={gap} rowGap={gap} {...props}>\n {children}\n </Box>\n );\n});\n\nVStack.displayName = 'VStack';\n\nexport { VStack, type VStackProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,MAAM,SAAS,KAAK,SAAS,OAAO,EAAE,KAAK,UAAU,KAAK,GAAG,SAAsB;AACjF,QACE,oBAAC;EAAS;EAAK,eAAc;EAAS,WAAW;EAAK,QAAQ;EAAK,GAAI;EACpE;GACG;EAER;AAEF,OAAO,cAAc"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
|
|
2
2
|
//#region ../icons/dist/glyphMap.d.ts
|
|
3
|
-
|
|
4
3
|
//#region generated/font/glyphMap.d.ts
|
|
5
4
|
type GlyphName = (typeof glyphNames)[number];
|
|
6
5
|
declare const glyphNames: readonly ["A11Y", "Accessible", "AccountRecover", "AccountRefresh", "AccountSwitchAlt", "AccountSwitcher", "AcousticGuitar", "Add", "AddBell", "AddCalendar", "AddCheckCircle", "AddCircle", "AddContactCard", "AddDocument", "AddFace", "AddFolder", "AddPaperPlane", "AddPeople", "AddQuestion", "AddSearch", "AddSquare", "AffiliateLink", "AirQuality", "Airplane", "AirplaneLanding", "AirplaneTakeOff", "AngledSquareOnSquare", "AnyFile", "AppSwitcher", "AquariusAstrology", "Archive", "AriesAstrology", "ArrowDown", "ArrowDownCircle", "ArrowLeft", "ArrowLineDown", "ArrowLineUp", "ArrowRight", "ArrowUp", "Article", "ArtisticGymnastics", "Ascender", "AudioFile", "Authenticator", "AutoDownload", "AutoSaveOffline", "AutoSaveSync", "AutoSaveUpload", "AutoSaveUploadFail", "AutoSaved", "BabyBottle", "BackTimeTen", "Badge", "Balance", "BallInWater", "Barometer", "BaseBallBat", "Baseball", "Basketball", "BasketballHoop", "BeachUmbrella", "Bed", "Bell", "Below", "BigDownArrow", "BigLeftArrow", "BigRightArrow", "BigRightStraightArrow", "BigUpArrow", "Bike", "Bingo", "Binoculars", "BlackJack", "Bold", "Bolt", "Bookmark", "BottomLine", "BowAndArrow", "BoxCircle", "BoxFront", "BoxOnBox", "BoxingGlove", "Browser", "BubbleZone", "Building", "BulletPointContainer", "BulletPoints", "Bullseye", "BusFront", "BusinessBag", "Cake", "Calendar", "CalendarClock", "CalendarConfirm", "CalendarFile", "CalendarICSFile", "CalendarRightArrow", "Camera", "CancerAstrology", "Canoe", "CapriconAstrology", "Car", "CardsCheck", "Cash", "CelebrityStar", "CenterAlignment", "ChatAi", "Check", "CheckBookmark", "CheckBox", "CheckCircle", "CheckDocuments", "CheckEnvelope", "CheckPeople", "CheckSpeechBubble", "CheckVoteBallot", "Checklist", "ChevronDown", "ChevronLeft", "ChevronLeftPeople", "ChevronRight", "ChevronRightPeople", "ChevronUp", "Circle", "ClearText", "Clipboard", "Clock", "Clone", "ClosedCaption", "Cloud", "CloudDay", "CloudNight", "Cocktails", "Coffee", "CoffeeTakeout", "Cog", "Coin", "CollapseColumn", "Command", "Compass", "ComputerChip", "Connection", "ConnectionScreen", "ContactBook", "ContactCard", "Convert", "ConvertAlt", "ConvertLeft", "ConvertRight", "Cookies", "Coupon", "CreditCard", "CreditCardPayment", "CrescentMoon", "Cricket", "Cross", "CrossCircle", "CrossEnvelope", "CrossPeople", "CrossShield", "Crossword", "Cycling", "DOCFile", "DailyFantasy", "DaisyFlower", "Dandelion", "DataBook", "DataCloud", "DataSilo", "DataStorage", "Debug", "DeleteTab", "DeliveryPackage", "Dense", "DenyCircle", "Descender", "Desktop", "DiagonalKey", "DiagonalLeftDown", "DiagonalLeftUp", "DiagonalRightDown", "DiagonalRightUp", "Diamond", "Dice", "Dining", "Direction", "DiscoBall", "Document", "DocumentImageRectangle", "DocumentImageSquare", "DocumentRectangle", "DollarCircleArrows", "DotEnvelope", "DotTwoRings", "DoubleBigLeftArrow", "DoubleChevronLeft", "DoubleChevronRight", "DownCurveArrow", "Download", "DownloadCircle", "DownloadComplete", "DownloadInProgressCircle", "DraftDocument", "DragVertical", "Dusk", "Easel", "Eclipse", "Edit", "EmailVerification", "Emails", "Embed", "EntertainmentTv", "Envelope", "Error", "ExpandArrowLeft", "ExpandArrowRight", "ExpandColumn", "Eye", "EyeSearch", "EyeShut", "FaceID", "FallLeaf", "Family", "FastForward", "FencingEpee", "FilmReel", "FilmRoll", "FingerPointLeftArrow", "FingerPointRightArrow", "FingerPointSelect", "FingerPrint", "Fire", "FirstAidKit", "FirstQuarter", "FiveCircles", "Flag", "FlameTorch", "Fog", "FogDay", "Folder", "Font", "Football", "FootballHelmet", "ForestTree", "FourBoxes", "FourCorners", "FourCornersMagnifyingGlass", "FourCornersMusicNote", "FourLinesSpread", "FourThreeRatio", "FullMoon", "GIF", "GeminiAstrology", "GiftBox", "GolfTee", "GraduationHat", "Graph", "Gymnastics", "HalfStar", "HalfSun", "HappyFace", "HazeDay", "HazeNight", "Heading2", "Heading3", "Headline1", "HeadlineDocumentSquare", "Headphone", "HeadphonesMic", "Heart", "HeartArrow", "HeartPulse", "HeavyRain", "HeavyRainDay", "HeavyRainLightning", "HeavyRainLightningDay", "HeavyRainLightningNight", "HeavyRainNight", "Help", "Highlighter", "History", "HockeyWithPuck", "Home", "HorseHeadBridle", "HotTub", "Hurricane", "Ice", "Id", "Image", "ImageFile", "ImageGallery", "Inbox", "InboxDownArrow", "InboxUpArrow", "IndentRight", "Infinity", "Info", "InstitutionalWesternBank", "Italics", "JoyfulFace", "JudoUniform", "Keyboard", "KeylineShapes", "Kick", "KnightChessPiece", "Laptop", "LaptopWithPhone", "Laurel", "LaurelLeft", "LaurelRight", "LayoutBottom", "LayoutDefault", "LayoutFourColumn", "LayoutGrid", "LayoutPerfectGrid", "LayoutRight", "LayoutThreeColumn", "LayoutThreeRows", "LayoutTwoColumn", "LeftAlign", "LeftCurveArrow", "LeftPageArrow", "LeoAstrology", "Letter", "LetterColor", "LetterSize", "LibraAstrology", "LifeRing", "Lightbulb", "Lightning", "LightningDay", "LightningNight", "Link", "LiquidDrop", "Live", "Livestream", "Location", "LocationCircle", "LocationMap", "Lock", "LogIn", "LogOut", "Lollipop", "LoveEnvelope", "LoyaltyCard", "MagicWand", "MagnifyingGlass", "Mahjong", "MakeupBeauty", "Mannequin", "Medal", "MedicineBottle", "MedicinePill", "Megaphone", "Microphone", "Microscope", "Minus", "MinusBox", "MinusCircle", "MinusPeople", "MinusSearch", "MmaGlove", "MmaRing", "MobileNumber", "MobilePhone", "More", "MoreVertical", "NeutralFace", "NewMoon", "Newsletter", "Night", "NineSixteenRatio", "NoBell", "NoConnectionScreen", "NoEye", "NoHeart", "NoImage", "NoPeople", "NoShield", "NoSmoking", "NoSquare", "NoStar", "NoVideoCamera", "NoWifi", "NotificationBell", "Null", "NumberedList", "OnTop", "OneOneRatio", "OpenBook", "OpenEnvelope", "OrderedList", "OutdentLeft", "PDF", "PPT", "PaperPlane", "PaperPlaneDiagonal", "Paperclip", "Paragraph", "ParagraphLeftIdent", "ParagraphRightIdent", "Parking", "ParkingSquare", "PassKey", "Password", "Pause", "Payments", "Payphone", "PayphoneFace", "Pencil", "PencilLines", "People", "Person", "PersonClimbing", "PersonShield", "Pets", "Phone", "PieChart", "Pin", "PingPong", "PiscesAstrology", "PlainText", "Play", "PlayCircle", "Pool", "PowerSwitch", "Preferences", "PreferencesAlt", "Printer", "Priority", "Profile", "Progress", "ProgressWithCheck", "Pulse", "PuzzlePiece", "QrCode", "QuestionBubble", "QuoteCircle", "QuoteSquare", "RAW", "RTF", "RTFOff", "RacingFlag", "Radar", "RadioCircle", "RainDay", "RainNight", "Receipt", "Receipts", "RedoPencil", "Refresh", "Restaurant", "RetailTag", "RightAlign", "RightCurveArrow", "RightPageArrow", "RobotHead", "Running", "SadFace", "SadderFace", "SagittariusAstrology", "SailBoat", "Satellite", "ScaleDown", "ScanQrCode", "Scissors", "ScorpioAstrology", "SearchConfirm", "SearchEnvelope", "SearchWorldWithLines", "SecurityKey", "SendToSelf", "Server", "SettingsAlt", "SettingsCogPeople", "Shapes", "Share", "Shield", "ShieldCheck", "ShieldSlash", "ShockedFace", "ShoppingBag", "ShoppingBasket", "ShoppingCart", "Shuttlecock", "SixteenNineRatio", "Skateboard", "SkipTimeTen", "Skull", "Slideshow", "SmallSquareInsideBigSquare", "SmartWatch", "SmileFace", "SmileFaceLife", "Sms", "SmsVerificationCode", "Sneaker", "SneakerAlt", "Snippet", "Snow", "SnowDay", "SnowNight", "Snowflake", "Soccer", "Solitaire", "SoundLow", "SoundOff", "SoundOn", "Spa", "Sparkle", "SparkleFootballBall", "SparkleTennisBall", "SpecialCharacter", "SpeechBubble", "SpeechBubbleStar", "SportsBook", "SportsSparkle", "SprinkleDay", "SprinkleNight", "Square", "Stadium", "Star", "StarArticle", "StarMedal", "StarTrophy", "StatePrivacyControls", "StockTrends", "Stopwatch", "Store", "Strikethrough", "Sun", "Sunrise", "Sunset", "SurfboardOnSand", "Swimming", "Sync", "Tab", "Tablet", "TaurusAstrology", "TechnicalRoute", "Television", "TennisBall", "TennisRacketBall", "ThirdQuarter", "ThreeCircles", "ThreeFourRatio", "ThreeLines", "ThreeLinesSpread", "ThumbsDown", "ThumbsUp", "Thumbtack", "ThumbtackDiagonal", "TimePaperPlane", "Tornado", "Trading", "TrafficSignRightTurn", "Trampoline", "Transactions", "Trash", "Trending", "TrendingCircle", "Trophy", "TruckRight", "Tshirt", "Tsunami", "Tub", "TwoArrowsDiagonalInwards", "TwoArrowsDiagonalOutwards", "TwoCorners", "TwoHorizontalRectangles", "TwoLinesContainer", "TwoMasks", "TwoRectangles", "TwoSparkles", "TwoSquares", "TwoThirdsColumn", "Underline", "Unlock", "UnorderedList", "UpCurveArrow", "UpDownChevron", "UpDownShortArrows", "UpFolder", "Upload", "Verification", "VideoCamera", "VideoFile", "VirgoAstrology", "Virus", "Volleyball", "Walking", "Wallet", "WaningCrescent", "WaningGibbous", "Warning", "WaxingCrescent", "WaxingGibbous", "Web", "Weights", "Wifi", "Wind", "WindCloud", "WindCloudDay", "WindCloudNight", "Wine", "WorldWithLines", "Wrench", "WrestlingHeadGear", "WritingAi", "XLSFile", "YEP", "ZIP"];
|