drab 5.0.1 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/animate/define.d.ts +1 -2
- package/animate/define.iife.js +1 -1
- package/animate/define.js +2 -1
- package/animate/index.d.ts +4 -6
- package/animate/index.iife.js +1 -1
- package/animate/index.js +138 -1
- package/{index-0rvQCq2U.d.ts → base/copy/index.d.ts} +2 -5
- package/base/copy/index.js +25 -0
- package/base/define.d.ts +1 -2
- package/base/define.iife.js +1 -1
- package/base/define.js +2 -1
- package/base/index.d.ts +8 -6
- package/base/index.iife.js +1 -1
- package/base/index.js +131 -1
- package/breakpoint/define.d.ts +1 -2
- package/breakpoint/define.iife.js +1 -1
- package/breakpoint/define.js +2 -1
- package/breakpoint/index.d.ts +5 -7
- package/breakpoint/index.iife.js +1 -1
- package/breakpoint/index.js +55 -1
- package/contextmenu/define.d.ts +1 -2
- package/contextmenu/define.iife.js +1 -1
- package/contextmenu/define.js +2 -1
- package/contextmenu/index.d.ts +4 -8
- package/contextmenu/index.iife.js +1 -1
- package/contextmenu/index.js +71 -1
- package/copy/define.d.ts +1 -2
- package/copy/define.iife.js +1 -1
- package/copy/define.js +2 -1
- package/copy/index.d.ts +4 -8
- package/copy/index.iife.js +1 -1
- package/copy/index.js +13 -1
- package/define/index.iife.js +9 -9
- package/define.d.ts +1 -0
- package/define.js +4 -0
- package/details/define.d.ts +1 -2
- package/details/define.iife.js +1 -1
- package/details/define.js +2 -1
- package/details/index.d.ts +4 -8
- package/details/index.iife.js +1 -1
- package/details/index.js +46 -1
- package/dialog/define.d.ts +1 -2
- package/dialog/define.iife.js +1 -1
- package/dialog/define.js +2 -1
- package/dialog/index.d.ts +4 -8
- package/dialog/index.iife.js +1 -1
- package/dialog/index.js +44 -1
- package/editor/define.d.ts +1 -2
- package/editor/define.iife.js +4 -4
- package/editor/define.js +2 -1
- package/editor/index.d.ts +5 -8
- package/editor/index.iife.js +4 -4
- package/editor/index.js +480 -1
- package/fullscreen/define.d.ts +1 -2
- package/fullscreen/define.iife.js +1 -1
- package/fullscreen/define.js +2 -1
- package/fullscreen/index.d.ts +4 -7
- package/fullscreen/index.iife.js +1 -1
- package/fullscreen/index.js +46 -1
- package/index.d.ts +15 -15
- package/index.iife.js +9 -9
- package/index.js +15 -1
- package/package.json +14 -4
- package/popover/define.d.ts +1 -2
- package/popover/define.iife.js +1 -1
- package/popover/define.js +2 -1
- package/popover/index.d.ts +4 -8
- package/popover/index.iife.js +1 -1
- package/popover/index.js +74 -1
- package/share/define.d.ts +1 -2
- package/share/define.iife.js +1 -1
- package/share/define.js +2 -1
- package/share/index.d.ts +4 -8
- package/share/index.iife.js +1 -1
- package/share/index.js +34 -1
- package/tablesort/define.d.ts +1 -2
- package/tablesort/define.iife.js +1 -1
- package/tablesort/define.js +2 -1
- package/tablesort/index.d.ts +4 -7
- package/tablesort/index.iife.js +1 -1
- package/tablesort/index.js +109 -1
- package/types/index.d.ts +11 -0
- package/types/index.js +1 -0
- package/wakelock/define.d.ts +1 -0
- package/wakelock/define.iife.js +1 -0
- package/wakelock/define.js +2 -0
- package/wakelock/index.d.ts +32 -0
- package/wakelock/index.iife.js +1 -0
- package/wakelock/index.js +88 -0
- package/youtube/define.d.ts +1 -2
- package/youtube/define.iife.js +1 -1
- package/youtube/define.js +2 -1
- package/youtube/index.d.ts +4 -7
- package/youtube/index.iife.js +1 -1
- package/youtube/index.js +56 -1
- package/chunk-3ASUSP4D.js +0 -1
- package/chunk-4WBITBA6.js +0 -1
- package/chunk-5JV4T7GM.js +0 -1
- package/chunk-7F7CQUEG.js +0 -1
- package/chunk-AWUCZCAJ.js +0 -1
- package/chunk-BCS5E3IH.js +0 -1
- package/chunk-DKKPV7QP.js +0 -1
- package/chunk-F5BEEHGA.js +0 -1
- package/chunk-GPET75FT.js +0 -9
- package/chunk-H4RNP4O4.js +0 -1
- package/chunk-LHXOPRVC.js +0 -1
- package/chunk-MXKU7AKV.js +0 -1
- package/chunk-VEVFQB5N.js +0 -1
- package/chunk-XAP2U34A.js +0 -1
- package/define/index.d.ts +0 -2
- package/define/index.js +0 -1
- package/index-J5TqSvEl.d.ts +0 -12
@@ -0,0 +1,32 @@
|
|
1
|
+
import { Base } from "../base/index.js";
|
2
|
+
import type { Attributes } from "../types/index.js";
|
3
|
+
export type WakeLockAttributes = Attributes<WakeLock> & Partial<{
|
4
|
+
"auto-lock": boolean;
|
5
|
+
locked: boolean;
|
6
|
+
}>;
|
7
|
+
/**
|
8
|
+
* `WakeLock` uses the [WakeLock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) to ensure the screen does not turn off when viewing the page on supported devices. Use your best judgement for when this is necessary, for example, if you have a timer that needs to stay on, or you are displaying a QR code.
|
9
|
+
*
|
10
|
+
* - WakeLock can be toggled with a `trigger`, or will be requested if the element has a `locked` attribute when connected.
|
11
|
+
* - Use `content` and `swap` elements to adjust the UI based on the current state.
|
12
|
+
* - `request` and `release` methods are provided to set the WakeLock with JavaScript.
|
13
|
+
* - `trigger` is disabled if not supported.
|
14
|
+
* - WakeLock is released when the element is removed from the DOM.
|
15
|
+
*
|
16
|
+
* `auto-lock`
|
17
|
+
*
|
18
|
+
* - By default, the WakeLock will be released when the tab is not active. Use the `auto-lock` attribute to automatically request the WakeLock when the user views the tab again.
|
19
|
+
*
|
20
|
+
*
|
21
|
+
*/
|
22
|
+
export declare class WakeLock extends Base {
|
23
|
+
#private;
|
24
|
+
wakeLock: WakeLockSentinel | null;
|
25
|
+
constructor();
|
26
|
+
/** Requests WakeLock on the current page. */
|
27
|
+
request(): Promise<void>;
|
28
|
+
/** Releases the WakeLock, sets `this.wakeLock` to null. */
|
29
|
+
release(): Promise<void>;
|
30
|
+
mount(): void;
|
31
|
+
destroy(): void;
|
32
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";(()=>{var i=class extends HTMLElement{#e=new AbortController;constructor(){super()}get event(){return this.getAttribute("event")??"click"}set event(e){this.setAttribute("event",e)}getTrigger(){return this.querySelectorAll(this.getAttribute("trigger")??"[data-trigger]")}getContent(e=HTMLElement){let n=this.querySelector(this.getAttribute("content")??"[data-content]");if(n instanceof e)return n;throw new Error("Content not found")}swapContent(e=!0,n=800){let t=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(t){let s=Array.from(this.getContent().childNodes),r=[];t instanceof HTMLTemplateElement?(r.push(t.content.cloneNode(!0)),t.content.replaceChildren(...s)):(r.push(...t.childNodes),t.replaceChildren(...s)),this.getContent().replaceChildren(...r),e&&setTimeout(()=>this.swapContent(!1),n)}}safeListener(e,n,t=document.body,s={}){s.signal=this.#e.signal,t.addEventListener(e,n,s)}triggerListener(e,n=this.event){for(let t of this.getTrigger())t.addEventListener(n,e)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#e.abort()}};var o=class extends i{wakeLock=null;constructor(){super()}#e(){return"wakeLock"in navigator}get#t(){return this.hasAttribute("auto-lock")}async request(){this.#e()&&document.visibilityState==="visible"&&(this.wakeLock=await navigator.wakeLock.request("screen"),this.setAttribute("locked",""),this.swapContent(!1),this.wakeLock.addEventListener("release",()=>{this.removeAttribute("locked"),this.swapContent(!1),this.#t||(this.wakeLock=null)}))}async release(){await this.wakeLock?.release(),this.wakeLock=null}mount(){this.hasAttribute("locked")&&this.request(),this.triggerListener(()=>{this.wakeLock?this.release():this.request()});for(let e of this.getTrigger())!this.#e()&&"disabled"in e&&(e.disabled=!0);this.#t&&this.safeListener("visibilitychange",()=>{this.wakeLock&&this.request()},document)}destroy(){this.release()}};})();
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { Base } from "../base/index.js";
|
2
|
+
/**
|
3
|
+
* `WakeLock` uses the [WakeLock API](https://developer.mozilla.org/en-US/docs/Web/API/Screen_Wake_Lock_API) to ensure the screen does not turn off when viewing the page on supported devices. Use your best judgement for when this is necessary, for example, if you have a timer that needs to stay on, or you are displaying a QR code.
|
4
|
+
*
|
5
|
+
* - WakeLock can be toggled with a `trigger`, or will be requested if the element has a `locked` attribute when connected.
|
6
|
+
* - Use `content` and `swap` elements to adjust the UI based on the current state.
|
7
|
+
* - `request` and `release` methods are provided to set the WakeLock with JavaScript.
|
8
|
+
* - `trigger` is disabled if not supported.
|
9
|
+
* - WakeLock is released when the element is removed from the DOM.
|
10
|
+
*
|
11
|
+
* `auto-lock`
|
12
|
+
*
|
13
|
+
* - By default, the WakeLock will be released when the tab is not active. Use the `auto-lock` attribute to automatically request the WakeLock when the user views the tab again.
|
14
|
+
*
|
15
|
+
*
|
16
|
+
*/
|
17
|
+
export class WakeLock extends Base {
|
18
|
+
wakeLock = null;
|
19
|
+
constructor() {
|
20
|
+
super();
|
21
|
+
}
|
22
|
+
/** If the WakeLock API is supported on the user's device. */
|
23
|
+
#wakeLockSupported() {
|
24
|
+
return "wakeLock" in navigator;
|
25
|
+
}
|
26
|
+
/**
|
27
|
+
* the `auto-lock` attribute controls whether an active WakeLock should be restored when navigating back to the page.
|
28
|
+
*/
|
29
|
+
get #autoLock() {
|
30
|
+
return this.hasAttribute("auto-lock");
|
31
|
+
}
|
32
|
+
/** Requests WakeLock on the current page. */
|
33
|
+
async request() {
|
34
|
+
if (this.#wakeLockSupported() && document.visibilityState === "visible") {
|
35
|
+
this.wakeLock = await navigator.wakeLock.request("screen");
|
36
|
+
this.setAttribute("locked", "");
|
37
|
+
this.swapContent(false);
|
38
|
+
this.wakeLock.addEventListener("release", () => {
|
39
|
+
this.removeAttribute("locked");
|
40
|
+
this.swapContent(false);
|
41
|
+
if (!this.#autoLock) {
|
42
|
+
// set to null is required, used to determine if screen should be
|
43
|
+
// locked again, see visibilitychange listener
|
44
|
+
this.wakeLock = null;
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}
|
48
|
+
}
|
49
|
+
/** Releases the WakeLock, sets `this.wakeLock` to null. */
|
50
|
+
async release() {
|
51
|
+
await this.wakeLock?.release();
|
52
|
+
this.wakeLock = null;
|
53
|
+
}
|
54
|
+
mount() {
|
55
|
+
// lock on mount if the `locked` attribute is present
|
56
|
+
if (this.hasAttribute("locked")) {
|
57
|
+
this.request();
|
58
|
+
}
|
59
|
+
this.triggerListener(() => {
|
60
|
+
// toggle
|
61
|
+
if (this.wakeLock) {
|
62
|
+
this.release();
|
63
|
+
}
|
64
|
+
else {
|
65
|
+
this.request();
|
66
|
+
}
|
67
|
+
});
|
68
|
+
for (const trigger of this.getTrigger()) {
|
69
|
+
if (!this.#wakeLockSupported() && "disabled" in trigger) {
|
70
|
+
// disable `trigger` if not supported
|
71
|
+
trigger.disabled = true;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
if (this.#autoLock) {
|
75
|
+
this.safeListener("visibilitychange", () => {
|
76
|
+
// When the tab is not visible, the wakeLock is automatically released.
|
77
|
+
// This requests it back if it exists, if it is `null`, that
|
78
|
+
// means it was removed. In which case, it shouldn't be requested again.
|
79
|
+
if (this.wakeLock) {
|
80
|
+
this.request();
|
81
|
+
}
|
82
|
+
}, document);
|
83
|
+
}
|
84
|
+
}
|
85
|
+
destroy() {
|
86
|
+
this.release();
|
87
|
+
}
|
88
|
+
}
|
package/youtube/define.d.ts
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
export { }
|
1
|
+
export {};
|
package/youtube/define.iife.js
CHANGED
@@ -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
|
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 r=this.querySelector(this.getAttribute("content")??"[data-content]");if(r instanceof t)return r;throw new Error("Content not found")}swapContent(t=!0,r=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let n=Array.from(this.getContent().childNodes),o=[];e instanceof HTMLTemplateElement?(o.push(e.content.cloneNode(!0)),e.content.replaceChildren(...n)):(o.push(...e.childNodes),e.replaceChildren(...n)),this.getContent().replaceChildren(...o),t&&setTimeout(()=>this.swapContent(!1),r)}}safeListener(t,r,e=document.body,n={}){n.signal=this.#t.signal,e.addEventListener(t,r,n)}triggerListener(t,r=this.event){for(let e of this.getTrigger())e.addEventListener(r,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),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":""}`})}};customElements.define("drab-youtube",i);})();
|
package/youtube/define.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
import{
|
1
|
+
import { YouTube } from "./index.js";
|
2
|
+
customElements.define("drab-youtube", YouTube);
|
package/youtube/index.d.ts
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
import { Base } from
|
2
|
-
import {
|
3
|
-
|
4
|
-
type YouTubeAttributes = Attributes<YouTube, "uid">;
|
1
|
+
import { Base } from "../base/index.js";
|
2
|
+
import type { Attributes } from "../types/index.js";
|
3
|
+
export type YouTubeAttributes = Attributes<YouTube, "uid">;
|
5
4
|
/**
|
6
5
|
* Embeds a YouTube video iframe into a website with the video uid, using www.youtube-nocookie.com.
|
7
6
|
*/
|
8
|
-
declare class YouTube extends Base {
|
7
|
+
export declare class YouTube extends Base {
|
9
8
|
static observedAttributes: readonly ["autoplay", "start", "uid"];
|
10
9
|
constructor();
|
11
10
|
/** The `HTMLIFrameElement` within the element. */
|
@@ -27,5 +26,3 @@ declare class YouTube extends Base {
|
|
27
26
|
mount(): void;
|
28
27
|
attributeChangedCallback(): void;
|
29
28
|
}
|
30
|
-
|
31
|
-
export { YouTube, type YouTubeAttributes };
|
package/youtube/index.iife.js
CHANGED
@@ -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
|
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 r=this.querySelector(this.getAttribute("content")??"[data-content]");if(r instanceof t)return r;throw new Error("Content not found")}swapContent(t=!0,r=800){let e=this.querySelector(this.getAttribute("swap")??"[data-swap]");if(e){let n=Array.from(this.getContent().childNodes),i=[];e instanceof HTMLTemplateElement?(i.push(e.content.cloneNode(!0)),e.content.replaceChildren(...n)):(i.push(...e.childNodes),e.replaceChildren(...n)),this.getContent().replaceChildren(...i),t&&setTimeout(()=>this.swapContent(!1),r)}}safeListener(t,r,e=document.body,n={}){n.signal=this.#t.signal,e.addEventListener(t,r,n)}triggerListener(t,r=this.event){for(let e of this.getTrigger())e.addEventListener(r,t)}mount(){}connectedCallback(){queueMicrotask(()=>this.mount())}destroy(){}disconnectedCallback(){this.destroy(),this.#t.abort()}};var o=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/youtube/index.js
CHANGED
@@ -1 +1,56 @@
|
|
1
|
-
import{
|
1
|
+
import { Base } from "../base/index.js";
|
2
|
+
/**
|
3
|
+
* Embeds a YouTube video iframe into a website with the video uid, using www.youtube-nocookie.com.
|
4
|
+
*/
|
5
|
+
export class YouTube extends Base {
|
6
|
+
static observedAttributes = ["autoplay", "start", "uid"];
|
7
|
+
constructor() {
|
8
|
+
super();
|
9
|
+
}
|
10
|
+
/** The `HTMLIFrameElement` within the element. */
|
11
|
+
get iframe() {
|
12
|
+
return this.getContent(HTMLIFrameElement);
|
13
|
+
}
|
14
|
+
/** Whether the video should start playing when loaded. */
|
15
|
+
get autoplay() {
|
16
|
+
return this.hasAttribute("autoplay");
|
17
|
+
}
|
18
|
+
set autoplay(value) {
|
19
|
+
if (value)
|
20
|
+
this.setAttribute("autoplay", "");
|
21
|
+
else
|
22
|
+
this.removeAttribute("autoplay");
|
23
|
+
}
|
24
|
+
/** The start time of the video (seconds). */
|
25
|
+
get start() {
|
26
|
+
return this.getAttribute("start") ?? "0";
|
27
|
+
}
|
28
|
+
set start(value) {
|
29
|
+
this.setAttribute("start", value);
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* The video's YouTube uid, found within the url of the video.
|
33
|
+
*
|
34
|
+
* For example if the video url is https://youtu.be/gouiY85kD2o,
|
35
|
+
* the `uid` is `"gouiY85kD2o"`.
|
36
|
+
*/
|
37
|
+
get uid() {
|
38
|
+
const uid = this.getAttribute("uid");
|
39
|
+
if (!uid)
|
40
|
+
throw new Error("YouTube: missing `uid` attribute.");
|
41
|
+
return uid;
|
42
|
+
}
|
43
|
+
set uid(v) {
|
44
|
+
this.setAttribute("uid", v);
|
45
|
+
}
|
46
|
+
mount() {
|
47
|
+
this.iframe.allowFullscreen = true;
|
48
|
+
this.iframe.allow =
|
49
|
+
"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture";
|
50
|
+
}
|
51
|
+
attributeChangedCallback() {
|
52
|
+
queueMicrotask(() => {
|
53
|
+
this.iframe.src = `https://www.youtube-nocookie.com/embed/${this.uid}?start=${this.start}${this.autoplay ? "&autoplay=1" : ""}`;
|
54
|
+
});
|
55
|
+
}
|
56
|
+
}
|
package/chunk-3ASUSP4D.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-4WBITBA6.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-5JV4T7GM.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{b as t}from"./chunk-MXKU7AKV.js";var r=class extends t{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)}};export{r as a};
|
package/chunk-7F7CQUEG.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{b as e}from"./chunk-MXKU7AKV.js";var r=class extends e{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()}};export{r as a};
|
package/chunk-AWUCZCAJ.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-BCS5E3IH.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-DKKPV7QP.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-F5BEEHGA.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-GPET75FT.js
DELETED
@@ -1,9 +0,0 @@
|
|
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};
|
package/chunk-H4RNP4O4.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-LHXOPRVC.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/chunk-MXKU7AKV.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
var o=Object.defineProperty;var l=(s,e)=>{for(var t in e)o(s,t,{get:e[t],enumerable:!0})};var i=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()}};export{l as a,i as b};
|
package/chunk-VEVFQB5N.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{b as e}from"./chunk-MXKU7AKV.js";var r=class extends e{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":""}`})}};export{r as a};
|
package/chunk-XAP2U34A.js
DELETED
@@ -1 +0,0 @@
|
|
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};
|
package/define/index.d.ts
DELETED
package/define/index.js
DELETED
@@ -1 +0,0 @@
|
|
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]);
|
package/index-J5TqSvEl.d.ts
DELETED
@@ -1,12 +0,0 @@
|
|
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 };
|