@yahoo/uds-mobile 2.9.0 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -24
- package/dist/components/Avatar.cjs +1 -1
- package/dist/components/Avatar.d.cts +1 -1
- package/dist/components/Avatar.d.ts +1 -1
- package/dist/components/Avatar.js +1 -1
- package/dist/components/Avatar.js.map +1 -1
- package/dist/components/Badge.cjs +1 -1
- package/dist/components/Badge.d.cts +1 -1
- package/dist/components/Badge.d.ts +1 -1
- package/dist/components/Badge.js +1 -1
- package/dist/components/Badge.js.map +1 -1
- package/dist/components/BlurTarget.cjs +2 -1
- package/dist/components/BlurTarget.d.cts +2 -1
- package/dist/components/BlurTarget.d.cts.map +1 -1
- package/dist/components/BlurTarget.d.ts +2 -1
- package/dist/components/BlurTarget.d.ts.map +1 -1
- package/dist/components/BlurTarget.js +2 -1
- package/dist/components/BlurTarget.js.map +1 -1
- package/dist/components/Box.cjs +1 -1
- package/dist/components/Box.d.cts +1 -1
- package/dist/components/Box.d.ts +1 -1
- package/dist/components/Box.js +1 -1
- package/dist/components/Box.js.map +1 -1
- package/dist/components/Button.cjs +1 -1
- package/dist/components/Button.d.cts +1 -1
- package/dist/components/Button.d.ts +1 -1
- package/dist/components/Button.js +1 -1
- package/dist/components/Button.js.map +1 -1
- package/dist/components/Checkbox.cjs +1 -1
- package/dist/components/Checkbox.d.cts +1 -1
- package/dist/components/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox.js +1 -1
- package/dist/components/Checkbox.js.map +1 -1
- package/dist/components/Chip.cjs +1 -1
- package/dist/components/Chip.d.cts +1 -1
- package/dist/components/Chip.d.ts +1 -1
- package/dist/components/Chip.js +1 -1
- package/dist/components/Chip.js.map +1 -1
- package/dist/components/Divider/Divider.cjs +103 -0
- package/dist/components/Divider/Divider.d.cts +50 -0
- package/dist/components/Divider/Divider.d.cts.map +1 -0
- package/dist/components/Divider/Divider.d.ts +50 -0
- package/dist/components/Divider/Divider.d.ts.map +1 -0
- package/dist/components/Divider/Divider.js +103 -0
- package/dist/components/Divider/Divider.js.map +1 -0
- package/dist/components/Divider/DividerLabel.cjs +37 -0
- package/dist/components/Divider/DividerLabel.d.cts +18 -0
- package/dist/components/Divider/DividerLabel.d.cts.map +1 -0
- package/dist/components/Divider/DividerLabel.d.ts +18 -0
- package/dist/components/Divider/DividerLabel.d.ts.map +1 -0
- package/dist/components/Divider/DividerLabel.js +37 -0
- package/dist/components/Divider/DividerLabel.js.map +1 -0
- package/dist/components/Divider/DividerLine.cjs +62 -0
- package/dist/components/Divider/DividerLine.d.cts +19 -0
- package/dist/components/Divider/DividerLine.d.cts.map +1 -0
- package/dist/components/Divider/DividerLine.d.ts +19 -0
- package/dist/components/Divider/DividerLine.d.ts.map +1 -0
- package/dist/components/Divider/DividerLine.js +62 -0
- package/dist/components/Divider/DividerLine.js.map +1 -0
- package/dist/components/Divider/index.cjs +8 -0
- package/dist/components/Divider/index.d.cts +6 -0
- package/dist/components/Divider/index.d.ts +6 -0
- package/dist/components/Divider/index.js +5 -0
- package/dist/components/Divider/types.cjs +1 -0
- package/dist/components/Divider/types.d.cts +35 -0
- package/dist/components/Divider/types.d.cts.map +1 -0
- package/dist/components/Divider/types.d.ts +35 -0
- package/dist/components/Divider/types.d.ts.map +1 -0
- package/dist/components/Divider/types.js +1 -0
- package/dist/components/Divider/utils.cjs +33 -0
- package/dist/components/Divider/utils.d.cts +12 -0
- package/dist/components/Divider/utils.d.cts.map +1 -0
- package/dist/components/Divider/utils.d.ts +12 -0
- package/dist/components/Divider/utils.d.ts.map +1 -0
- package/dist/components/Divider/utils.js +31 -0
- package/dist/components/Divider/utils.js.map +1 -0
- package/dist/components/HStack.cjs +1 -1
- package/dist/components/HStack.d.cts +1 -1
- package/dist/components/HStack.d.ts +1 -1
- package/dist/components/HStack.js +1 -1
- package/dist/components/HStack.js.map +1 -1
- package/dist/components/Icon.cjs +1 -1
- package/dist/components/Icon.d.cts +2 -2
- package/dist/components/Icon.d.ts +2 -2
- package/dist/components/Icon.js +1 -1
- package/dist/components/Icon.js.map +1 -1
- package/dist/components/IconButton.cjs +1 -1
- package/dist/components/IconButton.d.cts +1 -1
- package/dist/components/IconButton.d.ts +1 -1
- package/dist/components/IconButton.js +1 -1
- package/dist/components/IconButton.js.map +1 -1
- package/dist/components/IconSlot.cjs +1 -1
- package/dist/components/IconSlot.d.cts +1 -1
- package/dist/components/IconSlot.d.ts +1 -1
- package/dist/components/IconSlot.js +1 -1
- package/dist/components/IconSlot.js.map +1 -1
- package/dist/components/Image.cjs +1 -1
- package/dist/components/Image.d.cts +1 -1
- package/dist/components/Image.d.ts +1 -1
- package/dist/components/Image.js +1 -1
- package/dist/components/Image.js.map +1 -1
- package/dist/components/Input.cjs +1 -1
- package/dist/components/Input.d.cts +1 -1
- package/dist/components/Input.d.ts +1 -1
- package/dist/components/Input.js +1 -1
- package/dist/components/Input.js.map +1 -1
- package/dist/components/Link.cjs +1 -1
- package/dist/components/Link.d.cts +1 -1
- package/dist/components/Link.d.ts +1 -1
- package/dist/components/Link.js +1 -1
- package/dist/components/Link.js.map +1 -1
- package/dist/components/Pressable.cjs +1 -1
- package/dist/components/Pressable.d.cts +1 -1
- package/dist/components/Pressable.d.ts +1 -1
- package/dist/components/Pressable.js +1 -1
- package/dist/components/Pressable.js.map +1 -1
- package/dist/components/Radio.cjs +1 -1
- package/dist/components/Radio.d.cts +1 -1
- package/dist/components/Radio.d.ts +1 -1
- package/dist/components/Radio.js +1 -1
- package/dist/components/Radio.js.map +1 -1
- package/dist/components/Screen.cjs +1 -1
- package/dist/components/Screen.d.cts +1 -1
- package/dist/components/Screen.d.ts +1 -1
- package/dist/components/Screen.js +1 -1
- package/dist/components/Screen.js.map +1 -1
- package/dist/components/Switch.cjs +1 -1
- package/dist/components/Switch.d.cts +1 -1
- package/dist/components/Switch.d.ts +1 -1
- package/dist/components/Switch.js +1 -1
- package/dist/components/Switch.js.map +1 -1
- package/dist/components/Tabs/Tab.cjs +174 -0
- package/dist/components/Tabs/Tab.d.cts +26 -0
- package/dist/components/Tabs/Tab.d.cts.map +1 -0
- package/dist/components/Tabs/Tab.d.ts +26 -0
- package/dist/components/Tabs/Tab.d.ts.map +1 -0
- package/dist/components/Tabs/Tab.js +174 -0
- package/dist/components/Tabs/Tab.js.map +1 -0
- package/dist/components/Tabs/TabList.cjs +142 -0
- package/dist/components/Tabs/TabList.d.cts +24 -0
- package/dist/components/Tabs/TabList.d.cts.map +1 -0
- package/dist/components/Tabs/TabList.d.ts +24 -0
- package/dist/components/Tabs/TabList.d.ts.map +1 -0
- package/dist/components/Tabs/TabList.js +141 -0
- package/dist/components/Tabs/TabList.js.map +1 -0
- package/dist/components/Tabs/TabPanel.cjs +31 -0
- package/dist/components/Tabs/TabPanel.d.cts +24 -0
- package/dist/components/Tabs/TabPanel.d.cts.map +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +24 -0
- package/dist/components/Tabs/TabPanel.d.ts.map +1 -0
- package/dist/components/Tabs/TabPanel.js +31 -0
- package/dist/components/Tabs/TabPanel.js.map +1 -0
- package/dist/components/Tabs/Tabs.cjs +53 -0
- package/dist/components/Tabs/Tabs.d.cts +35 -0
- package/dist/components/Tabs/Tabs.d.cts.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +35 -0
- package/dist/components/Tabs/Tabs.d.ts.map +1 -0
- package/dist/components/Tabs/Tabs.js +53 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tabs/index.cjs +10 -0
- package/dist/components/Tabs/index.d.cts +13 -0
- package/dist/components/Tabs/index.d.cts.map +1 -0
- package/dist/components/Tabs/index.d.ts +13 -0
- package/dist/components/Tabs/index.d.ts.map +1 -0
- package/dist/components/Tabs/index.js +6 -0
- package/dist/components/Tabs/tabTheme.cjs +29 -0
- package/dist/components/Tabs/tabTheme.d.cts +23 -0
- package/dist/components/Tabs/tabTheme.d.cts.map +1 -0
- package/dist/components/Tabs/tabTheme.d.ts +23 -0
- package/dist/components/Tabs/tabTheme.d.ts.map +1 -0
- package/dist/components/Tabs/tabTheme.js +28 -0
- package/dist/components/Tabs/tabTheme.js.map +1 -0
- package/dist/components/Tabs/tabsContexts.cjs +91 -0
- package/dist/components/Tabs/tabsContexts.d.cts +35 -0
- package/dist/components/Tabs/tabsContexts.d.cts.map +1 -0
- package/dist/components/Tabs/tabsContexts.d.ts +35 -0
- package/dist/components/Tabs/tabsContexts.d.ts.map +1 -0
- package/dist/components/Tabs/tabsContexts.js +87 -0
- package/dist/components/Tabs/tabsContexts.js.map +1 -0
- package/dist/components/Text.cjs +1 -1
- package/dist/components/Text.d.cts +1 -1
- package/dist/components/Text.d.ts +1 -1
- package/dist/components/Text.js +1 -1
- package/dist/components/Text.js.map +1 -1
- package/dist/components/VStack.cjs +1 -1
- package/dist/components/VStack.d.cts +1 -1
- package/dist/components/VStack.d.ts +1 -1
- package/dist/components/VStack.js +1 -1
- package/dist/components/VStack.js.map +1 -1
- package/dist/jest/mocks/styles.cjs +22 -0
- package/dist/jest/mocks/styles.d.cts +4 -2
- package/dist/jest/mocks/styles.d.cts.map +1 -1
- package/dist/jest/mocks/styles.d.ts +4 -2
- package/dist/jest/mocks/styles.d.ts.map +1 -1
- package/dist/jest/mocks/styles.js +21 -1
- package/dist/jest/mocks/styles.js.map +1 -1
- package/dist/types/dist/index.d.cts +63 -2
- package/dist/types/dist/index.d.cts.map +1 -1
- package/dist/types/dist/index.d.ts +63 -2
- package/dist/types/dist/index.d.ts.map +1 -1
- package/fonts/uds-icons.ttf +0 -0
- package/generated/styles.cjs +87 -13
- package/generated/styles.d.ts +58 -0
- package/generated/styles.mjs +87 -13
- package/generated/unistyles.d.ts +62 -9
- package/package.json +21 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import type { CheckboxValue, CheckboxVariant, UniversalCheckboxProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withSpring } from 'react-native-reanimated';\n\nimport { checkboxStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { HStack } from './HStack';\nimport { Icon } from './Icon';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from CheckboxValue - maps boolean to 'checked'/'unchecked' string literals */\ntype CheckboxValueState = Exclude<CheckboxValue, boolean> | 'checked' | 'unchecked';\n\ninterface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the checkbox is required */\n required?: boolean;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype CheckboxStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<CheckboxVariant, CheckboxStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Checkbox Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A checkbox component**\n *\n * @description\n * A checkbox component allows users to select one or multiple options from a set.\n * It represents a binary state, typically as checked or unchecked, and optionally\n * includes a third \"indeterminate\" state to indicate partial selection.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Checkbox } from '@yahoo/uds-mobile';\n *\n * <Checkbox label=\"Agree to terms\" />\n * <Checkbox label=\"Subscribe\" checked={true} onChange={setChecked} />\n * <Checkbox label=\"Partial\" checked=\"indeterminate\" />\n * ```\n *\n * @usage\n * - Forms: For selecting options\n * - Settings: For toggling preferences\n * - Filters: For multi-select filtering\n *\n * @accessibility\n * - Sets `accessibilityRole=\"checkbox\"` automatically\n * - Announces checked/unchecked/mixed state\n * - Label is used as accessibility label\n * - Supports `reduceMotion` for users who prefer reduced motion\n *\n * @see {@link Radio} for single-select options\n * @see {@link Switch} for binary toggles\n */\nconst Checkbox = memo(function Checkbox({\n // Checkbox props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n onChange,\n ref,\n ...viewProps\n}: CheckboxProps) {\n const generatedId = useId();\n const uid = `uds-checkbox-${generatedId}`;\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<CheckboxValue>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: CheckboxValueState = useMemo(() => {\n if (checked === 'indeterminate') {\n return 'indeterminate';\n }\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n const iconName = valueState === 'indeterminate' ? 'Minus' : 'Check';\n const showIcon = valueState !== 'unchecked';\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n const checkboxAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = checked === 'indeterminate' ? true : !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: CheckboxStyleVariant = hasError\n ? VARIANT_ERROR_MAP[variantProp]\n : variantProp;\n\n checkboxStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked, indeterminate\n disabled,\n pressed,\n });\n\n const rootStyle = useMemo(\n () => [checkboxStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [checkboxStyles.root, disabled],\n );\n\n const checkboxBoxStyle = useMemo(\n () => [\n checkboxStyles.checkbox,\n { alignItems: 'center' as const, justifyContent: 'center' as const, borderRadius: 4 },\n checkboxAnimatedStyle,\n ],\n [checkboxStyles.checkbox, checkboxAnimatedStyle],\n );\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n const content =\n typeof label === 'function' ? label() : isValidElement(label) ? label : String(label);\n\n const textContent =\n typeof content === 'string' ? <Text style={checkboxStyles.text}>{content}</Text> : content;\n\n if (required) {\n return (\n <HStack columnGap=\"1\" alignItems=\"flex-start\">\n {textContent}\n <Text style={checkboxStyles.text}>*</Text>\n </HStack>\n );\n }\n\n return textContent;\n }, [label, required, checkboxStyles.text]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked:\n valueState === 'checked'\n ? true\n : valueState === 'indeterminate'\n ? ('mixed' as const)\n : false,\n }),\n [disabled, valueState],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf=\"flex-start\"\n accessibilityRole=\"checkbox\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={checkboxBoxStyle}>\n {showIcon && <Icon name={iconName} size=\"sm\" style={checkboxStyles.checkboxIcon} />}\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport { Checkbox, type CheckboxProps };\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":[],"sources":["../../src/components/Checkbox.tsx"],"sourcesContent":["import type { CheckboxValue, CheckboxVariant, UniversalCheckboxProps } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useId, useMemo, useState } from 'react';\nimport type { View, ViewProps } from 'react-native';\nimport Animated, { useAnimatedStyle, useDerivedValue, withSpring } from 'react-native-reanimated';\n\nimport { checkboxStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport { HStack } from './HStack';\nimport { Icon } from './Icon';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from CheckboxValue - maps boolean to 'checked'/'unchecked' string literals */\ntype CheckboxValueState = Exclude<CheckboxValue, boolean> | 'checked' | 'unchecked';\n\ninterface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the checkbox is required */\n required?: boolean;\n /** Callback fired when the checked state changes */\n onChange?: (checked: boolean) => void;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Variant Mapping */\n/* -------------------------------------------------------------------------- */\n\n/** All style variants available in the generated styles (includes error variants) */\ntype CheckboxStyleVariant = 'primary' | 'secondary' | 'alert' | 'alert-secondary';\n\nconst VARIANT_ERROR_MAP: Record<CheckboxVariant, CheckboxStyleVariant> = {\n primary: 'alert',\n secondary: 'alert-secondary',\n};\n\n/* -------------------------------------------------------------------------- */\n/* Checkbox Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **⚙️ A checkbox component**\n *\n * @description\n * A checkbox component allows users to select one or multiple options from a set.\n * It represents a binary state, typically as checked or unchecked, and optionally\n * includes a third \"indeterminate\" state to indicate partial selection.\n *\n * @category Form\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Checkbox } from '@yahoo/uds-mobile/Checkbox';\n *\n * <Checkbox label=\"Agree to terms\" />\n * <Checkbox label=\"Subscribe\" checked={true} onChange={setChecked} />\n * <Checkbox label=\"Partial\" checked=\"indeterminate\" />\n * ```\n *\n * @usage\n * - Forms: For selecting options\n * - Settings: For toggling preferences\n * - Filters: For multi-select filtering\n *\n * @accessibility\n * - Sets `accessibilityRole=\"checkbox\"` automatically\n * - Announces checked/unchecked/mixed state\n * - Label is used as accessibility label\n * - Supports `reduceMotion` for users who prefer reduced motion\n *\n * @see {@link Radio} for single-select options\n * @see {@link Switch} for binary toggles\n */\nconst Checkbox = memo(function Checkbox({\n // Checkbox props\n label,\n labelPosition = 'start',\n variant: variantProp = 'primary',\n size = 'md',\n checked: checkedProp,\n hasError,\n reduceMotion,\n // Native props\n defaultChecked,\n disabled,\n required,\n onChange,\n ref,\n ...viewProps\n}: CheckboxProps) {\n const generatedId = useId();\n const uid = `uds-checkbox-${generatedId}`;\n\n /* --------------------------------- State ---------------------------------- */\n const isControlled = checkedProp !== undefined;\n const [internalChecked, setInternalChecked] = useState<CheckboxValue>(\n isControlled ? checkedProp : (defaultChecked ?? false),\n );\n const [pressed, setPressed] = useState(false);\n\n // Use controlled value if provided, otherwise use internal state\n const checked = isControlled ? checkedProp : internalChecked;\n\n /* ------------------------------ Derived Values ---------------------------- */\n const valueState: CheckboxValueState = useMemo(() => {\n if (checked === 'indeterminate') {\n return 'indeterminate';\n }\n return checked ? 'checked' : 'unchecked';\n }, [checked]);\n\n const iconName = valueState === 'indeterminate' ? 'Minus' : 'Check';\n const showIcon = valueState !== 'unchecked';\n\n /* -------------------------------- Animation ------------------------------- */\n const shouldAnimate = !reduceMotion;\n\n // Scale animation for press feedback (disabled when reduceMotion is true)\n const scaleProgress = useDerivedValue(\n () =>\n shouldAnimate\n ? withSpring(pressed ? SCALE_EFFECTS.down : SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG)\n : SCALE_EFFECTS.none, // No scale effect when reduceMotion is true\n [pressed, shouldAnimate],\n );\n\n const checkboxAnimatedStyle = useAnimatedStyle(() => ({\n transform: [{ scale: scaleProgress.value }],\n }));\n\n /* -------------------------------- Handlers -------------------------------- */\n const handlePress = useCallback(() => {\n if (disabled) {\n return;\n }\n\n const newChecked = checked === 'indeterminate' ? true : !checked;\n\n if (!isControlled) {\n setInternalChecked(newChecked);\n }\n\n onChange?.(newChecked);\n }, [disabled, checked, isControlled, onChange]);\n\n const handlePressIn = useCallback(() => {\n setPressed(true);\n }, []);\n\n const handlePressOut = useCallback(() => {\n setPressed(false);\n }, []);\n\n /* --------------------------------- Styles --------------------------------- */\n // Compute the style variant (primary/secondary maps to alert variants when hasError)\n const styleVariant: CheckboxStyleVariant = hasError\n ? VARIANT_ERROR_MAP[variantProp]\n : variantProp;\n\n checkboxStyles.useVariants({\n size,\n variant: styleVariant, // primary, secondary, alert, alert-secondary\n value: valueState, // checked, unchecked, indeterminate\n disabled,\n pressed,\n });\n\n const rootStyle = useMemo(\n () => [checkboxStyles.root, { opacity: disabled ? 0.5 : 1 }],\n [checkboxStyles.root, disabled],\n );\n\n const checkboxBoxStyle = useMemo(\n () => [\n checkboxStyles.checkbox,\n { alignItems: 'center' as const, justifyContent: 'center' as const, borderRadius: 4 },\n checkboxAnimatedStyle,\n ],\n [checkboxStyles.checkbox, checkboxAnimatedStyle],\n );\n\n /* ---------------------------- Render Helpers ------------------------------ */\n const labelContent = useMemo(() => {\n if (!label) {\n return null;\n }\n\n const content =\n typeof label === 'function' ? label() : isValidElement(label) ? label : String(label);\n\n const textContent =\n typeof content === 'string' ? <Text style={checkboxStyles.text}>{content}</Text> : content;\n\n if (required) {\n return (\n <HStack columnGap=\"1\" alignItems=\"flex-start\">\n {textContent}\n <Text style={checkboxStyles.text}>*</Text>\n </HStack>\n );\n }\n\n return textContent;\n }, [label, required, checkboxStyles.text]);\n\n const a11yState = useMemo(\n () => ({\n disabled,\n checked:\n valueState === 'checked'\n ? true\n : valueState === 'indeterminate'\n ? ('mixed' as const)\n : false,\n }),\n [disabled, valueState],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <Pressable\n ref={ref}\n nativeID={uid}\n onPress={handlePress}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n disabled={disabled}\n flexDirection={labelPosition === 'start' ? 'row' : 'row-reverse'}\n alignItems=\"center\"\n alignSelf=\"flex-start\"\n accessibilityRole=\"checkbox\"\n accessibilityState={a11yState}\n accessibilityLabel={typeof label === 'string' ? label : undefined}\n {...viewProps}\n style={rootStyle}\n >\n <Animated.View style={checkboxBoxStyle}>\n {showIcon && <Icon name={iconName} size=\"sm\" style={checkboxStyles.checkboxIcon} />}\n </Animated.View>\n\n {labelContent}\n </Pressable>\n );\n});\n\nCheckbox.displayName = 'Checkbox';\n\nexport { Checkbox, type CheckboxProps };\n"],"mappings":"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"}
|
package/dist/components/Chip.cjs
CHANGED
package/dist/components/Chip.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.js","names":[],"sources":["../../src/components/Chip.tsx"],"sourcesContent":["import type { ChipSize, ChipVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useMemo } from 'react';\nimport type { View, ViewProps } from 'react-native';\n\nimport { chipStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\ninterface ChipProps extends Omit<ViewProps, 'children'> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** The visual style variant @default 'primary' */\n variant?: ChipVariant;\n /** The size of the chip @default 'md' */\n size?: ChipSize;\n /** Minimum width of the chip in pixels */\n minWidth?: number;\n /** Maximum width of the chip in pixels @default 200 */\n maxWidth?: number;\n /** Icon displayed at the start of the chip */\n startIcon?: IconSlotType;\n /** Icon displayed at the end of the chip */\n endIcon?: IconSlotType;\n /** Whether the chip is disabled */\n disabled?: boolean;\n /** Called when the chip is pressed. Makes the chip interactive. */\n onPress?: () => void;\n /** Whether the chip is toggled/selected. */\n isToggled?: boolean;\n /** Called when the chip toggle state changes. */\n onToggle?: (toggled: boolean) => void;\n /** Called when the dismiss button is pressed. Shows a dismiss icon. */\n onDismiss?: () => void;\n /** Accessibility label for the dismiss button. */\n dismissButtonAriaLabel?: string;\n /** Chip label content */\n children?: React.ReactNode;\n}\n\n/**\n * **A chip component for selections, filters, or actions**\n *\n * @description\n * Chips help people make selections, filter content, or trigger actions.\n * They can be toggleable, dismissible, or simple pressable elements.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Chip } from '@yahoo/uds-mobile';\n *\n * // Basic chip\n * <Chip>Label</Chip>\n *\n * // Toggle chip\n * <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>\n *\n * // Dismissible chip\n * <Chip onDismiss={() => removeChip()}>Tag</Chip>\n *\n * // With icons\n * <Chip startIcon=\"Star\" variant=\"brand\">Favorite</Chip>\n * ```\n *\n * @usage\n * - Filters: For multi-select filtering options\n * - Tags: For displaying and removing tags\n * - Actions: For quick contextual actions\n *\n * @accessibility\n * - Toggle chips use `accessibilityRole=\"checkbox\"` with checked state\n * - Action chips use `accessibilityRole=\"button\"`\n * - Dismiss button has customizable `dismissButtonAriaLabel`\n *\n * @see {@link Badge} for non-interactive status indicators\n * @see {@link Button} for primary actions\n */\nconst Chip = memo(function Chip({\n variant = 'primary',\n size = 'md',\n minWidth,\n maxWidth = 200,\n startIcon,\n endIcon,\n disabled = false,\n isToggled = false,\n onPress,\n onToggle,\n onDismiss,\n dismissButtonAriaLabel = 'Dismiss',\n children,\n style,\n ref,\n ...rest\n}: ChipProps) {\n const isInteractive = Boolean(onPress || onToggle);\n const isDismissible = Boolean(onDismiss);\n const isDisabled = disabled;\n // Determine which variant type to use for styling\n const toggleState = isToggled ? 'on' : 'off';\n\n // Apply layer-based styles\n // Note: Chip doesn't have disabled variants in theme - handled via opacity\n // Note: pressed state is applied dynamically via Pressable's style callback\n chipStyles.useVariants({\n size,\n link: variant,\n dismissible: variant,\n toggle: toggleState,\n });\n\n const handlePress = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (onToggle) {\n onToggle(!isToggled);\n } else if (onPress) {\n onPress();\n }\n }, [isDisabled, onToggle, isToggled, onPress]);\n\n const handleDismiss = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onDismiss?.();\n }, [isDisabled, onDismiss]);\n\n const content = (\n <>\n {startIcon && <IconSlot icon={startIcon} variant=\"fill\" style={chipStyles.icon} />}\n <Text numberOfLines={1} textAlign=\"center\" flexShrink=\"1\" style={chipStyles.text}>\n {children}\n </Text>\n {isDismissible ? (\n <Pressable\n onPress={isDisabled ? undefined : handleDismiss}\n disabled={isDisabled}\n accessibilityLabel={dismissButtonAriaLabel}\n accessibilityRole=\"button\"\n >\n <IconSlot icon={endIcon ?? 'Cross'} variant=\"fill\" style={chipStyles.icon} />\n </Pressable>\n ) : (\n endIcon && <IconSlot icon={endIcon} variant=\"fill\" style={chipStyles.icon} />\n )}\n </>\n );\n\n const a11yState = {\n disabled: isDisabled,\n checked: onToggle ? isToggled : undefined,\n };\n\n const rootStyles = useMemo(() => [chipStyles.root, style], [chipStyles.root, style]);\n const sharedProps = {\n ref,\n style: rootStyles,\n flexDirection: 'row',\n alignItems: 'center',\n overflow: 'hidden',\n alignSelf: 'flex-start',\n maxWidth,\n minWidth,\n disabled: isDisabled,\n opacity: isDisabled ? 0.5 : undefined,\n accessibilityState: a11yState,\n ...rest,\n } as const;\n\n // Interactive chip (toggle or button)\n if (isInteractive) {\n return (\n <Pressable\n onPress={handlePress}\n accessibilityRole={onToggle ? 'checkbox' : 'button'}\n {...sharedProps}\n >\n {content}\n </Pressable>\n );\n }\n\n // Non-interactive chip (display only or dismissible)\n return (\n <HStack accessibilityRole={isDismissible ? 'button' : undefined} {...sharedProps} {...rest}>\n {content}\n </HStack>\n );\n});\n\nChip.displayName = 'Chip';\n\nexport { Chip, type ChipProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,MAAM,OAAO,KAAK,SAAS,KAAK,EAC9B,UAAU,WACV,OAAO,MACP,UACA,WAAW,KACX,WACA,SACA,WAAW,OACX,YAAY,OACZ,SACA,UACA,WACA,yBAAyB,WACzB,UACA,OACA,KACA,GAAG,QACS;CACZ,MAAM,gBAAgB,QAAQ,WAAW,SAAS;CAClD,MAAM,gBAAgB,QAAQ,UAAU;CACxC,MAAM,aAAa;CAEnB,MAAM,cAAc,YAAY,OAAO;AAKvC,YAAW,YAAY;EACrB;EACA,MAAM;EACN,aAAa;EACb,QAAQ;EACT,CAAC;CAEF,MAAM,cAAc,kBAAkB;AACpC,MAAI,WACF;AAGF,MAAI,SACF,UAAS,CAAC,UAAU;WACX,QACT,UAAS;IAEV;EAAC;EAAY;EAAU;EAAW;EAAQ,CAAC;CAE9C,MAAM,gBAAgB,kBAAkB;AACtC,MAAI,WACF;AAEF,eAAa;IACZ,CAAC,YAAY,UAAU,CAAC;CAE3B,MAAM,UACJ,qBAAA,UAAA,EAAA,UAAA;EACG,aAAa,oBAAC,UAAD;GAAU,MAAM;GAAW,SAAQ;GAAO,OAAO,WAAW;GAAQ,CAAA;EAClF,oBAAC,MAAD;GAAM,eAAe;GAAG,WAAU;GAAS,YAAW;GAAI,OAAO,WAAW;GACzE;GACI,CAAA;EACN,gBACC,oBAAC,WAAD;GACE,SAAS,aAAa,KAAA,IAAY;GAClC,UAAU;GACV,oBAAoB;GACpB,mBAAkB;aAElB,oBAAC,UAAD;IAAU,MAAM,WAAW;IAAS,SAAQ;IAAO,OAAO,WAAW;IAAQ,CAAA;GACnE,CAAA,GAEZ,WAAW,oBAAC,UAAD;GAAU,MAAM;GAAS,SAAQ;GAAO,OAAO,WAAW;GAAQ,CAAA;EAE9E,EAAA,CAAA;CAGL,MAAM,YAAY;EAChB,UAAU;EACV,SAAS,WAAW,YAAY,KAAA;EACjC;CAGD,MAAM,cAAc;EAClB;EACA,OAHiB,cAAc,CAAC,WAAW,MAAM,MAAM,EAAE,CAAC,WAAW,MAAM,MAAM,CAGhE;EACjB,eAAe;EACf,YAAY;EACZ,UAAU;EACV,WAAW;EACX;EACA;EACA,UAAU;EACV,SAAS,aAAa,KAAM,KAAA;EAC5B,oBAAoB;EACpB,GAAG;EACJ;AAGD,KAAI,cACF,QACE,oBAAC,WAAD;EACE,SAAS;EACT,mBAAmB,WAAW,aAAa;EAC3C,GAAI;YAEH;EACS,CAAA;AAKhB,QACE,oBAAC,QAAD;EAAQ,mBAAmB,gBAAgB,WAAW,KAAA;EAAW,GAAI;EAAa,GAAI;YACnF;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
|
|
1
|
+
{"version":3,"file":"Chip.js","names":[],"sources":["../../src/components/Chip.tsx"],"sourcesContent":["import type { ChipSize, ChipVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { memo, useCallback, useMemo } from 'react';\nimport type { View, ViewProps } from 'react-native';\n\nimport { chipStyles } from '../../generated/styles';\nimport { HStack } from './HStack';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport { Pressable } from './Pressable';\nimport { Text } from './Text';\n\ninterface ChipProps extends Omit<ViewProps, 'children'> {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** The visual style variant @default 'primary' */\n variant?: ChipVariant;\n /** The size of the chip @default 'md' */\n size?: ChipSize;\n /** Minimum width of the chip in pixels */\n minWidth?: number;\n /** Maximum width of the chip in pixels @default 200 */\n maxWidth?: number;\n /** Icon displayed at the start of the chip */\n startIcon?: IconSlotType;\n /** Icon displayed at the end of the chip */\n endIcon?: IconSlotType;\n /** Whether the chip is disabled */\n disabled?: boolean;\n /** Called when the chip is pressed. Makes the chip interactive. */\n onPress?: () => void;\n /** Whether the chip is toggled/selected. */\n isToggled?: boolean;\n /** Called when the chip toggle state changes. */\n onToggle?: (toggled: boolean) => void;\n /** Called when the dismiss button is pressed. Shows a dismiss icon. */\n onDismiss?: () => void;\n /** Accessibility label for the dismiss button. */\n dismissButtonAriaLabel?: string;\n /** Chip label content */\n children?: React.ReactNode;\n}\n\n/**\n * **A chip component for selections, filters, or actions**\n *\n * @description\n * Chips help people make selections, filter content, or trigger actions.\n * They can be toggleable, dismissible, or simple pressable elements.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Chip } from '@yahoo/uds-mobile/Chip';\n *\n * // Basic chip\n * <Chip>Label</Chip>\n *\n * // Toggle chip\n * <Chip isToggled={selected} onToggle={setSelected}>Filter</Chip>\n *\n * // Dismissible chip\n * <Chip onDismiss={() => removeChip()}>Tag</Chip>\n *\n * // With icons\n * <Chip startIcon=\"Star\" variant=\"brand\">Favorite</Chip>\n * ```\n *\n * @usage\n * - Filters: For multi-select filtering options\n * - Tags: For displaying and removing tags\n * - Actions: For quick contextual actions\n *\n * @accessibility\n * - Toggle chips use `accessibilityRole=\"checkbox\"` with checked state\n * - Action chips use `accessibilityRole=\"button\"`\n * - Dismiss button has customizable `dismissButtonAriaLabel`\n *\n * @see {@link Badge} for non-interactive status indicators\n * @see {@link Button} for primary actions\n */\nconst Chip = memo(function Chip({\n variant = 'primary',\n size = 'md',\n minWidth,\n maxWidth = 200,\n startIcon,\n endIcon,\n disabled = false,\n isToggled = false,\n onPress,\n onToggle,\n onDismiss,\n dismissButtonAriaLabel = 'Dismiss',\n children,\n style,\n ref,\n ...rest\n}: ChipProps) {\n const isInteractive = Boolean(onPress || onToggle);\n const isDismissible = Boolean(onDismiss);\n const isDisabled = disabled;\n // Determine which variant type to use for styling\n const toggleState = isToggled ? 'on' : 'off';\n\n // Apply layer-based styles\n // Note: Chip doesn't have disabled variants in theme - handled via opacity\n // Note: pressed state is applied dynamically via Pressable's style callback\n chipStyles.useVariants({\n size,\n link: variant,\n dismissible: variant,\n toggle: toggleState,\n });\n\n const handlePress = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (onToggle) {\n onToggle(!isToggled);\n } else if (onPress) {\n onPress();\n }\n }, [isDisabled, onToggle, isToggled, onPress]);\n\n const handleDismiss = useCallback(() => {\n if (isDisabled) {\n return;\n }\n onDismiss?.();\n }, [isDisabled, onDismiss]);\n\n const content = (\n <>\n {startIcon && <IconSlot icon={startIcon} variant=\"fill\" style={chipStyles.icon} />}\n <Text numberOfLines={1} textAlign=\"center\" flexShrink=\"1\" style={chipStyles.text}>\n {children}\n </Text>\n {isDismissible ? (\n <Pressable\n onPress={isDisabled ? undefined : handleDismiss}\n disabled={isDisabled}\n accessibilityLabel={dismissButtonAriaLabel}\n accessibilityRole=\"button\"\n >\n <IconSlot icon={endIcon ?? 'Cross'} variant=\"fill\" style={chipStyles.icon} />\n </Pressable>\n ) : (\n endIcon && <IconSlot icon={endIcon} variant=\"fill\" style={chipStyles.icon} />\n )}\n </>\n );\n\n const a11yState = {\n disabled: isDisabled,\n checked: onToggle ? isToggled : undefined,\n };\n\n const rootStyles = useMemo(() => [chipStyles.root, style], [chipStyles.root, style]);\n const sharedProps = {\n ref,\n style: rootStyles,\n flexDirection: 'row',\n alignItems: 'center',\n overflow: 'hidden',\n alignSelf: 'flex-start',\n maxWidth,\n minWidth,\n disabled: isDisabled,\n opacity: isDisabled ? 0.5 : undefined,\n accessibilityState: a11yState,\n ...rest,\n } as const;\n\n // Interactive chip (toggle or button)\n if (isInteractive) {\n return (\n <Pressable\n onPress={handlePress}\n accessibilityRole={onToggle ? 'checkbox' : 'button'}\n {...sharedProps}\n >\n {content}\n </Pressable>\n );\n }\n\n // Non-interactive chip (display only or dismissible)\n return (\n <HStack accessibilityRole={isDismissible ? 'button' : undefined} {...sharedProps} {...rest}>\n {content}\n </HStack>\n );\n});\n\nChip.displayName = 'Chip';\n\nexport { Chip, type ChipProps };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmFA,MAAM,OAAO,KAAK,SAAS,KAAK,EAC9B,UAAU,WACV,OAAO,MACP,UACA,WAAW,KACX,WACA,SACA,WAAW,OACX,YAAY,OACZ,SACA,UACA,WACA,yBAAyB,WACzB,UACA,OACA,KACA,GAAG,QACS;CACZ,MAAM,gBAAgB,QAAQ,WAAW,SAAS;CAClD,MAAM,gBAAgB,QAAQ,UAAU;CACxC,MAAM,aAAa;CAEnB,MAAM,cAAc,YAAY,OAAO;AAKvC,YAAW,YAAY;EACrB;EACA,MAAM;EACN,aAAa;EACb,QAAQ;EACT,CAAC;CAEF,MAAM,cAAc,kBAAkB;AACpC,MAAI,WACF;AAGF,MAAI,SACF,UAAS,CAAC,UAAU;WACX,QACT,UAAS;IAEV;EAAC;EAAY;EAAU;EAAW;EAAQ,CAAC;CAE9C,MAAM,gBAAgB,kBAAkB;AACtC,MAAI,WACF;AAEF,eAAa;IACZ,CAAC,YAAY,UAAU,CAAC;CAE3B,MAAM,UACJ,qBAAA,UAAA,EAAA,UAAA;EACG,aAAa,oBAAC,UAAD;GAAU,MAAM;GAAW,SAAQ;GAAO,OAAO,WAAW;GAAQ,CAAA;EAClF,oBAAC,MAAD;GAAM,eAAe;GAAG,WAAU;GAAS,YAAW;GAAI,OAAO,WAAW;GACzE;GACI,CAAA;EACN,gBACC,oBAAC,WAAD;GACE,SAAS,aAAa,KAAA,IAAY;GAClC,UAAU;GACV,oBAAoB;GACpB,mBAAkB;aAElB,oBAAC,UAAD;IAAU,MAAM,WAAW;IAAS,SAAQ;IAAO,OAAO,WAAW;IAAQ,CAAA;GACnE,CAAA,GAEZ,WAAW,oBAAC,UAAD;GAAU,MAAM;GAAS,SAAQ;GAAO,OAAO,WAAW;GAAQ,CAAA;EAE9E,EAAA,CAAA;CAGL,MAAM,YAAY;EAChB,UAAU;EACV,SAAS,WAAW,YAAY,KAAA;EACjC;CAGD,MAAM,cAAc;EAClB;EACA,OAHiB,cAAc,CAAC,WAAW,MAAM,MAAM,EAAE,CAAC,WAAW,MAAM,MAAM,CAGhE;EACjB,eAAe;EACf,YAAY;EACZ,UAAU;EACV,WAAW;EACX;EACA;EACA,UAAU;EACV,SAAS,aAAa,KAAM,KAAA;EAC5B,oBAAoB;EACpB,GAAG;EACJ;AAGD,KAAI,cACF,QACE,oBAAC,WAAD;EACE,SAAS;EACT,mBAAmB,WAAW,aAAa;EAC3C,GAAI;YAEH;EACS,CAAA;AAKhB,QACE,oBAAC,QAAD;EAAQ,mBAAmB,gBAAgB,WAAW,KAAA;EAAW,GAAI;EAAa,GAAI;YACnF;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
const require_components_Box = require("../Box.cjs");
|
|
5
|
+
const require_components_HStack = require("../HStack.cjs");
|
|
6
|
+
const require_components_VStack = require("../VStack.cjs");
|
|
7
|
+
const require_components_Divider_DividerLabel = require("./DividerLabel.cjs");
|
|
8
|
+
const require_components_Divider_DividerLine = require("./DividerLine.cjs");
|
|
9
|
+
const require_components_Divider_utils = require("./utils.cjs");
|
|
10
|
+
let react = require("react");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
let generated_styles = require("../../../generated/styles");
|
|
13
|
+
//#region src/components/Divider/Divider.tsx
|
|
14
|
+
/**
|
|
15
|
+
* **A divider component that can be used to visually separate components**
|
|
16
|
+
*
|
|
17
|
+
* @description
|
|
18
|
+
* Divider is a visual separator for grouping content. It supports horizontal
|
|
19
|
+
* and vertical orientation, optional label content, configurable label
|
|
20
|
+
* positioning, and the same primary, secondary, tertiary, and muted variants
|
|
21
|
+
* as the web component.
|
|
22
|
+
*
|
|
23
|
+
* For custom composition, import `DividerLine` and `DividerLabel` from the same
|
|
24
|
+
* subpath and compose them inside `Divider`, `HStack`, or `VStack`.
|
|
25
|
+
*
|
|
26
|
+
* @category Layout
|
|
27
|
+
* @platform mobile
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* import { Divider, DividerLabel, DividerLine } from '@yahoo/uds-mobile/Divider';
|
|
32
|
+
*
|
|
33
|
+
* <Divider />
|
|
34
|
+
* <Divider variant="secondary" />
|
|
35
|
+
* <Divider contentPosition="start">Section</Divider>
|
|
36
|
+
* <Divider>
|
|
37
|
+
* <DividerLine />
|
|
38
|
+
* <DividerLabel>Custom</DividerLabel>
|
|
39
|
+
* <DividerLine />
|
|
40
|
+
* </Divider>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @usage
|
|
44
|
+
* - Separate related content groups in lists, settings screens, and stacked layouts
|
|
45
|
+
* - Use `vertical` inside horizontal layouts when a visual split is needed
|
|
46
|
+
* - Use `DividerLine` and `DividerLabel` when a layout needs custom composition
|
|
47
|
+
*
|
|
48
|
+
* @accessibility
|
|
49
|
+
* - Divider is visual-only by default
|
|
50
|
+
* - Use a text label only when the separator needs visible section context
|
|
51
|
+
*
|
|
52
|
+
* @see {@link DividerLine} for a standalone configured divider line
|
|
53
|
+
* @see {@link DividerLabel} for a standalone configured divider label
|
|
54
|
+
*/
|
|
55
|
+
const Divider = (0, react.memo)(function Divider({ variant = "primary", vertical = false, contentPosition = "center", gap, children, style, ref, ...boxProps }) {
|
|
56
|
+
generated_styles.dividerStyles.useVariants({ variant });
|
|
57
|
+
const rootStyle = (0, react.useMemo)(() => [
|
|
58
|
+
{ flexShrink: 0 },
|
|
59
|
+
gap === void 0 ? generated_styles.dividerStyles.root : void 0,
|
|
60
|
+
style
|
|
61
|
+
], [
|
|
62
|
+
gap,
|
|
63
|
+
generated_styles.dividerStyles.root,
|
|
64
|
+
style
|
|
65
|
+
]);
|
|
66
|
+
if (children) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(vertical ? require_components_VStack.VStack : require_components_HStack.HStack, {
|
|
67
|
+
ref,
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
flex: "1",
|
|
70
|
+
gap,
|
|
71
|
+
...boxProps,
|
|
72
|
+
style: rootStyle,
|
|
73
|
+
children: require_components_Divider_utils.hasManualLine(children) ? require_components_Divider_utils.renderManualChildren(children, variant, vertical) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
74
|
+
contentPosition !== "start" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Divider_DividerLine.DividerLine, {
|
|
75
|
+
variant,
|
|
76
|
+
vertical
|
|
77
|
+
}),
|
|
78
|
+
require_components_Divider_utils.shouldWrapInLabel(children) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Divider_DividerLabel.DividerLabel, {
|
|
79
|
+
variant,
|
|
80
|
+
children
|
|
81
|
+
}) : children,
|
|
82
|
+
contentPosition !== "end" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Divider_DividerLine.DividerLine, {
|
|
83
|
+
variant,
|
|
84
|
+
vertical
|
|
85
|
+
})
|
|
86
|
+
] })
|
|
87
|
+
});
|
|
88
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Box.Box, {
|
|
89
|
+
ref,
|
|
90
|
+
display: "flex",
|
|
91
|
+
flexDirection: vertical ? "column" : "row",
|
|
92
|
+
width: vertical ? void 0 : "100%",
|
|
93
|
+
...boxProps,
|
|
94
|
+
style: rootStyle,
|
|
95
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Divider_DividerLine.DividerLine, {
|
|
96
|
+
variant,
|
|
97
|
+
vertical
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
Divider.displayName = "Divider";
|
|
102
|
+
//#endregion
|
|
103
|
+
exports.Divider = Divider;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import { DividerProps } from "./types.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Divider/Divider.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* **A divider component that can be used to visually separate components**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Divider is a visual separator for grouping content. It supports horizontal
|
|
11
|
+
* and vertical orientation, optional label content, configurable label
|
|
12
|
+
* positioning, and the same primary, secondary, tertiary, and muted variants
|
|
13
|
+
* as the web component.
|
|
14
|
+
*
|
|
15
|
+
* For custom composition, import `DividerLine` and `DividerLabel` from the same
|
|
16
|
+
* subpath and compose them inside `Divider`, `HStack`, or `VStack`.
|
|
17
|
+
*
|
|
18
|
+
* @category Layout
|
|
19
|
+
* @platform mobile
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { Divider, DividerLabel, DividerLine } from '@yahoo/uds-mobile/Divider';
|
|
24
|
+
*
|
|
25
|
+
* <Divider />
|
|
26
|
+
* <Divider variant="secondary" />
|
|
27
|
+
* <Divider contentPosition="start">Section</Divider>
|
|
28
|
+
* <Divider>
|
|
29
|
+
* <DividerLine />
|
|
30
|
+
* <DividerLabel>Custom</DividerLabel>
|
|
31
|
+
* <DividerLine />
|
|
32
|
+
* </Divider>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @usage
|
|
36
|
+
* - Separate related content groups in lists, settings screens, and stacked layouts
|
|
37
|
+
* - Use `vertical` inside horizontal layouts when a visual split is needed
|
|
38
|
+
* - Use `DividerLine` and `DividerLabel` when a layout needs custom composition
|
|
39
|
+
*
|
|
40
|
+
* @accessibility
|
|
41
|
+
* - Divider is visual-only by default
|
|
42
|
+
* - Use a text label only when the separator needs visible section context
|
|
43
|
+
*
|
|
44
|
+
* @see {@link DividerLine} for a standalone configured divider line
|
|
45
|
+
* @see {@link DividerLabel} for a standalone configured divider label
|
|
46
|
+
*/
|
|
47
|
+
declare const Divider: _$react.NamedExoticComponent<DividerProps>;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Divider };
|
|
50
|
+
//# sourceMappingURL=Divider.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.d.cts","names":[],"sources":["../../../src/components/Divider/Divider.tsx"],"mappings":";;;;;;;;AAS4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4CtC,OAAA,EAAO,OAAA,CAAA,oBAAA,CAAA,YAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
|
|
2
|
+
import { DividerProps } from "./types.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Divider/Divider.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* **A divider component that can be used to visually separate components**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* Divider is a visual separator for grouping content. It supports horizontal
|
|
11
|
+
* and vertical orientation, optional label content, configurable label
|
|
12
|
+
* positioning, and the same primary, secondary, tertiary, and muted variants
|
|
13
|
+
* as the web component.
|
|
14
|
+
*
|
|
15
|
+
* For custom composition, import `DividerLine` and `DividerLabel` from the same
|
|
16
|
+
* subpath and compose them inside `Divider`, `HStack`, or `VStack`.
|
|
17
|
+
*
|
|
18
|
+
* @category Layout
|
|
19
|
+
* @platform mobile
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* import { Divider, DividerLabel, DividerLine } from '@yahoo/uds-mobile/Divider';
|
|
24
|
+
*
|
|
25
|
+
* <Divider />
|
|
26
|
+
* <Divider variant="secondary" />
|
|
27
|
+
* <Divider contentPosition="start">Section</Divider>
|
|
28
|
+
* <Divider>
|
|
29
|
+
* <DividerLine />
|
|
30
|
+
* <DividerLabel>Custom</DividerLabel>
|
|
31
|
+
* <DividerLine />
|
|
32
|
+
* </Divider>
|
|
33
|
+
* ```
|
|
34
|
+
*
|
|
35
|
+
* @usage
|
|
36
|
+
* - Separate related content groups in lists, settings screens, and stacked layouts
|
|
37
|
+
* - Use `vertical` inside horizontal layouts when a visual split is needed
|
|
38
|
+
* - Use `DividerLine` and `DividerLabel` when a layout needs custom composition
|
|
39
|
+
*
|
|
40
|
+
* @accessibility
|
|
41
|
+
* - Divider is visual-only by default
|
|
42
|
+
* - Use a text label only when the separator needs visible section context
|
|
43
|
+
*
|
|
44
|
+
* @see {@link DividerLine} for a standalone configured divider line
|
|
45
|
+
* @see {@link DividerLabel} for a standalone configured divider label
|
|
46
|
+
*/
|
|
47
|
+
declare const Divider: _$react.NamedExoticComponent<DividerProps>;
|
|
48
|
+
//#endregion
|
|
49
|
+
export { Divider };
|
|
50
|
+
//# sourceMappingURL=Divider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.d.ts","names":[],"sources":["../../../src/components/Divider/Divider.tsx"],"mappings":";;;;;;;;AAS4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4CtC,OAAA,EAAO,OAAA,CAAA,oBAAA,CAAA,YAAA"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { Box } from "../Box.js";
|
|
3
|
+
import { HStack } from "../HStack.js";
|
|
4
|
+
import { VStack } from "../VStack.js";
|
|
5
|
+
import { DividerLabel } from "./DividerLabel.js";
|
|
6
|
+
import { DividerLine } from "./DividerLine.js";
|
|
7
|
+
import { hasManualLine, renderManualChildren, shouldWrapInLabel } from "./utils.js";
|
|
8
|
+
import { memo, useMemo } from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { dividerStyles } from "../../../generated/styles";
|
|
11
|
+
//#region src/components/Divider/Divider.tsx
|
|
12
|
+
/**
|
|
13
|
+
* **A divider component that can be used to visually separate components**
|
|
14
|
+
*
|
|
15
|
+
* @description
|
|
16
|
+
* Divider is a visual separator for grouping content. It supports horizontal
|
|
17
|
+
* and vertical orientation, optional label content, configurable label
|
|
18
|
+
* positioning, and the same primary, secondary, tertiary, and muted variants
|
|
19
|
+
* as the web component.
|
|
20
|
+
*
|
|
21
|
+
* For custom composition, import `DividerLine` and `DividerLabel` from the same
|
|
22
|
+
* subpath and compose them inside `Divider`, `HStack`, or `VStack`.
|
|
23
|
+
*
|
|
24
|
+
* @category Layout
|
|
25
|
+
* @platform mobile
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* import { Divider, DividerLabel, DividerLine } from '@yahoo/uds-mobile/Divider';
|
|
30
|
+
*
|
|
31
|
+
* <Divider />
|
|
32
|
+
* <Divider variant="secondary" />
|
|
33
|
+
* <Divider contentPosition="start">Section</Divider>
|
|
34
|
+
* <Divider>
|
|
35
|
+
* <DividerLine />
|
|
36
|
+
* <DividerLabel>Custom</DividerLabel>
|
|
37
|
+
* <DividerLine />
|
|
38
|
+
* </Divider>
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @usage
|
|
42
|
+
* - Separate related content groups in lists, settings screens, and stacked layouts
|
|
43
|
+
* - Use `vertical` inside horizontal layouts when a visual split is needed
|
|
44
|
+
* - Use `DividerLine` and `DividerLabel` when a layout needs custom composition
|
|
45
|
+
*
|
|
46
|
+
* @accessibility
|
|
47
|
+
* - Divider is visual-only by default
|
|
48
|
+
* - Use a text label only when the separator needs visible section context
|
|
49
|
+
*
|
|
50
|
+
* @see {@link DividerLine} for a standalone configured divider line
|
|
51
|
+
* @see {@link DividerLabel} for a standalone configured divider label
|
|
52
|
+
*/
|
|
53
|
+
const Divider = memo(function Divider({ variant = "primary", vertical = false, contentPosition = "center", gap, children, style, ref, ...boxProps }) {
|
|
54
|
+
dividerStyles.useVariants({ variant });
|
|
55
|
+
const rootStyle = useMemo(() => [
|
|
56
|
+
{ flexShrink: 0 },
|
|
57
|
+
gap === void 0 ? dividerStyles.root : void 0,
|
|
58
|
+
style
|
|
59
|
+
], [
|
|
60
|
+
gap,
|
|
61
|
+
dividerStyles.root,
|
|
62
|
+
style
|
|
63
|
+
]);
|
|
64
|
+
if (children) return /* @__PURE__ */ jsx(vertical ? VStack : HStack, {
|
|
65
|
+
ref,
|
|
66
|
+
alignItems: "center",
|
|
67
|
+
flex: "1",
|
|
68
|
+
gap,
|
|
69
|
+
...boxProps,
|
|
70
|
+
style: rootStyle,
|
|
71
|
+
children: hasManualLine(children) ? renderManualChildren(children, variant, vertical) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
72
|
+
contentPosition !== "start" && /* @__PURE__ */ jsx(DividerLine, {
|
|
73
|
+
variant,
|
|
74
|
+
vertical
|
|
75
|
+
}),
|
|
76
|
+
shouldWrapInLabel(children) ? /* @__PURE__ */ jsx(DividerLabel, {
|
|
77
|
+
variant,
|
|
78
|
+
children
|
|
79
|
+
}) : children,
|
|
80
|
+
contentPosition !== "end" && /* @__PURE__ */ jsx(DividerLine, {
|
|
81
|
+
variant,
|
|
82
|
+
vertical
|
|
83
|
+
})
|
|
84
|
+
] })
|
|
85
|
+
});
|
|
86
|
+
return /* @__PURE__ */ jsx(Box, {
|
|
87
|
+
ref,
|
|
88
|
+
display: "flex",
|
|
89
|
+
flexDirection: vertical ? "column" : "row",
|
|
90
|
+
width: vertical ? void 0 : "100%",
|
|
91
|
+
...boxProps,
|
|
92
|
+
style: rootStyle,
|
|
93
|
+
children: /* @__PURE__ */ jsx(DividerLine, {
|
|
94
|
+
variant,
|
|
95
|
+
vertical
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
Divider.displayName = "Divider";
|
|
100
|
+
//#endregion
|
|
101
|
+
export { Divider };
|
|
102
|
+
|
|
103
|
+
//# sourceMappingURL=Divider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.js","names":[],"sources":["../../../src/components/Divider/Divider.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\n\nimport { dividerStyles } from '../../../generated/styles';\nimport { Box } from '../Box';\nimport { HStack } from '../HStack';\nimport { VStack } from '../VStack';\nimport { DividerLabel } from './DividerLabel';\nimport { DividerLine } from './DividerLine';\nimport type { DividerProps } from './types';\nimport { hasManualLine, renderManualChildren, shouldWrapInLabel } from './utils';\n\n/**\n * **A divider component that can be used to visually separate components**\n *\n * @description\n * Divider is a visual separator for grouping content. It supports horizontal\n * and vertical orientation, optional label content, configurable label\n * positioning, and the same primary, secondary, tertiary, and muted variants\n * as the web component.\n *\n * For custom composition, import `DividerLine` and `DividerLabel` from the same\n * subpath and compose them inside `Divider`, `HStack`, or `VStack`.\n *\n * @category Layout\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Divider, DividerLabel, DividerLine } from '@yahoo/uds-mobile/Divider';\n *\n * <Divider />\n * <Divider variant=\"secondary\" />\n * <Divider contentPosition=\"start\">Section</Divider>\n * <Divider>\n * <DividerLine />\n * <DividerLabel>Custom</DividerLabel>\n * <DividerLine />\n * </Divider>\n * ```\n *\n * @usage\n * - Separate related content groups in lists, settings screens, and stacked layouts\n * - Use `vertical` inside horizontal layouts when a visual split is needed\n * - Use `DividerLine` and `DividerLabel` when a layout needs custom composition\n *\n * @accessibility\n * - Divider is visual-only by default\n * - Use a text label only when the separator needs visible section context\n *\n * @see {@link DividerLine} for a standalone configured divider line\n * @see {@link DividerLabel} for a standalone configured divider label\n */\nconst Divider = memo(function Divider({\n variant = 'primary',\n vertical = false,\n contentPosition = 'center',\n gap,\n children,\n style,\n ref,\n ...boxProps\n}: DividerProps) {\n dividerStyles.useVariants({ variant });\n\n const rootStyle: StyleProp<ViewStyle> = useMemo(\n () => [{ flexShrink: 0 }, gap === undefined ? dividerStyles.root : undefined, style],\n [gap, dividerStyles.root, style],\n );\n\n if (children) {\n const InternalComponent = vertical ? VStack : HStack;\n\n return (\n <InternalComponent\n ref={ref}\n alignItems=\"center\"\n flex=\"1\"\n gap={gap}\n {...boxProps}\n style={rootStyle}\n >\n {hasManualLine(children) ? (\n renderManualChildren(children, variant, vertical)\n ) : (\n <>\n {contentPosition !== 'start' && <DividerLine variant={variant} vertical={vertical} />}\n {shouldWrapInLabel(children) ? (\n <DividerLabel variant={variant}>{children}</DividerLabel>\n ) : (\n children\n )}\n {contentPosition !== 'end' && <DividerLine variant={variant} vertical={vertical} />}\n </>\n )}\n </InternalComponent>\n );\n }\n\n return (\n <Box\n ref={ref}\n display=\"flex\"\n flexDirection={vertical ? 'column' : 'row'}\n width={vertical ? undefined : '100%'}\n {...boxProps}\n style={rootStyle}\n >\n <DividerLine variant={variant} vertical={vertical} />\n </Box>\n );\n});\n\nDivider.displayName = 'Divider';\n\nexport { Divider };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,MAAM,UAAU,KAAK,SAAS,QAAQ,EACpC,UAAU,WACV,WAAW,OACX,kBAAkB,UAClB,KACA,UACA,OACA,KACA,GAAG,YACY;AACf,eAAc,YAAY,EAAE,SAAS,CAAC;CAEtC,MAAM,YAAkC,cAChC;EAAC,EAAE,YAAY,GAAG;EAAE,QAAQ,KAAA,IAAY,cAAc,OAAO,KAAA;EAAW;EAAM,EACpF;EAAC;EAAK,cAAc;EAAM;EAAM,CACjC;AAED,KAAI,SAGF,QACE,oBAHwB,WAAW,SAAS,QAG5C;EACO;EACL,YAAW;EACX,MAAK;EACA;EACL,GAAI;EACJ,OAAO;YAEN,cAAc,SAAS,GACtB,qBAAqB,UAAU,SAAS,SAAS,GAEjD,qBAAA,UAAA,EAAA,UAAA;GACG,oBAAoB,WAAW,oBAAC,aAAD;IAAsB;IAAmB;IAAY,CAAA;GACpF,kBAAkB,SAAS,GAC1B,oBAAC,cAAD;IAAuB;IAAU;IAAwB,CAAA,GAEzD;GAED,oBAAoB,SAAS,oBAAC,aAAD;IAAsB;IAAmB;IAAY,CAAA;GAClF,EAAA,CAAA;EAEa,CAAA;AAIxB,QACE,oBAAC,KAAD;EACO;EACL,SAAQ;EACR,eAAe,WAAW,WAAW;EACrC,OAAO,WAAW,KAAA,IAAY;EAC9B,GAAI;EACJ,OAAO;YAEP,oBAAC,aAAD;GAAsB;GAAmB;GAAY,CAAA;EACjD,CAAA;EAER;AAEF,QAAQ,cAAc"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
4
|
+
const require_components_Text = require("../Text.cjs");
|
|
5
|
+
let react = require("react");
|
|
6
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
7
|
+
let generated_styles = require("../../../generated/styles");
|
|
8
|
+
//#region src/components/Divider/DividerLabel.tsx
|
|
9
|
+
/**
|
|
10
|
+
* **The configured label element used by Divider.**
|
|
11
|
+
*
|
|
12
|
+
* @description
|
|
13
|
+
* DividerLabel applies the configured divider label typography and color.
|
|
14
|
+
*
|
|
15
|
+
* @category Layout
|
|
16
|
+
* @platform mobile
|
|
17
|
+
*/
|
|
18
|
+
const DividerLabel = (0, react.memo)(function DividerLabel({ variant: variantProp, style, children, ref, ...textProps }) {
|
|
19
|
+
const variant = variantProp ?? "primary";
|
|
20
|
+
generated_styles.dividerStyles.useVariants({ variant });
|
|
21
|
+
const labelStyle = (0, react.useMemo)(() => [
|
|
22
|
+
{ flexShrink: 0 },
|
|
23
|
+
generated_styles.dividerStyles.label,
|
|
24
|
+
style
|
|
25
|
+
], [generated_styles.dividerStyles.label, style]);
|
|
26
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
|
|
27
|
+
ref,
|
|
28
|
+
color: "primary",
|
|
29
|
+
variant: "label3",
|
|
30
|
+
...textProps,
|
|
31
|
+
style: labelStyle,
|
|
32
|
+
children
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
DividerLabel.displayName = "DividerLabel";
|
|
36
|
+
//#endregion
|
|
37
|
+
exports.DividerLabel = DividerLabel;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
import { DividerLabelProps } from "./types.cjs";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Divider/DividerLabel.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* **The configured label element used by Divider.**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* DividerLabel applies the configured divider label typography and color.
|
|
11
|
+
*
|
|
12
|
+
* @category Layout
|
|
13
|
+
* @platform mobile
|
|
14
|
+
*/
|
|
15
|
+
declare const DividerLabel: _$react.NamedExoticComponent<DividerLabelProps>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DividerLabel };
|
|
18
|
+
//# sourceMappingURL=DividerLabel.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DividerLabel.d.cts","names":[],"sources":["../../../src/components/Divider/DividerLabel.tsx"],"mappings":";;;;;;;;AAIiD;;;;;;cAW3C,YAAA,EAAY,OAAA,CAAA,oBAAA,CAAA,iBAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
import { DividerLabelProps } from "./types.js";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Divider/DividerLabel.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* **The configured label element used by Divider.**
|
|
8
|
+
*
|
|
9
|
+
* @description
|
|
10
|
+
* DividerLabel applies the configured divider label typography and color.
|
|
11
|
+
*
|
|
12
|
+
* @category Layout
|
|
13
|
+
* @platform mobile
|
|
14
|
+
*/
|
|
15
|
+
declare const DividerLabel: _$react.NamedExoticComponent<DividerLabelProps>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { DividerLabel };
|
|
18
|
+
//# sourceMappingURL=DividerLabel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DividerLabel.d.ts","names":[],"sources":["../../../src/components/Divider/DividerLabel.tsx"],"mappings":";;;;;;;;AAIiD;;;;;;cAW3C,YAAA,EAAY,OAAA,CAAA,oBAAA,CAAA,iBAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*! © 2026 Yahoo, Inc. UDS Mobile v0.0.0-development */
|
|
2
|
+
import { Text } from "../Text.js";
|
|
3
|
+
import { memo, useMemo } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { dividerStyles } from "../../../generated/styles";
|
|
6
|
+
//#region src/components/Divider/DividerLabel.tsx
|
|
7
|
+
/**
|
|
8
|
+
* **The configured label element used by Divider.**
|
|
9
|
+
*
|
|
10
|
+
* @description
|
|
11
|
+
* DividerLabel applies the configured divider label typography and color.
|
|
12
|
+
*
|
|
13
|
+
* @category Layout
|
|
14
|
+
* @platform mobile
|
|
15
|
+
*/
|
|
16
|
+
const DividerLabel = memo(function DividerLabel({ variant: variantProp, style, children, ref, ...textProps }) {
|
|
17
|
+
const variant = variantProp ?? "primary";
|
|
18
|
+
dividerStyles.useVariants({ variant });
|
|
19
|
+
const labelStyle = useMemo(() => [
|
|
20
|
+
{ flexShrink: 0 },
|
|
21
|
+
dividerStyles.label,
|
|
22
|
+
style
|
|
23
|
+
], [dividerStyles.label, style]);
|
|
24
|
+
return /* @__PURE__ */ jsx(Text, {
|
|
25
|
+
ref,
|
|
26
|
+
color: "primary",
|
|
27
|
+
variant: "label3",
|
|
28
|
+
...textProps,
|
|
29
|
+
style: labelStyle,
|
|
30
|
+
children
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
DividerLabel.displayName = "DividerLabel";
|
|
34
|
+
//#endregion
|
|
35
|
+
export { DividerLabel };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=DividerLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DividerLabel.js","names":[],"sources":["../../../src/components/Divider/DividerLabel.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\n\nimport { dividerStyles } from '../../../generated/styles';\nimport { Text } from '../Text';\nimport type { DividerLabelProps } from './types';\n\n/**\n * **The configured label element used by Divider.**\n *\n * @description\n * DividerLabel applies the configured divider label typography and color.\n *\n * @category Layout\n * @platform mobile\n */\nconst DividerLabel = memo(function DividerLabel({\n variant: variantProp,\n style,\n children,\n ref,\n ...textProps\n}: DividerLabelProps) {\n const variant = variantProp ?? 'primary';\n\n dividerStyles.useVariants({ variant });\n\n const labelStyle = useMemo(\n () => [{ flexShrink: 0 }, dividerStyles.label, style],\n [dividerStyles.label, style],\n );\n\n return (\n <Text ref={ref} color=\"primary\" variant=\"label3\" {...textProps} style={labelStyle}>\n {children}\n </Text>\n );\n});\n\nDividerLabel.displayName = 'DividerLabel';\n\nexport { DividerLabel };\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,eAAe,KAAK,SAAS,aAAa,EAC9C,SAAS,aACT,OACA,UACA,KACA,GAAG,aACiB;CACpB,MAAM,UAAU,eAAe;AAE/B,eAAc,YAAY,EAAE,SAAS,CAAC;CAEtC,MAAM,aAAa,cACX;EAAC,EAAE,YAAY,GAAG;EAAE,cAAc;EAAO;EAAM,EACrD,CAAC,cAAc,OAAO,MAAM,CAC7B;AAED,QACE,oBAAC,MAAD;EAAW;EAAK,OAAM;EAAU,SAAQ;EAAS,GAAI;EAAW,OAAO;EACpE;EACI,CAAA;EAET;AAEF,aAAa,cAAc"}
|