drab 5.0.0-beta.6 → 5.0.1

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.
Files changed (71) hide show
  1. package/README.md +0 -5
  2. package/animate/define.iife.js +1 -1
  3. package/animate/define.js +1 -1
  4. package/animate/index.d.ts +6 -1
  5. package/animate/index.iife.js +1 -1
  6. package/animate/index.js +1 -1
  7. package/breakpoint/define.js +1 -1
  8. package/breakpoint/index.d.ts +5 -1
  9. package/breakpoint/index.js +1 -1
  10. package/chunk-3ASUSP4D.js +1 -0
  11. package/chunk-4WBITBA6.js +1 -0
  12. package/{chunk-57VEEUFG.js → chunk-AWUCZCAJ.js} +1 -1
  13. package/{chunk-6HYPZWQ4.js → chunk-BCS5E3IH.js} +1 -1
  14. package/chunk-DKKPV7QP.js +1 -0
  15. package/chunk-F5BEEHGA.js +1 -0
  16. package/{chunk-7S6DTKGH.js → chunk-H4RNP4O4.js} +1 -1
  17. package/chunk-LHXOPRVC.js +1 -0
  18. package/chunk-XAP2U34A.js +1 -0
  19. package/contextmenu/define.iife.js +1 -1
  20. package/contextmenu/define.js +1 -1
  21. package/contextmenu/index.d.ts +4 -2
  22. package/contextmenu/index.iife.js +1 -1
  23. package/contextmenu/index.js +1 -1
  24. package/copy/define.iife.js +1 -1
  25. package/copy/define.js +1 -1
  26. package/copy/index.d.ts +4 -2
  27. package/copy/index.iife.js +1 -1
  28. package/copy/index.js +1 -1
  29. package/define/index.iife.js +9 -9
  30. package/define/index.js +1 -1
  31. package/details/define.iife.js +1 -1
  32. package/details/define.js +1 -1
  33. package/details/index.d.ts +4 -2
  34. package/details/index.iife.js +1 -1
  35. package/details/index.js +1 -1
  36. package/dialog/define.iife.js +1 -1
  37. package/dialog/define.js +1 -1
  38. package/dialog/index.d.ts +4 -2
  39. package/dialog/index.iife.js +1 -1
  40. package/dialog/index.js +1 -1
  41. package/editor/index.d.ts +3 -1
  42. package/editor/index.iife.js +7 -7
  43. package/fullscreen/define.iife.js +1 -1
  44. package/fullscreen/index.d.ts +3 -1
  45. package/{index-SyRipepB.d.ts → index-0rvQCq2U.d.ts} +2 -0
  46. package/index-J5TqSvEl.d.ts +12 -0
  47. package/index.d.ts +14 -13
  48. package/index.iife.js +9 -9
  49. package/index.js +1 -1
  50. package/package.json +3 -3
  51. package/popover/define.iife.js +1 -1
  52. package/popover/define.js +1 -1
  53. package/popover/index.d.ts +4 -2
  54. package/popover/index.iife.js +1 -1
  55. package/popover/index.js +1 -1
  56. package/share/define.js +1 -1
  57. package/share/index.d.ts +5 -3
  58. package/share/index.js +1 -1
  59. package/tablesort/define.iife.js +1 -1
  60. package/tablesort/define.js +1 -1
  61. package/tablesort/index.d.ts +3 -1
  62. package/tablesort/index.iife.js +1 -1
  63. package/tablesort/index.js +1 -1
  64. package/youtube/index.d.ts +3 -1
  65. package/youtube/index.iife.js +1 -1
  66. package/chunk-7KU2PRW5.js +0 -1
  67. package/chunk-G5WFHYNX.js +0 -1
  68. package/chunk-IQJQPZUL.js +0 -1
  69. package/chunk-JMJUWKN2.js +0 -1
  70. package/chunk-T7RZI3ZL.js +0 -1
  71. package/chunk-TSTTUEAF.js +0 -1
package/README.md CHANGED
@@ -1,10 +1,5 @@
1
1
  # A Headless Custom Element Library
2
2
 
3
- - [Docs](https://drab.robino.dev)
4
- - [GitHub](https://github.com/rossrobino/drab)
5
- - [npm](https://www.npmjs.com/package/drab)
6
- - [MIT License](https://github.com/rossrobino/drab/blob/main/LICENSE.md)
7
-
8
3
  ## Features
9
4
 
10
5
  **drab** focuses on providing JavaScript functionality where it's most useful. Many of the elements are helpful wrappers around browser APIs. Here are some of the features of the library.
@@ -1 +1 @@
1
- "use strict";(()=>{var m=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(s){this.setAttribute("event",s)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(s=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof s)return n;throw new Error("Content not found")}swapContent(s=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let t=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),s&&setTimeout(()=>this.getContent().replaceChildren(...t),n)}}safeListener(s,n,e=document.body,t={}){t.signal=this.#e.signal,e.addEventListener(s,n,t)}triggerListener(s,n=this.event){for(let e of this.getTrigger())e.addEventListener(n,s)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let s={};for(let n of this.getAttributeNames())if(n.startsWith("animation-option-")){let e=this.getAttribute(n),[,,t]=n.split("-");e&&(t==="duration"||t==="delay"?s[t]=Number(e):t==="easing"&&(s[t]=e))}return s}async animateElement(s={element:this.getContent(),options:{}}){let{element:n=this.getContent(),options:e={}}=s,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 r=t.at(0),i=t.at(-1);if(r&&i){let a=["composite","easing","offset"];for(let l of a)delete r[l],delete i[l]}e.direction?.includes("reverse")&&([r,i]=[i,r]),Object.assign(n.style,r),await n.animate(t,e).finished,Object.assign(n.style,i)}}get keyframes(){let s=[];for(let n of this.getAttributeNames()){let e=this.getAttribute(n),[,,t,...r]=n.split("-");if(n.startsWith("animation-keyframe-")){let i=r.map((o,a)=>a<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(t&&i){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let o=Number(t),a=s.find(l=>l.offset===o);a?a[i]=e:s.push({[i]:e,offset:o})}}}return s.sort((n,e)=>Number(n.offset)-Number(e.offset)),s}};customElements.define("drab-animate",f);})();
1
+ "use strict";(()=>{var l=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(i){this.setAttribute("event",i)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(i=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof i)return n;throw new Error("Content not found")}swapContent(i=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let t=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),i&&setTimeout(()=>this.getContent().replaceChildren(...t),n)}}safeListener(i,n,e=document.body,t={}){t.signal=this.#e.signal,e.addEventListener(i,n,t)}triggerListener(i,n=this.event){for(let e of this.getTrigger())e.addEventListener(n,i)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var f=class extends l{constructor(){super()}get animationOptions(){let i={};for(let n of this.getAttributeNames())if(n.startsWith("animation-option-")){let e=this.getAttribute(n),[,,t]=n.split("-");e&&(t==="duration"||t==="delay"?i[t]=Number(e):t==="easing"&&(i[t]=e))}return i}async animateElement(i={element:this.getContent(),options:{}}){let{element:n=this.getContent(),options:e={}}=i,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 o=t.at(0),s=t.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let m of a)delete o[m],delete s[m]}e.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(n.style,o),await n.animate(t,e).finished,Object.assign(n.style,s)}}get keyframes(){let i=[];for(let n of this.getAttributeNames()){let e=this.getAttribute(n),[,,t,...o]=n.split("-");if(n.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(t&&s){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let r=Number(t),a=i.find(m=>m.offset===r);a?a[s]=e:i.push({[s]:e,offset:r})}}}return i.sort((n,e)=>Number(n.offset)-Number(e.offset)),i}};customElements.define("drab-animate",f);})();
package/animate/define.js CHANGED
@@ -1 +1 @@
1
- import{a as e}from"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-animate",e);
1
+ import{a as e}from"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-animate",e);
@@ -1,5 +1,10 @@
1
1
  import { Base } from '../base/index.js';
2
2
 
3
+ type AnimationKeyframe = `animation-keyframe-${"from" | "to" | number}-${string}`;
4
+ type AnimationOption = `animation-option-${"easing" | "duration" | "delay"}`;
5
+ type AnimateAttributes = Partial<{
6
+ [K in AnimationKeyframe | AnimationOption]: string;
7
+ }>;
3
8
  /**
4
9
  * The `Animate` base class provides a declarative way to use the
5
10
  * [Web Animations API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Animations_API)
@@ -51,4 +56,4 @@ declare class Animate extends Base {
51
56
  get keyframes(): Keyframe[];
52
57
  }
53
58
 
54
- export { Animate };
59
+ export { Animate, type AnimateAttributes };
@@ -1 +1 @@
1
- "use strict";(()=>{var f=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(s){this.setAttribute("event",s)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(s=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof s)return n;throw new Error("Content not found")}swapContent(s=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let t=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),s&&setTimeout(()=>this.getContent().replaceChildren(...t),n)}}safeListener(s,n,e=document.body,t={}){t.signal=this.#e.signal,e.addEventListener(s,n,t)}triggerListener(s,n=this.event){for(let e of this.getTrigger())e.addEventListener(n,s)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var m=class extends f{constructor(){super()}get animationOptions(){let s={};for(let n of this.getAttributeNames())if(n.startsWith("animation-option-")){let e=this.getAttribute(n),[,,t]=n.split("-");e&&(t==="duration"||t==="delay"?s[t]=Number(e):t==="easing"&&(s[t]=e))}return s}async animateElement(s={element:this.getContent(),options:{}}){let{element:n=this.getContent(),options:e={}}=s,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 r=t.at(0),i=t.at(-1);if(r&&i){let a=["composite","easing","offset"];for(let l of a)delete r[l],delete i[l]}e.direction?.includes("reverse")&&([r,i]=[i,r]),Object.assign(n.style,r),await n.animate(t,e).finished,Object.assign(n.style,i)}}get keyframes(){let s=[];for(let n of this.getAttributeNames()){let e=this.getAttribute(n),[,,t,...r]=n.split("-");if(n.startsWith("animation-keyframe-")){let i=r.map((o,a)=>a<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(t&&i){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let o=Number(t),a=s.find(l=>l.offset===o);a?a[i]=e:s.push({[i]:e,offset:o})}}}return s.sort((n,e)=>Number(n.offset)-Number(e.offset)),s}};})();
1
+ "use strict";(()=>{var m=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(i){this.setAttribute("event",i)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(i=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof i)return n;throw new Error("Content not found")}swapContent(i=!0,n=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let t=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),i&&setTimeout(()=>this.getContent().replaceChildren(...t),n)}}safeListener(i,n,e=document.body,t={}){t.signal=this.#e.signal,e.addEventListener(i,n,t)}triggerListener(i,n=this.event){for(let e of this.getTrigger())e.addEventListener(n,i)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let i={};for(let n of this.getAttributeNames())if(n.startsWith("animation-option-")){let e=this.getAttribute(n),[,,t]=n.split("-");e&&(t==="duration"||t==="delay"?i[t]=Number(e):t==="easing"&&(i[t]=e))}return i}async animateElement(i={element:this.getContent(),options:{}}){let{element:n=this.getContent(),options:e={}}=i,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 o=t.at(0),s=t.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete s[l]}e.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(n.style,o),await n.animate(t,e).finished,Object.assign(n.style,s)}}get keyframes(){let i=[];for(let n of this.getAttributeNames()){let e=this.getAttribute(n),[,,t,...o]=n.split("-");if(n.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(t&&s){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let r=Number(t),a=i.find(l=>l.offset===r);a?a[s]=e:i.push({[s]:e,offset:r})}}}return i.sort((n,e)=>Number(n.offset)-Number(e.offset)),i}};})();
package/animate/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";export{a as Animate};
1
+ import{a}from"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as Animate};
@@ -1 +1 @@
1
- import{a as e}from"../chunk-6HYPZWQ4.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-breakpoint",e);
1
+ import{a as e}from"../chunk-BCS5E3IH.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-breakpoint",e);
@@ -1,5 +1,9 @@
1
1
  import { Base } from '../base/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
 
4
+ type BreakpointAttributes = Attributes<Breakpoint> & Partial<{
5
+ [attr: `breakpoint-${string}`]: string;
6
+ }>;
3
7
  type Breakpoints = {
4
8
  name: string;
5
9
  width: number;
@@ -21,4 +25,4 @@ declare class Breakpoint extends Base {
21
25
  mount(): void;
22
26
  }
23
27
 
24
- export { Breakpoint, type Breakpoints };
28
+ export { Breakpoint, type BreakpointAttributes };
@@ -1 +1 @@
1
- import{a}from"../chunk-6HYPZWQ4.js";import"../chunk-MXKU7AKV.js";export{a as Breakpoint};
1
+ import{a}from"../chunk-BCS5E3IH.js";import"../chunk-MXKU7AKV.js";export{a as Breakpoint};
@@ -0,0 +1 @@
1
+ import{a as C}from"./chunk-VEVFQB5N.js";import{a as E}from"./chunk-GPET75FT.js";import{a as h}from"./chunk-5JV4T7GM.js";import{a as x}from"./chunk-DKKPV7QP.js";import{a as v}from"./chunk-4WBITBA6.js";import{a as f}from"./chunk-AWUCZCAJ.js";import{a as y}from"./chunk-XAP2U34A.js";import{a as d}from"./chunk-LHXOPRVC.js";import{a as T}from"./chunk-H4RNP4O4.js";import{a as A}from"./chunk-F5BEEHGA.js";import{a as c}from"./chunk-BCS5E3IH.js";import{a as S,b as u}from"./chunk-MXKU7AKV.js";var g={};S(g,{Animate:()=>A,Base:()=>u,Breakpoint:()=>c,ContextMenu:()=>f,Copy:()=>y,Details:()=>d,Dialog:()=>T,Editor:()=>E,Fullscreen:()=>h,Popover:()=>x,Share:()=>v,TableSort:()=>m,YouTube:()=>C});var m=class extends u{constructor(){super()}#t(t){let e="data-asc",r="data-desc";for(let s of this.getTrigger())s!==t&&(s.removeAttribute(e),s.removeAttribute(r));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(r,""),!1):(t.removeAttribute(r),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(L(e,this.#t(e))).forEach(r=>t.appendChild(r))})}},L=(o,t)=>(r,s)=>{let l=Array.from(o.parentNode?.children??[]).indexOf(o);return((i,a)=>{let p=o.dataset.type??"string";if(p==="string")return new Intl.Collator().compare(i,a);if(p==="boolean"){let n=b=>["0","false","null","undefined"].includes(b)?!1:!!b;return n(i)===n(a)?0:n(i)?-1:1}else return Number(i)-Number(a)})(M(t?r:s,l),M(t?s:r,l))},M=(o,t)=>{let e=o.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};export{m as a,g as b};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-7F7CQUEG.js";var a=class extends e{constructor(){super()}async share(t=this.value){if(navigator.canShare&&navigator.canShare({url:t}))try{await navigator.share({url:t})}catch(r){r?.name!=="AbortError"&&console.error(r)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};export{a};
@@ -1 +1 @@
1
- import{a as l}from"./chunk-7KU2PRW5.js";var a=class extends l{#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,i=window.scrollX,d=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,f=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,s=d+i,n=f+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let o=this.getContent().offsetWidth+24,h=this.getContent().offsetHeight+6,c=window.innerWidth,r=window.innerHeight;s+o>i+c&&(s=i+c-o),n+h>e+r&&(n=e+r-h),this.#e={x:s,y:n},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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};export{a};
1
+ import{a as l}from"./chunk-F5BEEHGA.js";var a=class extends l{#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,i=window.scrollX,u=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,d=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,s=u+i,n=d+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let o=this.getContent().offsetWidth+24,r=this.getContent().offsetHeight+6,h=window.innerWidth,c=window.innerHeight;s+o>i+h&&(s=i+h-o),n+r>e+c&&(n=e+c-r),this.#e={x:s,y:n},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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};export{a};
@@ -1 +1 @@
1
- import{b as n}from"./chunk-MXKU7AKV.js";var s=class extends n{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)}};export{s as a};
1
+ import{b as n}from"./chunk-MXKU7AKV.js";var r=class extends n{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)}};export{r as a};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-F5BEEHGA.js";var i=class extends e{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())})}};export{i as a};
@@ -0,0 +1 @@
1
+ import{b as m}from"./chunk-MXKU7AKV.js";var p=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 o=t.at(0),s=t.at(-1);if(o&&s){let r=["composite","easing","offset"];for(let f of r)delete o[f],delete s[f]}e.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(t,e).finished,Object.assign(i.style,s)}}get keyframes(){let n=[];for(let i of this.getAttributeNames()){let e=this.getAttribute(i),[,,t,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((a,r)=>r<1?a:a.at(0)?.toUpperCase()+a.slice(1)).join("");if(t&&s){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let a=Number(t),r=n.find(f=>f.offset===a);r?r[s]=e:n.push({[s]:e,offset:a})}}}return n.sort((i,e)=>Number(i.offset)-Number(e.offset)),n}};export{p as a};
@@ -1 +1 @@
1
- import{a as t}from"./chunk-7KU2PRW5.js";var s=class extends t{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",e=>{e.key==="Escape"&&this.dialog.open&&(e.preventDefault(),this.close())})}};export{s as a};
1
+ import{a as e}from"./chunk-F5BEEHGA.js";var i=class extends e{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};export{i as a};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-F5BEEHGA.js";var i=class extends e{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()})}};export{i as a};
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-7F7CQUEG.js";var e=class extends t{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};export{e as a};
@@ -1 +1 @@
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 s=Array.from(this.getContent().childNodes);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...s),e)}}safeListener(t,e,n=document.body,s={}){s.signal=this.#t.signal,n.addEventListener(t,e,s)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var f=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),[,,s]=e.split("-");n&&(s==="duration"||s==="delay"?t[s]=Number(n):s==="easing"&&(t[s]=n))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:n={}}=t,s=this.keyframes;if(s.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 r=s.at(0),i=s.at(-1);if(r&&i){let a=["composite","easing","offset"];for(let l of a)delete r[l],delete i[l]}n.direction?.includes("reverse")&&([r,i]=[i,r]),Object.assign(e.style,r),await e.animate(s,n).finished,Object.assign(e.style,i)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let n=this.getAttribute(e),[,,s,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let i=r.map((o,a)=>a<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(s&&i){s==="from"?s="0":s==="to"?s="1":s=String(parseInt(s)*.01);let o=Number(s),a=t.find(l=>l.offset===o);a?a[i]=n:t.push({[i]:n,offset:o})}}}return t.sort((e,n)=>Number(e.offset)-Number(n.offset)),t}};var m=class extends f{#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,s=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,i=s+n,o=r+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,d=window.innerHeight;i+a>n+u&&(i=n+u-a),o+l>e+d&&(o=e+d-l),this.#e={x:i,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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};customElements.define("drab-contextmenu",m);})();
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...i),e)}}safeListener(t,e,n=document.body,i={}){i.signal=this.#t.signal,n.addEventListener(t,e,i)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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 r=i.at(0),s=i.at(-1);if(r&&s){let a=["composite","easing","offset"];for(let l of a)delete r[l],delete s[l]}n.direction?.includes("reverse")&&([r,s]=[s,r]),Object.assign(e.style,r),await e.animate(i,n).finished,Object.assign(e.style,s)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let n=this.getAttribute(e),[,,i,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let s=r.map((o,a)=>a<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(i&&s){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let o=Number(i),a=t.find(l=>l.offset===o);a?a[s]=n:t.push({[s]:n,offset:o})}}}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,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,s=i+n,o=r+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,d=window.innerHeight;s+a>n+u&&(s=n+u-a),o+l>e+d&&(o=e+d-l),this.#e={x:s,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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};customElements.define("drab-contextmenu",f);})();
@@ -1 +1 @@
1
- import{a as e}from"../chunk-57VEEUFG.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-contextmenu",e);
1
+ import{a as e}from"../chunk-AWUCZCAJ.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-contextmenu",e);
@@ -1,6 +1,8 @@
1
- import { Animate } from '../animate/index.js';
1
+ import { AnimateAttributes, Animate } from '../animate/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
  import '../base/index.js';
3
4
 
5
+ type ContextMenuAttributes = Attributes<ContextMenu> & AnimateAttributes;
4
6
  /**
5
7
  * Displays content when the `trigger` element is right clicked, or long pressed on mobile.
6
8
  */
@@ -12,4 +14,4 @@ declare class ContextMenu extends Animate {
12
14
  mount(): void;
13
15
  }
14
16
 
15
- export { ContextMenu };
17
+ export { ContextMenu, type ContextMenuAttributes };
@@ -1 +1 @@
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 s=Array.from(this.getContent().childNodes);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...s),e)}}safeListener(t,e,n=document.body,s={}){s.signal=this.#t.signal,n.addEventListener(t,e,s)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var f=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),[,,s]=e.split("-");n&&(s==="duration"||s==="delay"?t[s]=Number(n):s==="easing"&&(t[s]=n))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:n={}}=t,s=this.keyframes;if(s.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 r=s.at(0),i=s.at(-1);if(r&&i){let a=["composite","easing","offset"];for(let l of a)delete r[l],delete i[l]}n.direction?.includes("reverse")&&([r,i]=[i,r]),Object.assign(e.style,r),await e.animate(s,n).finished,Object.assign(e.style,i)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let n=this.getAttribute(e),[,,s,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let i=r.map((o,a)=>a<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(s&&i){s==="from"?s="0":s==="to"?s="1":s=String(parseInt(s)*.01);let o=Number(s),a=t.find(l=>l.offset===o);a?a[i]=n:t.push({[i]:n,offset:o})}}}return t.sort((e,n)=>Number(e.offset)-Number(n.offset)),t}};var d=class extends f{#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,s=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,i=s+n,o=r+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let a=this.getContent().offsetWidth+24,l=this.getContent().offsetHeight+6,m=window.innerWidth,u=window.innerHeight;i+a>n+m&&(i=n+m-a),o+l>e+u&&(o=e+u-l),this.#e={x:i,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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};})();
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...i),e)}}safeListener(t,e,n=document.body,i={}){i.signal=this.#t.signal,n.addEventListener(t,e,i)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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 r=i.at(0),s=i.at(-1);if(r&&s){let a=["composite","easing","offset"];for(let l of a)delete r[l],delete s[l]}n.direction?.includes("reverse")&&([r,s]=[s,r]),Object.assign(e.style,r),await e.animate(i,n).finished,Object.assign(e.style,s)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let n=this.getAttribute(e),[,,i,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let s=r.map((o,a)=>a<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(i&&s){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let o=Number(i),a=t.find(l=>l.offset===o);a?a[s]=n:t.push({[s]:n,offset:o})}}}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,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,s=i+n,o=r+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let a=this.getContent().offsetWidth+24,l=this.getContent().offsetHeight+6,h=window.innerWidth,u=window.innerHeight;s+a>n+h&&(s=n+h-a),o+l>e+u&&(o=e+u-l),this.#e={x:s,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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};})();
@@ -1 +1 @@
1
- import{a}from"../chunk-57VEEUFG.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";export{a as ContextMenu};
1
+ import{a}from"../chunk-AWUCZCAJ.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as ContextMenu};
@@ -1 +1 @@
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...r),t)}}safeListener(e,t,n=document.body,r={}){r.signal=this.#e.signal,n.addEventListener(e,t,r)}triggerListener(e,t=this.event){for(let n of this.getTrigger())n.addEventListener(t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var i=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 o=class extends i{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};customElements.define("drab-copy",o);})();
1
+ "use strict";(()=>{var s=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 r=Array.from(this.getContent().childNodes);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...r),e)}}safeListener(t,e,n=document.body,r={}){r.signal=this.#t.signal,n.addEventListener(t,e,r)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var i=class extends s{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 o=class extends i{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};customElements.define("drab-copy",o);})();
package/copy/define.js CHANGED
@@ -1 +1 @@
1
- import{a as o}from"../chunk-TSTTUEAF.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-copy",o);
1
+ import{a as o}from"../chunk-XAP2U34A.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-copy",o);
package/copy/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { B as BaseCopy } from '../index-SyRipepB.js';
1
+ import { B as BaseCopy } from '../index-0rvQCq2U.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
  import '../base/index.js';
3
4
 
5
+ type CopyAttributes = Attributes<Copy, "value">;
4
6
  /**
5
7
  * Uses the [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText)
6
8
  * to copy text.
@@ -10,4 +12,4 @@ declare class Copy extends BaseCopy {
10
12
  mount(): void;
11
13
  }
12
14
 
13
- export { Copy };
15
+ export { Copy, type CopyAttributes };
@@ -1 +1 @@
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...r),t)}}safeListener(e,t,n=document.body,r={}){r.signal=this.#e.signal,n.addEventListener(e,t,r)}triggerListener(e,t=this.event){for(let n of this.getTrigger())n.addEventListener(t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var i=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 a=class extends i{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};})();
1
+ "use strict";(()=>{var s=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 r=Array.from(this.getContent().childNodes);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...r),e)}}safeListener(t,e,n=document.body,r={}){r.signal=this.#t.signal,n.addEventListener(t,e,r)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var i=class extends s{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 a=class extends i{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};})();
package/copy/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-TSTTUEAF.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";export{a as Copy};
1
+ import{a}from"../chunk-XAP2U34A.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";export{a as Copy};
@@ -1,9 +1,9 @@
1
- "use strict";(()=>{var K=Object.defineProperty;var B=(o,t)=>{for(var e in t)K(o,e,{get:t[e],enumerable:!0})};var L={};B(L,{Animate:()=>u,Base:()=>c,Breakpoint:()=>g,ContextMenu:()=>d,Copy:()=>y,Details:()=>b,Dialog:()=>w,Editor:()=>x,Fullscreen:()=>E,Popover:()=>k,Share:()=>T,TableSort:()=>A,YouTube:()=>C});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 s=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(s){let n=Array.from(this.getContent().childNodes);s instanceof HTMLTemplateElement?this.getContent().replaceChildren(s.content.cloneNode(!0)):this.getContent().replaceChildren(...s.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...n),e)}}safeListener(t,e,s=document.body,n={}){n.signal=this.#t.signal,s.addEventListener(t,e,n)}triggerListener(t,e=this.event){for(let s of this.getTrigger())s.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var u=class extends c{constructor(){super()}get animationOptions(){let t={};for(let e of this.getAttributeNames())if(e.startsWith("animation-option-")){let s=this.getAttribute(e),[,,n]=e.split("-");s&&(n==="duration"||n==="delay"?t[n]=Number(s):n==="easing"&&(t[n]=s))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:s={}}=t,n=this.keyframes;if(n.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){s=Object.assign(this.animationOptions,s),s.duration||(s.duration=200),s.easing||(s.easing="ease-in-out");let r=n.at(0),i=n.at(-1);if(r&&i){let l=["composite","easing","offset"];for(let h of l)delete r[h],delete i[h]}s.direction?.includes("reverse")&&([r,i]=[i,r]),Object.assign(e.style,r),await e.animate(n,s).finished,Object.assign(e.style,i)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let s=this.getAttribute(e),[,,n,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let i=r.map((a,l)=>l<1?a:a.at(0)?.toUpperCase()+a.slice(1)).join("");if(n&&i){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let a=Number(n),l=t.find(h=>h.offset===a);l?l[i]=s:t.push({[i]:s,offset:a})}}}return t.sort((e,s)=>Number(e.offset)-Number(s.offset)),t}};var g=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[,...s]=e.split("-");s&&t.push({name:s.join("-"),width:Number(this.getAttribute(e))})}t.length&&(this.breakpoints=t),this.breakpoints.sort((e,s)=>s.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 d=class extends u{#t;constructor(){super()}set#r(t){this.getContent().style.left=`${t.x}px`,this.getContent().style.top=`${t.y}px`}async show(t){let e=window.scrollY,s=window.scrollX,n=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,i=n+s,a=r+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let l=this.getContent().offsetWidth+24,h=this.getContent().offsetHeight+6,m=window.innerWidth,f=window.innerHeight;i+l>s+m&&(i=s+m-l),a+h>e+f&&(a=e+f-h),this.#r={x:i,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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};var p=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 y=class extends p{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var b=class extends u{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 w=class extends u{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};var x=class extends c{#t=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#r)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#r(){let t=[];for(let e of this.getTrigger())t.push(this.#a(e));return t}get#h(){let t=this.text.split("```"),e=0;for(let[s,n]of t.entries())if(e+=n.length+3,this.#s<e)return s;return 0}get#e(){return this.textArea.selectionEnd}get#s(){return this.textArea.selectionStart}#n(t,e){this.textArea.setSelectionRange(t,e)}#a(t){let e=t.dataset.type,s=t.dataset.value,n=t.dataset.key??void 0;return{type:e,value:s,key:n}}async#c(t,e,s){if(t.type==="inline")this.text=`${this.text.slice(0,s)}${t.value}${this.text.slice(s)}`;else if(t.type==="wrap")this.text=S(this.text,t.value,e),this.text=S(this.text,this.keyPairs[t.value],s+t.value.length),t.value.length<2&&this.#t.push(t.value);else if(t.type==="block"){let{lines:n,lineNumber:r}=this.#o(),i=t.value.at(0);i&&n[r]?.startsWith(i)?n[r]=t.value.trim()+n[r]:n[r]=t.value+n[r],this.text=n.join(`
2
- `)}}async#u(t,e,s){let n=0,r=0;if(/[a-z]/i.test(t)){for(let i=s;i<this.text.length;i++)if(this.text[i]?.match(/[a-z]/i))n?r=i+1:n=i;else if(n)break}else n=e+t.length,r=s+t.length;this.#n(n,r),this.textArea.focus()}async#i(t){let e=this.#e,s=this.#s;await this.#c(t,s,e),this.#u(t.value,s,e)}#m(t){if(t){let e=[];this.#r.forEach(n=>{n.type==="block"&&e.push(n.value)});for(let n=0;n<e.length;n++){let r=e[n];if(r&&t.startsWith(r))return r}let s=N(t);if(s)return`${s}. `}return""}#o(){let t=this.text.split(`
3
- `),e=0;for(let s=0;s<t.length;s++){let n=t.at(s)?.length??0;if(e++,e+=n,e>this.#e)return{lines:t,lineNumber:s,columnNumber:this.#e-(e-n-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#l(t,e=!1){let{lines:s}=this.#o();for(let n=t+1;n<s.length;n++){let r=s[n];if(r){let i=N(r);if(i){let a;if(e)if(i>1)a=i-1;else break;else a=i+1;s[n]=r.slice(String(i).length),s[n]=String(a)+s[n]}else break}}this.text=s.join(`
4
- `)}mount(){this.textArea.addEventListener("keydown",async t=>{let e=["ArrowUp","ArrowDown","Delete"],s=this.text[this.#e]??"";if(e.includes(t.key))this.#t=[];else if(t.key==="Backspace"){let n=this.text[this.#s-1];if(n&&n in this.keyPairs&&s===this.keyPairs[n]){t.preventDefault();let r=this.#s-1,i=this.#e-1;this.text=v(this.text,r),this.text=v(this.text,i),setTimeout(()=>{this.#n(r,i)},0),this.#t.pop()}if(n===`
5
- `&&this.#s===this.#e){t.preventDefault();let r=this.#s-1,{lineNumber:i}=this.#o();this.#l(i,!0),this.text=v(this.text,r),setTimeout(async()=>{this.#n(r,r)},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:n,lineNumber:r,columnNumber:i}=this.#o(),a=n.at(r),l=this.#m(a),h=l,m=N(l);if(m&&(l=`${m+1}. `),l&&h.length<i)t.preventDefault(),m&&this.#l(r),await this.#i({type:"inline",value:`
6
- ${l}`});else if(l&&h.length===i){t.preventDefault();let f=this.#e,M=f-h.length;for(let H=0;H<h.length;H++)this.text=v(this.text,f-(H+1));setTimeout(async()=>{this.#n(M,M),this.textArea.focus(),await this.#i({type:"inline",value:`
7
- `})},0)}}else{let n=Object.values(this.keyPairs).includes(s),r=this.#s!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#s===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:i,lineNumber:a,columnNumber:l}=this.#o();if(await navigator.clipboard.writeText(`${a===0&&t.key==="x"?"":`
8
- `}${i[a]}`),t.key==="x"){let h=this.#s-l;i.splice(a,1),this.text=i.join(`
9
- `),setTimeout(()=>{this.#n(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let i=this.#r.find(a=>a.key===t.key);i&&this.#i(i)}else n&&(s===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.#i({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.#i(this.#a(t))})}},N=o=>{let t=o.match(/^(\d+)\./);return t?Number(t[1]):null},S=(o,t,e)=>o.slice(0,e)+t+o.slice(e),v=(o,t)=>o.slice(0,t)+o.slice(t+1);var E=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 k=class extends u{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 p{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 A=class extends c{constructor(){super()}#t(t){let e="data-asc",s="data-desc";for(let n of this.getTrigger())n!==t&&(n.removeAttribute(e),n.removeAttribute(s));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(s,""),!1):(t.removeAttribute(s),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(P(e,this.#t(e))).forEach(s=>t.appendChild(s))})}},P=(o,t)=>(s,n)=>{let r=Array.from(o.parentNode?.children??[]).indexOf(o);return((a,l)=>{let h=o.dataset.type??"string";if(h==="string")return new Intl.Collator().compare(a,l);if(h==="boolean"){let m=f=>["0","false","null","undefined"].includes(f)?!1:!!f;return m(a)===m(l)?0:m(a)?-1:1}else return Number(a)-Number(l)})(D(t?s:n,r),D(t?n:s,r))},D=(o,t)=>{let e=o.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var C=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 L)customElements.define(`drab-${o.toLowerCase()}`,L[o]);})();
1
+ "use strict";(()=>{var P=Object.defineProperty;var B=(o,t)=>{for(var e in t)P(o,e,{get:t[e],enumerable:!0})};var L={};B(L,{Animate:()=>c,Base:()=>h,Breakpoint:()=>g,ContextMenu:()=>d,Copy:()=>y,Details:()=>b,Dialog:()=>A,Editor:()=>w,Fullscreen:()=>v,Popover:()=>E,Share:()=>k,TableSort:()=>T,YouTube:()=>C});var h=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);i instanceof HTMLTemplateElement?this.getContent().replaceChildren(i.content.cloneNode(!0)):this.getContent().replaceChildren(...i.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...s),e)}}safeListener(t,e,i=document.body,s={}){s.signal=this.#t.signal,i.addEventListener(t,e,s)}triggerListener(t,e=this.event){for(let i of this.getTrigger())i.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var c=class extends h{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 l=["composite","easing","offset"];for(let u of l)delete r[u],delete n[u]}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,l)=>l<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),l=t.find(u=>u.offset===a);l?l[n]=i:t.push({[n]:i,offset:a})}}}return t.sort((e,i)=>Number(e.offset)-Number(i.offset)),t}};var g=class extends h{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 d=class extends c{#t;constructor(){super()}set#r(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 l=this.getContent().offsetWidth+24,u=this.getContent().offsetHeight+6,m=window.innerWidth,p=window.innerHeight;n+l>i+m&&(n=i+m-l),a+u>e+p&&(a=e+p-u),this.#r={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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};var f=class extends h{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 y=class extends f{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var b=class extends c{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 c{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};var w=class extends h{#t=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#r)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#r(){let t=[];for(let e of this.getTrigger())t.push(this.#a(e));return t}get#u(){let t=this.text.split("```"),e=0;for(let[i,s]of t.entries())if(e+=s.length+3,this.#i<e)return i;return 0}get#e(){return this.textArea.selectionEnd}get#i(){return this.textArea.selectionStart}#s(t,e){this.textArea.setSelectionRange(t,e)}#a(t){let e=t.dataset.type,i=t.dataset.value,s=t.dataset.key??void 0;return{type:e,value:i,key:s}}async#h(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=N(this.text,t.value,e),this.text=N(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.#o(),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#c(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.#s(s,r),this.textArea.focus()}async#n(t){let e=this.#e,i=this.#i;await this.#h(t,i,e),this.#c(t.value,i,e)}#m(t){if(t){let e=[];this.#r.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=S(t);if(i)return`${i}. `}return""}#o(){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}}#l(t,e=!1){let{lines:i}=this.#o();for(let s=t+1;s<i.length;s++){let r=i[s];if(r){let n=S(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.#i-1];if(s&&s in this.keyPairs&&i===this.keyPairs[s]){t.preventDefault();let r=this.#i-1,n=this.#e-1;this.text=x(this.text,r),this.text=x(this.text,n),setTimeout(()=>{this.#s(r,n)},0),this.#t.pop()}if(s===`
5
+ `&&this.#i===this.#e){t.preventDefault();let r=this.#i-1,{lineNumber:n}=this.#o();this.#l(n,!0),this.text=x(this.text,r),setTimeout(async()=>{this.#s(r,r)},0)}}else if(t.key==="Tab")this.#u%2!==0&&(t.preventDefault(),await this.#n({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:s,lineNumber:r,columnNumber:n}=this.#o(),a=s.at(r),l=this.#m(a),u=l,m=S(l);if(m&&(l=`${m+1}. `),l&&u.length<n)t.preventDefault(),m&&this.#l(r),await this.#n({type:"inline",value:`
6
+ ${l}`});else if(l&&u.length===n){t.preventDefault();let p=this.#e,M=p-u.length;for(let H=0;H<u.length;H++)this.text=x(this.text,p-(H+1));setTimeout(async()=>{this.#s(M,M),this.textArea.focus(),await this.#n({type:"inline",value:`
7
+ `})},0)}}else{let s=Object.values(this.keyPairs).includes(i),r=this.#i!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#i===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:n,lineNumber:a,columnNumber:l}=this.#o();if(await navigator.clipboard.writeText(`${a===0&&t.key==="x"?"":`
8
+ `}${n[a]}`),t.key==="x"){let u=this.#i-l;n.splice(a,1),this.text=n.join(`
9
+ `),setTimeout(()=>{this.#s(u,u)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#r.find(a=>a.key===t.key);n&&this.#n(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#s(this.#i+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#n({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#i!==this.#e&&(this.text[this.#i]===" "&&this.#s(this.#i+1,this.#e),this.text[this.#e-1]===" "&&this.#s(this.#i,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#n(this.#a(t))})}},S=o=>{let t=o.match(/^(\d+)\./);return t?Number(t[1]):null},N=(o,t,e)=>o.slice(0,e)+t+o.slice(e),x=(o,t)=>o.slice(0,t)+o.slice(t+1);var v=class extends h{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 E=class extends c{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 k=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 T=class extends h{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(K(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},K=(o,t)=>(i,s)=>{let r=Array.from(o.parentNode?.children??[]).indexOf(o);return((a,l)=>{let u=o.dataset.type??"string";if(u==="string")return new Intl.Collator().compare(a,l);if(u==="boolean"){let m=p=>["0","false","null","undefined"].includes(p)?!1:!!p;return m(a)===m(l)?0:m(a)?-1:1}else return Number(a)-Number(l)})(D(t?i:s,r),D(t?s:i,r))},D=(o,t)=>{let e=o.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var C=class extends h{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 L)customElements.define(`drab-${o.toLowerCase()}`,L[o]);})();
package/define/index.js CHANGED
@@ -1 +1 @@
1
- import{b as e}from"../chunk-G5WFHYNX.js";import"../chunk-VEVFQB5N.js";import"../chunk-GPET75FT.js";import"../chunk-5JV4T7GM.js";import"../chunk-T7RZI3ZL.js";import"../chunk-IQJQPZUL.js";import"../chunk-57VEEUFG.js";import"../chunk-TSTTUEAF.js";import"../chunk-7F7CQUEG.js";import"../chunk-JMJUWKN2.js";import"../chunk-7S6DTKGH.js";import"../chunk-7KU2PRW5.js";import"../chunk-6HYPZWQ4.js";import"../chunk-MXKU7AKV.js";for(let o in e)customElements.define(`drab-${o.toLowerCase()}`,e[o]);
1
+ import{b as e}from"../chunk-3ASUSP4D.js";import"../chunk-VEVFQB5N.js";import"../chunk-GPET75FT.js";import"../chunk-5JV4T7GM.js";import"../chunk-DKKPV7QP.js";import"../chunk-4WBITBA6.js";import"../chunk-AWUCZCAJ.js";import"../chunk-XAP2U34A.js";import"../chunk-7F7CQUEG.js";import"../chunk-LHXOPRVC.js";import"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-BCS5E3IH.js";import"../chunk-MXKU7AKV.js";for(let o in e)customElements.define(`drab-${o.toLowerCase()}`,e[o]);
@@ -1 +1 @@
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 s=this.querySelector(this.getAttribute("content")??"[data-content]");if(s instanceof e)return s;throw new Error("Content not found")}swapContent(e=!0,s=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let n=Array.from(this.getContent().childNodes);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),s)}}safeListener(e,s,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,s,n)}triggerListener(e,s=this.event){for(let t of this.getTrigger())t.addEventListener(s,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let e={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let t=this.getAttribute(s),[,,n]=s.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:s=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 o=n.at(0),i=n.at(-1);if(o&&i){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete i[l]}t.direction?.includes("reverse")&&([o,i]=[i,o]),Object.assign(s.style,o),await s.animate(n,t).finished,Object.assign(s.style,i)}}get keyframes(){let e=[];for(let s of this.getAttributeNames()){let t=this.getAttribute(s),[,,n,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let i=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&i){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[i]=t:e.push({[i]:t,offset:r})}}}return e.sort((s,t)=>Number(s.offset)-Number(t.offset)),e}};var c=class extends f{constructor(){super()}get details(){let e=this.getContent(HTMLElement).parentElement;if(!(e instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return e}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(e=>{e.preventDefault(),this.toggle()})}};customElements.define("drab-details",c);})();
1
+ "use strict";(()=>{var m=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 i=this.querySelector(this.getAttribute("content")??"[data-content]");if(i instanceof t)return i;throw new Error("Content not found")}swapContent(t=!0,i=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let n=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...n),i)}}safeListener(t,i,e=document.body,n={}){n.signal=this.#t.signal,e.addEventListener(t,i,n)}triggerListener(t,i=this.event){for(let e of this.getTrigger())e.addEventListener(i,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let t={};for(let i of this.getAttributeNames())if(i.startsWith("animation-option-")){let e=this.getAttribute(i),[,,n]=i.split("-");e&&(n==="duration"||n==="delay"?t[n]=Number(e):n==="easing"&&(t[n]=e))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:i=this.getContent(),options:e={}}=t,n=this.keyframes;if(n.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 o=n.at(0),s=n.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete s[l]}e.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(n,e).finished,Object.assign(i.style,s)}}get keyframes(){let t=[];for(let i of this.getAttributeNames()){let e=this.getAttribute(i),[,,n,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&s){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let r=Number(n),a=t.find(l=>l.offset===r);a?a[s]=e:t.push({[s]:e,offset:r})}}}return t.sort((i,e)=>Number(i.offset)-Number(e.offset)),t}};var c=class extends f{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()})}};customElements.define("drab-details",c);})();
package/details/define.js CHANGED
@@ -1 +1 @@
1
- import{a as e}from"../chunk-JMJUWKN2.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-details",e);
1
+ import{a as e}from"../chunk-LHXOPRVC.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-details",e);
@@ -1,6 +1,8 @@
1
- import { Animate } from '../animate/index.js';
1
+ import { AnimateAttributes, Animate } from '../animate/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
  import '../base/index.js';
3
4
 
5
+ type DetailsAttributes = Attributes<Details> & AnimateAttributes;
4
6
  /**
5
7
  * This element provides a progressive enhancement on top of the `HTMLDetailsElement` to
6
8
  * animate it with the Web Animations API.
@@ -20,4 +22,4 @@ declare class Details extends Animate {
20
22
  mount(): void;
21
23
  }
22
24
 
23
- export { Details };
25
+ export { Details, type DetailsAttributes };
@@ -1 +1 @@
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 s=this.querySelector(this.getAttribute("content")??"[data-content]");if(s instanceof e)return s;throw new Error("Content not found")}swapContent(e=!0,s=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let n=Array.from(this.getContent().childNodes);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),s)}}safeListener(e,s,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,s,n)}triggerListener(e,s=this.event){for(let t of this.getTrigger())t.addEventListener(s,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let e={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let t=this.getAttribute(s),[,,n]=s.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:s=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 o=n.at(0),i=n.at(-1);if(o&&i){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete i[l]}t.direction?.includes("reverse")&&([o,i]=[i,o]),Object.assign(s.style,o),await s.animate(n,t).finished,Object.assign(s.style,i)}}get keyframes(){let e=[];for(let s of this.getAttributeNames()){let t=this.getAttribute(s),[,,n,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let i=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&i){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[i]=t:e.push({[i]:t,offset:r})}}}return e.sort((s,t)=>Number(s.offset)-Number(t.offset)),e}};var u=class extends f{constructor(){super()}get details(){let e=this.getContent(HTMLElement).parentElement;if(!(e instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return e}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(e=>{e.preventDefault(),this.toggle()})}};})();
1
+ "use strict";(()=>{var m=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 i=this.querySelector(this.getAttribute("content")??"[data-content]");if(i instanceof t)return i;throw new Error("Content not found")}swapContent(t=!0,i=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let n=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...n),i)}}safeListener(t,i,e=document.body,n={}){n.signal=this.#t.signal,e.addEventListener(t,i,n)}triggerListener(t,i=this.event){for(let e of this.getTrigger())e.addEventListener(i,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var f=class extends m{constructor(){super()}get animationOptions(){let t={};for(let i of this.getAttributeNames())if(i.startsWith("animation-option-")){let e=this.getAttribute(i),[,,n]=i.split("-");e&&(n==="duration"||n==="delay"?t[n]=Number(e):n==="easing"&&(t[n]=e))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:i=this.getContent(),options:e={}}=t,n=this.keyframes;if(n.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 o=n.at(0),s=n.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete s[l]}e.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(n,e).finished,Object.assign(i.style,s)}}get keyframes(){let t=[];for(let i of this.getAttributeNames()){let e=this.getAttribute(i),[,,n,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&s){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let r=Number(n),a=t.find(l=>l.offset===r);a?a[s]=e:t.push({[s]:e,offset:r})}}}return t.sort((i,e)=>Number(i.offset)-Number(e.offset)),t}};var u=class extends f{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()})}};})();
package/details/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-JMJUWKN2.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";export{a as Details};
1
+ import{a}from"../chunk-LHXOPRVC.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as Details};
@@ -1 +1 @@
1
- "use strict";(()=>{var m=class extends HTMLElement{#e=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 e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let n=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...n),s)}}safeListener(t,s,e=document.body,n={}){n.signal=this.#e.signal,e.addEventListener(t,s,n)}triggerListener(t,s=this.event){for(let e of this.getTrigger())e.addEventListener(s,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var c=class extends m{constructor(){super()}get animationOptions(){let t={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let e=this.getAttribute(s),[,,n]=s.split("-");e&&(n==="duration"||n==="delay"?t[n]=Number(e):n==="easing"&&(t[n]=e))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:s=this.getContent(),options:e={}}=t,n=this.keyframes;if(n.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 o=n.at(0),i=n.at(-1);if(o&&i){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete i[l]}e.direction?.includes("reverse")&&([o,i]=[i,o]),Object.assign(s.style,o),await s.animate(n,e).finished,Object.assign(s.style,i)}}get keyframes(){let t=[];for(let s of this.getAttributeNames()){let e=this.getAttribute(s),[,,n,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let i=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&i){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let r=Number(n),a=t.find(l=>l.offset===r);a?a[i]=e:t.push({[i]:e,offset:r})}}}return t.sort((s,e)=>Number(s.offset)-Number(e.offset)),t}};var f=class extends c{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};customElements.define("drab-dialog",f);})();
1
+ "use strict";(()=>{var m=class extends HTMLElement{#t=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);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),i)}}safeListener(e,i,t=document.body,n={}){n.signal=this.#t.signal,t.addEventListener(e,i,n)}triggerListener(e,i=this.event){for(let t of this.getTrigger())t.addEventListener(i,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.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 o=n.at(0),s=n.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete s[l]}t.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(n,t).finished,Object.assign(i.style,s)}}get keyframes(){let e=[];for(let i of this.getAttributeNames()){let t=this.getAttribute(i),[,,n,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&s){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[s]=t:e.push({[s]:t,offset:r})}}}return e.sort((i,t)=>Number(i.offset)-Number(t.offset)),e}};var c=class extends f{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",e=>{e.key==="Escape"&&this.dialog.open&&(e.preventDefault(),this.close())})}};customElements.define("drab-dialog",c);})();
package/dialog/define.js CHANGED
@@ -1 +1 @@
1
- import{a as o}from"../chunk-7S6DTKGH.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-dialog",o);
1
+ import{a as o}from"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-dialog",o);
package/dialog/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
- import { Animate } from '../animate/index.js';
1
+ import { AnimateAttributes, Animate } from '../animate/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
  import '../base/index.js';
3
4
 
5
+ type DialogAttributes = Attributes<Dialog> & AnimateAttributes;
4
6
  /**
5
7
  * Provides triggers and animations for the `HTMLDialogElement`.
6
8
  */
@@ -17,4 +19,4 @@ declare class Dialog extends Animate {
17
19
  mount(): void;
18
20
  }
19
21
 
20
- export { Dialog };
22
+ export { Dialog, type DialogAttributes };
@@ -1 +1 @@
1
- "use strict";(()=>{var c=class extends HTMLElement{#e=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 e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let n=Array.from(this.getContent().childNodes);e instanceof HTMLTemplateElement?this.getContent().replaceChildren(e.content.cloneNode(!0)):this.getContent().replaceChildren(...e.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...n),s)}}safeListener(t,s,e=document.body,n={}){n.signal=this.#e.signal,e.addEventListener(t,s,n)}triggerListener(t,s=this.event){for(let e of this.getTrigger())e.addEventListener(s,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var m=class extends c{constructor(){super()}get animationOptions(){let t={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let e=this.getAttribute(s),[,,n]=s.split("-");e&&(n==="duration"||n==="delay"?t[n]=Number(e):n==="easing"&&(t[n]=e))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:s=this.getContent(),options:e={}}=t,n=this.keyframes;if(n.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 o=n.at(0),i=n.at(-1);if(o&&i){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete i[l]}e.direction?.includes("reverse")&&([o,i]=[i,o]),Object.assign(s.style,o),await s.animate(n,e).finished,Object.assign(s.style,i)}}get keyframes(){let t=[];for(let s of this.getAttributeNames()){let e=this.getAttribute(s),[,,n,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let i=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&i){n==="from"?n="0":n==="to"?n="1":n=String(parseInt(n)*.01);let r=Number(n),a=t.find(l=>l.offset===r);a?a[i]=e:t.push({[i]:e,offset:r})}}}return t.sort((s,e)=>Number(s.offset)-Number(e.offset)),t}};var g=class extends m{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};})();
1
+ "use strict";(()=>{var m=class extends HTMLElement{#t=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);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),i)}}safeListener(e,i,t=document.body,n={}){n.signal=this.#t.signal,t.addEventListener(e,i,n)}triggerListener(e,i=this.event){for(let t of this.getTrigger())t.addEventListener(i,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.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 o=n.at(0),s=n.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete s[l]}t.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(n,t).finished,Object.assign(i.style,s)}}get keyframes(){let e=[];for(let i of this.getAttributeNames()){let t=this.getAttribute(i),[,,n,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&s){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[s]=t:e.push({[s]:t,offset:r})}}}return e.sort((i,t)=>Number(i.offset)-Number(t.offset)),e}};var g=class extends f{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),this.dialog.close()}async toggle(){this.dialog.open?this.close():this.show()}mount(){this.triggerListener(()=>this.toggle()),this.safeListener("keydown",e=>{e.key==="Escape"&&this.dialog.open&&(e.preventDefault(),this.close())})}};})();
package/dialog/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-7S6DTKGH.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";export{a as Dialog};
1
+ import{a}from"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as Dialog};
package/editor/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Base } from '../base/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
 
4
+ type EditorAttributes = Attributes<Editor>;
3
5
  /**
4
6
  * A piece of content to insert into the `textarea`.
5
7
  */
@@ -55,4 +57,4 @@ declare class Editor extends Base {
55
57
  mount(): void;
56
58
  }
57
59
 
58
- export { type ContentElement, Editor };
60
+ export { type ContentElement, Editor, type EditorAttributes };
@@ -1,9 +1,9 @@
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...e),s)}}safeListener(t,s,n=document.body,e={}){e.signal=this.#n.signal,n.addEventListener(t,s,e)}triggerListener(t,s=this.event){for(let n of this.getTrigger())n.addEventListener(s,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#n.abort()}};var d=class extends c{#n=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#l)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#l(){let t=[];for(let s of this.getTrigger())t.push(this.#o(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)}#o(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)}#g(t){if(t){let s=[];this.#l.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 l;if(s)if(r>1)l=r-1;else break;else l=r+1;n[e]=i.slice(String(r).length),n[e]=String(l)+n[e]}else break}}this.text=n.join(`
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...e),s)}}safeListener(t,s,n=document.body,e={}){e.signal=this.#n.signal,n.addEventListener(t,s,e)}triggerListener(t,s=this.event){for(let n of this.getTrigger())n.addEventListener(s,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#n.abort()}};var d=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)}#g(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
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(),l=e.at(i),a=this.#g(l),h=a,g=m(a);if(g&&(a=`${g+1}. `),a&&h.length<r)t.preventDefault(),g&&this.#a(i),await this.#i({type:"inline",value:`
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.#g(o),h=a,g=m(a);if(g&&(a=`${g+1}. `),a&&h.length<r)t.preventDefault(),g&&this.#a(i),await this.#i({type:"inline",value:`
6
6
  ${a}`});else if(a&&h.length===r){t.preventDefault();let p=this.#t,y=p-h.length;for(let f=0;f<h.length;f++)this.text=u(this.text,p-(f+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:l,columnNumber:a}=this.#r();if(await navigator.clipboard.writeText(`${l===0&&t.key==="x"?"":`
8
- `}${r[l]}`),t.key==="x"){let h=this.#e-a;r.splice(l,1),this.text=r.join(`
9
- `),setTimeout(()=>{this.#s(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#l.find(l=>l.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.#o(t))})}},m=o=>{let t=o.match(/^(\d+)\./);return t?Number(t[1]):null},v=(o,t,s)=>o.slice(0,s)+t+o.slice(s),u=(o,t)=>o.slice(0,t)+o.slice(t+1);})();
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 +1 @@
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...r),t)}}safeListener(e,t,n=document.body,r={}){r.signal=this.#e.signal,n.addEventListener(e,t,r)}triggerListener(e,t=this.event){for(let n of this.getTrigger())n.addEventListener(t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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);})();
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);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...r),t)}}safeListener(e,t,n=document.body,r={}){r.signal=this.#e.signal,n.addEventListener(e,t,r)}triggerListener(e,t=this.event){for(let n of this.getTrigger())n.addEventListener(t,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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)}};customElements.define("drab-fullscreen",i);})();
@@ -1,5 +1,7 @@
1
1
  import { Base } from '../base/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
 
4
+ type FullscreenAttributes = Attributes<Fullscreen>;
3
5
  /**
4
6
  * Toggles the `documentElement` or `content` element to fullscreen mode.
5
7
  *
@@ -20,4 +22,4 @@ declare class Fullscreen extends Base {
20
22
  mount(): void;
21
23
  }
22
24
 
23
- export { Fullscreen };
25
+ export { Fullscreen, type FullscreenAttributes };
@@ -3,6 +3,8 @@ import { Base } from './base/index.js';
3
3
  declare class BaseCopy extends Base {
4
4
  constructor();
5
5
  /**
6
+ * The value to copy or share.
7
+ *
6
8
  * @default "" the empty string
7
9
  */
8
10
  get value(): string;
@@ -0,0 +1,12 @@
1
+ type BaseAttributes = {
2
+ trigger: string;
3
+ content: string;
4
+ swap: string;
5
+ };
6
+ /**
7
+ * Creates a partial of the custom element's type. Makes some attributes required
8
+ * if passed in.
9
+ */
10
+ type Attributes<CustomElement, Required extends keyof CustomElement = never> = Pick<CustomElement, Required> & Partial<Omit<CustomElement, Required>> & Partial<BaseAttributes>;
11
+
12
+ export type { Attributes as A };
package/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  export { Base } from './base/index.js';
2
- export { Animate } from './animate/index.js';
3
- export { Breakpoint } from './breakpoint/index.js';
4
- export { ContextMenu } from './contextmenu/index.js';
5
- export { Copy } from './copy/index.js';
6
- export { Details } from './details/index.js';
7
- export { Dialog } from './dialog/index.js';
8
- export { Editor } from './editor/index.js';
9
- export { Fullscreen } from './fullscreen/index.js';
10
- export { Popover } from './popover/index.js';
11
- export { Share } from './share/index.js';
12
- export { TableSort } from './tablesort/index.js';
13
- export { YouTube } from './youtube/index.js';
14
- import './index-SyRipepB.js';
2
+ export { Animate, AnimateAttributes } from './animate/index.js';
3
+ export { Breakpoint, BreakpointAttributes } from './breakpoint/index.js';
4
+ export { ContextMenu, ContextMenuAttributes } from './contextmenu/index.js';
5
+ export { Copy, CopyAttributes } from './copy/index.js';
6
+ export { Details, DetailsAttributes } from './details/index.js';
7
+ export { Dialog, DialogAttributes } from './dialog/index.js';
8
+ export { Editor, EditorAttributes } from './editor/index.js';
9
+ export { Fullscreen, FullscreenAttributes } from './fullscreen/index.js';
10
+ export { Popover, PopoverAttributes } from './popover/index.js';
11
+ export { Share, ShareAttributes } from './share/index.js';
12
+ export { TableSort, TableSortAttributes } from './tablesort/index.js';
13
+ export { YouTube, YouTubeAttributes } from './youtube/index.js';
14
+ import './index-J5TqSvEl.js';
15
+ import './index-0rvQCq2U.js';
package/index.iife.js CHANGED
@@ -1,9 +1,9 @@
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 s=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(s){let i=Array.from(this.getContent().childNodes);s instanceof HTMLTemplateElement?this.getContent().replaceChildren(s.content.cloneNode(!0)):this.getContent().replaceChildren(...s.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...i),e)}}safeListener(t,e,s=document.body,i={}){i.signal=this.#t.signal,s.addEventListener(t,e,i)}triggerListener(t,e=this.event){for(let s of this.getTrigger())s.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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 s=this.getAttribute(e),[,,i]=e.split("-");s&&(i==="duration"||i==="delay"?t[i]=Number(s):i==="easing"&&(t[i]=s))}return t}async animateElement(t={element:this.getContent(),options:{}}){let{element:e=this.getContent(),options:s={}}=t,i=this.keyframes;if(i.length&&!window.matchMedia("(prefers-reduced-motion: reduce)").matches){s=Object.assign(this.animationOptions,s),s.duration||(s.duration=200),s.easing||(s.easing="ease-in-out");let r=i.at(0),n=i.at(-1);if(r&&n){let l=["composite","easing","offset"];for(let h of l)delete r[h],delete n[h]}s.direction?.includes("reverse")&&([r,n]=[n,r]),Object.assign(e.style,r),await e.animate(i,s).finished,Object.assign(e.style,n)}}get keyframes(){let t=[];for(let e of this.getAttributeNames()){let s=this.getAttribute(e),[,,i,...r]=e.split("-");if(e.startsWith("animation-keyframe-")){let n=r.map((o,l)=>l<1?o:o.at(0)?.toUpperCase()+o.slice(1)).join("");if(i&&n){i==="from"?i="0":i==="to"?i="1":i=String(parseInt(i)*.01);let o=Number(i),l=t.find(h=>h.offset===o);l?l[n]=s:t.push({[n]:s,offset:o})}}}return t.sort((e,s)=>Number(e.offset)-Number(s.offset)),t}};var b=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[,...s]=e.split("-");s&&t.push({name:s.join("-"),width:Number(this.getAttribute(e))})}t.length&&(this.breakpoints=t),this.breakpoints.sort((e,s)=>s.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 w=class extends m{#t;constructor(){super()}set#r(t){this.getContent().style.left=`${t.x}px`,this.getContent().style.top=`${t.y}px`}async show(t){let e=window.scrollY,s=window.scrollX,i=t instanceof MouseEvent?t.clientX:t.touches[0]?.clientX??0,r=t instanceof MouseEvent?t.clientY:t.touches[0]?.clientY??0,n=i+s,o=r+e;this.getContent().style.position="absolute",this.getContent().style.display="block";let l=this.getContent().offsetWidth+24,h=this.getContent().offsetHeight+6,u=window.innerWidth,f=window.innerHeight;n+l>s+u&&(n=s+u-l),o+h>e+f&&(o=e+f-h),this.#r={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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};var p=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 p{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var x=class extends m{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 E=class extends m{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};var T=class extends c{#t=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#r)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#r(){let t=[];for(let e of this.getTrigger())t.push(this.#a(e));return t}get#h(){let t=this.text.split("```"),e=0;for(let[s,i]of t.entries())if(e+=i.length+3,this.#s<e)return s;return 0}get#e(){return this.textArea.selectionEnd}get#s(){return this.textArea.selectionStart}#i(t,e){this.textArea.setSelectionRange(t,e)}#a(t){let e=t.dataset.type,s=t.dataset.value,i=t.dataset.key??void 0;return{type:e,value:s,key:i}}async#c(t,e,s){if(t.type==="inline")this.text=`${this.text.slice(0,s)}${t.value}${this.text.slice(s)}`;else if(t.type==="wrap")this.text=N(this.text,t.value,e),this.text=N(this.text,this.keyPairs[t.value],s+t.value.length),t.value.length<2&&this.#t.push(t.value);else if(t.type==="block"){let{lines:i,lineNumber:r}=this.#o(),n=t.value.at(0);n&&i[r]?.startsWith(n)?i[r]=t.value.trim()+i[r]:i[r]=t.value+i[r],this.text=i.join(`
2
- `)}}async#u(t,e,s){let i=0,r=0;if(/[a-z]/i.test(t)){for(let n=s;n<this.text.length;n++)if(this.text[n]?.match(/[a-z]/i))i?r=n+1:i=n;else if(i)break}else i=e+t.length,r=s+t.length;this.#i(i,r),this.textArea.focus()}async#n(t){let e=this.#e,s=this.#s;await this.#c(t,s,e),this.#u(t.value,s,e)}#m(t){if(t){let e=[];this.#r.forEach(i=>{i.type==="block"&&e.push(i.value)});for(let i=0;i<e.length;i++){let r=e[i];if(r&&t.startsWith(r))return r}let s=k(t);if(s)return`${s}. `}return""}#o(){let t=this.text.split(`
3
- `),e=0;for(let s=0;s<t.length;s++){let i=t.at(s)?.length??0;if(e++,e+=i,e>this.#e)return{lines:t,lineNumber:s,columnNumber:this.#e-(e-i-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#l(t,e=!1){let{lines:s}=this.#o();for(let i=t+1;i<s.length;i++){let r=s[i];if(r){let n=k(r);if(n){let o;if(e)if(n>1)o=n-1;else break;else o=n+1;s[i]=r.slice(String(n).length),s[i]=String(o)+s[i]}else break}}this.text=s.join(`
4
- `)}mount(){this.textArea.addEventListener("keydown",async t=>{let e=["ArrowUp","ArrowDown","Delete"],s=this.text[this.#e]??"";if(e.includes(t.key))this.#t=[];else if(t.key==="Backspace"){let i=this.text[this.#s-1];if(i&&i in this.keyPairs&&s===this.keyPairs[i]){t.preventDefault();let r=this.#s-1,n=this.#e-1;this.text=g(this.text,r),this.text=g(this.text,n),setTimeout(()=>{this.#i(r,n)},0),this.#t.pop()}if(i===`
5
- `&&this.#s===this.#e){t.preventDefault();let r=this.#s-1,{lineNumber:n}=this.#o();this.#l(n,!0),this.text=g(this.text,r),setTimeout(async()=>{this.#i(r,r)},0)}}else if(t.key==="Tab")this.#h%2!==0&&(t.preventDefault(),await this.#n({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:i,lineNumber:r,columnNumber:n}=this.#o(),o=i.at(r),l=this.#m(o),h=l,u=k(l);if(u&&(l=`${u+1}. `),l&&h.length<n)t.preventDefault(),u&&this.#l(r),await this.#n({type:"inline",value:`
6
- ${l}`});else if(l&&h.length===n){t.preventDefault();let f=this.#e,d=f-h.length;for(let y=0;y<h.length;y++)this.text=g(this.text,f-(y+1));setTimeout(async()=>{this.#i(d,d),this.textArea.focus(),await this.#n({type:"inline",value:`
7
- `})},0)}}else{let i=Object.values(this.keyPairs).includes(s),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:l}=this.#o();if(await navigator.clipboard.writeText(`${o===0&&t.key==="x"?"":`
8
- `}${n[o]}`),t.key==="x"){let h=this.#s-l;n.splice(o,1),this.text=n.join(`
9
- `),setTimeout(()=>{this.#i(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#r.find(o=>o.key===t.key);n&&this.#n(n)}else i&&(s===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#i(this.#s+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#n({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#s!==this.#e&&(this.text[this.#s]===" "&&this.#i(this.#s+1,this.#e),this.text[this.#e-1]===" "&&this.#i(this.#s,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#n(this.#a(t))})}},k=a=>{let t=a.match(/^(\d+)\./);return t?Number(t[1]):null},N=(a,t,e)=>a.slice(0,e)+t+a.slice(e),g=(a,t)=>a.slice(0,t)+a.slice(t+1);var A=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 C=class extends m{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 L=class extends p{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 M=class extends c{constructor(){super()}#t(t){let e="data-asc",s="data-desc";for(let i of this.getTrigger())i!==t&&(i.removeAttribute(e),i.removeAttribute(s));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(s,""),!1):(t.removeAttribute(s),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(D(e,this.#t(e))).forEach(s=>t.appendChild(s))})}},D=(a,t)=>(s,i)=>{let r=Array.from(a.parentNode?.children??[]).indexOf(a);return((o,l)=>{let h=a.dataset.type??"string";if(h==="string")return new Intl.Collator().compare(o,l);if(h==="boolean"){let u=f=>["0","false","null","undefined"].includes(f)?!1:!!f;return u(o)===u(l)?0:u(o)?-1:1}else return Number(o)-Number(l)})(S(t?s:i,r),S(t?i:s,r))},S=(a,t)=>{let e=a.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var H=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":""}`})}};})();
1
+ "use strict";(()=>{var h=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);i instanceof HTMLTemplateElement?this.getContent().replaceChildren(i.content.cloneNode(!0)):this.getContent().replaceChildren(...i.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...s),e)}}safeListener(t,e,i=document.body,s={}){s.signal=this.#t.signal,i.addEventListener(t,e,s)}triggerListener(t,e=this.event){for(let i of this.getTrigger())i.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var m=class extends h{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 l=["composite","easing","offset"];for(let u of l)delete r[u],delete n[u]}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,l)=>l<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),l=t.find(u=>u.offset===o);l?l[n]=i:t.push({[n]:i,offset:o})}}}return t.sort((e,i)=>Number(e.offset)-Number(i.offset)),t}};var b=class extends h{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 m{#t;constructor(){super()}set#r(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 l=this.getContent().offsetWidth+24,u=this.getContent().offsetHeight+6,c=window.innerWidth,p=window.innerHeight;n+l>i+c&&(n=i+c-l),o+u>e+p&&(o=e+p-u),this.#r={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");let t=()=>clearTimeout(this.#t);this.triggerListener(t,"touchend"),this.triggerListener(t,"touchcancel"),this.safeListener("keydown",e=>{e.key==="Escape"&&this.hide()})}};var f=class extends h{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 x=class extends f{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var w=class extends m{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 v=class extends m{constructor(){super()}get dialog(){return this.getContent(HTMLDialogElement)}async show(){this.dialog.showModal(),await this.animateElement()}async close(){await this.animateElement({options:{direction:"reverse"}}),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())})}};var k=class extends h{#t=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#r)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#r(){let t=[];for(let e of this.getTrigger())t.push(this.#a(e));return t}get#u(){let t=this.text.split("```"),e=0;for(let[i,s]of t.entries())if(e+=s.length+3,this.#i<e)return i;return 0}get#e(){return this.textArea.selectionEnd}get#i(){return this.textArea.selectionStart}#s(t,e){this.textArea.setSelectionRange(t,e)}#a(t){let e=t.dataset.type,i=t.dataset.value,s=t.dataset.key??void 0;return{type:e,value:i,key:s}}async#h(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=S(this.text,t.value,e),this.text=S(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.#o(),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#c(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.#s(s,r),this.textArea.focus()}async#n(t){let e=this.#e,i=this.#i;await this.#h(t,i,e),this.#c(t.value,i,e)}#m(t){if(t){let e=[];this.#r.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=E(t);if(i)return`${i}. `}return""}#o(){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}}#l(t,e=!1){let{lines:i}=this.#o();for(let s=t+1;s<i.length;s++){let r=i[s];if(r){let n=E(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.#i-1];if(s&&s in this.keyPairs&&i===this.keyPairs[s]){t.preventDefault();let r=this.#i-1,n=this.#e-1;this.text=g(this.text,r),this.text=g(this.text,n),setTimeout(()=>{this.#s(r,n)},0),this.#t.pop()}if(s===`
5
+ `&&this.#i===this.#e){t.preventDefault();let r=this.#i-1,{lineNumber:n}=this.#o();this.#l(n,!0),this.text=g(this.text,r),setTimeout(async()=>{this.#s(r,r)},0)}}else if(t.key==="Tab")this.#u%2!==0&&(t.preventDefault(),await this.#n({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:s,lineNumber:r,columnNumber:n}=this.#o(),o=s.at(r),l=this.#m(o),u=l,c=E(l);if(c&&(l=`${c+1}. `),l&&u.length<n)t.preventDefault(),c&&this.#l(r),await this.#n({type:"inline",value:`
6
+ ${l}`});else if(l&&u.length===n){t.preventDefault();let p=this.#e,d=p-u.length;for(let y=0;y<u.length;y++)this.text=g(this.text,p-(y+1));setTimeout(async()=>{this.#s(d,d),this.textArea.focus(),await this.#n({type:"inline",value:`
7
+ `})},0)}}else{let s=Object.values(this.keyPairs).includes(i),r=this.#i!==this.#e;if((t.ctrlKey||t.metaKey)&&this.#i===this.#e&&(t.key==="c"||t.key==="x")){t.preventDefault();let{lines:n,lineNumber:o,columnNumber:l}=this.#o();if(await navigator.clipboard.writeText(`${o===0&&t.key==="x"?"":`
8
+ `}${n[o]}`),t.key==="x"){let u=this.#i-l;n.splice(o,1),this.text=n.join(`
9
+ `),setTimeout(()=>{this.#s(u,u)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let n=this.#r.find(o=>o.key===t.key);n&&this.#n(n)}else s&&(i===t.key||t.key==="ArrowRight")&&this.#t.length&&!r?(t.preventDefault(),this.#s(this.#i+1,this.#e+1),this.#t.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#n({type:"wrap",value:t.key}),this.#t.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#i!==this.#e&&(this.text[this.#i]===" "&&this.#s(this.#i+1,this.#e),this.text[this.#e-1]===" "&&this.#s(this.#i,this.#e-1))}),this.textArea.addEventListener("click",()=>this.#t=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#n(this.#a(t))})}},E=a=>{let t=a.match(/^(\d+)\./);return t?Number(t[1]):null},S=(a,t,e)=>a.slice(0,e)+t+a.slice(e),g=(a,t)=>a.slice(0,t)+a.slice(t+1);var T=class extends h{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 C=class extends m{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 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 M=class extends h{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(D(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},D=(a,t)=>(i,s)=>{let r=Array.from(a.parentNode?.children??[]).indexOf(a);return((o,l)=>{let u=a.dataset.type??"string";if(u==="string")return new Intl.Collator().compare(o,l);if(u==="boolean"){let c=p=>["0","false","null","undefined"].includes(p)?!1:!!p;return c(o)===c(l)?0:c(o)?-1:1}else return Number(o)-Number(l)})(N(t?i:s,r),N(t?s:i,r))},N=(a,t)=>{let e=a.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};var H=class extends h{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 CHANGED
@@ -1 +1 @@
1
- import{a as l}from"./chunk-G5WFHYNX.js";import{a as m}from"./chunk-VEVFQB5N.js";import{a as h}from"./chunk-GPET75FT.js";import{a as i}from"./chunk-5JV4T7GM.js";import{a as j}from"./chunk-T7RZI3ZL.js";import{a as k}from"./chunk-IQJQPZUL.js";import{a as d}from"./chunk-57VEEUFG.js";import{a as e}from"./chunk-TSTTUEAF.js";import"./chunk-7F7CQUEG.js";import{a as f}from"./chunk-JMJUWKN2.js";import{a as g}from"./chunk-7S6DTKGH.js";import{a as b}from"./chunk-7KU2PRW5.js";import{a as c}from"./chunk-6HYPZWQ4.js";import{b as a}from"./chunk-MXKU7AKV.js";export{b as Animate,a as Base,c as Breakpoint,d as ContextMenu,e as Copy,f as Details,g as Dialog,h as Editor,i as Fullscreen,j as Popover,k as Share,l as TableSort,m as YouTube};
1
+ import{a as l}from"./chunk-3ASUSP4D.js";import{a as m}from"./chunk-VEVFQB5N.js";import{a as h}from"./chunk-GPET75FT.js";import{a as i}from"./chunk-5JV4T7GM.js";import{a as j}from"./chunk-DKKPV7QP.js";import{a as k}from"./chunk-4WBITBA6.js";import{a as d}from"./chunk-AWUCZCAJ.js";import{a as e}from"./chunk-XAP2U34A.js";import"./chunk-7F7CQUEG.js";import{a as f}from"./chunk-LHXOPRVC.js";import{a as g}from"./chunk-H4RNP4O4.js";import{a as b}from"./chunk-F5BEEHGA.js";import{a as c}from"./chunk-BCS5E3IH.js";import{b as a}from"./chunk-MXKU7AKV.js";export{b as Animate,a as Base,c as Breakpoint,d as ContextMenu,e as Copy,f as Details,g as Dialog,h as Editor,i as Fullscreen,j as Popover,k as Share,l as TableSort,m as YouTube};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "drab",
3
3
  "description": "A headless custom element library",
4
- "version": "5.0.0-beta.6",
4
+ "version": "5.0.1",
5
5
  "homepage": "https://drab.robino.dev",
6
6
  "license": "MIT",
7
7
  "author": {
@@ -152,11 +152,11 @@
152
152
  "copy": "cp package.json ./package && cp README.md ./package && cp LICENSE.md ./package",
153
153
  "json": "bun src/lib/scripts/packageJson/index.ts && prettier --write package.json",
154
154
  "package": "bun json && tsup && bun copy",
155
- "pub": "bun i && bun doc && bun package && npm publish --access public --tag beta ./package"
155
+ "pub": "bun i && bun doc && bun package && npm publish --access public ./package"
156
156
  },
157
157
  "devDependencies": {
158
158
  "@tailwindcss/typography": "^0.5.10",
159
- "@types/node": "^20.11.7",
159
+ "@types/node": "^20.11.16",
160
160
  "autoprefixer": "^10.4.17",
161
161
  "domco": "^0.3.7",
162
162
  "prettier": "^3.2.4",
@@ -1 +1 @@
1
- "use strict";(()=>{var f=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 s=this.querySelector(this.getAttribute("content")??"[data-content]");if(s instanceof e)return s;throw new Error("Content not found")}swapContent(e=!0,s=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let n=Array.from(this.getContent().childNodes);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),s)}}safeListener(e,s,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,s,n)}triggerListener(e,s=this.event){for(let t of this.getTrigger())t.addEventListener(s,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var m=class extends f{constructor(){super()}get animationOptions(){let e={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let t=this.getAttribute(s),[,,n]=s.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:s=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 o=n.at(0),i=n.at(-1);if(o&&i){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete i[l]}t.direction?.includes("reverse")&&([o,i]=[i,o]),Object.assign(s.style,o),await s.animate(n,t).finished,Object.assign(s.style,i)}}get keyframes(){let e=[];for(let s of this.getAttributeNames()){let t=this.getAttribute(s),[,,n,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let i=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&i){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[i]=t:e.push({[i]:t,offset:r})}}}return e.sort((s,t)=>Number(s.offset)-Number(t.offset)),e}};var c=class extends m{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",c);})();
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);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),i)}}safeListener(e,i,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,i,n)}triggerListener(e,i=this.event){for(let t of this.getTrigger())t.addEventListener(i,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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 o=n.at(0),s=n.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let m of a)delete o[m],delete s[m]}t.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(n,t).finished,Object.assign(i.style,s)}}get keyframes(){let e=[];for(let i of this.getAttributeNames()){let t=this.getAttribute(i),[,,n,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&s){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[s]=t:e.push({[s]: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 CHANGED
@@ -1 +1 @@
1
- import{a as o}from"../chunk-T7RZI3ZL.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-popover",o);
1
+ import{a as o}from"../chunk-DKKPV7QP.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-popover",o);
@@ -1,6 +1,8 @@
1
- import { Animate } from '../animate/index.js';
1
+ import { AnimateAttributes, Animate } from '../animate/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
  import '../base/index.js';
3
4
 
5
+ type PopoverAttributes = Attributes<Popover> & AnimateAttributes;
4
6
  /**
5
7
  * Provides animations for the Popover API.
6
8
  *
@@ -26,4 +28,4 @@ declare class Popover extends Animate {
26
28
  mount(): void;
27
29
  }
28
30
 
29
- export { Popover };
31
+ export { Popover, type PopoverAttributes };
@@ -1 +1 @@
1
- "use strict";(()=>{var f=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 s=this.querySelector(this.getAttribute("content")??"[data-content]");if(s instanceof e)return s;throw new Error("Content not found")}swapContent(e=!0,s=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let n=Array.from(this.getContent().childNodes);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),s)}}safeListener(e,s,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,s,n)}triggerListener(e,s=this.event){for(let t of this.getTrigger())t.addEventListener(s,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#e.abort()}};var m=class extends f{constructor(){super()}get animationOptions(){let e={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let t=this.getAttribute(s),[,,n]=s.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:s=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 o=n.at(0),i=n.at(-1);if(o&&i){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete i[l]}t.direction?.includes("reverse")&&([o,i]=[i,o]),Object.assign(s.style,o),await s.animate(n,t).finished,Object.assign(s.style,i)}}get keyframes(){let e=[];for(let s of this.getAttributeNames()){let t=this.getAttribute(s),[,,n,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let i=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&i){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[i]=t:e.push({[i]:t,offset:r})}}}return e.sort((s,t)=>Number(s.offset)-Number(t.offset)),e}};var h=class extends m{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())})}};})();
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);t instanceof HTMLTemplateElement?this.getContent().replaceChildren(t.content.cloneNode(!0)):this.getContent().replaceChildren(...t.childNodes),e&&setTimeout(()=>this.getContent().replaceChildren(...n),i)}}safeListener(e,i,t=document.body,n={}){n.signal=this.#e.signal,t.addEventListener(e,i,n)}triggerListener(e,i=this.event){for(let t of this.getTrigger())t.addEventListener(i,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){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 o=n.at(0),s=n.at(-1);if(o&&s){let a=["composite","easing","offset"];for(let l of a)delete o[l],delete s[l]}t.direction?.includes("reverse")&&([o,s]=[s,o]),Object.assign(i.style,o),await i.animate(n,t).finished,Object.assign(i.style,s)}}get keyframes(){let e=[];for(let i of this.getAttributeNames()){let t=this.getAttribute(i),[,,n,...o]=i.split("-");if(i.startsWith("animation-keyframe-")){let s=o.map((r,a)=>a<1?r:r.at(0)?.toUpperCase()+r.slice(1)).join("");if(n&&s){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[s]=t:e.push({[s]: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 CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-T7RZI3ZL.js";import"../chunk-7KU2PRW5.js";import"../chunk-MXKU7AKV.js";export{a as Popover};
1
+ import{a}from"../chunk-DKKPV7QP.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as Popover};
package/share/define.js CHANGED
@@ -1 +1 @@
1
- import{a as e}from"../chunk-IQJQPZUL.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-share",e);
1
+ import{a as e}from"../chunk-4WBITBA6.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-share",e);
package/share/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { B as BaseCopy } from '../index-SyRipepB.js';
1
+ import { B as BaseCopy } from '../index-0rvQCq2U.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
  import '../base/index.js';
3
4
 
5
+ type ShareAttributes = Attributes<Share, "value">;
4
6
  /**
5
- * Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) to share a `url`. If `share` is not supported, falls back to copy the text instead.
7
+ * Uses the [Navigator API](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/share) to share a url. If `share` is not supported, falls back to copy the text instead.
6
8
  */
7
9
  declare class Share extends BaseCopy {
8
10
  constructor();
@@ -16,4 +18,4 @@ declare class Share extends BaseCopy {
16
18
  mount(): void;
17
19
  }
18
20
 
19
- export { Share };
21
+ export { Share, type ShareAttributes };
package/share/index.js CHANGED
@@ -1 +1 @@
1
- import{a}from"../chunk-IQJQPZUL.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";export{a as Share};
1
+ import{a}from"../chunk-4WBITBA6.js";import"../chunk-7F7CQUEG.js";import"../chunk-MXKU7AKV.js";export{a as Share};
@@ -1 +1 @@
1
- "use strict";(()=>{var n=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 s=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(s){let i=Array.from(this.getContent().childNodes);s instanceof HTMLTemplateElement?this.getContent().replaceChildren(s.content.cloneNode(!0)):this.getContent().replaceChildren(...s.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...i),e)}}safeListener(t,e,s=document.body,i={}){i.signal=this.#t.signal,s.addEventListener(t,e,i)}triggerListener(t,e=this.event){for(let s of this.getTrigger())s.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var o=class extends n{constructor(){super()}#t(t){let e="data-asc",s="data-desc";for(let i of this.getTrigger())i!==t&&(i.removeAttribute(e),i.removeAttribute(s));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(s,""),!1):(t.removeAttribute(s),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(d(e,this.#t(e))).forEach(s=>t.appendChild(s))})}},d=(r,t)=>(s,i)=>{let u=Array.from(r.parentNode?.children??[]).indexOf(r);return((a,c)=>{let m=r.dataset.type??"string";if(m==="string")return new Intl.Collator().compare(a,c);if(m==="boolean"){let l=f=>["0","false","null","undefined"].includes(f)?!1:!!f;return l(a)===l(c)?0:l(a)?-1:1}else return Number(a)-Number(c)})(p(t?s:i,u),p(t?i:s,u))},p=(r,t)=>{let e=r.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};customElements.define("drab-tablesort",o);})();
1
+ "use strict";(()=>{var n=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);i instanceof HTMLTemplateElement?this.getContent().replaceChildren(i.content.cloneNode(!0)):this.getContent().replaceChildren(...i.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...s),e)}}safeListener(t,e,i=document.body,s={}){s.signal=this.#t.signal,i.addEventListener(t,e,s)}triggerListener(t,e=this.event){for(let i of this.getTrigger())i.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var o=class extends n{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(d(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},d=(r,t)=>(i,s)=>{let c=Array.from(r.parentNode?.children??[]).indexOf(r);return((a,h)=>{let m=r.dataset.type??"string";if(m==="string")return new Intl.Collator().compare(a,h);if(m==="boolean"){let l=p=>["0","false","null","undefined"].includes(p)?!1:!!p;return l(a)===l(h)?0:l(a)?-1:1}else return Number(a)-Number(h)})(f(t?i:s,c),f(t?s:i,c))},f=(r,t)=>{let e=r.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};customElements.define("drab-tablesort",o);})();
@@ -1 +1 @@
1
- import{a as e}from"../chunk-G5WFHYNX.js";import"../chunk-VEVFQB5N.js";import"../chunk-GPET75FT.js";import"../chunk-5JV4T7GM.js";import"../chunk-T7RZI3ZL.js";import"../chunk-IQJQPZUL.js";import"../chunk-57VEEUFG.js";import"../chunk-TSTTUEAF.js";import"../chunk-7F7CQUEG.js";import"../chunk-JMJUWKN2.js";import"../chunk-7S6DTKGH.js";import"../chunk-7KU2PRW5.js";import"../chunk-6HYPZWQ4.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-tablesort",e);
1
+ import{a as e}from"../chunk-3ASUSP4D.js";import"../chunk-VEVFQB5N.js";import"../chunk-GPET75FT.js";import"../chunk-5JV4T7GM.js";import"../chunk-DKKPV7QP.js";import"../chunk-4WBITBA6.js";import"../chunk-AWUCZCAJ.js";import"../chunk-XAP2U34A.js";import"../chunk-7F7CQUEG.js";import"../chunk-LHXOPRVC.js";import"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-BCS5E3IH.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-tablesort",e);
@@ -1,5 +1,7 @@
1
1
  import { Base } from '../base/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
 
4
+ type TableSortAttributes = Attributes<TableSort>;
3
5
  /**
4
6
  * Wrap a `HTMLTableElement` in the `TableSort` element to have sortable column
5
7
  * headers. Set each `th` that you want to sort to the `trigger`. Set the `tbody`
@@ -19,4 +21,4 @@ declare class TableSort extends Base {
19
21
  mount(): void;
20
22
  }
21
23
 
22
- export { TableSort };
24
+ export { TableSort, type TableSortAttributes };
@@ -1 +1 @@
1
- "use strict";(()=>{var n=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 s=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(s){let i=Array.from(this.getContent().childNodes);s instanceof HTMLTemplateElement?this.getContent().replaceChildren(s.content.cloneNode(!0)):this.getContent().replaceChildren(...s.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...i),e)}}safeListener(t,e,s=document.body,i={}){i.signal=this.#t.signal,s.addEventListener(t,e,i)}triggerListener(t,e=this.event){for(let s of this.getTrigger())s.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var c=class extends n{constructor(){super()}#t(t){let e="data-asc",s="data-desc";for(let i of this.getTrigger())i!==t&&(i.removeAttribute(e),i.removeAttribute(s));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(s,""),!1):(t.removeAttribute(s),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(d(e,this.#t(e))).forEach(s=>t.appendChild(s))})}},d=(r,t)=>(s,i)=>{let u=Array.from(r.parentNode?.children??[]).indexOf(r);return((o,h)=>{let m=r.dataset.type??"string";if(m==="string")return new Intl.Collator().compare(o,h);if(m==="boolean"){let a=f=>["0","false","null","undefined"].includes(f)?!1:!!f;return a(o)===a(h)?0:a(o)?-1:1}else return Number(o)-Number(h)})(p(t?s:i,u),p(t?i:s,u))},p=(r,t)=>{let e=r.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};})();
1
+ "use strict";(()=>{var n=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);i instanceof HTMLTemplateElement?this.getContent().replaceChildren(i.content.cloneNode(!0)):this.getContent().replaceChildren(...i.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...s),e)}}safeListener(t,e,i=document.body,s={}){s.signal=this.#t.signal,i.addEventListener(t,e,s)}triggerListener(t,e=this.event){for(let i of this.getTrigger())i.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var h=class extends n{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(d(e,this.#t(e))).forEach(i=>t.appendChild(i))})}},d=(r,t)=>(i,s)=>{let c=Array.from(r.parentNode?.children??[]).indexOf(r);return((o,u)=>{let m=r.dataset.type??"string";if(m==="string")return new Intl.Collator().compare(o,u);if(m==="boolean"){let a=p=>["0","false","null","undefined"].includes(p)?!1:!!p;return a(o)===a(u)?0:a(o)?-1:1}else return Number(o)-Number(u)})(f(t?i:s,c),f(t?s:i,c))},f=(r,t)=>{let e=r.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};})();
@@ -1 +1 @@
1
- import{a}from"../chunk-G5WFHYNX.js";import"../chunk-VEVFQB5N.js";import"../chunk-GPET75FT.js";import"../chunk-5JV4T7GM.js";import"../chunk-T7RZI3ZL.js";import"../chunk-IQJQPZUL.js";import"../chunk-57VEEUFG.js";import"../chunk-TSTTUEAF.js";import"../chunk-7F7CQUEG.js";import"../chunk-JMJUWKN2.js";import"../chunk-7S6DTKGH.js";import"../chunk-7KU2PRW5.js";import"../chunk-6HYPZWQ4.js";import"../chunk-MXKU7AKV.js";export{a as TableSort};
1
+ import{a}from"../chunk-3ASUSP4D.js";import"../chunk-VEVFQB5N.js";import"../chunk-GPET75FT.js";import"../chunk-5JV4T7GM.js";import"../chunk-DKKPV7QP.js";import"../chunk-4WBITBA6.js";import"../chunk-AWUCZCAJ.js";import"../chunk-XAP2U34A.js";import"../chunk-7F7CQUEG.js";import"../chunk-LHXOPRVC.js";import"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-BCS5E3IH.js";import"../chunk-MXKU7AKV.js";export{a as TableSort};
@@ -1,5 +1,7 @@
1
1
  import { Base } from '../base/index.js';
2
+ import { A as Attributes } from '../index-J5TqSvEl.js';
2
3
 
4
+ type YouTubeAttributes = Attributes<YouTube, "uid">;
3
5
  /**
4
6
  * Embeds a YouTube video iframe into a website with the video uid, using www.youtube-nocookie.com.
5
7
  */
@@ -26,4 +28,4 @@ declare class YouTube extends Base {
26
28
  attributeChangedCallback(): void;
27
29
  }
28
30
 
29
- export { YouTube };
31
+ export { YouTube, type YouTubeAttributes };
@@ -1 +1 @@
1
- "use strict";(()=>{var s=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 r=Array.from(this.getContent().childNodes);n instanceof HTMLTemplateElement?this.getContent().replaceChildren(n.content.cloneNode(!0)):this.getContent().replaceChildren(...n.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...r),e)}}safeListener(t,e,n=document.body,r={}){r.signal=this.#t.signal,n.addEventListener(t,e,r)}triggerListener(t,e=this.event){for(let n of this.getTrigger())n.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var i=class extends s{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":""}`})}};})();
1
+ "use strict";(()=>{var s=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 r=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(r){let n=Array.from(this.getContent().childNodes);r instanceof HTMLTemplateElement?this.getContent().replaceChildren(r.content.cloneNode(!0)):this.getContent().replaceChildren(...r.childNodes),t&&setTimeout(()=>this.getContent().replaceChildren(...n),e)}}safeListener(t,e,r=document.body,n={}){n.signal=this.#t.signal,r.addEventListener(t,e,n)}triggerListener(t,e=this.event){for(let r of this.getTrigger())r.addEventListener(e,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}disconnectedCallback(){this.#t.abort()}};var i=class extends s{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/chunk-7KU2PRW5.js DELETED
@@ -1 +0,0 @@
1
- import{b as m}from"./chunk-MXKU7AKV.js";var l=class extends m{constructor(){super()}get animationOptions(){let i={};for(let s of this.getAttributeNames())if(s.startsWith("animation-option-")){let e=this.getAttribute(s),[,,t]=s.split("-");e&&(t==="duration"||t==="delay"?i[t]=Number(e):t==="easing"&&(i[t]=e))}return i}async animateElement(i={element:this.getContent(),options:{}}){let{element:s=this.getContent(),options:e={}}=i,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 o=t.at(0),n=t.at(-1);if(o&&n){let r=["composite","easing","offset"];for(let f of r)delete o[f],delete n[f]}e.direction?.includes("reverse")&&([o,n]=[n,o]),Object.assign(s.style,o),await s.animate(t,e).finished,Object.assign(s.style,n)}}get keyframes(){let i=[];for(let s of this.getAttributeNames()){let e=this.getAttribute(s),[,,t,...o]=s.split("-");if(s.startsWith("animation-keyframe-")){let n=o.map((a,r)=>r<1?a:a.at(0)?.toUpperCase()+a.slice(1)).join("");if(t&&n){t==="from"?t="0":t==="to"?t="1":t=String(parseInt(t)*.01);let a=Number(t),r=i.find(f=>f.offset===a);r?r[n]=e:i.push({[n]:e,offset:a})}}}return i.sort((s,e)=>Number(s.offset)-Number(e.offset)),i}};export{l as a};
package/chunk-G5WFHYNX.js DELETED
@@ -1 +0,0 @@
1
- import{a as M}from"./chunk-VEVFQB5N.js";import{a as h}from"./chunk-GPET75FT.js";import{a as y}from"./chunk-5JV4T7GM.js";import{a as v}from"./chunk-T7RZI3ZL.js";import{a as L}from"./chunk-IQJQPZUL.js";import{a as b}from"./chunk-57VEEUFG.js";import{a as T}from"./chunk-TSTTUEAF.js";import{a as A}from"./chunk-JMJUWKN2.js";import{a as E}from"./chunk-7S6DTKGH.js";import{a as p}from"./chunk-7KU2PRW5.js";import{a as d}from"./chunk-6HYPZWQ4.js";import{a as H,b as i}from"./chunk-MXKU7AKV.js";var g={};H(g,{Animate:()=>p,Base:()=>i,Breakpoint:()=>d,ContextMenu:()=>b,Copy:()=>T,Details:()=>A,Dialog:()=>E,Editor:()=>h,Fullscreen:()=>y,Popover:()=>v,Share:()=>L,TableSort:()=>l,YouTube:()=>M});var l=class extends i{constructor(){super()}#t(t){let e="data-asc",r="data-desc";for(let n of this.getTrigger())n!==t&&(n.removeAttribute(e),n.removeAttribute(r));return t.hasAttribute(e)?(t.removeAttribute(e),t.setAttribute(r,""),!1):(t.removeAttribute(r),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(C(e,this.#t(e))).forEach(r=>t.appendChild(r))})}},C=(o,t)=>(r,n)=>{let c=Array.from(o.parentNode?.children??[]).indexOf(o);return((s,a)=>{let u=o.dataset.type??"string";if(u==="string")return new Intl.Collator().compare(s,a);if(u==="boolean"){let m=f=>["0","false","null","undefined"].includes(f)?!1:!!f;return m(s)===m(a)?0:m(s)?-1:1}else return Number(s)-Number(a)})(x(t?r:n,c),x(t?n:r,c))},x=(o,t)=>{let e=o.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};export{l as a,g as b};
package/chunk-IQJQPZUL.js DELETED
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-7F7CQUEG.js";var e=class extends t{constructor(){super()}async share(r=this.value){if(navigator.canShare&&navigator.canShare({url:r}))try{await navigator.share({url:r})}catch(a){a?.name!=="AbortError"&&console.error(a)}else this.copy()}mount(){this.triggerListener(async()=>await this.share())}};export{e as a};
package/chunk-JMJUWKN2.js DELETED
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-7KU2PRW5.js";var n=class extends t{constructor(){super()}get details(){let e=this.getContent(HTMLElement).parentElement;if(!(e instanceof HTMLDetailsElement))throw new Error("Details: HTMLDetailsElement not found.");return e}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(e=>{e.preventDefault(),this.toggle()})}};export{n as a};
package/chunk-T7RZI3ZL.js DELETED
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-7KU2PRW5.js";var s=class extends t{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())})}};export{s as a};
package/chunk-TSTTUEAF.js DELETED
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-7F7CQUEG.js";var s=class extends t{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};export{s as a};