monobill-mintui 0.4.2 → 0.4.3
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/dist/Icon-BTuYBm_3.cjs +1 -0
- package/dist/Icon-ByNhn8tE.js +77 -0
- package/dist/button-CAQ8mBQ2.js +575 -0
- package/dist/button-DuNZkwFV.cjs +1 -0
- package/dist/button.cjs +1 -0
- package/dist/button.d.ts +1 -0
- package/dist/button.js +2 -0
- package/dist/card-C1AqNkxK.cjs +1 -0
- package/dist/card-LNjZ86sr.js +58 -0
- package/dist/card.cjs +1 -0
- package/dist/card.d.ts +1 -0
- package/dist/card.js +2 -0
- package/dist/checkbox-Bkgxfl0k.js +169 -0
- package/dist/checkbox-DgwXHIbu.cjs +1 -0
- package/dist/checkbox.cjs +1 -0
- package/dist/checkbox.d.ts +1 -0
- package/dist/checkbox.js +1 -0
- package/dist/choice-BAk8Jd5E.cjs +1 -0
- package/dist/choice-Cs16XiRh.js +204 -0
- package/dist/choice.cjs +1 -0
- package/dist/choice.d.ts +1 -0
- package/dist/choice.js +1 -0
- package/dist/grid-ByGfCtMT.cjs +1 -0
- package/dist/grid-DhnNax_w.js +62 -0
- package/dist/grid.cjs +1 -0
- package/dist/grid.d.ts +1 -0
- package/dist/grid.js +2 -0
- package/dist/icon-D8dpuFVm.js +701 -0
- package/dist/icon-Dut5ZPmM.cjs +1 -0
- package/dist/icon.cjs +1 -0
- package/dist/icon.d.ts +1 -0
- package/dist/icon.js +3 -0
- package/dist/index.cjs +1 -63
- package/dist/index.d.ts +35 -0
- package/dist/index.js +16 -2756
- package/dist/link-B-z-io7I.cjs +1 -0
- package/dist/link-DC8l274I.js +75 -0
- package/dist/link.cjs +1 -0
- package/dist/link.d.ts +1 -0
- package/dist/link.js +2 -0
- package/dist/mintui-elements.d.ts +78 -0
- package/dist/modal-BZYcRU3i.js +98 -0
- package/dist/modal-C_ukm1We.cjs +1 -0
- package/dist/modal.cjs +1 -0
- package/dist/modal.d.ts +1 -0
- package/dist/modal.js +1 -0
- package/dist/page-CJ3M0wAd.cjs +1 -0
- package/dist/page-aBsDfG3x.js +112 -0
- package/dist/page.cjs +1 -0
- package/dist/page.d.ts +1 -0
- package/dist/page.js +2 -0
- package/dist/popover-7bn3gySt.js +181 -0
- package/dist/popover-CuSBQ8Jm.cjs +1 -0
- package/dist/popover.cjs +1 -0
- package/dist/popover.d.ts +1 -0
- package/dist/popover.js +1 -0
- package/dist/spinner-DqXU-cr-.js +111 -0
- package/dist/spinner-GtQIe8rS.cjs +63 -0
- package/dist/spinner.cjs +1 -0
- package/dist/spinner.d.ts +1 -0
- package/dist/spinner.js +2 -0
- package/dist/stack-D0noPfD1.js +114 -0
- package/dist/stack-tFy8YlX2.cjs +1 -0
- package/dist/stack.cjs +1 -0
- package/dist/stack.d.ts +1 -0
- package/dist/stack.js +2 -0
- package/dist/styles.css +1 -0
- package/dist/switch-DQ0Eaz6M.js +138 -0
- package/dist/switch-DeQNPnla.cjs +1 -0
- package/dist/switch.cjs +1 -0
- package/dist/switch.d.ts +1 -0
- package/dist/switch.js +2 -0
- package/dist/text-CoinZsjJ.cjs +1 -0
- package/dist/text-q58TQcH-.js +111 -0
- package/dist/text.cjs +1 -0
- package/dist/text.d.ts +1 -0
- package/dist/text.js +2 -0
- package/package.json +50 -23
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=class extends HTMLElement{static get observedAttributes(){return[`href`,`target`]}constructor(){super(),this._link=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._observeContent()}disconnectedCallback(){this._contentObserver&&=(this._contentObserver.disconnect(),null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll(`mint-text`).forEach(e=>{e.classList.contains(`underline`)||e.classList.add(`underline`)})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHref(){return this.getAttribute(`href`)||`#`}getTarget(){return this.getAttribute(`target`)||``}hasIcon(){return!!this.querySelector(`mint-icon`)||!!this._link?.querySelector(`mint-icon`)}render(){let e=this.getHref(),t=this.getTarget();if(!this._link){for(this._link=document.createElement(`a`);this.firstChild;)this._link.appendChild(this.firstChild);this.appendChild(this._link)}this._link.href=e,t?(this._link.target=t,t===`_blank`&&(this._link.rel=`noopener noreferrer`)):(this._link.removeAttribute(`target`),this._link.removeAttribute(`rel`));let n=this.hasIcon(),r=[`text-slate-800`,`dark:text-slate-200`,`underline`,`hover:text-slate-950`,`dark:hover:text-slate-100`,`transition-colors`,`duration-200`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`rounded`];n&&r.push(`inline-flex`,`items-center`,`gap-2`),this._link.className=r.join(` `),this._link.querySelectorAll(`mint-text`).forEach(e=>{e.classList.contains(`underline`)||e.classList.add(`underline`)}),[`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`].forEach(e=>{this.classList.contains(e)||this.classList.add(e)})}};customElements.get(`mint-link`)||customElements.define(`mint-link`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
//#region src/components/link/Link.js
|
|
2
|
+
var e = class extends HTMLElement {
|
|
3
|
+
static get observedAttributes() {
|
|
4
|
+
return ["href", "target"];
|
|
5
|
+
}
|
|
6
|
+
constructor() {
|
|
7
|
+
super(), this._link = null;
|
|
8
|
+
}
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._observeContent();
|
|
11
|
+
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
this._contentObserver &&= (this._contentObserver.disconnect(), null);
|
|
14
|
+
}
|
|
15
|
+
_observeContent() {
|
|
16
|
+
this._contentObserver || (this._contentObserver = new MutationObserver(() => {
|
|
17
|
+
this._link && this._link.querySelectorAll("mint-text").forEach((e) => {
|
|
18
|
+
e.classList.contains("underline") || e.classList.add("underline");
|
|
19
|
+
});
|
|
20
|
+
}), this._contentObserver.observe(this, {
|
|
21
|
+
childList: !0,
|
|
22
|
+
subtree: !0
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
attributeChangedCallback(e, t, n) {
|
|
26
|
+
t !== n && this.render();
|
|
27
|
+
}
|
|
28
|
+
getHref() {
|
|
29
|
+
return this.getAttribute("href") || "#";
|
|
30
|
+
}
|
|
31
|
+
getTarget() {
|
|
32
|
+
return this.getAttribute("target") || "";
|
|
33
|
+
}
|
|
34
|
+
hasIcon() {
|
|
35
|
+
return !!this.querySelector("mint-icon") || !!this._link?.querySelector("mint-icon");
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
let e = this.getHref(), t = this.getTarget();
|
|
39
|
+
if (!this._link) {
|
|
40
|
+
for (this._link = document.createElement("a"); this.firstChild;) this._link.appendChild(this.firstChild);
|
|
41
|
+
this.appendChild(this._link);
|
|
42
|
+
}
|
|
43
|
+
this._link.href = e, t ? (this._link.target = t, t === "_blank" && (this._link.rel = "noopener noreferrer")) : (this._link.removeAttribute("target"), this._link.removeAttribute("rel"));
|
|
44
|
+
let n = this.hasIcon(), r = [
|
|
45
|
+
"text-slate-800",
|
|
46
|
+
"dark:text-slate-200",
|
|
47
|
+
"underline",
|
|
48
|
+
"hover:text-slate-950",
|
|
49
|
+
"dark:hover:text-slate-100",
|
|
50
|
+
"transition-colors",
|
|
51
|
+
"duration-200",
|
|
52
|
+
"focus-visible:outline-none",
|
|
53
|
+
"focus-visible:ring-2",
|
|
54
|
+
"focus-visible:ring-offset-2",
|
|
55
|
+
"focus-visible:ring-slate-500",
|
|
56
|
+
"dark:focus-visible:ring-slate-400",
|
|
57
|
+
"rounded"
|
|
58
|
+
];
|
|
59
|
+
n && r.push("inline-flex", "items-center", "gap-2"), this._link.className = r.join(" "), this._link.querySelectorAll("mint-text").forEach((e) => {
|
|
60
|
+
e.classList.contains("underline") || e.classList.add("underline");
|
|
61
|
+
}), [
|
|
62
|
+
"box-border",
|
|
63
|
+
"m-0",
|
|
64
|
+
"p-0",
|
|
65
|
+
"border-0",
|
|
66
|
+
"align-baseline",
|
|
67
|
+
"inline-block"
|
|
68
|
+
].forEach((e) => {
|
|
69
|
+
this.classList.contains(e) || this.classList.add(e);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
customElements.get("mint-link") || customElements.define("mint-link", e);
|
|
74
|
+
//#endregion
|
|
75
|
+
export { e as t };
|
package/dist/link.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./link-B-z-io7I.cjs`);module.exports=e.t;
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintLink as default } from './mintui-elements'
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM typings for MintUI custom elements (implementation is plain JS).
|
|
3
|
+
*
|
|
4
|
+
* Observed attributes (use `setAttribute` / HTML): see JSDoc on each class.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** Attributes: variant, tone, disabled, loading, button-type, full-width, icon-position, icon */
|
|
8
|
+
export declare class MintButton extends HTMLElement {}
|
|
9
|
+
|
|
10
|
+
/** Attributes: checked, disabled, label, icon */
|
|
11
|
+
export declare class MintSwitch extends HTMLElement {}
|
|
12
|
+
|
|
13
|
+
/** Attributes: size, data-button-variant, data-button-tone */
|
|
14
|
+
export declare class MintSpinner extends HTMLElement {}
|
|
15
|
+
|
|
16
|
+
/** Attributes: name */
|
|
17
|
+
export declare class MintIcon extends HTMLElement {}
|
|
18
|
+
|
|
19
|
+
/** Attributes: variant, size, bold, underline, strike, italic, display */
|
|
20
|
+
export declare class MintText extends HTMLElement {}
|
|
21
|
+
|
|
22
|
+
/** Attributes: direction, text-align */
|
|
23
|
+
export declare class MintStack extends HTMLElement {}
|
|
24
|
+
|
|
25
|
+
export declare class MintCard extends HTMLElement {}
|
|
26
|
+
|
|
27
|
+
/** Attributes: href, target */
|
|
28
|
+
export declare class MintLink extends HTMLElement {}
|
|
29
|
+
|
|
30
|
+
/** Attributes: heading, fallback-href, show-back-button */
|
|
31
|
+
export declare class MintPage extends HTMLElement {}
|
|
32
|
+
|
|
33
|
+
/** Attributes: columns, sm, md, lg, xl, gap */
|
|
34
|
+
export declare class MintGrid extends HTMLElement {}
|
|
35
|
+
|
|
36
|
+
/** Attributes: id, heading, open */
|
|
37
|
+
export declare class MintModal extends HTMLElement {}
|
|
38
|
+
|
|
39
|
+
/** Attributes: id, direction, open, trigger-id */
|
|
40
|
+
export declare class MintPopover extends HTMLElement {}
|
|
41
|
+
|
|
42
|
+
/** Attributes: checked, disabled, label, info, id, name, value */
|
|
43
|
+
export declare class MintCheckbox extends HTMLElement {}
|
|
44
|
+
|
|
45
|
+
/** Attributes: checked, disabled, label, info, id, name, value */
|
|
46
|
+
export declare class MintChoice extends HTMLElement {}
|
|
47
|
+
|
|
48
|
+
/** Icon module shape used by the registry helpers. */
|
|
49
|
+
export interface MintIconRegistration {
|
|
50
|
+
name: string
|
|
51
|
+
[key: string]: unknown
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export declare function registerIcon(icon: MintIconRegistration): void
|
|
55
|
+
export declare function getIcon(name: string): MintIconRegistration | undefined
|
|
56
|
+
export declare function hasIcon(name: string): boolean
|
|
57
|
+
export declare function getAllIcons(): MintIconRegistration[]
|
|
58
|
+
|
|
59
|
+
declare global {
|
|
60
|
+
interface HTMLElementTagNameMap {
|
|
61
|
+
'mint-button': MintButton
|
|
62
|
+
'mint-switch': MintSwitch
|
|
63
|
+
'mint-spinner': MintSpinner
|
|
64
|
+
'mint-icon': MintIcon
|
|
65
|
+
'mint-text': MintText
|
|
66
|
+
'mint-stack': MintStack
|
|
67
|
+
'mint-card': MintCard
|
|
68
|
+
'mint-link': MintLink
|
|
69
|
+
'mint-page': MintPage
|
|
70
|
+
'mint-grid': MintGrid
|
|
71
|
+
'mint-modal': MintModal
|
|
72
|
+
'mint-popover': MintPopover
|
|
73
|
+
'mint-checkbox': MintCheckbox
|
|
74
|
+
'mint-choice': MintChoice
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export {}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import "./icon-D8dpuFVm.js";
|
|
2
|
+
import "./button-CAQ8mBQ2.js";
|
|
3
|
+
import "./text-q58TQcH-.js";
|
|
4
|
+
import "./stack-D0noPfD1.js";
|
|
5
|
+
//#region src/components/modal/Modal.js
|
|
6
|
+
var e = class extends HTMLElement {
|
|
7
|
+
static get observedAttributes() {
|
|
8
|
+
return [
|
|
9
|
+
"id",
|
|
10
|
+
"heading",
|
|
11
|
+
"open"
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
constructor() {
|
|
15
|
+
super(), this._overlay = null, this._modal = null, this._header = null, this._headingSlot = null, this._bodySlot = null, this._actionsSlot = null, this._closeButton = null, this._darkModeObserver = null;
|
|
16
|
+
}
|
|
17
|
+
connectedCallback() {
|
|
18
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "fixed", "inset-0", "z-50"), this.isOpen() || this.classList.add("hidden"), this.render(), this._observeDarkMode();
|
|
19
|
+
}
|
|
20
|
+
disconnectedCallback() {
|
|
21
|
+
this._darkModeObserver &&= (this._darkModeObserver.disconnect(), null);
|
|
22
|
+
}
|
|
23
|
+
attributeChangedCallback(e, t, n) {
|
|
24
|
+
t !== n && this.render();
|
|
25
|
+
}
|
|
26
|
+
getId() {
|
|
27
|
+
return this.getAttribute("id") || "";
|
|
28
|
+
}
|
|
29
|
+
getHeading() {
|
|
30
|
+
return this.getAttribute("heading") || "";
|
|
31
|
+
}
|
|
32
|
+
isOpen() {
|
|
33
|
+
return this.hasAttribute("open");
|
|
34
|
+
}
|
|
35
|
+
open() {
|
|
36
|
+
this.setAttribute("open", "");
|
|
37
|
+
}
|
|
38
|
+
close() {
|
|
39
|
+
this.removeAttribute("open");
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
let e = this.getId(), t = this.getHeading(), n = this.isOpen();
|
|
43
|
+
if (e && (this.id = e), this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40", this._overlay.addEventListener("click", () => this.close()), this.appendChild(this._overlay)), this._modal || (this._modal = document.createElement("div"), this._modal.className = "fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50", this.appendChild(this._modal)), n) {
|
|
44
|
+
let e = this._modal.querySelector(".modal-content");
|
|
45
|
+
e || (e = document.createElement("div"), e.className = "modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform", this._modal.appendChild(e)), this._animateEnter();
|
|
46
|
+
} else this._animateExit();
|
|
47
|
+
let r = this._modal.querySelector(".modal-content");
|
|
48
|
+
r || (r = document.createElement("div"), r.className = "modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform", this._modal.appendChild(r)), this._header || (this._header = document.createElement("div"), this._header.className = "flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700", r.appendChild(this._header)), this._headingSlot || (this._headingSlot = document.createElement("div"), this._headingSlot.className = "flex-1", this._headingSlot.setAttribute("slot", "heading"), this._header.appendChild(this._headingSlot));
|
|
49
|
+
let i = this._headingSlot.querySelector("mint-text");
|
|
50
|
+
t ? (i || (i = document.createElement("mint-text"), i.setAttribute("size", "sub-heading"), i.setAttribute("bold", ""), this._headingSlot.appendChild(i)), i.textContent = t) : i && i.remove(), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._modal && e !== this._headingSlot && e.getAttribute("slot") === "heading").forEach((e) => {
|
|
51
|
+
e.parentElement !== this._headingSlot && this._headingSlot.appendChild(e);
|
|
52
|
+
}), this._closeButton || (this._closeButton = document.createElement("mint-button"), this._closeButton.setAttribute("variant", "ghost"), this._closeButton.setAttribute("icon", "close"), this._closeButton.addEventListener("click", () => this.close()), this._header.appendChild(this._closeButton)), this._bodySlot || (this._bodySlot = document.createElement("div"), this._bodySlot.className = "flex-1 overflow-y-auto p-4", this._bodySlot.setAttribute("slot", "body"), r.appendChild(this._bodySlot)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._modal && e !== this._bodySlot && e.getAttribute("slot") === "body").forEach((e) => {
|
|
53
|
+
e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
54
|
+
}), this._actionsSlot || (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "p-4 border-t border-gray-200 dark:border-gray-700", this._actionsSlot.setAttribute("slot", "actions"), r.appendChild(this._actionsSlot));
|
|
55
|
+
let a = this._actionsSlot.querySelector("mint-stack");
|
|
56
|
+
a || (a = document.createElement("mint-stack"), a.setAttribute("direction", "horizontal"), a.className = "justify-end", this._actionsSlot.appendChild(a)), Array.from(this.children).filter((e) => e !== this._overlay && e !== this._modal && e !== this._actionsSlot && e.getAttribute("slot") === "actions").forEach((e) => {
|
|
57
|
+
Array.from(e.children).forEach((e) => {
|
|
58
|
+
e.parentElement !== a && a.appendChild(e);
|
|
59
|
+
}), e.parentElement && e.remove();
|
|
60
|
+
}), Array.from(this.children).forEach((e) => {
|
|
61
|
+
e !== this._overlay && e !== this._modal && e.getAttribute("slot") !== "heading" && e.getAttribute("slot") !== "body" && e.getAttribute("slot") !== "actions" && e !== this._headingSlot && e !== this._bodySlot && e !== this._actionsSlot && e.parentElement !== this._bodySlot && this._bodySlot.appendChild(e);
|
|
62
|
+
}), this._updateBackgroundColor();
|
|
63
|
+
}
|
|
64
|
+
_updateBackgroundColor() {
|
|
65
|
+
if (!this._modal) return;
|
|
66
|
+
let e = document.documentElement.classList.contains("dark"), t = this._modal.querySelector(".modal-content");
|
|
67
|
+
t && (e ? (t.classList.remove("bg-white"), t.classList.add("bg-gray-800")) : (t.classList.remove("bg-gray-800"), t.classList.add("bg-white")));
|
|
68
|
+
}
|
|
69
|
+
_observeDarkMode() {
|
|
70
|
+
this._darkModeObserver || (this._darkModeObserver = new MutationObserver(() => {
|
|
71
|
+
this._updateBackgroundColor();
|
|
72
|
+
}), this._darkModeObserver.observe(document.documentElement, {
|
|
73
|
+
attributes: !0,
|
|
74
|
+
attributeFilter: ["class"]
|
|
75
|
+
}));
|
|
76
|
+
}
|
|
77
|
+
_animateEnter() {
|
|
78
|
+
let e = this._modal?.querySelector(".modal-content");
|
|
79
|
+
e && (e.style.transform = "scale(0.97) translateY(10px)", e.style.opacity = "0", e.style.transition = "all 200ms ease-out", this.classList.remove("hidden"), requestAnimationFrame(() => {
|
|
80
|
+
requestAnimationFrame(() => {
|
|
81
|
+
e.style.transform = "scale(1) translateY(0)", e.style.opacity = "1";
|
|
82
|
+
});
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
_animateExit() {
|
|
86
|
+
let e = this._modal?.querySelector(".modal-content");
|
|
87
|
+
if (!e) {
|
|
88
|
+
this.classList.add("hidden");
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
e.style.transition = "all 200ms ease-in", e.style.transform = "scale(0.97) translateY(10px)", e.style.opacity = "0", setTimeout(() => {
|
|
92
|
+
this.classList.add("hidden"), e.style.transform = "", e.style.opacity = "", e.style.transition = "";
|
|
93
|
+
}, 200);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
customElements.get("mint-modal") || customElements.define("mint-modal", e);
|
|
97
|
+
//#endregion
|
|
98
|
+
export { e as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./icon-Dut5ZPmM.cjs`),require(`./button-DuNZkwFV.cjs`),require(`./text-CoinZsjJ.cjs`),require(`./stack-tFy8YlX2.cjs`);var e=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`]}constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`fixed`,`inset-0`,`z-50`),this.isOpen()||this.classList.add(`hidden`),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}isOpen(){return this.hasAttribute(`open`)}open(){this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement(`div`),this._modal.className=`fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform`,this._modal.appendChild(e)),this._animateEnter()}else this._animateExit();let r=this._modal.querySelector(`.modal-content`);r||(r=document.createElement(`div`),r.className=`modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform`,this._modal.appendChild(r)),this._header||(this._header=document.createElement(`div`),this._header.className=`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,r.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement(`div`),this._headingSlot.className=`flex-1`,this._headingSlot.setAttribute(`slot`,`heading`),this._header.appendChild(this._headingSlot));let i=this._headingSlot.querySelector(`mint-text`);t?(i||(i=document.createElement(`mint-text`),i.setAttribute(`size`,`sub-heading`),i.setAttribute(`bold`,``),this._headingSlot.appendChild(i)),i.textContent=t):i&&i.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),this._closeButton||(this._closeButton=document.createElement(`mint-button`),this._closeButton.setAttribute(`variant`,`ghost`),this._closeButton.setAttribute(`icon`,`close`),this._closeButton.addEventListener(`click`,()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._bodySlot.className=`flex-1 overflow-y-auto p-4`,this._bodySlot.setAttribute(`slot`,`body`),r.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-gray-700`,this._actionsSlot.setAttribute(`slot`,`actions`),r.appendChild(this._actionsSlot));let a=this._actionsSlot.querySelector(`mint-stack`);a||(a=document.createElement(`mint-stack`),a.setAttribute(`direction`,`horizontal`),a.className=`justify-end`,this._actionsSlot.appendChild(a)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==a&&a.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;let e=document.documentElement.classList.contains(`dark`),t=this._modal.querySelector(`.modal-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-gray-800`)):(t.classList.remove(`bg-gray-800`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,e.style.transition=`all 200ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})}))}_animateExit(){let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`hidden`);return}e.style.transition=`all 200ms ease-in`,e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,setTimeout(()=>{this.classList.add(`hidden`),e.style.transform=``,e.style.opacity=``,e.style.transition=``},200)}};customElements.get(`mint-modal`)||customElements.define(`mint-modal`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
package/dist/modal.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./modal-C_ukm1We.cjs`);
|
package/dist/modal.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintModal as default } from './mintui-elements'
|
package/dist/modal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./modal-BZYcRU3i.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./text-CoinZsjJ.cjs`);var e=class extends HTMLElement{static get observedAttributes(){return[`href`,`fallback-href`]}constructor(){super(),this._historyDepth=0,this._maxBackAttempts=10,this._backAttempts=0}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`,`flex`,`items-center`,`justify-center`),this.render(),this._setupHistoryTracking()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_setupHistoryTracking(){window.addEventListener(`popstate`,()=>{this._backAttempts=0}),this._historyDepth=window.history.length}getFallbackHref(){return this.getAttribute(`fallback-href`)||this.getAttribute(`href`)||`/`}handleClick(e){if(e.preventDefault(),e.stopPropagation(),window.history.length>1&&this._backAttempts<this._maxBackAttempts&&this._backAttempts===0){this._backAttempts++;let e=window.location.href,t=Date.now();window.history.back(),setTimeout(()=>{Date.now()-t,window.location.href===e?this._navigateToFallback():setTimeout(()=>{this._backAttempts=0},500)},200)}else this._navigateToFallback()}_navigateToFallback(){let e=this.getFallbackHref();if(this._backAttempts=0,e.startsWith(`/`)&&!e.startsWith(`//`)){let t=document.querySelector(`#app`).__vue_app__;if(t&&t.config&&t.config.globalProperties&&t.config.globalProperties.$router)try{t.config.globalProperties.$router.push(e);return}catch{}try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`));return}catch{}}window.location.href=e}render(){this._button||(this._button=document.createElement(`mint-button`),this._button.setAttribute(`variant`,`neutral`),this._button.setAttribute(`icon`,`arrow-left`),this._button.addEventListener(`click`,e=>this.handleClick(e)),this.appendChild(this._button))}};customElements.get(`mint-back-button`)||customElements.define(`mint-back-button`,e);var t=class extends HTMLElement{static get observedAttributes(){return[`heading`,`fallback-href`,`show-back-button`]}constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}getHeading(){return this.getAttribute(`heading`)||``}getFallbackHref(){return this.getAttribute(`fallback-href`)||`/`}shouldShowBackButton(){return this.hasAttribute(`show-back-button`)}render(){let e=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement(`div`),this._pageContainer.className=`min-h-screen p-8 transition-colors duration-200`,this.appendChild(this._pageContainer)),this._header||(this._header=document.createElement(`div`),this._header.className=`flex justify-between mb-8`,this._pageContainer.appendChild(this._header)),this._titleElement||(this._titleElement=document.createElement(`div`),this._titleElement.className=`flex gap-4 min-w-0 flex-1`,this._header.appendChild(this._titleElement));let t=this._titleElement.querySelector(`mint-back-button`);if(this.shouldShowBackButton()){t||(t=document.createElement(`mint-back-button`),this._titleElement.insertBefore(t,this._titleElement.firstChild));let e=this.getFallbackHref();t.setAttribute(`fallback-href`,e)}else t&&=(t.remove(),null);e?(this._headingText?(this._headingText.classList.add(`truncate`,`min-w-0`),t&&t.parentElement===this._titleElement?this._headingText.previousSibling!==t&&this._titleElement.insertBefore(this._headingText,t.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement(`mint-text`),this._headingText.setAttribute(`size`,`heading`),this._headingText.setAttribute(`bold`,``),this._headingText.classList.add(`truncate`,`min-w-0`),t&&t.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,t.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=e):this._headingText&&=(this._headingText.remove(),null),this._actionsSlot?this._actionsSlot.classList.contains(`ml-4`)||this._actionsSlot.classList.add(`ml-4`):(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`flex gap-2 items-center ml-4`,this._actionsSlot.setAttribute(`slot`,`actions`),this._header.appendChild(this._actionsSlot)),Array.from(this.children).filter(e=>e!==this._pageContainer&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{e.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(e)}),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(e=>{e!==this._pageContainer&&e.getAttribute(`slot`)!==`actions`&&e!==this._actionsSlot&&e!==this._header&&e!==this._bodySlot&&e!==this._headingText&&e.parentElement!==this._bodySlot&&e.parentElement!==this._pageContainer&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_updateBackgroundColor(){this._pageContainer&&(document.documentElement.classList.contains(`dark`)?(this._pageContainer.classList.remove(`bg-gray-50`),this._pageContainer.classList.add(`bg-gray-900`)):(this._pageContainer.classList.remove(`bg-gray-900`),this._pageContainer.classList.add(`bg-gray-50`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}};customElements.get(`mint-page`)||customElements.define(`mint-page`,t),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import "./text-q58TQcH-.js";
|
|
2
|
+
//#region src/components/back-button/BackButton.js
|
|
3
|
+
var e = class extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ["href", "fallback-href"];
|
|
6
|
+
}
|
|
7
|
+
constructor() {
|
|
8
|
+
super(), this._historyDepth = 0, this._maxBackAttempts = 10, this._backAttempts = 0;
|
|
9
|
+
}
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block", "flex", "items-center", "justify-center"), this.render(), this._setupHistoryTracking();
|
|
12
|
+
}
|
|
13
|
+
attributeChangedCallback(e, t, n) {
|
|
14
|
+
t !== n && this.render();
|
|
15
|
+
}
|
|
16
|
+
_setupHistoryTracking() {
|
|
17
|
+
window.addEventListener("popstate", () => {
|
|
18
|
+
this._backAttempts = 0;
|
|
19
|
+
}), this._historyDepth = window.history.length;
|
|
20
|
+
}
|
|
21
|
+
getFallbackHref() {
|
|
22
|
+
return this.getAttribute("fallback-href") || this.getAttribute("href") || "/";
|
|
23
|
+
}
|
|
24
|
+
handleClick(e) {
|
|
25
|
+
if (e.preventDefault(), e.stopPropagation(), window.history.length > 1 && this._backAttempts < this._maxBackAttempts && this._backAttempts === 0) {
|
|
26
|
+
this._backAttempts++;
|
|
27
|
+
let e = window.location.href, t = Date.now();
|
|
28
|
+
window.history.back(), setTimeout(() => {
|
|
29
|
+
Date.now() - t, window.location.href === e ? this._navigateToFallback() : setTimeout(() => {
|
|
30
|
+
this._backAttempts = 0;
|
|
31
|
+
}, 500);
|
|
32
|
+
}, 200);
|
|
33
|
+
} else this._navigateToFallback();
|
|
34
|
+
}
|
|
35
|
+
_navigateToFallback() {
|
|
36
|
+
let e = this.getFallbackHref();
|
|
37
|
+
if (this._backAttempts = 0, e.startsWith("/") && !e.startsWith("//")) {
|
|
38
|
+
let t = document.querySelector("#app").__vue_app__;
|
|
39
|
+
if (t && t.config && t.config.globalProperties && t.config.globalProperties.$router) try {
|
|
40
|
+
t.config.globalProperties.$router.push(e);
|
|
41
|
+
return;
|
|
42
|
+
} catch {}
|
|
43
|
+
try {
|
|
44
|
+
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
45
|
+
return;
|
|
46
|
+
} catch {}
|
|
47
|
+
}
|
|
48
|
+
window.location.href = e;
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
this._button || (this._button = document.createElement("mint-button"), this._button.setAttribute("variant", "neutral"), this._button.setAttribute("icon", "arrow-left"), this._button.addEventListener("click", (e) => this.handleClick(e)), this.appendChild(this._button));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
customElements.get("mint-back-button") || customElements.define("mint-back-button", e);
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/components/page/Page.js
|
|
57
|
+
var t = class extends HTMLElement {
|
|
58
|
+
static get observedAttributes() {
|
|
59
|
+
return [
|
|
60
|
+
"heading",
|
|
61
|
+
"fallback-href",
|
|
62
|
+
"show-back-button"
|
|
63
|
+
];
|
|
64
|
+
}
|
|
65
|
+
constructor() {
|
|
66
|
+
super(), this._pageContainer = null, this._header = null, this._titleElement = null, this._headingText = null, this._actionsSlot = null, this._bodySlot = null, this._darkModeObserver = null;
|
|
67
|
+
}
|
|
68
|
+
connectedCallback() {
|
|
69
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "block"), this.render(), this._observeDarkMode();
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
this._darkModeObserver &&= (this._darkModeObserver.disconnect(), null);
|
|
73
|
+
}
|
|
74
|
+
getHeading() {
|
|
75
|
+
return this.getAttribute("heading") || "";
|
|
76
|
+
}
|
|
77
|
+
getFallbackHref() {
|
|
78
|
+
return this.getAttribute("fallback-href") || "/";
|
|
79
|
+
}
|
|
80
|
+
shouldShowBackButton() {
|
|
81
|
+
return this.hasAttribute("show-back-button");
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
let e = this.getHeading();
|
|
85
|
+
this._pageContainer || (this._pageContainer = document.createElement("div"), this._pageContainer.className = "min-h-screen p-8 transition-colors duration-200", this.appendChild(this._pageContainer)), this._header || (this._header = document.createElement("div"), this._header.className = "flex justify-between mb-8", this._pageContainer.appendChild(this._header)), this._titleElement || (this._titleElement = document.createElement("div"), this._titleElement.className = "flex gap-4 min-w-0 flex-1", this._header.appendChild(this._titleElement));
|
|
86
|
+
let t = this._titleElement.querySelector("mint-back-button");
|
|
87
|
+
if (this.shouldShowBackButton()) {
|
|
88
|
+
t || (t = document.createElement("mint-back-button"), this._titleElement.insertBefore(t, this._titleElement.firstChild));
|
|
89
|
+
let e = this.getFallbackHref();
|
|
90
|
+
t.setAttribute("fallback-href", e);
|
|
91
|
+
} else t &&= (t.remove(), null);
|
|
92
|
+
e ? (this._headingText ? (this._headingText.classList.add("truncate", "min-w-0"), t && t.parentElement === this._titleElement ? this._headingText.previousSibling !== t && this._titleElement.insertBefore(this._headingText, t.nextSibling) : this._headingText.previousSibling && this._titleElement.insertBefore(this._headingText, this._titleElement.firstChild)) : (this._headingText = document.createElement("mint-text"), this._headingText.setAttribute("size", "heading"), this._headingText.setAttribute("bold", ""), this._headingText.classList.add("truncate", "min-w-0"), t && t.parentElement === this._titleElement ? this._titleElement.insertBefore(this._headingText, t.nextSibling) : this._titleElement.insertBefore(this._headingText, this._titleElement.firstChild)), this._headingText.textContent = e) : this._headingText &&= (this._headingText.remove(), null), this._actionsSlot ? this._actionsSlot.classList.contains("ml-4") || this._actionsSlot.classList.add("ml-4") : (this._actionsSlot = document.createElement("div"), this._actionsSlot.className = "flex gap-2 items-center ml-4", this._actionsSlot.setAttribute("slot", "actions"), this._header.appendChild(this._actionsSlot)), Array.from(this.children).filter((e) => e !== this._pageContainer && e !== this._actionsSlot && e.getAttribute("slot") === "actions").forEach((e) => {
|
|
93
|
+
e.parentElement !== this._actionsSlot && this._actionsSlot.appendChild(e);
|
|
94
|
+
}), this._bodySlot || (this._bodySlot = document.createElement("div"), this._pageContainer.appendChild(this._bodySlot)), Array.from(this.children).forEach((e) => {
|
|
95
|
+
e !== this._pageContainer && e.getAttribute("slot") !== "actions" && e !== this._actionsSlot && e !== this._header && e !== this._bodySlot && e !== this._headingText && e.parentElement !== this._bodySlot && e.parentElement !== this._pageContainer && this._bodySlot.appendChild(e);
|
|
96
|
+
}), this._updateBackgroundColor();
|
|
97
|
+
}
|
|
98
|
+
_updateBackgroundColor() {
|
|
99
|
+
this._pageContainer && (document.documentElement.classList.contains("dark") ? (this._pageContainer.classList.remove("bg-gray-50"), this._pageContainer.classList.add("bg-gray-900")) : (this._pageContainer.classList.remove("bg-gray-900"), this._pageContainer.classList.add("bg-gray-50")));
|
|
100
|
+
}
|
|
101
|
+
_observeDarkMode() {
|
|
102
|
+
this._darkModeObserver || (this._darkModeObserver = new MutationObserver(() => {
|
|
103
|
+
this._updateBackgroundColor();
|
|
104
|
+
}), this._darkModeObserver.observe(document.documentElement, {
|
|
105
|
+
attributes: !0,
|
|
106
|
+
attributeFilter: ["class"]
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
customElements.get("mint-page") || customElements.define("mint-page", t);
|
|
111
|
+
//#endregion
|
|
112
|
+
export { t };
|
package/dist/page.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./page-CJ3M0wAd.cjs`);module.exports=e.t;
|
package/dist/page.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MintPage as default } from './mintui-elements'
|
package/dist/page.js
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import "./stack-D0noPfD1.js";
|
|
2
|
+
//#region src/components/popover/Popover.js
|
|
3
|
+
var e = class extends HTMLElement {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return [
|
|
6
|
+
"id",
|
|
7
|
+
"direction",
|
|
8
|
+
"open",
|
|
9
|
+
"trigger-id"
|
|
10
|
+
];
|
|
11
|
+
}
|
|
12
|
+
constructor() {
|
|
13
|
+
super(), this._overlay = null, this._popover = null, this._triggerElement = null, this._darkModeObserver = null, this._clickOutsideHandler = null, this._triggerClickHandler = null, this._scrollHandler = null, this._resizeHandler = null;
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "fixed", "inset-0", "z-50"), this.isOpen() || this.classList.add("hidden"), this.render(), this._setupTrigger(), this._observeDarkMode();
|
|
17
|
+
}
|
|
18
|
+
disconnectedCallback() {
|
|
19
|
+
this._darkModeObserver &&= (this._darkModeObserver.disconnect(), null), this._clickOutsideHandler &&= (document.removeEventListener("click", this._clickOutsideHandler), null), this._triggerClickHandler && this._triggerElement && (this._triggerElement.removeEventListener("click", this._triggerClickHandler), this._triggerClickHandler = null), this._scrollHandler &&= (window.removeEventListener("scroll", this._scrollHandler, !0), null), this._resizeHandler &&= (window.removeEventListener("resize", this._resizeHandler), null);
|
|
20
|
+
}
|
|
21
|
+
attributeChangedCallback(e, t, n) {
|
|
22
|
+
t !== n && (this.render(), e === "trigger-id" && this._setupTrigger());
|
|
23
|
+
}
|
|
24
|
+
getId() {
|
|
25
|
+
return this.getAttribute("id") || "";
|
|
26
|
+
}
|
|
27
|
+
getDirection() {
|
|
28
|
+
return this.getAttribute("direction") || "down";
|
|
29
|
+
}
|
|
30
|
+
getTriggerId() {
|
|
31
|
+
return this.getAttribute("trigger-id") || "";
|
|
32
|
+
}
|
|
33
|
+
isOpen() {
|
|
34
|
+
return this.hasAttribute("open");
|
|
35
|
+
}
|
|
36
|
+
open() {
|
|
37
|
+
this.setAttribute("open", "");
|
|
38
|
+
}
|
|
39
|
+
close() {
|
|
40
|
+
this.removeAttribute("open");
|
|
41
|
+
}
|
|
42
|
+
_setupTrigger() {
|
|
43
|
+
let e = this.getTriggerId();
|
|
44
|
+
this._triggerClickHandler && this._triggerElement && (this._triggerElement.removeEventListener("click", this._triggerClickHandler), this._triggerClickHandler = null), e && (this._triggerElement = document.getElementById(e), this._triggerElement ? this._attachTriggerListener() : setTimeout(() => {
|
|
45
|
+
this._triggerElement = document.getElementById(e), this._triggerElement && this._attachTriggerListener();
|
|
46
|
+
}, 10));
|
|
47
|
+
}
|
|
48
|
+
_attachTriggerListener() {
|
|
49
|
+
if (this._triggerElement && !this._triggerClickHandler) {
|
|
50
|
+
let e = this;
|
|
51
|
+
this._triggerClickHandler = function(t) {
|
|
52
|
+
t.stopImmediatePropagation(), t.preventDefault(), e.hasAttribute("open") ? e.removeAttribute("open") : e.setAttribute("open", "");
|
|
53
|
+
}, this._triggerElement.addEventListener("click", this._triggerClickHandler, !0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
_calculatePosition() {
|
|
57
|
+
if (!this._triggerElement || !this._popover) return {
|
|
58
|
+
top: 0,
|
|
59
|
+
left: 0,
|
|
60
|
+
direction: "down"
|
|
61
|
+
};
|
|
62
|
+
let e = this._triggerElement.getBoundingClientRect(), t = this._popover.querySelector(".popover-content");
|
|
63
|
+
if (!t) return {
|
|
64
|
+
top: 0,
|
|
65
|
+
left: 0,
|
|
66
|
+
direction: "down"
|
|
67
|
+
};
|
|
68
|
+
this.classList.contains("hidden") && (this.classList.remove("hidden"), this._popover.style.visibility = "hidden");
|
|
69
|
+
let n = t.getBoundingClientRect(), r = window.innerWidth, i = window.innerHeight, a = this.getDirection(), o = 0, s = 0;
|
|
70
|
+
switch (a) {
|
|
71
|
+
case "down":
|
|
72
|
+
if (o = e.bottom + 8, s = e.left + e.width / 2 - n.width / 2, o + n.height > i) {
|
|
73
|
+
let t = e.top - n.height - 8;
|
|
74
|
+
t >= 0 ? (a = "up", o = t) : (o = Math.max(0, i - n.height - 8), o + n.height > i && (o = 0));
|
|
75
|
+
}
|
|
76
|
+
s < 0 && (s = 8), s + n.width > r && (s = Math.max(8, r - n.width - 8), s + n.width > r && (s = r - n.width));
|
|
77
|
+
break;
|
|
78
|
+
case "up":
|
|
79
|
+
if (o = e.top - n.height - 8, s = e.left + e.width / 2 - n.width / 2, o < 0) {
|
|
80
|
+
let t = e.bottom + 8;
|
|
81
|
+
t + n.height <= i ? (a = "down", o = t) : (o = Math.min(i - n.height - 8, i - n.height), o < 0 && (o = i - n.height));
|
|
82
|
+
}
|
|
83
|
+
s < 0 && (s = 8), s + n.width > r && (s = Math.max(8, r - n.width - 8), s + n.width > r && (s = r - n.width));
|
|
84
|
+
break;
|
|
85
|
+
case "right":
|
|
86
|
+
if (o = e.top + e.height / 2 - n.height / 2, s = e.right + 8, s + n.width > r) {
|
|
87
|
+
let t = e.left - n.width - 8;
|
|
88
|
+
t >= 0 ? (a = "left", s = t) : (s = Math.max(0, r - n.width - 8), s + n.width > r && (s = r - n.width));
|
|
89
|
+
}
|
|
90
|
+
o < 0 && (o = 8), o + n.height > i && (o = Math.max(8, i - n.height - 8), o + n.height > i && (o = i - n.height));
|
|
91
|
+
break;
|
|
92
|
+
case "left":
|
|
93
|
+
if (o = e.top + e.height / 2 - n.height / 2, s = e.left - n.width - 8, s < 0) {
|
|
94
|
+
let t = e.right + 8;
|
|
95
|
+
t + n.width <= r ? (a = "right", s = t) : (s = Math.min(r - n.width - 8, r - n.width), s < 0 && (s = 0));
|
|
96
|
+
}
|
|
97
|
+
o < 0 && (o = 8), o + n.height > i && (o = Math.max(8, i - n.height - 8), o + n.height > i && (o = i - n.height));
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
top: o,
|
|
102
|
+
left: s,
|
|
103
|
+
direction: a
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
render() {
|
|
107
|
+
let e = this.getId(), t = this.isOpen();
|
|
108
|
+
if (e && (this.id = e), t) {
|
|
109
|
+
if (this.classList.remove("hidden"), this.style.pointerEvents = "auto", !this._clickOutsideHandler) {
|
|
110
|
+
let e = this;
|
|
111
|
+
this._clickOutsideHandler = function(t) {
|
|
112
|
+
let n = t.target, r = e._popover?.querySelector(".popover-content"), i = r && (r.contains(n) || r === n), a = n.closest("button, a, [role=\"button\"], mint-button, mint-link") !== null;
|
|
113
|
+
(!i || a) && e.close();
|
|
114
|
+
}, setTimeout(() => {
|
|
115
|
+
document.addEventListener("click", this._clickOutsideHandler, !1);
|
|
116
|
+
}, 100);
|
|
117
|
+
}
|
|
118
|
+
} else this.classList.add("hidden"), this.style.pointerEvents = "none", this._clickOutsideHandler &&= (document.removeEventListener("click", this._clickOutsideHandler, !0), null);
|
|
119
|
+
this._overlay || (this._overlay = document.createElement("div"), this._overlay.className = "fixed inset-0 pointer-events-none z-40", this.appendChild(this._overlay)), this._popover || (this._popover = document.createElement("div"), this._popover.className = "fixed z-50 pointer-events-auto", this.appendChild(this._popover));
|
|
120
|
+
let n = this._popover.querySelector(".popover-content");
|
|
121
|
+
n || (n = document.createElement("div"), n.className = "popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl p-4 transition-all duration-200 ease-out transform", this._popover.appendChild(n)), Array.from(this.children).forEach((e) => {
|
|
122
|
+
e !== this._overlay && e !== this._popover && e.parentElement === this && n.appendChild(e);
|
|
123
|
+
}), t ? (this._triggerElement || this._setupTrigger(), this._setupPositionListeners(), this.offsetHeight, this._triggerElement ? this._updatePosition(n) : (this._popover.style.top = "50%", this._popover.style.left = "50%", this._popover.style.transform = "translate(-50%, -50%)", this._popover.style.visibility = "visible", this._popover.style.display = "block", n.style.transform = "scale(0.97) translateY(10px)", n.style.opacity = "0", n.style.transition = "all 200ms ease-out", requestAnimationFrame(() => {
|
|
124
|
+
requestAnimationFrame(() => {
|
|
125
|
+
n.style.transform = "scale(1) translateY(0)", n.style.opacity = "1";
|
|
126
|
+
});
|
|
127
|
+
}))) : !t && n && (this._removePositionListeners(), n.style.opacity !== "0" && n.style.opacity !== "" && (n.style.transition = "all 200ms ease-in", n.style.transform = "scale(0.97) translateY(10px)", n.style.opacity = "0", setTimeout(() => {
|
|
128
|
+
n.style.transform = "", n.style.opacity = "", n.style.transition = "", this._popover.style.visibility = "", this._popover.style.display = "";
|
|
129
|
+
}, 200))), this._updateBackgroundColor();
|
|
130
|
+
}
|
|
131
|
+
_updateBackgroundColor() {
|
|
132
|
+
if (!this._popover) return;
|
|
133
|
+
let e = document.documentElement.classList.contains("dark"), t = this._popover.querySelector(".popover-content");
|
|
134
|
+
t && (e ? (t.classList.remove("bg-white"), t.classList.add("bg-gray-800")) : (t.classList.remove("bg-gray-800"), t.classList.add("bg-white")));
|
|
135
|
+
}
|
|
136
|
+
_observeDarkMode() {
|
|
137
|
+
this._darkModeObserver || (this._darkModeObserver = new MutationObserver(() => {
|
|
138
|
+
this._updateBackgroundColor();
|
|
139
|
+
}), this._darkModeObserver.observe(document.documentElement, {
|
|
140
|
+
attributes: !0,
|
|
141
|
+
attributeFilter: ["class"]
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
_updatePosition(e) {
|
|
145
|
+
if (!this._triggerElement || !this._popover) return;
|
|
146
|
+
let t = this._popover.style.visibility !== "hidden";
|
|
147
|
+
t || (this._popover.style.visibility = "hidden", this._popover.style.display = "block", this._popover.style.top = "0", this._popover.style.left = "0"), this._popover.offsetHeight;
|
|
148
|
+
let n = this._calculatePosition();
|
|
149
|
+
this._popover.style.top = `${n.top}px`, this._popover.style.left = `${n.left}px`, t || (this._popover.style.visibility = "visible", e && (!e.style.opacity || e.style.opacity === "") && (e.style.transform = "scale(0.97) translateY(10px)", e.style.opacity = "0", e.style.transition = "all 200ms ease-out", requestAnimationFrame(() => {
|
|
150
|
+
requestAnimationFrame(() => {
|
|
151
|
+
e.style.transform = "scale(1) translateY(0)", e.style.opacity = "1";
|
|
152
|
+
});
|
|
153
|
+
})));
|
|
154
|
+
}
|
|
155
|
+
_setupPositionListeners() {
|
|
156
|
+
if (!this._scrollHandler && this.isOpen()) {
|
|
157
|
+
let e = this;
|
|
158
|
+
this._scrollHandler = function() {
|
|
159
|
+
if (e.isOpen() && e._popover) {
|
|
160
|
+
let t = e._popover.querySelector(".popover-content");
|
|
161
|
+
e._updatePosition(t);
|
|
162
|
+
}
|
|
163
|
+
}, window.addEventListener("scroll", this._scrollHandler, !0);
|
|
164
|
+
}
|
|
165
|
+
if (!this._resizeHandler && this.isOpen()) {
|
|
166
|
+
let e = this;
|
|
167
|
+
this._resizeHandler = function() {
|
|
168
|
+
if (e.isOpen() && e._popover) {
|
|
169
|
+
let t = e._popover.querySelector(".popover-content");
|
|
170
|
+
e._updatePosition(t);
|
|
171
|
+
}
|
|
172
|
+
}, window.addEventListener("resize", this._resizeHandler);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
_removePositionListeners() {
|
|
176
|
+
this._scrollHandler &&= (window.removeEventListener("scroll", this._scrollHandler, !0), null), this._resizeHandler &&= (window.removeEventListener("resize", this._resizeHandler), null);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
customElements.get("mint-popover") || customElements.define("mint-popover", e);
|
|
180
|
+
//#endregion
|
|
181
|
+
export { e as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./stack-tFy8YlX2.cjs`);var e=class extends HTMLElement{static get observedAttributes(){return[`id`,`direction`,`open`,`trigger-id`]}constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._scrollHandler=null,this._resizeHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`fixed`,`inset-0`,`z-50`),this.isOpen()||this.classList.add(`hidden`),this.render(),this._setupTrigger(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler),null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener(`click`,this._triggerClickHandler),this._triggerClickHandler=null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}attributeChangedCallback(e,t,n){t!==n&&(this.render(),e===`trigger-id`&&this._setupTrigger())}getId(){return this.getAttribute(`id`)||``}getDirection(){return this.getAttribute(`direction`)||`down`}getTriggerId(){return this.getAttribute(`trigger-id`)||``}isOpen(){return this.hasAttribute(`open`)}open(){this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}_setupTrigger(){let e=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener(`click`,this._triggerClickHandler),this._triggerClickHandler=null),e&&(this._triggerElement=document.getElementById(e),this._triggerElement?this._attachTriggerListener():setTimeout(()=>{this._triggerElement=document.getElementById(e),this._triggerElement&&this._attachTriggerListener()},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){let e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.hasAttribute(`open`)?e.removeAttribute(`open`):e.setAttribute(`open`,``)},this._triggerElement.addEventListener(`click`,this._triggerClickHandler,!0)}}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:`down`};let e=this._triggerElement.getBoundingClientRect(),t=this._popover.querySelector(`.popover-content`);if(!t)return{top:0,left:0,direction:`down`};this.classList.contains(`hidden`)&&(this.classList.remove(`hidden`),this._popover.style.visibility=`hidden`);let n=t.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=this.getDirection(),o=0,s=0;switch(a){case`down`:if(o=e.bottom+8,s=e.left+e.width/2-n.width/2,o+n.height>i){let t=e.top-n.height-8;t>=0?(a=`up`,o=t):(o=Math.max(0,i-n.height-8),o+n.height>i&&(o=0))}s<0&&(s=8),s+n.width>r&&(s=Math.max(8,r-n.width-8),s+n.width>r&&(s=r-n.width));break;case`up`:if(o=e.top-n.height-8,s=e.left+e.width/2-n.width/2,o<0){let t=e.bottom+8;t+n.height<=i?(a=`down`,o=t):(o=Math.min(i-n.height-8,i-n.height),o<0&&(o=i-n.height))}s<0&&(s=8),s+n.width>r&&(s=Math.max(8,r-n.width-8),s+n.width>r&&(s=r-n.width));break;case`right`:if(o=e.top+e.height/2-n.height/2,s=e.right+8,s+n.width>r){let t=e.left-n.width-8;t>=0?(a=`left`,s=t):(s=Math.max(0,r-n.width-8),s+n.width>r&&(s=r-n.width))}o<0&&(o=8),o+n.height>i&&(o=Math.max(8,i-n.height-8),o+n.height>i&&(o=i-n.height));break;case`left`:if(o=e.top+e.height/2-n.height/2,s=e.left-n.width-8,s<0){let t=e.right+8;t+n.width<=r?(a=`right`,s=t):(s=Math.min(r-n.width-8,r-n.width),s<0&&(s=0))}o<0&&(o=8),o+n.height>i&&(o=Math.max(8,i-n.height-8),o+n.height>i&&(o=i-n.height));break}return{top:o,left:s,direction:a}}render(){let e=this.getId(),t=this.isOpen();if(e&&(this.id=e),t){if(this.classList.remove(`hidden`),this.style.pointerEvents=`auto`,!this._clickOutsideHandler){let e=this;this._clickOutsideHandler=function(t){let n=t.target,r=e._popover?.querySelector(`.popover-content`),i=r&&(r.contains(n)||r===n),a=n.closest(`button, a, [role="button"], mint-button, mint-link`)!==null;(!i||a)&&e.close()},setTimeout(()=>{document.addEventListener(`click`,this._clickOutsideHandler,!1)},100)}}else this.classList.add(`hidden`),this.style.pointerEvents=`none`,this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler,!0),null);this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 pointer-events-none z-40`,this.appendChild(this._overlay)),this._popover||(this._popover=document.createElement(`div`),this._popover.className=`fixed z-50 pointer-events-auto`,this.appendChild(this._popover));let n=this._popover.querySelector(`.popover-content`);n||(n=document.createElement(`div`),n.className=`popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl p-4 transition-all duration-200 ease-out transform`,this._popover.appendChild(n)),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._popover&&e.parentElement===this&&n.appendChild(e)}),t?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(n):(this._popover.style.top=`50%`,this._popover.style.left=`50%`,this._popover.style.transform=`translate(-50%, -50%)`,this._popover.style.visibility=`visible`,this._popover.style.display=`block`,n.style.transform=`scale(0.97) translateY(10px)`,n.style.opacity=`0`,n.style.transition=`all 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.style.transform=`scale(1) translateY(0)`,n.style.opacity=`1`})}))):!t&&n&&(this._removePositionListeners(),n.style.opacity!==`0`&&n.style.opacity!==``&&(n.style.transition=`all 200ms ease-in`,n.style.transform=`scale(0.97) translateY(10px)`,n.style.opacity=`0`,setTimeout(()=>{n.style.transform=``,n.style.opacity=``,n.style.transition=``,this._popover.style.visibility=``,this._popover.style.display=``},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;let e=document.documentElement.classList.contains(`dark`),t=this._popover.querySelector(`.popover-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-gray-800`)):(t.classList.remove(`bg-gray-800`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_updatePosition(e){if(!this._triggerElement||!this._popover)return;let t=this._popover.style.visibility!==`hidden`;t||(this._popover.style.visibility=`hidden`,this._popover.style.display=`block`,this._popover.style.top=`0`,this._popover.style.left=`0`),this._popover.offsetHeight;let n=this._calculatePosition();this._popover.style.top=`${n.top}px`,this._popover.style.left=`${n.left}px`,t||(this._popover.style.visibility=`visible`,e&&(!e.style.opacity||e.style.opacity===``)&&(e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,e.style.transition=`all 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){let e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){let t=e._popover.querySelector(`.popover-content`);e._updatePosition(t)}},window.addEventListener(`scroll`,this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){let e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){let t=e._popover.querySelector(`.popover-content`);e._updatePosition(t)}},window.addEventListener(`resize`,this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}};customElements.get(`mint-popover`)||customElements.define(`mint-popover`,e),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
package/dist/popover.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require(`./popover-CuSBQ8Jm.cjs`);
|