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