@yahoo/uds-mobile 2.11.0 → 2.13.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.
Files changed (99) hide show
  1. package/dist/bin/fixtures/dist/index.mjs +0 -10
  2. package/dist/bin/mobile/scripts/utils/configToRNMappings.mjs +2 -0
  3. package/dist/bin/modes/dist/index.mjs +1 -0
  4. package/dist/bin/palette/dist/index.mjs +1 -0
  5. package/dist/components/AndroidBackHandler.js.map +1 -1
  6. package/dist/components/Avatar.js.map +1 -1
  7. package/dist/components/Badge.js.map +1 -1
  8. package/dist/components/Banner/Banner.js.map +1 -1
  9. package/dist/components/Banner/BannerContent.js.map +1 -1
  10. package/dist/components/Banner/BannerDescription.js.map +1 -1
  11. package/dist/components/Banner/BannerTitle.js.map +1 -1
  12. package/dist/components/Banner/utils.js.map +1 -1
  13. package/dist/components/BlurTarget.js.map +1 -1
  14. package/dist/components/BottomSheet/BottomSheet.js.map +1 -1
  15. package/dist/components/BottomSheet/BottomSheetContent.js.map +1 -1
  16. package/dist/components/BottomSheet/BottomSheetDismiss.js.map +1 -1
  17. package/dist/components/BottomSheet/BottomSheetHandle.js.map +1 -1
  18. package/dist/components/BottomSheet/BottomSheetHeader.js.map +1 -1
  19. package/dist/components/BottomSheet/BottomSheetInternalProvider.js.map +1 -1
  20. package/dist/components/BottomSheet/BottomSheetProvider.js.map +1 -1
  21. package/dist/components/BottomSheet/BottomSheetTrigger.js.map +1 -1
  22. package/dist/components/BottomSheet/useBottomSheetDrag.js.map +1 -1
  23. package/dist/components/BottomSheet/useBottomSheetScroll.js.map +1 -1
  24. package/dist/components/BottomSheet/useBottomSheetSnapModel.js.map +1 -1
  25. package/dist/components/BottomSheet/useBottomSheetStore.js.map +1 -1
  26. package/dist/components/BottomSheet/useExpansionMargins.js.map +1 -1
  27. package/dist/components/BottomSheet/useKeyboardAvoidance.js.map +1 -1
  28. package/dist/components/BottomSheet/utils.js.map +1 -1
  29. package/dist/components/Box.js.map +1 -1
  30. package/dist/components/Button.js.map +1 -1
  31. package/dist/components/Checkbox.cjs +10 -15
  32. package/dist/components/Checkbox.d.cts.map +1 -1
  33. package/dist/components/Checkbox.d.ts.map +1 -1
  34. package/dist/components/Checkbox.js +11 -16
  35. package/dist/components/Checkbox.js.map +1 -1
  36. package/dist/components/Chip.js.map +1 -1
  37. package/dist/components/Divider/Divider.js.map +1 -1
  38. package/dist/components/Divider/DividerLabel.js.map +1 -1
  39. package/dist/components/Divider/DividerLine.js.map +1 -1
  40. package/dist/components/Divider/utils.js.map +1 -1
  41. package/dist/components/FormLabel.cjs +31 -0
  42. package/dist/components/FormLabel.d.cts +21 -0
  43. package/dist/components/FormLabel.d.cts.map +1 -0
  44. package/dist/components/FormLabel.d.ts +21 -0
  45. package/dist/components/FormLabel.d.ts.map +1 -0
  46. package/dist/components/FormLabel.js +31 -0
  47. package/dist/components/FormLabel.js.map +1 -0
  48. package/dist/components/HStack.js.map +1 -1
  49. package/dist/components/Icon.js.map +1 -1
  50. package/dist/components/IconButton.js.map +1 -1
  51. package/dist/components/IconSlot.js.map +1 -1
  52. package/dist/components/Image.js.map +1 -1
  53. package/dist/components/Input.js.map +1 -1
  54. package/dist/components/Link.js.map +1 -1
  55. package/dist/components/Pressable.js.map +1 -1
  56. package/dist/components/Radio.cjs +10 -15
  57. package/dist/components/Radio.d.cts.map +1 -1
  58. package/dist/components/Radio.d.ts.map +1 -1
  59. package/dist/components/Radio.js +11 -16
  60. package/dist/components/Radio.js.map +1 -1
  61. package/dist/components/Screen.js.map +1 -1
  62. package/dist/components/Scrim.js.map +1 -1
  63. package/dist/components/Switch.cjs +8 -13
  64. package/dist/components/Switch.d.cts.map +1 -1
  65. package/dist/components/Switch.d.ts.map +1 -1
  66. package/dist/components/Switch.js +8 -13
  67. package/dist/components/Switch.js.map +1 -1
  68. package/dist/components/Tabs/Tab.js.map +1 -1
  69. package/dist/components/Tabs/TabList.js.map +1 -1
  70. package/dist/components/Tabs/TabPanel.js.map +1 -1
  71. package/dist/components/Tabs/Tabs.js.map +1 -1
  72. package/dist/components/Tabs/tabTheme.js.map +1 -1
  73. package/dist/components/Tabs/tabsContexts.js.map +1 -1
  74. package/dist/components/Text.cjs +12 -6
  75. package/dist/components/Text.d.cts +3 -2
  76. package/dist/components/Text.d.cts.map +1 -1
  77. package/dist/components/Text.d.ts +3 -2
  78. package/dist/components/Text.d.ts.map +1 -1
  79. package/dist/components/Text.js +12 -6
  80. package/dist/components/Text.js.map +1 -1
  81. package/dist/components/UDSProvider.js.map +1 -1
  82. package/dist/components/VStack.js.map +1 -1
  83. package/dist/jest/mocks/icons.js.map +1 -1
  84. package/dist/jest/mocks/react-native.js.map +1 -1
  85. package/dist/jest/mocks/reanimated.js.map +1 -1
  86. package/dist/jest/mocks/styles.js.map +1 -1
  87. package/dist/jest/mocks/svg.js.map +1 -1
  88. package/dist/jest/mocks/unistyles.js.map +1 -1
  89. package/dist/jest/setup.js.map +1 -1
  90. package/dist/portal.js.map +1 -1
  91. package/dist/types/dist/index.d.cts +39 -1
  92. package/dist/types/dist/index.d.cts.map +1 -1
  93. package/dist/types/dist/index.d.ts +39 -1
  94. package/dist/types/dist/index.d.ts.map +1 -1
  95. package/generated/styles.cjs +4 -0
  96. package/generated/styles.d.ts +2 -1
  97. package/generated/styles.mjs +4 -0
  98. package/generated/unistyles.d.ts +6 -0
  99. package/package.json +11 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useBottomSheetSnapModel.js","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetSnapModel.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { runOnJS, useSharedValue, withSpring } from 'react-native-reanimated';\n\nimport { MOTION_CONFIG } from '../../motion';\nimport type { BottomSheetHeight } from './types';\nimport { clampIndex, DEFAULT_SNAP_POINT, resolveHeightToPx } from './utils';\n\n/**\n * Spring configuration for sheet snap/close animations.\n * Uses the UDS `smooth['3']` motion preset.\n */\nconst SHEET_SPRING_CONFIG = {\n damping: MOTION_CONFIG.smooth['3'].damping,\n stiffness: MOTION_CONFIG.smooth['3'].stiffness,\n mass: 1,\n} as const;\n\n/** @internal */\ninterface UseBottomSheetSnapModelParams {\n snapPointsProp?: BottomSheetHeight[];\n height?: BottomSheetHeight;\n defaultSnapPointIndex: number;\n snapPointIndexProp?: number;\n onSnapPointChange?: (index: number, height: BottomSheetHeight) => void;\n containerHeight: SharedValue<number>;\n /** Bottom inset in px (margin + safe area). */\n bottomInsetPx: number;\n /** Top safe-area inset in px — limits maximum sheet height. */\n topInsetPx: number;\n /** Horizontal margin in px (currently informational, not used in snap math). */\n sideInsetPx: number;\n /** Whether margins collapse at the max snap point. */\n fullWidthAtMaxSnap: boolean;\n /** Bottom inset at max snap when fullWidthAtMaxSnap (safe area only, no margin). */\n expandedBottomInsetPx: number;\n}\n\ninterface UseBottomSheetSnapModelResult {\n /** The resolved snap points array. */\n resolvedSnapPoints: BottomSheetHeight[];\n /** Animated translateY position of the sheet. */\n translateY: SharedValue<number>;\n /** Current active snap index. */\n activeSnapIndex: SharedValue<number>;\n /** Whether the sheet is currently animating. */\n isAnimating: SharedValue<boolean>;\n /** Compute translateY for a given snap index (worklet). */\n getTranslateYForSnap: (index: number) => number;\n /** Compute the closed translateY position (worklet). */\n getClosedTranslateY: () => number;\n /** Animate to a specific snap index. */\n animateToSnap: (index: number) => void;\n /** Animate to the closed position. Optional callback fires on JS thread when complete. */\n animateToClose: (onComplete?: () => void) => void;\n /** Animate to a specific snap index from within a worklet. */\n animateToSnapWorklet: (index: number) => void;\n /** Animate to the closed position from within a worklet. */\n animateToCloseWorklet: () => void;\n}\n\n/**\n * Manages the snap-point position model for the bottom sheet.\n *\n * Resolves snap point strings to pixel positions, provides spring-animated\n * `animateToSnap` / `animateToClose` functions for both JS and UI threads,\n * and exposes shared values for `translateY`, `activeSnapIndex`, and `isAnimating`.\n *\n * Position model: `translateY = containerHeight - snapHeightPx - bottomInsetPx`\n */\nfunction useBottomSheetSnapModel({\n snapPointsProp,\n height,\n defaultSnapPointIndex,\n snapPointIndexProp,\n onSnapPointChange,\n containerHeight,\n bottomInsetPx,\n topInsetPx,\n fullWidthAtMaxSnap,\n expandedBottomInsetPx,\n}: UseBottomSheetSnapModelParams): UseBottomSheetSnapModelResult {\n const resolvedSnapPoints = useMemo<BottomSheetHeight[]>(() => {\n if (snapPointsProp?.length) {\n return snapPointsProp;\n }\n if (height !== undefined) {\n return [height];\n }\n return [DEFAULT_SNAP_POINT];\n }, [height, snapPointsProp]);\n\n // Start off-screen (will be set to closed position on first layout).\n const translateY = useSharedValue(9999);\n const activeSnapIndex = useSharedValue(\n clampIndex(snapPointIndexProp ?? defaultSnapPointIndex, resolvedSnapPoints.length),\n );\n const isAnimating = useSharedValue(false);\n\n /**\n * Compute translateY for a snap index.\n * Position model: translateY = containerHeight - snapHeightPx - bottomInsetPx\n */\n const getTranslateYForSnap = useCallback(\n (index: number): number => {\n 'worklet';\n const clamped = clampIndex(index, resolvedSnapPoints.length);\n const sp = resolvedSnapPoints[clamped]!;\n const heightPx = resolveHeightToPx(sp, containerHeight.value);\n // At max snap with fullWidthAtMaxSnap, margins collapse so use reduced bottom inset.\n const isExpandedMaxSnap = fullWidthAtMaxSnap && clamped === resolvedSnapPoints.length - 1;\n const effectiveBottomInset = isExpandedMaxSnap ? expandedBottomInsetPx : bottomInsetPx;\n const maxHeight = containerHeight.value - effectiveBottomInset - topInsetPx;\n const clampedHeight = Math.max(0, Math.min(heightPx, maxHeight));\n return containerHeight.value - clampedHeight - effectiveBottomInset;\n },\n [\n resolvedSnapPoints,\n containerHeight,\n bottomInsetPx,\n topInsetPx,\n fullWidthAtMaxSnap,\n expandedBottomInsetPx,\n ],\n );\n\n /** Compute the closed (off-screen) translateY. */\n const getClosedTranslateY = useCallback((): number => {\n 'worklet';\n return containerHeight.value + bottomInsetPx;\n }, [containerHeight, bottomInsetPx]);\n\n /** Emit snap point change callback on the JS thread. */\n const emitSnapChange = useCallback(\n (index: number) => {\n onSnapPointChange?.(index, resolvedSnapPoints[index]!);\n },\n [onSnapPointChange, resolvedSnapPoints],\n );\n\n /** Animate to snap index — call from JS thread. */\n const animateToSnap = useCallback(\n (index: number) => {\n const clamped = clampIndex(index, resolvedSnapPoints.length);\n const targetY = getTranslateYForSnap(clamped);\n\n isAnimating.value = true;\n activeSnapIndex.value = clamped;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n 'worklet';\n if (finished) {\n isAnimating.value = false;\n }\n });\n\n emitSnapChange(clamped);\n },\n [\n resolvedSnapPoints,\n getTranslateYForSnap,\n isAnimating,\n activeSnapIndex,\n translateY,\n emitSnapChange,\n ],\n );\n\n /** Animate to closed position — call from JS thread. */\n const animateToClose = useCallback(\n (onComplete?: () => void) => {\n const targetY = getClosedTranslateY();\n isAnimating.value = true;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n 'worklet';\n if (finished) {\n isAnimating.value = false;\n if (onComplete) {\n runOnJS(onComplete)();\n }\n }\n });\n },\n [getClosedTranslateY, isAnimating, translateY],\n );\n\n /** Animate to snap — safe to call from a worklet (onEnd handler). */\n const animateToSnapWorklet = useCallback(\n (index: number) => {\n 'worklet';\n const clamped = clampIndex(index, resolvedSnapPoints.length);\n const targetY = getTranslateYForSnap(clamped);\n\n isAnimating.value = true;\n activeSnapIndex.value = clamped;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n if (finished) {\n isAnimating.value = false;\n }\n });\n\n runOnJS(emitSnapChange)(clamped);\n },\n [\n resolvedSnapPoints,\n getTranslateYForSnap,\n isAnimating,\n activeSnapIndex,\n translateY,\n emitSnapChange,\n ],\n );\n\n /** Animate to closed — safe to call from a worklet. */\n const animateToCloseWorklet = useCallback(() => {\n 'worklet';\n const targetY = getClosedTranslateY();\n isAnimating.value = true;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n if (finished) {\n isAnimating.value = false;\n }\n });\n }, [getClosedTranslateY, isAnimating, translateY]);\n\n return {\n resolvedSnapPoints,\n translateY,\n activeSnapIndex,\n isAnimating,\n getTranslateYForSnap,\n getClosedTranslateY,\n animateToSnap,\n animateToClose,\n animateToSnapWorklet,\n animateToCloseWorklet,\n };\n}\n\nexport { SHEET_SPRING_CONFIG, useBottomSheetSnapModel };\n"],"mappings":";;;;;;;;;;AAYA,MAAM,sBAAsB;CAC1B,SAAS,cAAc,OAAO,KAAK;CACnC,WAAW,cAAc,OAAO,KAAK;CACrC,MAAM;CACP;;;;;;;;;;AAsDD,SAAS,wBAAwB,EAC/B,gBACA,QACA,uBACA,oBACA,mBACA,iBACA,eACA,YACA,oBACA,yBAC+D;CAC/D,MAAM,qBAAqB,cAAmC;AAC5D,MAAI,gBAAgB,OAClB,QAAO;AAET,MAAI,WAAW,KAAA,EACb,QAAO,CAAC,OAAO;AAEjB,SAAO,CAAA,MAAoB;IAC1B,CAAC,QAAQ,eAAe,CAAC;CAG5B,MAAM,aAAa,eAAe,KAAK;CACvC,MAAM,kBAAkB,eACtB,WAAW,sBAAsB,uBAAuB,mBAAmB,OAAO,CACnF;CACD,MAAM,cAAc,eAAe,MAAM;;;;;CAMzC,MAAM,uBAAuB,aAC1B,UAA0B;AACzB;EACA,MAAM,UAAU,WAAW,OAAO,mBAAmB,OAAO;EAC5D,MAAM,KAAK,mBAAmB;EAC9B,MAAM,WAAW,kBAAkB,IAAI,gBAAgB,MAAM;EAG7D,MAAM,uBADoB,sBAAsB,YAAY,mBAAmB,SAAS,IACvC,wBAAwB;EACzE,MAAM,YAAY,gBAAgB,QAAQ,uBAAuB;EACjE,MAAM,gBAAgB,KAAK,IAAI,GAAG,KAAK,IAAI,UAAU,UAAU,CAAC;AAChE,SAAO,gBAAgB,QAAQ,gBAAgB;IAEjD;EACE;EACA;EACA;EACA;EACA;EACA;EACD,CACF;;CAGD,MAAM,sBAAsB,kBAA0B;AACpD;AACA,SAAO,gBAAgB,QAAQ;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AAa;GAAW,CAY1B;EACtB"}
1
+ {"version":3,"file":"useBottomSheetSnapModel.js","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetSnapModel.ts"],"sourcesContent":["import { useCallback, useMemo } from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { runOnJS, useSharedValue, withSpring } from 'react-native-reanimated';\n\nimport { MOTION_CONFIG } from '../../motion';\nimport type { BottomSheetHeight } from './types';\nimport { clampIndex, DEFAULT_SNAP_POINT, resolveHeightToPx } from './utils';\n\n/**\n * Spring configuration for sheet snap/close animations.\n * Uses the UDS `smooth['3']` motion preset.\n */\nconst SHEET_SPRING_CONFIG = {\n damping: MOTION_CONFIG.smooth['3'].damping,\n stiffness: MOTION_CONFIG.smooth['3'].stiffness,\n mass: 1,\n} as const;\n\n/** @internal */\ninterface UseBottomSheetSnapModelParams {\n snapPointsProp?: BottomSheetHeight[];\n height?: BottomSheetHeight;\n defaultSnapPointIndex: number;\n snapPointIndexProp?: number;\n onSnapPointChange?: (index: number, height: BottomSheetHeight) => void;\n containerHeight: SharedValue<number>;\n /** Bottom inset in px (margin + safe area). */\n bottomInsetPx: number;\n /** Top safe-area inset in px — limits maximum sheet height. */\n topInsetPx: number;\n /** Horizontal margin in px (currently informational, not used in snap math). */\n sideInsetPx: number;\n /** Whether margins collapse at the max snap point. */\n fullWidthAtMaxSnap: boolean;\n /** Bottom inset at max snap when fullWidthAtMaxSnap (safe area only, no margin). */\n expandedBottomInsetPx: number;\n}\n\ninterface UseBottomSheetSnapModelResult {\n /** The resolved snap points array. */\n resolvedSnapPoints: BottomSheetHeight[];\n /** Animated translateY position of the sheet. */\n translateY: SharedValue<number>;\n /** Current active snap index. */\n activeSnapIndex: SharedValue<number>;\n /** Whether the sheet is currently animating. */\n isAnimating: SharedValue<boolean>;\n /** Compute translateY for a given snap index (worklet). */\n getTranslateYForSnap: (index: number) => number;\n /** Compute the closed translateY position (worklet). */\n getClosedTranslateY: () => number;\n /** Animate to a specific snap index. */\n animateToSnap: (index: number) => void;\n /** Animate to the closed position. Optional callback fires on JS thread when complete. */\n animateToClose: (onComplete?: () => void) => void;\n /** Animate to a specific snap index from within a worklet. */\n animateToSnapWorklet: (index: number) => void;\n /** Animate to the closed position from within a worklet. */\n animateToCloseWorklet: () => void;\n}\n\n/**\n * Manages the snap-point position model for the bottom sheet.\n *\n * Resolves snap point strings to pixel positions, provides spring-animated\n * `animateToSnap` / `animateToClose` functions for both JS and UI threads,\n * and exposes shared values for `translateY`, `activeSnapIndex`, and `isAnimating`.\n *\n * Position model: `translateY = containerHeight - snapHeightPx - bottomInsetPx`\n */\nfunction useBottomSheetSnapModel({\n snapPointsProp,\n height,\n defaultSnapPointIndex,\n snapPointIndexProp,\n onSnapPointChange,\n containerHeight,\n bottomInsetPx,\n topInsetPx,\n fullWidthAtMaxSnap,\n expandedBottomInsetPx,\n}: UseBottomSheetSnapModelParams): UseBottomSheetSnapModelResult {\n const resolvedSnapPoints = useMemo<BottomSheetHeight[]>(() => {\n if (snapPointsProp?.length) {\n return snapPointsProp;\n }\n if (height !== undefined) {\n return [height];\n }\n return [DEFAULT_SNAP_POINT];\n }, [height, snapPointsProp]);\n\n // Start off-screen (will be set to closed position on first layout).\n const translateY = useSharedValue(9999);\n const activeSnapIndex = useSharedValue(\n clampIndex(snapPointIndexProp ?? defaultSnapPointIndex, resolvedSnapPoints.length),\n );\n const isAnimating = useSharedValue(false);\n\n /**\n * Compute translateY for a snap index.\n * Position model: translateY = containerHeight - snapHeightPx - bottomInsetPx\n */\n const getTranslateYForSnap = useCallback(\n (index: number): number => {\n 'worklet';\n const clamped = clampIndex(index, resolvedSnapPoints.length);\n const sp = resolvedSnapPoints[clamped]!;\n const heightPx = resolveHeightToPx(sp, containerHeight.value);\n // At max snap with fullWidthAtMaxSnap, margins collapse so use reduced bottom inset.\n const isExpandedMaxSnap = fullWidthAtMaxSnap && clamped === resolvedSnapPoints.length - 1;\n const effectiveBottomInset = isExpandedMaxSnap ? expandedBottomInsetPx : bottomInsetPx;\n const maxHeight = containerHeight.value - effectiveBottomInset - topInsetPx;\n const clampedHeight = Math.max(0, Math.min(heightPx, maxHeight));\n return containerHeight.value - clampedHeight - effectiveBottomInset;\n },\n [\n resolvedSnapPoints,\n containerHeight,\n bottomInsetPx,\n topInsetPx,\n fullWidthAtMaxSnap,\n expandedBottomInsetPx,\n ],\n );\n\n /** Compute the closed (off-screen) translateY. */\n const getClosedTranslateY = useCallback((): number => {\n 'worklet';\n return containerHeight.value + bottomInsetPx;\n }, [containerHeight, bottomInsetPx]);\n\n /** Emit snap point change callback on the JS thread. */\n const emitSnapChange = useCallback(\n (index: number) => {\n onSnapPointChange?.(index, resolvedSnapPoints[index]!);\n },\n [onSnapPointChange, resolvedSnapPoints],\n );\n\n /** Animate to snap index — call from JS thread. */\n const animateToSnap = useCallback(\n (index: number) => {\n const clamped = clampIndex(index, resolvedSnapPoints.length);\n const targetY = getTranslateYForSnap(clamped);\n\n isAnimating.value = true;\n activeSnapIndex.value = clamped;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n 'worklet';\n if (finished) {\n isAnimating.value = false;\n }\n });\n\n emitSnapChange(clamped);\n },\n [\n resolvedSnapPoints,\n getTranslateYForSnap,\n isAnimating,\n activeSnapIndex,\n translateY,\n emitSnapChange,\n ],\n );\n\n /** Animate to closed position — call from JS thread. */\n const animateToClose = useCallback(\n (onComplete?: () => void) => {\n const targetY = getClosedTranslateY();\n isAnimating.value = true;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n 'worklet';\n if (finished) {\n isAnimating.value = false;\n if (onComplete) {\n runOnJS(onComplete)();\n }\n }\n });\n },\n [getClosedTranslateY, isAnimating, translateY],\n );\n\n /** Animate to snap — safe to call from a worklet (onEnd handler). */\n const animateToSnapWorklet = useCallback(\n (index: number) => {\n 'worklet';\n const clamped = clampIndex(index, resolvedSnapPoints.length);\n const targetY = getTranslateYForSnap(clamped);\n\n isAnimating.value = true;\n activeSnapIndex.value = clamped;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n if (finished) {\n isAnimating.value = false;\n }\n });\n\n runOnJS(emitSnapChange)(clamped);\n },\n [\n resolvedSnapPoints,\n getTranslateYForSnap,\n isAnimating,\n activeSnapIndex,\n translateY,\n emitSnapChange,\n ],\n );\n\n /** Animate to closed — safe to call from a worklet. */\n const animateToCloseWorklet = useCallback(() => {\n 'worklet';\n const targetY = getClosedTranslateY();\n isAnimating.value = true;\n translateY.value = withSpring(targetY, SHEET_SPRING_CONFIG, (finished) => {\n if (finished) {\n isAnimating.value = false;\n }\n });\n }, [getClosedTranslateY, isAnimating, translateY]);\n\n return {\n resolvedSnapPoints,\n translateY,\n activeSnapIndex,\n isAnimating,\n getTranslateYForSnap,\n getClosedTranslateY,\n animateToSnap,\n animateToClose,\n animateToSnapWorklet,\n animateToCloseWorklet,\n };\n}\n\nexport { SHEET_SPRING_CONFIG, useBottomSheetSnapModel };\n"],"mappings":";;;;;;;;;;AAYA,MAAM,sBAAsB;CAC1B,SAAS,cAAc,OAAO,KAAK;CACnC,WAAW,cAAc,OAAO,KAAK;CACrC,MAAM;CACP;;;;;;;;;;AAsDD,SAAS,wBAAwB,EAC/B,gBACA,QACA,uBACA,oBACA,mBACA,iBACA,eACA,YACA,oBACA,yBAC+D;CAC/D,MAAM,qBAAqB,cAAmC;EAC5D,IAAI,gBAAgB,QAClB,OAAO;EAET,IAAI,WAAW,KAAA,GACb,OAAO,CAAC,OAAO;EAEjB,OAAO,CAAA,MAAoB;IAC1B,CAAC,QAAQ,eAAe,CAAC;CAG5B,MAAM,aAAa,eAAe,KAAK;CACvC,MAAM,kBAAkB,eACtB,WAAW,sBAAsB,uBAAuB,mBAAmB,OAAO,CACnF;CACD,MAAM,cAAc,eAAe,MAAM;;;;;CAMzC,MAAM,uBAAuB,aAC1B,UAA0B;AACzB;EACA,MAAM,UAAU,WAAW,OAAO,mBAAmB,OAAO;EAC5D,MAAM,KAAK,m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Y,QAAQ;GACpB,gBAAgB,QAAQ;GACxB,WAAW,QAAQ,WAAW,SAAS,sBAAsB,aAAa;IACxE,IAAI,UACF,YAAY,QAAQ;KAEtB;GAEF,QAAQ,eAAe,CAAC,QAAQ;KAElC;GACE;GACA;GACA;GACA;GACA;GACA;GACD,CAwBmB;EACpB,uBArB4B,kBAAkB;AAC9C;GACA,MAAM,UAAU,qBAAqB;GACrC,YAAY,QAAQ;GACpB,WAAW,QAAQ,WAAW,SAAS,sBAAsB,aAAa;IACxE,IAAI,UACF,YAAY,QAAQ;KAEtB;KACD;GAAC;GAAqB;GAAa;GAAW,CAY1B;EACtB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useBottomSheetStore.js","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetStore.ts"],"sourcesContent":["import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';\n\nimport type { BottomSheetController, UseBottomSheetStoreProps } from './types';\n\ntype Listener = () => void;\n\n/**\n * Creates a lightweight external store for bottom-sheet open/close state.\n * Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.\n *\n * @param initialOpen - Initial open state.\n * @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.\n * @internal\n */\nfunction createBottomSheetStore(initialOpen: boolean) {\n let isOpen = initialOpen;\n const listeners = new Set<Listener>();\n\n function subscribe(listener: Listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n }\n\n function getSnapshot() {\n return isOpen;\n }\n\n function setOpen(next: boolean) {\n if (next === isOpen) {\n return;\n }\n isOpen = next;\n for (const listener of listeners) {\n listener();\n }\n }\n\n return { subscribe, getSnapshot, setOpen };\n}\n\n/** @internal */\nconst BOTTOM_SHEET_INTERNAL_STORE_KEY = '__bottomSheetInternal';\n\ntype InternalStore = ReturnType<typeof createBottomSheetStore>;\n\ntype BottomSheetControllerWithInternal = BottomSheetController & {\n [BOTTOM_SHEET_INTERNAL_STORE_KEY]: InternalStore;\n};\n\n/** @internal — retrieve the internal store from a controller. */\nfunction getBottomSheetInternal(controller: BottomSheetController): InternalStore {\n const internal = (controller as BottomSheetControllerWithInternal)[\n BOTTOM_SHEET_INTERNAL_STORE_KEY\n ];\n if (!internal) {\n throw new Error('Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.');\n }\n return internal;\n}\n\n/**\n * Creates a {@link BottomSheetController} that manages open/close state.\n *\n * Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.\n * The returned controller can be passed to `<BottomSheetProvider controller={...}>`\n * or `<BottomSheet controller={...}>`.\n *\n * @param props - Optional `defaultOpen` and/or controlled `open` value.\n * @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.\n *\n * @example\n * ```tsx\n * const store = useBottomSheetStore();\n * // ...\n * <Button onPress={() => store.open()}>Open</Button>\n * ```\n */\nfunction useBottomSheetStore({\n defaultOpen = false,\n open: openProp,\n}: UseBottomSheetStoreProps = {}): BottomSheetController {\n // Use useState with lazy initializer to create the store once.\n const [store] = useState(() => createBottomSheetStore(openProp ?? defaultOpen));\n\n // Sync controlled `open` prop into store via effect.\n useEffect(() => {\n if (openProp !== undefined) {\n store.setOpen(openProp);\n }\n }, [openProp, store]);\n\n const isOpen = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n const open = useCallback(() => store.setOpen(true), [store]);\n const close = useCallback(() => store.setOpen(false), [store]);\n\n return {\n open,\n close,\n isOpen,\n [BOTTOM_SHEET_INTERNAL_STORE_KEY]: store,\n } as BottomSheetController;\n}\n\nexport { getBottomSheetInternal, useBottomSheetStore };\n"],"mappings":";;;;;;;;;;;AAcA,SAAS,uBAAuB,aAAsB;CACpD,IAAI,SAAS;CACb,MAAM,4BAAY,IAAI,KAAe;CAErC,SAAS,UAAU,UAAoB;AACrC,YAAU,IAAI,SAAS;AACvB,eAAa;AACX,aAAU,OAAO,SAAS;;;CAI9B,SAAS,cAAc;AACrB,SAAO;;CAGT,SAAS,QAAQ,MAAe;AAC9B,MAAI,SAAS,OACX;AAEF,WAAS;AACT,OAAK,MAAM,YAAY,UACrB,WAAU;;AAId,QAAO;EAAE;EAAW;EAAa;EAAS;;;AAI5C,MAAM,kCAAkC;;AASxC,SAAS,uBAAuB,YAAkD;CAChF,MAAM,WAAY,WAChB;AAEF,KAAI,CAAC,SACH,OAAM,IAAI,MAAM,6EAA6E;AAE/F,QAAO;;;;;;;;;;;;;;;;;;;AAoBT,SAAS,oBAAoB,EAC3B,cAAc,OACd,MAAM,aACsB,EAAE,EAAyB;CAEvD,MAAM,CAAC,SAAS,eAAe,uBAAuB,YAAY,YAAY,CAAC;AAG/E,iBAAgB;AACd,MAAI,aAAa,KAAA,EACf,OAAM,QAAQ,SAAS;IAExB,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,SAAS,qBAAqB,MAAM,WAAW,MAAM,YAAY;AAKvE,QAAO;EACL,MAJW,kBAAkB,MAAM,QAAQ,KAAK,EAAE,CAAC,MAAM,CAIrD;EACJ,OAJY,kBAAkB,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,CAItD;EACL;GACC,kCAAkC;EACpC"}
1
+ {"version":3,"file":"useBottomSheetStore.js","names":[],"sources":["../../../src/components/BottomSheet/useBottomSheetStore.ts"],"sourcesContent":["import { useCallback, useEffect, useState, useSyncExternalStore } from 'react';\n\nimport type { BottomSheetController, UseBottomSheetStoreProps } from './types';\n\ntype Listener = () => void;\n\n/**\n * Creates a lightweight external store for bottom-sheet open/close state.\n * Uses the `subscribe` / `getSnapshot` pattern for {@link useSyncExternalStore}.\n *\n * @param initialOpen - Initial open state.\n * @returns Store with `subscribe`, `getSnapshot`, and `setOpen`.\n * @internal\n */\nfunction createBottomSheetStore(initialOpen: boolean) {\n let isOpen = initialOpen;\n const listeners = new Set<Listener>();\n\n function subscribe(listener: Listener) {\n listeners.add(listener);\n return () => {\n listeners.delete(listener);\n };\n }\n\n function getSnapshot() {\n return isOpen;\n }\n\n function setOpen(next: boolean) {\n if (next === isOpen) {\n return;\n }\n isOpen = next;\n for (const listener of listeners) {\n listener();\n }\n }\n\n return { subscribe, getSnapshot, setOpen };\n}\n\n/** @internal */\nconst BOTTOM_SHEET_INTERNAL_STORE_KEY = '__bottomSheetInternal';\n\ntype InternalStore = ReturnType<typeof createBottomSheetStore>;\n\ntype BottomSheetControllerWithInternal = BottomSheetController & {\n [BOTTOM_SHEET_INTERNAL_STORE_KEY]: InternalStore;\n};\n\n/** @internal — retrieve the internal store from a controller. */\nfunction getBottomSheetInternal(controller: BottomSheetController): InternalStore {\n const internal = (controller as BottomSheetControllerWithInternal)[\n BOTTOM_SHEET_INTERNAL_STORE_KEY\n ];\n if (!internal) {\n throw new Error('Invalid BottomSheet controller. Use `useBottomSheetStore()` to create one.');\n }\n return internal;\n}\n\n/**\n * Creates a {@link BottomSheetController} that manages open/close state.\n *\n * Supports both uncontrolled (`defaultOpen`) and controlled (`open`) modes.\n * The returned controller can be passed to `<BottomSheetProvider controller={...}>`\n * or `<BottomSheet controller={...}>`.\n *\n * @param props - Optional `defaultOpen` and/or controlled `open` value.\n * @returns A stable {@link BottomSheetController} with `open()`, `close()`, and `isOpen`.\n *\n * @example\n * ```tsx\n * const store = useBottomSheetStore();\n * // ...\n * <Button onPress={() => store.open()}>Open</Button>\n * ```\n */\nfunction useBottomSheetStore({\n defaultOpen = false,\n open: openProp,\n}: UseBottomSheetStoreProps = {}): BottomSheetController {\n // Use useState with lazy initializer to create the store once.\n const [store] = useState(() => createBottomSheetStore(openProp ?? defaultOpen));\n\n // Sync controlled `open` prop into store via effect.\n useEffect(() => {\n if (openProp !== undefined) {\n store.setOpen(openProp);\n }\n }, [openProp, store]);\n\n const isOpen = useSyncExternalStore(store.subscribe, store.getSnapshot);\n\n const open = useCallback(() => store.setOpen(true), [store]);\n const close = useCallback(() => store.setOpen(false), [store]);\n\n return {\n open,\n close,\n isOpen,\n [BOTTOM_SHEET_INTERNAL_STORE_KEY]: store,\n } as BottomSheetController;\n}\n\nexport { getBottomSheetInternal, useBottomSheetStore };\n"],"mappings":";;;;;;;;;;;AAcA,SAAS,uBAAuB,aAAsB;CACpD,IAAI,SAAS;CACb,MAAM,4BAAY,IAAI,KAAe;CAErC,SAAS,UAAU,UAAoB;EACrC,UAAU,IAAI,SAAS;EACvB,aAAa;GACX,UAAU,OAAO,SAAS;;;CAI9B,SAAS,cAAc;EACrB,OAAO;;CAGT,SAAS,QAAQ,MAAe;EAC9B,IAAI,SAAS,QACX;EAEF,SAAS;EACT,KAAK,MAAM,YAAY,WACrB,UAAU;;CAId,OAAO;EAAE;EAAW;EAAa;EAAS;;;AAI5C,MAAM,kCAAkC;;AASxC,SAAS,uBAAuB,YAAkD;CAChF,MAAM,WAAY,WAChB;CAEF,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,6EAA6E;CAE/F,OAAO;;;;;;;;;;;;;;;;;;;AAoBT,SAAS,oBAAoB,EAC3B,cAAc,OACd,MAAM,aACsB,EAAE,EAAyB;CAEvD,MAAM,CAAC,SAAS,eAAe,uBAAuB,YAAY,YAAY,CAAC;CAG/E,gBAAgB;EACd,IAAI,aAAa,KAAA,GACf,MAAM,QAAQ,SAAS;IAExB,CAAC,UAAU,MAAM,CAAC;CAErB,MAAM,SAAS,qBAAqB,MAAM,WAAW,MAAM,YAAY;CAKvE,OAAO;EACL,MAJW,kBAAkB,MAAM,QAAQ,KAAK,EAAE,CAAC,MAAM,CAIrD;EACJ,OAJY,kBAAkB,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,CAItD;EACL;GACC,kCAAkC;EACpC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useExpansionMargins.js","names":[],"sources":["../../../src/components/BottomSheet/useExpansionMargins.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { interpolate, useAnimatedStyle } from 'react-native-reanimated';\n\nimport type { BottomSheetHeight } from './types';\nimport { clampIndex, resolveHeightToPx } from './utils';\n\n/** @internal */\ninterface UseExpansionMarginsParams {\n /** Whether `fullWidthAtMaxSnap` is enabled on the sheet. */\n enabled: boolean;\n /** Base horizontal margin from configurator tokens (px). */\n baseMarginHorizontal: number;\n /** Base bottom margin from configurator tokens (px). */\n baseMarginBottom: number;\n /** Resolved snap points array. */\n resolvedSnapPoints: BottomSheetHeight[];\n /** Container height (UI-thread shared value). */\n containerHeight: SharedValue<number>;\n /** Bottom inset in px (margin + safe area). */\n bottomInsetPx: number;\n /** Bottom inset at max snap when expanded (safe area only, no margin). */\n expandedBottomInsetPx: number;\n /** The sheet's animated translateY shared value. */\n translateY: SharedValue<number>;\n}\n\n/**\n * Animates sheet margins from their base values to `0` as the sheet expands\n * from the second-highest snap point to the max snap point.\n *\n * Also returns the interpolation thresholds (`maxSnapTranslateY` and\n * `thresholdTranslateY`) so the caller can animate other properties\n * (e.g. the height constraint's effective bottom inset) in sync.\n *\n * @returns An animated margin style and the expansion interpolation thresholds.\n */\nfunction useExpansionMargins({\n enabled,\n baseMarginHorizontal,\n baseMarginBottom,\n resolvedSnapPoints,\n containerHeight,\n bottomInsetPx,\n expandedBottomInsetPx,\n translateY,\n}: UseExpansionMarginsParams) {\n // Compute threshold and max snap translateY positions.\n // Max snap uses expandedBottomInsetPx (margins collapsed), threshold uses bottomInsetPx.\n const { maxSnapTranslateY, thresholdTranslateY } = useMemo(() => {\n if (!enabled || resolvedSnapPoints.length === 0) {\n return { maxSnapTranslateY: 0, thresholdTranslateY: 0 };\n }\n\n const h = containerHeight.value;\n const maxIdx = resolvedSnapPoints.length - 1;\n const maxHeight = resolveHeightToPx(resolvedSnapPoints[maxIdx]!, h);\n const clampedMax = Math.min(maxHeight, h - expandedBottomInsetPx);\n const maxTransY = h - clampedMax - expandedBottomInsetPx;\n\n // Threshold is the second-highest snap, or the max snap if only one exists.\n const thresholdIdx = clampIndex(maxIdx - 1, resolvedSnapPoints.length);\n const thresholdHeight = resolveHeightToPx(resolvedSnapPoints[thresholdIdx]!, h);\n const clampedThreshold = Math.min(thresholdHeight, h - bottomInsetPx);\n const thresholdTransY = h - clampedThreshold - bottomInsetPx;\n\n return { maxSnapTranslateY: maxTransY, thresholdTranslateY: thresholdTransY };\n }, [enabled, resolvedSnapPoints, containerHeight.value, bottomInsetPx, expandedBottomInsetPx]);\n\n const animatedMarginStyle = useAnimatedStyle(() => {\n if (!enabled) {\n return {};\n }\n\n // When translateY moves from thresholdTranslateY to maxSnapTranslateY\n // (sheet expanding), margins go from base values to 0.\n const mh = interpolate(\n translateY.value,\n [maxSnapTranslateY, thresholdTranslateY],\n [0, baseMarginHorizontal],\n 'clamp',\n );\n const mb = interpolate(\n translateY.value,\n [maxSnapTranslateY, thresholdTranslateY],\n [0, baseMarginBottom],\n 'clamp',\n );\n\n return {\n marginLeft: mh,\n marginRight: mh,\n marginBottom: mb,\n };\n });\n\n return { animatedMarginStyle, maxSnapTranslateY, thresholdTranslateY };\n}\n\nexport { useExpansionMargins };\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,SAAS,oBAAoB,EAC3B,SACA,sBACA,kBACA,oBACA,iBACA,eACA,uBACA,cAC4B;CAG5B,MAAM,EAAE,mBAAmB,wBAAwB,cAAc;AAC/D,MAAI,CAAC,WAAW,mBAAmB,WAAW,EAC5C,QAAO;GAAE,mBAAmB;GAAG,qBAAqB;GAAG;EAGzD,MAAM,IAAI,gBAAgB;EAC1B,MAAM,SAAS,mBAAmB,SAAS;EAC3C,MAAM,YAAY,kBAAkB,mBAAmB,SAAU,EAAE;EAEnE,MAAM,YAAY,IADC,KAAK,IAAI,WAAW,IAAI,sBACX,GAAG;EAInC,MAAM,kBAAkB,kBAAkB,mBADrB,WAAW,SAAS,GAAG,mBAAmB,OACU,GAAI,EAAE;AAI/E,SAAO;GAAE,mBAAmB;GAAW,qBAFf,IADC,KAAK,IAAI,iBAAiB,IAAI,cACX,GAAG;GAE8B;IAC5E;EAAC;EAAS;EAAoB,gBAAgB;EAAO;EAAe;EAAsB,CAAC;AA6B9F,QAAO;EAAE,qBA3BmB,uBAAuB;AACjD,OAAI,CAAC,QACH,QAAO,EAAE;GAKX,MAAM,KAAK,YACT,WAAW,OACX,CAAC,mBAAmB,oBAAoB,EACxC,CAAC,GAAG,qBAAqB,EACzB,QACD;AAQD,UAAO;IACL,YAAY;IACZ,aAAa;IACb,cAVS,YACT,WAAW,OACX,CAAC,mBAAmB,oBAAoB,EACxC,CAAC,GAAG,iBAAiB,EACrB,QAMgB;IACjB;IAGyB;EAAE;EAAmB;EAAqB"}
1
+ {"version":3,"file":"useExpansionMargins.js","names":[],"sources":["../../../src/components/BottomSheet/useExpansionMargins.ts"],"sourcesContent":["import { useMemo } from 'react';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { interpolate, useAnimatedStyle } from 'react-native-reanimated';\n\nimport type { BottomSheetHeight } from './types';\nimport { clampIndex, resolveHeightToPx } from './utils';\n\n/** @internal */\ninterface UseExpansionMarginsParams {\n /** Whether `fullWidthAtMaxSnap` is enabled on the sheet. */\n enabled: boolean;\n /** Base horizontal margin from configurator tokens (px). */\n baseMarginHorizontal: number;\n /** Base bottom margin from configurator tokens (px). */\n baseMarginBottom: number;\n /** Resolved snap points array. */\n resolvedSnapPoints: BottomSheetHeight[];\n /** Container height (UI-thread shared value). */\n containerHeight: SharedValue<number>;\n /** Bottom inset in px (margin + safe area). */\n bottomInsetPx: number;\n /** Bottom inset at max snap when expanded (safe area only, no margin). */\n expandedBottomInsetPx: number;\n /** The sheet's animated translateY shared value. */\n translateY: SharedValue<number>;\n}\n\n/**\n * Animates sheet margins from their base values to `0` as the sheet expands\n * from the second-highest snap point to the max snap point.\n *\n * Also returns the interpolation thresholds (`maxSnapTranslateY` and\n * `thresholdTranslateY`) so the caller can animate other properties\n * (e.g. the height constraint's effective bottom inset) in sync.\n *\n * @returns An animated margin style and the expansion interpolation thresholds.\n */\nfunction useExpansionMargins({\n enabled,\n baseMarginHorizontal,\n baseMarginBottom,\n resolvedSnapPoints,\n containerHeight,\n bottomInsetPx,\n expandedBottomInsetPx,\n translateY,\n}: UseExpansionMarginsParams) {\n // Compute threshold and max snap translateY positions.\n // Max snap uses expandedBottomInsetPx (margins collapsed), threshold uses bottomInsetPx.\n const { maxSnapTranslateY, thresholdTranslateY } = useMemo(() => {\n if (!enabled || resolvedSnapPoints.length === 0) {\n return { maxSnapTranslateY: 0, thresholdTranslateY: 0 };\n }\n\n const h = containerHeight.value;\n const maxIdx = resolvedSnapPoints.length - 1;\n const maxHeight = resolveHeightToPx(resolvedSnapPoints[maxIdx]!, h);\n const clampedMax = Math.min(maxHeight, h - expandedBottomInsetPx);\n const maxTransY = h - clampedMax - expandedBottomInsetPx;\n\n // Threshold is the second-highest snap, or the max snap if only one exists.\n const thresholdIdx = clampIndex(maxIdx - 1, resolvedSnapPoints.length);\n const thresholdHeight = resolveHeightToPx(resolvedSnapPoints[thresholdIdx]!, h);\n const clampedThreshold = Math.min(thresholdHeight, h - bottomInsetPx);\n const thresholdTransY = h - clampedThreshold - bottomInsetPx;\n\n return { maxSnapTranslateY: maxTransY, thresholdTranslateY: thresholdTransY };\n }, [enabled, resolvedSnapPoints, containerHeight.value, bottomInsetPx, expandedBottomInsetPx]);\n\n const animatedMarginStyle = useAnimatedStyle(() => {\n if (!enabled) {\n return {};\n }\n\n // When translateY moves from thresholdTranslateY to maxSnapTranslateY\n // (sheet expanding), margins go from base values to 0.\n const mh = interpolate(\n translateY.value,\n [maxSnapTranslateY, thresholdTranslateY],\n [0, baseMarginHorizontal],\n 'clamp',\n );\n const mb = interpolate(\n translateY.value,\n [maxSnapTranslateY, thresholdTranslateY],\n [0, baseMarginBottom],\n 'clamp',\n );\n\n return {\n marginLeft: mh,\n marginRight: mh,\n marginBottom: mb,\n };\n });\n\n return { animatedMarginStyle, maxSnapTranslateY, thresholdTranslateY };\n}\n\nexport { useExpansionMargins };\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,SAAS,oBAAoB,EAC3B,SACA,sBACA,kBACA,oBACA,iBACA,eACA,uBACA,cAC4B;CAG5B,MAAM,EAAE,mBAAmB,wBAAwB,cAAc;EAC/D,IAAI,CAAC,WAAW,mBAAmB,WAAW,GAC5C,OAAO;GAAE,mBAAmB;GAAG,qBAAqB;GAAG;EAGzD,MAAM,IAAI,gBAAgB;EAC1B,MAAM,SAAS,mBAAmB,SAAS;EAC3C,MAAM,YAAY,kBAAkB,mBAAmB,SAAU,EAAE;EAEnE,MAAM,YAAY,IADC,KAAK,IAAI,WAAW,IAAI,sBACX,GAAG;EAInC,MAAM,kBAAkB,kBAAkB,mBADrB,WAAW,SAAS,GAAG,mBAAmB,OACU,GAAI,EAAE;EAI/E,OAAO;GAAE,mBAAmB;GAAW,qBAFf,IADC,KAAK,IAAI,iBAAiB,IAAI,cACX,GAAG;GAE8B;IAC5E;EAAC;EAAS;EAAoB,gBAAgB;EAAO;EAAe;EAAsB,CAAC;CA6B9F,OAAO;EAAE,qBA3BmB,uBAAuB;GACjD,IAAI,CAAC,SACH,OAAO,EAAE;GAKX,MAAM,KAAK,YACT,WAAW,OACX,CAAC,mBAAmB,oBAAoB,EACxC,CAAC,GAAG,qBAAqB,EACzB,QACD;GAQD,OAAO;IACL,YAAY;IACZ,aAAa;IACb,cAVS,YACT,WAAW,OACX,CAAC,mBAAmB,oBAAoB,EACxC,CAAC,GAAG,iBAAiB,EACrB,QAMgB;IACjB;IAGyB;EAAE;EAAmB;EAAqB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useKeyboardAvoidance.js","names":[],"sources":["../../../src/components/BottomSheet/useKeyboardAvoidance.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { Keyboard, Platform } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { withTiming } from 'react-native-reanimated';\n\n/** Duration (ms) for the keyboard offset animation. */\nconst KEYBOARD_ANIMATION_DURATION = 250;\n\n/** @internal */\ninterface UseKeyboardAvoidanceParams {\n /** Whether the sheet is currently open. */\n isOpen: boolean;\n /** The sheet's animated translateY shared value. */\n translateY: SharedValue<number>;\n /** Whether the sheet is currently animating (snap/close spring). */\n isAnimating: SharedValue<boolean>;\n}\n\n/**\n * Offsets the sheet's `translateY` when the software keyboard opens or closes.\n *\n * - **iOS**: Listens to `keyboardWillShow` / `keyboardWillHide` for smoother,\n * synchronous animation with the keyboard.\n * - **Android**: Listens to `keyboardDidShow` / `keyboardDidHide` (will-events\n * are not available on Android).\n *\n * Captures `translateY` before the offset and restores it when the keyboard hides.\n */\nfunction useKeyboardAvoidance({ isOpen, translateY, isAnimating }: UseKeyboardAvoidanceParams) {\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n // Store the translateY before keyboard offset so we can restore it.\n let preKeyboardTranslateY: number | null = null;\n\n const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';\n const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';\n\n const showSub = Keyboard.addListener(showEvent, (event) => {\n const keyboardHeight = event.endCoordinates.height;\n if (keyboardHeight <= 0) {\n return;\n }\n\n // Capture current position before offsetting.\n if (preKeyboardTranslateY === null) {\n preKeyboardTranslateY = translateY.value;\n }\n\n // Clear isAnimating so a cancelled snap/close spring doesn't leave\n // drag permanently blocked. The keyboard animation takes over translateY.\n isAnimating.value = false;\n\n // Move sheet up by keyboard height.\n const target = preKeyboardTranslateY - keyboardHeight;\n // Clamp to 0 so the sheet doesn't go above the screen.\n const clamped = Math.max(0, target);\n translateY.value = withTiming(clamped, { duration: KEYBOARD_ANIMATION_DURATION });\n });\n\n const hideSub = Keyboard.addListener(hideEvent, () => {\n if (preKeyboardTranslateY !== null) {\n translateY.value = withTiming(preKeyboardTranslateY, {\n duration: KEYBOARD_ANIMATION_DURATION,\n });\n preKeyboardTranslateY = null;\n }\n });\n\n return () => {\n showSub.remove();\n hideSub.remove();\n };\n }, [isOpen, translateY, isAnimating]);\n}\n\nexport { useKeyboardAvoidance };\n"],"mappings":";;;;;;AAMA,MAAM,8BAA8B;;;;;;;;;;;AAsBpC,SAAS,qBAAqB,EAAE,QAAQ,YAAY,eAA2C;AAC7F,iBAAgB;AACd,MAAI,CAAC,OACH;EAIF,IAAI,wBAAuC;EAE3C,MAAM,YAAY,SAAS,OAAO,QAAQ,qBAAqB;EAC/D,MAAM,YAAY,SAAS,OAAO,QAAQ,qBAAqB;EAE/D,MAAM,UAAU,SAAS,YAAY,YAAY,UAAU;GACzD,MAAM,iBAAiB,MAAM,eAAe;AAC5C,OAAI,kBAAkB,EACpB;AAIF,OAAI,0BAA0B,KAC5B,yBAAwB,WAAW;AAKrC,eAAY,QAAQ;GAGpB,MAAM,SAAS,wBAAwB;AAGvC,cAAW,QAAQ,WADH,KAAK,IAAI,GAAG,OACS,EAAE,EAAE,UAAU,6BAA6B,CAAC;IACjF;EAEF,MAAM,UAAU,SAAS,YAAY,iBAAiB;AACpD,OAAI,0BAA0B,MAAM;AAClC,eAAW,QAAQ,WAAW,uBAAuB,EACnD,UAAU,6BACX,CAAC;AACF,4BAAwB;;IAE1B;AAEF,eAAa;AACX,WAAQ,QAAQ;AAChB,WAAQ,QAAQ;;IAEjB;EAAC;EAAQ;EAAY;EAAY,CAAC"}
1
+ {"version":3,"file":"useKeyboardAvoidance.js","names":[],"sources":["../../../src/components/BottomSheet/useKeyboardAvoidance.ts"],"sourcesContent":["import { useEffect } from 'react';\nimport { Keyboard, Platform } from 'react-native';\nimport type { SharedValue } from 'react-native-reanimated';\nimport { withTiming } from 'react-native-reanimated';\n\n/** Duration (ms) for the keyboard offset animation. */\nconst KEYBOARD_ANIMATION_DURATION = 250;\n\n/** @internal */\ninterface UseKeyboardAvoidanceParams {\n /** Whether the sheet is currently open. */\n isOpen: boolean;\n /** The sheet's animated translateY shared value. */\n translateY: SharedValue<number>;\n /** Whether the sheet is currently animating (snap/close spring). */\n isAnimating: SharedValue<boolean>;\n}\n\n/**\n * Offsets the sheet's `translateY` when the software keyboard opens or closes.\n *\n * - **iOS**: Listens to `keyboardWillShow` / `keyboardWillHide` for smoother,\n * synchronous animation with the keyboard.\n * - **Android**: Listens to `keyboardDidShow` / `keyboardDidHide` (will-events\n * are not available on Android).\n *\n * Captures `translateY` before the offset and restores it when the keyboard hides.\n */\nfunction useKeyboardAvoidance({ isOpen, translateY, isAnimating }: UseKeyboardAvoidanceParams) {\n useEffect(() => {\n if (!isOpen) {\n return;\n }\n\n // Store the translateY before keyboard offset so we can restore it.\n let preKeyboardTranslateY: number | null = null;\n\n const showEvent = Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow';\n const hideEvent = Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide';\n\n const showSub = Keyboard.addListener(showEvent, (event) => {\n const keyboardHeight = event.endCoordinates.height;\n if (keyboardHeight <= 0) {\n return;\n }\n\n // Capture current position before offsetting.\n if (preKeyboardTranslateY === null) {\n preKeyboardTranslateY = translateY.value;\n }\n\n // Clear isAnimating so a cancelled snap/close spring doesn't leave\n // drag permanently blocked. The keyboard animation takes over translateY.\n isAnimating.value = false;\n\n // Move sheet up by keyboard height.\n const target = preKeyboardTranslateY - keyboardHeight;\n // Clamp to 0 so the sheet doesn't go above the screen.\n const clamped = Math.max(0, target);\n translateY.value = withTiming(clamped, { duration: KEYBOARD_ANIMATION_DURATION });\n });\n\n const hideSub = Keyboard.addListener(hideEvent, () => {\n if (preKeyboardTranslateY !== null) {\n translateY.value = withTiming(preKeyboardTranslateY, {\n duration: KEYBOARD_ANIMATION_DURATION,\n });\n preKeyboardTranslateY = null;\n }\n });\n\n return () => {\n showSub.remove();\n hideSub.remove();\n };\n }, [isOpen, translateY, isAnimating]);\n}\n\nexport { useKeyboardAvoidance };\n"],"mappings":";;;;;;AAMA,MAAM,8BAA8B;;;;;;;;;;;AAsBpC,SAAS,qBAAqB,EAAE,QAAQ,YAAY,eAA2C;CAC7F,gBAAgB;EACd,IAAI,CAAC,QACH;EAIF,IAAI,wBAAuC;EAE3C,MAAM,YAAY,SAAS,OAAO,QAAQ,qBAAqB;EAC/D,MAAM,YAAY,SAAS,OAAO,QAAQ,qBAAqB;EAE/D,MAAM,UAAU,SAAS,YAAY,YAAY,UAAU;GACzD,MAAM,iBAAiB,MAAM,eAAe;GAC5C,IAAI,kBAAkB,GACpB;GAIF,IAAI,0BAA0B,MAC5B,wBAAwB,WAAW;GAKrC,YAAY,QAAQ;GAGpB,MAAM,SAAS,wBAAwB;GAGvC,WAAW,QAAQ,WADH,KAAK,IAAI,GAAG,OACS,EAAE,EAAE,UAAU,6BAA6B,CAAC;IACjF;EAEF,MAAM,UAAU,SAAS,YAAY,iBAAiB;GACpD,IAAI,0BAA0B,MAAM;IAClC,WAAW,QAAQ,WAAW,uBAAuB,EACnD,UAAU,6BACX,CAAC;IACF,wBAAwB;;IAE1B;EAEF,aAAa;GACX,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;;IAEjB;EAAC;EAAQ;EAAY;EAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/BottomSheet/utils.ts"],"sourcesContent":["import type { BottomSheetHeight } from './types';\n\n/** Default snap point used when neither `snapPoints` nor `height` is specified. */\nconst DEFAULT_SNAP_POINT: BottomSheetHeight = '40%';\n\n/**\n * Resolves a {@link BottomSheetHeight} string to a pixel value.\n *\n * @param height - A percentage (`'50%'`) or pixel (`'300px'`) string.\n * @param containerHeightPx - The container height in pixels (used for `%` values).\n * @returns The resolved height in pixels, or `0` if the format is invalid.\n */\nfunction resolveHeightToPx(height: BottomSheetHeight, containerHeightPx: number): number {\n 'worklet';\n const trimmed = (height as string).trim();\n\n if (trimmed.endsWith('%')) {\n const pct = Number.parseFloat(trimmed.slice(0, -1));\n if (Number.isFinite(pct)) {\n return (pct / 100) * containerHeightPx;\n }\n }\n\n if (trimmed.endsWith('px')) {\n const px = Number.parseFloat(trimmed.slice(0, -2));\n if (Number.isFinite(px)) {\n return px;\n }\n }\n\n return 0;\n}\n\n/**\n * Clamps an index into the valid range `[0, length - 1]`.\n *\n * @param index - The index to clamp.\n * @param length - The length of the array.\n * @returns The clamped index.\n */\nfunction clampIndex(index: number, length: number): number {\n 'worklet';\n if (length <= 0) {\n return 0;\n }\n return Math.max(0, Math.min(index, length - 1));\n}\n\n/**\n * Clamps a numeric value to `[min, max]`.\n *\n * @param value - The value to clamp.\n * @param min - Lower bound.\n * @param max - Upper bound.\n * @returns The clamped value.\n */\nfunction clamp(value: number, min: number, max: number): number {\n 'worklet';\n return Math.max(min, Math.min(max, value));\n}\n\n/**\n * Resolves an array of snap points into pixel heights and translateY positions.\n *\n * Position model: `translateY = containerHeight - snapHeightPx - bottomInsetPx`\n *\n * @param snapPoints - Array of snap point height strings.\n * @param containerHeightPx - Container height in pixels.\n * @param bottomInsetPx - Bottom inset (margin + safe area) in pixels.\n * @param maxHeightPx - Maximum allowed sheet height in pixels.\n * @returns Object containing `heightsPx`, `translateYs`, and `closedTranslateY`.\n */\nfunction resolveSnapPositions(\n snapPoints: BottomSheetHeight[],\n containerHeightPx: number,\n bottomInsetPx: number,\n maxHeightPx: number,\n) {\n 'worklet';\n const heightsPx = snapPoints.map((sp) =>\n clamp(resolveHeightToPx(sp, containerHeightPx), 0, maxHeightPx),\n );\n const translateYs = heightsPx.map((h) => containerHeightPx - h - bottomInsetPx);\n const closedTranslateY = containerHeightPx + bottomInsetPx;\n\n return { heightsPx, translateYs, closedTranslateY };\n}\n\nexport { clamp, clampIndex, DEFAULT_SNAP_POINT, resolveHeightToPx, resolveSnapPositions };\n"],"mappings":";;;AAGA,MAAM,qBAAwC;;;;;;;;AAS9C,SAAS,kBAAkB,QAA2B,mBAAmC;AACvF;CACA,MAAM,UAAW,OAAkB,MAAM;AAEzC,KAAI,QAAQ,SAAS,IAAI,EAAE;EACzB,MAAM,MAAM,OAAO,WAAW,QAAQ,MAAM,GAAG,GAAG,CAAC;AACnD,MAAI,OAAO,SAAS,IAAI,CACtB,QAAQ,MAAM,MAAO;;AAIzB,KAAI,QAAQ,SAAS,KAAK,EAAE;EAC1B,MAAM,KAAK,OAAO,WAAW,QAAQ,MAAM,GAAG,GAAG,CAAC;AAClD,MAAI,OAAO,SAAS,GAAG,CACrB,QAAO;;AAIX,QAAO;;;;;;;;;AAUT,SAAS,WAAW,OAAe,QAAwB;AACzD;AACA,KAAI,UAAU,EACZ,QAAO;AAET,QAAO,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,SAAS,EAAE,CAAC;;;;;;;;;;AAWjD,SAAS,MAAM,OAAe,KAAa,KAAqB;AAC9D;AACA,QAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,MAAM,CAAC;;;;;;;;;;;;;AAc5C,SAAS,qBACP,YACA,mBACA,eACA,aACA;AACA;CACA,MAAM,YAAY,WAAW,KAAK,OAChC,MAAM,kBAAkB,IAAI,kBAAkB,EAAE,GAAG,YAAY,CAChE;AAID,QAAO;EAAE;EAAW,aAHA,UAAU,KAAK,MAAM,oBAAoB,IAAI,cAGlC;EAAE,kBAFR,oBAAoB;EAEM"}
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../../src/components/BottomSheet/utils.ts"],"sourcesContent":["import type { BottomSheetHeight } from './types';\n\n/** Default snap point used when neither `snapPoints` nor `height` is specified. */\nconst DEFAULT_SNAP_POINT: BottomSheetHeight = '40%';\n\n/**\n * Resolves a {@link BottomSheetHeight} string to a pixel value.\n *\n * @param height - A percentage (`'50%'`) or pixel (`'300px'`) string.\n * @param containerHeightPx - The container height in pixels (used for `%` values).\n * @returns The resolved height in pixels, or `0` if the format is invalid.\n */\nfunction resolveHeightToPx(height: BottomSheetHeight, containerHeightPx: number): number {\n 'worklet';\n const trimmed = (height as string).trim();\n\n if (trimmed.endsWith('%')) {\n const pct = Number.parseFloat(trimmed.slice(0, -1));\n if (Number.isFinite(pct)) {\n return (pct / 100) * containerHeightPx;\n }\n }\n\n if (trimmed.endsWith('px')) {\n const px = Number.parseFloat(trimmed.slice(0, -2));\n if (Number.isFinite(px)) {\n return px;\n }\n }\n\n return 0;\n}\n\n/**\n * Clamps an index into the valid range `[0, length - 1]`.\n *\n * @param index - The index to clamp.\n * @param length - The length of the array.\n * @returns The clamped index.\n */\nfunction clampIndex(index: number, length: number): number {\n 'worklet';\n if (length <= 0) {\n return 0;\n }\n return Math.max(0, Math.min(index, length - 1));\n}\n\n/**\n * Clamps a numeric value to `[min, max]`.\n *\n * @param value - The value to clamp.\n * @param min - Lower bound.\n * @param max - Upper bound.\n * @returns The clamped value.\n */\nfunction clamp(value: number, min: number, max: number): number {\n 'worklet';\n return Math.max(min, Math.min(max, value));\n}\n\n/**\n * Resolves an array of snap points into pixel heights and translateY positions.\n *\n * Position model: `translateY = containerHeight - snapHeightPx - bottomInsetPx`\n *\n * @param snapPoints - Array of snap point height strings.\n * @param containerHeightPx - Container height in pixels.\n * @param bottomInsetPx - Bottom inset (margin + safe area) in pixels.\n * @param maxHeightPx - Maximum allowed sheet height in pixels.\n * @returns Object containing `heightsPx`, `translateYs`, and `closedTranslateY`.\n */\nfunction resolveSnapPositions(\n snapPoints: BottomSheetHeight[],\n containerHeightPx: number,\n bottomInsetPx: number,\n maxHeightPx: number,\n) {\n 'worklet';\n const heightsPx = snapPoints.map((sp) =>\n clamp(resolveHeightToPx(sp, containerHeightPx), 0, maxHeightPx),\n );\n const translateYs = heightsPx.map((h) => containerHeightPx - h - bottomInsetPx);\n const closedTranslateY = containerHeightPx + bottomInsetPx;\n\n return { heightsPx, translateYs, closedTranslateY };\n}\n\nexport { clamp, clampIndex, DEFAULT_SNAP_POINT, resolveHeightToPx, resolveSnapPositions };\n"],"mappings":";;;AAGA,MAAM,qBAAwC;;;;;;;;AAS9C,SAAS,kBAAkB,QAA2B,mBAAmC;AACvF;CACA,MAAM,UAAW,OAAkB,MAAM;CAEzC,IAAI,QAAQ,SAAS,IAAI,EAAE;EACzB,MAAM,MAAM,OAAO,WAAW,QAAQ,MAAM,GAAG,GAAG,CAAC;EACnD,IAAI,OAAO,SAAS,IAAI,EACtB,OAAQ,MAAM,MAAO;;CAIzB,IAAI,QAAQ,SAAS,KAAK,EAAE;EAC1B,MAAM,KAAK,OAAO,WAAW,QAAQ,MAAM,GAAG,GAAG,CAAC;EAClD,IAAI,OAAO,SAAS,GAAG,EACrB,OAAO;;CAIX,OAAO;;;;;;;;;AAUT,SAAS,WAAW,OAAe,QAAwB;AACzD;CACA,IAAI,UAAU,GACZ,OAAO;CAET,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,OAAO,SAAS,EAAE,CAAC;;;;;;;;;;AAWjD,SAAS,MAAM,OAAe,KAAa,KAAqB;AAC9D;CACA,OAAO,KAAK,IAAI,KAAK,KAAK,IAAI,KAAK,MAAM,CAAC;;;;;;;;;;;;;AAc5C,SAAS,qBACP,YACA,mBACA,eACA,aACA;AACA;CACA,MAAM,YAAY,WAAW,KAAK,OAChC,MAAM,kBAAkB,IAAI,kBAAkB,EAAE,GAAG,YAAY,CAChE;CAID,OAAO;EAAE;EAAW,aAHA,UAAU,KAAK,MAAM,oBAAoB,IAAI,cAGlC;EAAE,kBAFR,oBAAoB;EAEM"}
@@ -1 +1 @@
1
- {"version":3,"file":"Box.js","names":["StyleSheet"],"sources":["../../src/components/Box.tsx"],"sourcesContent":["import type { ElevationLevel } from '@yahoo/uds-types';\nimport type { ComponentType, Ref, RefObject } from 'react';\nimport { memo, useEffect, useMemo, useRef, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Platform, View } from 'react-native';\n// eslint-disable-next-line uds/no-use-unistyles -- blur intensity is not a style property, requires direct theme access\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport type { SizeProps } from '../types';\n\n// Optional expo-blur dependency - loaded via dynamic import for Metro compatibility\n// Metro can statically analyze import() and will include expo-blur in the bundle if installed\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet BlurView: ComponentType<any> | null = null;\nlet blurLoadState: 'pending' | 'loaded' | 'failed' = 'pending';\nconst blurLoadListeners: (() => void)[] = [];\n\n// Start loading expo-blur immediately (Metro will bundle it if installed)\nimport('expo-blur')\n .then((mod) => {\n BlurView = mod.BlurView;\n blurLoadState = 'loaded';\n blurLoadListeners.forEach((cb) => cb());\n })\n .catch(() => {\n blurLoadState = 'failed';\n blurLoadListeners.forEach((cb) => cb());\n });\n\n/** Hook to get BlurView component, re-renders when loaded */\nfunction useBlurView() {\n const [, forceUpdate] = useState(0);\n\n useEffect(() => {\n if (blurLoadState === 'pending') {\n const listener = () => forceUpdate((n) => n + 1);\n blurLoadListeners.push(listener);\n return () => {\n const idx = blurLoadListeners.indexOf(listener);\n if (idx >= 0) {\n blurLoadListeners.splice(idx, 1);\n }\n };\n }\n }, []);\n\n return { BlurView, isLoaded: blurLoadState !== 'pending', isFailed: blurLoadState === 'failed' };\n}\n\ninterface BoxProps extends ViewProps, SizeProps {\n ref?: Ref<View>;\n elevation?: ElevationLevel;\n backgroundColor?: StyleProps['backgroundColor'];\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 alignContent?: StyleProps['alignContent'];\n alignItems?: StyleProps['alignItems'];\n alignSelf?: StyleProps['alignSelf'];\n flex?: StyleProps['flex'];\n flexDirection?: StyleProps['flexDirection'];\n flexGrow?: StyleProps['flexGrow'];\n flexShrink?: StyleProps['flexShrink'];\n flexWrap?: StyleProps['flexWrap'];\n justifyContent?: StyleProps['justifyContent'];\n // flexBasis?: StyleProps['flexBasis'];\n display?: StyleProps['display'];\n overflow?: StyleProps['overflow'];\n // overflowX?: StyleProps['overflowX'];\n // overflowY?: StyleProps['overflowY'];\n // position?: StyleProps['position'];\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?: 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 columnGap?: StyleProps['columnGap'];\n rowGap?: StyleProps['rowGap'];\n dropShadow?: StyleProps['dropShadow'];\n insetShadow?: StyleProps['insetShadow'];\n dangerouslySetBackgroundColor?: string;\n dangerouslySetBorderColor?: string;\n /**\n * Manual blur intensity (0-100). When set, renders as a BlurView.\n * Requires `blurTarget` pointing to a BlurTarget ref wrapping the content to blur.\n */\n blur?: number;\n /**\n * Reference to a BlurTarget component wrapping the content to blur.\n * Required when using `blur` prop or elevation with blur configured.\n */\n blurTarget?: RefObject<View | null>;\n}\n\n/**\n * **📦 A layout component that can be used to compose other components**\n *\n * @description\n * The most simple component we ship - a View. But with all the power of the UDS design system.\n * By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,\n * consider using VStack or HStack respectively.\n *\n * @category Layout\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Box } from '@yahoo/uds-mobile/Box';\n *\n * <Box backgroundColor=\"primary\" spacing=\"6\">\n * Any kind of content can go here!\n * </Box>\n * ```\n *\n * @usage\n * - Use as a container to apply padding, shapes, or other styling\n * - Use for creating card components\n * - Use HStack/VStack for directional layouts\n *\n * @see {@link HStack} for horizontal layouts\n * @see {@link VStack} for vertical layouts\n */\nconst Box = memo(function Box({\n // elevation\n elevation,\n // background\n backgroundColor,\n dangerouslySetBackgroundColor,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n dangerouslySetBorderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // flex\n alignContent,\n alignItems,\n alignSelf,\n flex,\n flexDirection,\n flexGrow,\n flexShrink,\n flexWrap,\n justifyContent,\n // flexBasis,\n // layout\n display = 'flex',\n overflow,\n // overflowX,\n // overflowY,\n // position,\n // spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n columnGap,\n rowGap,\n // size\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n // shadow\n dropShadow,\n insetShadow,\n // blur\n blur,\n blurTarget,\n // // nested border radius\n // nestedBorderRadius,\n // nestedBorderRadiusSize = nestedBorderRadius ? borderRadius : undefined,\n // nestedBorderRadiusSpacing = nestedBorderRadius ? spacing : undefined,\n // nestedBorderRadiusWidth = nestedBorderRadius ? borderWidth : undefined,\n // style - extracted to merge with variants\n style,\n ref,\n // rest\n ...props\n}: BoxProps) {\n const { theme, rt } = useUnistyles();\n const {\n BlurView: BlurViewComponent,\n isLoaded: blurIsLoaded,\n isFailed: blurFailed,\n } = useBlurView();\n const elevationAlias = elevation !== undefined ? (`elevation-${elevation}` as const) : undefined;\n\n // Track if blur prop was explicitly set (even to 0) vs derived from elevation\n const blurExplicitlySet = blur !== undefined;\n\n // Get blur intensity from manual blur prop or elevation config\n const blurIntensity = useMemo(() => {\n // Manual blur prop takes precedence (including 0)\n if (blur !== undefined) {\n return blur;\n }\n // Fall back to elevation-based blur\n if (elevation === undefined || !theme.blur) {\n return 0;\n }\n const blurKey = `elevation-${elevation}` as keyof typeof theme.blur;\n return theme.blur[blurKey] ?? 0;\n }, [blur, elevation, theme]);\n\n // Warn in development about blur issues (once per mount)\n const hasWarnedRef = useRef<'none' | 'no-expo-blur' | 'no-blur-target'>('none');\n useEffect(() => {\n if (!__DEV__ || blurIntensity === 0 || !blurIsLoaded) {\n return;\n }\n\n // Warn if expo-blur is not installed\n if (blurFailed && hasWarnedRef.current !== 'no-expo-blur') {\n hasWarnedRef.current = 'no-expo-blur';\n console.warn('[UDS Mobile] Box: Blur effect requested but expo-blur is not installed. ');\n return;\n }\n\n // Warn if blur is used without blurTarget\n if (!blurTarget && hasWarnedRef.current !== 'no-blur-target') {\n hasWarnedRef.current = 'no-blur-target';\n console.warn(\n '[UDS Mobile] Box: Blur effect requires a blurTarget ref. ' +\n 'Wrap the content to blur in <BlurTarget ref={ref}> and pass the ref to blurTarget prop. ' +\n 'See BACKGROUND_BLUR.md for details.',\n );\n }\n }, [blurIntensity, blurTarget, blurIsLoaded, blurFailed]);\n\n const variants = {\n // background\n backgroundColor: backgroundColor ?? elevationAlias,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n // nestedBorderRadius,\n // nestedBorderRadiusSize,\n // nestedBorderRadiusSpacing,\n // nestedBorderRadiusWidth,\n borderColor: borderColor ?? elevationAlias,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth: borderWidth ?? elevationAlias,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // flex\n alignContent,\n alignItems,\n alignSelf,\n flex,\n flexDirection,\n flexGrow,\n flexShrink,\n flexWrap,\n justifyContent,\n // flexBasis,\n // layout\n display,\n overflow,\n // overflowX,\n // overflowY,\n // position,\n // spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n columnGap,\n rowGap,\n // rest\n };\n\n styles.useVariants(variants);\n\n const effectiveDropShadow = dropShadow ?? elevationAlias;\n const shadowStyle =\n effectiveDropShadow || insetShadow\n ? shadowSheet.shadow(effectiveDropShadow, insetShadow)\n : undefined;\n\n // styles.foundation must be in deps - it returns a new reference when variants change\n const boxStyles = useMemo(\n () => [\n dangerouslySetBackgroundColor\n ? { backgroundColor: dangerouslySetBackgroundColor }\n : undefined,\n dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : undefined,\n width ? { width } : undefined,\n height ? { height } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n shadowStyle,\n styles.foundation,\n style,\n ],\n [\n dangerouslySetBackgroundColor,\n dangerouslySetBorderColor,\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n shadowStyle,\n styles.foundation,\n style,\n ],\n );\n\n // Merge variant styles with user-provided style prop\n // User styles come last so they can override variant styles if needed\n\n // If blur is configured (manual or via elevation), render BlurView instead of View\n // Note: On Android, blur requires BlurTarget setup by the developer\n // See BACKGROUND_BLUR.md for Android-specific instructions\n // When blur prop is explicitly set (even to 0), use BlurView so blur=0 is transparent, not solid\n const shouldUseBlurView = BlurViewComponent && (blurIntensity > 0 || blurExplicitlySet);\n if (shouldUseBlurView) {\n const isAndroid = Platform.OS === 'android';\n // Match blur tint to the app's theme (from unistyles runtime)\n const blurTint = rt.themeName === 'dark' ? 'dark' : 'light';\n\n // On iOS, BlurView provides its own frosted background via the tint prop.\n // We must NOT apply an opaque backgroundColor or it will cover the blur effect.\n // On Android, the blur is applied to the blurTarget, so backgroundColor is fine.\n const blurStyles = isAndroid\n ? boxStyles\n : [\n // Exclude backgroundColor for iOS - the blur tint provides the visual background\n dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : undefined,\n width ? { width } : undefined,\n height ? { height } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n shadowStyle,\n // Filter out backgroundColor from foundation styles\n {\n ...styles.foundation,\n backgroundColor: undefined,\n },\n // Also filter backgroundColor from user style if provided (handles both object and array styles)\n style\n ? Array.isArray(style)\n ? style.map((s) =>\n s && typeof s === 'object' ? { ...s, backgroundColor: undefined } : s,\n )\n : typeof style === 'object'\n ? { ...style, backgroundColor: undefined }\n : style\n : undefined,\n ];\n\n // Scale Android intensity to keep tint overlay subtle (Android overlays become\n // too opaque at high intensities). 0.4 scale maps intensity=100 to effective ~40.\n const effectiveIntensity = isAndroid ? Math.min(blurIntensity * 0.4, 40) : blurIntensity;\n\n return (\n <BlurViewComponent\n ref={ref}\n intensity={effectiveIntensity}\n tint={blurTint}\n blurTarget={isAndroid ? blurTarget : undefined}\n blurMethod={isAndroid ? 'dimezisBlurView' : undefined}\n style={blurStyles}\n {...props}\n >\n {props.children}\n </BlurViewComponent>\n );\n }\n\n // Fallback to regular View (blur not available or not requested)\n\n return <View ref={ref} style={boxStyles} {...props} />;\n});\n\nBox.displayName = 'Box';\n\n/**\n * Dynamic shadow stylesheet that merges drop and inset shadows into a single\n * boxShadow CSS string. Theme-reactive so shadows update on color mode change.\n */\nconst shadowSheet = StyleSheet.create((theme) => ({\n shadow: (drop?: string, inset?: string) => {\n const parts = [\n drop ? theme.boxShadow.drop[drop as keyof typeof theme.boxShadow.drop] : '',\n inset ? theme.boxShadow.inset[inset as keyof typeof theme.boxShadow.inset] : '',\n ].filter(Boolean);\n return parts.length > 0 ? { boxShadow: parts.join(', ') } : {};\n },\n}));\n\nexport { Box, type BoxProps };\n"],"mappings":";;;;;;;AAeA,IAAI,WAAsC;AAC1C,IAAI,gBAAiD;AACrD,MAAM,oBAAoC,EAAE;AAG5C,OAAO,aACJ,MAAM,QAAQ;AACb,YAAW,IAAI;AACf,iBAAgB;AAChB,mBAAkB,SAAS,OAAO,IAAI,CAAC;EACvC,CACD,YAAY;AACX,iBAAgB;AAChB,mBAAkB,SAAS,OAAO,IAAI,CAAC;EACvC;;AAGJ,SAAS,cAAc;CACrB,MAAM,GAAG,eAAe,SAAS,EAAE;AAEnC,iBAAgB;AACd,MAAI,kBAAkB,WAAW;GAC/B,MAAM,iBAAiB,aAAa,MAAM,IAAI,EAAE;AAChD,qBAAkB,KAAK,SAAS;AAChC,gBAAa;IACX,MAAM,MAAM,kBAAkB,QAAQ,SAAS;AAC/C,QAAI,OAAO,EACT,mBAAkB,OAAO,KAAK,EAAE;;;IAIrC,EAAE,CAAC;AAEN,QAAO;EAAE;EAAU,UAAU,kBAAkB;EAAW,UAAU,kBAAkB;EAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGlG,MAAM,MAAM,KAAK,SAAS,IAAI,EAE5B,WAEA,iBACA,+BAEA,cACA,sBACA,oBACA,yBACA,uBACA,aACA,2BACA,kBACA,gBACA,gBACA,mBACA,aACA,qBACA,uBACA,kBACA,gBACA,gBACA,mBAEA,cACA,YACA,WACA,MACA,eACA,UACA,YACA,UACA,gBAGA,UAAU,QACV,UAKA,SACA,mBACA,iBACA,eACA,YACA,cACA,YACA,QACA,gBACA,kBACA,cACA,WACA,aACA,WACA,WACA,QAEA,OACA,QACA,UACA,UACA,WACA,WAEA,YACA,aAEA,MACA,YAOA,OACA,KAEA,GAAG,SACQ;CACX,MAAM,EAAE,OAAO,OAAO,cAAc;CACpC,MAAM,EACJ,UAAU,mBACV,UAAU,cACV,UAAU,eACR,aAAa;CACjB,MAAM,iBAAiB,cAAc,KAAA,IAAa,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W,EAChD,SAAS,MAAe,UAAmB;CACzC,MAAM,QAAQ,CACZ,OAAO,MAAM,UAAU,KAAK,QAA6C,IACzE,QAAQ,MAAM,UAAU,MAAM,SAA+C,GAC9E,CAAC,OAAO,QAAQ;AACjB,QAAO,MAAM,SAAS,IAAI,EAAE,WAAW,MAAM,KAAK,KAAK,EAAE,GAAG,EAAE;GAEjE,EAAE"}
1
+ {"version":3,"file":"Box.js","names":["StyleSheet"],"sources":["../../src/components/Box.tsx"],"sourcesContent":["import type { ElevationLevel } from '@yahoo/uds-types';\nimport type { ComponentType, Ref, RefObject } from 'react';\nimport { memo, useEffect, useMemo, useRef, useState } from 'react';\nimport type { ViewProps } from 'react-native';\nimport { Platform, View } from 'react-native';\n// eslint-disable-next-line uds/no-use-unistyles -- blur intensity is not a style property, requires direct theme access\nimport { StyleSheet, useUnistyles } from 'react-native-unistyles';\n\nimport type { StyleProps } from '../../generated/styles';\nimport { styles } from '../../generated/styles';\nimport type { SizeProps } from '../types';\n\n// Optional expo-blur dependency - loaded via dynamic import for Metro compatibility\n// Metro can statically analyze import() and will include expo-blur in the bundle if installed\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet BlurView: ComponentType<any> | null = null;\nlet blurLoadState: 'pending' | 'loaded' | 'failed' = 'pending';\nconst blurLoadListeners: (() => void)[] = [];\n\n// Start loading expo-blur immediately (Metro will bundle it if installed)\nimport('expo-blur')\n .then((mod) => {\n BlurView = mod.BlurView;\n blurLoadState = 'loaded';\n blurLoadListeners.forEach((cb) => cb());\n })\n .catch(() => {\n blurLoadState = 'failed';\n blurLoadListeners.forEach((cb) => cb());\n });\n\n/** Hook to get BlurView component, re-renders when loaded */\nfunction useBlurView() {\n const [, forceUpdate] = useState(0);\n\n useEffect(() => {\n if (blurLoadState === 'pending') {\n const listener = () => forceUpdate((n) => n + 1);\n blurLoadListeners.push(listener);\n return () => {\n const idx = blurLoadListeners.indexOf(listener);\n if (idx >= 0) {\n blurLoadListeners.splice(idx, 1);\n }\n };\n }\n }, []);\n\n return { BlurView, isLoaded: blurLoadState !== 'pending', isFailed: blurLoadState === 'failed' };\n}\n\ninterface BoxProps extends ViewProps, SizeProps {\n ref?: Ref<View>;\n elevation?: ElevationLevel;\n backgroundColor?: StyleProps['backgroundColor'];\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 alignContent?: StyleProps['alignContent'];\n alignItems?: StyleProps['alignItems'];\n alignSelf?: StyleProps['alignSelf'];\n flex?: StyleProps['flex'];\n flexDirection?: StyleProps['flexDirection'];\n flexGrow?: StyleProps['flexGrow'];\n flexShrink?: StyleProps['flexShrink'];\n flexWrap?: StyleProps['flexWrap'];\n justifyContent?: StyleProps['justifyContent'];\n // flexBasis?: StyleProps['flexBasis'];\n display?: StyleProps['display'];\n overflow?: StyleProps['overflow'];\n // overflowX?: StyleProps['overflowX'];\n // overflowY?: StyleProps['overflowY'];\n // position?: StyleProps['position'];\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?: 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 columnGap?: StyleProps['columnGap'];\n rowGap?: StyleProps['rowGap'];\n dropShadow?: StyleProps['dropShadow'];\n insetShadow?: StyleProps['insetShadow'];\n dangerouslySetBackgroundColor?: string;\n dangerouslySetBorderColor?: string;\n /**\n * Manual blur intensity (0-100). When set, renders as a BlurView.\n * Requires `blurTarget` pointing to a BlurTarget ref wrapping the content to blur.\n */\n blur?: number;\n /**\n * Reference to a BlurTarget component wrapping the content to blur.\n * Required when using `blur` prop or elevation with blur configured.\n */\n blurTarget?: RefObject<View | null>;\n}\n\n/**\n * **📦 A layout component that can be used to compose other components**\n *\n * @description\n * The most simple component we ship - a View. But with all the power of the UDS design system.\n * By default, `Box` is a flexbox container. When working with vertical or horizontal layouts,\n * consider using VStack or HStack respectively.\n *\n * @category Layout\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Box } from '@yahoo/uds-mobile/Box';\n *\n * <Box backgroundColor=\"primary\" spacing=\"6\">\n * Any kind of content can go here!\n * </Box>\n * ```\n *\n * @usage\n * - Use as a container to apply padding, shapes, or other styling\n * - Use for creating card components\n * - Use HStack/VStack for directional layouts\n *\n * @see {@link HStack} for horizontal layouts\n * @see {@link VStack} for vertical layouts\n */\nconst Box = memo(function Box({\n // elevation\n elevation,\n // background\n backgroundColor,\n dangerouslySetBackgroundColor,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n borderColor,\n dangerouslySetBorderColor,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // flex\n alignContent,\n alignItems,\n alignSelf,\n flex,\n flexDirection,\n flexGrow,\n flexShrink,\n flexWrap,\n justifyContent,\n // flexBasis,\n // layout\n display = 'flex',\n overflow,\n // overflowX,\n // overflowY,\n // position,\n // spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n columnGap,\n rowGap,\n // size\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n // shadow\n dropShadow,\n insetShadow,\n // blur\n blur,\n blurTarget,\n // // nested border radius\n // nestedBorderRadius,\n // nestedBorderRadiusSize = nestedBorderRadius ? borderRadius : undefined,\n // nestedBorderRadiusSpacing = nestedBorderRadius ? spacing : undefined,\n // nestedBorderRadiusWidth = nestedBorderRadius ? borderWidth : undefined,\n // style - extracted to merge with variants\n style,\n ref,\n // rest\n ...props\n}: BoxProps) {\n const { theme, rt } = useUnistyles();\n const {\n BlurView: BlurViewComponent,\n isLoaded: blurIsLoaded,\n isFailed: blurFailed,\n } = useBlurView();\n const elevationAlias = elevation !== undefined ? (`elevation-${elevation}` as const) : undefined;\n\n // Track if blur prop was explicitly set (even to 0) vs derived from elevation\n const blurExplicitlySet = blur !== undefined;\n\n // Get blur intensity from manual blur prop or elevation config\n const blurIntensity = useMemo(() => {\n // Manual blur prop takes precedence (including 0)\n if (blur !== undefined) {\n return blur;\n }\n // Fall back to elevation-based blur\n if (elevation === undefined || !theme.blur) {\n return 0;\n }\n const blurKey = `elevation-${elevation}` as keyof typeof theme.blur;\n return theme.blur[blurKey] ?? 0;\n }, [blur, elevation, theme]);\n\n // Warn in development about blur issues (once per mount)\n const hasWarnedRef = useRef<'none' | 'no-expo-blur' | 'no-blur-target'>('none');\n useEffect(() => {\n if (!__DEV__ || blurIntensity === 0 || !blurIsLoaded) {\n return;\n }\n\n // Warn if expo-blur is not installed\n if (blurFailed && hasWarnedRef.current !== 'no-expo-blur') {\n hasWarnedRef.current = 'no-expo-blur';\n console.warn('[UDS Mobile] Box: Blur effect requested but expo-blur is not installed. ');\n return;\n }\n\n // Warn if blur is used without blurTarget\n if (!blurTarget && hasWarnedRef.current !== 'no-blur-target') {\n hasWarnedRef.current = 'no-blur-target';\n console.warn(\n '[UDS Mobile] Box: Blur effect requires a blurTarget ref. ' +\n 'Wrap the content to blur in <BlurTarget ref={ref}> and pass the ref to blurTarget prop. ' +\n 'See BACKGROUND_BLUR.md for details.',\n );\n }\n }, [blurIntensity, blurTarget, blurIsLoaded, blurFailed]);\n\n const variants = {\n // background\n backgroundColor: backgroundColor ?? elevationAlias,\n // border\n borderRadius,\n borderTopStartRadius,\n borderTopEndRadius,\n borderBottomStartRadius,\n borderBottomEndRadius,\n // nestedBorderRadius,\n // nestedBorderRadiusSize,\n // nestedBorderRadiusSpacing,\n // nestedBorderRadiusWidth,\n borderColor: borderColor ?? elevationAlias,\n borderStartColor,\n borderEndColor,\n borderTopColor,\n borderBottomColor,\n borderWidth: borderWidth ?? elevationAlias,\n borderVerticalWidth,\n borderHorizontalWidth,\n borderStartWidth,\n borderEndWidth,\n borderTopWidth,\n borderBottomWidth,\n // flex\n alignContent,\n alignItems,\n alignSelf,\n flex,\n flexDirection,\n flexGrow,\n flexShrink,\n flexWrap,\n justifyContent,\n // flexBasis,\n // layout\n display,\n overflow,\n // overflowX,\n // overflowY,\n // position,\n // spacing\n spacing,\n spacingHorizontal,\n spacingVertical,\n spacingBottom,\n spacingEnd,\n spacingStart,\n spacingTop,\n offset,\n offsetVertical,\n offsetHorizontal,\n offsetBottom,\n offsetEnd,\n offsetStart,\n offsetTop,\n columnGap,\n rowGap,\n // rest\n };\n\n styles.useVariants(variants);\n\n const effectiveDropShadow = dropShadow ?? elevationAlias;\n const shadowStyle =\n effectiveDropShadow || insetShadow\n ? shadowSheet.shadow(effectiveDropShadow, insetShadow)\n : undefined;\n\n // styles.foundation must be in deps - it returns a new reference when variants change\n const boxStyles = useMemo(\n () => [\n dangerouslySetBackgroundColor\n ? { backgroundColor: dangerouslySetBackgroundColor }\n : undefined,\n dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : undefined,\n width ? { width } : undefined,\n height ? { height } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n shadowStyle,\n styles.foundation,\n style,\n ],\n [\n dangerouslySetBackgroundColor,\n dangerouslySetBorderColor,\n width,\n height,\n minWidth,\n maxWidth,\n minHeight,\n maxHeight,\n shadowStyle,\n styles.foundation,\n style,\n ],\n );\n\n // Merge variant styles with user-provided style prop\n // User styles come last so they can override variant styles if needed\n\n // If blur is configured (manual or via elevation), render BlurView instead of View\n // Note: On Android, blur requires BlurTarget setup by the developer\n // See BACKGROUND_BLUR.md for Android-specific instructions\n // When blur prop is explicitly set (even to 0), use BlurView so blur=0 is transparent, not solid\n const shouldUseBlurView = BlurViewComponent && (blurIntensity > 0 || blurExplicitlySet);\n if (shouldUseBlurView) {\n const isAndroid = Platform.OS === 'android';\n // Match blur tint to the app's theme (from unistyles runtime)\n const blurTint = rt.themeName === 'dark' ? 'dark' : 'light';\n\n // On iOS, BlurView provides its own frosted background via the tint prop.\n // We must NOT apply an opaque backgroundColor or it will cover the blur effect.\n // On Android, the blur is applied to the blurTarget, so backgroundColor is fine.\n const blurStyles = isAndroid\n ? boxStyles\n : [\n // Exclude backgroundColor for iOS - the blur tint provides the visual background\n dangerouslySetBorderColor ? { borderColor: dangerouslySetBorderColor } : undefined,\n width ? { width } : undefined,\n height ? { height } : undefined,\n minWidth ? { minWidth } : undefined,\n maxWidth ? { maxWidth } : undefined,\n minHeight ? { minHeight } : undefined,\n maxHeight ? { maxHeight } : undefined,\n shadowStyle,\n // Filter out backgroundColor from foundation styles\n {\n ...styles.foundation,\n backgroundColor: undefined,\n },\n // Also filter backgroundColor from user style if provided (handles both object and array styles)\n style\n ? Array.isArray(style)\n ? style.map((s) =>\n s && typeof s === 'object' ? { ...s, backgroundColor: undefined } : s,\n )\n : typeof style === 'object'\n ? { ...style, backgroundColor: undefined }\n : style\n : undefined,\n ];\n\n // Scale Android intensity to keep tint overlay subtle (Android overlays become\n // too opaque at high intensities). 0.4 scale maps intensity=100 to effective ~40.\n const effectiveIntensity = isAndroid ? Math.min(blurIntensity * 0.4, 40) : blurIntensity;\n\n return (\n <BlurViewComponent\n ref={ref}\n intensity={effectiveIntensity}\n tint={blurTint}\n blurTarget={isAndroid ? blurTarget : undefined}\n blurMethod={isAndroid ? 'dimezisBlurView' : undefined}\n style={blurStyles}\n {...props}\n >\n {props.children}\n </BlurViewComponent>\n );\n }\n\n // Fallback to regular View (blur not available or not requested)\n\n return <View ref={ref} style={boxStyles} {...props} />;\n});\n\nBox.displayName = 'Box';\n\n/**\n * Dynamic shadow stylesheet that merges drop and inset shadows into a single\n * boxShadow CSS string. Theme-reactive so shadows update on color mode change.\n */\nconst shadowSheet = StyleSheet.create((theme) => ({\n shadow: (drop?: string, inset?: string) => {\n const parts = [\n drop ? theme.boxShadow.drop[drop as keyof typeof theme.boxShadow.drop] : '',\n inset ? theme.boxShadow.inset[inset as keyof typeof theme.boxShadow.inset] : '',\n ].filter(Boolean);\n return parts.length > 0 ? { boxShadow: parts.join(', ') } : {};\n },\n}));\n\nexport { Box, type BoxProps };\n"],"mappings":";;;;;;;AAeA,IAAI,WAAsC;AAC1C,IAAI,gBAAiD;AACrD,MAAM,oBAAoC,EAAE;AAG5C,OAAO,aACJ,MAAM,QAAQ;CACb,WAAW,IAAI;CACf,gBAAgB;CAChB,kBAAkB,SAAS,OAAO,IAAI,CAAC;EACvC,CACD,YAAY;CACX,gBAAgB;CAChB,kBAAkB,SAAS,OAAO,IAAI,CAAC;EACvC;;AAGJ,SAAS,cAAc;CACrB,MAAM,GAAG,eAAe,SA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4B,EAAE,aAAa,2BAA2B,GAAG,KAAA;GACzE,QAAQ,EAAE,OAAO,GAAG,KAAA;GACpB,SAAS,EAAE,QAAQ,GAAG,KAAA;GACtB,WAAW,EAAE,UAAU,GAAG,KAAA;GAC1B,WAAW,EAAE,UAAU,GAAG,KAAA;GAC1B,YAAY,EAAE,WAAW,GAAG,KAAA;GAC5B,YAAY,EAAE,WAAW,GAAG,KAAA;GAC5B;GAEA;IACE,GAAG,OAAO;IACV,iBAAiB,KAAA;IAClB;GAED,QACI,MAAM,QAAQ,MAAM,GAClB,MAAM,KAAK,MACT,KAAK,OAAO,MAAM,WAAW;IAAE,GAAG;IAAG,iBAAiB,KAAA;IAAW,GAAG,EACrE,GACD,OAAO,UAAU,WACf;IAAE,GAAG;IAAO,iBAAiB,KAAA;IAAW,GACxC,QACJ,KAAA;GACL;EAML,OACE,oBAAC,mBAAD;GACO;GACL,WALuB,YAAY,KAAK,IAAI,gBAAgB,IAAK,GAAG,GAAG;GAMvE,MAAM;GACN,YAAY,YAAY,aAAa,KAAA;GACrC,YAAY,YAAY,oBAAoB,KAAA;GAC5C,OAAO;GACP,GAAI;aAEH,MAAM;GACW,CAAA;;CAMxB,OAAO,oBAAC,MAAD;EAAW;EAAK,OAAO;EAAW,GAAI;EAAS,CAAA;EACtD;AAEF,IAAI,cAAc;;;;;AAMlB,MAAM,cAAcA,aAAW,QAAQ,WAAW,EAChD,SAAS,MAAe,UAAmB;CACzC,MAAM,QAAQ,CACZ,OAAO,MAAM,UAAU,KAAK,QAA6C,IACzE,QAAQ,MAAM,UAAU,MAAM,SAA+C,GAC9E,CAAC,OAAO,QAAQ;CACjB,OAAO,MAAM,SAAS,IAAI,EAAE,WAAW,MAAM,KAAK,KAAK,EAAE,GAAG,EAAE;GAEjE,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"Button.js","names":["Text"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonSize, ButtonVariantFlat, IconSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useMemo, useState } from 'react';\nimport type { View } from 'react-native';\nimport { ActivityIndicator } from 'react-native';\nimport Animated, {\n Easing,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\nimport { useAnimatedTheme } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport type { PressableProps } from './Pressable';\nimport { AnimatedPressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Animation Helpers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Interpolates a boxShadow string by scaling the alpha of all colors.\n * This allows smooth fade-in/out of shadows.\n */\nfunction interpolateShadowAlpha(shadow: string | undefined, alpha: number): string {\n 'worklet';\n if (!shadow) {\n return '';\n }\n if (alpha >= 1) {\n return shadow;\n }\n if (alpha <= 0) {\n return '';\n }\n\n return shadow.replace(/rgba\\(([^,]+),\\s*([^,]+),\\s*([^,]+),\\s*([^)]+)\\)/g, (_, r, g, b, a) => {\n const newAlpha = parseFloat(a) * alpha;\n return `rgba(${r}, ${g}, ${b}, ${newAlpha.toFixed(3)})`;\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* Animated Icon Slot */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Animated wrapper for icon/loading content.\n * Matches web Button icon animation: scale 0.7→1, opacity 0→1, width 0→auto\n * Uses staggered animation: opacity waits until halfway through width animation.\n */\nfunction AnimatedIconSlot({\n children,\n visible,\n iconSize,\n gap,\n}: {\n children: React.ReactNode;\n visible: boolean;\n iconSize: number;\n gap: number;\n}) {\n // Use useDerivedValue instead of useEffect + useSharedValue\n // This is the idiomatic Reanimated pattern for deriving animated values from React state\n const progress = useDerivedValue(\n () => withSpring(visible ? 1 : 0, BUTTON_SPRING_CONFIG),\n [visible],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n // Total width includes icon + gap when visible\n const totalWidth = iconSize + gap;\n const width = interpolate(progress.value, [0, 1], [0, totalWidth]);\n\n // Staggered animation: opacity starts at 50% of width animation\n // On enter: width expands first, then icon fades in\n // On exit: icon fades out first, then width collapses\n const opacity = interpolate(progress.value, [0.5, 1], [0, 1], 'clamp');\n const scale = interpolate(progress.value, [0.5, 1], [0.7, 1], 'clamp');\n\n return {\n width,\n opacity,\n transform: [{ scale }],\n overflow: 'hidden' as const,\n };\n });\n\n return <Animated.View style={animatedStyle}>{children}</Animated.View>;\n}\n\n// function LoadingIcon({ size, variant }: { size: ButtonSize, variant: ButtonVariantFlat }) {\n// const { theme } = useUnistyles();\n// const themeKey = `buttonVariant${variantToCapitalMap[variant]}IconRest` as const;\n// const iconSize = theme.components.buttonSizeLgIconRest.fontSize;\n// return <ActivityIndicator size={iconSize} color={theme.colors.text.primary} />;\n// }\n\n/* -------------------------------------------------------------------------- */\n/* Button Props */\n/* -------------------------------------------------------------------------- */\n\ninterface ButtonProps extends Omit<PressableProps, 'children' | 'disabled'> {\n /** The visual style variant of the button @default 'primary' */\n variant?: ButtonVariantFlat;\n /** The size of the button @default 'md' */\n size?: ButtonSize;\n /** The icon style variant @default 'outline' */\n iconVariant?: IconVariant;\n /** Icon displayed before the button label */\n startIcon?: IconSlotType;\n /** Icon displayed after the button label */\n endIcon?: IconSlotType;\n /** Shows a loading spinner and disables the button */\n loading?: boolean;\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Button label content */\n children?: React.ReactNode;\n /**\n * Disable motion effects (scale on press, icon animations)\n * @default false\n */\n disableEffects?: boolean;\n /** Ref to the underlying View */\n ref?: Ref<View>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Button Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **🖲️ A button element that can be used to trigger an action**\n *\n * @description\n * A button is a fundamental component used to trigger an action or event.\n * Buttons are interactive elements that users can click, tap, or otherwise\n * engage with to submit forms, open dialogues, or perform any other interaction.\n *\n * Features animated scale effect on press and smooth icon transitions matching\n * the web UDS Button behavior.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Button } from '@yahoo/uds-mobile/Button';\n *\n * <Button onPress={() => console.log('pressed')}>Save</Button>\n * <Button variant=\"secondary\">Cancel</Button>\n * <Button startIcon=\"Add\" variant=\"brand\">Add Item</Button>\n * <Button loading>Saving...</Button>\n * ```\n *\n * @accessibility\n * - Sets `accessibilityRole=\"button\"` automatically\n * - Announces loading state to screen readers\n * - Use `accessibilityLabel` for icon-only buttons\n *\n * @see {@link IconButton} for icon-only buttons\n * @see {@link Link} for navigation actions\n */\nconst Button = memo(function Button({\n variant = 'primary',\n size = 'md',\n iconVariant = 'outline',\n startIcon,\n endIcon,\n loading,\n disabled,\n width: _width,\n children,\n style,\n accessibilityLabel,\n accessibilityHint,\n disableEffects = false,\n onPressIn,\n onPressOut,\n ref,\n ...props\n}: ButtonProps) {\n const shouldAnimate = !disableEffects;\n\n /* --------------------------------- State ---------------------------------- */\n const [pressed, setPressed] = useState(false);\n\n buttonStyles.useVariants({ size, variant, disabled, pressed });\n\n // Get gap and icon size from current variant styles\n const buttonGap = buttonStyles.root.gap;\n const iconSize = buttonStyles.icon.fontSize;\n\n // Get animated theme for boxShadow (useAnimatedVariantColor doesn't support non-color props)\n const animatedTheme = useAnimatedTheme();\n\n /* ------------------------------- Animation -------------------------------- */\n const scale = useSharedValue<number>(SCALE_EFFECTS.none);\n\n const handlePressIn = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressIn']>>[0]) => {\n setPressed(true);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.down, BUTTON_SPRING_CONFIG);\n }\n onPressIn?.(event);\n },\n [shouldAnimate, scale, onPressIn],\n );\n\n const handlePressOut = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressOut']>>[0]) => {\n setPressed(false);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG);\n }\n onPressOut?.(event);\n },\n [shouldAnimate, scale, onPressOut],\n );\n\n /* -------------------------------- Content --------------------------------- */\n const childrenNode =\n children &&\n (isValidElement(children) ? (\n children\n ) : (\n <Text numberOfLines={1} textAlign=\"center\" style={buttonStyles.text}>\n {children}\n </Text>\n ));\n\n const a11yState = useMemo(() => ({ disabled, busy: loading }), [disabled, loading]);\n\n /* --------------------------------- Styles --------------------------------- */\n // Animate pressed state for shadow (0 = rest, 1 = pressed)\n const pressProgress = useDerivedValue(\n () => withTiming(pressed ? 1 : 0, { duration: 220, easing: Easing.bezier(0, 0, 0.2, 1) }),\n [pressed],\n );\n\n // Animate using Unistyles' variant color system + boxShadow from theme\n const animatedStyles = useAnimatedStyle(() => {\n // Get boxShadow from theme using flattened path (no camelCase conversion needed!)\n const components = animatedTheme.value.components;\n const buttonVariantPath = `button/variant/${variant}/root/pressed` as const;\n const shadowPressed = components[buttonVariantPath]?.boxShadow;\n\n return {\n transform: [{ scale: scale.value }],\n // Only animate shadow if the theme defines one for this variant\n ...(shadowPressed && {\n boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\n }),\n };\n });\n\n // Determine what should be visible in start slot\n const showLoading = !!loading;\n const showStartIcon = !!startIcon && !loading;\n const showEndIcon = !!endIcon && !loading;\n\n const iconSizeToken = (buttonStyles.icon.iconSizeToken as IconSize) ?? 'sm';\n\n // Start slot: either loading spinner or start icon\n const startContent = (\n <AnimatedIconSlot visible={showLoading || showStartIcon} iconSize={iconSize} gap={buttonGap}>\n {showLoading ? (\n <ActivityIndicator size={buttonStyles.icon.fontSize} color={buttonStyles.icon.color} />\n ) : (\n <IconSlot\n icon={startIcon}\n size={iconSizeToken}\n variant={iconVariant}\n style={buttonStyles.icon}\n />\n )}\n </AnimatedIconSlot>\n );\n\n // End slot: only end icon (no loading here)\n const endContent = (\n <AnimatedIconSlot visible={showEndIcon} iconSize={iconSize} gap={buttonGap}>\n <IconSlot\n icon={endIcon}\n size={iconSizeToken}\n variant={iconVariant}\n style={buttonStyles.icon}\n />\n </AnimatedIconSlot>\n );\n\n const rootStyles = useMemo(\n () => [\n buttonStyles.root,\n animatedStyles,\n typeof style === 'function' ? style({ pressed }) : style,\n ],\n [buttonStyles.root, animatedStyles, style, pressed],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <AnimatedPressable\n ref={ref}\n disabled={disabled}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n overflow=\"hidden\"\n accessibilityLabel={loading ? `${accessibilityLabel ?? ''}, loading` : accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole=\"button\"\n accessibilityState={a11yState}\n alignContent=\"center\"\n style={rootStyles}\n {...props}\n >\n {startContent}\n {childrenNode}\n {endContent}\n </AnimatedPressable>\n );\n});\n\nButton.displayName = 'Button';\n\nexport { Button, type ButtonProps };\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAS,uBAAuB,QAA4B,OAAuB;AACjF;AACA,KAAI,CAAC,OACH,QAAO;AAET,KAAI,SAAS,EACX,QAAO;AAET,KAAI,SAAS,EACX,QAAO;AAGT,QAAO,OAAO,QAAQ,sDAAsD,GAAG,GAAG,GAAG,GAAG,MAAM;AAE5F,SAAO,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KADZ,WAAW,EAAE,GAAG,OACS,QAAQ,EAAE,CAAC;GACrD;;;;;;;AAYJ,SAAS,iBAAiB,EACxB,UACA,SACA,UACA,OAMC;CAGD,MAAM,WAAW,sBACT,WAAW,UAAU,IAAI,GAAG,qBAAqB,EACvD,CAAC,QAAQ,CACV;CAED,MAAM,gBAAgB,uBAAuB;EAE3C,MAAM,aAAa,WAAW;AAS9B,SAAO;GACL,OATY,YAAY,SAAS,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,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;EACf,UAAS;EACT,oBAAoB,UAAU,GAAG,sBAAsB,GAAG,aAAa;EACpD;EACnB,mBAAkB;EAClB,oBAAoB;EACpB,cAAa;EACb,OAAO;EACP,GAAI;YAfN;GAiBG;GACA;GACA;GACiB;;EAEtB;AAEF,OAAO,cAAc"}
1
+ {"version":3,"file":"Button.js","names":["Text"],"sources":["../../src/components/Button.tsx"],"sourcesContent":["import type { ButtonSize, ButtonVariantFlat, IconSize, IconVariant } from '@yahoo/uds-types';\nimport type { Ref } from 'react';\nimport { isValidElement, memo, useCallback, useMemo, useState } from 'react';\nimport type { View } from 'react-native';\nimport { ActivityIndicator } from 'react-native';\nimport Animated, {\n Easing,\n interpolate,\n useAnimatedStyle,\n useDerivedValue,\n useSharedValue,\n withSpring,\n withTiming,\n} from 'react-native-reanimated';\nimport { useAnimatedTheme } from 'react-native-unistyles/reanimated';\n\nimport { buttonStyles } from '../../generated/styles';\nimport { BUTTON_SPRING_CONFIG, SCALE_EFFECTS } from '../motion';\nimport type { IconSlotType } from './IconSlot';\nimport { IconSlot } from './IconSlot';\nimport type { PressableProps } from './Pressable';\nimport { AnimatedPressable } from './Pressable';\nimport { Text } from './Text';\n\n/* -------------------------------------------------------------------------- */\n/* Animation Helpers */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Interpolates a boxShadow string by scaling the alpha of all colors.\n * This allows smooth fade-in/out of shadows.\n */\nfunction interpolateShadowAlpha(shadow: string | undefined, alpha: number): string {\n 'worklet';\n if (!shadow) {\n return '';\n }\n if (alpha >= 1) {\n return shadow;\n }\n if (alpha <= 0) {\n return '';\n }\n\n return shadow.replace(/rgba\\(([^,]+),\\s*([^,]+),\\s*([^,]+),\\s*([^)]+)\\)/g, (_, r, g, b, a) => {\n const newAlpha = parseFloat(a) * alpha;\n return `rgba(${r}, ${g}, ${b}, ${newAlpha.toFixed(3)})`;\n });\n}\n\n/* -------------------------------------------------------------------------- */\n/* Animated Icon Slot */\n/* -------------------------------------------------------------------------- */\n\n/**\n * Animated wrapper for icon/loading content.\n * Matches web Button icon animation: scale 0.7→1, opacity 0→1, width 0→auto\n * Uses staggered animation: opacity waits until halfway through width animation.\n */\nfunction AnimatedIconSlot({\n children,\n visible,\n iconSize,\n gap,\n}: {\n children: React.ReactNode;\n visible: boolean;\n iconSize: number;\n gap: number;\n}) {\n // Use useDerivedValue instead of useEffect + useSharedValue\n // This is the idiomatic Reanimated pattern for deriving animated values from React state\n const progress = useDerivedValue(\n () => withSpring(visible ? 1 : 0, BUTTON_SPRING_CONFIG),\n [visible],\n );\n\n const animatedStyle = useAnimatedStyle(() => {\n // Total width includes icon + gap when visible\n const totalWidth = iconSize + gap;\n const width = interpolate(progress.value, [0, 1], [0, totalWidth]);\n\n // Staggered animation: opacity starts at 50% of width animation\n // On enter: width expands first, then icon fades in\n // On exit: icon fades out first, then width collapses\n const opacity = interpolate(progress.value, [0.5, 1], [0, 1], 'clamp');\n const scale = interpolate(progress.value, [0.5, 1], [0.7, 1], 'clamp');\n\n return {\n width,\n opacity,\n transform: [{ scale }],\n overflow: 'hidden' as const,\n };\n });\n\n return <Animated.View style={animatedStyle}>{children}</Animated.View>;\n}\n\n// function LoadingIcon({ size, variant }: { size: ButtonSize, variant: ButtonVariantFlat }) {\n// const { theme } = useUnistyles();\n// const themeKey = `buttonVariant${variantToCapitalMap[variant]}IconRest` as const;\n// const iconSize = theme.components.buttonSizeLgIconRest.fontSize;\n// return <ActivityIndicator size={iconSize} color={theme.colors.text.primary} />;\n// }\n\n/* -------------------------------------------------------------------------- */\n/* Button Props */\n/* -------------------------------------------------------------------------- */\n\ninterface ButtonProps extends Omit<PressableProps, 'children' | 'disabled'> {\n /** The visual style variant of the button @default 'primary' */\n variant?: ButtonVariantFlat;\n /** The size of the button @default 'md' */\n size?: ButtonSize;\n /** The icon style variant @default 'outline' */\n iconVariant?: IconVariant;\n /** Icon displayed before the button label */\n startIcon?: IconSlotType;\n /** Icon displayed after the button label */\n endIcon?: IconSlotType;\n /** Shows a loading spinner and disables the button */\n loading?: boolean;\n /** Whether the button is disabled */\n disabled?: boolean;\n /** Button label content */\n children?: React.ReactNode;\n /**\n * Disable motion effects (scale on press, icon animations)\n * @default false\n */\n disableEffects?: boolean;\n /** Ref to the underlying View */\n ref?: Ref<View>;\n}\n\n/* -------------------------------------------------------------------------- */\n/* Button Component */\n/* -------------------------------------------------------------------------- */\n\n/**\n * **🖲️ A button element that can be used to trigger an action**\n *\n * @description\n * A button is a fundamental component used to trigger an action or event.\n * Buttons are interactive elements that users can click, tap, or otherwise\n * engage with to submit forms, open dialogues, or perform any other interaction.\n *\n * Features animated scale effect on press and smooth icon transitions matching\n * the web UDS Button behavior.\n *\n * @category Interactive\n * @platform mobile\n *\n * @example\n * ```tsx\n * import { Button } from '@yahoo/uds-mobile/Button';\n *\n * <Button onPress={() => console.log('pressed')}>Save</Button>\n * <Button variant=\"secondary\">Cancel</Button>\n * <Button startIcon=\"Add\" variant=\"brand\">Add Item</Button>\n * <Button loading>Saving...</Button>\n * ```\n *\n * @accessibility\n * - Sets `accessibilityRole=\"button\"` automatically\n * - Announces loading state to screen readers\n * - Use `accessibilityLabel` for icon-only buttons\n *\n * @see {@link IconButton} for icon-only buttons\n * @see {@link Link} for navigation actions\n */\nconst Button = memo(function Button({\n variant = 'primary',\n size = 'md',\n iconVariant = 'outline',\n startIcon,\n endIcon,\n loading,\n disabled,\n width: _width,\n children,\n style,\n accessibilityLabel,\n accessibilityHint,\n disableEffects = false,\n onPressIn,\n onPressOut,\n ref,\n ...props\n}: ButtonProps) {\n const shouldAnimate = !disableEffects;\n\n /* --------------------------------- State ---------------------------------- */\n const [pressed, setPressed] = useState(false);\n\n buttonStyles.useVariants({ size, variant, disabled, pressed });\n\n // Get gap and icon size from current variant styles\n const buttonGap = buttonStyles.root.gap;\n const iconSize = buttonStyles.icon.fontSize;\n\n // Get animated theme for boxShadow (useAnimatedVariantColor doesn't support non-color props)\n const animatedTheme = useAnimatedTheme();\n\n /* ------------------------------- Animation -------------------------------- */\n const scale = useSharedValue<number>(SCALE_EFFECTS.none);\n\n const handlePressIn = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressIn']>>[0]) => {\n setPressed(true);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.down, BUTTON_SPRING_CONFIG);\n }\n onPressIn?.(event);\n },\n [shouldAnimate, scale, onPressIn],\n );\n\n const handlePressOut = useCallback(\n (event: Parameters<NonNullable<PressableProps['onPressOut']>>[0]) => {\n setPressed(false);\n if (shouldAnimate) {\n scale.value = withSpring(SCALE_EFFECTS.none, BUTTON_SPRING_CONFIG);\n }\n onPressOut?.(event);\n },\n [shouldAnimate, scale, onPressOut],\n );\n\n /* -------------------------------- Content --------------------------------- */\n const childrenNode =\n children &&\n (isValidElement(children) ? (\n children\n ) : (\n <Text numberOfLines={1} textAlign=\"center\" style={buttonStyles.text}>\n {children}\n </Text>\n ));\n\n const a11yState = useMemo(() => ({ disabled, busy: loading }), [disabled, loading]);\n\n /* --------------------------------- Styles --------------------------------- */\n // Animate pressed state for shadow (0 = rest, 1 = pressed)\n const pressProgress = useDerivedValue(\n () => withTiming(pressed ? 1 : 0, { duration: 220, easing: Easing.bezier(0, 0, 0.2, 1) }),\n [pressed],\n );\n\n // Animate using Unistyles' variant color system + boxShadow from theme\n const animatedStyles = useAnimatedStyle(() => {\n // Get boxShadow from theme using flattened path (no camelCase conversion needed!)\n const components = animatedTheme.value.components;\n const buttonVariantPath = `button/variant/${variant}/root/pressed` as const;\n const shadowPressed = components[buttonVariantPath]?.boxShadow;\n\n return {\n transform: [{ scale: scale.value }],\n // Only animate shadow if the theme defines one for this variant\n ...(shadowPressed && {\n boxShadow: interpolateShadowAlpha(shadowPressed, pressProgress.value),\n }),\n };\n });\n\n // Determine what should be visible in start slot\n const showLoading = !!loading;\n const showStartIcon = !!startIcon && !loading;\n const showEndIcon = !!endIcon && !loading;\n\n const iconSizeToken = (buttonStyles.icon.iconSizeToken as IconSize) ?? 'sm';\n\n // Start slot: either loading spinner or start icon\n const startContent = (\n <AnimatedIconSlot visible={showLoading || showStartIcon} iconSize={iconSize} gap={buttonGap}>\n {showLoading ? (\n <ActivityIndicator size={buttonStyles.icon.fontSize} color={buttonStyles.icon.color} />\n ) : (\n <IconSlot\n icon={startIcon}\n size={iconSizeToken}\n variant={iconVariant}\n style={buttonStyles.icon}\n />\n )}\n </AnimatedIconSlot>\n );\n\n // End slot: only end icon (no loading here)\n const endContent = (\n <AnimatedIconSlot visible={showEndIcon} iconSize={iconSize} gap={buttonGap}>\n <IconSlot\n icon={endIcon}\n size={iconSizeToken}\n variant={iconVariant}\n style={buttonStyles.icon}\n />\n </AnimatedIconSlot>\n );\n\n const rootStyles = useMemo(\n () => [\n buttonStyles.root,\n animatedStyles,\n typeof style === 'function' ? style({ pressed }) : style,\n ],\n [buttonStyles.root, animatedStyles, style, pressed],\n );\n\n /* --------------------------------- Render --------------------------------- */\n return (\n <AnimatedPressable\n ref={ref}\n disabled={disabled}\n onPressIn={handlePressIn}\n onPressOut={handlePressOut}\n flexDirection=\"row\"\n alignItems=\"center\"\n justifyContent=\"center\"\n overflow=\"hidden\"\n accessibilityLabel={loading ? `${accessibilityLabel ?? ''}, loading` : accessibilityLabel}\n accessibilityHint={accessibilityHint}\n accessibilityRole=\"button\"\n accessibilityState={a11yState}\n alignContent=\"center\"\n style={rootStyles}\n {...props}\n >\n {startContent}\n {childrenNode}\n {endContent}\n </AnimatedPressable>\n );\n});\n\nButton.displayName = 'Button';\n\nexport { Button, type ButtonProps };\n"],"mappings":";;;;;;;;;;;;;;;;;AAgCA,SAAS,uBAAuB,QAA4B,OAAuB;AACjF;CACA,IAAI,CAAC,QACH,OAAO;CAET,IAAI,SAAS,GACX,OAAO;CAET,IAAI,SAAS,GACX,OAAO;CAGT,OAAO,OAAO,QAAQ,sDAAsD,GAAG,GAAG,GAAG,GAAG,MAAM;EAE5F,OAAO,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KADZ,WAAW,EAAE,GAAG,O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AAM;GACN,SAAS;GACT,OAAO,aAAa;GACpB,CAAA;EACe,CAAA;CAGrB,MAAM,aAAa,cACX;EACJ,aAAa;EACb;EACA,OAAO,UAAU,aAAa,MAAM,EAAE,SAAS,CAAC,GAAG;EACpD,EACD;EAAC,aAAa;EAAM;EAAgB;EAAO;EAAQ,CACpD;CAGD,OACE,qBAAC,mBAAD;EACO;EACK;EACV,WAAW;EACX,YAAY;EACZ,eAAc;EACd,YAAW;EACX,gBAAe;EACf,UAAS;EACT,oBAAoB,UAAU,GAAG,sBAAsB,GAAG,aAAa;EACpD;EACnB,mBAAkB;EAClB,oBAAoB;EACpB,cAAa;EACb,OAAO;EACP,GAAI;YAfN;GAiBG;GACA;GACA;GACiB;;EAEtB;AAEF,OAAO,cAAc"}
@@ -4,9 +4,8 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
4
4
  const require_index = require("../motion-tokens/dist/index.cjs");
5
5
  const require_motion = require("../motion.cjs");
6
6
  const require_components_Icon = require("./Icon.cjs");
7
- const require_components_Text = require("./Text.cjs");
8
- const require_components_HStack = require("./HStack.cjs");
9
7
  const require_components_Pressable = require("./Pressable.cjs");
8
+ const require_components_FormLabel = require("./FormLabel.cjs");
10
9
  let react = require("react");
11
10
  let react_jsx_runtime = require("react/jsx-runtime");
12
11
  let generated_styles = require("../../generated/styles");
@@ -103,23 +102,19 @@ const Checkbox = (0, react.memo)(function Checkbox({ label, labelPosition = "sta
103
102
  ], [generated_styles.checkboxStyles.checkbox, checkboxAnimatedStyle]);
104
103
  const labelContent = (0, react.useMemo)(() => {
105
104
  if (!label) return null;
106
- const content = typeof label === "function" ? label() : (0, react.isValidElement)(label) ? label : String(label);
107
- const textContent = typeof content === "string" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
108
- style: generated_styles.checkboxStyles.text,
109
- children: content
110
- }) : content;
111
- if (required) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_components_HStack.HStack, {
112
- columnGap: "1",
113
- alignItems: "flex-start",
114
- children: [textContent, /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_Text.Text, {
115
- style: generated_styles.checkboxStyles.text,
116
- children: "*"
117
- })]
105
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_components_FormLabel.FormLabel, {
106
+ color: "inherit",
107
+ variant: "inherit",
108
+ label,
109
+ required,
110
+ showRequiredAsterisk: required,
111
+ hasError,
112
+ style: generated_styles.checkboxStyles.text
118
113
  });
119
- return textContent;
120
114
  }, [
121
115
  label,
122
116
  required,
117
+ hasError,
123
118
  generated_styles.checkboxStyles.text
124
119
  ]);
125
120
  const a11yState = (0, react.useMemo)(() => ({
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.cts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAoBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;EAU9B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,OAAA,CAAA,oBAAA,CAAA,aAAA"}
1
+ {"version":3,"file":"Checkbox.d.cts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAmBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;EAU9B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,OAAA,CAAA,oBAAA,CAAA,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAoBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;EAU9B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,OAAA,CAAA,oBAAA,CAAA,aAAA"}
1
+ {"version":3,"file":"Checkbox.d.ts","names":[],"sources":["../../src/components/Checkbox.tsx"],"mappings":";;;;;;;UAmBU,aAAA,SAAsB,IAAA,CAAK,SAAA,YAAqB,sBAAA;;EAExD,GAAA,GAAM,GAAA,CAAI,IAAA;EAFF;EAIR,cAAA;;EAEA,QAAA;EAJU;EAMV,QAAA;EAR8B;EAU9B,QAAA,IAAY,OAAA;AAAA;;;;;;;;;;;;;;;AAAgB;;;;;;;;;;;;;;;;;;;;cAqDxB,QAAA,EAAQ,OAAA,CAAA,oBAAA,CAAA,aAAA"}
@@ -2,10 +2,9 @@
2
2
  import { SCALE_EFFECTS } from "../motion-tokens/dist/index.js";
3
3
  import { BUTTON_SPRING_CONFIG } from "../motion.js";
4
4
  import { Icon } from "./Icon.js";
5
- import { Text } from "./Text.js";
6
- import { HStack } from "./HStack.js";
7
5
  import { Pressable } from "./Pressable.js";
8
- import { isValidElement, memo, useCallback, useId, useMemo, useState } from "react";
6
+ import { FormLabel } from "./FormLabel.js";
7
+ import { memo, useCallback, useId, useMemo, useState } from "react";
9
8
  import { jsx, jsxs } from "react/jsx-runtime";
10
9
  import { checkboxStyles } from "../../generated/styles";
11
10
  import Animated, { useAnimatedStyle, useDerivedValue, withSpring } from "react-native-reanimated";
@@ -100,23 +99,19 @@ const Checkbox = memo(function Checkbox({ label, labelPosition = "start", varian
100
99
  ], [checkboxStyles.checkbox, checkboxAnimatedStyle]);
101
100
  const labelContent = useMemo(() => {
102
101
  if (!label) return null;
103
- const content = typeof label === "function" ? label() : isValidElement(label) ? label : String(label);
104
- const textContent = typeof content === "string" ? /* @__PURE__ */ jsx(Text, {
105
- style: checkboxStyles.text,
106
- children: content
107
- }) : content;
108
- if (required) return /* @__PURE__ */ jsxs(HStack, {
109
- columnGap: "1",
110
- alignItems: "flex-start",
111
- children: [textContent, /* @__PURE__ */ jsx(Text, {
112
- style: checkboxStyles.text,
113
- children: "*"
114
- })]
102
+ return /* @__PURE__ */ jsx(FormLabel, {
103
+ color: "inherit",
104
+ variant: "inherit",
105
+ label,
106
+ required,
107
+ showRequiredAsterisk: required,
108
+ hasError,
109
+ style: checkboxStyles.text
115
110
  });
116
- return textContent;
117
111
  }, [
118
112
  label,
119
113
  required,
114
+ hasError,
120
115
  checkboxStyles.text
121
116
  ]);
122
117
  const a11yState = useMemo(() => ({
@@ -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/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":";;;;;;;;;;;;AAwCA,MAAM,oBAAmE;CACvE,SAAS;CACT,WAAW;CACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCD,MAAM,WAAW,KAAK,SAAS,SAAS,EAEtC,OAC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C,eAAe,MAAM,SAAS,CAChC;CAED,MAAM,mBAAmB,cACjB;EACJ,eAAe;EACf;GAAE,YAAY;GAAmB,gBAAgB;GAAmB,cAAc;GAAG;EACrF;EACD,EACD,CAAC,eAAe,UAAU,sBAAsB,CACjD;CAGD,MAAM,eAAe,cAAc;AACjC,MAAI,CAAC,MACH,QAAO;EAGT,MAAM,UACJ,OAAO,UAAU,aAAa,OAAO,GAAG,eAAe,MAAM,GAAG,QAAQ,OAAO,MAAM;EAEvF,MAAM,cACJ,OAAO,YAAY,WAAW,oBAAC,MAAD;GAAM,OAAO,eAAe;aAAO;GAAe,CAAA,GAAG;AAErF,MAAI,SACF,QACE,qBAAC,QAAD;GAAQ,WAAU;GAAI,YAAW;aAAjC,CACG,aACD,oBAAC,MAAD;IAAM,OAAO,eAAe;cAAM;IAAQ,CAAA,CACnC;;AAIb,SAAO;IACN;EAAC;EAAO;EAAU,eAAe;EAAK,CAAC;CAE1C,MAAM,YAAY,eACT;EACL;EACA,SACE,eAAe,YACX,OACA,eAAe,kBACZ,UACD;EACT,GACD,CAAC,UAAU,WAAW,CACvB;AAGD,QACE,qBAAC,WAAD;EACO;EACL,UAAU;EACV,SAAS;EACT,WAAW;EACX,YAAY;EACF;EACV,eAAe,kBAAkB,UAAU,QAAQ;EACnD,YAAW;EACX,WAAU;EACV,mBAAkB;EAClB,oBAAoB;EACpB,oBAAoB,OAAO,UAAU,WAAW,QAAQ,KAAA;EACxD,GAAI;EACJ,OAAO;YAdT,CAgBE,oBAAC,SAAS,MAAV;GAAe,OAAO;aACnB,YAAY,oBAAC,MAAD;IAAM,MAAM;IAAU,MAAK;IAAK,OAAO,eAAe;IAAgB,CAAA;GACrE,CAAA,EAEf,aACS;;EAEd;AAEF,SAAS,cAAc"}
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 { 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 { FormLabel } from './FormLabel';\nimport { Icon } from './Icon';\nimport { Pressable } from './Pressable';\n\n/* -------------------------------------------------------------------------- */\n/* Types */\n/* -------------------------------------------------------------------------- */\n\n/** Derived from CheckboxValue - maps boolean to 'checked'/'unchecked' string literals */\ntype CheckboxValueState = Exclude<CheckboxValue, boolean> | 'checked' | 'unchecked';\n\ninterface CheckboxProps extends Omit<ViewProps, 'style'>, UniversalCheckboxProps {\n /** Ref to the underlying View */\n ref?: Ref<View>;\n /** Default checked state for uncontrolled mode */\n defaultChecked?: boolean;\n /** Whether the checkbox is disabled */\n disabled?: boolean;\n /** Whether the checkbox is required */\n required?: boolean;\n /** 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 return (\n <FormLabel\n color=\"inherit\"\n variant=\"inherit\"\n label={label}\n required={required}\n showRequiredAsterisk={required}\n hasError={hasError}\n style={checkboxStyles.text}\n />\n );\n }, [label, required, hasError, 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":";;;;;;;;;;;AAuCA,MAAM,oBAAmE;CACvE,SAAS;CACT,WAAW;CACZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCD,MAAM,WAAW,KAAK,SAAS,SAAS,EAEtC,OACA,gBAAgB,SAChB,SAAS,cAAc,WACvB,OAAO,MACP,SAAS,aACT,UACA,cAEA,gBACA,UACA,UACA,UACA,KACA,GAAG,aACa;CAEhB,MAAM,MAAM,gBADQ,OACmB;CAGvC,MAAM,eAAe,gBAAgB,KAAA;CACrC,MAAM,CAAC,iBAAiB,sBAAsB,SAC5C,eAAe,cAAe,kBAAkB,MACjD;CACD,MAAM,CAAC,SAAS,cAAc,SAAS,MAAM;CAG7C,MAAM,UAAU,eAAe,cAAc;CAG7C,MAAM,aAAiC,cAAc;EACnD,IAAI,YAAY,iBACd,OAAO;EAET,OAAO,UAAU,YAAY;IAC5B,CAAC,QAAQ,CAAC;CAEb,MAAM,WAAW,eAAe,kBAAkB,UAAU;CAC5D,MAAM,WAAW,eAAe;CAGhC,MAAM,gBAAgB,CAAC;CAGvB,MAAM,gBAAgB,sBAElB,gBACI,WAAW,UAAU,cAAc,OAAO,cAAc,MAAM,qBAAqB,GACnF,cAAc,MACpB,CAAC,SAAS,cAAc,CACzB;CAED,MAAM,wBAAwB,wBAAwB,EACpD,WAAW,CAAC,EAAE,OAAO,cAAc,OAAO,CAAC,EAC5C,EAAE;CAGH,MAAM,cAAc,kBAAkB;EACpC,IAAI,UACF;EAGF,M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AAD;IAAM,MAAM;IAAU,MAAK;IAAK,OAAO,eAAe;IAAgB,CAAA;GACrE,CAAA,EAEf,aACS;;EAEd;AAEF,SAAS,cAAc"}
@@ -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/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,MA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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;CAKvC,WAAW,YAAY;EACrB;EACA,MAAM;EACN,aAAa;EACb,QAAQ;EACT,CAAC;CAEF,MAAM,cAAc,kBAAkB;EACpC,IAAI,YACF;EAGF,IAAI,UACF,SAAS,CAAC,UAAU;OACf,IAAI,SACT,SAAS;IAEV;EAAC;EAAY;EAAU;EAAW;EAAQ,CAAC;CAE9C,MAAM,gBAAgB,kBAAkB;EACtC,IAAI,YACF;EAEF,aAAa;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;CAGD,IAAI,eACF,OACE,oBAAC,WAAD;EACE,SAAS;EACT,mBAAmB,WAAW,aAAa;EAC3C,GAAI;YAEH;EACS,CAAA;CAKhB,OACE,oBAAC,QAAD;EAAQ,mBAAmB,gBAAgB,WAAW,KAAA;EAAW,GAAI;EAAa,GAAI;YACnF;EACM,CAAA;EAEX;AAEF,KAAK,cAAc"}
@@ -1 +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"}
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;CACf,cAAc,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;CAED,IAAI,UAGF,OACE,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;CAIxB,OACE,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"}
@@ -1 +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"}
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;CAE/B,cAAc,YAAY,EAAE,SAAS,CAAC;CAEtC,MAAM,aAAa,cACX;EAAC,EAAE,YAAY,GAAG;EAAE,cAAc;EAAO;EAAM,EACrD,CAAC,cAAc,OAAO,MAAM,CAC7B;CAED,OACE,oBAAC,MAAD;EAAW;EAAK,OAAM;EAAU,SAAQ;EAAS,GAAI;EAAW,OAAO;EACpE;EACI,CAAA;EAET;AAEF,aAAa,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"DividerLine.js","names":[],"sources":["../../../src/components/Divider/DividerLine.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native';\n\nimport { dividerStyles } from '../../../generated/styles';\nimport { Box } from '../Box';\nimport type { DividerLineProps } from './types';\n\n/**\n * **The configured line element used by Divider.**\n *\n * @description\n * DividerLine can be used inside Divider for custom composition, or directly\n * inside HStack/VStack when a fully manual layout is easier.\n *\n * @category Layout\n * @platform mobile\n */\nconst DividerLine = memo(function DividerLine({\n variant: variantProp,\n vertical: verticalProp,\n style,\n ref,\n ...boxProps\n}: DividerLineProps) {\n const variant = variantProp ?? 'primary';\n const vertical = verticalProp ?? false;\n\n dividerStyles.useVariants({ variant });\n\n const lineTokens = StyleSheet.flatten(dividerStyles.line) as {\n borderColor?: string;\n borderWidth?: number;\n };\n const lineWidth = lineTokens.borderWidth || StyleSheet.hairlineWidth;\n\n const lineStyle: StyleProp<ViewStyle> = useMemo(\n () => [\n {\n backgroundColor: lineTokens.borderColor,\n borderWidth: 0,\n },\n vertical ? { height: '100%', width: lineWidth } : { height: lineWidth, width: '100%' },\n style,\n ],\n [lineTokens.borderColor, lineWidth, vertical, style],\n );\n\n return (\n <Box\n ref={ref}\n alignItems=\"center\"\n flex=\"1\"\n justifyContent=\"center\"\n minHeight={vertical ? 1 : lineWidth}\n minWidth={vertical ? lineWidth : 1}\n pointerEvents=\"none\"\n {...boxProps}\n >\n <Box pointerEvents=\"none\" style={lineStyle} />\n </Box>\n );\n});\n\nDividerLine.displayName = 'DividerLine';\n\nexport { DividerLine };\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,SAAS,YAAY,EAC5C,SAAS,aACT,UAAU,cACV,OACA,KACA,GAAG,YACgB;CACnB,MAAM,UAAU,eAAe;CAC/B,MAAM,WAAW,gBAAgB;AAEjC,eAAc,YAAY,EAAE,SAAS,CAAC;CAEtC,MAAM,aAAa,WAAW,QAAQ,cAAc,KAAK;CAIzD,MAAM,YAAY,WAAW,eAAe,WAAW;CAEvD,MAAM,YAAkC,cAChC;EACJ;GACE,iBAAiB,WAAW;GAC5B,aAAa;GACd;EACD,WAAW;GAAE,QAAQ;GAAQ,OAAO;GAAW,GAAG;GAAE,QAAQ;GAAW,OAAO;GAAQ;EACtF;EACD,EACD;EAAC,WAAW;EAAa;EAAW;EAAU;EAAM,CACrD;AAED,QACE,oBAAC,KAAD;EACO;EACL,YAAW;EACX,MAAK;EACL,gBAAe;EACf,WAAW,WAAW,IAAI;EAC1B,UAAU,WAAW,YAAY;EACjC,eAAc;EACd,GAAI;YAEJ,oBAAC,KAAD;GAAK,eAAc;GAAO,OAAO;GAAa,CAAA;EAC1C,CAAA;EAER;AAEF,YAAY,cAAc"}
1
+ {"version":3,"file":"DividerLine.js","names":[],"sources":["../../../src/components/Divider/DividerLine.tsx"],"sourcesContent":["import { memo, useMemo } from 'react';\nimport type { StyleProp, ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native';\n\nimport { dividerStyles } from '../../../generated/styles';\nimport { Box } from '../Box';\nimport type { DividerLineProps } from './types';\n\n/**\n * **The configured line element used by Divider.**\n *\n * @description\n * DividerLine can be used inside Divider for custom composition, or directly\n * inside HStack/VStack when a fully manual layout is easier.\n *\n * @category Layout\n * @platform mobile\n */\nconst DividerLine = memo(function DividerLine({\n variant: variantProp,\n vertical: verticalProp,\n style,\n ref,\n ...boxProps\n}: DividerLineProps) {\n const variant = variantProp ?? 'primary';\n const vertical = verticalProp ?? false;\n\n dividerStyles.useVariants({ variant });\n\n const lineTokens = StyleSheet.flatten(dividerStyles.line) as {\n borderColor?: string;\n borderWidth?: number;\n };\n const lineWidth = lineTokens.borderWidth || StyleSheet.hairlineWidth;\n\n const lineStyle: StyleProp<ViewStyle> = useMemo(\n () => [\n {\n backgroundColor: lineTokens.borderColor,\n borderWidth: 0,\n },\n vertical ? { height: '100%', width: lineWidth } : { height: lineWidth, width: '100%' },\n style,\n ],\n [lineTokens.borderColor, lineWidth, vertical, style],\n );\n\n return (\n <Box\n ref={ref}\n alignItems=\"center\"\n flex=\"1\"\n justifyContent=\"center\"\n minHeight={vertical ? 1 : lineWidth}\n minWidth={vertical ? lineWidth : 1}\n pointerEvents=\"none\"\n {...boxProps}\n >\n <Box pointerEvents=\"none\" style={lineStyle} />\n </Box>\n );\n});\n\nDividerLine.displayName = 'DividerLine';\n\nexport { DividerLine };\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,SAAS,YAAY,EAC5C,SAAS,aACT,UAAU,cACV,OACA,KACA,GAAG,YACgB;CACnB,MAAM,UAAU,eAAe;CAC/B,MAAM,WAAW,gBAAgB;CAEjC,cAAc,YAAY,EAAE,SAAS,CAAC;CAEtC,MAAM,aAAa,WAAW,QAAQ,cAAc,KAAK;CAIzD,MAAM,YAAY,WAAW,eAAe,WAAW;CAEvD,MAAM,YAAkC,cAChC;EACJ;GACE,iBAAiB,WAAW;GAC5B,aAAa;GACd;EACD,WAAW;GAAE,QAAQ;GAAQ,OAAO;GAAW,GAAG;GAAE,QAAQ;GAAW,OAAO;GAAQ;EACtF;EACD,EACD;EAAC,WAAW;EAAa;EAAW;EAAU;EAAM,CACrD;CAED,OACE,oBAAC,KAAD;EACO;EACL,YAAW;EACX,MAAK;EACL,gBAAe;EACf,WAAW,WAAW,IAAI;EAC1B,UAAU,WAAW,YAAY;EACjC,eAAc;EACd,GAAI;YAEJ,oBAAC,KAAD;GAAK,eAAc;GAAO,OAAO;GAAa,CAAA;EAC1C,CAAA;EAER;AAEF,YAAY,cAAc"}