drab 5.4.1 → 6.0.0
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/{base → dist/base}/copy/index.d.ts +4 -1
- package/{base → dist/base}/index.d.ts +8 -3
- package/{base → dist/base}/index.js +4 -6
- package/dist/contextmenu/index.d.ts +12 -0
- package/{contextmenu → dist/contextmenu}/index.js +6 -12
- package/{copy → dist/copy}/index.d.ts +2 -3
- package/dist/define.js +4 -0
- package/{dialog → dist/dialog}/index.d.ts +7 -8
- package/{dialog → dist/dialog}/index.js +10 -23
- package/{editor → dist/editor}/index.d.ts +2 -3
- package/{fullscreen → dist/fullscreen}/index.d.ts +3 -7
- package/{fullscreen → dist/fullscreen}/index.js +2 -3
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -0
- package/{intersect → dist/intersect}/index.d.ts +4 -5
- package/{prefetch → dist/prefetch}/index.d.ts +7 -10
- package/{share → dist/share}/index.d.ts +2 -3
- package/{tablesort → dist/tablesort}/index.d.ts +2 -3
- package/{tablesort → dist/tablesort}/index.js +1 -1
- package/{wakelock → dist/wakelock}/index.d.ts +5 -6
- package/{youtube → dist/youtube}/index.d.ts +6 -3
- package/{youtube → dist/youtube}/index.js +0 -1
- package/package.json +103 -147
- package/LICENSE.md +0 -21
- package/README.md +0 -49
- package/animate/define.iife.js +0 -1
- package/animate/define.js +0 -2
- package/animate/index.d.ts +0 -57
- package/animate/index.iife.js +0 -1
- package/animate/index.js +0 -138
- package/base/define.iife.js +0 -1
- package/base/index.iife.js +0 -1
- package/breakpoint/define.iife.js +0 -1
- package/breakpoint/define.js +0 -2
- package/breakpoint/index.d.ts +0 -26
- package/breakpoint/index.iife.js +0 -1
- package/breakpoint/index.js +0 -55
- package/contextmenu/define.iife.js +0 -1
- package/contextmenu/index.d.ts +0 -13
- package/contextmenu/index.iife.js +0 -1
- package/copy/define.iife.js +0 -1
- package/copy/index.iife.js +0 -1
- package/define.iife.js +0 -9
- package/define.js +0 -4
- package/details/define.iife.js +0 -1
- package/details/define.js +0 -2
- package/details/index.d.ts +0 -21
- package/details/index.iife.js +0 -1
- package/details/index.js +0 -46
- package/dialog/define.iife.js +0 -1
- package/dialog/index.iife.js +0 -1
- package/editor/define.iife.js +0 -9
- package/editor/index.iife.js +0 -9
- package/fullscreen/define.iife.js +0 -1
- package/fullscreen/index.iife.js +0 -1
- package/index.d.ts +0 -17
- package/index.iife.js +0 -9
- package/index.js +0 -17
- package/intersect/define.iife.js +0 -1
- package/intersect/index.iife.js +0 -1
- package/popover/define.iife.js +0 -1
- package/popover/define.js +0 -2
- package/popover/index.d.ts +0 -25
- package/popover/index.iife.js +0 -1
- package/popover/index.js +0 -72
- package/prefetch/define.iife.js +0 -1
- package/prefetch/index.iife.js +0 -1
- package/share/define.d.ts +0 -1
- package/share/define.iife.js +0 -1
- package/share/index.iife.js +0 -1
- package/tablesort/define.d.ts +0 -1
- package/tablesort/define.iife.js +0 -1
- package/tablesort/index.iife.js +0 -1
- package/types/index.d.ts +0 -11
- package/types/index.js +0 -1
- package/wakelock/define.d.ts +0 -1
- package/wakelock/define.iife.js +0 -1
- package/wakelock/index.iife.js +0 -1
- package/youtube/define.d.ts +0 -1
- package/youtube/define.iife.js +0 -1
- package/youtube/index.iife.js +0 -1
- /package/{base → dist/base}/copy/index.js +0 -0
- /package/{animate → dist/base}/define.d.ts +0 -0
- /package/{base → dist/base}/define.js +0 -0
- /package/{base → dist/contextmenu}/define.d.ts +0 -0
- /package/{contextmenu → dist/contextmenu}/define.js +0 -0
- /package/{breakpoint → dist/copy}/define.d.ts +0 -0
- /package/{copy → dist/copy}/define.js +0 -0
- /package/{copy → dist/copy}/index.js +0 -0
- /package/{contextmenu → dist}/define.d.ts +0 -0
- /package/{copy → dist/dialog}/define.d.ts +0 -0
- /package/{dialog → dist/dialog}/define.js +0 -0
- /package/{define.d.ts → dist/editor/define.d.ts} +0 -0
- /package/{editor → dist/editor}/define.js +0 -0
- /package/{editor → dist/editor}/index.js +0 -0
- /package/{details → dist/fullscreen}/define.d.ts +0 -0
- /package/{fullscreen → dist/fullscreen}/define.js +0 -0
- /package/{dialog → dist/intersect}/define.d.ts +0 -0
- /package/{intersect → dist/intersect}/define.js +0 -0
- /package/{intersect → dist/intersect}/index.js +0 -0
- /package/{editor → dist/prefetch}/define.d.ts +0 -0
- /package/{prefetch → dist/prefetch}/define.js +0 -0
- /package/{prefetch → dist/prefetch}/index.js +0 -0
- /package/{fullscreen → dist/share}/define.d.ts +0 -0
- /package/{share → dist/share}/define.js +0 -0
- /package/{share → dist/share}/index.js +0 -0
- /package/{intersect → dist/tablesort}/define.d.ts +0 -0
- /package/{tablesort → dist/tablesort}/define.js +0 -0
- /package/{popover → dist/wakelock}/define.d.ts +0 -0
- /package/{wakelock → dist/wakelock}/define.js +0 -0
- /package/{wakelock → dist/wakelock}/index.js +0 -0
- /package/{prefetch → dist/youtube}/define.d.ts +0 -0
- /package/{youtube → dist/youtube}/define.js +0 -0
package/breakpoint/index.js
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
import { Base } from "../base/index.js";
|
2
|
-
/**
|
3
|
-
* Displays the current breakpoint and `window.innerWidth`, based on the `breakpoints` provided. Defaults to [TailwindCSS breakpoint sizes](https://tailwindcss.com/docs/responsive-design).
|
4
|
-
*
|
5
|
-
* Provide alternate breakpoints by specifying `breakpoint` attributes:
|
6
|
-
*
|
7
|
-
* ```html
|
8
|
-
* <drab-breakpoint breakpoint-name="400">
|
9
|
-
* ```
|
10
|
-
*/
|
11
|
-
export class Breakpoint extends Base {
|
12
|
-
breakpoints = [
|
13
|
-
{ name: "sm", width: 640 },
|
14
|
-
{ name: "md", width: 768 },
|
15
|
-
{ name: "lg", width: 1024 },
|
16
|
-
{ name: "xl", width: 1280 },
|
17
|
-
{ name: "2xl", width: 1536 },
|
18
|
-
];
|
19
|
-
constructor() {
|
20
|
-
super();
|
21
|
-
const custom = [];
|
22
|
-
for (const attributeName of this.getAttributeNames()) {
|
23
|
-
if (attributeName.startsWith("breakpoint-")) {
|
24
|
-
const [, ...name] = attributeName.split("-");
|
25
|
-
if (name) {
|
26
|
-
custom.push({
|
27
|
-
name: name.join("-"),
|
28
|
-
width: Number(this.getAttribute(attributeName)),
|
29
|
-
});
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}
|
33
|
-
if (custom.length)
|
34
|
-
this.breakpoints = custom;
|
35
|
-
// highest to lowest
|
36
|
-
this.breakpoints.sort((a, b) => b.width - a.width);
|
37
|
-
}
|
38
|
-
/** finds the current breakpoint */
|
39
|
-
get breakpoint() {
|
40
|
-
for (let i = 0; i < this.breakpoints.length; i++) {
|
41
|
-
const breakpoint = this.breakpoints[i];
|
42
|
-
if (breakpoint) {
|
43
|
-
if (window.innerWidth > breakpoint.width) {
|
44
|
-
return breakpoint.name;
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}
|
48
|
-
return "none";
|
49
|
-
}
|
50
|
-
mount() {
|
51
|
-
const render = () => (this.getContent().innerHTML = `${this.breakpoint}:${window.innerWidth}`);
|
52
|
-
render();
|
53
|
-
this.safeListener("resize", render, window);
|
54
|
-
}
|
55
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var l=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let e=this.querySelector(this.getAttribute("content")??"[data-content]");if(e instanceof t)return e;throw new Error("Content not found")}swapContent(t=!0,e=800){let n=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(n){let i=Array.from(this.getContent().childNodes),s=[];n instanceof HTMLTemplateElement?(s.push(n.content.cloneNode(!0)),n.content.replaceChildren(...i)):(s.push(...n.childNodes),n.replaceChildren(...i)),this.getContent().replaceChildren(...s),t&&setTimeout(()=>this.swapContent(!1),e)}}safeListener(t,e,n=document.body,i={}){i.signal=this.#t.signal,n.addEventListener(t,e,i)}triggerListener(t,e=this.event,n){for(let i of this.getTrigger())i.addEventListener(e,t,n)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var m=class extends l{constructor(){super()}get animationOptions(){let t={};for(let e of this.getAttributeNames())if(e.startsWith("animation-option-")){let n=this.getAttribute(e),[,,i]=e.split("-");n&&(i==="duration"||i==="delay"?t[i]=Number(n):i==="easing"&&(t[i]=n))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:n={}}=t,i=this.keyframes;if(i.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){n=Object.assign(this.animationOptions,n),n.duration||(n.duration=200),n.easing||(n.easing="ease-in-out");let s=i.at(0),o=i.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let c of a)delete s[c],delete o[c]}n.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(e.style,s),await e.animate(i,n).finished,Object.assign(e.style,o)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let n=this.getAttribute(e),[,,i,...s]=e.split("-");if(e.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(i&&o){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let r=Number(i),a=t.find(c=>c.offset===r);a?a[o]=n:t.push({[o]:n,offset:r})}}}return t.sort((e,n)=>Number(e.offset)-Number(n.offset)),t}};var f=class extends m{#t;constructor(){super()}set#e(t){this.getContent().style.left=`${t.x}px`,this.getContent().style.top=`${t.y}px`}async show(t){let e=window.scrollY,n=window.scrollX,i=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,s=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,o=i+n,r=s+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let a=this.getContent().offsetWidth+24,c=this.getContent().offsetHeight+6,h=window.innerWidth,d=window.innerHeight;o+a>n+h&&(o=n+h-a),r+c>e+d&&(r=e+d-c),this.#e={x:o,y:r},await this.animateElement()}async hide(){this.getContent().style.display!=="none"&&(await this.animateElement({options:{direction:"reverse"}}),this.getContent().style.display="none")}mount(){this.triggerListener(e=>{e.preventDefault(),this.show(e)},"contextmenu"),this.safeListener("click",()=>this.hide()),this.triggerListener(e=>{this.#t=setTimeout(()=>{this.show(e)},800)},"touchstart",{passive:!0});let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend",{passive:!0}),this.triggerListener(t,"touchcancel",{passive:!0}),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};customElements.define("drab-contextmenu",f);})();
|
package/contextmenu/index.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import { Animate, type AnimateAttributes } from "../animate/index.js";
|
2
|
-
import type { Attributes } from "../types/index.js";
|
3
|
-
export type ContextMenuAttributes = Attributes<ContextMenu> & AnimateAttributes;
|
4
|
-
/**
|
5
|
-
* Displays content when the `trigger` element is right clicked, or long pressed on mobile.
|
6
|
-
*/
|
7
|
-
export declare class ContextMenu extends Animate {
|
8
|
-
#private;
|
9
|
-
constructor();
|
10
|
-
show(e: MouseEvent | TouchEvent): Promise<void>;
|
11
|
-
hide(): Promise<void>;
|
12
|
-
mount(): void;
|
13
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let e=this.querySelector(this.getAttribute("content")??"[data-content]");if(e instanceof t)return e;throw new Error("Content not found")}swapContent(t=!0,e=800){let n=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(n){let i=Array.from(this.getContent().childNodes),s=[];n instanceof HTMLTemplateElement?(s.push(n.content.cloneNode(!0)),n.content.replaceChildren(...i)):(s.push(...n.childNodes),n.replaceChildren(...i)),this.getContent().replaceChildren(...s),t&&setTimeout(()=>this.swapContent(!1),e)}}safeListener(t,e,n=document.body,i={}){i.signal=this.#t.signal,n.addEventListener(t,e,i)}triggerListener(t,e=this.event,n){for(let i of this.getTrigger())i.addEventListener(e,t,n)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var m=class extends c{constructor(){super()}get animationOptions(){let t={};for(let e of this.getAttributeNames())if(e.startsWith("animation-option-")){let n=this.getAttribute(e),[,,i]=e.split("-");n&&(i==="duration"||i==="delay"?t[i]=Number(n):i==="easing"&&(t[i]=n))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:n={}}=t,i=this.keyframes;if(i.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){n=Object.assign(this.animationOptions,n),n.duration||(n.duration=200),n.easing||(n.easing="ease-in-out");let s=i.at(0),o=i.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let l of a)delete s[l],delete o[l]}n.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(e.style,s),await e.animate(i,n).finished,Object.assign(e.style,o)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let n=this.getAttribute(e),[,,i,...s]=e.split("-");if(e.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(i&&o){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let r=Number(i),a=t.find(l=>l.offset===r);a?a[o]=n:t.push({[o]:n,offset:r})}}}return t.sort((e,n)=>Number(e.offset)-Number(n.offset)),t}};var d=class extends m{#t;constructor(){super()}set#e(t){this.getContent().style.left=`${t.x}px`,this.getContent().style.top=`${t.y}px`}async show(t){let e=window.scrollY,n=window.scrollX,i=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,s=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,o=i+n,r=s+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let a=this.getContent().offsetWidth+24,l=this.getContent().offsetHeight+6,u=window.innerWidth,h=window.innerHeight;o+a>n+u&&(o=n+u-a),r+l>e+h&&(r=e+h-l),this.#e={x:o,y:r},await this.animateElement()}async hide(){this.getContent().style.display!=="none"&&(await this.animateElement({options:{direction:"reverse"}}),this.getContent().style.display="none")}mount(){this.triggerListener(e=>{e.preventDefault(),this.show(e)},"contextmenu"),this.safeListener("click",()=>this.hide()),this.triggerListener(e=>{this.#t=setTimeout(()=>{this.show(e)},800)},"touchstart",{passive:!0});let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend",{passive:!0}),this.triggerListener(t,"touchcancel",{passive:!0}),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};})();
|
package/copy/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var s=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof e)return n;throw new Error("Content not found")}swapContent(e=!0,n=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let r=Array.from(this.getContent().childNodes),a=[];t instanceof HTMLTemplateElement?(a.push(t.content.cloneNode(!0)),t.content.replaceChildren(...r)):(a.push(...t.childNodes),t.replaceChildren(...r)),this.getContent().replaceChildren(...a),e&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(e,n,t=document.body,r={}){r.signal=this.#e.signal,t.addEventListener(e,n,r)}triggerListener(e,n=this.event,t){for(let r of this.getTrigger())r.addEventListener(n,e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var o=class extends s{constructor(){super()}get value(){return this.getAttribute("value")??""}set value(e){this.setAttribute("value",e)}async copy(e=this.value){await navigator.clipboard.writeText(e),this.swapContent()}};var i=class extends o{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};customElements.define("drab-copy",i);})();
|
package/copy/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var s=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof e)return n;throw new Error("Content not found")}swapContent(e=!0,n=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let r=Array.from(this.getContent().childNodes),i=[];t instanceof HTMLTemplateElement?(i.push(t.content.cloneNode(!0)),t.content.replaceChildren(...r)):(i.push(...t.childNodes),t.replaceChildren(...r)),this.getContent().replaceChildren(...i),e&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(e,n,t=document.body,r={}){r.signal=this.#e.signal,t.addEventListener(e,n,r)}triggerListener(e,n=this.event,t){for(let r of this.getTrigger())r.addEventListener(n,e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var o=class extends s{constructor(){super()}get value(){return this.getAttribute("value")??""}set value(e){this.setAttribute("value",e)}async copy(e=this.value){await navigator.clipboard.writeText(e),this.swapContent()}};var l=class extends o{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};})();
|
package/define.iife.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var R=Object.defineProperty;var j=(o,t)=>{for(var e in t)R(o,e,{get:t[e],enumerable:!0})};var H={};j(H,{Animate:()=>p,Base:()=>c,Breakpoint:()=>d,ContextMenu:()=>g,Copy:()=>b,Details:()=>y,Dialog:()=>A,Editor:()=>v,Fullscreen:()=>x,Intersect:()=>w,Popover:()=>E,Prefetch:()=>T,Share:()=>L,TableSort:()=>C,WakeLock:()=>M,YouTube:()=>S});var c=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let e=this.querySelector(this.getAttribute("content")??"[data-content]");if(e instanceof t)return e;throw new Error("Content not found")}swapContent(t=!0,e=800){let i=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(i){let s=Array.from(this.getContent().childNodes),r=[];i instanceof HTMLTemplateElement?(r.push(i.content.cloneNode(!0)),i.content.replaceChildren(...s)):(r.push(...i.childNodes),i.replaceChildren(...s)),this.getContent().replaceChildren(...r),t&&setTimeout(()=>this.swapContent(!1),e)}}safeListener(t,e,i=document.body,s={}){s.signal=this.#t.signal,i.addEventListener(t,e,s)}triggerListener(t,e=this.event,i){for(let s of this.getTrigger())s.addEventListener(e,t,i)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var p=class extends c{constructor(){super()}get animationOptions(){let t={};for(let e of this.getAttributeNames())if(e.startsWith("animation-option-")){let i=this.getAttribute(e),[,,s]=e.split("-");i&&(s==="duration"||s==="delay"?t[s]=Number(i):s==="easing"&&(t[s]=i))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:i={}}=t,s=this.keyframes;if(s.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){i=Object.assign(this.animationOptions,i),i.duration||(i.duration=200),i.easing||(i.easing="ease-in-out");let r=s.at(0),n=s.at(-1);if(r&&n){let u=["composite","easing","offset"];for(let l of u)delete r[l],delete n[l]}i.direction?.includes("reverse")&&([r,n]=[n,r]),Object.assign(e.style,r),await e.animate(s,i).finished,Object.assign(e.style,n)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let i=this.getAttribute(e),[,,s,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let n=r.map((a,u)=>u<1?a:a.at(0)?.toUpperCase()+a.slice(1)).join("");if(s&&n){s==="from"?s="0":s==="to"?s="1":s=String(parseInt(s)*.01);let a=Number(s),u=t.find(l=>l.offset===a);u?u[n]=i:t.push({[n]:i,offset:a})}}}return t.sort((e,i)=>Number(e.offset)-Number(i.offset)),t}};var d=class extends c{breakpoints=[{name:"sm",width:640},{name:"md",width:768},{name:"lg",width:1024},{name:"xl",width:1280},{name:"2xl",width:1536}];constructor(){super();let t=[];for(let e of this.getAttributeNames())if(e.startsWith("breakpoint-")){let[,...i]=e.split("-");i&&t.push({name:i.join("-"),width:Number(this.getAttribute(e))})}t.length&&(this.breakpoints=t),this.breakpoints.sort((e,i)=>i.width-e.width)}get breakpoint(){for(let t=0;t<this.breakpoints.length;t++){let e=this.breakpoints[t];if(e&&window.innerWidth>e.width)return e.name}return"none"}mount(){let t=()=>this.getContent().innerHTML=`${this.breakpoint}:${window.innerWidth}`;t(),this.safeListener("resize",t,window)}};var g=class extends p{#t;constructor(){super()}set#i(t){this.getContent().style.left=`${t.x}px`,this.getContent().style.top=`${t.y}px`}async show(t){let e=window.scrollY,i=window.scrollX,s=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,n=s+i,a=r+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let u=this.getContent().offsetWidth+24,l=this.getContent().offsetHeight+6,h=window.innerWidth,m=window.innerHeight;n+u>i+h&&(n=i+h-u),a+l>e+m&&(a=e+m-l),this.#i={x:n,y:a},await this.animateElement()}async hide(){this.getContent().style.display!=="none"&&(await this.animateElement({options:{direction:"reverse"}}),this.getContent().style.display="none")}mount(){this.triggerListener(e=>{e.preventDefault(),this.show(e)},"contextmenu"),this.safeListener("click",()=>this.hide()),this.triggerListener(e=>{this.#t=setTimeout(()=>{this.show(e)},800)},"touchstart",{passive:!0});let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend",{passive:!0}),this.triggerListener(t,"touchcancel",{passive:!0}),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};var f=class extends c{constructor(){super()}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}async copy(t=this.value){await navigator.clipboard.writeText(t),this.swapContent()}};var b=class extends f{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var y=class extends p{constructor(){super()}get details(){let t=this.getContent(HTMLElement).parentElement;if(!(t instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return t}async open(){this.details.open=!0,await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.details.open=!1}toggle(){this.details.open?this.close():this.open()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()})}};var A=class extends p{#t=parseInt(getComputedStyle(document.body).marginRight);constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}get#i(){return window.innerWidth-document.documentElement.clientWidth}set#r(t){document.body.style.marginRight=`${t}px`}set#e(t){document.body.style.overflow=t}#s(t){this.hasAttribute("remove-body-scroll")&&(this.#r=t?this.#t+this.#i:this.#t,this.#e=t?"hidden":"")}async show(){this.dialog.showModal(),this.#s(!0),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.#s(!1),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",t=>{t.key==="Escape"&&this.dialog.open&&(t.preventDefault(),this.close())}),this.hasAttribute("click-outside-close")&&this.dialog.addEventListener("click",t=>{let e=this.dialog.getBoundingClientRect();(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this.close()})}};var v=class extends c{#t=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#i)t.type==="wrap"&&(this.keyPairs[t.value]=t.value)}get textArea(){return this.getContent(HTMLTextAreaElement)}get text(){return this.textArea.value}set text(t){this.textArea.value=t}get#i(){let t=[];for(let e of this.getTrigger())t.push(this.#l(e));return t}get#r(){let t=this.text.split("```"),e=0;for(let[i,s]of t.entries())if(e+=s.length+3,this.#s<e)return i;return 0}get#e(){return this.textArea.selectionEnd}get#s(){return this.textArea.selectionStart}#n(t,e){this.textArea.setSelectionRange(t,e)}#l(t){let e=t.dataset.type,i=t.dataset.value,s=t.dataset.key??void 0;return{type:e,value:i,key:s}}async#c(t,e,i){if(t.type==="inline")this.text=`${this.text.slice(0,i)}${t.value}${this.text.slice(i)}`;else if(t.type==="wrap")this.text=B(this.text,t.value,e),this.text=B(this.text,this.keyPairs[t.value],i+t.value.length),t.value.length<2&&this.#t.push(t.value);else if(t.type==="block"){let{lines:s,lineNumber:r}=this.#a(),n=t.value.at(0);n&&s[r]?.startsWith(n)?s[r]=t.value.trim()+s[r]:s[r]=t.value+s[r],this.text=s.join(`
|
2
|
-
`)}}async#h(t,e,i){let s=0,r=0;if(/[a-z]/i.test(t)){for(let n=i;n<this.text.length;n++)if(this.text[n]?.match(/[a-z]/i))s?r=n+1:s=n;else if(s)break}else s=e+t.length,r=i+t.length;this.#n(s,r),this.textArea.focus()}async#o(t){let e=this.#e,i=this.#s;await this.#c(t,i,e),this.#h(t.value,i,e)}#p(t){if(t){let e=[];this.#i.forEach(s=>{s.type==="block"&&e.push(s.value)});for(let s=0;s<e.length;s++){let r=e[s];if(r&&t.startsWith(r))return r}let i=P(t);if(i)return`${i}. `}return""}#a(){let t=this.text.split(`
|
3
|
-
`),e=0;for(let i=0;i<t.length;i++){let s=t.at(i)?.length??0;if(e++,e+=s,e>this.#e)return{lines:t,lineNumber:i,columnNumber:this.#e-(e-s-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#u(t,e=!1){let{lines:i}=this.#a();for(let s=t+1;s<i.length;s++){let r=i[s];if(r){let n=P(r);if(n){let a;if(e)if(n>1)a=n-1;else break;else a=n+1;i[s]=r.slice(String(n).length),i[s]=String(a)+i[s]}else break}}this.text=i.join(`
|
4
|
-
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let e=["ArrowUp","ArrowDown","Delete"],i=this.text[this.#e]??"";if(e.includes(t.key))this.#t=[];else if(t.key==="Backspace"){let s=this.text[this.#s-1];if(s&&s in this.keyPairs&&i===this.keyPairs[s]){t.preventDefault();let r=this.#s-1,n=this.#e-1;this.text=k(this.text,r),this.text=k(this.text,n),setTimeout(()=>{this.#n(r,n)},0),this.#t.pop()}if(s===`
|
5
|
-
`&&this.#s===this.#e){t.preventDefault();let r=this.#s-1,{lineNumber:n}=this.#a();this.#u(n,!0),this.text=k(this.text,r),setTimeout(async()=>{this.#n(r,r)},0)}}else if(t.key==="Tab")this.#r%2!==0&&(t.preventDefault(),await this.#o({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:s,lineNumber:r,columnNumber:n}=this.#a(),a=s.at(r),u=this.#p(a),l=u,h=P(u);if(h&&(u=`${h+1}. `),u&&l.length<n)t.preventDefault(),h&&this.#u(r),await this.#o({type:"inline",value:`
|
6
|
-
${u}`});else if(u&&l.length===n){t.preventDefault();let m=this.#e,N=m-l.length;for(let D=0;D<l.length;D++)this.text=k(this.text,m-(D+1));setTimeout(async()=>{this.#n(N,N),this.textArea.focus(),await this.#o({type:"inline",value:`
|
7
|
-
`})},0)}}else{let s=Object.values(this.keyPairs).includes(i),r=this.#s!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#s===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:n,lineNumber:a,columnNumber:u}=this.#a();if(await navigator.clipboard.writeText(`${a===0&&t.key==="x"?"":`
|
8
|
-
`}${n[a]}`),t.key==="x"){let l=this.#s-u;n.splice(a,1),this.text=n.join(`
|
9
|
-
`),setTimeout(()=>{this.#n(l,l)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#i.find(a=>a.key===t.key);n&&this.#o(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#n(this.#s+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#o({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#s!==this.#e&&(this.text[this.#s]===" "&&this.#n(this.#s+1,this.#e),this.text[this.#e-1]===" "&&this.#n(this.#s,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#o(this.#l(t))})}},P=o=>{let t=o.match(/^(\d+)\./);return t?Number(t[1]):null},B=(o,t,e)=>o.slice(0,e)+t+o.slice(e),k=(o,t)=>o.slice(0,t)+o.slice(t+1);var x=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var w=class extends c{#t=[];#i=[];constructor(){super()}get#r(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#i.push(t)}mount(){let t=new IntersectionObserver(e=>{let i="data-intersect";for(let s of e)if(s.isIntersecting){this.getContent().setAttribute(i,"");for(let r of this.#t)r()}else{this.getContent().removeAttribute(i);for(let r of this.#i)r()}},{threshold:this.#r});for(let e of this.getTrigger())t.observe(e)}};var E=class extends p{constructor(){super()}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",t=>{t.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",t=>{t.key==="Escape"&&this.open&&(t.preventDefault(),this.hide())})}};var T=class extends c{#t=[];constructor(){super()}get#i(){return this.getAttribute("strategy")??"hover"}get#r(){return this.hasAttribute("prerender")}get#e(){return this.getAttribute("url")}appendTag(t){let{url:e,prerender:i}=t;if(e!==window.location.href&&!this.#t.includes(e))if(this.#t.push(e),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let s={prefetch:[{source:"list",urls:[e]}]};i&&(s.prerender=s.prefetch);let r=document.createElement("script");r.type="speculationrules",r.textContent=JSON.stringify(s),document.head.append(r)}else{let s=document.createElement("link");s.rel="prefetch",s.as="document",s.href=e,document.head.append(s)}}prefetch(t={anchors:this.getTrigger(),prerender:this.#r,strategy:this.#i}){let{anchors:e=this.getTrigger(),prerender:i=this.#r,strategy:s=this.#i}=t,r,n=(l=200)=>h=>{let{href:m}=h.currentTarget;r=setTimeout(()=>this.appendTag({url:m,prerender:i}),l)},a=()=>clearTimeout(r),u=new IntersectionObserver(l=>{for(let h of l)h.isIntersecting&&this.appendTag({url:h.target.href,prerender:i})});for(let l of e)s==="load"?this.appendTag({url:l.href,prerender:i}):s==="visible"?u.observe(l):(l.addEventListener("mouseover",n()),l.addEventListener("mouseout",a),l.addEventListener("focus",n()),l.addEventListener("focusout",a),l.addEventListener("touchstart",n(0),{passive:!0}))}mount(){this.#e&&this.appendTag({url:this.#e,prerender:this.#r}),this.prefetch()}};var L=class extends f{constructor(){super()}async share(t=this.value){if(navigator.canShare&&navigator.canShare({url:t}))try{await navigator.share({url:t})}catch(e){e?.name!=="AbortError"&&console.error(e)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};var C=class extends c{constructor(){super()}#t(t){let e="data-asc",i="data-desc";for(let s of this.getTrigger())s!==t&&(s.removeAttribute(e),s.removeAttribute(i));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(i,""),!1):(t.removeAttribute(i),t.setAttribute(e,""),!0)}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(I(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},I=(o,t)=>(i,s)=>{let r=Array.from(o.parentNode?.children??[]).indexOf(o);return((a,u)=>{let l=o.dataset.type??"string";if(l==="string")return new Intl.Collator().compare(a,u);if(l==="boolean"){let h=m=>["0","false","null","undefined"].includes(m)?!1:!!m;return h(a)===h(u)?0:h(a)?-1:1}else return Number(a)-Number(u)})(W(t?i:s,r),W(t?s:i,r))},W=(o,t)=>{let e=o.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var M=class extends c{wakeLock=null;constructor(){super()}#t(){return"wakeLock"in navigator}get#i(){return this.hasAttribute("auto-lock")}async request(){this.#t()&&document.visibilityState==="visible"&&(this.wakeLock=await navigator.wakeLock.request("screen"),this.setAttribute("locked",""),this.swapContent(!1),this.wakeLock.addEventListener("release",()=>{this.removeAttribute("locked"),this.swapContent(!1),this.#i||(this.wakeLock=null)}))}async release(){await this.wakeLock?.release(),this.wakeLock=null}mount(){this.hasAttribute("locked")&&this.request(),this.triggerListener(()=>{this.wakeLock?this.release():this.request()});for(let t of this.getTrigger())!this.#t()&&"disabled"in t&&(t.disabled=!0);this.#i&&this.safeListener("visibilitychange",()=>{this.wakeLock&&this.request()},document)}destroy(){this.release()}};var S=class extends c{static observedAttributes=["autoplay","start","uid"];constructor(){super()}get iframe(){return this.getContent(HTMLIFrameElement)}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(t){t?this.setAttribute("autoplay",""):this.removeAttribute("autoplay")}get start(){return this.getAttribute("start")??"0"}set start(t){this.setAttribute("start",t)}get uid(){let t=this.getAttribute("uid");if(!t)throw new Error("YouTube: missing `uid` attribute.");return t}set uid(t){this.setAttribute("uid",t)}mount(){this.iframe.allowFullscreen=!0,this.iframe.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"}attributeChangedCallback(){queueMicrotask(()=>{this.iframe.src=`https://www.youtube-nocookie.com/embed/${this.uid}?start=${this.start}${this.autoplay?"&autoplay=1":""}`})}};for(let o in H)customElements.define(`drab-${o.toLowerCase()}`,H[o]);})();
|
package/define.js
DELETED
package/details/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var m=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(n){this.setAttribute("event",n)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(n=HTMLElement){let i=this.querySelector(this.getAttribute("content")??"[data-content]");if(i instanceof n)return i;throw new Error("Content not found")}swapContent(n=!0,i=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let t=Array.from(this.getContent().childNodes),s=[];e instanceof HTMLTemplateElement?(s.push(e.content.cloneNode(!0)),e.content.replaceChildren(...t)):(s.push(...e.childNodes),e.replaceChildren(...t)),this.getContent().replaceChildren(...s),n&&setTimeout(()=>this.swapContent(!1),i)}}safeListener(n,i,e=document.body,t={}){t.signal=this.#e.signal,e.addEventListener(n,i,t)}triggerListener(n,i=this.event,e){for(let t of this.getTrigger())t.addEventListener(i,n,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let n={};for(let i of this.getAttributeNames())if(i.startsWith("animation-option-")){let e=this.getAttribute(i),[,,t]=i.split("-");e&&(t==="duration"||t==="delay"?n[t]=Number(e):t==="easing"&&(n[t]=e))}return n}async animateElement(n={element:this.getContent(),options:{}}){let{element:i=this.getContent(),options:e={}}=n,t=this.keyframes;if(t.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){e=Object.assign(this.animationOptions,e),e.duration||(e.duration=200),e.easing||(e.easing="ease-in-out");let s=t.at(0),o=t.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let l of a)delete s[l],delete o[l]}e.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(i.style,s),await i.animate(t,e).finished,Object.assign(i.style,o)}}get keyframes(){let n=[];for(let i of this.getAttributeNames()){let e=this.getAttribute(i),[,,t,...s]=i.split("-");if(i.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(t&&o){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let r=Number(t),a=n.find(l=>l.offset===r);a?a[o]=e:n.push({[o]:e,offset:r})}}}return n.sort((i,e)=>Number(i.offset)-Number(e.offset)),n}};var c=class extends f{constructor(){super()}get details(){let n=this.getContent(HTMLElement).parentElement;if(!(n instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return n}async open(){this.details.open=!0,await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.details.open=!1}toggle(){this.details.open?this.close():this.open()}mount(){this.triggerListener(n=>{n.preventDefault(),this.toggle()})}};customElements.define("drab-details",c);})();
|
package/details/define.js
DELETED
package/details/index.d.ts
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
import { Animate, type AnimateAttributes } from "../animate/index.js";
|
2
|
-
import type { Attributes } from "../types/index.js";
|
3
|
-
export type DetailsAttributes = Attributes<Details> & AnimateAttributes;
|
4
|
-
/**
|
5
|
-
* This element provides a progressive enhancement on top of the `HTMLDetailsElement` to
|
6
|
-
* animate it with the Web Animations API.
|
7
|
-
*
|
8
|
-
* The best way I've found to animate the details element is using CSS grid from this
|
9
|
-
* [Kevin Powell video](https://youtu.be/B_n4YONte5A?t=116). The example demonstrates
|
10
|
-
* this animation. If you know the exact height of the content, you could animate `height`
|
11
|
-
* instead.
|
12
|
-
*/
|
13
|
-
export declare class Details extends Animate {
|
14
|
-
constructor();
|
15
|
-
get details(): HTMLDetailsElement;
|
16
|
-
open(): Promise<void>;
|
17
|
-
/** Closes details with animation. */
|
18
|
-
close(): Promise<void>;
|
19
|
-
toggle(): void;
|
20
|
-
mount(): void;
|
21
|
-
}
|
package/details/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var m=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(n){this.setAttribute("event",n)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(n=HTMLElement){let i=this.querySelector(this.getAttribute("content")??"[data-content]");if(i instanceof n)return i;throw new Error("Content not found")}swapContent(n=!0,i=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let t=Array.from(this.getContent().childNodes),s=[];e instanceof HTMLTemplateElement?(s.push(e.content.cloneNode(!0)),e.content.replaceChildren(...t)):(s.push(...e.childNodes),e.replaceChildren(...t)),this.getContent().replaceChildren(...s),n&&setTimeout(()=>this.swapContent(!1),i)}}safeListener(n,i,e=document.body,t={}){t.signal=this.#e.signal,e.addEventListener(n,i,t)}triggerListener(n,i=this.event,e){for(let t of this.getTrigger())t.addEventListener(i,n,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let n={};for(let i of this.getAttributeNames())if(i.startsWith("animation-option-")){let e=this.getAttribute(i),[,,t]=i.split("-");e&&(t==="duration"||t==="delay"?n[t]=Number(e):t==="easing"&&(n[t]=e))}return n}async animateElement(n={element:this.getContent(),options:{}}){let{element:i=this.getContent(),options:e={}}=n,t=this.keyframes;if(t.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){e=Object.assign(this.animationOptions,e),e.duration||(e.duration=200),e.easing||(e.easing="ease-in-out");let s=t.at(0),o=t.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let l of a)delete s[l],delete o[l]}e.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(i.style,s),await i.animate(t,e).finished,Object.assign(i.style,o)}}get keyframes(){let n=[];for(let i of this.getAttributeNames()){let e=this.getAttribute(i),[,,t,...s]=i.split("-");if(i.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(t&&o){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let r=Number(t),a=n.find(l=>l.offset===r);a?a[o]=e:n.push({[o]:e,offset:r})}}}return n.sort((i,e)=>Number(i.offset)-Number(e.offset)),n}};var u=class extends f{constructor(){super()}get details(){let n=this.getContent(HTMLElement).parentElement;if(!(n instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return n}async open(){this.details.open=!0,await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.details.open=!1}toggle(){this.details.open?this.close():this.open()}mount(){this.triggerListener(n=>{n.preventDefault(),this.toggle()})}};})();
|
package/details/index.js
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
import { Animate } from "../animate/index.js";
|
2
|
-
/**
|
3
|
-
* This element provides a progressive enhancement on top of the `HTMLDetailsElement` to
|
4
|
-
* animate it with the Web Animations API.
|
5
|
-
*
|
6
|
-
* The best way I've found to animate the details element is using CSS grid from this
|
7
|
-
* [Kevin Powell video](https://youtu.be/B_n4YONte5A?t=116). The example demonstrates
|
8
|
-
* this animation. If you know the exact height of the content, you could animate `height`
|
9
|
-
* instead.
|
10
|
-
*/
|
11
|
-
export class Details extends Animate {
|
12
|
-
constructor() {
|
13
|
-
super();
|
14
|
-
}
|
15
|
-
get details() {
|
16
|
-
const details = this.getContent(HTMLElement).parentElement;
|
17
|
-
if (!(details instanceof HTMLDetailsElement))
|
18
|
-
throw new Error("Details: HTMLDetailsElement not found.");
|
19
|
-
return details;
|
20
|
-
}
|
21
|
-
async open() {
|
22
|
-
this.details.open = true;
|
23
|
-
await this.animateElement();
|
24
|
-
}
|
25
|
-
/** Closes details with animation. */
|
26
|
-
async close() {
|
27
|
-
await this.animateElement({
|
28
|
-
options: { direction: "reverse" },
|
29
|
-
});
|
30
|
-
this.details.open = false;
|
31
|
-
}
|
32
|
-
toggle() {
|
33
|
-
if (this.details.open) {
|
34
|
-
this.close();
|
35
|
-
}
|
36
|
-
else {
|
37
|
-
this.open();
|
38
|
-
}
|
39
|
-
}
|
40
|
-
mount() {
|
41
|
-
this.triggerListener((e) => {
|
42
|
-
e.preventDefault();
|
43
|
-
this.toggle();
|
44
|
-
});
|
45
|
-
}
|
46
|
-
}
|
package/dialog/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof t)return n;throw new Error("Content not found")}swapContent(t=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let i=Array.from(this.getContent().childNodes),s=[];e instanceof HTMLTemplateElement?(s.push(e.content.cloneNode(!0)),e.content.replaceChildren(...i)):(s.push(...e.childNodes),e.replaceChildren(...i)),this.getContent().replaceChildren(...s),t&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(t,n,e=document.body,i={}){i.signal=this.#t.signal,e.addEventListener(t,n,i)}triggerListener(t,n=this.event,e){for(let i of this.getTrigger())i.addEventListener(n,t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var m=class extends c{constructor(){super()}get animationOptions(){let t={};for(let n of this.getAttributeNames())if(n.startsWith("animation-option-")){let e=this.getAttribute(n),[,,i]=n.split("-");e&&(i==="duration"||i==="delay"?t[i]=Number(e):i==="easing"&&(t[i]=e))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:n=this.getContent(),options:e={}}=t,i=this.keyframes;if(i.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){e=Object.assign(this.animationOptions,e),e.duration||(e.duration=200),e.easing||(e.easing="ease-in-out");let s=i.at(0),o=i.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let l of a)delete s[l],delete o[l]}e.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(n.style,s),await n.animate(i,e).finished,Object.assign(n.style,o)}}get keyframes(){let t=[];for(let n of this.getAttributeNames()){let e=this.getAttribute(n),[,,i,...s]=n.split("-");if(n.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(i&&o){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let r=Number(i),a=t.find(l=>l.offset===r);a?a[o]=e:t.push({[o]:e,offset:r})}}}return t.sort((n,e)=>Number(n.offset)-Number(e.offset)),t}};var d=class extends m{#t=parseInt(getComputedStyle(document.body).marginRight);constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}get#n(){return window.innerWidth-document.documentElement.clientWidth}set#i(t){document.body.style.marginRight=`${t}px`}set#s(t){document.body.style.overflow=t}#e(t){this.hasAttribute("remove-body-scroll")&&(this.#i=t?this.#t+this.#n:this.#t,this.#s=t?"hidden":"")}async show(){this.dialog.showModal(),this.#e(!0),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.#e(!1),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",t=>{t.key==="Escape"&&this.dialog.open&&(t.preventDefault(),this.close())}),this.hasAttribute("click-outside-close")&&this.dialog.addEventListener("click",t=>{let n=this.dialog.getBoundingClientRect();(t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom)&&this.close()})}};customElements.define("drab-dialog",d);})();
|
package/dialog/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof t)return n;throw new Error("Content not found")}swapContent(t=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let i=Array.from(this.getContent().childNodes),s=[];e instanceof HTMLTemplateElement?(s.push(e.content.cloneNode(!0)),e.content.replaceChildren(...i)):(s.push(...e.childNodes),e.replaceChildren(...i)),this.getContent().replaceChildren(...s),t&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(t,n,e=document.body,i={}){i.signal=this.#t.signal,e.addEventListener(t,n,i)}triggerListener(t,n=this.event,e){for(let i of this.getTrigger())i.addEventListener(n,t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var m=class extends c{constructor(){super()}get animationOptions(){let t={};for(let n of this.getAttributeNames())if(n.startsWith("animation-option-")){let e=this.getAttribute(n),[,,i]=n.split("-");e&&(i==="duration"||i==="delay"?t[i]=Number(e):i==="easing"&&(t[i]=e))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:n=this.getContent(),options:e={}}=t,i=this.keyframes;if(i.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){e=Object.assign(this.animationOptions,e),e.duration||(e.duration=200),e.easing||(e.easing="ease-in-out");let s=i.at(0),o=i.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let l of a)delete s[l],delete o[l]}e.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(n.style,s),await n.animate(i,e).finished,Object.assign(n.style,o)}}get keyframes(){let t=[];for(let n of this.getAttributeNames()){let e=this.getAttribute(n),[,,i,...s]=n.split("-");if(n.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(i&&o){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let r=Number(i),a=t.find(l=>l.offset===r);a?a[o]=e:t.push({[o]:e,offset:r})}}}return t.sort((n,e)=>Number(n.offset)-Number(e.offset)),t}};var f=class extends m{#t=parseInt(getComputedStyle(document.body).marginRight);constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}get#n(){return window.innerWidth-document.documentElement.clientWidth}set#i(t){document.body.style.marginRight=`${t}px`}set#s(t){document.body.style.overflow=t}#e(t){this.hasAttribute("remove-body-scroll")&&(this.#i=t?this.#t+this.#n:this.#t,this.#s=t?"hidden":"")}async show(){this.dialog.showModal(),this.#e(!0),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.#e(!1),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",t=>{t.key==="Escape"&&this.dialog.open&&(t.preventDefault(),this.close())}),this.hasAttribute("click-outside-close")&&this.dialog.addEventListener("click",t=>{let n=this.dialog.getBoundingClientRect();(t.clientX<n.left||t.clientX>n.right||t.clientY<n.top||t.clientY>n.bottom)&&this.close()})}};})();
|
package/editor/define.iife.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#n=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let s=this.querySelector(this.getAttribute("content")??"[data-content]");if(s instanceof t)return s;throw new Error("Content not found")}swapContent(t=!0,s=800){let n=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(n){let e=Array.from(this.getContent().childNodes),i=[];n instanceof HTMLTemplateElement?(i.push(n.content.cloneNode(!0)),n.content.replaceChildren(...e)):(i.push(...n.childNodes),n.replaceChildren(...e)),this.getContent().replaceChildren(...i),t&&setTimeout(()=>this.swapContent(!1),s)}}safeListener(t,s,n=document.body,e={}){e.signal=this.#n.signal,n.addEventListener(t,s,e)}triggerListener(t,s=this.event,n){for(let e of this.getTrigger())e.addEventListener(s,t,n)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#n.abort()}};var f=class extends c{#n=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#o)t.type==="wrap"&&(this.keyPairs[t.value]=t.value)}get textArea(){return this.getContent(HTMLTextAreaElement)}get text(){return this.textArea.value}set text(t){this.textArea.value=t}get#o(){let t=[];for(let s of this.getTrigger())t.push(this.#l(s));return t}get#h(){let t=this.text.split("```"),s=0;for(let[n,e]of t.entries())if(s+=e.length+3,this.#e<s)return n;return 0}get#t(){return this.textArea.selectionEnd}get#e(){return this.textArea.selectionStart}#s(t,s){this.textArea.setSelectionRange(t,s)}#l(t){let s=t.dataset.type,n=t.dataset.value,e=t.dataset.key??void 0;return{type:s,value:n,key:e}}async#c(t,s,n){if(t.type==="inline")this.text=`${this.text.slice(0,n)}${t.value}${this.text.slice(n)}`;else if(t.type==="wrap")this.text=v(this.text,t.value,s),this.text=v(this.text,this.keyPairs[t.value],n+t.value.length),t.value.length<2&&this.#n.push(t.value);else if(t.type==="block"){let{lines:e,lineNumber:i}=this.#r(),r=t.value.at(0);r&&e[i]?.startsWith(r)?e[i]=t.value.trim()+e[i]:e[i]=t.value+e[i],this.text=e.join(`
|
2
|
-
`)}}async#u(t,s,n){let e=0,i=0;if(/[a-z]/i.test(t)){for(let r=n;r<this.text.length;r++)if(this.text[r]?.match(/[a-z]/i))e?i=r+1:e=r;else if(e)break}else e=s+t.length,i=n+t.length;this.#s(e,i),this.textArea.focus()}async#i(t){let s=this.#t,n=this.#e;await this.#c(t,n,s),this.#u(t.value,n,s)}#f(t){if(t){let s=[];this.#o.forEach(e=>{e.type==="block"&&s.push(e.value)});for(let e=0;e<s.length;e++){let i=s[e];if(i&&t.startsWith(i))return i}let n=p(t);if(n)return`${n}. `}return""}#r(){let t=this.text.split(`
|
3
|
-
`),s=0;for(let n=0;n<t.length;n++){let e=t.at(n)?.length??0;if(s++,s+=e,s>this.#t)return{lines:t,lineNumber:n,columnNumber:this.#t-(s-e-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#a(t,s=!1){let{lines:n}=this.#r();for(let e=t+1;e<n.length;e++){let i=n[e];if(i){let r=p(i);if(r){let o;if(s)if(r>1)o=r-1;else break;else o=r+1;n[e]=i.slice(String(r).length),n[e]=String(o)+n[e]}else break}}this.text=n.join(`
|
4
|
-
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let s=["ArrowUp","ArrowDown","Delete"],n=this.text[this.#t]??"";if(s.includes(t.key))this.#n=[];else if(t.key==="Backspace"){let e=this.text[this.#e-1];if(e&&e in this.keyPairs&&n===this.keyPairs[e]){t.preventDefault();let i=this.#e-1,r=this.#t-1;this.text=u(this.text,i),this.text=u(this.text,r),setTimeout(()=>{this.#s(i,r)},0),this.#n.pop()}if(e===`
|
5
|
-
`&&this.#e===this.#t){t.preventDefault();let i=this.#e-1,{lineNumber:r}=this.#r();this.#a(r,!0),this.text=u(this.text,i),setTimeout(async()=>{this.#s(i,i)},0)}}else if(t.key==="Tab")this.#h%2!==0&&(t.preventDefault(),await this.#i({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:e,lineNumber:i,columnNumber:r}=this.#r(),o=e.at(i),a=this.#f(o),h=a,g=p(a);if(g&&(a=`${g+1}. `),a&&h.length<r)t.preventDefault(),g&&this.#a(i),await this.#i({type:"inline",value:`
|
6
|
-
${a}`});else if(a&&h.length===r){t.preventDefault();let d=this.#t,y=d-h.length;for(let m=0;m<h.length;m++)this.text=u(this.text,d-(m+1));setTimeout(async()=>{this.#s(y,y),this.textArea.focus(),await this.#i({type:"inline",value:`
|
7
|
-
`})},0)}}else{let e=Object.values(this.keyPairs).includes(n),i=this.#e!==this.#t;if((t.ctrlKey||t.metaKey)&&this.#e===this.#t&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:r,lineNumber:o,columnNumber:a}=this.#r();if(await navigator.clipboard.writeText(`${o===0&&t.key==="x"?"":`
|
8
|
-
`}${r[o]}`),t.key==="x"){let h=this.#e-a;r.splice(o,1),this.text=r.join(`
|
9
|
-
`),setTimeout(()=>{this.#s(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#o.find(o=>o.key===t.key);r&&this.#i(r)}else e&&(n===t.key||t.key==="ArrowRight")&&this.#n.length&&!i?(t.preventDefault(),this.#s(this.#e+1,this.#t+1),this.#n.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#i({type:"wrap",value:t.key}),this.#n.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#s(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#s(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#n=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#i(this.#l(t))})}},p=l=>{let t=l.match(/^(\d+)\./);return t?Number(t[1]):null},v=(l,t,s)=>l.slice(0,s)+t+l.slice(s),u=(l,t)=>l.slice(0,t)+l.slice(t+1);customElements.define("drab-editor",f);})();
|
package/editor/index.iife.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#n=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let s=this.querySelector(this.getAttribute("content")??"[data-content]");if(s instanceof t)return s;throw new Error("Content not found")}swapContent(t=!0,s=800){let n=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(n){let e=Array.from(this.getContent().childNodes),i=[];n instanceof HTMLTemplateElement?(i.push(n.content.cloneNode(!0)),n.content.replaceChildren(...e)):(i.push(...n.childNodes),n.replaceChildren(...e)),this.getContent().replaceChildren(...i),t&&setTimeout(()=>this.swapContent(!1),s)}}safeListener(t,s,n=document.body,e={}){e.signal=this.#n.signal,n.addEventListener(t,s,e)}triggerListener(t,s=this.event,n){for(let e of this.getTrigger())e.addEventListener(s,t,n)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#n.abort()}};var y=class extends c{#n=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#o)t.type==="wrap"&&(this.keyPairs[t.value]=t.value)}get textArea(){return this.getContent(HTMLTextAreaElement)}get text(){return this.textArea.value}set text(t){this.textArea.value=t}get#o(){let t=[];for(let s of this.getTrigger())t.push(this.#l(s));return t}get#h(){let t=this.text.split("```"),s=0;for(let[n,e]of t.entries())if(s+=e.length+3,this.#e<s)return n;return 0}get#t(){return this.textArea.selectionEnd}get#e(){return this.textArea.selectionStart}#s(t,s){this.textArea.setSelectionRange(t,s)}#l(t){let s=t.dataset.type,n=t.dataset.value,e=t.dataset.key??void 0;return{type:s,value:n,key:e}}async#c(t,s,n){if(t.type==="inline")this.text=`${this.text.slice(0,n)}${t.value}${this.text.slice(n)}`;else if(t.type==="wrap")this.text=v(this.text,t.value,s),this.text=v(this.text,this.keyPairs[t.value],n+t.value.length),t.value.length<2&&this.#n.push(t.value);else if(t.type==="block"){let{lines:e,lineNumber:i}=this.#r(),r=t.value.at(0);r&&e[i]?.startsWith(r)?e[i]=t.value.trim()+e[i]:e[i]=t.value+e[i],this.text=e.join(`
|
2
|
-
`)}}async#u(t,s,n){let e=0,i=0;if(/[a-z]/i.test(t)){for(let r=n;r<this.text.length;r++)if(this.text[r]?.match(/[a-z]/i))e?i=r+1:e=r;else if(e)break}else e=s+t.length,i=n+t.length;this.#s(e,i),this.textArea.focus()}async#i(t){let s=this.#t,n=this.#e;await this.#c(t,n,s),this.#u(t.value,n,s)}#f(t){if(t){let s=[];this.#o.forEach(e=>{e.type==="block"&&s.push(e.value)});for(let e=0;e<s.length;e++){let i=s[e];if(i&&t.startsWith(i))return i}let n=m(t);if(n)return`${n}. `}return""}#r(){let t=this.text.split(`
|
3
|
-
`),s=0;for(let n=0;n<t.length;n++){let e=t.at(n)?.length??0;if(s++,s+=e,s>this.#t)return{lines:t,lineNumber:n,columnNumber:this.#t-(s-e-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#a(t,s=!1){let{lines:n}=this.#r();for(let e=t+1;e<n.length;e++){let i=n[e];if(i){let r=m(i);if(r){let o;if(s)if(r>1)o=r-1;else break;else o=r+1;n[e]=i.slice(String(r).length),n[e]=String(o)+n[e]}else break}}this.text=n.join(`
|
4
|
-
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let s=["ArrowUp","ArrowDown","Delete"],n=this.text[this.#t]??"";if(s.includes(t.key))this.#n=[];else if(t.key==="Backspace"){let e=this.text[this.#e-1];if(e&&e in this.keyPairs&&n===this.keyPairs[e]){t.preventDefault();let i=this.#e-1,r=this.#t-1;this.text=u(this.text,i),this.text=u(this.text,r),setTimeout(()=>{this.#s(i,r)},0),this.#n.pop()}if(e===`
|
5
|
-
`&&this.#e===this.#t){t.preventDefault();let i=this.#e-1,{lineNumber:r}=this.#r();this.#a(r,!0),this.text=u(this.text,i),setTimeout(async()=>{this.#s(i,i)},0)}}else if(t.key==="Tab")this.#h%2!==0&&(t.preventDefault(),await this.#i({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:e,lineNumber:i,columnNumber:r}=this.#r(),o=e.at(i),a=this.#f(o),h=a,f=m(a);if(f&&(a=`${f+1}. `),a&&h.length<r)t.preventDefault(),f&&this.#a(i),await this.#i({type:"inline",value:`
|
6
|
-
${a}`});else if(a&&h.length===r){t.preventDefault();let p=this.#t,d=p-h.length;for(let g=0;g<h.length;g++)this.text=u(this.text,p-(g+1));setTimeout(async()=>{this.#s(d,d),this.textArea.focus(),await this.#i({type:"inline",value:`
|
7
|
-
`})},0)}}else{let e=Object.values(this.keyPairs).includes(n),i=this.#e!==this.#t;if((t.ctrlKey||t.metaKey)&&this.#e===this.#t&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:r,lineNumber:o,columnNumber:a}=this.#r();if(await navigator.clipboard.writeText(`${o===0&&t.key==="x"?"":`
|
8
|
-
`}${r[o]}`),t.key==="x"){let h=this.#e-a;r.splice(o,1),this.text=r.join(`
|
9
|
-
`),setTimeout(()=>{this.#s(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#o.find(o=>o.key===t.key);r&&this.#i(r)}else e&&(n===t.key||t.key==="ArrowRight")&&this.#n.length&&!i?(t.preventDefault(),this.#s(this.#e+1,this.#t+1),this.#n.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#i({type:"wrap",value:t.key}),this.#n.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#s(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#s(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#n=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#i(this.#l(t))})}},m=l=>{let t=l.match(/^(\d+)\./);return t?Number(t[1]):null},v=(l,t,s)=>l.slice(0,s)+t+l.slice(s),u=(l,t)=>l.slice(0,t)+l.slice(t+1);})();
|
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var s=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof e)return n;throw new Error("Content not found")}swapContent(e=!0,n=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let r=Array.from(this.getContent().childNodes),i=[];t instanceof HTMLTemplateElement?(i.push(t.content.cloneNode(!0)),t.content.replaceChildren(...r)):(i.push(...t.childNodes),t.replaceChildren(...r)),this.getContent().replaceChildren(...i),e&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(e,n,t=document.body,r={}){r.signal=this.#e.signal,t.addEventListener(e,n,r)}triggerListener(e,n=this.event,t){for(let r of this.getTrigger())r.addEventListener(n,e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var o=class extends s{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let e of this.getTrigger())!this.fullscreenSupported()&&"disabled"in e&&(e.disabled=!0)}};customElements.define("drab-fullscreen",o);})();
|
package/fullscreen/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var s=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof e)return n;throw new Error("Content not found")}swapContent(e=!0,n=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let r=Array.from(this.getContent().childNodes),o=[];t instanceof HTMLTemplateElement?(o.push(t.content.cloneNode(!0)),t.content.replaceChildren(...r)):(o.push(...t.childNodes),t.replaceChildren(...r)),this.getContent().replaceChildren(...o),e&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(e,n,t=document.body,r={}){r.signal=this.#e.signal,t.addEventListener(e,n,r)}triggerListener(e,n=this.event,t){for(let r of this.getTrigger())r.addEventListener(n,e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var i=class extends s{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let e of this.getTrigger())!this.fullscreenSupported()&&"disabled"in e&&(e.disabled=!0)}};})();
|
package/index.d.ts
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Base } from "./base/index.js";
|
2
|
-
import { Animate, type AnimateAttributes } from "./animate/index.js";
|
3
|
-
import { Breakpoint, type BreakpointAttributes } from "./breakpoint/index.js";
|
4
|
-
import { ContextMenu, type ContextMenuAttributes } from "./contextmenu/index.js";
|
5
|
-
import { Copy, type CopyAttributes } from "./copy/index.js";
|
6
|
-
import { Details, type DetailsAttributes } from "./details/index.js";
|
7
|
-
import { Dialog, type DialogAttributes } from "./dialog/index.js";
|
8
|
-
import { Editor, type EditorAttributes } from "./editor/index.js";
|
9
|
-
import { Fullscreen, type FullscreenAttributes } from "./fullscreen/index.js";
|
10
|
-
import { Intersect, type IntersectAttributes } from "./intersect/index.js";
|
11
|
-
import { Popover, type PopoverAttributes } from "./popover/index.js";
|
12
|
-
import { Prefetch, type PrefetchAttributes } from "./prefetch/index.js";
|
13
|
-
import { Share, type ShareAttributes } from "./share/index.js";
|
14
|
-
import { TableSort, type TableSortAttributes } from "./tablesort/index.js";
|
15
|
-
import { WakeLock, type WakeLockAttributes } from "./wakelock/index.js";
|
16
|
-
import { YouTube, type YouTubeAttributes } from "./youtube/index.js";
|
17
|
-
export { Base, Animate, AnimateAttributes, Breakpoint, BreakpointAttributes, ContextMenu, ContextMenuAttributes, Copy, CopyAttributes, Details, DetailsAttributes, Dialog, DialogAttributes, Editor, EditorAttributes, Fullscreen, FullscreenAttributes, Intersect, IntersectAttributes, Popover, PopoverAttributes, Prefetch, PrefetchAttributes, Share, ShareAttributes, TableSort, TableSortAttributes, WakeLock, WakeLockAttributes, YouTube, YouTubeAttributes, };
|
package/index.iife.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let e=this.querySelector(this.getAttribute("content")??"[data-content]");if(e instanceof t)return e;throw new Error("Content not found")}swapContent(t=!0,e=800){let i=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(i){let s=Array.from(this.getContent().childNodes),r=[];i instanceof HTMLTemplateElement?(r.push(i.content.cloneNode(!0)),i.content.replaceChildren(...s)):(r.push(...i.childNodes),i.replaceChildren(...s)),this.getContent().replaceChildren(...r),t&&setTimeout(()=>this.swapContent(!1),e)}}safeListener(t,e,i=document.body,s={}){s.signal=this.#t.signal,i.addEventListener(t,e,s)}triggerListener(t,e=this.event,i){for(let s of this.getTrigger())s.addEventListener(e,t,i)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var p=class extends c{constructor(){super()}get animationOptions(){let t={};for(let e of this.getAttributeNames())if(e.startsWith("animation-option-")){let i=this.getAttribute(e),[,,s]=e.split("-");i&&(s==="duration"||s==="delay"?t[s]=Number(i):s==="easing"&&(t[s]=i))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:i={}}=t,s=this.keyframes;if(s.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){i=Object.assign(this.animationOptions,i),i.duration||(i.duration=200),i.easing||(i.easing="ease-in-out");let r=s.at(0),n=s.at(-1);if(r&&n){let u=["composite","easing","offset"];for(let l of u)delete r[l],delete n[l]}i.direction?.includes("reverse")&&([r,n]=[n,r]),Object.assign(e.style,r),await e.animate(s,i).finished,Object.assign(e.style,n)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let i=this.getAttribute(e),[,,s,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let n=r.map((o,u)=>u<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(s&&n){s==="from"?s="0":s==="to"?s="1":s=String(parseInt(s)*.01);let o=Number(s),u=t.find(l=>l.offset===o);u?u[n]=i:t.push({[n]:i,offset:o})}}}return t.sort((e,i)=>Number(e.offset)-Number(i.offset)),t}};var y=class extends c{breakpoints=[{name:"sm",width:640},{name:"md",width:768},{name:"lg",width:1024},{name:"xl",width:1280},{name:"2xl",width:1536}];constructor(){super();let t=[];for(let e of this.getAttributeNames())if(e.startsWith("breakpoint-")){let[,...i]=e.split("-");i&&t.push({name:i.join("-"),width:Number(this.getAttribute(e))})}t.length&&(this.breakpoints=t),this.breakpoints.sort((e,i)=>i.width-e.width)}get breakpoint(){for(let t=0;t<this.breakpoints.length;t++){let e=this.breakpoints[t];if(e&&window.innerWidth>e.width)return e.name}return"none"}mount(){let t=()=>this.getContent().innerHTML=`${this.breakpoint}:${window.innerWidth}`;t(),this.safeListener("resize",t,window)}};var A=class extends p{#t;constructor(){super()}set#i(t){this.getContent().style.left=`${t.x}px`,this.getContent().style.top=`${t.y}px`}async show(t){let e=window.scrollY,i=window.scrollX,s=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,n=s+i,o=r+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let u=this.getContent().offsetWidth+24,l=this.getContent().offsetHeight+6,h=window.innerWidth,m=window.innerHeight;n+u>i+h&&(n=i+h-u),o+l>e+m&&(o=e+m-l),this.#i={x:n,y:o},await this.animateElement()}async hide(){this.getContent().style.display!=="none"&&(await this.animateElement({options:{direction:"reverse"}}),this.getContent().style.display="none")}mount(){this.triggerListener(e=>{e.preventDefault(),this.show(e)},"contextmenu"),this.safeListener("click",()=>this.hide()),this.triggerListener(e=>{this.#t=setTimeout(()=>{this.show(e)},800)},"touchstart",{passive:!0});let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend",{passive:!0}),this.triggerListener(t,"touchcancel",{passive:!0}),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};var f=class extends c{constructor(){super()}get value(){return this.getAttribute("value")??""}set value(t){this.setAttribute("value",t)}async copy(t=this.value){await navigator.clipboard.writeText(t),this.swapContent()}};var v=class extends f{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var k=class extends p{constructor(){super()}get details(){let t=this.getContent(HTMLElement).parentElement;if(!(t instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return t}async open(){this.details.open=!0,await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.details.open=!1}toggle(){this.details.open?this.close():this.open()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()})}};var x=class extends p{#t=parseInt(getComputedStyle(document.body).marginRight);constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}get#i(){return window.innerWidth-document.documentElement.clientWidth}set#r(t){document.body.style.marginRight=`${t}px`}set#e(t){document.body.style.overflow=t}#s(t){this.hasAttribute("remove-body-scroll")&&(this.#r=t?this.#t+this.#i:this.#t,this.#e=t?"hidden":"")}async show(){this.dialog.showModal(),this.#s(!0),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.#s(!1),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",t=>{t.key==="Escape"&&this.dialog.open&&(t.preventDefault(),this.close())}),this.hasAttribute("click-outside-close")&&this.dialog.addEventListener("click",t=>{let e=this.dialog.getBoundingClientRect();(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this.close()})}};var E=class extends c{#t=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#i)t.type==="wrap"&&(this.keyPairs[t.value]=t.value)}get textArea(){return this.getContent(HTMLTextAreaElement)}get text(){return this.textArea.value}set text(t){this.textArea.value=t}get#i(){let t=[];for(let e of this.getTrigger())t.push(this.#l(e));return t}get#r(){let t=this.text.split("```"),e=0;for(let[i,s]of t.entries())if(e+=s.length+3,this.#s<e)return i;return 0}get#e(){return this.textArea.selectionEnd}get#s(){return this.textArea.selectionStart}#n(t,e){this.textArea.setSelectionRange(t,e)}#l(t){let e=t.dataset.type,i=t.dataset.value,s=t.dataset.key??void 0;return{type:e,value:i,key:s}}async#c(t,e,i){if(t.type==="inline")this.text=`${this.text.slice(0,i)}${t.value}${this.text.slice(i)}`;else if(t.type==="wrap")this.text=P(this.text,t.value,e),this.text=P(this.text,this.keyPairs[t.value],i+t.value.length),t.value.length<2&&this.#t.push(t.value);else if(t.type==="block"){let{lines:s,lineNumber:r}=this.#a(),n=t.value.at(0);n&&s[r]?.startsWith(n)?s[r]=t.value.trim()+s[r]:s[r]=t.value+s[r],this.text=s.join(`
|
2
|
-
`)}}async#h(t,e,i){let s=0,r=0;if(/[a-z]/i.test(t)){for(let n=i;n<this.text.length;n++)if(this.text[n]?.match(/[a-z]/i))s?r=n+1:s=n;else if(s)break}else s=e+t.length,r=i+t.length;this.#n(s,r),this.textArea.focus()}async#o(t){let e=this.#e,i=this.#s;await this.#c(t,i,e),this.#h(t.value,i,e)}#p(t){if(t){let e=[];this.#i.forEach(s=>{s.type==="block"&&e.push(s.value)});for(let s=0;s<e.length;s++){let r=e[s];if(r&&t.startsWith(r))return r}let i=w(t);if(i)return`${i}. `}return""}#a(){let t=this.text.split(`
|
3
|
-
`),e=0;for(let i=0;i<t.length;i++){let s=t.at(i)?.length??0;if(e++,e+=s,e>this.#e)return{lines:t,lineNumber:i,columnNumber:this.#e-(e-s-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#u(t,e=!1){let{lines:i}=this.#a();for(let s=t+1;s<i.length;s++){let r=i[s];if(r){let n=w(r);if(n){let o;if(e)if(n>1)o=n-1;else break;else o=n+1;i[s]=r.slice(String(n).length),i[s]=String(o)+i[s]}else break}}this.text=i.join(`
|
4
|
-
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let e=["ArrowUp","ArrowDown","Delete"],i=this.text[this.#e]??"";if(e.includes(t.key))this.#t=[];else if(t.key==="Backspace"){let s=this.text[this.#s-1];if(s&&s in this.keyPairs&&i===this.keyPairs[s]){t.preventDefault();let r=this.#s-1,n=this.#e-1;this.text=d(this.text,r),this.text=d(this.text,n),setTimeout(()=>{this.#n(r,n)},0),this.#t.pop()}if(s===`
|
5
|
-
`&&this.#s===this.#e){t.preventDefault();let r=this.#s-1,{lineNumber:n}=this.#a();this.#u(n,!0),this.text=d(this.text,r),setTimeout(async()=>{this.#n(r,r)},0)}}else if(t.key==="Tab")this.#r%2!==0&&(t.preventDefault(),await this.#o({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:s,lineNumber:r,columnNumber:n}=this.#a(),o=s.at(r),u=this.#p(o),l=u,h=w(u);if(h&&(u=`${h+1}. `),u&&l.length<n)t.preventDefault(),h&&this.#u(r),await this.#o({type:"inline",value:`
|
6
|
-
${u}`});else if(u&&l.length===n){t.preventDefault();let m=this.#e,g=m-l.length;for(let b=0;b<l.length;b++)this.text=d(this.text,m-(b+1));setTimeout(async()=>{this.#n(g,g),this.textArea.focus(),await this.#o({type:"inline",value:`
|
7
|
-
`})},0)}}else{let s=Object.values(this.keyPairs).includes(i),r=this.#s!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#s===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:n,lineNumber:o,columnNumber:u}=this.#a();if(await navigator.clipboard.writeText(`${o===0&&t.key==="x"?"":`
|
8
|
-
`}${n[o]}`),t.key==="x"){let l=this.#s-u;n.splice(o,1),this.text=n.join(`
|
9
|
-
`),setTimeout(()=>{this.#n(l,l)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#i.find(o=>o.key===t.key);n&&this.#o(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#n(this.#s+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#o({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#s!==this.#e&&(this.text[this.#s]===" "&&this.#n(this.#s+1,this.#e),this.text[this.#e-1]===" "&&this.#n(this.#s,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#o(this.#l(t))})}},w=a=>{let t=a.match(/^(\d+)\./);return t?Number(t[1]):null},P=(a,t,e)=>a.slice(0,e)+t+a.slice(e),d=(a,t)=>a.slice(0,t)+a.slice(t+1);var T=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var L=class extends c{#t=[];#i=[];constructor(){super()}get#r(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#i.push(t)}mount(){let t=new IntersectionObserver(e=>{let i="data-intersect";for(let s of e)if(s.isIntersecting){this.getContent().setAttribute(i,"");for(let r of this.#t)r()}else{this.getContent().removeAttribute(i);for(let r of this.#i)r()}},{threshold:this.#r});for(let e of this.getTrigger())t.observe(e)}};var C=class extends p{constructor(){super()}get open(){return this.hasAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(t=>{t.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",t=>{t.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",t=>{t.key==="Escape"&&this.open&&(t.preventDefault(),this.hide())})}};var M=class extends c{#t=[];constructor(){super()}get#i(){return this.getAttribute("strategy")??"hover"}get#r(){return this.hasAttribute("prerender")}get#e(){return this.getAttribute("url")}appendTag(t){let{url:e,prerender:i}=t;if(e!==window.location.href&&!this.#t.includes(e))if(this.#t.push(e),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let s={prefetch:[{source:"list",urls:[e]}]};i&&(s.prerender=s.prefetch);let r=document.createElement("script");r.type="speculationrules",r.textContent=JSON.stringify(s),document.head.append(r)}else{let s=document.createElement("link");s.rel="prefetch",s.as="document",s.href=e,document.head.append(s)}}prefetch(t={anchors:this.getTrigger(),prerender:this.#r,strategy:this.#i}){let{anchors:e=this.getTrigger(),prerender:i=this.#r,strategy:s=this.#i}=t,r,n=(l=200)=>h=>{let{href:m}=h.currentTarget;r=setTimeout(()=>this.appendTag({url:m,prerender:i}),l)},o=()=>clearTimeout(r),u=new IntersectionObserver(l=>{for(let h of l)h.isIntersecting&&this.appendTag({url:h.target.href,prerender:i})});for(let l of e)s==="load"?this.appendTag({url:l.href,prerender:i}):s==="visible"?u.observe(l):(l.addEventListener("mouseover",n()),l.addEventListener("mouseout",o),l.addEventListener("focus",n()),l.addEventListener("focusout",o),l.addEventListener("touchstart",n(0),{passive:!0}))}mount(){this.#e&&this.appendTag({url:this.#e,prerender:this.#r}),this.prefetch()}};var S=class extends f{constructor(){super()}async share(t=this.value){if(navigator.canShare&&navigator.canShare({url:t}))try{await navigator.share({url:t})}catch(e){e?.name!=="AbortError"&&console.error(e)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};var H=class extends c{constructor(){super()}#t(t){let e="data-asc",i="data-desc";for(let s of this.getTrigger())s!==t&&(s.removeAttribute(e),s.removeAttribute(i));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(i,""),!1):(t.removeAttribute(i),t.setAttribute(e,""),!0)}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(W(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},W=(a,t)=>(i,s)=>{let r=Array.from(a.parentNode?.children??[]).indexOf(a);return((o,u)=>{let l=a.dataset.type??"string";if(l==="string")return new Intl.Collator().compare(o,u);if(l==="boolean"){let h=m=>["0","false","null","undefined"].includes(m)?!1:!!m;return h(o)===h(u)?0:h(o)?-1:1}else return Number(o)-Number(u)})(B(t?i:s,r),B(t?s:i,r))},B=(a,t)=>{let e=a.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var N=class extends c{wakeLock=null;constructor(){super()}#t(){return"wakeLock"in navigator}get#i(){return this.hasAttribute("auto-lock")}async request(){this.#t()&&document.visibilityState==="visible"&&(this.wakeLock=await navigator.wakeLock.request("screen"),this.setAttribute("locked",""),this.swapContent(!1),this.wakeLock.addEventListener("release",()=>{this.removeAttribute("locked"),this.swapContent(!1),this.#i||(this.wakeLock=null)}))}async release(){await this.wakeLock?.release(),this.wakeLock=null}mount(){this.hasAttribute("locked")&&this.request(),this.triggerListener(()=>{this.wakeLock?this.release():this.request()});for(let t of this.getTrigger())!this.#t()&&"disabled"in t&&(t.disabled=!0);this.#i&&this.safeListener("visibilitychange",()=>{this.wakeLock&&this.request()},document)}destroy(){this.release()}};var D=class extends c{static observedAttributes=["autoplay","start","uid"];constructor(){super()}get iframe(){return this.getContent(HTMLIFrameElement)}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(t){t?this.setAttribute("autoplay",""):this.removeAttribute("autoplay")}get start(){return this.getAttribute("start")??"0"}set start(t){this.setAttribute("start",t)}get uid(){let t=this.getAttribute("uid");if(!t)throw new Error("YouTube: missing `uid` attribute.");return t}set uid(t){this.setAttribute("uid",t)}mount(){this.iframe.allowFullscreen=!0,this.iframe.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"}attributeChangedCallback(){queueMicrotask(()=>{this.iframe.src=`https://www.youtube-nocookie.com/embed/${this.uid}?start=${this.start}${this.autoplay?"&autoplay=1":""}`})}};})();
|
package/index.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
import { Base } from "./base/index.js";
|
2
|
-
import { Animate } from "./animate/index.js";
|
3
|
-
import { Breakpoint } from "./breakpoint/index.js";
|
4
|
-
import { ContextMenu, } from "./contextmenu/index.js";
|
5
|
-
import { Copy } from "./copy/index.js";
|
6
|
-
import { Details } from "./details/index.js";
|
7
|
-
import { Dialog } from "./dialog/index.js";
|
8
|
-
import { Editor } from "./editor/index.js";
|
9
|
-
import { Fullscreen } from "./fullscreen/index.js";
|
10
|
-
import { Intersect } from "./intersect/index.js";
|
11
|
-
import { Popover } from "./popover/index.js";
|
12
|
-
import { Prefetch } from "./prefetch/index.js";
|
13
|
-
import { Share } from "./share/index.js";
|
14
|
-
import { TableSort } from "./tablesort/index.js";
|
15
|
-
import { WakeLock } from "./wakelock/index.js";
|
16
|
-
import { YouTube } from "./youtube/index.js";
|
17
|
-
export { Base, Animate, Breakpoint, ContextMenu, Copy, Details, Dialog, Editor, Fullscreen, Intersect, Popover, Prefetch, Share, TableSort, WakeLock, YouTube, };
|
package/intersect/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var o=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof t)return n;throw new Error("Content not found")}swapContent(t=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let r=Array.from(this.getContent().childNodes),s=[];e instanceof HTMLTemplateElement?(s.push(e.content.cloneNode(!0)),e.content.replaceChildren(...r)):(s.push(...e.childNodes),e.replaceChildren(...r)),this.getContent().replaceChildren(...s),t&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(t,n,e=document.body,r={}){r.signal=this.#t.signal,e.addEventListener(t,n,r)}triggerListener(t,n=this.event,e){for(let r of this.getTrigger())r.addEventListener(n,t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var i=class extends o{#t=[];#e=[];constructor(){super()}get#n(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#e.push(t)}mount(){let t=new IntersectionObserver(n=>{let e="data-intersect";for(let r of n)if(r.isIntersecting){this.getContent().setAttribute(e,"");for(let s of this.#t)s()}else{this.getContent().removeAttribute(e);for(let s of this.#e)s()}},{threshold:this.#n});for(let n of this.getTrigger())t.observe(n)}};customElements.define("drab-intersect",i);})();
|
package/intersect/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var o=class extends HTMLElement{#t=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(t){this.setAttribute("event",t)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(t=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof t)return n;throw new Error("Content not found")}swapContent(t=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let r=Array.from(this.getContent().childNodes),s=[];e instanceof HTMLTemplateElement?(s.push(e.content.cloneNode(!0)),e.content.replaceChildren(...r)):(s.push(...e.childNodes),e.replaceChildren(...r)),this.getContent().replaceChildren(...s),t&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(t,n,e=document.body,r={}){r.signal=this.#t.signal,e.addEventListener(t,n,r)}triggerListener(t,n=this.event,e){for(let r of this.getTrigger())r.addEventListener(n,t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var i=class extends o{#t=[];#e=[];constructor(){super()}get#n(){return Number(this.getAttribute("threshold")??0)}onIntersect(t){this.#t.push(t)}onExit(t){this.#e.push(t)}mount(){let t=new IntersectionObserver(n=>{let e="data-intersect";for(let r of n)if(r.isIntersecting){this.getContent().setAttribute(e,"");for(let s of this.#t)s()}else{this.getContent().removeAttribute(e);for(let s of this.#e)s()}},{threshold:this.#n});for(let n of this.getTrigger())t.observe(n)}};})();
|
package/popover/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var l=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let i=this.querySelector(this.getAttribute("content")??"[data-content]");if(i instanceof e)return i;throw new Error("Content not found")}swapContent(e=!0,i=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let n=Array.from(this.getContent().childNodes),s=[];t instanceof HTMLTemplateElement?(s.push(t.content.cloneNode(!0)),t.content.replaceChildren(...n)):(s.push(...t.childNodes),t.replaceChildren(...n)),this.getContent().replaceChildren(...s),e&&setTimeout(()=>this.swapContent(!1),i)}}safeListener(e,i,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,i,n)}triggerListener(e,i=this.event,t){for(let n of this.getTrigger())n.addEventListener(i,e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var f=class extends l{constructor(){super()}get animationOptions(){let e={};for(let i of this.getAttributeNames())if(i.startsWith("animation-option-")){let t=this.getAttribute(i),[,,n]=i.split("-");t&&(n==="duration"||n==="delay"?e[n]=Number(t):n==="easing"&&(e[n]=t))}return e}async animateElement(e={element:this.getContent(),options:{}}){let{element:i=this.getContent(),options:t={}}=e,n=this.keyframes;if(n.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){t=Object.assign(this.animationOptions,t),t.duration||(t.duration=200),t.easing||(t.easing="ease-in-out");let s=n.at(0),o=n.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let m of a)delete s[m],delete o[m]}t.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(i.style,s),await i.animate(n,t).finished,Object.assign(i.style,o)}}get keyframes(){let e=[];for(let i of this.getAttributeNames()){let t=this.getAttribute(i),[,,n,...s]=i.split("-");if(i.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&o){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let r=Number(n),a=e.find(m=>m.offset===r);a?a[o]=t:e.push({[o]:t,offset:r})}}}return e.sort((i,t)=>Number(i.offset)-Number(t.offset)),e}};var p=class extends f{constructor(){super()}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(e=>{e.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",e=>{e.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",e=>{e.key==="Escape"&&this.open&&(e.preventDefault(),this.hide())})}};customElements.define("drab-popover",p);})();
|
package/popover/define.js
DELETED
package/popover/index.d.ts
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
import { Animate, type AnimateAttributes } from "../animate/index.js";
|
2
|
-
import type { Attributes } from "../types/index.js";
|
3
|
-
export type PopoverAttributes = Attributes<Popover> & AnimateAttributes;
|
4
|
-
/**
|
5
|
-
* Provides animations for the Popover API.
|
6
|
-
*
|
7
|
-
* This component can be deprecated once it can be animated with CSS only,
|
8
|
-
* currently [only available in Chrome](https://developer.chrome.com/blog/introducing-popover-api#interactive_entry_and_exit).
|
9
|
-
*/
|
10
|
-
export declare class Popover extends Animate {
|
11
|
-
constructor();
|
12
|
-
/**
|
13
|
-
* Whether the popover is open or closed. This doesn't get set
|
14
|
-
* automatically on the element like with the `HTMLDialogElement`.
|
15
|
-
*/
|
16
|
-
get open(): boolean;
|
17
|
-
set open(value: boolean);
|
18
|
-
/** `HTMLElement.showPopover()` with animation. */
|
19
|
-
show(): Promise<void>;
|
20
|
-
/** `HTMLElement.hidePopover()` with animation. */
|
21
|
-
hide(): Promise<void>;
|
22
|
-
/** `show` or `hide` depending on the current state. */
|
23
|
-
toggle(): Promise<void>;
|
24
|
-
mount(): void;
|
25
|
-
}
|
package/popover/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var m=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let i=this.querySelector(this.getAttribute("content")??"[data-content]");if(i instanceof e)return i;throw new Error("Content not found")}swapContent(e=!0,i=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let n=Array.from(this.getContent().childNodes),s=[];t instanceof HTMLTemplateElement?(s.push(t.content.cloneNode(!0)),t.content.replaceChildren(...n)):(s.push(...t.childNodes),t.replaceChildren(...n)),this.getContent().replaceChildren(...s),e&&setTimeout(()=>this.swapContent(!1),i)}}safeListener(e,i,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,i,n)}triggerListener(e,i=this.event,t){for(let n of this.getTrigger())n.addEventListener(i,e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let e={};for(let i of this.getAttributeNames())if(i.startsWith("animation-option-")){let t=this.getAttribute(i),[,,n]=i.split("-");t&&(n==="duration"||n==="delay"?e[n]=Number(t):n==="easing"&&(e[n]=t))}return e}async animateElement(e={element:this.getContent(),options:{}}){let{element:i=this.getContent(),options:t={}}=e,n=this.keyframes;if(n.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){t=Object.assign(this.animationOptions,t),t.duration||(t.duration=200),t.easing||(t.easing="ease-in-out");let s=n.at(0),o=n.at(-1);if(s&&o){let a=["composite","easing","offset"];for(let l of a)delete s[l],delete o[l]}t.direction?.includes("reverse")&&([s,o]=[o,s]),Object.assign(i.style,s),await i.animate(n,t).finished,Object.assign(i.style,o)}}get keyframes(){let e=[];for(let i of this.getAttributeNames()){let t=this.getAttribute(i),[,,n,...s]=i.split("-");if(i.startsWith("animation-keyframe-")){let o=s.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&o){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let r=Number(n),a=e.find(l=>l.offset===r);a?a[o]=t:e.push({[o]:t,offset:r})}}}return e.sort((i,t)=>Number(i.offset)-Number(t.offset)),e}};var c=class extends f{constructor(){super()}get open(){return this.hasAttribute("open")}set open(e){e?this.setAttribute("open",""):this.removeAttribute("open")}async show(){this.getContent().showPopover(),await this.animateElement()}async hide(){await this.animateElement({options:{direction:"reverse"}}),this.getContent().hidePopover()}async toggle(){this.open?this.hide():this.show()}mount(){this.triggerListener(e=>{e.preventDefault(),this.toggle()}),this.getContent().addEventListener("toggle",e=>{e.newState==="open"?this.open=!0:this.open=!1}),this.safeListener("keydown",e=>{e.key==="Escape"&&this.open&&(e.preventDefault(),this.hide())})}};})();
|
package/popover/index.js
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
import { Animate } from "../animate/index.js";
|
2
|
-
/**
|
3
|
-
* Provides animations for the Popover API.
|
4
|
-
*
|
5
|
-
* This component can be deprecated once it can be animated with CSS only,
|
6
|
-
* currently [only available in Chrome](https://developer.chrome.com/blog/introducing-popover-api#interactive_entry_and_exit).
|
7
|
-
*/
|
8
|
-
export class Popover extends Animate {
|
9
|
-
constructor() {
|
10
|
-
super();
|
11
|
-
}
|
12
|
-
/**
|
13
|
-
* Whether the popover is open or closed. This doesn't get set
|
14
|
-
* automatically on the element like with the `HTMLDialogElement`.
|
15
|
-
*/
|
16
|
-
get open() {
|
17
|
-
return this.hasAttribute("open");
|
18
|
-
}
|
19
|
-
set open(value) {
|
20
|
-
if (value) {
|
21
|
-
this.setAttribute("open", "");
|
22
|
-
}
|
23
|
-
else {
|
24
|
-
this.removeAttribute("open");
|
25
|
-
}
|
26
|
-
}
|
27
|
-
/** `HTMLElement.showPopover()` with animation. */
|
28
|
-
async show() {
|
29
|
-
// @ts-ignore - not supported in FF
|
30
|
-
this.getContent().showPopover();
|
31
|
-
await this.animateElement();
|
32
|
-
}
|
33
|
-
/** `HTMLElement.hidePopover()` with animation. */
|
34
|
-
async hide() {
|
35
|
-
await this.animateElement({
|
36
|
-
options: {
|
37
|
-
direction: "reverse",
|
38
|
-
},
|
39
|
-
});
|
40
|
-
// @ts-ignore - not supported in FF
|
41
|
-
this.getContent().hidePopover();
|
42
|
-
}
|
43
|
-
/** `show` or `hide` depending on the current state. */
|
44
|
-
async toggle() {
|
45
|
-
if (this.open)
|
46
|
-
this.hide();
|
47
|
-
else
|
48
|
-
this.show();
|
49
|
-
}
|
50
|
-
mount() {
|
51
|
-
this.triggerListener((e) => {
|
52
|
-
e.preventDefault();
|
53
|
-
this.toggle();
|
54
|
-
});
|
55
|
-
this.getContent().addEventListener("toggle", (e) => {
|
56
|
-
//@ts-expect-error - not supported in FF as of 1/23/24
|
57
|
-
if (e.newState === "open") {
|
58
|
-
this.open = true;
|
59
|
-
}
|
60
|
-
else {
|
61
|
-
this.open = false;
|
62
|
-
}
|
63
|
-
});
|
64
|
-
this.safeListener("keydown", (e) => {
|
65
|
-
if (e.key === "Escape" && this.open) {
|
66
|
-
// to execute animation
|
67
|
-
e.preventDefault();
|
68
|
-
this.hide();
|
69
|
-
}
|
70
|
-
});
|
71
|
-
}
|
72
|
-
}
|
package/prefetch/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var a=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(n){this.setAttribute("event",n)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(n=HTMLElement){let t=this.querySelector(this.getAttribute("content")??"[data-content]");if(t instanceof n)return t;throw new Error("Content not found")}swapContent(n=!0,t=800){let r=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(r){let e=Array.from(this.getContent().childNodes),o=[];r instanceof HTMLTemplateElement?(o.push(r.content.cloneNode(!0)),r.content.replaceChildren(...e)):(o.push(...r.childNodes),r.replaceChildren(...e)),this.getContent().replaceChildren(...o),n&&setTimeout(()=>this.swapContent(!1),t)}}safeListener(n,t,r=document.body,e={}){e.signal=this.#e.signal,r.addEventListener(n,t,e)}triggerListener(n,t=this.event,r){for(let e of this.getTrigger())e.addEventListener(t,n,r)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var c=class extends a{#e=[];constructor(){super()}get#r(){return this.getAttribute("strategy")??"hover"}get#t(){return this.hasAttribute("prerender")}get#n(){return this.getAttribute("url")}appendTag(n){let{url:t,prerender:r}=n;if(t!==window.location.href&&!this.#e.includes(t))if(this.#e.push(t),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let e={prefetch:[{source:"list",urls:[t]}]};r&&(e.prerender=e.prefetch);let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify(e),document.head.append(o)}else{let e=document.createElement("link");e.rel="prefetch",e.as="document",e.href=t,document.head.append(e)}}prefetch(n={anchors:this.getTrigger(),prerender:this.#t,strategy:this.#r}){let{anchors:t=this.getTrigger(),prerender:r=this.#t,strategy:e=this.#r}=n,o,l=(s=200)=>i=>{let{href:p}=i.currentTarget;o=setTimeout(()=>this.appendTag({url:p,prerender:r}),s)},u=()=>clearTimeout(o),h=new IntersectionObserver(s=>{for(let i of s)i.isIntersecting&&this.appendTag({url:i.target.href,prerender:r})});for(let s of t)e==="load"?this.appendTag({url:s.href,prerender:r}):e==="visible"?h.observe(s):(s.addEventListener("mouseover",l()),s.addEventListener("mouseout",u),s.addEventListener("focus",l()),s.addEventListener("focusout",u),s.addEventListener("touchstart",l(0),{passive:!0}))}mount(){this.#n&&this.appendTag({url:this.#n,prerender:this.#t}),this.prefetch()}};customElements.define("drab-prefetch",c);})();
|
package/prefetch/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var a=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(n){this.setAttribute("event",n)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(n=HTMLElement){let t=this.querySelector(this.getAttribute("content")??"[data-content]");if(t instanceof n)return t;throw new Error("Content not found")}swapContent(n=!0,t=800){let r=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(r){let e=Array.from(this.getContent().childNodes),o=[];r instanceof HTMLTemplateElement?(o.push(r.content.cloneNode(!0)),r.content.replaceChildren(...e)):(o.push(...r.childNodes),r.replaceChildren(...e)),this.getContent().replaceChildren(...o),n&&setTimeout(()=>this.swapContent(!1),t)}}safeListener(n,t,r=document.body,e={}){e.signal=this.#e.signal,r.addEventListener(n,t,e)}triggerListener(n,t=this.event,r){for(let e of this.getTrigger())e.addEventListener(t,n,r)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var u=class extends a{#e=[];constructor(){super()}get#r(){return this.getAttribute("strategy")??"hover"}get#t(){return this.hasAttribute("prerender")}get#n(){return this.getAttribute("url")}appendTag(n){let{url:t,prerender:r}=n;if(t!==window.location.href&&!this.#e.includes(t))if(this.#e.push(t),HTMLScriptElement.supports&&HTMLScriptElement.supports("speculationrules")){let e={prefetch:[{source:"list",urls:[t]}]};r&&(e.prerender=e.prefetch);let o=document.createElement("script");o.type="speculationrules",o.textContent=JSON.stringify(e),document.head.append(o)}else{let e=document.createElement("link");e.rel="prefetch",e.as="document",e.href=t,document.head.append(e)}}prefetch(n={anchors:this.getTrigger(),prerender:this.#t,strategy:this.#r}){let{anchors:t=this.getTrigger(),prerender:r=this.#t,strategy:e=this.#r}=n,o,l=(s=200)=>i=>{let{href:p}=i.currentTarget;o=setTimeout(()=>this.appendTag({url:p,prerender:r}),s)},c=()=>clearTimeout(o),h=new IntersectionObserver(s=>{for(let i of s)i.isIntersecting&&this.appendTag({url:i.target.href,prerender:r})});for(let s of t)e==="load"?this.appendTag({url:s.href,prerender:r}):e==="visible"?h.observe(s):(s.addEventListener("mouseover",l()),s.addEventListener("mouseout",c),s.addEventListener("focus",l()),s.addEventListener("focusout",c),s.addEventListener("touchstart",l(0),{passive:!0}))}mount(){this.#n&&this.appendTag({url:this.#n,prerender:this.#t}),this.prefetch()}};})();
|
package/share/define.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/share/define.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var s=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let t=this.querySelector(this.getAttribute("content")??"[data-content]");if(t instanceof e)return t;throw new Error("Content not found")}swapContent(e=!0,t=800){let n=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(n){let r=Array.from(this.getContent().childNodes),a=[];n instanceof HTMLTemplateElement?(a.push(n.content.cloneNode(!0)),n.content.replaceChildren(...r)):(a.push(...n.childNodes),n.replaceChildren(...r)),this.getContent().replaceChildren(...a),e&&setTimeout(()=>this.swapContent(!1),t)}}safeListener(e,t,n=document.body,r={}){r.signal=this.#e.signal,n.addEventListener(e,t,r)}triggerListener(e,t=this.event,n){for(let r of this.getTrigger())r.addEventListener(t,e,n)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var o=class extends s{constructor(){super()}get value(){return this.getAttribute("value")??""}set value(e){this.setAttribute("value",e)}async copy(e=this.value){await navigator.clipboard.writeText(e),this.swapContent()}};var i=class extends o{constructor(){super()}async share(e=this.value){if(navigator.canShare&&navigator.canShare({url:e}))try{await navigator.share({url:e})}catch(t){t?.name!=="AbortError"&&console.error(t)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};customElements.define("drab-share",i);})();
|
package/share/index.iife.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
"use strict";(()=>{var s=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let t=this.querySelector(this.getAttribute("content")??"[data-content]");if(t instanceof e)return t;throw new Error("Content not found")}swapContent(e=!0,t=800){let n=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(n){let r=Array.from(this.getContent().childNodes),i=[];n instanceof HTMLTemplateElement?(i.push(n.content.cloneNode(!0)),n.content.replaceChildren(...r)):(i.push(...n.childNodes),n.replaceChildren(...r)),this.getContent().replaceChildren(...i),e&&setTimeout(()=>this.swapContent(!1),t)}}safeListener(e,t,n=document.body,r={}){r.signal=this.#e.signal,n.addEventListener(e,t,r)}triggerListener(e,t=this.event,n){for(let r of this.getTrigger())r.addEventListener(t,e,n)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var o=class extends s{constructor(){super()}get value(){return this.getAttribute("value")??""}set value(e){this.setAttribute("value",e)}async copy(e=this.value){await navigator.clipboard.writeText(e),this.swapContent()}};var c=class extends o{constructor(){super()}async share(e=this.value){if(navigator.canShare&&navigator.canShare({url:e}))try{await navigator.share({url:e})}catch(t){t?.name!=="AbortError"&&console.error(t)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};})();
|
package/tablesort/define.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|