base-vaul 1.1.0 → 1.2.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/dist/index.d.mts CHANGED
@@ -31,11 +31,9 @@ interface WithoutFadeFromProps {
31
31
  snapPoints?: (number | string)[];
32
32
  fadeFromIndex?: never;
33
33
  }
34
- type DialogProps = {
34
+ type DialogProps = Dialog.Root.Props & {
35
35
  activeSnapPoint?: number | string | null;
36
36
  setActiveSnapPoint?: (snapPoint: number | string | null) => void;
37
- children?: React.ReactNode;
38
- open?: boolean;
39
37
  /**
40
38
  * Number between 0 and 1 that determines when the drawer should be closed.
41
39
  * Example: threshold of 0.5 would close the drawer if the user swiped for 50% of the height of the drawer or more.
@@ -75,11 +73,6 @@ type DialogProps = {
75
73
  dismissible?: boolean;
76
74
  onDrag?: (event: BaseUIMouseEvent, percentageDragged: number) => void;
77
75
  onRelease?: (event: BaseUIMouseEvent, open: boolean) => void;
78
- /**
79
- * When `false` it allows to interact with elements outside of the drawer without closing it.
80
- * @default true
81
- */
82
- modal?: boolean;
83
76
  nested?: boolean;
84
77
  onClose?: () => void;
85
78
  /**
@@ -87,11 +80,6 @@ type DialogProps = {
87
80
  * @default 'bottom'
88
81
  */
89
82
  direction?: "top" | "bottom" | "left" | "right";
90
- /**
91
- * Opened by default, skips initial enter animation. Still reacts to `open` state changes
92
- * @default false
93
- */
94
- defaultOpen?: boolean;
95
83
  /**
96
84
  * When set to `true` prevents scrolling on the document body on mount, and restores it on unmount.
97
85
  * @default false
@@ -111,17 +99,13 @@ type DialogProps = {
111
99
  */
112
100
  snapToSequentialPoint?: boolean;
113
101
  container?: HTMLElement | null;
114
- /**
115
- * 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.
116
- * Useful to revert any state changes for example.
117
- */
118
- onAnimationEnd?: (open: boolean) => void;
119
102
  preventScrollRestoration?: boolean;
120
103
  autoFocus?: boolean;
121
104
  } & (WithFadeFromProps | WithoutFadeFromProps);
122
105
  declare function Root({
123
106
  open: openProp,
124
107
  onOpenChange,
108
+ onOpenChangeComplete,
125
109
  children,
126
110
  onDrag: onDragProp,
127
111
  onRelease: onReleaseProp,
@@ -146,7 +130,6 @@ declare function Root({
146
130
  snapToSequentialPoint,
147
131
  preventScrollRestoration,
148
132
  repositionInputs,
149
- onAnimationEnd,
150
133
  container,
151
134
  autoFocus
152
135
  }: DialogProps): react_jsx_runtime0.JSX.Element;
package/dist/index.mjs CHANGED
@@ -663,17 +663,21 @@ function usePositionFixed({ isOpen, modal, nested, hasBeenOpened, preventScrollR
663
663
 
664
664
  //#endregion
665
665
  //#region src/index.tsx
666
- function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = "bottom", defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
666
+ function Root({ open: openProp, onOpenChange, onOpenChangeComplete, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = "bottom", defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, container, autoFocus = false }) {
667
+ const isModal = modal === true || modal === "trap-focus";
667
668
  const [isOpen = false, setIsOpen] = useControllableState({
668
669
  defaultProp: defaultOpen,
669
670
  prop: openProp,
670
671
  onChange: (o) => {
671
- onOpenChange?.(o);
672
+ onOpenChange?.(o, {
673
+ reason: "none",
674
+ preventUnmountOnClose: () => {}
675
+ });
672
676
  if (!o && !nested) restorePositionSetting();
673
677
  setTimeout(() => {
674
- onAnimationEnd?.(o);
678
+ onOpenChangeComplete?.(o);
675
679
  }, TRANSITIONS.DURATION * 1e3);
676
- if (o && !modal) {
680
+ if (o && !isModal) {
677
681
  if (typeof window !== "undefined") window.requestAnimationFrame(() => {
678
682
  document.body.style.pointerEvents = "auto";
679
683
  });
@@ -713,10 +717,10 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
713
717
  container,
714
718
  snapToSequentialPoint
715
719
  });
716
- usePreventScroll({ isDisabled: !isOpen || isDragging || !modal || justReleased || !hasBeenOpened || !repositionInputs || !disablePreventScroll });
720
+ usePreventScroll({ isDisabled: !isOpen || isDragging || !isModal || justReleased || !hasBeenOpened || !repositionInputs || !disablePreventScroll });
717
721
  const { restorePositionSetting } = usePositionFixed({
718
722
  isOpen,
719
- modal,
723
+ modal: isModal,
720
724
  nested: nested ?? false,
721
725
  hasBeenOpened,
722
726
  preventScrollRestoration,
@@ -996,10 +1000,10 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
996
1000
  });
997
1001
  }
998
1002
  React.useEffect(() => {
999
- if (!modal) window.requestAnimationFrame(() => {
1003
+ if (!isModal) window.requestAnimationFrame(() => {
1000
1004
  document.body.style.pointerEvents = "auto";
1001
1005
  });
1002
- }, [modal]);
1006
+ }, [isModal]);
1003
1007
  return /* @__PURE__ */ jsx(Dialog.Root, {
1004
1008
  defaultOpen,
1005
1009
  onOpenChange: (open) => {
@@ -1010,6 +1014,7 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
1010
1014
  },
1011
1015
  open: isOpen,
1012
1016
  modal,
1017
+ onOpenChangeComplete,
1013
1018
  children: /* @__PURE__ */ jsx(DrawerContext.Provider, {
1014
1019
  value: {
1015
1020
  activeSnapPoint,
@@ -1032,7 +1037,7 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
1032
1037
  onNestedOpenChange,
1033
1038
  onNestedRelease,
1034
1039
  keyboardIsOpen,
1035
- modal,
1040
+ modal: isModal,
1036
1041
  snapPointsOffset,
1037
1042
  activeSnapPointIndex,
1038
1043
  direction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "base-vaul",
3
- "version": "1.1.0",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -49,8 +49,8 @@
49
49
  "turbo": "2.6.3",
50
50
  "typescript": "5.9.2",
51
51
  "unplugin-lightningcss": "^0.4.3",
52
- "@repo/eslint-config": "0.0.1",
53
- "@repo/typescript-config": "0.0.0"
52
+ "@repo/typescript-config": "0.0.0",
53
+ "@repo/eslint-config": "0.0.1"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc",