@seed-design/react-drawer 1.0.0 → 1.0.1
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/lib/Drawer-12s-BXSK15mB.cjs +1453 -0
- package/lib/Drawer-12s-CAlIg6sU.js +1420 -0
- package/lib/index.cjs +27 -0
- package/lib/index.d.ts +211 -0
- package/lib/index.js +17 -0
- package/package.json +1 -1
package/lib/index.cjs
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var Drawer12s = require('./Drawer-12s-BXSK15mB.cjs');
|
|
2
|
+
|
|
3
|
+
var Drawer_namespace = {
|
|
4
|
+
__proto__: null,
|
|
5
|
+
Backdrop: Drawer12s.DrawerBackdrop,
|
|
6
|
+
CloseButton: Drawer12s.DrawerCloseButton,
|
|
7
|
+
Content: Drawer12s.DrawerContent,
|
|
8
|
+
Description: Drawer12s.DrawerDescription,
|
|
9
|
+
Handle: Drawer12s.DrawerHandle,
|
|
10
|
+
Positioner: Drawer12s.DrawerPositioner,
|
|
11
|
+
Root: Drawer12s.DrawerRoot,
|
|
12
|
+
Title: Drawer12s.DrawerTitle,
|
|
13
|
+
Trigger: Drawer12s.DrawerTrigger
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.DrawerBackdrop = Drawer12s.DrawerBackdrop;
|
|
17
|
+
exports.DrawerCloseButton = Drawer12s.DrawerCloseButton;
|
|
18
|
+
exports.DrawerContent = Drawer12s.DrawerContent;
|
|
19
|
+
exports.DrawerDescription = Drawer12s.DrawerDescription;
|
|
20
|
+
exports.DrawerHandle = Drawer12s.DrawerHandle;
|
|
21
|
+
exports.DrawerPositioner = Drawer12s.DrawerPositioner;
|
|
22
|
+
exports.DrawerRoot = Drawer12s.DrawerRoot;
|
|
23
|
+
exports.DrawerTitle = Drawer12s.DrawerTitle;
|
|
24
|
+
exports.DrawerTrigger = Drawer12s.DrawerTrigger;
|
|
25
|
+
exports.useDrawer = Drawer12s.useDrawer;
|
|
26
|
+
exports.useDrawerContext = Drawer12s.useDrawerContext;
|
|
27
|
+
exports.Drawer = Drawer_namespace;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
3
|
+
import { PrimitiveProps } from '@seed-design/react-primitive';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
|
|
6
|
+
interface DialogProps {
|
|
7
|
+
activeSnapPoint?: number | string | null;
|
|
8
|
+
setActiveSnapPoint?: (snapPoint: number | string | null) => void;
|
|
9
|
+
children?: React.ReactNode;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Number between 0 and 1 that determines when the drawer should be closed.
|
|
13
|
+
* Example: threshold of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.
|
|
14
|
+
* @default 0.25
|
|
15
|
+
*/
|
|
16
|
+
closeThreshold?: number;
|
|
17
|
+
/**
|
|
18
|
+
* When `true` the `body` doesn't get any styles assigned from Vaul
|
|
19
|
+
*/
|
|
20
|
+
noBodyStyles?: boolean;
|
|
21
|
+
onOpenChange?: (open: boolean) => void;
|
|
22
|
+
/**
|
|
23
|
+
* Duration for which the drawer is not draggable after scrolling content inside of the drawer.
|
|
24
|
+
* @default 500ms
|
|
25
|
+
*/
|
|
26
|
+
scrollLockTimeout?: number;
|
|
27
|
+
/**
|
|
28
|
+
* When `true`, don't move the drawer upwards if there's space, but rather only change it's height so it's fully scrollable when the keyboard is open
|
|
29
|
+
*/
|
|
30
|
+
fixed?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* When `true` only allows the drawer to be dragged by the `<Drawer.Handle />` component.
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
handleOnly?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* When `false` dragging, clicking outside, pressing esc, etc. will not close the drawer.
|
|
38
|
+
* Use this in comination with the `open` prop, otherwise you won't be able to open/close the drawer.
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
dismissible?: boolean;
|
|
42
|
+
onDrag?: (event: React.PointerEvent<HTMLDivElement>, percentageDragged: number) => void;
|
|
43
|
+
onRelease?: (event: React.PointerEvent<HTMLDivElement>, open: boolean) => void;
|
|
44
|
+
/**
|
|
45
|
+
* When `false` it allows to interact with elements outside of the drawer without closing it.
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
modal?: boolean;
|
|
49
|
+
nested?: boolean;
|
|
50
|
+
onClose?: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Direction of the drawer. Can be `top` or `bottom`, `left`, `right`.
|
|
53
|
+
* @default 'bottom'
|
|
54
|
+
*/
|
|
55
|
+
direction?: "top" | "bottom" | "left" | "right";
|
|
56
|
+
/**
|
|
57
|
+
* Opened by default, skips initial enter animation. Still reacts to `open` state changes
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
defaultOpen?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* When set to `true` prevents scrolling on the document body on mount, and restores it on unmount.
|
|
63
|
+
* @default false
|
|
64
|
+
*/
|
|
65
|
+
disablePreventScroll?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* When `true` Vaul will reposition inputs rather than scroll then into view if the keyboard is in the way.
|
|
68
|
+
* Setting it to `false` will fall back to the default browser behavior.
|
|
69
|
+
* @default true when {@link snapPoints} is defined
|
|
70
|
+
*/
|
|
71
|
+
repositionInputs?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Disabled velocity based swiping for snap points.
|
|
74
|
+
* This means that a snap point won't be skipped even if the velocity is high enough.
|
|
75
|
+
* Useful if each snap point in a drawer is equally important.
|
|
76
|
+
* @default false
|
|
77
|
+
*/
|
|
78
|
+
snapToSequentialPoint?: boolean;
|
|
79
|
+
container?: HTMLElement | null;
|
|
80
|
+
/**
|
|
81
|
+
* Gets triggered after the open or close animation ends, it receives an `open` argument with the `open` state of the drawer by the time the function was triggered.
|
|
82
|
+
* Useful to revert any state changes for example.
|
|
83
|
+
*/
|
|
84
|
+
onAnimationEnd?: (open: boolean) => void;
|
|
85
|
+
preventScrollRestoration?: boolean;
|
|
86
|
+
autoFocus?: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Array of snap points to use.
|
|
89
|
+
* Example: snapPoints={[0, 100, 200]} will use the first snap point at 0px, the second at 100px, and the third at 200px.
|
|
90
|
+
* @default undefined
|
|
91
|
+
*/
|
|
92
|
+
snapPoints?: (number | string)[];
|
|
93
|
+
/**
|
|
94
|
+
* Index of the snap point to start fading from.
|
|
95
|
+
* Example: fadeFromIndex={0} will start fading from the first snap point.
|
|
96
|
+
* @default snapPoints.length - 1
|
|
97
|
+
*/
|
|
98
|
+
fadeFromIndex?: number;
|
|
99
|
+
/**
|
|
100
|
+
* Whether to close the drawer when interacting outside of the drawer.
|
|
101
|
+
* @default true
|
|
102
|
+
*/
|
|
103
|
+
closeOnInteractOutside?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether to close the drawer when pressing the escape key.
|
|
106
|
+
* @default true
|
|
107
|
+
*/
|
|
108
|
+
closeOnEscape?: boolean;
|
|
109
|
+
}
|
|
110
|
+
declare function useDrawer(props: DialogProps): {
|
|
111
|
+
activeSnapPoint: string | number | null;
|
|
112
|
+
snapPoints: (string | number)[] | undefined;
|
|
113
|
+
setActiveSnapPoint: (value: react.SetStateAction<string | number | null>) => void;
|
|
114
|
+
drawerRef: react.RefObject<HTMLDivElement | null>;
|
|
115
|
+
overlayRef: react.RefObject<HTMLDivElement | null>;
|
|
116
|
+
shouldOverlayAnimate: boolean;
|
|
117
|
+
onOpenChange: ((open: boolean) => void) | undefined;
|
|
118
|
+
onPress: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
119
|
+
onRelease: (event: React.PointerEvent<HTMLDivElement> | null) => void;
|
|
120
|
+
onDrag: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
121
|
+
dismissible: boolean;
|
|
122
|
+
shouldAnimate: react.RefObject<boolean>;
|
|
123
|
+
handleOnly: boolean;
|
|
124
|
+
isOpen: boolean;
|
|
125
|
+
isDragging: boolean;
|
|
126
|
+
shouldFade: boolean;
|
|
127
|
+
closeDrawer: (fromWithin?: boolean) => void;
|
|
128
|
+
keyboardIsOpen: react.RefObject<boolean>;
|
|
129
|
+
modal: boolean;
|
|
130
|
+
snapPointsOffset: number[];
|
|
131
|
+
activeSnapPointIndex: number | null;
|
|
132
|
+
direction: "top" | "bottom" | "left" | "right";
|
|
133
|
+
noBodyStyles: boolean;
|
|
134
|
+
container: HTMLElement | null | undefined;
|
|
135
|
+
autoFocus: boolean;
|
|
136
|
+
setHasBeenOpened: react.Dispatch<react.SetStateAction<boolean>>;
|
|
137
|
+
setIsOpen: (value: react.SetStateAction<boolean>) => void;
|
|
138
|
+
closeOnInteractOutside: boolean;
|
|
139
|
+
closeOnEscape: boolean;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
interface DrawerRootProps extends DialogProps {
|
|
143
|
+
children?: react.ReactNode;
|
|
144
|
+
}
|
|
145
|
+
declare const DrawerRoot: (props: DrawerRootProps) => react_jsx_runtime.JSX.Element;
|
|
146
|
+
interface DrawerTriggerProps extends DialogPrimitive.DialogTriggerProps {
|
|
147
|
+
}
|
|
148
|
+
declare const DrawerTrigger: react.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & react.RefAttributes<HTMLButtonElement>>;
|
|
149
|
+
interface DrawerPositionerProps extends PrimitiveProps, react.HTMLAttributes<HTMLDivElement> {
|
|
150
|
+
}
|
|
151
|
+
declare const DrawerPositioner: react.ForwardRefExoticComponent<DrawerPositionerProps & react.RefAttributes<HTMLDivElement>>;
|
|
152
|
+
interface DrawerBackdropProps extends DialogPrimitive.DialogOverlayProps, react.HTMLAttributes<HTMLDivElement> {
|
|
153
|
+
}
|
|
154
|
+
declare const DrawerBackdrop: react.ForwardRefExoticComponent<DrawerBackdropProps & react.RefAttributes<HTMLDivElement>>;
|
|
155
|
+
interface DrawerContentProps extends DialogPrimitive.DialogContentProps, react.HTMLAttributes<HTMLDivElement> {
|
|
156
|
+
}
|
|
157
|
+
declare const DrawerContent: react.ForwardRefExoticComponent<DrawerContentProps & react.RefAttributes<HTMLDivElement>>;
|
|
158
|
+
interface DrawerTitleProps extends DialogPrimitive.DialogTitleProps {
|
|
159
|
+
}
|
|
160
|
+
declare const DrawerTitle: react.ForwardRefExoticComponent<DialogPrimitive.DialogTitleProps & react.RefAttributes<HTMLHeadingElement>>;
|
|
161
|
+
interface DrawerDescriptionProps extends DialogPrimitive.DialogDescriptionProps {
|
|
162
|
+
}
|
|
163
|
+
declare const DrawerDescription: react.ForwardRefExoticComponent<DialogPrimitive.DialogDescriptionProps & react.RefAttributes<HTMLParagraphElement>>;
|
|
164
|
+
interface DrawerCloseButtonProps extends DialogPrimitive.DialogCloseProps {
|
|
165
|
+
}
|
|
166
|
+
declare const DrawerCloseButton: react.ForwardRefExoticComponent<DrawerCloseButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
167
|
+
interface DrawerHandleProps extends react.HTMLAttributes<HTMLDivElement> {
|
|
168
|
+
preventCycle?: boolean;
|
|
169
|
+
}
|
|
170
|
+
declare const DrawerHandle: react.ForwardRefExoticComponent<DrawerHandleProps & react.RefAttributes<HTMLDivElement>>;
|
|
171
|
+
|
|
172
|
+
type DrawerContextValue = ReturnType<typeof useDrawer>;
|
|
173
|
+
declare function useDrawerContext(): {
|
|
174
|
+
activeSnapPoint: string | number | null;
|
|
175
|
+
snapPoints: (string | number)[] | undefined;
|
|
176
|
+
setActiveSnapPoint: (value: react.SetStateAction<string | number | null>) => void;
|
|
177
|
+
drawerRef: react.RefObject<HTMLDivElement | null>;
|
|
178
|
+
overlayRef: react.RefObject<HTMLDivElement | null>;
|
|
179
|
+
shouldOverlayAnimate: boolean;
|
|
180
|
+
onOpenChange: ((open: boolean) => void) | undefined;
|
|
181
|
+
onPress: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
182
|
+
onRelease: (event: React.PointerEvent<HTMLDivElement> | null) => void;
|
|
183
|
+
onDrag: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
184
|
+
dismissible: boolean;
|
|
185
|
+
shouldAnimate: react.RefObject<boolean>;
|
|
186
|
+
handleOnly: boolean;
|
|
187
|
+
isOpen: boolean;
|
|
188
|
+
isDragging: boolean;
|
|
189
|
+
shouldFade: boolean;
|
|
190
|
+
closeDrawer: (fromWithin?: boolean) => void;
|
|
191
|
+
keyboardIsOpen: react.RefObject<boolean>;
|
|
192
|
+
modal: boolean;
|
|
193
|
+
snapPointsOffset: number[];
|
|
194
|
+
activeSnapPointIndex: number | null;
|
|
195
|
+
direction: "top" | "bottom" | "left" | "right";
|
|
196
|
+
noBodyStyles: boolean;
|
|
197
|
+
container: HTMLElement | null | undefined;
|
|
198
|
+
autoFocus: boolean;
|
|
199
|
+
setHasBeenOpened: react.Dispatch<react.SetStateAction<boolean>>;
|
|
200
|
+
setIsOpen: (value: react.SetStateAction<boolean>) => void;
|
|
201
|
+
closeOnInteractOutside: boolean;
|
|
202
|
+
closeOnEscape: boolean;
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
declare namespace Drawer_namespace {
|
|
206
|
+
export { DrawerBackdrop as Backdrop, DrawerCloseButton as CloseButton, DrawerContent as Content, DrawerDescription as Description, DrawerHandle as Handle, DrawerPositioner as Positioner, DrawerRoot as Root, DrawerTitle as Title, DrawerTrigger as Trigger };
|
|
207
|
+
export type { DrawerBackdropProps as BackdropProps, DrawerCloseButtonProps as CloseButtonProps, DrawerContentProps as ContentProps, DrawerDescriptionProps as DescriptionProps, DrawerHandleProps as HandleProps, DrawerPositionerProps as PositionerProps, DrawerRootProps as RootProps, DrawerTitleProps as TitleProps, DrawerTriggerProps as TriggerProps };
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { Drawer_namespace as Drawer, DrawerBackdrop, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerHandle, DrawerPositioner, DrawerRoot, DrawerTitle, DrawerTrigger, useDrawer, useDrawerContext };
|
|
211
|
+
export type { DialogProps, DrawerBackdropProps, DrawerCloseButtonProps, DrawerContentProps, DrawerContextValue, DrawerDescriptionProps, DrawerHandleProps, DrawerPositionerProps, DrawerRootProps, DrawerTitleProps, DrawerTriggerProps };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { D as DrawerBackdrop, a as DrawerCloseButton, b as DrawerContent, c as DrawerDescription, d as DrawerHandle, e as DrawerPositioner, f as DrawerRoot, g as DrawerTitle, h as DrawerTrigger } from './Drawer-12s-CAlIg6sU.js';
|
|
2
|
+
export { u as useDrawer, i as useDrawerContext } from './Drawer-12s-CAlIg6sU.js';
|
|
3
|
+
|
|
4
|
+
var Drawer_namespace = {
|
|
5
|
+
__proto__: null,
|
|
6
|
+
Backdrop: DrawerBackdrop,
|
|
7
|
+
CloseButton: DrawerCloseButton,
|
|
8
|
+
Content: DrawerContent,
|
|
9
|
+
Description: DrawerDescription,
|
|
10
|
+
Handle: DrawerHandle,
|
|
11
|
+
Positioner: DrawerPositioner,
|
|
12
|
+
Root: DrawerRoot,
|
|
13
|
+
Title: DrawerTitle,
|
|
14
|
+
Trigger: DrawerTrigger
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Drawer_namespace as Drawer, DrawerBackdrop, DrawerCloseButton, DrawerContent, DrawerDescription, DrawerHandle, DrawerPositioner, DrawerRoot, DrawerTitle, DrawerTrigger };
|