@cdx-ui/components 0.1.2 → 0.1.4

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 (144) hide show
  1. package/coverage.svg +1 -1
  2. package/lib/commonjs/components/Avatar/index.js +30 -8
  3. package/lib/commonjs/components/Avatar/index.js.map +1 -1
  4. package/lib/commonjs/components/Avatar/styles.js +163 -7
  5. package/lib/commonjs/components/Avatar/styles.js.map +1 -1
  6. package/lib/commonjs/components/CLAUDE.md +2 -1
  7. package/lib/commonjs/components/Chip/styles.js +1 -1
  8. package/lib/commonjs/components/Chip/styles.js.map +1 -1
  9. package/lib/commonjs/components/Drawer/animation.js +13 -0
  10. package/lib/commonjs/components/Drawer/animation.js.map +1 -0
  11. package/lib/commonjs/components/Drawer/index.js +739 -0
  12. package/lib/commonjs/components/Drawer/index.js.map +1 -0
  13. package/lib/commonjs/components/Drawer/styles.js +185 -0
  14. package/lib/commonjs/components/Drawer/styles.js.map +1 -0
  15. package/lib/commonjs/components/Drawer/utils.js +95 -0
  16. package/lib/commonjs/components/Drawer/utils.js.map +1 -0
  17. package/lib/commonjs/components/InsuranceDisclosure/styles.js +1 -1
  18. package/lib/commonjs/components/InsuranceDisclosure/styles.js.map +1 -1
  19. package/lib/commonjs/components/Menu/index.js +187 -61
  20. package/lib/commonjs/components/Menu/index.js.map +1 -1
  21. package/lib/commonjs/components/Menu/styles.js +32 -37
  22. package/lib/commonjs/components/Menu/styles.js.map +1 -1
  23. package/lib/commonjs/components/Select/index.js +2 -10
  24. package/lib/commonjs/components/Select/index.js.map +1 -1
  25. package/lib/commonjs/components/Tabs/styles.js +9 -10
  26. package/lib/commonjs/components/Tabs/styles.js.map +1 -1
  27. package/lib/commonjs/components/Toast/styles.js +1 -1
  28. package/lib/commonjs/components/Toast/styles.js.map +1 -1
  29. package/lib/commonjs/components/index.js +12 -0
  30. package/lib/commonjs/components/index.js.map +1 -1
  31. package/lib/commonjs/figma/Avatar.figma.js +18 -4
  32. package/lib/commonjs/figma/Avatar.figma.js.map +1 -1
  33. package/lib/commonjs/figma/Drawer.Content.figma.js +29 -0
  34. package/lib/commonjs/figma/Drawer.Content.figma.js.map +1 -0
  35. package/lib/commonjs/figma/Drawer.Description.figma.js +20 -0
  36. package/lib/commonjs/figma/Drawer.Description.figma.js.map +1 -0
  37. package/lib/commonjs/figma/Drawer.Footer.figma.js +41 -0
  38. package/lib/commonjs/figma/Drawer.Footer.figma.js.map +1 -0
  39. package/lib/commonjs/figma/Drawer.Header.figma.js +45 -0
  40. package/lib/commonjs/figma/Drawer.Header.figma.js.map +1 -0
  41. package/lib/commonjs/figma/Drawer.Title.figma.js +20 -0
  42. package/lib/commonjs/figma/Drawer.Title.figma.js.map +1 -0
  43. package/lib/commonjs/figma/Drawer.figma.js +41 -0
  44. package/lib/commonjs/figma/Drawer.figma.js.map +1 -0
  45. package/lib/commonjs/figma/Menu.Item.figma.js +33 -5
  46. package/lib/commonjs/figma/Menu.Item.figma.js.map +1 -1
  47. package/lib/commonjs/figma/icons.figma.batch.json +262 -2
  48. package/lib/module/components/Avatar/index.js +30 -8
  49. package/lib/module/components/Avatar/index.js.map +1 -1
  50. package/lib/module/components/Avatar/styles.js +163 -7
  51. package/lib/module/components/Avatar/styles.js.map +1 -1
  52. package/lib/module/components/CLAUDE.md +2 -1
  53. package/lib/module/components/Chip/styles.js +1 -1
  54. package/lib/module/components/Chip/styles.js.map +1 -1
  55. package/lib/module/components/Drawer/animation.js +7 -0
  56. package/lib/module/components/Drawer/animation.js.map +1 -0
  57. package/lib/module/components/Drawer/index.js +724 -0
  58. package/lib/module/components/Drawer/index.js.map +1 -0
  59. package/lib/module/components/Drawer/styles.js +181 -0
  60. package/lib/module/components/Drawer/styles.js.map +1 -0
  61. package/lib/module/components/Drawer/utils.js +86 -0
  62. package/lib/module/components/Drawer/utils.js.map +1 -0
  63. package/lib/module/components/InsuranceDisclosure/styles.js +1 -1
  64. package/lib/module/components/InsuranceDisclosure/styles.js.map +1 -1
  65. package/lib/module/components/Menu/index.js +178 -52
  66. package/lib/module/components/Menu/index.js.map +1 -1
  67. package/lib/module/components/Menu/styles.js +31 -36
  68. package/lib/module/components/Menu/styles.js.map +1 -1
  69. package/lib/module/components/Select/index.js +3 -11
  70. package/lib/module/components/Select/index.js.map +1 -1
  71. package/lib/module/components/Tabs/styles.js +9 -10
  72. package/lib/module/components/Tabs/styles.js.map +1 -1
  73. package/lib/module/components/Toast/styles.js +1 -1
  74. package/lib/module/components/Toast/styles.js.map +1 -1
  75. package/lib/module/components/index.js +1 -0
  76. package/lib/module/components/index.js.map +1 -1
  77. package/lib/module/figma/Avatar.figma.js +18 -4
  78. package/lib/module/figma/Avatar.figma.js.map +1 -1
  79. package/lib/module/figma/Drawer.Content.figma.js +23 -0
  80. package/lib/module/figma/Drawer.Content.figma.js.map +1 -0
  81. package/lib/module/figma/Drawer.Description.figma.js +14 -0
  82. package/lib/module/figma/Drawer.Description.figma.js.map +1 -0
  83. package/lib/module/figma/Drawer.Footer.figma.js +35 -0
  84. package/lib/module/figma/Drawer.Footer.figma.js.map +1 -0
  85. package/lib/module/figma/Drawer.Header.figma.js +39 -0
  86. package/lib/module/figma/Drawer.Header.figma.js.map +1 -0
  87. package/lib/module/figma/Drawer.Title.figma.js +14 -0
  88. package/lib/module/figma/Drawer.Title.figma.js.map +1 -0
  89. package/lib/module/figma/Drawer.figma.js +35 -0
  90. package/lib/module/figma/Drawer.figma.js.map +1 -0
  91. package/lib/module/figma/Menu.Item.figma.js +33 -5
  92. package/lib/module/figma/Menu.Item.figma.js.map +1 -1
  93. package/lib/module/figma/icons.figma.batch.json +262 -2
  94. package/lib/typescript/components/Avatar/index.d.ts +19 -1
  95. package/lib/typescript/components/Avatar/index.d.ts.map +1 -1
  96. package/lib/typescript/components/Avatar/styles.d.ts +10 -1
  97. package/lib/typescript/components/Avatar/styles.d.ts.map +1 -1
  98. package/lib/typescript/components/Drawer/animation.d.ts +9 -0
  99. package/lib/typescript/components/Drawer/animation.d.ts.map +1 -0
  100. package/lib/typescript/components/Drawer/index.d.ts +106 -0
  101. package/lib/typescript/components/Drawer/index.d.ts.map +1 -0
  102. package/lib/typescript/components/Drawer/styles.d.ts +32 -0
  103. package/lib/typescript/components/Drawer/styles.d.ts.map +1 -0
  104. package/lib/typescript/components/Drawer/utils.d.ts +23 -0
  105. package/lib/typescript/components/Drawer/utils.d.ts.map +1 -0
  106. package/lib/typescript/components/InsuranceDisclosure/styles.d.ts.map +1 -1
  107. package/lib/typescript/components/Menu/index.d.ts +29 -2
  108. package/lib/typescript/components/Menu/index.d.ts.map +1 -1
  109. package/lib/typescript/components/Menu/styles.d.ts +6 -2
  110. package/lib/typescript/components/Menu/styles.d.ts.map +1 -1
  111. package/lib/typescript/components/Select/index.d.ts.map +1 -1
  112. package/lib/typescript/components/Tabs/styles.d.ts.map +1 -1
  113. package/lib/typescript/components/index.d.ts +1 -0
  114. package/lib/typescript/components/index.d.ts.map +1 -1
  115. package/lib/typescript/figma/Avatar.figma.d.ts.map +1 -1
  116. package/lib/typescript/figma/Drawer.Content.figma.d.ts +8 -0
  117. package/lib/typescript/figma/Drawer.Content.figma.d.ts.map +1 -0
  118. package/lib/typescript/figma/Drawer.Description.figma.d.ts +8 -0
  119. package/lib/typescript/figma/Drawer.Description.figma.d.ts.map +1 -0
  120. package/lib/typescript/figma/Drawer.Footer.figma.d.ts +11 -0
  121. package/lib/typescript/figma/Drawer.Footer.figma.d.ts.map +1 -0
  122. package/lib/typescript/figma/Drawer.Header.figma.d.ts +8 -0
  123. package/lib/typescript/figma/Drawer.Header.figma.d.ts.map +1 -0
  124. package/lib/typescript/figma/Drawer.Title.figma.d.ts +8 -0
  125. package/lib/typescript/figma/Drawer.Title.figma.d.ts.map +1 -0
  126. package/lib/typescript/figma/Drawer.figma.d.ts +8 -0
  127. package/lib/typescript/figma/Drawer.figma.d.ts.map +1 -0
  128. package/lib/typescript/figma/Menu.Item.figma.d.ts.map +1 -1
  129. package/package.json +5 -5
  130. package/src/components/Avatar/index.tsx +45 -9
  131. package/src/components/Avatar/styles.ts +106 -23
  132. package/src/components/CLAUDE.md +2 -1
  133. package/src/components/Chip/styles.ts +1 -1
  134. package/src/components/Drawer/animation.ts +11 -0
  135. package/src/components/Drawer/index.tsx +896 -0
  136. package/src/components/Drawer/styles.ts +188 -0
  137. package/src/components/Drawer/utils.ts +83 -0
  138. package/src/components/InsuranceDisclosure/styles.ts +1 -3
  139. package/src/components/Menu/index.tsx +204 -62
  140. package/src/components/Menu/styles.ts +44 -54
  141. package/src/components/Select/index.tsx +7 -9
  142. package/src/components/Tabs/styles.ts +9 -10
  143. package/src/components/Toast/styles.ts +1 -1
  144. package/src/components/index.ts +1 -0
@@ -0,0 +1,724 @@
1
+ "use strict";
2
+
3
+ import { Children, forwardRef, isValidElement, useCallback, useEffect, useMemo, useRef, useState } from 'react';
4
+ import { BackHandler, Platform, ScrollView, StyleSheet, useWindowDimensions, View } from 'react-native';
5
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
6
+ import { FocusScope } from '@react-native-aria/focus';
7
+ import { Close as CloseIcon } from '@cdx-ui/icons';
8
+ import { DrawerClose as DrawerClosePrimitive, DrawerOverlay as DrawerOverlayPrimitive, DrawerPortal as DrawerPortalPrimitive, DrawerRoot as DrawerRootPrimitive, FullWindowOverlay, MODAL_OVERLAY_Z_INDEX, Slot, dataAttributes, mergeDataAttributes, useDrawer, useEscapeKey, useOverlayStackRegistration } from '@cdx-ui/primitives';
9
+ import { cn, mergeRefs, ParentContext, useParentContext, useStyleContext } from '@cdx-ui/utils';
10
+ import { usePopupOverlayAnimation, usePopupRootAnimation } from '../../animation';
11
+ import { AnimationSettingsProvider, useAnimationSettings } from '../../providers/animation-settings';
12
+ import { Heading } from '../Heading';
13
+ import { Icon } from '../Icon';
14
+ import { Text } from '../Text';
15
+ import { DrawerAnimationProvider, useDrawerAnimation } from './animation';
16
+ import { drawerCloseIconVariants, drawerCloseVariants, drawerContentInnerVariants, drawerContentVariants, drawerDescriptionVariants, drawerFooterVariants, drawerHeaderContentVariants, drawerHeaderVariants, drawerLeadingSlotVariants, drawerOverlayVariants, drawerPanelVariants, drawerPortalVariants, drawerTitleVariants } from './styles';
17
+ import { DRAWER_EDGE_PADDING, DRAWER_ENTER_EASING, DRAWER_ENTER_MS, DRAWER_EXIT_EASING, DRAWER_EXIT_MS, DRAWER_WIDE_BREAKPOINT, WEB_TRANSITION_SAFETY_MS, getDrawerSlideKeyframes, isHorizontalDrawerPlacement, resolveDrawerPlacement, useClampedDrawerExtent, useSafeInsets } from './utils';
18
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
19
+ export { useDrawer } from '@cdx-ui/primitives';
20
+ const IS_WEB = Platform.OS === 'web';
21
+ // =============================================================================
22
+ // STYLE CONTEXT
23
+ // =============================================================================
24
+
25
+ const SCOPE = 'DRAWER';
26
+ const useDrawerStyleContext = () => useStyleContext(SCOPE);
27
+
28
+ // =============================================================================
29
+ // ANIMATED PRIMITIVES
30
+ // =============================================================================
31
+
32
+ const AnimatedOverlay = Animated.createAnimatedComponent(DrawerOverlayPrimitive);
33
+
34
+ // =============================================================================
35
+ // STYLED ROOT
36
+ // =============================================================================
37
+
38
+ const DrawerRoot = /*#__PURE__*/forwardRef(({
39
+ variant = 'permanent',
40
+ size = 'default',
41
+ placement: placementProp,
42
+ fullBleed = false,
43
+ animation,
44
+ className,
45
+ children,
46
+ style,
47
+ isOpen,
48
+ defaultOpen,
49
+ onOpenChange,
50
+ closeOnBackdropPress = true,
51
+ closeOnEscKey = true,
52
+ zIndex = MODAL_OVERLAY_Z_INDEX,
53
+ ...props
54
+ }, ref) => {
55
+ const placement = resolveDrawerPlacement(placementProp);
56
+ const parent = useParentContext();
57
+ const ctx = useMemo(() => ({
58
+ ...parent,
59
+ [SCOPE]: {
60
+ variant,
61
+ size,
62
+ placement,
63
+ fullBleed
64
+ }
65
+ }), [parent, variant, size, placement, fullBleed]);
66
+ const {
67
+ progress,
68
+ isAllAnimationsDisabled
69
+ } = usePopupRootAnimation({
70
+ animation
71
+ });
72
+ const panelExtent = useClampedDrawerExtent(size, placement);
73
+ const animationContextValue = useMemo(() => ({
74
+ progress
75
+ }), [progress]);
76
+ const animationSettingsContextValue = useMemo(() => ({
77
+ isAllAnimationsDisabled
78
+ }), [isAllAnimationsDisabled]);
79
+ if (variant === 'permanent') {
80
+ return /*#__PURE__*/_jsx(AnimationSettingsProvider, {
81
+ value: animationSettingsContextValue,
82
+ children: /*#__PURE__*/_jsx(ParentContext.Provider, {
83
+ value: ctx,
84
+ children: /*#__PURE__*/_jsx(DrawerRootPrimitive, {
85
+ ref: ref,
86
+ isOpen: isOpen,
87
+ defaultOpen: defaultOpen ?? true,
88
+ onOpenChange: onOpenChange,
89
+ closeOnBackdropPress: false,
90
+ closeOnEscKey: false,
91
+ className: cn('self-stretch overflow-hidden', className),
92
+ style: style,
93
+ ...props,
94
+ ...mergeDataAttributes(props, dataAttributes({
95
+ slot: 'drawer',
96
+ placement
97
+ })),
98
+ children: /*#__PURE__*/_jsx(DrawerPermanentPanel, {
99
+ size: size,
100
+ placement: placement,
101
+ panelExtent: panelExtent,
102
+ children: children
103
+ })
104
+ })
105
+ })
106
+ });
107
+ }
108
+ return /*#__PURE__*/_jsx(AnimationSettingsProvider, {
109
+ value: animationSettingsContextValue,
110
+ children: /*#__PURE__*/_jsx(DrawerAnimationProvider, {
111
+ value: animationContextValue,
112
+ children: /*#__PURE__*/_jsx(ParentContext.Provider, {
113
+ value: ctx,
114
+ children: /*#__PURE__*/_jsx(DrawerRootPrimitive, {
115
+ ref: ref,
116
+ isOpen: isOpen,
117
+ defaultOpen: defaultOpen,
118
+ onOpenChange: onOpenChange,
119
+ closeOnBackdropPress: closeOnBackdropPress,
120
+ closeOnEscKey: closeOnEscKey,
121
+ className: className,
122
+ style: style,
123
+ ...props,
124
+ ...mergeDataAttributes(props, dataAttributes({
125
+ slot: 'drawer',
126
+ placement
127
+ })),
128
+ children: /*#__PURE__*/_jsx(DrawerPopup, {
129
+ zIndex: zIndex,
130
+ children: children
131
+ })
132
+ })
133
+ })
134
+ })
135
+ });
136
+ });
137
+ DrawerRoot.displayName = 'Drawer';
138
+ const DrawerPermanentPanel = ({
139
+ size,
140
+ placement,
141
+ panelExtent,
142
+ children
143
+ }) => {
144
+ const {
145
+ open
146
+ } = useDrawer();
147
+ const {
148
+ isAllAnimationsDisabled
149
+ } = useAnimationSettings();
150
+ const isHorizontal = isHorizontalDrawerPlacement(placement);
151
+ const extent = useSharedValue(open ? panelExtent : 0);
152
+ const hasMounted = useRef(false);
153
+ useEffect(() => {
154
+ const target = open ? panelExtent : 0;
155
+ if (!hasMounted.current) {
156
+ hasMounted.current = true;
157
+ extent.set(target);
158
+ return;
159
+ }
160
+ if (isAllAnimationsDisabled) {
161
+ extent.set(target);
162
+ return;
163
+ }
164
+ extent.set(withTiming(target, {
165
+ duration: open ? DRAWER_ENTER_MS : DRAWER_EXIT_MS,
166
+ easing: open ? DRAWER_ENTER_EASING : DRAWER_EXIT_EASING
167
+ }));
168
+ }, [extent, isAllAnimationsDisabled, open, panelExtent]);
169
+ const animatedStyle = useAnimatedStyle(() => {
170
+ const value = extent.get();
171
+ return isHorizontal ? {
172
+ width: value
173
+ } : {
174
+ height: value
175
+ };
176
+ }, [isHorizontal]);
177
+ return /*#__PURE__*/_jsx(Animated.View, {
178
+ className: drawerPanelVariants({
179
+ size,
180
+ variant: 'permanent',
181
+ placement
182
+ }),
183
+ pointerEvents: open ? 'auto' : 'none',
184
+ style: animatedStyle,
185
+ children: /*#__PURE__*/_jsx(View, {
186
+ className: "h-full",
187
+ style: isHorizontal ? {
188
+ width: panelExtent
189
+ } : {
190
+ height: panelExtent
191
+ },
192
+ children: open ? children : null
193
+ })
194
+ });
195
+ };
196
+
197
+ // =============================================================================
198
+ // INTERNAL POPUP (portal + overlay + panel — not a Figma slot)
199
+ // =============================================================================
200
+
201
+ const DrawerPopup = /*#__PURE__*/forwardRef(({
202
+ className,
203
+ children,
204
+ disableFullWindowOverlay = false,
205
+ zIndex = MODAL_OVERLAY_Z_INDEX
206
+ }, ref) => {
207
+ const {
208
+ size,
209
+ placement: placementProp
210
+ } = useDrawerStyleContext();
211
+ const placement = resolveDrawerPlacement(placementProp);
212
+ const {
213
+ open,
214
+ onOpenChange,
215
+ closeOnEscKey,
216
+ nativeID
217
+ } = useDrawer();
218
+ const {
219
+ width: windowWidth,
220
+ height: windowHeight
221
+ } = useWindowDimensions();
222
+ const panelExtent = useClampedDrawerExtent(size, placement);
223
+ const parentContext = useParentContext();
224
+ const animationContext = useDrawerAnimation();
225
+ const parentAnimationSettings = useAnimationSettings();
226
+ const {
227
+ isAllAnimationsDisabled
228
+ } = parentAnimationSettings;
229
+ const panelMotion = useMemo(() => getDrawerSlideKeyframes(placement, panelExtent), [panelExtent, placement]);
230
+ const fallbackIsDragging = useSharedValue(false);
231
+ const fallbackIsGestureReleaseAnimationRunning = useSharedValue(false);
232
+ const progress = animationContext.progress;
233
+ useEffect(() => {
234
+ if (open) {
235
+ progress.set(1);
236
+ }
237
+ }, [open, progress]);
238
+ const {
239
+ rContainerStyle,
240
+ entering: overlayEntering,
241
+ exiting: overlayExiting
242
+ } = usePopupOverlayAnimation({
243
+ progress,
244
+ isDragging: fallbackIsDragging,
245
+ isGestureReleaseAnimationRunning: fallbackIsGestureReleaseAnimationRunning
246
+ });
247
+ const panelRef = useRef(null);
248
+ const prevOpenRef = useRef(open);
249
+ const [isExiting, setIsExiting] = useState(false);
250
+ const [webState, setWebState] = useState(open ? 'entering' : 'closed');
251
+ const handleClose = useCallback(() => {
252
+ onOpenChange(false);
253
+ }, [onOpenChange]);
254
+ useEscapeKey(open && closeOnEscKey, handleClose, {
255
+ id: nativeID,
256
+ groupId: nativeID,
257
+ layer: 'modal'
258
+ });
259
+ const {
260
+ isTopmost
261
+ } = useOverlayStackRegistration({
262
+ active: open && Platform.OS !== 'web',
263
+ capabilities: ['back'],
264
+ id: nativeID,
265
+ groupId: nativeID,
266
+ layer: 'modal'
267
+ });
268
+ useEffect(() => {
269
+ if (!open || Platform.OS === 'web') return;
270
+ const backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
271
+ if (!isTopmost('back')) return false;
272
+ handleClose();
273
+ return true;
274
+ });
275
+ return () => {
276
+ backHandler.remove();
277
+ };
278
+ }, [handleClose, isTopmost, open]);
279
+ if (IS_WEB && prevOpenRef.current && !open && !isExiting) {
280
+ setIsExiting(true);
281
+ setWebState('closed');
282
+ }
283
+ if (IS_WEB && !prevOpenRef.current && open) {
284
+ setIsExiting(false);
285
+ setWebState('entering');
286
+ }
287
+ prevOpenRef.current = open;
288
+ useEffect(() => {
289
+ if (!IS_WEB || !open) return;
290
+ const raf = requestAnimationFrame(() => {
291
+ setWebState('open');
292
+ });
293
+ return () => cancelAnimationFrame(raf);
294
+ }, [open]);
295
+ useEffect(() => {
296
+ if (!IS_WEB || !isExiting) return;
297
+ const node = panelRef.current;
298
+ let done = false;
299
+ const finish = () => {
300
+ if (done) return;
301
+ done = true;
302
+ setIsExiting(false);
303
+ };
304
+ const safetyTimer = setTimeout(finish, WEB_TRANSITION_SAFETY_MS);
305
+ if (!node || typeof node.addEventListener !== 'function') {
306
+ return () => {
307
+ clearTimeout(safetyTimer);
308
+ };
309
+ }
310
+ const handler = event => {
311
+ if (event.target !== node) return;
312
+ const propertyName = event.propertyName ?? '';
313
+ if (propertyName === 'opacity' || propertyName === 'transform') {
314
+ finish();
315
+ }
316
+ };
317
+ node.addEventListener('transitionend', handler);
318
+ return () => {
319
+ clearTimeout(safetyTimer);
320
+ node.removeEventListener('transitionend', handler);
321
+ };
322
+ }, [isExiting]);
323
+ const dataState = webState;
324
+ const shouldMount = IS_WEB ? open || isExiting : open;
325
+ if (!shouldMount) {
326
+ return null;
327
+ }
328
+ const portalClassName = cn(drawerPortalVariants());
329
+ const overlayClassName = cn(drawerOverlayVariants());
330
+ const panelClassName = cn(drawerPanelVariants({
331
+ size,
332
+ variant: 'modal',
333
+ placement
334
+ }), className);
335
+ const panelSizeStyle = isHorizontalDrawerPlacement(placement) ? {
336
+ width: panelExtent,
337
+ height: windowHeight
338
+ } : {
339
+ width: windowWidth,
340
+ height: panelExtent
341
+ };
342
+ const nativePanelEntering = IS_WEB || isAllAnimationsDisabled ? undefined : panelMotion.entering;
343
+ const nativePanelExiting = IS_WEB || isAllAnimationsDisabled ? undefined : panelMotion.exiting;
344
+ return /*#__PURE__*/_jsx(DrawerPortalPrimitive, {
345
+ forceMount: true,
346
+ children: /*#__PURE__*/_jsx(ParentContext.Provider, {
347
+ value: parentContext,
348
+ children: /*#__PURE__*/_jsx(AnimationSettingsProvider, {
349
+ value: parentAnimationSettings,
350
+ children: /*#__PURE__*/_jsx(DrawerAnimationProvider, {
351
+ value: animationContext,
352
+ children: /*#__PURE__*/_jsx(FullWindowOverlay, {
353
+ disableFullWindowOverlay: disableFullWindowOverlay,
354
+ unstable_accessibilityContainerViewIsModal: true,
355
+ children: /*#__PURE__*/_jsxs(View, {
356
+ className: portalClassName,
357
+ style: {
358
+ zIndex
359
+ },
360
+ pointerEvents: "box-none",
361
+ ...(IS_WEB ? dataAttributes({
362
+ state: dataState
363
+ }) : undefined),
364
+ children: [/*#__PURE__*/_jsx(Animated.View, {
365
+ entering: overlayEntering,
366
+ exiting: overlayExiting,
367
+ style: StyleSheet.absoluteFill,
368
+ children: /*#__PURE__*/_jsx(AnimatedOverlay, {
369
+ forceMount: true,
370
+ testID: "drawer-overlay",
371
+ className: overlayClassName,
372
+ style: IS_WEB ? undefined : rContainerStyle,
373
+ ...mergeDataAttributes({}, dataAttributes({
374
+ slot: 'drawer-overlay'
375
+ }), IS_WEB ? dataAttributes({
376
+ state: dataState
377
+ }) : undefined)
378
+ })
379
+ }), /*#__PURE__*/_jsx(Animated.View, {
380
+ entering: nativePanelEntering,
381
+ exiting: nativePanelExiting,
382
+ pointerEvents: "box-none",
383
+ style: [internalStyles[placement], panelSizeStyle],
384
+ children: /*#__PURE__*/_jsx(FocusScope, {
385
+ contain: open,
386
+ restoreFocus: true,
387
+ autoFocus: open,
388
+ children: /*#__PURE__*/_jsx(View, {
389
+ ref: mergeRefs(ref, panelRef),
390
+ nativeID: nativeID,
391
+ role: "dialog",
392
+ "aria-modal": true,
393
+ "aria-labelledby": `${nativeID}-title`,
394
+ "aria-describedby": `${nativeID}-description`,
395
+ className: panelClassName,
396
+ style: panelSizeStyle,
397
+ ...mergeDataAttributes({}, dataAttributes({
398
+ slot: 'drawer',
399
+ placement
400
+ }), IS_WEB ? dataAttributes({
401
+ state: dataState
402
+ }) : undefined),
403
+ children: children
404
+ })
405
+ })
406
+ })]
407
+ })
408
+ })
409
+ })
410
+ })
411
+ })
412
+ });
413
+ });
414
+ DrawerPopup.displayName = 'DrawerPopup';
415
+ const DrawerClose = /*#__PURE__*/forwardRef(({
416
+ className,
417
+ accessibilityLabel = 'Close',
418
+ children,
419
+ style,
420
+ ...props
421
+ }, ref) => /*#__PURE__*/_jsx(DrawerClosePrimitive, {
422
+ ref: ref,
423
+ className: cn(drawerCloseVariants(), className),
424
+ style: style,
425
+ hitSlop: 12,
426
+ accessibilityRole: "button",
427
+ accessibilityLabel: accessibilityLabel,
428
+ ...props,
429
+ ...mergeDataAttributes(props, dataAttributes({
430
+ slot: 'drawer-close'
431
+ })),
432
+ children: children ?? /*#__PURE__*/_jsx(Icon, {
433
+ as: CloseIcon,
434
+ className: drawerCloseIconVariants()
435
+ })
436
+ }));
437
+ DrawerClose.displayName = 'Drawer.Close';
438
+
439
+ // =============================================================================
440
+ // STYLED LEADING SLOT
441
+ // =============================================================================
442
+
443
+ const DrawerLeadingSlot = /*#__PURE__*/forwardRef(({
444
+ asChild,
445
+ className,
446
+ style,
447
+ 'aria-hidden': ariaHidden,
448
+ ...props
449
+ }, ref) => {
450
+ const Comp = asChild ? Slot : View;
451
+ return /*#__PURE__*/_jsx(Comp, {
452
+ ref: ref,
453
+ accessibilityElementsHidden: ariaHidden !== false,
454
+ "aria-hidden": ariaHidden ?? true,
455
+ className: cn(drawerLeadingSlotVariants(), className),
456
+ style: style,
457
+ ...props,
458
+ ...mergeDataAttributes(props, dataAttributes({
459
+ slot: 'drawer-leading'
460
+ }))
461
+ });
462
+ });
463
+ DrawerLeadingSlot.displayName = 'Drawer.LeadingSlot';
464
+
465
+ // =============================================================================
466
+ // STYLED HEADER
467
+ // =============================================================================
468
+
469
+ /**
470
+ * Props for `Drawer.Header`.
471
+ *
472
+ * The header lays out its direct children as a fixed row regardless of JSX
473
+ * order: the first `Drawer.LeadingSlot` at the start, every other child
474
+ * (`Drawer.Title`, `Drawer.Description`, custom content) in a text column, and
475
+ * the close control at the end. Additional `Drawer.LeadingSlot` or
476
+ * `Drawer.Close` children are ignored.
477
+ *
478
+ * `Drawer.LeadingSlot` and `Drawer.Close` must be direct children. They are
479
+ * matched by component identity, so wrapping them in `memo()`, an HOC, or a
480
+ * custom component hides them from the header and they render in the text
481
+ * column instead.
482
+ */
483
+
484
+ const renderDrawerHeaderRow = (children, close) => {
485
+ const childArray = Children.toArray(children);
486
+ const leadingChild = childArray.find(child => /*#__PURE__*/isValidElement(child) && child.type === DrawerLeadingSlot);
487
+ const closeChild = childArray.find(child => /*#__PURE__*/isValidElement(child) && child.type === DrawerClose);
488
+ const textChildren = childArray.filter(child => ! /*#__PURE__*/isValidElement(child) || child.type !== DrawerLeadingSlot && child.type !== DrawerClose);
489
+ const closeElement = close === undefined ? closeChild ?? /*#__PURE__*/_jsx(DrawerClose, {}) : close;
490
+ return /*#__PURE__*/_jsxs(_Fragment, {
491
+ children: [leadingChild, textChildren.length > 0 ? /*#__PURE__*/_jsx(View, {
492
+ className: drawerHeaderContentVariants(),
493
+ children: textChildren
494
+ }) : null, closeElement]
495
+ });
496
+ };
497
+ const DrawerHeader = /*#__PURE__*/forwardRef(({
498
+ asChild,
499
+ close,
500
+ showSeparator = true,
501
+ className,
502
+ children,
503
+ style,
504
+ ...props
505
+ }, ref) => {
506
+ const insets = useSafeInsets();
507
+ const {
508
+ placement: placementProp,
509
+ variant
510
+ } = useDrawerStyleContext();
511
+ const placement = resolveDrawerPlacement(placementProp);
512
+ const paddingTop = variant === 'modal' && placement !== 'bottom' ? Math.max(insets.top, DRAWER_EDGE_PADDING) : DRAWER_EDGE_PADDING;
513
+ const computedClassName = cn(drawerHeaderVariants({
514
+ showSeparator
515
+ }), className);
516
+ const Comp = asChild ? Slot : View;
517
+ return /*#__PURE__*/_jsx(Comp, {
518
+ ref: ref,
519
+ className: computedClassName,
520
+ style: [{
521
+ paddingTop
522
+ }, style],
523
+ ...props,
524
+ ...mergeDataAttributes(props, dataAttributes({
525
+ slot: 'drawer-header'
526
+ })),
527
+ children: asChild ? children : renderDrawerHeaderRow(children, close)
528
+ });
529
+ });
530
+ DrawerHeader.displayName = 'Drawer.Header';
531
+
532
+ // =============================================================================
533
+ // STYLED TITLE
534
+ // =============================================================================
535
+
536
+ const DrawerTitle = /*#__PURE__*/forwardRef(({
537
+ asChild,
538
+ className,
539
+ children,
540
+ style,
541
+ ...props
542
+ }, ref) => {
543
+ const {
544
+ nativeID
545
+ } = useDrawer();
546
+ const computedClassName = cn(drawerTitleVariants(), className);
547
+ if (asChild) {
548
+ return /*#__PURE__*/_jsx(Slot, {
549
+ ref: ref,
550
+ nativeID: `${nativeID}-title`,
551
+ className: computedClassName,
552
+ style: style,
553
+ ...props,
554
+ ...mergeDataAttributes(props, dataAttributes({
555
+ slot: 'drawer-title'
556
+ })),
557
+ children: children
558
+ });
559
+ }
560
+ return /*#__PURE__*/_jsx(Heading, {
561
+ ref: ref,
562
+ size: "sm",
563
+ nativeID: `${nativeID}-title`,
564
+ className: computedClassName,
565
+ style: style,
566
+ ...props,
567
+ ...mergeDataAttributes(props, dataAttributes({
568
+ slot: 'drawer-title'
569
+ })),
570
+ children: children
571
+ });
572
+ });
573
+ DrawerTitle.displayName = 'Drawer.Title';
574
+
575
+ // =============================================================================
576
+ // STYLED DESCRIPTION
577
+ // =============================================================================
578
+
579
+ const DrawerDescription = /*#__PURE__*/forwardRef(({
580
+ asChild,
581
+ className,
582
+ children,
583
+ style,
584
+ ...props
585
+ }, ref) => {
586
+ const {
587
+ nativeID
588
+ } = useDrawer();
589
+ const computedClassName = cn(drawerDescriptionVariants(), className);
590
+ const Comp = asChild ? Slot : Text;
591
+ return /*#__PURE__*/_jsx(Comp, {
592
+ ref: ref,
593
+ nativeID: `${nativeID}-description`,
594
+ size: "sm",
595
+ className: computedClassName,
596
+ style: style,
597
+ ...props,
598
+ ...mergeDataAttributes(props, dataAttributes({
599
+ slot: 'drawer-description'
600
+ })),
601
+ children: children
602
+ });
603
+ });
604
+ DrawerDescription.displayName = 'Drawer.Description';
605
+
606
+ // =============================================================================
607
+ // STYLED CONTENT (Figma Drawer.Content — scroll region)
608
+ // =============================================================================
609
+
610
+ const DrawerContent = /*#__PURE__*/forwardRef(({
611
+ className,
612
+ contentClassName,
613
+ children,
614
+ style,
615
+ contentContainerStyle,
616
+ fullBleed: fullBleedProp,
617
+ ...props
618
+ }, ref) => {
619
+ const {
620
+ fullBleed: contextFullBleed
621
+ } = useDrawerStyleContext();
622
+ const fullBleed = fullBleedProp ?? contextFullBleed ?? false;
623
+ return /*#__PURE__*/_jsx(ScrollView, {
624
+ ref: ref,
625
+ className: cn(drawerContentVariants({
626
+ fullBleed
627
+ }), className),
628
+ style: style,
629
+ contentContainerClassName: cn(drawerContentInnerVariants(), contentClassName),
630
+ contentContainerStyle: contentContainerStyle,
631
+ ...props,
632
+ ...mergeDataAttributes(props, dataAttributes({
633
+ slot: 'drawer-content'
634
+ })),
635
+ children: children
636
+ });
637
+ });
638
+ DrawerContent.displayName = 'Drawer.Content';
639
+
640
+ // =============================================================================
641
+ // STYLED FOOTER
642
+ // =============================================================================
643
+
644
+ const DrawerFooter = /*#__PURE__*/forwardRef(({
645
+ asChild,
646
+ showSeparator = false,
647
+ direction: directionProp,
648
+ className,
649
+ children,
650
+ style,
651
+ ...props
652
+ }, ref) => {
653
+ const {
654
+ width
655
+ } = useWindowDimensions();
656
+ const insets = useSafeInsets();
657
+ const {
658
+ placement: placementProp,
659
+ variant
660
+ } = useDrawerStyleContext();
661
+ const placement = resolveDrawerPlacement(placementProp);
662
+ const direction = directionProp ?? (width >= DRAWER_WIDE_BREAKPOINT ? 'row' : 'column');
663
+ const computedClassName = cn(drawerFooterVariants({
664
+ showSeparator,
665
+ direction
666
+ }), className);
667
+ const Comp = asChild ? Slot : View;
668
+ const paddingBottom = variant === 'modal' && placement !== 'top' ? Math.max(insets.bottom, DRAWER_EDGE_PADDING) : DRAWER_EDGE_PADDING;
669
+ return /*#__PURE__*/_jsx(Comp, {
670
+ ref: ref,
671
+ className: computedClassName,
672
+ style: [{
673
+ paddingBottom
674
+ }, style],
675
+ ...props,
676
+ ...mergeDataAttributes(props, dataAttributes({
677
+ slot: 'drawer-footer'
678
+ })),
679
+ children: children
680
+ });
681
+ });
682
+ DrawerFooter.displayName = 'Drawer.Footer';
683
+
684
+ // =============================================================================
685
+ // COMPOUND COMPONENT
686
+ // =============================================================================
687
+
688
+ export const Drawer = Object.assign(DrawerRoot, {
689
+ Header: DrawerHeader,
690
+ LeadingSlot: DrawerLeadingSlot,
691
+ Close: DrawerClose,
692
+ Title: DrawerTitle,
693
+ Description: DrawerDescription,
694
+ Content: DrawerContent,
695
+ Footer: DrawerFooter
696
+ });
697
+ const internalStyles = StyleSheet.create({
698
+ right: {
699
+ position: 'absolute',
700
+ top: 0,
701
+ bottom: 0,
702
+ right: 0
703
+ },
704
+ left: {
705
+ position: 'absolute',
706
+ top: 0,
707
+ bottom: 0,
708
+ left: 0
709
+ },
710
+ top: {
711
+ position: 'absolute',
712
+ top: 0,
713
+ left: 0,
714
+ right: 0
715
+ },
716
+ bottom: {
717
+ position: 'absolute',
718
+ bottom: 0,
719
+ left: 0,
720
+ right: 0
721
+ }
722
+ });
723
+ export { MODAL_OVERLAY_Z_INDEX };
724
+ //# sourceMappingURL=index.js.map