@sohanemon/utils 7.2.6 → 7.2.8
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/README.md +9 -2
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.cts +47 -8
- package/dist/components/index.d.ts +47 -8
- package/dist/components/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -185,12 +185,14 @@ const { scrolledPast, direction } = useScrollTracker({ threshold: 300 });
|
|
|
185
185
|
```
|
|
186
186
|
|
|
187
187
|
#### UI Components
|
|
188
|
-
|
|
189
188
|
```tsx
|
|
190
|
-
import { HtmlInjector, ResponsiveIndicator, Iconify } from '@sohanemon/utils';
|
|
189
|
+
import { HtmlInjector, ResponsiveIndicator, Portal, Iconify } from '@sohanemon/utils';
|
|
191
190
|
|
|
192
191
|
<HtmlInjector html="<p>Injected HTML</p>" />
|
|
193
192
|
<ResponsiveIndicator />
|
|
193
|
+
<Portal container="#modal-root">
|
|
194
|
+
<Modal />
|
|
195
|
+
</Portal>
|
|
194
196
|
<Iconify icon="mdi:home" />
|
|
195
197
|
```
|
|
196
198
|
|
|
@@ -487,6 +489,11 @@ ScrollableMarker: React.Component<{
|
|
|
487
489
|
className?: string;
|
|
488
490
|
children?: React.ReactNode;
|
|
489
491
|
}>
|
|
492
|
+
|
|
493
|
+
Portal: React.Component<{
|
|
494
|
+
children: React.ReactNode;
|
|
495
|
+
container: `#${string}` | `.${string}` | `[${string}]` | React.RefObject<HTMLElement>;
|
|
496
|
+
}>
|
|
490
497
|
```
|
|
491
498
|
|
|
492
499
|
### Types
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";const e=require(`../hooks-DATf1uhM.cjs`),t=require(`../functions-BbXeio5-.cjs`);let n=require(`react`);n=e.A(n);let r=require(`react/jsx-runtime`),i=require(`@iconify/react`);function
|
|
1
|
+
"use client";const e=require(`../hooks-DATf1uhM.cjs`),t=require(`../functions-BbXeio5-.cjs`);let n=require(`react`);n=e.A(n);let r=require(`react/jsx-runtime`),i=require(`@iconify/react`),a=require(`react-dom`);function o({className:i,html:a,sanitize:o=!1,executeScripts:s=!0,...c}){let l=n.useRef([]),u=n.useRef(null);e.k(()=>{if(l.current.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),l.current=[],!(!s||!a))try{let e=document.createElement(`div`);e.innerHTML=a,e.querySelectorAll(`script`).forEach(e=>{let t=document.createElement(`script`);e.textContent&&(t.textContent=e.textContent),Array.from(e.attributes).forEach(e=>{t.setAttribute(e.name,e.value)}),t.onerror=e=>{console.error(`Script injection error:`,e)},document.body.appendChild(t),l.current.push(t)})}catch(e){console.error(`HTML injection error:`,e)}},[a,s]),n.useEffect(()=>()=>{l.current.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)})},[]);let d=n.useMemo(()=>{if(!a)return``;if(o){let e=document.createElement(`div`);e.innerHTML=a,e.querySelectorAll(`script`).forEach(e=>e.remove());let t=[`onclick`,`onload`,`onerror`,`onmouseover`];return e.querySelectorAll(`*`).forEach(e=>{t.forEach(t=>{e.hasAttribute(t)&&e.removeAttribute(t)})}),e.innerHTML}return a},[a,o]);return a?(0,r.jsx)(`div`,{ref:u,className:t.r(i),dangerouslySetInnerHTML:{__html:d},...c}):null}function s({breakpoint:t,as:i=`div`,fallback:a=n.Fragment,className:o,classNameFallback:s,...c}){let l=e.T(t.split(`-`).pop())===t.startsWith(`max`),u=l?a:i,d=l?s:o;return u===n.Fragment?(0,r.jsx)(u,{ref:c.ref,children:c.children},c.key):(0,r.jsx)(u,{className:d,...c})}function c({children:e,container:t}){let r=(0,n.useRef)(null);return r.current||=typeof t==`string`?document.querySelector(t):t.current,r.current?(0,a.createPortal)(e,r.current):null}const l=[`bottom-left`,`bottom-right`,`top-right`,`top-left`],u=({side:t,offset:i=2,unit:a=`rem`})=>{let[o,s]=n.useState(t??`bottom-left`),c=e.T({DEFAULT:`xs`,sm:`sm`,md:`md`,lg:`lg`,xl:`xl`,"2xl":`2xl`}),[u,d]=n.useState(typeof window<`u`?window.innerWidth:0);n.useEffect(()=>{if(typeof window>`u`)return;let e=()=>d(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let f=c===`2xl`&&u>=1792?a===`rem`?`${(u/16).toFixed(1)}rem`:`${u}${a}`:c,p={"bottom-left":{bottom:`${i}${a}`,left:`${i}${a}`},"bottom-right":{bottom:`${i}${a}`,right:`${i}${a}`},"top-right":{top:`${i}${a}`,right:`${i}${a}`},"top-left":{top:`${i}${a}`,left:`${i}${a}`}};return(0,r.jsx)(`button`,{type:`button`,onClick:()=>{s(l[(l.indexOf(o)+1)%l.length])},style:{position:`fixed`,zIndex:50,display:`grid`,height:`2.5rem`,minWidth:`2.5rem`,borderRadius:`30px`,placeContent:`center`,backgroundColor:`#2d3748`,fontFamily:`Courier New, Courier, monospace`,fontSize:`1rem`,color:`#ffffff`,border:`2px solid #4a5568`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)`,padding:`0.5rem`,transition:`all 0.2s ease-in-out`,...p[o]},children:f})};function d(){return e.k(()=>{let e=document.body;if(!e)return;let t=e=>{let t=getComputedStyle(e);if(t.overflow===`hidden`&&t.overflowY===`hidden`&&t.overflowX===`hidden`)return!1;let n=(t.overflowY===`auto`||t.overflowY===`scroll`)&&e.scrollHeight>e.clientHeight,r=(t.overflowX===`auto`||t.overflowX===`scroll`)&&e.scrollWidth>e.clientWidth;return n||r},n=e=>{t(e)?e.dataset.scrollable=`true`:delete e.dataset.scrollable},r=e=>{n(e);for(let t=0;t<e.children.length;t++){let n=e.children[t];r(n)}};`requestIdleCallback`in window?window.requestIdleCallback(()=>r(e)):setTimeout(()=>r(e),0);let i=new MutationObserver(e=>{for(let t of e)t.type===`childList`?t.addedNodes.forEach(e=>{e instanceof HTMLElement&&r(e)}):t.type===`attributes`&&t.target instanceof HTMLElement&&n(t.target)});return i.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`style`,`class`]}),()=>i.disconnect()},[]),null}exports.HtmlInjector=o,Object.defineProperty(exports,`Iconify`,{enumerable:!0,get:function(){return i.Icon}}),exports.MediaWrapper=s,exports.Portal=c,exports.ResponsiveIndicator=u,exports.TailwindIndicator=u,exports.ScrollTracker=e.C,exports.ScrollableMarker=d;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Icon as Iconify } from "@iconify/react";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
-
import * as React from "react";
|
|
3
|
+
import * as React$1 from "react";
|
|
4
4
|
|
|
5
5
|
//#region src/components/html-injector.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Props for the HtmlInjector component
|
|
8
8
|
*/
|
|
9
|
-
type HtmlInjectorProps = Omit<React.ComponentProps<'div'>, 'dangerouslySetInnerHTML'> & {
|
|
9
|
+
type HtmlInjectorProps = Omit<React$1.ComponentProps<'div'>, 'dangerouslySetInnerHTML'> & {
|
|
10
10
|
/** The HTML content to inject and render */
|
|
11
11
|
html: string;
|
|
12
12
|
/**
|
|
@@ -66,13 +66,13 @@ type BreakPoints = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'max-sm' | 'max-md' | 'ma
|
|
|
66
66
|
/**
|
|
67
67
|
* Props for the MediaWrapper component.
|
|
68
68
|
*/
|
|
69
|
-
type MediaWrapperProps = React.ComponentProps<'div'> & {
|
|
69
|
+
type MediaWrapperProps = React$1.ComponentProps<'div'> & {
|
|
70
70
|
/** The breakpoint at which to switch between the main component and fallback. */
|
|
71
71
|
breakpoint: BreakPoints;
|
|
72
72
|
/** The component to render when the breakpoint matches. Defaults to 'div'. */
|
|
73
|
-
as?: React.ElementType;
|
|
73
|
+
as?: React$1.ElementType;
|
|
74
74
|
/** The component to render when the breakpoint doesn't match. Defaults to React.Fragment. */
|
|
75
|
-
fallback?: React.ElementType;
|
|
75
|
+
fallback?: React$1.ElementType;
|
|
76
76
|
/** Class name to apply to the fallback component. */
|
|
77
77
|
classNameFallback?: string;
|
|
78
78
|
};
|
|
@@ -107,6 +107,45 @@ declare function MediaWrapper({
|
|
|
107
107
|
...props
|
|
108
108
|
}: MediaWrapperProps): react_jsx_runtime0.JSX.Element;
|
|
109
109
|
//#endregion
|
|
110
|
+
//#region src/components/portal.d.ts
|
|
111
|
+
/**
|
|
112
|
+
* Renders children into a DOM element at the specified container.
|
|
113
|
+
*
|
|
114
|
+
* @param props - The component props.
|
|
115
|
+
* @param props.children - The content to render in the portal.
|
|
116
|
+
* @param props.container - The target container selector or ref.
|
|
117
|
+
* - Selector string: `#id`, `.class`, or `[attribute]`
|
|
118
|
+
* - React ref: A RefObject pointing to an existing DOM element.
|
|
119
|
+
* @returns The portal component or null if container not found.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* // Using ID selector
|
|
124
|
+
* <Portal container="#modal-root">
|
|
125
|
+
* <Modal />
|
|
126
|
+
* </Portal>
|
|
127
|
+
*
|
|
128
|
+
* // Using class selector
|
|
129
|
+
* <Portal container=".portal-container">
|
|
130
|
+
* <Content />
|
|
131
|
+
* </Portal>
|
|
132
|
+
*
|
|
133
|
+
* // Using ref
|
|
134
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
135
|
+
* <Portal container={containerRef}>
|
|
136
|
+
* <Content />
|
|
137
|
+
* </Portal>
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
interface PortalProps {
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
container: `#${string}` | `.${string}` | `[${string}]` | React.RefObject<HTMLElement>;
|
|
143
|
+
}
|
|
144
|
+
declare function Portal({
|
|
145
|
+
children,
|
|
146
|
+
container
|
|
147
|
+
}: PortalProps): React$1.ReactPortal | null;
|
|
148
|
+
//#endregion
|
|
110
149
|
//#region src/components/responsive-indicator.d.ts
|
|
111
150
|
type Side = 'bottom-left' | 'bottom-right' | 'top-right' | 'top-left';
|
|
112
151
|
/**
|
|
@@ -138,7 +177,7 @@ interface ResponsiveIndicatorProps {
|
|
|
138
177
|
* <ResponsiveIndicator side="top-right" offset={1} unit="rem" />
|
|
139
178
|
* ```
|
|
140
179
|
*/
|
|
141
|
-
declare const ResponsiveIndicator: React.FC<ResponsiveIndicatorProps>;
|
|
180
|
+
declare const ResponsiveIndicator: React$1.FC<ResponsiveIndicatorProps>;
|
|
142
181
|
//#endregion
|
|
143
182
|
//#region src/components/scroll-tracker.d.ts
|
|
144
183
|
/**
|
|
@@ -146,7 +185,7 @@ declare const ResponsiveIndicator: React.FC<ResponsiveIndicatorProps>;
|
|
|
146
185
|
*/
|
|
147
186
|
interface ScrollTrackerProps {
|
|
148
187
|
/** The child elements to render within the scrollable container. */
|
|
149
|
-
children: React.ReactNode;
|
|
188
|
+
children: React$1.ReactNode;
|
|
150
189
|
}
|
|
151
190
|
/**
|
|
152
191
|
* A component that provides a scrollable container and context for scroll tracking.
|
|
@@ -191,4 +230,4 @@ declare const ScrollTracker: ({
|
|
|
191
230
|
*/
|
|
192
231
|
declare function ScrollableMarker(): null;
|
|
193
232
|
//#endregion
|
|
194
|
-
export { HtmlInjector, Iconify, MediaWrapper, ResponsiveIndicator, ResponsiveIndicator as TailwindIndicator, ScrollTracker, ScrollableMarker };
|
|
233
|
+
export { HtmlInjector, Iconify, MediaWrapper, Portal, ResponsiveIndicator, ResponsiveIndicator as TailwindIndicator, ScrollTracker, ScrollableMarker };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as React from "react";
|
|
1
|
+
import * as React$1 from "react";
|
|
2
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
3
|
import { Icon as Iconify } from "@iconify/react";
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ import { Icon as Iconify } from "@iconify/react";
|
|
|
6
6
|
/**
|
|
7
7
|
* Props for the HtmlInjector component
|
|
8
8
|
*/
|
|
9
|
-
type HtmlInjectorProps = Omit<React.ComponentProps<'div'>, 'dangerouslySetInnerHTML'> & {
|
|
9
|
+
type HtmlInjectorProps = Omit<React$1.ComponentProps<'div'>, 'dangerouslySetInnerHTML'> & {
|
|
10
10
|
/** The HTML content to inject and render */
|
|
11
11
|
html: string;
|
|
12
12
|
/**
|
|
@@ -66,13 +66,13 @@ type BreakPoints = 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'max-sm' | 'max-md' | 'ma
|
|
|
66
66
|
/**
|
|
67
67
|
* Props for the MediaWrapper component.
|
|
68
68
|
*/
|
|
69
|
-
type MediaWrapperProps = React.ComponentProps<'div'> & {
|
|
69
|
+
type MediaWrapperProps = React$1.ComponentProps<'div'> & {
|
|
70
70
|
/** The breakpoint at which to switch between the main component and fallback. */
|
|
71
71
|
breakpoint: BreakPoints;
|
|
72
72
|
/** The component to render when the breakpoint matches. Defaults to 'div'. */
|
|
73
|
-
as?: React.ElementType;
|
|
73
|
+
as?: React$1.ElementType;
|
|
74
74
|
/** The component to render when the breakpoint doesn't match. Defaults to React.Fragment. */
|
|
75
|
-
fallback?: React.ElementType;
|
|
75
|
+
fallback?: React$1.ElementType;
|
|
76
76
|
/** Class name to apply to the fallback component. */
|
|
77
77
|
classNameFallback?: string;
|
|
78
78
|
};
|
|
@@ -107,6 +107,45 @@ declare function MediaWrapper({
|
|
|
107
107
|
...props
|
|
108
108
|
}: MediaWrapperProps): react_jsx_runtime0.JSX.Element;
|
|
109
109
|
//#endregion
|
|
110
|
+
//#region src/components/portal.d.ts
|
|
111
|
+
/**
|
|
112
|
+
* Renders children into a DOM element at the specified container.
|
|
113
|
+
*
|
|
114
|
+
* @param props - The component props.
|
|
115
|
+
* @param props.children - The content to render in the portal.
|
|
116
|
+
* @param props.container - The target container selector or ref.
|
|
117
|
+
* - Selector string: `#id`, `.class`, or `[attribute]`
|
|
118
|
+
* - React ref: A RefObject pointing to an existing DOM element.
|
|
119
|
+
* @returns The portal component or null if container not found.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* // Using ID selector
|
|
124
|
+
* <Portal container="#modal-root">
|
|
125
|
+
* <Modal />
|
|
126
|
+
* </Portal>
|
|
127
|
+
*
|
|
128
|
+
* // Using class selector
|
|
129
|
+
* <Portal container=".portal-container">
|
|
130
|
+
* <Content />
|
|
131
|
+
* </Portal>
|
|
132
|
+
*
|
|
133
|
+
* // Using ref
|
|
134
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
135
|
+
* <Portal container={containerRef}>
|
|
136
|
+
* <Content />
|
|
137
|
+
* </Portal>
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
interface PortalProps {
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
container: `#${string}` | `.${string}` | `[${string}]` | React.RefObject<HTMLElement>;
|
|
143
|
+
}
|
|
144
|
+
declare function Portal({
|
|
145
|
+
children,
|
|
146
|
+
container
|
|
147
|
+
}: PortalProps): React$1.ReactPortal | null;
|
|
148
|
+
//#endregion
|
|
110
149
|
//#region src/components/responsive-indicator.d.ts
|
|
111
150
|
type Side = 'bottom-left' | 'bottom-right' | 'top-right' | 'top-left';
|
|
112
151
|
/**
|
|
@@ -138,7 +177,7 @@ interface ResponsiveIndicatorProps {
|
|
|
138
177
|
* <ResponsiveIndicator side="top-right" offset={1} unit="rem" />
|
|
139
178
|
* ```
|
|
140
179
|
*/
|
|
141
|
-
declare const ResponsiveIndicator: React.FC<ResponsiveIndicatorProps>;
|
|
180
|
+
declare const ResponsiveIndicator: React$1.FC<ResponsiveIndicatorProps>;
|
|
142
181
|
//#endregion
|
|
143
182
|
//#region src/components/scroll-tracker.d.ts
|
|
144
183
|
/**
|
|
@@ -146,7 +185,7 @@ declare const ResponsiveIndicator: React.FC<ResponsiveIndicatorProps>;
|
|
|
146
185
|
*/
|
|
147
186
|
interface ScrollTrackerProps {
|
|
148
187
|
/** The child elements to render within the scrollable container. */
|
|
149
|
-
children: React.ReactNode;
|
|
188
|
+
children: React$1.ReactNode;
|
|
150
189
|
}
|
|
151
190
|
/**
|
|
152
191
|
* A component that provides a scrollable container and context for scroll tracking.
|
|
@@ -191,4 +230,4 @@ declare const ScrollTracker: ({
|
|
|
191
230
|
*/
|
|
192
231
|
declare function ScrollableMarker(): null;
|
|
193
232
|
//#endregion
|
|
194
|
-
export { HtmlInjector, Iconify, MediaWrapper, ResponsiveIndicator, ResponsiveIndicator as TailwindIndicator, ScrollTracker, ScrollableMarker };
|
|
233
|
+
export { HtmlInjector, Iconify, MediaWrapper, Portal, ResponsiveIndicator, ResponsiveIndicator as TailwindIndicator, ScrollTracker, ScrollableMarker };
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{r as e}from"../functions-NBY7C4F1.js";import{C as t,T as n,k as r}from"../hooks-Bc_So9mz.js";import*as i from"react";import{
|
|
1
|
+
"use client";import{r as e}from"../functions-NBY7C4F1.js";import{C as t,T as n,k as r}from"../hooks-Bc_So9mz.js";import*as i from"react";import{useRef as a}from"react";import{jsx as o}from"react/jsx-runtime";import{Icon as s}from"@iconify/react";import{createPortal as c}from"react-dom";function l({className:t,html:n,sanitize:a=!1,executeScripts:s=!0,...c}){let l=i.useRef([]),u=i.useRef(null);r(()=>{if(l.current.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)}),l.current=[],!(!s||!n))try{let e=document.createElement(`div`);e.innerHTML=n,e.querySelectorAll(`script`).forEach(e=>{let t=document.createElement(`script`);e.textContent&&(t.textContent=e.textContent),Array.from(e.attributes).forEach(e=>{t.setAttribute(e.name,e.value)}),t.onerror=e=>{console.error(`Script injection error:`,e)},document.body.appendChild(t),l.current.push(t)})}catch(e){console.error(`HTML injection error:`,e)}},[n,s]),i.useEffect(()=>()=>{l.current.forEach(e=>{e.parentNode&&e.parentNode.removeChild(e)})},[]);let d=i.useMemo(()=>{if(!n)return``;if(a){let e=document.createElement(`div`);e.innerHTML=n,e.querySelectorAll(`script`).forEach(e=>e.remove());let t=[`onclick`,`onload`,`onerror`,`onmouseover`];return e.querySelectorAll(`*`).forEach(e=>{t.forEach(t=>{e.hasAttribute(t)&&e.removeAttribute(t)})}),e.innerHTML}return n},[n,a]);return n?o(`div`,{ref:u,className:e(t),dangerouslySetInnerHTML:{__html:d},...c}):null}function u({breakpoint:e,as:t=`div`,fallback:r=i.Fragment,className:a,classNameFallback:s,...c}){let l=n(e.split(`-`).pop())===e.startsWith(`max`),u=l?r:t,d=l?s:a;return u===i.Fragment?o(u,{ref:c.ref,children:c.children},c.key):o(u,{className:d,...c})}function d({children:e,container:t}){let n=a(null);return n.current||=typeof t==`string`?document.querySelector(t):t.current,n.current?c(e,n.current):null}const f=[`bottom-left`,`bottom-right`,`top-right`,`top-left`],p=({side:e,offset:t=2,unit:r=`rem`})=>{let[a,s]=i.useState(e??`bottom-left`),c=n({DEFAULT:`xs`,sm:`sm`,md:`md`,lg:`lg`,xl:`xl`,"2xl":`2xl`}),[l,u]=i.useState(typeof window<`u`?window.innerWidth:0);i.useEffect(()=>{if(typeof window>`u`)return;let e=()=>u(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let d=c===`2xl`&&l>=1792?r===`rem`?`${(l/16).toFixed(1)}rem`:`${l}${r}`:c;return o(`button`,{type:`button`,onClick:()=>{s(f[(f.indexOf(a)+1)%f.length])},style:{position:`fixed`,zIndex:50,display:`grid`,height:`2.5rem`,minWidth:`2.5rem`,borderRadius:`30px`,placeContent:`center`,backgroundColor:`#2d3748`,fontFamily:`Courier New, Courier, monospace`,fontSize:`1rem`,color:`#ffffff`,border:`2px solid #4a5568`,boxShadow:`0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)`,padding:`0.5rem`,transition:`all 0.2s ease-in-out`,...{"bottom-left":{bottom:`${t}${r}`,left:`${t}${r}`},"bottom-right":{bottom:`${t}${r}`,right:`${t}${r}`},"top-right":{top:`${t}${r}`,right:`${t}${r}`},"top-left":{top:`${t}${r}`,left:`${t}${r}`}}[a]},children:d})};function m(){return r(()=>{let e=document.body;if(!e)return;let t=e=>{let t=getComputedStyle(e);if(t.overflow===`hidden`&&t.overflowY===`hidden`&&t.overflowX===`hidden`)return!1;let n=(t.overflowY===`auto`||t.overflowY===`scroll`)&&e.scrollHeight>e.clientHeight,r=(t.overflowX===`auto`||t.overflowX===`scroll`)&&e.scrollWidth>e.clientWidth;return n||r},n=e=>{t(e)?e.dataset.scrollable=`true`:delete e.dataset.scrollable},r=e=>{n(e);for(let t=0;t<e.children.length;t++){let n=e.children[t];r(n)}};`requestIdleCallback`in window?window.requestIdleCallback(()=>r(e)):setTimeout(()=>r(e),0);let i=new MutationObserver(e=>{for(let t of e)t.type===`childList`?t.addedNodes.forEach(e=>{e instanceof HTMLElement&&r(e)}):t.type===`attributes`&&t.target instanceof HTMLElement&&n(t.target)});return i.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:[`style`,`class`]}),()=>i.disconnect()},[]),null}export{l as HtmlInjector,s as Iconify,u as MediaWrapper,d as Portal,p as ResponsiveIndicator,p as TailwindIndicator,t as ScrollTracker,m as ScrollableMarker};
|