@luscii-healthtech/web-ui 44.3.2 → 44.3.4

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.
@@ -4781,12 +4781,51 @@ const Switch = (props) => {
4781
4781
  }), children: jsxRuntime.jsx(RadixSwitch__namespace.Thumb, { className: classNames__default.default("ui:h-[20px] ui:w-[20px]", "ui:bg-white", "ui:transition-transform ui:duration-100 ui:will-change-transform", "ui:translate-x-1 ui:data-[state=checked]:translate-x-[32px]", "ui:block ui:rounded-full") }) });
4782
4782
  };
4783
4783
 
4784
+ const useOnCloseAnimationFinished = ({
4785
+ /**
4786
+ * Reference to the dialog element
4787
+ */
4788
+ dialog,
4789
+ /**
4790
+ * Whether the dialog is open or closed
4791
+ */
4792
+ open,
4793
+ /**
4794
+ * Callback fired when the close transition has finished
4795
+ */
4796
+ onCloseAnimationFinished
4797
+ }) => {
4798
+ const debouncedOnCloseAnimationFinished = React.useCallback(debounce__default.default(onCloseAnimationFinished, 150), [onCloseAnimationFinished]);
4799
+ const onTransitionEnd = React.useCallback((event) => {
4800
+ if (event.target !== dialog.current) {
4801
+ return;
4802
+ }
4803
+ if (!open) {
4804
+ debouncedOnCloseAnimationFinished();
4805
+ }
4806
+ }, [open, debouncedOnCloseAnimationFinished]);
4807
+ React.useEffect(() => {
4808
+ const transitionStopEvents = ["transitioncancel", "transitionend"];
4809
+ transitionStopEvents.forEach((event) => {
4810
+ var _a;
4811
+ (_a = dialog.current) === null || _a === void 0 ? void 0 : _a.addEventListener(event, onTransitionEnd);
4812
+ });
4813
+ return () => {
4814
+ transitionStopEvents.forEach((event) => {
4815
+ var _a;
4816
+ (_a = dialog.current) === null || _a === void 0 ? void 0 : _a.removeEventListener(event, onTransitionEnd);
4817
+ });
4818
+ };
4819
+ }, [open, onTransitionEnd]);
4820
+ };
4821
+
4784
4822
  const context$3 = React.createContext({
4785
4823
  $dialog: null
4786
4824
  });
4787
4825
  const useModalDialog = () => React.useContext(context$3);
4788
4826
  const ModalDialog = (_a) => {
4789
- var { open, className, size, onClose, children, variant = "centered-dialog", keepChildrenMountedWhenClosed = false } = _a, rest = __rest(_a, ["open", "className", "size", "onClose", "children", "variant", "keepChildrenMountedWhenClosed"]);
4827
+ var { open, className, size, onClose, children, variant = "centered-dialog", keepChildrenMountedWhenClosed = false, onCloseAnimationFinished = () => {
4828
+ } } = _a, rest = __rest(_a, ["open", "className", "size", "onClose", "children", "variant", "keepChildrenMountedWhenClosed", "onCloseAnimationFinished"]);
4790
4829
  const dialog = React.useRef(null);
4791
4830
  const transitionsClasses = classNames__default.default("ui:transition-discrete ui:transition-[display,overlay,opacity,scale,translate] ui:duration-[300ms] ui:motion-reduce:duration-[0ms] ui:delay-100", "ui:backdrop:transition-[display,overlay,opacity] ui:backdrop:duration-[300ms] ui:motion-reduce:backdrop:duration-[0ms] ui:delay-0", "ui:opacity-0 ui:open:starting:opacity-0", "ui:open:opacity-100", "ui:backdrop:opacity-0 ui:open:backdrop:starting:opacity-0", "ui:open:backdrop:opacity-100", {
4792
4831
  "ui:translate-y-[-5px] ui:open:starting:translate-y-[-5px] ui:open:translate-y-0": variant !== "side-modal",
@@ -4815,6 +4854,7 @@ const ModalDialog = (_a) => {
4815
4854
  "ui:w-screen ui:h-screen": variant === "full-screen",
4816
4855
  "ui:max-w-screen ui:max-h-screen": variant === "full-screen"
4817
4856
  }, transitionsClasses, className);
4857
+ useOnCloseAnimationFinished({ dialog, open, onCloseAnimationFinished });
4818
4858
  React.useEffect(() => {
4819
4859
  var _a2, _b;
4820
4860
  if (open) {