colibri-ui 0.8.86 → 0.8.87

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/Drawer/Drawer.js CHANGED
@@ -34,17 +34,23 @@ const Drawer = /*#__PURE__*/React.forwardRef(function DrawerRoot(_a, forwardedRe
34
34
  focusAfterRef,
35
35
  portalContainer,
36
36
  onClose,
37
+ onClosed,
37
38
  onEscKeyDown,
38
39
  onOverlayClick,
39
40
  className,
40
41
  style,
41
42
  children
42
43
  } = _a,
43
- rest = tslib.__rest(_a, ["opened", "placement", "width", "height", "offset", "zIndex", "asModal", "withBlur", "closeOnEsc", "closeOnOverlayClick", "borderRadius", "customBackgroundColor", "customContentBackgroundColor", "animationInfo", "initialFocusRef", "focusAfterRef", "portalContainer", "onClose", "onEscKeyDown", "onOverlayClick", "className", "style", "children"]);
44
+ rest = tslib.__rest(_a, ["opened", "placement", "width", "height", "offset", "zIndex", "asModal", "withBlur", "closeOnEsc", "closeOnOverlayClick", "borderRadius", "customBackgroundColor", "customContentBackgroundColor", "animationInfo", "initialFocusRef", "focusAfterRef", "portalContainer", "onClose", "onClosed", "onEscKeyDown", "onOverlayClick", "className", "style", "children"]);
44
45
  const panelRef = React.useRef(null);
45
46
  const previousFocus = React.useRef(null);
46
47
  const [rendered, setRendered] = React.useState(opened);
47
48
  const [closing, setClosing] = React.useState(false);
49
+ // The latest callback without restarting the closing timer.
50
+ const onClosedRef = React.useRef(onClosed);
51
+ React.useEffect(() => {
52
+ onClosedRef.current = onClosed;
53
+ }, [onClosed]);
48
54
  const setPanelRef = element => {
49
55
  panelRef.current = element;
50
56
  if (typeof forwardedRef === "function") forwardedRef(element);else if (forwardedRef) forwardedRef.current = element;
@@ -58,8 +64,10 @@ const Drawer = /*#__PURE__*/React.forwardRef(function DrawerRoot(_a, forwardedRe
58
64
  if (!rendered) return;
59
65
  setClosing(true);
60
66
  const timeout = window.setTimeout(() => {
67
+ var _a;
61
68
  setRendered(false);
62
69
  setClosing(false);
70
+ (_a = onClosedRef.current) === null || _a === void 0 ? void 0 : _a.call(onClosedRef);
63
71
  }, 200);
64
72
  return () => window.clearTimeout(timeout);
65
73
  }, [opened, rendered]);
@@ -24,6 +24,8 @@ export interface DrawerProps extends Omit<HTMLAttributes<HTMLDivElement>, "onAni
24
24
  focusAfterRef?: RefObject<HTMLElement | null>;
25
25
  portalContainer?: HTMLElement | null;
26
26
  onClose?: () => void;
27
+ /** Called once the closing animation has finished and the drawer is removed. */
28
+ onClosed?: () => void;
27
29
  onEscKeyDown?: (event: KeyboardEvent) => void;
28
30
  onOverlayClick?: MouseEventHandler<HTMLDivElement>;
29
31
  }
package/Sheet/Sheet.js CHANGED
@@ -32,6 +32,7 @@ const Sheet = /*#__PURE__*/React.forwardRef(function SheetComponent(_a, forwarde
32
32
  var {
33
33
  open,
34
34
  onOpenChange,
35
+ onClosed,
35
36
  title,
36
37
  description,
37
38
  header,
@@ -58,7 +59,7 @@ const Sheet = /*#__PURE__*/React.forwardRef(function SheetComponent(_a, forwarde
58
59
  "aria-labelledby": ariaLabelledBy,
59
60
  "aria-describedby": ariaDescribedBy
60
61
  } = _a,
61
- rest = tslib.__rest(_a, ["open", "onOpenChange", "title", "description", "header", "footer", "snapPoints", "snapPoint", "defaultSnapPoint", "onSnapPointChange", "modal", "blurOverlay", "closeOnOverlayClick", "closeOnEscape", "draggable", "showHandle", "lockBodyScroll", "portalContainer", "initialFocusRef", "returnFocusRef", "zIndex", "className", "style", "children", "aria-label", "aria-labelledby", "aria-describedby"]);
62
+ rest = tslib.__rest(_a, ["open", "onOpenChange", "onClosed", "title", "description", "header", "footer", "snapPoints", "snapPoint", "defaultSnapPoint", "onSnapPointChange", "modal", "blurOverlay", "closeOnOverlayClick", "closeOnEscape", "draggable", "showHandle", "lockBodyScroll", "portalContainer", "initialFocusRef", "returnFocusRef", "zIndex", "className", "style", "children", "aria-label", "aria-labelledby", "aria-describedby"]);
62
63
  const normalizedPoints = snapPoints.length ? snapPoints : defaultSnapPoints;
63
64
  const controlledSnap = snapPoint !== undefined;
64
65
  const [internalSnap, setInternalSnap] = React.useState(() => findPoint(normalizedPoints, defaultSnapPoint));
@@ -88,6 +89,11 @@ const Sheet = /*#__PURE__*/React.forwardRef(function SheetComponent(_a, forwarde
88
89
  if (!controlledSnap) setInternalSnap(next);
89
90
  onSnapPointChange === null || onSnapPointChange === void 0 ? void 0 : onSnapPointChange(next);
90
91
  };
92
+ // The latest callback without restarting the closing timer.
93
+ const onClosedRef = React.useRef(onClosed);
94
+ React.useEffect(() => {
95
+ onClosedRef.current = onClosed;
96
+ }, [onClosed]);
91
97
  React.useEffect(() => {
92
98
  if (open) {
93
99
  setRendered(true);
@@ -98,8 +104,10 @@ const Sheet = /*#__PURE__*/React.forwardRef(function SheetComponent(_a, forwarde
98
104
  setClosing(true);
99
105
  const duration = panelRef.current ? Number.parseFloat(getComputedStyle(panelRef.current).animationDuration) * 1000 : 220;
100
106
  const timer = window.setTimeout(() => {
107
+ var _a;
101
108
  setRendered(false);
102
109
  setClosing(false);
110
+ (_a = onClosedRef.current) === null || _a === void 0 ? void 0 : _a.call(onClosedRef);
103
111
  }, Number.isFinite(duration) ? duration : 220);
104
112
  return () => window.clearTimeout(timer);
105
113
  }, [open, rendered]);
@@ -4,6 +4,8 @@ export type SheetCloseReason = "overlay" | "escape" | "drag";
4
4
  export interface SheetProps extends Omit<HTMLAttributes<HTMLDivElement>, "title" | "onChange"> {
5
5
  open: boolean;
6
6
  onOpenChange: (open: boolean, reason?: SheetCloseReason) => void;
7
+ /** Called once the closing animation has finished and the sheet is removed. */
8
+ onClosed?: () => void;
7
9
  title?: ReactNode;
8
10
  description?: ReactNode;
9
11
  header?: ReactNode;