drab 5.0.1 → 5.0.2

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 (84) hide show
  1. package/animate/define.d.ts +1 -2
  2. package/animate/define.js +2 -1
  3. package/animate/index.d.ts +4 -6
  4. package/animate/index.js +138 -1
  5. package/{index-0rvQCq2U.d.ts → base/copy/index.d.ts} +2 -5
  6. package/base/copy/index.js +25 -0
  7. package/base/define.d.ts +1 -2
  8. package/base/define.js +2 -1
  9. package/base/index.d.ts +1 -3
  10. package/base/index.js +108 -1
  11. package/breakpoint/define.d.ts +1 -2
  12. package/breakpoint/define.js +2 -1
  13. package/breakpoint/index.d.ts +5 -7
  14. package/breakpoint/index.js +55 -1
  15. package/contextmenu/define.d.ts +1 -2
  16. package/contextmenu/define.js +2 -1
  17. package/contextmenu/index.d.ts +4 -8
  18. package/contextmenu/index.js +71 -1
  19. package/copy/define.d.ts +1 -2
  20. package/copy/define.iife.js +1 -1
  21. package/copy/define.js +2 -1
  22. package/copy/index.d.ts +4 -8
  23. package/copy/index.js +13 -1
  24. package/define/index.iife.js +1 -1
  25. package/define.d.ts +1 -0
  26. package/define.js +4 -0
  27. package/details/define.d.ts +1 -2
  28. package/details/define.iife.js +1 -1
  29. package/details/define.js +2 -1
  30. package/details/index.d.ts +4 -8
  31. package/details/index.js +46 -1
  32. package/dialog/define.d.ts +1 -2
  33. package/dialog/define.js +2 -1
  34. package/dialog/index.d.ts +4 -8
  35. package/dialog/index.js +44 -1
  36. package/editor/define.d.ts +1 -2
  37. package/editor/define.js +2 -1
  38. package/editor/index.d.ts +5 -8
  39. package/editor/index.js +480 -1
  40. package/fullscreen/define.d.ts +1 -2
  41. package/fullscreen/define.iife.js +1 -1
  42. package/fullscreen/define.js +2 -1
  43. package/fullscreen/index.d.ts +4 -7
  44. package/fullscreen/index.iife.js +1 -1
  45. package/fullscreen/index.js +45 -1
  46. package/index.d.ts +14 -15
  47. package/index.iife.js +1 -1
  48. package/index.js +14 -1
  49. package/package.json +5 -4
  50. package/popover/define.d.ts +1 -2
  51. package/popover/define.js +2 -1
  52. package/popover/index.d.ts +4 -8
  53. package/popover/index.js +74 -1
  54. package/share/define.d.ts +1 -2
  55. package/share/define.js +2 -1
  56. package/share/index.d.ts +4 -8
  57. package/share/index.js +34 -1
  58. package/tablesort/define.d.ts +1 -2
  59. package/tablesort/define.js +2 -1
  60. package/tablesort/index.d.ts +4 -7
  61. package/tablesort/index.js +109 -1
  62. package/types/index.d.ts +11 -0
  63. package/types/index.js +1 -0
  64. package/youtube/define.d.ts +1 -2
  65. package/youtube/define.js +2 -1
  66. package/youtube/index.d.ts +4 -7
  67. package/youtube/index.js +56 -1
  68. package/chunk-3ASUSP4D.js +0 -1
  69. package/chunk-4WBITBA6.js +0 -1
  70. package/chunk-5JV4T7GM.js +0 -1
  71. package/chunk-7F7CQUEG.js +0 -1
  72. package/chunk-AWUCZCAJ.js +0 -1
  73. package/chunk-BCS5E3IH.js +0 -1
  74. package/chunk-DKKPV7QP.js +0 -1
  75. package/chunk-F5BEEHGA.js +0 -1
  76. package/chunk-GPET75FT.js +0 -9
  77. package/chunk-H4RNP4O4.js +0 -1
  78. package/chunk-LHXOPRVC.js +0 -1
  79. package/chunk-MXKU7AKV.js +0 -1
  80. package/chunk-VEVFQB5N.js +0 -1
  81. package/chunk-XAP2U34A.js +0 -1
  82. package/define/index.d.ts +0 -2
  83. package/define/index.js +0 -1
  84. package/index-J5TqSvEl.d.ts +0 -12
@@ -1 +1 @@
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);})();
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 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);})();
package/details/define.js CHANGED
@@ -1 +1,2 @@
1
- import{a as e}from"../chunk-LHXOPRVC.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-details",e);
1
+ import { Details } from "./index.js";
2
+ customElements.define("drab-details", Details);
@@ -1,8 +1,6 @@
1
- import { AnimateAttributes, Animate } from '../animate/index.js';
2
- import { A as Attributes } from '../index-J5TqSvEl.js';
3
- import '../base/index.js';
4
-
5
- type DetailsAttributes = Attributes<Details> & AnimateAttributes;
1
+ import { Animate, type AnimateAttributes } from "../animate/index.js";
2
+ import type { Attributes } from "../types/index.js";
3
+ export type DetailsAttributes = Attributes<Details> & AnimateAttributes;
6
4
  /**
7
5
  * This element provides a progressive enhancement on top of the `HTMLDetailsElement` to
8
6
  * animate it with the Web Animations API.
@@ -12,7 +10,7 @@ type DetailsAttributes = Attributes<Details> & AnimateAttributes;
12
10
  * this animation. If you know the exact height of the content, you could animate `height`
13
11
  * instead.
14
12
  */
15
- declare class Details extends Animate {
13
+ export declare class Details extends Animate {
16
14
  constructor();
17
15
  get details(): HTMLDetailsElement;
18
16
  open(): Promise<void>;
@@ -21,5 +19,3 @@ declare class Details extends Animate {
21
19
  toggle(): void;
22
20
  mount(): void;
23
21
  }
24
-
25
- export { Details, type DetailsAttributes };
package/details/index.js CHANGED
@@ -1 +1,46 @@
1
- import{a}from"../chunk-LHXOPRVC.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as Details};
1
+ import { Animate } from "../animate/index.js";
2
+ /**
3
+ * This element provides a progressive enhancement on top of the `HTMLDetailsElement` to
4
+ * animate it with the Web Animations API.
5
+ *
6
+ * The best way I've found to animate the details element is using CSS grid from this
7
+ * [Kevin Powell video](https://youtu.be/B_n4YONte5A?t=116). The example demonstrates
8
+ * this animation. If you know the exact height of the content, you could animate `height`
9
+ * instead.
10
+ */
11
+ export class Details extends Animate {
12
+ constructor() {
13
+ super();
14
+ }
15
+ get details() {
16
+ const details = this.getContent(HTMLElement).parentElement;
17
+ if (!(details instanceof HTMLDetailsElement))
18
+ throw new Error("Details: HTMLDetailsElement not found.");
19
+ return details;
20
+ }
21
+ async open() {
22
+ this.details.open = true;
23
+ await this.animateElement();
24
+ }
25
+ /** Closes details with animation. */
26
+ async close() {
27
+ await this.animateElement({
28
+ options: { direction: "reverse" },
29
+ });
30
+ this.details.open = false;
31
+ }
32
+ toggle() {
33
+ if (this.details.open) {
34
+ this.close();
35
+ }
36
+ else {
37
+ this.open();
38
+ }
39
+ }
40
+ mount() {
41
+ this.triggerListener((e) => {
42
+ e.preventDefault();
43
+ this.toggle();
44
+ });
45
+ }
46
+ }
@@ -1,2 +1 @@
1
-
2
- export { }
1
+ export {};
package/dialog/define.js CHANGED
@@ -1 +1,2 @@
1
- import{a as o}from"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-dialog",o);
1
+ import { Dialog } from "./index.js";
2
+ customElements.define("drab-dialog", Dialog);
package/dialog/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
- import { AnimateAttributes, Animate } from '../animate/index.js';
2
- import { A as Attributes } from '../index-J5TqSvEl.js';
3
- import '../base/index.js';
4
-
5
- type DialogAttributes = Attributes<Dialog> & AnimateAttributes;
1
+ import { Animate, type AnimateAttributes } from "../animate/index.js";
2
+ import type { Attributes } from "../types/index.js";
3
+ export type DialogAttributes = Attributes<Dialog> & AnimateAttributes;
6
4
  /**
7
5
  * Provides triggers and animations for the `HTMLDialogElement`.
8
6
  */
9
- declare class Dialog extends Animate {
7
+ export declare class Dialog extends Animate {
10
8
  constructor();
11
9
  /** The `HTMLDialogElement` within the element. */
12
10
  get dialog(): HTMLDialogElement;
@@ -18,5 +16,3 @@ declare class Dialog extends Animate {
18
16
  toggle(): Promise<void>;
19
17
  mount(): void;
20
18
  }
21
-
22
- export { Dialog, type DialogAttributes };
package/dialog/index.js CHANGED
@@ -1 +1,44 @@
1
- import{a}from"../chunk-H4RNP4O4.js";import"../chunk-F5BEEHGA.js";import"../chunk-MXKU7AKV.js";export{a as Dialog};
1
+ import { Animate } from "../animate/index.js";
2
+ /**
3
+ * Provides triggers and animations for the `HTMLDialogElement`.
4
+ */
5
+ export class Dialog extends Animate {
6
+ constructor() {
7
+ super();
8
+ }
9
+ /** The `HTMLDialogElement` within the element. */
10
+ get dialog() {
11
+ return this.getContent(HTMLDialogElement);
12
+ }
13
+ /** `HTMLDialogElement.showModal()` with animation. */
14
+ async show() {
15
+ this.dialog.showModal();
16
+ await this.animateElement();
17
+ }
18
+ /** `HTMLDialogElement.close()` with animation. */
19
+ async close() {
20
+ await this.animateElement({
21
+ options: {
22
+ direction: "reverse",
23
+ },
24
+ });
25
+ this.dialog.close();
26
+ }
27
+ /** `show` or `close` depending on the dialog's `open` attribute. */
28
+ async toggle() {
29
+ if (this.dialog.open)
30
+ this.close();
31
+ else
32
+ this.show();
33
+ }
34
+ mount() {
35
+ this.triggerListener(() => this.toggle());
36
+ this.safeListener("keydown", (e) => {
37
+ if (e.key === "Escape" && this.dialog.open) {
38
+ // to execute animation
39
+ e.preventDefault();
40
+ this.close();
41
+ }
42
+ });
43
+ }
44
+ }
@@ -1,2 +1 @@
1
-
2
- export { }
1
+ export {};
package/editor/define.js CHANGED
@@ -1 +1,2 @@
1
- import{a as e}from"../chunk-GPET75FT.js";import"../chunk-MXKU7AKV.js";customElements.define("drab-editor",e);
1
+ import { Editor } from "./index.js";
2
+ customElements.define("drab-editor", Editor);
package/editor/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- import { Base } from '../base/index.js';
2
- import { A as Attributes } from '../index-J5TqSvEl.js';
3
-
4
- type EditorAttributes = Attributes<Editor>;
1
+ import { Base } from "../base/index.js";
2
+ import type { Attributes } from "../types/index.js";
3
+ export type EditorAttributes = Attributes<Editor>;
5
4
  /**
6
5
  * A piece of content to insert into the `textarea`.
7
6
  */
8
- type ContentElement = {
7
+ export type ContentElement = {
9
8
  /** How to insert the content. */
10
9
  type: "block" | "inline" | "wrap";
11
10
  /** The value to insert. */
@@ -42,7 +41,7 @@ type ContentElement = {
42
41
  * - `tab` key will indent and not change focus if the selection is within a code block (three backticks).
43
42
  * - When text is highlighted and a `wrap` character `keyPair` is typed, the highlighted text will be wrapped with the character instead of removing it. For example, if a word is highlighted and the `"` character is typed, the work will be surrounded by `"`s.
44
43
  */
45
- declare class Editor extends Base {
44
+ export declare class Editor extends Base {
46
45
  #private;
47
46
  /** The characters that will be automatically closed when typed. */
48
47
  keyPairs: {
@@ -56,5 +55,3 @@ declare class Editor extends Base {
56
55
  set text(value: string);
57
56
  mount(): void;
58
57
  }
59
-
60
- export { type ContentElement, Editor, type EditorAttributes };