drab 5.0.0-beta.4 → 5.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunk-GPET75FT.js +9 -0
- package/{chunk-JS7MGAA3.js → chunk-NKTVSHQB.js} +1 -1
- package/define/index.iife.js +1 -1
- package/define/index.js +1 -1
- package/editor/define.iife.js +3 -3
- package/editor/define.js +1 -1
- package/editor/index.iife.js +3 -3
- package/editor/index.js +1 -1
- package/index.iife.js +9 -9
- package/index.js +1 -1
- package/package.json +1 -1
- package/tablesort/define.iife.js +1 -1
- package/tablesort/define.js +1 -1
- package/tablesort/index.iife.js +1 -1
- package/tablesort/index.js +1 -1
- package/chunk-OVFOS5OP.js +0 -9
@@ -0,0 +1,9 @@
|
|
1
|
+
import{b as p}from"./chunk-MXKU7AKV.js";var x=class extends p{#s=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#h)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#h(){let t=[];for(let s of this.getTrigger())t.push(this.#l(s));return t}get#o(){let t=this.text.split("```"),s=0;for(let[i,e]of t.entries())if(s+=e.length+3,this.#e<s)return i;return 0}get#t(){return this.textArea.selectionEnd}get#e(){return this.textArea.selectionStart}#i(t,s){this.textArea.setSelectionRange(t,s)}#l(t){let s=t.dataset.type,i=t.dataset.value,e=t.dataset.key??void 0;return{type:s,value:i,key:e}}async#c(t,s,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=k(this.text,t.value,s),this.text=k(this.text,this.keyPairs[t.value],i+t.value.length),t.value.length<2&&this.#s.push(t.value);else if(t.type==="block"){let{lines:e,lineNumber:n}=this.#r(),r=t.value.at(0);r&&e[n]?.startsWith(r)?e[n]=t.value.trim()+e[n]:e[n]=t.value+e[n],this.text=e.join(`
|
2
|
+
`)}}async#u(t,s,i){let e=0,n=0;if(/[a-z]/i.test(t)){for(let r=i;r<this.text.length;r++)if(this.text[r]?.match(/[a-z]/i))e?n=r+1:e=r;else if(e)break}else e=s+t.length,n=i+t.length;this.#i(e,n),this.textArea.focus()}async#n(t){let s=this.#t,i=this.#e;await this.#c(t,i,s),this.#u(t.value,i,s)}#f(t){if(t){let s=[];this.#h.forEach(e=>{e.type==="block"&&s.push(e.value)});for(let e=0;e<s.length;e++){let n=s[e];if(n&&t.startsWith(n))return n}let i=g(t);if(i)return`${i}. `}return""}#r(){let t=this.text.split(`
|
3
|
+
`),s=0;for(let i=0;i<t.length;i++){let e=t.at(i)?.length??0;if(s++,s+=e,s>this.#t)return{lines:t,lineNumber:i,columnNumber:this.#t-(s-e-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#a(t,s=!1){let{lines:i}=this.#r();for(let e=t+1;e<i.length;e++){let n=i[e];if(n){let r=g(n);if(r){let h;if(s)if(r>1)h=r-1;else break;else h=r+1;i[e]=n.slice(String(r).length),i[e]=String(h)+i[e]}else break}}this.text=i.join(`
|
4
|
+
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let s=["ArrowUp","ArrowDown","Delete"],i=this.text[this.#t]??"";if(s.includes(t.key))this.#s=[];else if(t.key==="Backspace"){let e=this.text[this.#e-1];if(e&&e in this.keyPairs&&i===this.keyPairs[e]){t.preventDefault();let n=this.#e-1,r=this.#t-1;this.text=c(this.text,n),this.text=c(this.text,r),setTimeout(()=>{this.#i(n,r)},0),this.#s.pop()}if(e===`
|
5
|
+
`&&this.#e===this.#t){t.preventDefault();let n=this.#e-1,{lineNumber:r}=this.#r();this.#a(r,!0),this.text=c(this.text,n),setTimeout(async()=>{this.#i(n,n)},0)}}else if(t.key==="Tab")this.#o%2!==0&&(t.preventDefault(),await this.#n({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:e,lineNumber:n,columnNumber:r}=this.#r(),h=e.at(n),a=this.#f(h),o=a,u=g(a);if(u&&(a=`${u+1}. `),a&&o.length<r)t.preventDefault(),u&&this.#a(n),await this.#n({type:"inline",value:`
|
6
|
+
${a}`});else if(a&&o.length===r){t.preventDefault();let m=this.#t,y=m-o.length;for(let f=0;f<o.length;f++)this.text=c(this.text,m-(f+1));setTimeout(async()=>{this.#i(y,y),this.textArea.focus(),await this.#n({type:"inline",value:`
|
7
|
+
`})},0)}}else{let e=Object.values(this.keyPairs).includes(i),n=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:h,columnNumber:a}=this.#r();if(await navigator.clipboard.writeText(`${h===0&&t.key==="x"?"":`
|
8
|
+
`}${r[h]}`),t.key==="x"){let o=this.#e-a;r.splice(h,1),this.text=r.join(`
|
9
|
+
`),setTimeout(()=>{this.#i(o,o)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#h.find(h=>h.key===t.key);r&&this.#n(r)}else e&&(i===t.key||t.key==="ArrowRight")&&this.#s.length&&!n?(t.preventDefault(),this.#i(this.#e+1,this.#t+1),this.#s.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#n({type:"wrap",value:t.key}),this.#s.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#i(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#i(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#s=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#n(this.#l(t))})}},g=l=>{let t=l.match(/^(\d+)\./);return t?Number(t[1]):null},k=(l,t,s)=>l.slice(0,s)+t+l.slice(s),c=(l,t)=>l.slice(0,t)+l.slice(t+1);export{x as a};
|
@@ -1 +1 @@
|
|
1
|
-
import{a as h}from"./chunk-VEVFQB5N.js";import{a as E}from"./chunk-
|
1
|
+
import{a as h}from"./chunk-VEVFQB5N.js";import{a as E}from"./chunk-GPET75FT.js";import{a as x}from"./chunk-5JV4T7GM.js";import{a as L}from"./chunk-T7RZI3ZL.js";import{a as M}from"./chunk-IQJQPZUL.js";import{a as g}from"./chunk-57VEEUFG.js";import{a as T}from"./chunk-TSTTUEAF.js";import{a as b}from"./chunk-JMJUWKN2.js";import{a as y}from"./chunk-7S6DTKGH.js";import{a as u}from"./chunk-7KU2PRW5.js";import{a as d}from"./chunk-6HYPZWQ4.js";import{a as H,b as s}from"./chunk-MXKU7AKV.js";var A={};H(A,{Animate:()=>u,Base:()=>s,Breakpoint:()=>d,ContextMenu:()=>g,Copy:()=>T,Details:()=>b,Dialog:()=>y,Editor:()=>E,Fullscreen:()=>x,Popover:()=>L,Share:()=>M,TableSort:()=>i,YouTube:()=>h});var i=class extends s{constructor(){super()}mount(){let r=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(r.querySelectorAll("tr")).sort(B(e,e.toggleAttribute("data-ascending"))).forEach(o=>r.appendChild(o))})}},B=(t,r)=>(o,a)=>{let c=Array.from(t.parentNode?.children??[]).indexOf(t);return((n,l)=>{let f=t.dataset.type??"string";if(f==="string")return new Intl.Collator().compare(n,l);if(f==="boolean"){let m=p=>["0","false","null","undefined"].includes(p)?!1:!!p;return m(n)===m(l)?0:m(n)?-1:1}else return Number(n)-Number(l)})(C(r?o:a,c),C(r?a:o,c))},C=(t,r)=>{let e=t.children[r];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};export{i as a,A as b};
|
package/define/index.iife.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
`),e=0;for(let s=0;s<t.length;s++){let n=t.at(s)?.length??0;if(e++,e+=n,e>this.#t)return{lines:t,lineNumber:s,columnNumber:this.#t-(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
4
|
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let e=["ArrowUp","ArrowDown","Delete"],s=this.text[this.#t]??"";if(e.includes(t.key))this.#s=[];else if(t.key==="Backspace"){let n=this.text[this.#e-1];if(n&&n in this.keyPairs&&s===this.keyPairs[n]){t.preventDefault();let r=this.#e-1,i=this.#t-1;this.text=x(this.text,r),this.text=x(this.text,i),setTimeout(()=>{this.#n(r,i)},0),this.#s.pop()}if(n===`
|
5
5
|
`&&this.#e===this.#t){t.preventDefault();let r=this.#e-1,{lineNumber:i}=this.#o();this.#l(i,!0),this.text=x(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
|
6
|
+
${l}`});else if(l&&h.length===i){t.preventDefault();let f=this.#t,M=f-h.length;for(let H=0;H<h.length;H++)this.text=x(this.text,f-(H+1));setTimeout(async()=>{this.#n(M,M),this.textArea.focus(),await this.#i({type:"inline",value:`
|
7
7
|
`})},0)}}else{let n=Object.values(this.keyPairs).includes(s),r=this.#e!==this.#t;if((t.ctrlKey||t.metaKey)&&this.#e===this.#t&&(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
8
|
`}${i[a]}`),t.key==="x"){let h=this.#e-l;i.splice(a,1),this.text=i.join(`
|
9
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.#s.length&&!r?(t.preventDefault(),this.#n(this.#e+1,this.#t+1),this.#s.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#i({type:"wrap",value:t.key}),this.#s.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#n(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#n(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#s=[]);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),x=(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 C=class extends c{constructor(){super()}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(P(e,e.toggleAttribute("data-ascending"))).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 L=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 A)customElements.define(`drab-${o.toLowerCase()}`,A[o]);})();
|
package/define/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{b as e}from"../chunk-
|
1
|
+
import{b as e}from"../chunk-NKTVSHQB.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]);
|
package/editor/define.iife.js
CHANGED
@@ -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 g=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=
|
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 g=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
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=p(t);if(n)return`${n}. `}return""}#r(){let t=this.text.split(`
|
3
3
|
`),s=0;for(let n=0;n<t.length;n++){let e=t.at(n)?.length??0;if(s++,s+=e,s>this.#t)return{lines:t,lineNumber:n,columnNumber:this.#t-(s-e-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#a(t,s=!1){let{lines:n}=this.#r();for(let e=t+1;e<n.length;e++){let i=n[e];if(i){let r=p(i);if(r){let o;if(s)if(r>1)o=r-1;else break;else o=r+1;n[e]=i.slice(String(r).length),n[e]=String(o)+n[e]}else break}}this.text=n.join(`
|
4
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
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,f=p(a);if(f&&(a=`${f+1}. `),a&&h.length<r)t.preventDefault(),f&&this.#a(i),await this.#i({type:"inline",value:`
|
6
|
-
${a}`});else if(a&&h.length===r){t.preventDefault();let d=this.#t-h.length;for(let m=0;m<h.length;m++)this.text=u(this.text,
|
6
|
+
${a}`});else if(a&&h.length===r){t.preventDefault();let d=this.#t,y=d-h.length;for(let m=0;m<h.length;m++)this.text=u(this.text,d-(m+1));setTimeout(async()=>{this.#s(y,y),this.textArea.focus(),await this.#i({type:"inline",value:`
|
7
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
8
|
`}${r[o]}`),t.key==="x"){let h=this.#e-a;r.splice(o,1),this.text=r.join(`
|
9
|
-
`),setTimeout(()=>{this.#s(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#o.find(o=>o.key===t.key);r&&this.#i(r)}else e&&(n===t.key||t.key==="ArrowRight")&&this.#n.length&&!i?(t.preventDefault(),this.#s(this.#e+1,this.#t+1),this.#n.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#i({type:"wrap",value:t.key}),this.#n.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#s(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#s(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#n=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#i(this.#l(t))})}},p=l=>{let t=l.match(/^(\d+)\./);return t?Number(t[1]):null},
|
9
|
+
`),setTimeout(()=>{this.#s(h,h)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#o.find(o=>o.key===t.key);r&&this.#i(r)}else e&&(n===t.key||t.key==="ArrowRight")&&this.#n.length&&!i?(t.preventDefault(),this.#s(this.#e+1,this.#t+1),this.#n.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#i({type:"wrap",value:t.key}),this.#n.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#s(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#s(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#n=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#i(this.#l(t))})}},p=l=>{let t=l.match(/^(\d+)\./);return t?Number(t[1]):null},v=(l,t,s)=>l.slice(0,s)+t+l.slice(s),u=(l,t)=>l.slice(0,t)+l.slice(t+1);customElements.define("drab-editor",g);})();
|
package/editor/define.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{a as e}from"../chunk-
|
1
|
+
import{a as e}from"../chunk-GPET75FT.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-editor",e);
|
package/editor/index.iife.js
CHANGED
@@ -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
|
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
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
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(`
|
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
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:`
|
6
|
-
${a}`});else if(a&&h.length===r){t.preventDefault();let p=this.#t-h.length;for(let f=0;f<h.length;f++)this.text=u(this.text,
|
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
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
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},
|
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);})();
|
package/editor/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{a}from"../chunk-
|
1
|
+
import{a}from"../chunk-GPET75FT.js";import"../chunk-MXKU7AKV.js";export{a as Editor};
|
package/index.iife.js
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
"use strict";(()=>{var c=class extends HTMLElement{#s=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
|
2
|
-
`)}}async#u(t,e,s){let
|
3
|
-
`),e=0;for(let s=0;s<t.length;s++){let
|
4
|
-
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let e=["ArrowUp","ArrowDown","Delete"],s=this.text[this.#t]??"";if(e.includes(t.key))this.#s=[];else if(t.key==="Backspace"){let
|
5
|
-
`&&this.#e===this.#t){t.preventDefault();let r=this.#e-1,{lineNumber:
|
6
|
-
${l}`});else if(l&&h.length===
|
7
|
-
`})},0)}}else{let
|
8
|
-
`}${
|
9
|
-
`),setTimeout(()=>{this.#
|
1
|
+
"use strict";(()=>{var c=class extends HTMLElement{#s=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.#s.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.#s.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{#s;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.#s=setTimeout(()=>{this.show(e)},800)},"touchstart");let t=()=>clearTimeout(this.#s);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 x=class extends p{constructor(){super()}mount(){this.triggerListener(async()=>await this.copy())}};var v=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{#s=[];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.#e<e)return s;return 0}get#t(){return this.textArea.selectionEnd}get#e(){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.#s.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.#t,s=this.#e;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.#t)return{lines:t,lineNumber:s,columnNumber:this.#t-(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.#t]??"";if(e.includes(t.key))this.#s=[];else if(t.key==="Backspace"){let i=this.text[this.#e-1];if(i&&i in this.keyPairs&&s===this.keyPairs[i]){t.preventDefault();let r=this.#e-1,n=this.#t-1;this.text=g(this.text,r),this.text=g(this.text,n),setTimeout(()=>{this.#i(r,n)},0),this.#s.pop()}if(i===`
|
5
|
+
`&&this.#e===this.#t){t.preventDefault();let r=this.#e-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.#t,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.#e!==this.#t;if((t.ctrlKey||t.metaKey)&&this.#e===this.#t&&(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.#e-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.#s.length&&!r?(t.preventDefault(),this.#i(this.#e+1,this.#t+1),this.#s.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#n({type:"wrap",value:t.key}),this.#s.push(t.key))}}),this.textArea.addEventListener("dblclick",()=>{this.#e!==this.#t&&(this.text[this.#e]===" "&&this.#i(this.#e+1,this.#t),this.text[this.#t-1]===" "&&this.#i(this.#e,this.#t-1))}),this.textArea.addEventListener("click",()=>this.#s=[]);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 C=class extends c{constructor(){super()}isFullscreen(){return document.fullscreenElement!==null}fullscreenSupported(){return!!document.documentElement.requestFullscreen}toggle(){if(this.isFullscreen())document.exitFullscreen();else try{this.getContent(HTMLElement).requestFullscreen()}catch{document.documentElement.requestFullscreen()}}mount(){this.triggerListener(()=>this.toggle());for(let t of this.getTrigger())!this.fullscreenSupported()&&"disabled"in t&&(t.disabled=!0)}};var L=class extends 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 A=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()}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(D(e,e.toggleAttribute("data-ascending"))).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":""}`})}};})();
|
package/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{a as l}from"./chunk-
|
1
|
+
import{a as l}from"./chunk-NKTVSHQB.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};
|
package/package.json
CHANGED
package/tablesort/define.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var i=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 r=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(...r),e)}}safeListener(t,e,s=document.body,r={}){r.signal=this.#t.signal,s.addEventListener(t,e,r)}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 i{constructor(){super()}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(d(e,e.toggleAttribute("data-ascending"))).forEach(s=>t.appendChild(s))})}},d=(n,t)=>(s,r)=>{let u=Array.from(n.parentNode?.children??[]).indexOf(n);return((a,c)=>{let m=n.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:r,u),p(t?r:s,u))},p=(n,t)=>{let e=n.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};customElements.define("drab-tablesort",o);})();
|
package/tablesort/define.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{a as e}from"../chunk-
|
1
|
+
import{a as e}from"../chunk-NKTVSHQB.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);
|
package/tablesort/index.iife.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";(()=>{var
|
1
|
+
"use strict";(()=>{var i=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 r=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(...r),e)}}safeListener(t,e,s=document.body,r={}){r.signal=this.#t.signal,s.addEventListener(t,e,r)}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 i{constructor(){super()}mount(){let t=this.getContent(HTMLTableSectionElement);for(let e of this.getTrigger())e.addEventListener(this.event,()=>{Array.from(t.querySelectorAll("tr")).sort(d(e,e.toggleAttribute("data-ascending"))).forEach(s=>t.appendChild(s))})}},d=(n,t)=>(s,r)=>{let u=Array.from(n.parentNode?.children??[]).indexOf(n);return((o,h)=>{let m=n.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:r,u),p(t?r:s,u))},p=(n,t)=>{let e=n.children[t];return e instanceof HTMLElement?e.dataset.value??e.textContent??"":""};})();
|
package/tablesort/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{a}from"../chunk-
|
1
|
+
import{a}from"../chunk-NKTVSHQB.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};
|
package/chunk-OVFOS5OP.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
import{b as y}from"./chunk-MXKU7AKV.js";var p=class extends y{#i=[];keyPairs={"(":")","{":"}","[":"]","<":">",'"':'"',"`":"`"};constructor(){super();for(let t of this.#h)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#h(){let t=[];for(let i of this.getTrigger())t.push(this.#l(i));return t}get#o(){let t=this.text.split("```"),i=0;for(let[s,e]of t.entries())if(i+=e.length+3,this.#e<i)return s;return 0}get#t(){return this.textArea.selectionEnd}get#e(){return this.textArea.selectionStart}#s(t,i){this.textArea.setSelectionRange(t,i)}#l(t){let i=t.dataset.type,s=t.dataset.value,e=t.dataset.key??void 0;return{type:i,value:s,key:e}}async#c(t,i,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=x(this.text,t.value,i),this.text=x(this.text,this.keyPairs[t.value],s+t.value.length),t.value.length<2&&this.#i.push(t.value);else if(t.type==="block"){let{lines:e,lineNumber:n}=this.#r(),r=t.value.at(0);r&&e[n]?.startsWith(r)?e[n]=t.value.trim()+e[n]:e[n]=t.value+e[n],this.text=e.join(`
|
2
|
-
`)}}async#u(t,i,s){let e=0,n=0;if(/[a-z]/i.test(t)){for(let r=s;r<this.text.length;r++)if(this.text[r]?.match(/[a-z]/i))e?n=r+1:e=r;else if(e)break}else e=i+t.length,n=s+t.length;this.#s(e,n),this.textArea.focus()}async#n(t){let i=this.#t,s=this.#e;await this.#c(t,s,i),this.#u(t.value,s,i)}#f(t){if(t){let i=[];this.#h.forEach(e=>{e.type==="block"&&i.push(e.value)});for(let e=0;e<i.length;e++){let n=i[e];if(n&&t.startsWith(n))return n}let s=g(t);if(s)return`${s}. `}return""}#r(){let t=this.text.split(`
|
3
|
-
`),i=0;for(let s=0;s<t.length;s++){let e=t.at(s)?.length??0;if(i++,i+=e,i>this.#t)return{lines:t,lineNumber:s,columnNumber:this.#t-(i-e-1)}}return{lines:t,lineNumber:0,columnNumber:0}}#a(t,i=!1){let{lines:s}=this.#r();for(let e=t+1;e<s.length;e++){let n=s[e];if(n){let r=g(n);if(r){let h;if(i)if(r>1)h=r-1;else break;else h=r+1;s[e]=n.slice(String(r).length),s[e]=String(h)+s[e]}else break}}this.text=s.join(`
|
4
|
-
`)}mount(){this.textArea.addEventListener("keydown",async t=>{let i=["ArrowUp","ArrowDown","Delete"],s=this.text[this.#t]??"";if(i.includes(t.key))this.#i=[];else if(t.key==="Backspace"){let e=this.text[this.#e-1];if(e&&e in this.keyPairs&&s===this.keyPairs[e]){t.preventDefault();let n=this.#e-1,r=this.#t-1;this.text=c(this.text,n),this.text=c(this.text,r),setTimeout(()=>{this.#s(n,r)},0),this.#i.pop()}if(e===`
|
5
|
-
`&&this.#e===this.#t){t.preventDefault();let n=this.#e-1,{lineNumber:r}=this.#r();this.#a(r,!0),this.text=c(this.text,n),setTimeout(async()=>{this.#s(n,n)},0)}}else if(t.key==="Tab")this.#o%2!==0&&(t.preventDefault(),await this.#n({type:"inline",value:" "}));else if(t.key==="Enter"){let{lines:e,lineNumber:n,columnNumber:r}=this.#r(),h=e.at(n),a=this.#f(h),o=a,u=g(a);if(u&&(a=`${u+1}. `),a&&o.length<r)t.preventDefault(),u&&this.#a(n),await this.#n({type:"inline",value:`
|
6
|
-
${a}`});else if(a&&o.length===r){t.preventDefault();let m=this.#t-o.length;for(let f=0;f<o.length;f++)this.text=c(this.text,this.#t-(f+1));setTimeout(async()=>{this.#s(m,m),this.textArea.focus(),await this.#n({type:"inline",value:`
|
7
|
-
`})},0)}}else{let e=Object.values(this.keyPairs).includes(s),n=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:h,columnNumber:a}=this.#r();if(await navigator.clipboard.writeText(`${h===0&&t.key==="x"?"":`
|
8
|
-
`}${r[h]}`),t.key==="x"){let o=this.#e-a;r.splice(h,1),this.text=r.join(`
|
9
|
-
`),setTimeout(()=>{this.#s(o,o)},0)}}if((t.ctrlKey||t.metaKey)&&t.key){let r=this.#h.find(h=>h.key===t.key);r&&this.#n(r)}else e&&(s===t.key||t.key==="ArrowRight")&&this.#i.length&&!n?(t.preventDefault(),this.#s(this.#e+1,this.#t+1),this.#i.pop()):t.key in this.keyPairs&&(t.preventDefault(),await this.#n({type:"wrap",value:t.key}),this.#i.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.#i=[]);for(let t of this.getTrigger())t.addEventListener(this.event,()=>{this.#n(this.#l(t))})}},g=l=>{let t=l.match(/^(\d+)\./);return t?Number(t[1]):null},x=(l,t,i)=>l.slice(0,i)+t+l.slice(i),c=(l,t)=>l.slice(0,t)+l.slice(t+1);export{p as a};
|