@voxel51/voodo 0.0.31 → 0.0.32
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/components/Drawer/Drawer.d.ts +3 -47
- package/dist/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1829 -1816
- package/dist/index.js.map +1 -1
- package/dist/util/useResizableDrawer.d.ts +23 -45
- package/dist/util/useResizableDrawer.d.ts.map +1 -1
- package/dist/voodo.css +1 -1
- package/package.json +1 -1
|
@@ -2,68 +2,46 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { UseDisclosureOptions, UseDisclosureReturn } from './useDisclosure';
|
|
3
3
|
import { DragAxis } from './useDragDelta';
|
|
4
4
|
export type { DragAxis };
|
|
5
|
-
/**
|
|
6
|
-
* Options for {@link useResizableDrawer}.
|
|
7
|
-
*
|
|
8
|
-
* Extends {@link UseDisclosureOptions} so the drawer's open state can be
|
|
9
|
-
* controlled or uncontrolled in the same way as {@link useDisclosure}.
|
|
10
|
-
*/
|
|
11
5
|
export interface UseResizableDrawerOptions extends UseDisclosureOptions {
|
|
12
6
|
/** Axis the drawer resizes along. `"horizontal"` for left/right drawers, `"vertical"` for top/bottom. */
|
|
13
7
|
axis: DragAxis;
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/** Maximum drawer size in pixels. */
|
|
8
|
+
/**
|
|
9
|
+
* Maximum content-area size in pixels. The header and handle are excluded —
|
|
10
|
+
* `maxSize` caps only the scrollable body region.
|
|
11
|
+
*/
|
|
19
12
|
maxSize: number;
|
|
20
|
-
/** Size at which a drag triggers close. Defaults to 0. */
|
|
21
|
-
closeThreshold?: number;
|
|
22
13
|
/** Flip the delta sign — use for right-side and bottom-side handles. */
|
|
23
14
|
invert?: boolean;
|
|
24
|
-
/** Invoked with the new size on every drag-induced resize
|
|
15
|
+
/** Invoked with the new content-area size on every drag-induced resize. */
|
|
25
16
|
onSizeChange?: (size: number) => void;
|
|
26
17
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Return value of {@link useResizableDrawer}. Extends {@link UseDisclosureReturn}
|
|
29
|
-
* with size and drag state.
|
|
30
|
-
*/
|
|
31
18
|
export interface UseResizableDrawerReturn extends UseDisclosureReturn {
|
|
32
|
-
/** Current
|
|
19
|
+
/** Current content-area size in pixels (0 when closed or not yet measured). */
|
|
33
20
|
size: number;
|
|
34
21
|
/** `true` while the user is actively dragging the resize handle. */
|
|
35
22
|
isDragging: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* `true` only when the current size change should be animated — i.e. an
|
|
25
|
+
* open/close toggle. Content-driven resizes and drags are instant (`false`),
|
|
26
|
+
* so the size snaps and doesn't fight the header's un-animated layout change.
|
|
27
|
+
*/
|
|
28
|
+
animating: boolean;
|
|
36
29
|
/** Props to spread onto the drag handle element. */
|
|
37
30
|
dragHandleProps: {
|
|
38
31
|
onPointerDown: (e: React.PointerEvent<HTMLElement>) => void;
|
|
39
32
|
onPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
|
|
40
33
|
onPointerUp: () => void;
|
|
41
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* Attach the size-bearing wrapper's `onTransitionEnd` to this so `animating`
|
|
37
|
+
* clears when the open/close transition completes.
|
|
38
|
+
*/
|
|
39
|
+
onTransitionEnd: () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Attach to the content element. The hook observes it via ResizeObserver and
|
|
42
|
+
* keeps the open size equal to `min(contentHeight, maxSize)` automatically.
|
|
43
|
+
*/
|
|
44
|
+
contentRef: (el: HTMLElement | null) => void;
|
|
42
45
|
}
|
|
43
|
-
|
|
44
|
-
* Hook which models a drawer that can be opened, closed, and resized by
|
|
45
|
-
* dragging a handle.
|
|
46
|
-
*
|
|
47
|
-
* Behavior:
|
|
48
|
-
* - Dragging below `closeThreshold` (default `0`) closes the drawer.
|
|
49
|
-
* - Dragging above `closeThreshold` while closed reopens the drawer.
|
|
50
|
-
* - Sizes are clamped to `[minSize, maxSize]` while open.
|
|
51
|
-
* - `toggle()` restores the last dragged size when reopening.
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```tsx
|
|
55
|
-
* const { open, size, toggle, dragHandleProps } = useResizableDrawer({
|
|
56
|
-
* axis: "horizontal",
|
|
57
|
-
* defaultSize: 320,
|
|
58
|
-
* minSize: 200,
|
|
59
|
-
* maxSize: 600,
|
|
60
|
-
* });
|
|
61
|
-
* return (
|
|
62
|
-
* <aside style={{ width: open ? size : 0 }}>
|
|
63
|
-
* <div {...dragHandleProps} />
|
|
64
|
-
* </aside>
|
|
65
|
-
* );
|
|
66
|
-
* ```
|
|
67
|
-
*/
|
|
68
|
-
export declare function useResizableDrawer({ axis, defaultSize, minSize, maxSize, closeThreshold, invert, onSizeChange, ...disclosureOptions }: UseResizableDrawerOptions): UseResizableDrawerReturn;
|
|
46
|
+
export declare function useResizableDrawer({ axis, maxSize, invert, onSizeChange, ...disclosureOptions }: UseResizableDrawerOptions): UseResizableDrawerReturn;
|
|
69
47
|
//# sourceMappingURL=useResizableDrawer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizableDrawer.d.ts","sourceRoot":"","sources":["../../src/util/useResizableDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useResizableDrawer.d.ts","sourceRoot":"","sources":["../../src/util/useResizableDrawer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAyD,MAAM,OAAO,CAAC;AAE9E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AAIxD,YAAY,EAAE,QAAQ,EAAE,CAAC;AAEzB,MAAM,WAAW,yBAA0B,SAAQ,oBAAoB;IACrE,yGAAyG;IACzG,IAAI,EAAE,QAA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