@kadoui/react 2.1.1 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-components/DrawerSheet/DrawerSheet.d.ts +2 -0
- package/dist/react-components/DrawerSheet/DrawerSheet.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/DrawerSheet.js +1 -0
- package/dist/react-components/DrawerSheet/browser.d.ts +8 -0
- package/dist/react-components/DrawerSheet/browser.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/browser.js +27 -0
- package/dist/react-components/DrawerSheet/constants.d.ts +12 -0
- package/dist/react-components/DrawerSheet/constants.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/constants.js +11 -0
- package/dist/react-components/DrawerSheet/context.d.ts +38 -0
- package/dist/react-components/DrawerSheet/context.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/context.js +39 -0
- package/dist/react-components/DrawerSheet/helpers.d.ts +17 -0
- package/dist/react-components/DrawerSheet/helpers.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/helpers.js +97 -0
- package/dist/react-components/DrawerSheet/index.d.ts +147 -0
- package/dist/react-components/DrawerSheet/index.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/index.js +803 -0
- package/dist/react-components/DrawerSheet/types.d.ts +7 -0
- package/dist/react-components/DrawerSheet/types.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/types.js +1 -0
- package/dist/react-components/DrawerSheet/use-composed-refs.d.ts +14 -0
- package/dist/react-components/DrawerSheet/use-composed-refs.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/use-composed-refs.js +30 -0
- package/dist/react-components/DrawerSheet/use-controllable-state.d.ts +9 -0
- package/dist/react-components/DrawerSheet/use-controllable-state.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/use-controllable-state.js +41 -0
- package/dist/react-components/DrawerSheet/use-position-fixed.d.ts +19 -0
- package/dist/react-components/DrawerSheet/use-position-fixed.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/use-position-fixed.js +109 -0
- package/dist/react-components/DrawerSheet/use-prevent-scroll.d.ts +18 -0
- package/dist/react-components/DrawerSheet/use-prevent-scroll.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/use-prevent-scroll.js +237 -0
- package/dist/react-components/DrawerSheet/use-scale-background.d.ts +2 -0
- package/dist/react-components/DrawerSheet/use-scale-background.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/use-scale-background.js +50 -0
- package/dist/react-components/DrawerSheet/use-snap-points.d.ts +32 -0
- package/dist/react-components/DrawerSheet/use-snap-points.d.ts.map +1 -0
- package/dist/react-components/DrawerSheet/use-snap-points.js +200 -0
- package/dist/react-components/Modal/ModalBody.d.ts.map +1 -1
- package/dist/react-components/Modal/ModalBody.js +1 -1
- package/dist/react-components/Otp/OtpRoot.d.ts.map +1 -1
- package/dist/react-components/Otp/OtpRoot.js +2 -2
- package/dist/react-components/Otp/otpTypes.d.ts +1 -1
- package/dist/react-components/Otp/otpTypes.d.ts.map +1 -1
- package/dist/react-components/drawer-sheet/DrawerSheet.d.ts +23 -0
- package/dist/react-components/drawer-sheet/DrawerSheet.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheet.js +22 -0
- package/dist/react-components/drawer-sheet/DrawerSheetBackdrop.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetBackdrop.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetBackdrop.js +13 -0
- package/dist/react-components/drawer-sheet/DrawerSheetBody.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetBody.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetBody.js +165 -0
- package/dist/react-components/drawer-sheet/DrawerSheetContent.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetContent.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetContent.js +16 -0
- package/dist/react-components/drawer-sheet/DrawerSheetContext.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetContext.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetContext.js +2 -0
- package/dist/react-components/drawer-sheet/DrawerSheetHandlebar.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetHandlebar.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetHandlebar.js +5 -0
- package/dist/react-components/drawer-sheet/DrawerSheetHeader.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetHeader.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetHeader.js +5 -0
- package/dist/react-components/drawer-sheet/DrawerSheetPortal.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetPortal.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetPortal.js +13 -0
- package/dist/react-components/drawer-sheet/DrawerSheetProvider.d.ts +15 -0
- package/dist/react-components/drawer-sheet/DrawerSheetProvider.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetProvider.js +75 -0
- package/dist/react-components/drawer-sheet/DrawerSheetRoot.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetRoot.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetRoot.js +130 -0
- package/dist/react-components/drawer-sheet/DrawerSheetToggle.d.ts +3 -0
- package/dist/react-components/drawer-sheet/DrawerSheetToggle.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetToggle.js +11 -0
- package/dist/react-components/drawer-sheet/DrawerSheetViewport.d.ts +4 -0
- package/dist/react-components/drawer-sheet/DrawerSheetViewport.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/DrawerSheetViewport.js +5 -0
- package/dist/react-components/drawer-sheet/drawerSheetTypes.d.ts +30 -0
- package/dist/react-components/drawer-sheet/drawerSheetTypes.d.ts.map +1 -0
- package/dist/react-components/drawer-sheet/drawerSheetTypes.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { set, isVertical } from './helpers';
|
|
3
|
+
import { TRANSITIONS, VELOCITY_THRESHOLD } from './constants';
|
|
4
|
+
import { useControllableState } from './use-controllable-state';
|
|
5
|
+
export function useSnapPoints({ activeSnapPointProp, setActiveSnapPointProp, snapPoints, drawerRef, overlayRef, fadeFromIndex, onSnapPointChange, direction = 'bottom', container, snapToSequentialPoint, }) {
|
|
6
|
+
const [activeSnapPoint, setActiveSnapPoint] = useControllableState({
|
|
7
|
+
prop: activeSnapPointProp,
|
|
8
|
+
defaultProp: snapPoints?.[0],
|
|
9
|
+
onChange: setActiveSnapPointProp,
|
|
10
|
+
});
|
|
11
|
+
const [windowDimensions, setWindowDimensions] = React.useState(typeof window !== 'undefined'
|
|
12
|
+
? {
|
|
13
|
+
innerWidth: window.innerWidth,
|
|
14
|
+
innerHeight: window.innerHeight,
|
|
15
|
+
}
|
|
16
|
+
: undefined);
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
function onResize() {
|
|
19
|
+
setWindowDimensions({
|
|
20
|
+
innerWidth: window.innerWidth,
|
|
21
|
+
innerHeight: window.innerHeight,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
window.addEventListener('resize', onResize);
|
|
25
|
+
return () => window.removeEventListener('resize', onResize);
|
|
26
|
+
}, []);
|
|
27
|
+
const isLastSnapPoint = React.useMemo(() => activeSnapPoint === snapPoints?.[snapPoints.length - 1] || null, [snapPoints, activeSnapPoint]);
|
|
28
|
+
const activeSnapPointIndex = React.useMemo(() => snapPoints?.findIndex((snapPoint) => snapPoint === activeSnapPoint) ?? null, [snapPoints, activeSnapPoint]);
|
|
29
|
+
const shouldFade = (snapPoints &&
|
|
30
|
+
snapPoints.length > 0 &&
|
|
31
|
+
(fadeFromIndex || fadeFromIndex === 0) &&
|
|
32
|
+
!Number.isNaN(fadeFromIndex) &&
|
|
33
|
+
snapPoints[fadeFromIndex] === activeSnapPoint) ||
|
|
34
|
+
!snapPoints;
|
|
35
|
+
const snapPointsOffset = React.useMemo(() => {
|
|
36
|
+
const containerSize = container
|
|
37
|
+
? { width: container.getBoundingClientRect().width, height: container.getBoundingClientRect().height }
|
|
38
|
+
: typeof window !== 'undefined'
|
|
39
|
+
? { width: window.innerWidth, height: window.innerHeight }
|
|
40
|
+
: { width: 0, height: 0 };
|
|
41
|
+
return (snapPoints?.map((snapPoint) => {
|
|
42
|
+
const isPx = typeof snapPoint === 'string';
|
|
43
|
+
let snapPointAsNumber = 0;
|
|
44
|
+
if (isPx) {
|
|
45
|
+
snapPointAsNumber = parseInt(snapPoint, 10);
|
|
46
|
+
}
|
|
47
|
+
if (isVertical(direction)) {
|
|
48
|
+
const height = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.height : 0;
|
|
49
|
+
if (windowDimensions) {
|
|
50
|
+
return direction === 'bottom' ? containerSize.height - height : -containerSize.height + height;
|
|
51
|
+
}
|
|
52
|
+
return height;
|
|
53
|
+
}
|
|
54
|
+
const width = isPx ? snapPointAsNumber : windowDimensions ? snapPoint * containerSize.width : 0;
|
|
55
|
+
if (windowDimensions) {
|
|
56
|
+
return direction === 'right' ? containerSize.width - width : -containerSize.width + width;
|
|
57
|
+
}
|
|
58
|
+
return width;
|
|
59
|
+
}) ?? []);
|
|
60
|
+
}, [snapPoints, windowDimensions, container, direction]);
|
|
61
|
+
const activeSnapPointOffset = React.useMemo(() => (activeSnapPointIndex !== null ? snapPointsOffset?.[activeSnapPointIndex] : null), [snapPointsOffset, activeSnapPointIndex]);
|
|
62
|
+
const snapToPoint = React.useCallback((dimension) => {
|
|
63
|
+
const newSnapPointIndex = snapPointsOffset?.findIndex((snapPointDim) => snapPointDim === dimension) ?? null;
|
|
64
|
+
onSnapPointChange(newSnapPointIndex);
|
|
65
|
+
set(drawerRef.current, {
|
|
66
|
+
transition: `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
67
|
+
transform: isVertical(direction) ? `translate3d(0, ${dimension}px, 0)` : `translate3d(${dimension}px, 0, 0)`,
|
|
68
|
+
});
|
|
69
|
+
if (snapPointsOffset &&
|
|
70
|
+
newSnapPointIndex !== snapPointsOffset.length - 1 &&
|
|
71
|
+
fadeFromIndex !== undefined &&
|
|
72
|
+
newSnapPointIndex !== fadeFromIndex &&
|
|
73
|
+
newSnapPointIndex < fadeFromIndex) {
|
|
74
|
+
set(overlayRef.current, {
|
|
75
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
76
|
+
opacity: '0',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
set(overlayRef.current, {
|
|
81
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
82
|
+
opacity: '1',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
setActiveSnapPoint(snapPoints?.[Math.max(newSnapPointIndex, 0)]);
|
|
86
|
+
}, [drawerRef, snapPoints, snapPointsOffset, fadeFromIndex, overlayRef, setActiveSnapPoint]);
|
|
87
|
+
React.useEffect(() => {
|
|
88
|
+
if (activeSnapPoint || activeSnapPointProp) {
|
|
89
|
+
const newIndex = snapPoints?.findIndex((snapPoint) => snapPoint === activeSnapPointProp || snapPoint === activeSnapPoint) ?? -1;
|
|
90
|
+
if (snapPointsOffset && newIndex !== -1 && typeof snapPointsOffset[newIndex] === 'number') {
|
|
91
|
+
snapToPoint(snapPointsOffset[newIndex]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, [activeSnapPoint, activeSnapPointProp, snapPoints, snapPointsOffset, snapToPoint]);
|
|
95
|
+
function onRelease({ draggedDistance, closeDrawer, velocity, dismissible, }) {
|
|
96
|
+
if (fadeFromIndex === undefined)
|
|
97
|
+
return;
|
|
98
|
+
const currentPosition = direction === 'bottom' || direction === 'right'
|
|
99
|
+
? (activeSnapPointOffset ?? 0) - draggedDistance
|
|
100
|
+
: (activeSnapPointOffset ?? 0) + draggedDistance;
|
|
101
|
+
const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
|
|
102
|
+
const isFirst = activeSnapPointIndex === 0;
|
|
103
|
+
const hasDraggedUp = draggedDistance > 0;
|
|
104
|
+
if (isOverlaySnapPoint) {
|
|
105
|
+
set(overlayRef.current, {
|
|
106
|
+
transition: `opacity ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if (!snapToSequentialPoint && velocity > 2 && !hasDraggedUp) {
|
|
110
|
+
if (dismissible)
|
|
111
|
+
closeDrawer();
|
|
112
|
+
else
|
|
113
|
+
snapToPoint(snapPointsOffset[0]); // snap to initial point
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (!snapToSequentialPoint && velocity > 2 && hasDraggedUp && snapPointsOffset && snapPoints) {
|
|
117
|
+
snapToPoint(snapPointsOffset[snapPoints.length - 1]);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
// Find the closest snap point to the current position
|
|
121
|
+
const closestSnapPoint = snapPointsOffset?.reduce((prev, curr) => {
|
|
122
|
+
if (typeof prev !== 'number' || typeof curr !== 'number')
|
|
123
|
+
return prev;
|
|
124
|
+
return Math.abs(curr - currentPosition) < Math.abs(prev - currentPosition) ? curr : prev;
|
|
125
|
+
});
|
|
126
|
+
const dim = isVertical(direction) ? window.innerHeight : window.innerWidth;
|
|
127
|
+
if (velocity > VELOCITY_THRESHOLD && Math.abs(draggedDistance) < dim * 0.4) {
|
|
128
|
+
const dragDirection = hasDraggedUp ? 1 : -1; // 1 = up, -1 = down
|
|
129
|
+
// Don't do anything if we swipe upwards while being on the last snap point
|
|
130
|
+
if (dragDirection > 0 && isLastSnapPoint && snapPoints) {
|
|
131
|
+
snapToPoint(snapPointsOffset[snapPoints.length - 1]);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (isFirst && dragDirection < 0 && dismissible) {
|
|
135
|
+
closeDrawer();
|
|
136
|
+
}
|
|
137
|
+
if (activeSnapPointIndex === null)
|
|
138
|
+
return;
|
|
139
|
+
snapToPoint(snapPointsOffset[activeSnapPointIndex + dragDirection]);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
snapToPoint(closestSnapPoint);
|
|
143
|
+
}
|
|
144
|
+
function onDrag({ draggedDistance }) {
|
|
145
|
+
if (activeSnapPointOffset === null)
|
|
146
|
+
return;
|
|
147
|
+
const newValue = direction === 'bottom' || direction === 'right'
|
|
148
|
+
? activeSnapPointOffset - draggedDistance
|
|
149
|
+
: activeSnapPointOffset + draggedDistance;
|
|
150
|
+
// Don't do anything if we exceed the last(biggest) snap point
|
|
151
|
+
if ((direction === 'bottom' || direction === 'right') && newValue < snapPointsOffset[snapPointsOffset.length - 1]) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if ((direction === 'top' || direction === 'left') && newValue > snapPointsOffset[snapPointsOffset.length - 1]) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
set(drawerRef.current, {
|
|
158
|
+
transform: isVertical(direction) ? `translate3d(0, ${newValue}px, 0)` : `translate3d(${newValue}px, 0, 0)`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function getPercentageDragged(absDraggedDistance, isDraggingDown) {
|
|
162
|
+
if (!snapPoints || typeof activeSnapPointIndex !== 'number' || !snapPointsOffset || fadeFromIndex === undefined)
|
|
163
|
+
return null;
|
|
164
|
+
// If this is true we are dragging to a snap point that is supposed to have an overlay
|
|
165
|
+
const isOverlaySnapPoint = activeSnapPointIndex === fadeFromIndex - 1;
|
|
166
|
+
const isOverlaySnapPointOrHigher = activeSnapPointIndex >= fadeFromIndex;
|
|
167
|
+
if (isOverlaySnapPointOrHigher && isDraggingDown) {
|
|
168
|
+
return 0;
|
|
169
|
+
}
|
|
170
|
+
// Don't animate, but still use this one if we are dragging away from the overlaySnapPoint
|
|
171
|
+
if (isOverlaySnapPoint && !isDraggingDown)
|
|
172
|
+
return 1;
|
|
173
|
+
if (!shouldFade && !isOverlaySnapPoint)
|
|
174
|
+
return null;
|
|
175
|
+
// Either fadeFrom index or the one before
|
|
176
|
+
const targetSnapPointIndex = isOverlaySnapPoint ? activeSnapPointIndex + 1 : activeSnapPointIndex - 1;
|
|
177
|
+
// Get the distance from overlaySnapPoint to the one before or vice-versa to calculate the opacity percentage accordingly
|
|
178
|
+
const snapPointDistance = isOverlaySnapPoint
|
|
179
|
+
? snapPointsOffset[targetSnapPointIndex] - snapPointsOffset[targetSnapPointIndex - 1]
|
|
180
|
+
: snapPointsOffset[targetSnapPointIndex + 1] - snapPointsOffset[targetSnapPointIndex];
|
|
181
|
+
const percentageDragged = absDraggedDistance / Math.abs(snapPointDistance);
|
|
182
|
+
if (isOverlaySnapPoint) {
|
|
183
|
+
return 1 - percentageDragged;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return percentageDragged;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return {
|
|
190
|
+
isLastSnapPoint,
|
|
191
|
+
activeSnapPoint,
|
|
192
|
+
shouldFade,
|
|
193
|
+
getPercentageDragged,
|
|
194
|
+
setActiveSnapPoint,
|
|
195
|
+
activeSnapPointIndex,
|
|
196
|
+
onRelease,
|
|
197
|
+
onDrag,
|
|
198
|
+
snapPointsOffset,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalBody.d.ts","sourceRoot":"","sources":["../../../src/react-components/Modal/ModalBody.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ModalBody.d.ts","sourceRoot":"","sources":["../../../src/react-components/Modal/ModalBody.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAGpD,wBAAgB,SAAS,CAAC,CAAC,EAAE,eAAe,2CA4B3C"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { use, useEffect, useRef } from "react";
|
|
4
4
|
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
-
import { FRAMER_MOTION_DURATION } from "../../configs";
|
|
6
5
|
import { ModalContext } from "./ModalContext";
|
|
6
|
+
import { FRAMER_MOTION_DURATION } from "../../configs";
|
|
7
7
|
export function ModalBody(p) {
|
|
8
8
|
const { isOpen } = use(ModalContext);
|
|
9
9
|
const bodyRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OtpRoot.d.ts","sourceRoot":"","sources":["../../../src/react-components/Otp/OtpRoot.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"OtpRoot.d.ts","sourceRoot":"","sources":["../../../src/react-components/Otp/OtpRoot.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,wBAAgB,OAAO,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,aAAa,2CAsBzD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef } from "react";
|
|
4
|
-
import { AccessNavigation } from "../AccessNavigation/AccessNavigation";
|
|
5
4
|
import { OtpContext } from "./OtpContext";
|
|
5
|
+
import { AccessNavigation } from "../AccessNavigation/AccessNavigation";
|
|
6
6
|
export function OtpRoot({ autoFocus, ...p }) {
|
|
7
7
|
const inputs = useRef([]);
|
|
8
8
|
useEffect(() => {
|
|
@@ -13,5 +13,5 @@ export function OtpRoot({ autoFocus, ...p }) {
|
|
|
13
13
|
const getInputsValue = () => {
|
|
14
14
|
return inputs?.current.map((input) => input?.value || "").join("") || "";
|
|
15
15
|
};
|
|
16
|
-
return (_jsx(OtpContext, { value: { inputs, getInputsValue }, children: _jsx(AccessNavigation, { direction: "x", ...p }) }));
|
|
16
|
+
return (_jsx(OtpContext, { value: { inputs, getInputsValue }, children: _jsx(AccessNavigation, { dir: "ltr", direction: "x", ...p }) }));
|
|
17
17
|
}
|
|
@@ -4,7 +4,7 @@ export type OtpContextT = {
|
|
|
4
4
|
inputs?: RefObject<(HTMLInputElement | null)[]>;
|
|
5
5
|
getInputsValue: () => string;
|
|
6
6
|
};
|
|
7
|
-
export type OtpRootPropsT = Omit<AccessNavigationPropsT, "direction"> & {
|
|
7
|
+
export type OtpRootPropsT = Omit<AccessNavigationPropsT, "direction" | "dir"> & {
|
|
8
8
|
autoFocus?: boolean;
|
|
9
9
|
};
|
|
10
10
|
export type OtpInputsPropsT = ComponentProps<"input"> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otpTypes.d.ts","sourceRoot":"","sources":["../../../src/react-components/Otp/otpTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,sBAAsB,EAAE,WAAW,CAAC,GAAG;
|
|
1
|
+
{"version":3,"file":"otpTypes.d.ts","sourceRoot":"","sources":["../../../src/react-components/Otp/otpTypes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC,gBAAgB,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAChD,cAAc,EAAE,MAAM,MAAM,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,sBAAsB,EAAE,WAAW,GAAG,KAAK,CAAC,GAAG;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG;IACtD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DrawerSheetBody } from "./DrawerSheetBody";
|
|
2
|
+
import { DrawerSheetRoot } from "./DrawerSheetRoot";
|
|
3
|
+
import { DrawerSheetHeader } from "./DrawerSheetHeader";
|
|
4
|
+
import { DrawerSheetPortal } from "./DrawerSheetPortal";
|
|
5
|
+
import { DrawerSheetToggle } from "./DrawerSheetToggle";
|
|
6
|
+
import { DrawerSheetContent } from "./DrawerSheetContent";
|
|
7
|
+
import { DrawerSheetHandlebar } from "./DrawerSheetHandlebar";
|
|
8
|
+
import { DrawerSheetProvider } from "./DrawerSheetProvider";
|
|
9
|
+
import { DrawerSheetViewport } from "./DrawerSheetViewport";
|
|
10
|
+
import { DrawerSheetBackdrop } from "./DrawerSheetBackdrop";
|
|
11
|
+
export declare const DrawerSheet: typeof DrawerSheetRoot & {
|
|
12
|
+
Provider: typeof DrawerSheetProvider;
|
|
13
|
+
Portal: typeof DrawerSheetPortal;
|
|
14
|
+
Viewport: typeof DrawerSheetViewport;
|
|
15
|
+
Backdrop: typeof DrawerSheetBackdrop;
|
|
16
|
+
Body: typeof DrawerSheetBody;
|
|
17
|
+
Header: typeof DrawerSheetHeader;
|
|
18
|
+
Handlebar: typeof DrawerSheetHandlebar;
|
|
19
|
+
Content: typeof DrawerSheetContent;
|
|
20
|
+
Toggle: typeof DrawerSheetToggle;
|
|
21
|
+
};
|
|
22
|
+
export * from "./drawerSheetTypes";
|
|
23
|
+
//# sourceMappingURL=DrawerSheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheet.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,WAAW;;;;;;;;;;CAUtB,CAAC;AAEH,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DrawerSheetBody } from "./DrawerSheetBody";
|
|
2
|
+
import { DrawerSheetRoot } from "./DrawerSheetRoot";
|
|
3
|
+
import { DrawerSheetHeader } from "./DrawerSheetHeader";
|
|
4
|
+
import { DrawerSheetPortal } from "./DrawerSheetPortal";
|
|
5
|
+
import { DrawerSheetToggle } from "./DrawerSheetToggle";
|
|
6
|
+
import { DrawerSheetContent } from "./DrawerSheetContent";
|
|
7
|
+
import { DrawerSheetHandlebar } from "./DrawerSheetHandlebar";
|
|
8
|
+
import { DrawerSheetProvider } from "./DrawerSheetProvider";
|
|
9
|
+
import { DrawerSheetViewport } from "./DrawerSheetViewport";
|
|
10
|
+
import { DrawerSheetBackdrop } from "./DrawerSheetBackdrop";
|
|
11
|
+
export const DrawerSheet = Object.assign(DrawerSheetRoot, {
|
|
12
|
+
Provider: DrawerSheetProvider,
|
|
13
|
+
Portal: DrawerSheetPortal,
|
|
14
|
+
Viewport: DrawerSheetViewport,
|
|
15
|
+
Backdrop: DrawerSheetBackdrop,
|
|
16
|
+
Body: DrawerSheetBody,
|
|
17
|
+
Header: DrawerSheetHeader,
|
|
18
|
+
Handlebar: DrawerSheetHandlebar,
|
|
19
|
+
Content: DrawerSheetContent,
|
|
20
|
+
Toggle: DrawerSheetToggle,
|
|
21
|
+
});
|
|
22
|
+
export * from "./drawerSheetTypes";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetBackdrop.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetBackdrop.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,yBAAyB,2CAwB/D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
import { ClientOnly } from "../ClientOnly/ClientOnly";
|
|
6
|
+
import { Portal } from "../Portal/Portal";
|
|
7
|
+
import { DrawerSheetContext } from "./DrawerSheetContext";
|
|
8
|
+
export function DrawerSheetBackdrop(p) {
|
|
9
|
+
const { isOpen, closeHandler: handleClose, nestedDrawerCount } = use(DrawerSheetContext);
|
|
10
|
+
// Adjust z-index based on nested drawer count
|
|
11
|
+
const zIndex = 49 + (nestedDrawerCount || 0);
|
|
12
|
+
return (_jsx(ClientOnly, { children: _jsx(Portal, { children: _jsx(AnimatePresence, { children: isOpen ? (_jsx(motion.div, { onClick: handleClose, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, style: { zIndex }, ...p })) : null }) }) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetBody.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetBody.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,wBAAgB,eAAe,CAAC,EAAE,aAAa,EAAE,GAAG,CAAC,EAAE,EAAE,qBAAqB,2CAsN7E"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { use, useEffect, useRef, useLayoutEffect, useState } from "react";
|
|
4
|
+
import { motion, useDragControls, AnimatePresence } from "framer-motion";
|
|
5
|
+
import { FRAMER_MOTION_DURATION } from "../../configs";
|
|
6
|
+
import { DrawerSheetContext } from "./DrawerSheetContext";
|
|
7
|
+
export function DrawerSheetBody({ onPointerDown, ...p }) {
|
|
8
|
+
const controls = useDragControls();
|
|
9
|
+
const { isOpen, y, x, closeHandler: handleClose, position, swipeDirection, drawerId, hasNestedDrawer, nestedDrawerCount, frontmostHeight, updateDrawerHeight } = use(DrawerSheetContext);
|
|
10
|
+
const bodyRef = useRef(null);
|
|
11
|
+
// Measure and update drawer height
|
|
12
|
+
useLayoutEffect(() => {
|
|
13
|
+
if (!isOpen || !bodyRef.current)
|
|
14
|
+
return;
|
|
15
|
+
const measureHeight = () => {
|
|
16
|
+
const element = bodyRef.current;
|
|
17
|
+
if (!element)
|
|
18
|
+
return;
|
|
19
|
+
const height = element.offsetHeight;
|
|
20
|
+
setDrawerHeight(height);
|
|
21
|
+
updateDrawerHeight?.(drawerId, height);
|
|
22
|
+
};
|
|
23
|
+
measureHeight();
|
|
24
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
25
|
+
const resizeObserver = new ResizeObserver(measureHeight);
|
|
26
|
+
resizeObserver.observe(bodyRef.current);
|
|
27
|
+
return () => resizeObserver.disconnect();
|
|
28
|
+
}
|
|
29
|
+
}, [isOpen, drawerId, updateDrawerHeight]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (isOpen) {
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
const focusableElement = bodyRef.current?.querySelector("[data-drawer-sheet='focus']");
|
|
34
|
+
focusableElement?.focus();
|
|
35
|
+
}, FRAMER_MOTION_DURATION);
|
|
36
|
+
}
|
|
37
|
+
}, [isOpen]);
|
|
38
|
+
// Determine drag direction and initial/exit values based on position
|
|
39
|
+
const getDragDirection = () => {
|
|
40
|
+
if (position === "top" || position === "bottom")
|
|
41
|
+
return "y";
|
|
42
|
+
return "x";
|
|
43
|
+
};
|
|
44
|
+
const getInitialValue = () => {
|
|
45
|
+
if (position === "top")
|
|
46
|
+
return "-100%";
|
|
47
|
+
if (position === "bottom")
|
|
48
|
+
return "100%";
|
|
49
|
+
if (position === "left")
|
|
50
|
+
return "-100%";
|
|
51
|
+
if (position === "right")
|
|
52
|
+
return "100%";
|
|
53
|
+
return "100%";
|
|
54
|
+
};
|
|
55
|
+
const getExitValue = () => {
|
|
56
|
+
return getInitialValue();
|
|
57
|
+
};
|
|
58
|
+
const getStyleValue = () => {
|
|
59
|
+
if (position === "top" || position === "bottom")
|
|
60
|
+
return y;
|
|
61
|
+
return x;
|
|
62
|
+
};
|
|
63
|
+
const getPositionStyles = () => {
|
|
64
|
+
const baseStyles = {};
|
|
65
|
+
if (position === "top") {
|
|
66
|
+
baseStyles.top = 0;
|
|
67
|
+
baseStyles.left = 0;
|
|
68
|
+
baseStyles.right = 0;
|
|
69
|
+
baseStyles.width = "100%";
|
|
70
|
+
baseStyles.height = "auto";
|
|
71
|
+
baseStyles.maxHeight = "90vh";
|
|
72
|
+
}
|
|
73
|
+
else if (position === "bottom") {
|
|
74
|
+
baseStyles.bottom = 0;
|
|
75
|
+
baseStyles.left = 0;
|
|
76
|
+
baseStyles.right = 0;
|
|
77
|
+
baseStyles.width = "100%";
|
|
78
|
+
baseStyles.height = "auto";
|
|
79
|
+
baseStyles.maxHeight = "90vh";
|
|
80
|
+
}
|
|
81
|
+
else if (position === "left") {
|
|
82
|
+
baseStyles.top = 0;
|
|
83
|
+
baseStyles.bottom = 0;
|
|
84
|
+
baseStyles.left = 0;
|
|
85
|
+
baseStyles.width = "clamp(300px, 30vw, 400px)";
|
|
86
|
+
baseStyles.height = "100%";
|
|
87
|
+
}
|
|
88
|
+
else if (position === "right") {
|
|
89
|
+
baseStyles.top = 0;
|
|
90
|
+
baseStyles.bottom = 0;
|
|
91
|
+
baseStyles.right = 0;
|
|
92
|
+
baseStyles.width = "clamp(300px, 30vw, 400px)";
|
|
93
|
+
baseStyles.height = "100%";
|
|
94
|
+
}
|
|
95
|
+
return baseStyles;
|
|
96
|
+
};
|
|
97
|
+
const dragDirection = getDragDirection();
|
|
98
|
+
const initialValue = getInitialValue();
|
|
99
|
+
const exitValue = getExitValue();
|
|
100
|
+
const styleValue = getStyleValue();
|
|
101
|
+
const positionStyles = getPositionStyles();
|
|
102
|
+
const getDragConstraints = () => {
|
|
103
|
+
if (dragDirection === "y") {
|
|
104
|
+
return {
|
|
105
|
+
top: 0,
|
|
106
|
+
bottom: 0,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
left: 0,
|
|
111
|
+
right: 0,
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
const getDragElastic = () => {
|
|
115
|
+
if (position === "top") {
|
|
116
|
+
return { top: 0.5, bottom: 0 };
|
|
117
|
+
}
|
|
118
|
+
if (position === "bottom") {
|
|
119
|
+
return { top: 0, bottom: 0.5 };
|
|
120
|
+
}
|
|
121
|
+
if (position === "left") {
|
|
122
|
+
return { left: 0.5, right: 0 };
|
|
123
|
+
}
|
|
124
|
+
if (position === "right") {
|
|
125
|
+
return { left: 0, right: 0.5 };
|
|
126
|
+
}
|
|
127
|
+
return { top: 0, bottom: 0.5 };
|
|
128
|
+
};
|
|
129
|
+
const handleDragEnd = () => {
|
|
130
|
+
const currentValue = styleValue?.get() || 0;
|
|
131
|
+
const threshold = 100;
|
|
132
|
+
if ((position === "bottom" && currentValue >= threshold) ||
|
|
133
|
+
(position === "top" && currentValue <= -threshold) ||
|
|
134
|
+
(position === "right" && currentValue >= threshold) ||
|
|
135
|
+
(position === "left" && currentValue <= -threshold)) {
|
|
136
|
+
handleClose();
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
// Adjust z-index based on nested drawer count
|
|
140
|
+
const zIndex = 50 + (nestedDrawerCount || 0);
|
|
141
|
+
// Track drawer height for CSS variable
|
|
142
|
+
const [drawerHeight, setDrawerHeight] = useState(0);
|
|
143
|
+
return (_jsx(AnimatePresence, { children: isOpen ? (_jsx(motion.div, { id: `drawer-sheet-${drawerId}`, ref: bodyRef, onClick: (ev) => ev.stopPropagation(), "data-nested-drawer-open": hasNestedDrawer ? "" : undefined, initial: dragDirection === "y"
|
|
144
|
+
? { y: initialValue }
|
|
145
|
+
: { x: initialValue }, animate: dragDirection === "y"
|
|
146
|
+
? { y: 0 }
|
|
147
|
+
: { x: 0 }, exit: dragDirection === "y"
|
|
148
|
+
? { y: exitValue }
|
|
149
|
+
: { x: exitValue }, style: {
|
|
150
|
+
...positionStyles,
|
|
151
|
+
[dragDirection === "y" ? "y" : "x"]: styleValue,
|
|
152
|
+
zIndex,
|
|
153
|
+
// CSS variables for nested drawer styling
|
|
154
|
+
["--nested-drawers"]: nestedDrawerCount,
|
|
155
|
+
["--drawer-height"]: drawerHeight > 0 ? `${drawerHeight}px` : "auto",
|
|
156
|
+
["--drawer-frontmost-height"]: frontmostHeight > 0 ? `${frontmostHeight}px` : undefined,
|
|
157
|
+
}, drag: dragDirection, dragListener: false, dragControls: controls, onPointerDown: (ev) => {
|
|
158
|
+
ev.stopPropagation();
|
|
159
|
+
controls?.start(ev);
|
|
160
|
+
onPointerDown?.(ev);
|
|
161
|
+
}, transition: {
|
|
162
|
+
ease: "easeInOut",
|
|
163
|
+
duration: FRAMER_MOTION_DURATION
|
|
164
|
+
}, onDragEnd: handleDragEnd, dragConstraints: getDragConstraints(), dragElastic: getDragElastic(), ...p })) : null }));
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetContent.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetContent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEnE,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,EAAE,EAAE,wBAAwB,2CAmBrF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export function DrawerSheetContent({ style, onScroll, ...p }) {
|
|
4
|
+
return (_jsx("div", { style: {
|
|
5
|
+
touchAction: "pan-down",
|
|
6
|
+
...style,
|
|
7
|
+
}, onScroll: (ev) => {
|
|
8
|
+
if (ev.currentTarget.scrollTop > 0) {
|
|
9
|
+
ev.currentTarget.style.touchAction = "pan-y";
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
ev.currentTarget.style.touchAction = "pan-down";
|
|
13
|
+
}
|
|
14
|
+
onScroll?.(ev);
|
|
15
|
+
}, ...p }));
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetContext.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,eAAO,MAAM,kBAAkB,8CAAgE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetHandlebar.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetHandlebar.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,0BAA0B,2CAExE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetHeader.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetHeader.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,uBAAuB,2CAElE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetPortal.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetPortal.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAElE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,uBAAuB,2CAyB3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { use } from "react";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
import { ClientOnly } from "../ClientOnly/ClientOnly";
|
|
6
|
+
import { Portal } from "../Portal/Portal";
|
|
7
|
+
import { DrawerSheetContext } from "./DrawerSheetContext";
|
|
8
|
+
export function DrawerSheetPortal(p) {
|
|
9
|
+
const { isOpen, closeHandler: handleClose, scope, nestedDrawerCount } = use(DrawerSheetContext);
|
|
10
|
+
// Adjust z-index based on nested drawer count
|
|
11
|
+
const zIndex = 49 + (nestedDrawerCount || 0);
|
|
12
|
+
return (_jsx(ClientOnly, { children: _jsx(Portal, { children: _jsx(AnimatePresence, { children: isOpen ? (_jsx(motion.div, { ref: scope, onClick: handleClose, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, style: { zIndex }, ...p })) : null }) }) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type DrawerSheetProviderContextT = {
|
|
2
|
+
registerDrawer: (id: string, isOpen: boolean, height?: number) => void;
|
|
3
|
+
unregisterDrawer: (id: string) => void;
|
|
4
|
+
updateDrawerHeight: (id: string, height: number) => void;
|
|
5
|
+
hasOpenDrawer: boolean;
|
|
6
|
+
nestedDrawerCount: number;
|
|
7
|
+
frontmostHeight: number;
|
|
8
|
+
getDrawerHeight: (id: string) => number | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare function DrawerSheetProvider({ children }: {
|
|
11
|
+
children: React.ReactNode;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare function useDrawerSheetProvider(): DrawerSheetProviderContextT | null;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=DrawerSheetProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DrawerSheetProvider.d.ts","sourceRoot":"","sources":["../../../src/react-components/drawer-sheet/DrawerSheetProvider.tsx"],"names":[],"mappings":"AAIA,KAAK,2BAA2B,GAAG;IACjC,cAAc,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACvE,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,kBAAkB,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzD,aAAa,EAAE,OAAO,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CACrD,CAAC;AASF,wBAAgB,mBAAmB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAiF9E;AAED,wBAAgB,sBAAsB,uCAGrC"}
|