@prismicio/editor-support
Advanced tools
Comparing version 0.4.45 to 0.4.46
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t){let e=t;for(;e&&!(l(e)&&e.tabIndex>=0);)e=e.parentElement??void 0;return e}function s(t){return t instanceof Element}function l(t){return t instanceof HTMLElement}function a(t){let e=t;for(;e&&!u(e);)e=e.parentElement??void 0;return e===document.body&&(e=document.scrollingElement??void 0),e??document.scrollingElement??document.documentElement}function u(t){const e=getComputedStyle(t);return/auto|scroll/.test(e.overflow+e.overflowX+e.overflowY)}function d(t,e){let n=0,o=t;for(;o&&o!==e;){n+=o.offsetTop;const r=o.offsetParent;o=r instanceof HTMLElement?r:null}return n}function f(t,e=50){return t.scrollHeight-t.scrollTop-t.clientHeight<e}function m(t){const e=t.getBoundingClientRect(),n=e.top+e.height>=0&&e.top<=window.innerHeight,o=e.left+e.width>=0&&e.left<=window.innerWidth;return n&&o}const i={isAvailable:()=>{const t="__$$__test";try{return window.localStorage.setItem(t,t),window.localStorage.removeItem(t),!0}catch{return!1}},read:t=>{try{return window.localStorage.getItem(t)??void 0}catch{return}},write:(t,e)=>{try{window.localStorage.setItem(t,e)}catch{}},readJSON:(t,e)=>{try{const n=i.read(t);if(!n)return;const o=JSON.parse(n),r=e.safeParse(o);return r.success?r.data:void 0}catch{return}}};exports.findFocusableAncestor=c;exports.getOffsetTopRelativeTo=d;exports.getScrollableAncestor=a;exports.isElement=s;exports.isElementInView=m;exports.isHTMLElement=l;exports.isScrolledToBottom=f;exports.localStorage=i; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t){let e=t;for(;e&&!(l(e)&&e.tabIndex>=0);)e=e.parentElement??void 0;return e}function s(t){return t instanceof Element}function l(t){return t instanceof HTMLElement}function a(t){let e=t;for(;e&&!d(e);)e=e.parentElement??void 0;return e===document.body&&(e=document.scrollingElement??void 0),e??document.scrollingElement??document.documentElement}function d(t){const e=getComputedStyle(t);return/auto|scroll/.test(e.overflow+e.overflowX+e.overflowY)}function u(t,e){let o=0,n=t;for(;n&&n!==e;){o+=n.offsetTop;const r=n.offsetParent;n=r instanceof HTMLElement?r:null}return o}function f(t,e=50){return t.scrollHeight-t.scrollTop-t.clientHeight<e}function w(t){const e=t.getBoundingClientRect(),o=e.top+e.height>=0&&e.top<=window.innerHeight,n=e.left+e.width>=0&&e.left<=window.innerWidth;return o&&n}const i={isAvailable:()=>{const t="__$$__test";try{return window.localStorage.setItem(t,t),window.localStorage.removeItem(t),!0}catch{return!1}},has:t=>!!i.read(t),read:t=>{try{return window.localStorage.getItem(t)??void 0}catch{return}},write:(t,e)=>{try{window.localStorage.setItem(t,e),window.dispatchEvent(new StorageEvent("storage",{key:t,newValue:e}))}catch{}},readJSON:(t,e)=>{try{const o=i.read(t);if(!o)return;const n=JSON.parse(o),r=e.safeParse(n);return r.success?r.data:void 0}catch{return}},subscribe:t=>(window.addEventListener("storage",t),()=>window.removeEventListener("storage",t))};exports.findFocusableAncestor=c;exports.getOffsetTopRelativeTo=u;exports.getScrollableAncestor=a;exports.isElement=s;exports.isElementInView=w;exports.isHTMLElement=l;exports.isScrolledToBottom=f;exports.localStorage=i; |
@@ -14,5 +14,7 @@ import type { ZodType, ZodTypeDef } from "zod"; | ||
isAvailable: () => boolean; | ||
has: (key: string) => boolean; | ||
read: (key: string) => string | undefined; | ||
write: (key: string, value: string) => void; | ||
readJSON: <Value>(key: string, validator: ZodType<Value, ZodTypeDef, unknown>) => Value | undefined; | ||
subscribe: (listener: () => void) => () => void; | ||
}; |
@@ -1,26 +0,26 @@ | ||
function s(e) { | ||
let t = e; | ||
for (; t && !(i(t) && t.tabIndex >= 0); ) | ||
t = t.parentElement ?? void 0; | ||
return t; | ||
function a(t) { | ||
let e = t; | ||
for (; e && !(l(e) && e.tabIndex >= 0); ) | ||
e = e.parentElement ?? void 0; | ||
return e; | ||
} | ||
function a(e) { | ||
return e instanceof Element; | ||
function s(t) { | ||
return t instanceof Element; | ||
} | ||
function i(e) { | ||
return e instanceof HTMLElement; | ||
function l(t) { | ||
return t instanceof HTMLElement; | ||
} | ||
function u(e) { | ||
let t = e; | ||
for (; t && !l(t); ) | ||
t = t.parentElement ?? void 0; | ||
return t === document.body && (t = document.scrollingElement ?? void 0), t ?? document.scrollingElement ?? document.documentElement; | ||
function d(t) { | ||
let e = t; | ||
for (; e && !c(e); ) | ||
e = e.parentElement ?? void 0; | ||
return e === document.body && (e = document.scrollingElement ?? void 0), e ?? document.scrollingElement ?? document.documentElement; | ||
} | ||
function l(e) { | ||
const t = getComputedStyle(e); | ||
return /auto|scroll/.test(t.overflow + t.overflowX + t.overflowY); | ||
function c(t) { | ||
const e = getComputedStyle(t); | ||
return /auto|scroll/.test(e.overflow + e.overflowX + e.overflowY); | ||
} | ||
function d(e, t) { | ||
let o = 0, n = e; | ||
for (; n && n !== t; ) { | ||
function u(t, e) { | ||
let o = 0, n = t; | ||
for (; n && n !== e; ) { | ||
o += n.offsetTop; | ||
@@ -32,14 +32,14 @@ const r = n.offsetParent; | ||
} | ||
function f(e, t = 50) { | ||
return e.scrollHeight - e.scrollTop - e.clientHeight < t; | ||
function w(t, e = 50) { | ||
return t.scrollHeight - t.scrollTop - t.clientHeight < e; | ||
} | ||
function m(e) { | ||
const t = e.getBoundingClientRect(), o = t.top + t.height >= 0 && t.top <= window.innerHeight, n = t.left + t.width >= 0 && t.left <= window.innerWidth; | ||
function f(t) { | ||
const e = t.getBoundingClientRect(), o = e.top + e.height >= 0 && e.top <= window.innerHeight, n = e.left + e.width >= 0 && e.left <= window.innerWidth; | ||
return o && n; | ||
} | ||
const c = { | ||
const i = { | ||
isAvailable: () => { | ||
const e = "__$$__test"; | ||
const t = "__$$__test"; | ||
try { | ||
return window.localStorage.setItem(e, e), window.localStorage.removeItem(e), !0; | ||
return window.localStorage.setItem(t, t), window.localStorage.removeItem(t), !0; | ||
} catch { | ||
@@ -49,5 +49,6 @@ return !1; | ||
}, | ||
read: (e) => { | ||
has: (t) => !!i.read(t), | ||
read: (t) => { | ||
try { | ||
return window.localStorage.getItem(e) ?? void 0; | ||
return window.localStorage.getItem(t) ?? void 0; | ||
} catch { | ||
@@ -57,14 +58,16 @@ return; | ||
}, | ||
write: (e, t) => { | ||
write: (t, e) => { | ||
try { | ||
window.localStorage.setItem(e, t); | ||
window.localStorage.setItem(t, e), window.dispatchEvent( | ||
new StorageEvent("storage", { key: t, newValue: e }) | ||
); | ||
} catch { | ||
} | ||
}, | ||
readJSON: (e, t) => { | ||
readJSON: (t, e) => { | ||
try { | ||
const o = c.read(e); | ||
const o = i.read(t); | ||
if (!o) | ||
return; | ||
const n = JSON.parse(o), r = t.safeParse(n); | ||
const n = JSON.parse(o), r = e.safeParse(n); | ||
return r.success ? r.data : void 0; | ||
@@ -74,13 +77,14 @@ } catch { | ||
} | ||
} | ||
}, | ||
subscribe: (t) => (window.addEventListener("storage", t), () => window.removeEventListener("storage", t)) | ||
}; | ||
export { | ||
s as findFocusableAncestor, | ||
d as getOffsetTopRelativeTo, | ||
u as getScrollableAncestor, | ||
a as isElement, | ||
m as isElementInView, | ||
i as isHTMLElement, | ||
f as isScrolledToBottom, | ||
c as localStorage | ||
a as findFocusableAncestor, | ||
u as getOffsetTopRelativeTo, | ||
d as getScrollableAncestor, | ||
s as isElement, | ||
f as isElementInView, | ||
l as isHTMLElement, | ||
w as isScrolledToBottom, | ||
i as localStorage | ||
}; |
@@ -65,3 +65,3 @@ import { type JSXElementConstructor, type ReactNode, type RefObject, type TransitionStartFunction } from "react"; | ||
*/ | ||
export declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void; | ||
export declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) => void; | ||
/** | ||
@@ -71,3 +71,3 @@ * A custom hook that composes multiple refs | ||
*/ | ||
export declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void; | ||
export declare function useComposedRefs<T>(...refs: PossibleRef<T>[]): (node: T | null) => void; | ||
export declare function useTabFocus(onFocus: () => void): void; | ||
@@ -74,0 +74,0 @@ export declare function refContainsTarget(ref: RefObject<Node>, target: EventTarget | null): boolean; |
@@ -67,3 +67,3 @@ { | ||
}, | ||
"version": "0.4.45" | ||
"version": "0.4.46" | ||
} |
62476
1480