@underverse-ui/underverse 1.0.31 → 1.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/index.js CHANGED
@@ -18849,16 +18849,14 @@ var LoadingBar = ({
18849
18849
  // ../../components/ui/OverlayScrollbarProvider.tsx
18850
18850
  import { useEffect as useEffect28 } from "react";
18851
18851
  import { OverlayScrollbars } from "overlayscrollbars";
18852
- var EXPLICIT_SCROLLABLE_SELECTOR = [".thin-scrollbar", ".scrollbar-thin", ".custom-scrollbar", "[data-os-scrollbar]"].join(", ");
18853
- var GENERIC_SCROLLABLE_SELECTOR = [
18854
- ".overflow-auto",
18855
- ".overflow-x-auto",
18856
- ".overflow-y-auto",
18857
- ".overflow-scroll",
18858
- ".overflow-x-scroll",
18859
- ".overflow-y-scroll"
18852
+ var EXPLICIT_SELECTOR = [".thin-scrollbar", ".scrollbar-thin", ".custom-scrollbar", "[data-os-scrollbar]"].join(", ");
18853
+ var PORTAL_EXCLUDE_SELECTOR = [
18854
+ "[data-radix-portal]",
18855
+ "[role='dialog']",
18856
+ "[aria-modal='true']",
18857
+ "[data-sonner-toaster]"
18860
18858
  ].join(", ");
18861
- var SCROLLBAR_OPTIONS = {
18859
+ var OPTIONS = {
18862
18860
  scrollbars: {
18863
18861
  theme: "os-theme-underverse",
18864
18862
  visibility: "auto",
@@ -18868,42 +18866,27 @@ var SCROLLBAR_OPTIONS = {
18868
18866
  clickScroll: false
18869
18867
  }
18870
18868
  };
18869
+ function shouldSkip(element) {
18870
+ if (element === document.body || element === document.documentElement) return true;
18871
+ if (element.hasAttribute("data-os-ignore")) return true;
18872
+ if (element.hasAttribute("data-overlayscrollbars")) return true;
18873
+ if (element.closest(PORTAL_EXCLUDE_SELECTOR)) return true;
18874
+ return false;
18875
+ }
18871
18876
  function OverlayScrollbarProvider() {
18872
18877
  useEffect28(() => {
18873
- const bodyInstance = OverlayScrollbars(document.body, SCROLLBAR_OPTIONS);
18874
18878
  const instances = /* @__PURE__ */ new Map();
18875
- const shouldSkip = (element) => {
18876
- if (element === document.body) return true;
18877
- if (element.hasAttribute("data-os-ignore")) return true;
18878
- if (element.hasAttribute("data-overlayscrollbars")) return true;
18879
- return false;
18880
- };
18881
- const initElement = (element) => {
18879
+ let rafId = 0;
18880
+ const init = (element) => {
18882
18881
  if (shouldSkip(element)) return;
18883
18882
  if (instances.has(element)) return;
18884
- instances.set(element, OverlayScrollbars(element, SCROLLBAR_OPTIONS));
18885
- };
18886
- const collectCandidates = (root, selector) => {
18887
- const candidates = [];
18888
- if (root instanceof HTMLElement && root.matches(selector)) {
18889
- candidates.push(root);
18890
- }
18891
- if ("querySelectorAll" in root) {
18892
- root.querySelectorAll(selector).forEach((element) => {
18893
- candidates.push(element);
18894
- });
18895
- }
18896
- return candidates.filter((element, index) => candidates.indexOf(element) === index);
18883
+ instances.set(element, OverlayScrollbars(element, OPTIONS));
18897
18884
  };
18898
18885
  const scan = (root) => {
18899
- const explicitCandidates = collectCandidates(root, EXPLICIT_SCROLLABLE_SELECTOR).filter((element) => !shouldSkip(element));
18900
- explicitCandidates.forEach(initElement);
18901
- const genericCandidates = collectCandidates(root, GENERIC_SCROLLABLE_SELECTOR).filter((element) => !shouldSkip(element));
18902
- const filteredGeneric = genericCandidates.filter(
18903
- (element) => !explicitCandidates.some((explicit) => explicit === element || explicit.contains(element) || element.contains(explicit))
18904
- );
18905
- const leafGeneric = filteredGeneric.filter((element) => !filteredGeneric.some((other) => other !== element && element.contains(other)));
18906
- leafGeneric.forEach(initElement);
18886
+ if (root instanceof HTMLElement && root.matches(EXPLICIT_SELECTOR)) {
18887
+ init(root);
18888
+ }
18889
+ root.querySelectorAll(EXPLICIT_SELECTOR).forEach(init);
18907
18890
  };
18908
18891
  const cleanup = () => {
18909
18892
  instances.forEach((instance, element) => {
@@ -18914,14 +18897,13 @@ function OverlayScrollbarProvider() {
18914
18897
  });
18915
18898
  };
18916
18899
  scan(document.body);
18917
- let rafId = 0;
18918
18900
  const observer = new MutationObserver((mutations) => {
18919
18901
  if (rafId) return;
18920
- rafId = window.requestAnimationFrame(() => {
18902
+ rafId = requestAnimationFrame(() => {
18921
18903
  rafId = 0;
18922
18904
  const scanRoots = /* @__PURE__ */ new Set();
18923
18905
  mutations.forEach((mutation) => {
18924
- if (mutation.target instanceof Element || mutation.target instanceof Document || mutation.target instanceof DocumentFragment) {
18906
+ if (mutation.target instanceof HTMLElement || mutation.target instanceof Document || mutation.target instanceof DocumentFragment) {
18925
18907
  scanRoots.add(mutation.target);
18926
18908
  }
18927
18909
  mutation.addedNodes.forEach((node) => {
@@ -18934,16 +18916,17 @@ function OverlayScrollbarProvider() {
18934
18916
  cleanup();
18935
18917
  });
18936
18918
  });
18937
- observer.observe(document.body, { childList: true, subtree: true });
18919
+ observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ["class"] });
18938
18920
  return () => {
18939
- if (rafId) window.cancelAnimationFrame(rafId);
18921
+ if (rafId) cancelAnimationFrame(rafId);
18940
18922
  observer.disconnect();
18941
18923
  instances.forEach((instance) => instance.destroy());
18942
- bodyInstance.destroy();
18924
+ instances.clear();
18943
18925
  };
18944
18926
  }, []);
18945
18927
  return null;
18946
18928
  }
18929
+ var OverlayScrollbarProvider_default = OverlayScrollbarProvider;
18947
18930
 
18948
18931
  // ../../components/ui/Table.tsx
18949
18932
  import React55 from "react";
@@ -24912,7 +24895,7 @@ export {
24912
24895
  NotificationModal_default as NotificationModal,
24913
24896
  NumberInput,
24914
24897
  OverlayControls,
24915
- OverlayScrollbarProvider,
24898
+ OverlayScrollbarProvider_default as OverlayScrollbarProvider,
24916
24899
  PageLoading,
24917
24900
  Pagination,
24918
24901
  PasswordInput,