monobill-mintui 0.6.645 → 0.6.647
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/bin/component-dependencies.json +6 -1
- package/dist/back-button.css +1 -1
- package/dist/button.css +1 -1
- package/dist/components/back-button/BackButton.d.ts.map +1 -1
- package/dist/components/back-button/browser.js +2 -224
- package/dist/components/back-button/index.cjs +1 -1
- package/dist/components/back-button/index.js +2 -224
- package/dist/components/button/browser.js +1 -1
- package/dist/components/button/index.cjs +1 -1
- package/dist/components/button/index.js +1 -1
- package/dist/components/chip/browser.js +1 -1
- package/dist/components/chip/index.cjs +1 -1
- package/dist/components/chip/index.js +1 -1
- package/dist/components/chunks/back-button-CDyPYehm.js +224 -0
- package/dist/components/chunks/back-button-SmmB1OdQ.js +1 -0
- package/dist/components/chunks/{button--a5GFBsq.js → button-BYkzR0uX.js} +1 -1
- package/dist/components/chunks/{button-BSQ2kbSp.js → button-DfY2Sr3-.js} +1 -1
- package/dist/components/chunks/{confirm-action-Bv8hCxqm.js → confirm-action-CjXJmqh4.js} +1 -1
- package/dist/components/chunks/{confirm-action-BecP6BE6.js → confirm-action-Et6i603N.js} +2 -2
- package/dist/components/chunks/{input-DpwjDKrY.js → input-4DeekhBC.js} +2 -2
- package/dist/components/chunks/{input-6-AalZ1Z.js → input-CF0QIi3N.js} +1 -1
- package/dist/components/chunks/{modal-f4myL8Ka.js → modal-CHLB5Td7.js} +1 -1
- package/dist/components/chunks/{modal-aq9VkzER.js → modal-DXviLYW_.js} +2 -2
- package/dist/components/confirm-action/browser.js +1 -1
- package/dist/components/confirm-action/index.cjs +1 -1
- package/dist/components/confirm-action/index.js +1 -1
- package/dist/components/date-picker/browser.js +3 -3
- package/dist/components/date-picker/index.cjs +1 -1
- package/dist/components/date-picker/index.js +3 -3
- package/dist/components/input/browser.js +1 -1
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +1 -1
- package/dist/components/link/browser.js +1 -1
- package/dist/components/link/index.cjs +1 -1
- package/dist/components/link/index.js +1 -1
- package/dist/components/modal/browser.js +1 -1
- package/dist/components/modal/index.cjs +1 -1
- package/dist/components/modal/index.js +1 -1
- package/dist/components/navigation/browser.js +3 -3
- package/dist/components/navigation/index.cjs +1 -1
- package/dist/components/navigation/index.js +3 -3
- package/dist/components/off-canvas/browser.js +2 -2
- package/dist/components/off-canvas/index.cjs +1 -1
- package/dist/components/off-canvas/index.js +2 -2
- package/dist/components/page/Page.d.ts.map +1 -1
- package/dist/components/page/browser.js +8 -3
- package/dist/components/page/index.cjs +45 -7
- package/dist/components/page/index.js +8 -3
- package/dist/components/popover/browser.js +1 -1
- package/dist/components/popover/index.cjs +1 -1
- package/dist/components/popover/index.js +1 -1
- package/dist/components/resource-table/browser.js +8 -8
- package/dist/components/resource-table/index.cjs +1 -1
- package/dist/components/resource-table/index.js +8 -8
- package/dist/components/search/browser.js +4 -4
- package/dist/components/search/index.cjs +1 -1
- package/dist/components/search/index.js +4 -4
- package/dist/components/select/browser.js +2 -2
- package/dist/components/select/index.cjs +1 -1
- package/dist/components/select/index.js +2 -2
- package/dist/components/side-navigation/browser.js +3 -3
- package/dist/components/side-navigation/index.cjs +1 -1
- package/dist/components/side-navigation/index.js +3 -3
- package/dist/components/sortable/browser.js +1 -1
- package/dist/components/sortable/index.cjs +1 -1
- package/dist/components/sortable/index.js +1 -1
- package/dist/components/spinner/browser.js +1 -1
- package/dist/components/spinner/index.cjs +1 -1
- package/dist/components/spinner/index.js +1 -1
- package/dist/components/stack/browser.js +1 -1
- package/dist/components/stack/index.cjs +1 -1
- package/dist/components/stack/index.js +1 -1
- package/dist/components/table/browser.js +1 -1
- package/dist/components/table/index.cjs +1 -1
- package/dist/components/table/index.js +1 -1
- package/dist/components/tags/browser.js +3 -3
- package/dist/components/tags/index.cjs +1 -1
- package/dist/components/tags/index.js +3 -3
- package/dist/components/time-picker/browser.js +2 -2
- package/dist/components/time-picker/index.cjs +1 -1
- package/dist/components/time-picker/index.js +2 -2
- package/dist/components/tree/browser.js +5 -5
- package/dist/components/tree/index.cjs +1 -1
- package/dist/components/tree/index.js +5 -5
- package/dist/confirm-action.css +1 -1
- package/dist/index.cjs +46 -8
- package/dist/index.css +6 -6
- package/dist/index.js +238 -238
- package/dist/modal.css +1 -1
- package/dist/navigation.css +1 -1
- package/dist/page.css +1 -1
- package/package.json +1 -1
- /package/dist/components/chunks/{caret-down-CDnWVla1.js → caret-down-Ccvv5gwc.js} +0 -0
- /package/dist/components/chunks/{caret-down-Bc-42asv.js → caret-down-D1Qs39Av.js} +0 -0
- /package/dist/components/chunks/{caret-right-Dl7Btqeu.js → caret-right-C83pwBin.js} +0 -0
- /package/dist/components/chunks/{caret-right-pNDbqRU-.js → caret-right-IYvGg3-k.js} +0 -0
- /package/dist/components/chunks/{caret-up-B9fWmN80.js → caret-up-CqFNwOux.js} +0 -0
- /package/dist/components/chunks/{caret-up-DS_oo8YB.js → caret-up-CsT9c_xE.js} +0 -0
- /package/dist/components/chunks/{chip-mkhI7zxk.js → chip-CLCBimJI.js} +0 -0
- /package/dist/components/chunks/{chip-Bl9qQp6u.js → chip-Dfj3x__h.js} +0 -0
- /package/dist/components/chunks/{link-4LblIyiP.js → link-BsC3zT_I.js} +0 -0
- /package/dist/components/chunks/{link-DYbrI89a.js → link-dTjSvr4E.js} +0 -0
- /package/dist/components/chunks/{popover-Db9ZGHd9.js → popover-CNZ5u-MA.js} +0 -0
- /package/dist/components/chunks/{popover-CV-QCPjW.js → popover-DB1OaYVe.js} +0 -0
- /package/dist/components/chunks/{search-CYCZByVh.js → search-W2xBCOsc.js} +0 -0
- /package/dist/components/chunks/{search-DCUJFMBL.js → search-oWslgsR8.js} +0 -0
- /package/dist/components/chunks/{sortable-CparUKN_.js → sortable-B1nMJBah.js} +0 -0
- /package/dist/components/chunks/{sortable-DX2PwFLN.js → sortable-CXM-7eyL.js} +0 -0
- /package/dist/components/chunks/{spinner-BsaFHuS6.js → spinner-BjC3nA-C.js} +0 -0
- /package/dist/components/chunks/{spinner-DbTohC6i.js → spinner-DfPbEa2d.js} +0 -0
- /package/dist/components/chunks/{stack-CpmqyaNX.js → stack-Bdl46AdO.js} +0 -0
- /package/dist/components/chunks/{stack-_7V0Fcu0.js → stack-nq3AmcMG.js} +0 -0
- /package/dist/components/chunks/{table-CI11Mff-.js → table-2-0iNQJy.js} +0 -0
- /package/dist/components/chunks/{table-EgbYUKL8.js → table-DRdsVUJL.js} +0 -0
|
@@ -3,227 +3,5 @@ import '../../button.css'
|
|
|
3
3
|
import '../../spinner.css'
|
|
4
4
|
import '../../icon.css'
|
|
5
5
|
import '../../back-button.css'
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import "../chunks/icon-CkFfk0oc.js";
|
|
9
|
-
/* empty css */
|
|
10
|
-
import "../chunks/spinner-BsaFHuS6.js";
|
|
11
|
-
e({
|
|
12
|
-
name: "arrow-left",
|
|
13
|
-
viewBox: "0 0 24 24",
|
|
14
|
-
path: "M19 12H5m7-7l-7 7 7 7",
|
|
15
|
-
strokeLinecap: "round",
|
|
16
|
-
strokeLinejoin: "round"
|
|
17
|
-
});
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/components/button/Button.js
|
|
20
|
-
var n = class extends HTMLElement {
|
|
21
|
-
static get observedAttributes() {
|
|
22
|
-
return [
|
|
23
|
-
"variant",
|
|
24
|
-
"tone",
|
|
25
|
-
"disabled",
|
|
26
|
-
"loading",
|
|
27
|
-
"button-type",
|
|
28
|
-
"type",
|
|
29
|
-
"full-width",
|
|
30
|
-
"icon-position",
|
|
31
|
-
"icon"
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
constructor() {
|
|
35
|
-
super(), this._button = null, this._clickHandler = null, this._isHandlingClick = !1;
|
|
36
|
-
}
|
|
37
|
-
connectedCallback() {
|
|
38
|
-
this.render(), this._button && this.setupEventListeners();
|
|
39
|
-
}
|
|
40
|
-
disconnectedCallback() {
|
|
41
|
-
this.removeEventListeners();
|
|
42
|
-
}
|
|
43
|
-
attributeChangedCallback(e, t, n) {
|
|
44
|
-
t !== n && this.render();
|
|
45
|
-
}
|
|
46
|
-
getVariant() {
|
|
47
|
-
return this.getAttribute("variant") || "solid";
|
|
48
|
-
}
|
|
49
|
-
getTone() {
|
|
50
|
-
return this.getAttribute("tone") || "neutral";
|
|
51
|
-
}
|
|
52
|
-
isDisabled() {
|
|
53
|
-
return this.hasAttribute("disabled");
|
|
54
|
-
}
|
|
55
|
-
isLoading() {
|
|
56
|
-
return this.hasAttribute("loading");
|
|
57
|
-
}
|
|
58
|
-
getType() {
|
|
59
|
-
return (this.getAttribute("type") || this.getAttribute("button-type") || "default") === "submit" ? "submit" : "button";
|
|
60
|
-
}
|
|
61
|
-
isFullWidth() {
|
|
62
|
-
return this.hasAttribute("full-width");
|
|
63
|
-
}
|
|
64
|
-
getIconPosition() {
|
|
65
|
-
return this.getAttribute("icon-position") || "left";
|
|
66
|
-
}
|
|
67
|
-
getIcon() {
|
|
68
|
-
return this.getAttribute("icon") || "";
|
|
69
|
-
}
|
|
70
|
-
isIconOnly() {
|
|
71
|
-
if (!(this.getIcon() || this._button?.querySelector("[slot=\"icon\"], .mint-button-icon, mint-icon"))) return !1;
|
|
72
|
-
let e = this._button?.querySelector(".mint-button-content");
|
|
73
|
-
if (e && e.textContent.trim()) return !1;
|
|
74
|
-
if (this._button) {
|
|
75
|
-
for (let e = this._button.firstChild; e; e = e.nextSibling) if (e.nodeType === Node.TEXT_NODE && e.textContent.trim() || e.nodeType === Node.ELEMENT_NODE && e.tagName !== "MINT-ICON" && e.tagName !== "MINT-SPINNER" && !e.querySelector?.("mint-spinner") && !e.hasAttribute?.("slot") && e.className !== "mint-button-icon" && !(e.className === "mr-2" && e.querySelector("mint-spinner")) && e.textContent.trim()) return !1;
|
|
76
|
-
}
|
|
77
|
-
return !0;
|
|
78
|
-
}
|
|
79
|
-
getButtonClasses() {
|
|
80
|
-
return [
|
|
81
|
-
"mint-button-core",
|
|
82
|
-
"mint-button-" + this.getVariant(),
|
|
83
|
-
"mint-button-tone-" + this.getTone(),
|
|
84
|
-
this.isIconOnly() ? "mint-button-icon-only" : "",
|
|
85
|
-
this.isFullWidth() ? "mint-button-full-width" : ""
|
|
86
|
-
].filter(Boolean).join(" ");
|
|
87
|
-
}
|
|
88
|
-
render() {
|
|
89
|
-
let e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
90
|
-
if (!this._button) {
|
|
91
|
-
for (this._button = document.createElement("button"); this.firstChild;) this._button.appendChild(this.firstChild);
|
|
92
|
-
this.appendChild(this._button), this.setupEventListeners();
|
|
93
|
-
}
|
|
94
|
-
this._button.type = t, this._button.disabled = e;
|
|
95
|
-
let n = this._button.querySelector("mint-spinner");
|
|
96
|
-
if (this.isLoading()) if (n) n.setAttribute("data-button-variant", this.getVariant()), n.setAttribute("data-button-tone", this.getTone()), n.render();
|
|
97
|
-
else {
|
|
98
|
-
let e = document.createElement("span");
|
|
99
|
-
e.className = "mint-spinner-wrap";
|
|
100
|
-
let t = document.createElement("mint-spinner");
|
|
101
|
-
t.setAttribute("size", "default"), t.setAttribute("data-button-variant", this.getVariant()), t.setAttribute("data-button-tone", this.getTone()), t.style.width = "0.875rem", t.style.height = "0.875rem", e.appendChild(t), this._button.insertBefore(e, this._button.firstChild);
|
|
102
|
-
}
|
|
103
|
-
else n && n.parentElement?.remove();
|
|
104
|
-
for (; this.firstChild && this.firstChild !== this._button;) this._button.appendChild(this.firstChild);
|
|
105
|
-
let r = this.getIcon(), i = this._button.querySelector("[slot=\"icon\"], .mint-button-icon, mint-icon");
|
|
106
|
-
r ? (i && i.tagName !== "MINT-ICON" && (i.remove(), i = null), !i || i.tagName !== "MINT-ICON" ? (i = document.createElement("mint-icon"), i.setAttribute("name", r), i.className = "mint-button-icon") : i.setAttribute("name", r)) : i && i.tagName === "MINT-ICON" && (i.remove(), i = null), i ||= this._button.querySelector("[slot=\"icon\"], .mint-button-icon");
|
|
107
|
-
let a = this.getIconPosition(), o = this._button.querySelector(".mint-button-content");
|
|
108
|
-
if (o) {
|
|
109
|
-
let e = i && i.tagName === "MINT-ICON";
|
|
110
|
-
if (i && !i.parentElement) {
|
|
111
|
-
let t = this._button.querySelector("mint-spinner")?.parentElement;
|
|
112
|
-
e || a === "left" ? t ? t.insertAdjacentElement("afterend", i) : this._button.insertBefore(i, o) : o.insertAdjacentElement("afterend", i);
|
|
113
|
-
} else if (i && (e || a === "left") && i.nextSibling !== o) {
|
|
114
|
-
i.remove();
|
|
115
|
-
let e = this._button.querySelector("mint-spinner")?.parentElement;
|
|
116
|
-
e ? e.insertAdjacentElement("afterend", i) : this._button.insertBefore(i, o);
|
|
117
|
-
} else i && !e && a === "right" && i.previousSibling !== o && (i.remove(), o.insertAdjacentElement("afterend", i));
|
|
118
|
-
} else {
|
|
119
|
-
let e = [];
|
|
120
|
-
for (let t = this._button.firstChild; t; t = t.nextSibling) t.tagName !== "MINT-SPINNER" && !t.querySelector?.("mint-spinner") && t !== i && !t.hasAttribute?.("slot") && !(t.className === "mr-2" && t.querySelector("mint-spinner")) && e.push(t);
|
|
121
|
-
if (e.length > 0) {
|
|
122
|
-
o = document.createElement("span"), o.className = "mint-button-content", e.forEach((e) => {
|
|
123
|
-
o.appendChild(e);
|
|
124
|
-
});
|
|
125
|
-
let t = this._button.querySelector("mint-spinner")?.parentElement;
|
|
126
|
-
i && a === "left" ? t ? (t.insertAdjacentElement("afterend", i), i.insertAdjacentElement("afterend", o)) : (this._button.insertBefore(i, this._button.firstChild), i.insertAdjacentElement("afterend", o)) : i && a === "right" ? t ? (t.insertAdjacentElement("afterend", o), o.insertAdjacentElement("afterend", i)) : (this._button.insertBefore(o, this._button.firstChild), o.insertAdjacentElement("afterend", i)) : t ? t.insertAdjacentElement("afterend", o) : this._button.insertBefore(o, this._button.firstChild);
|
|
127
|
-
} else if (i && i.tagName === "MINT-ICON" && !i.parentElement) {
|
|
128
|
-
let e = this._button.querySelector("mint-spinner")?.parentElement;
|
|
129
|
-
e ? e.insertAdjacentElement("afterend", i) : this._button.insertBefore(i, this._button.firstChild);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
let s = this.isIconOnly();
|
|
133
|
-
i && (i.classList.contains("mint-button-icon") || i.classList.add("mint-button-icon"), i.classList.remove("mint-icon-leading", "mint-icon-trailing"), s ? i.tagName === "MINT-ICON" ? (i.style.width = "1rem", i.style.height = "1rem", i.style.maxWidth = "1rem", i.style.maxHeight = "1rem", i.style.flexShrink = "0") : (i.style.maxWidth = "1rem", i.style.maxHeight = "1rem", i.style.flexShrink = "0", i.tagName === "svg" && (i.style.width = "1rem", i.style.height = "1rem")) : a === "left" ? i.classList.add("mint-icon-leading") : i.classList.add("mint-icon-trailing"));
|
|
134
|
-
let c = this.getButtonClasses();
|
|
135
|
-
this._button.className = c;
|
|
136
|
-
}
|
|
137
|
-
setupEventListeners() {
|
|
138
|
-
this._button && !this._clickHandler && (this._clickHandler = this.handleClick.bind(this), this._button.addEventListener("click", this._clickHandler, !0), this._button.addEventListener("mousedown", this._handleMouseDown), this._button.addEventListener("mouseup", this._handleMouseUp), this._button.addEventListener("mouseleave", this._handleMouseLeave), this._button.addEventListener("touchstart", this._handleTouchStart), this._button.addEventListener("touchend", this._handleTouchEnd), this._button.addEventListener("touchcancel", this._handleTouchCancel));
|
|
139
|
-
}
|
|
140
|
-
removeEventListeners() {
|
|
141
|
-
this._button && (this._clickHandler &&= (this._button.removeEventListener("click", this._clickHandler, !0), null), this._button.removeEventListener("mousedown", this._handleMouseDown), this._button.removeEventListener("mouseup", this._handleMouseUp), this._button.removeEventListener("mouseleave", this._handleMouseLeave), this._button.removeEventListener("touchstart", this._handleTouchStart), this._button.removeEventListener("touchend", this._handleTouchEnd), this._button.removeEventListener("touchcancel", this._handleTouchCancel));
|
|
142
|
-
}
|
|
143
|
-
_handleMouseDown = () => {
|
|
144
|
-
this._button && !this.isDisabled() && !this.isLoading() && this._button.classList.add("mint-button-active");
|
|
145
|
-
};
|
|
146
|
-
_handleMouseUp = () => {
|
|
147
|
-
this._button && this._button.classList.remove("mint-button-active");
|
|
148
|
-
};
|
|
149
|
-
_handleMouseLeave = () => {
|
|
150
|
-
this._button && this._button.classList.remove("mint-button-active");
|
|
151
|
-
};
|
|
152
|
-
_handleTouchStart = () => {
|
|
153
|
-
this._button && !this.isDisabled() && !this.isLoading() && this._button.classList.add("mint-button-active");
|
|
154
|
-
};
|
|
155
|
-
_handleTouchEnd = () => {
|
|
156
|
-
this._button && this._button.classList.remove("mint-button-active");
|
|
157
|
-
};
|
|
158
|
-
_handleTouchCancel = () => {
|
|
159
|
-
this._button && this._button.classList.remove("mint-button-active");
|
|
160
|
-
};
|
|
161
|
-
handleClick(e) {
|
|
162
|
-
if (this.isDisabled() || this.isLoading()) {
|
|
163
|
-
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (e.stopPropagation(), e.stopImmediatePropagation(), this._isHandlingClick) {
|
|
167
|
-
e.preventDefault();
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
this._isHandlingClick = !0, e.preventDefault(), this.dispatchEvent(new CustomEvent("click", {
|
|
171
|
-
detail: { originalEvent: e },
|
|
172
|
-
bubbles: !0,
|
|
173
|
-
cancelable: !0,
|
|
174
|
-
composed: !0
|
|
175
|
-
})), requestAnimationFrame(() => {
|
|
176
|
-
this._isHandlingClick = !1;
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
typeof customElements < "u" && !customElements.get("mint-button") && t("mint-button", n);
|
|
181
|
-
//#endregion
|
|
182
|
-
//#region src/components/back-button/BackButton.js
|
|
183
|
-
var r = class extends HTMLElement {
|
|
184
|
-
static get observedAttributes() {
|
|
185
|
-
return ["href", "fallback-href"];
|
|
186
|
-
}
|
|
187
|
-
constructor() {
|
|
188
|
-
super(), this._historyDepth = 0, this._maxBackAttempts = 10, this._backAttempts = 0;
|
|
189
|
-
}
|
|
190
|
-
connectedCallback() {
|
|
191
|
-
this.render(), this._setupHistoryTracking();
|
|
192
|
-
}
|
|
193
|
-
attributeChangedCallback(e, t, n) {
|
|
194
|
-
t !== n && this.render();
|
|
195
|
-
}
|
|
196
|
-
_setupHistoryTracking() {
|
|
197
|
-
window.addEventListener("popstate", () => {
|
|
198
|
-
this._backAttempts = 0;
|
|
199
|
-
}), this._historyDepth = window.history.length;
|
|
200
|
-
}
|
|
201
|
-
getFallbackHref() {
|
|
202
|
-
return this.getAttribute("fallback-href") || this.getAttribute("href") || "/";
|
|
203
|
-
}
|
|
204
|
-
handleClick(e) {
|
|
205
|
-
if (e.preventDefault(), e.stopPropagation(), window.history.length > 1 && this._backAttempts < this._maxBackAttempts && this._backAttempts === 0) {
|
|
206
|
-
this._backAttempts++;
|
|
207
|
-
let e = window.location.href, t = Date.now();
|
|
208
|
-
window.history.back(), setTimeout(() => {
|
|
209
|
-
Date.now() - t, window.location.href === e ? this._navigateToFallback() : setTimeout(() => {
|
|
210
|
-
this._backAttempts = 0;
|
|
211
|
-
}, 500);
|
|
212
|
-
}, 200);
|
|
213
|
-
} else this._navigateToFallback();
|
|
214
|
-
}
|
|
215
|
-
_navigateToFallback() {
|
|
216
|
-
let e = this.getFallbackHref();
|
|
217
|
-
if (this._backAttempts = 0, e.startsWith("/") && !e.startsWith("//")) try {
|
|
218
|
-
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
219
|
-
return;
|
|
220
|
-
} catch {}
|
|
221
|
-
window.location.href = e;
|
|
222
|
-
}
|
|
223
|
-
render() {
|
|
224
|
-
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));
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
typeof customElements < "u" && !customElements.get("mint-back-button") && t("mint-back-button", r);
|
|
228
|
-
//#endregion
|
|
229
|
-
export { r as default };
|
|
6
|
+
import { t as e } from "../chunks/back-button-CDyPYehm.js";
|
|
7
|
+
export { e as default };
|
|
@@ -14,5 +14,5 @@ __mintLoadStyle('theme', '../../theme.css')
|
|
|
14
14
|
__mintLoadStyle('spinner', '../../spinner.css')
|
|
15
15
|
__mintLoadStyle('icon', '../../icon.css')
|
|
16
16
|
__mintLoadStyle('button', '../../button.css')
|
|
17
|
-
import { t as e } from "../chunks/button
|
|
17
|
+
import { t as e } from "../chunks/button-BYkzR0uX.js";
|
|
18
18
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/button-
|
|
1
|
+
const e=require(`../chunks/button-DfY2Sr3-.js`);module.exports=e.t;
|
|
@@ -13,5 +13,5 @@ const __mintLoadStyle = (key, url) => {
|
|
|
13
13
|
__mintLoadStyle('theme', '../../theme.css')
|
|
14
14
|
__mintLoadStyle('icon', '../../icon.css')
|
|
15
15
|
__mintLoadStyle('chip', '../../chip.css')
|
|
16
|
-
import { t as e } from "../chunks/chip-
|
|
16
|
+
import { t as e } from "../chunks/chip-CLCBimJI.js";
|
|
17
17
|
export { e as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../chunks/chip-
|
|
1
|
+
const e=require(`../chunks/chip-Dfj3x__h.js`);module.exports=e.t;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { a as e } from "./icon-D9zLlMGu.js";
|
|
2
|
+
import { t } from "./register-element-BFYmIynH.js";
|
|
3
|
+
import "./icon-CkFfk0oc.js";
|
|
4
|
+
/* empty css */
|
|
5
|
+
import "./spinner-BjC3nA-C.js";
|
|
6
|
+
e({
|
|
7
|
+
name: "arrow-left",
|
|
8
|
+
viewBox: "0 0 24 24",
|
|
9
|
+
path: "M19 12H5m7-7l-7 7 7 7",
|
|
10
|
+
strokeLinecap: "round",
|
|
11
|
+
strokeLinejoin: "round"
|
|
12
|
+
});
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/components/button/Button.js
|
|
15
|
+
var n = class extends HTMLElement {
|
|
16
|
+
static get observedAttributes() {
|
|
17
|
+
return [
|
|
18
|
+
"variant",
|
|
19
|
+
"tone",
|
|
20
|
+
"disabled",
|
|
21
|
+
"loading",
|
|
22
|
+
"button-type",
|
|
23
|
+
"type",
|
|
24
|
+
"full-width",
|
|
25
|
+
"icon-position",
|
|
26
|
+
"icon"
|
|
27
|
+
];
|
|
28
|
+
}
|
|
29
|
+
constructor() {
|
|
30
|
+
super(), this._button = null, this._clickHandler = null, this._isHandlingClick = !1;
|
|
31
|
+
}
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
this.render(), this._button && this.setupEventListeners();
|
|
34
|
+
}
|
|
35
|
+
disconnectedCallback() {
|
|
36
|
+
this.removeEventListeners();
|
|
37
|
+
}
|
|
38
|
+
attributeChangedCallback(e, t, n) {
|
|
39
|
+
t !== n && this.render();
|
|
40
|
+
}
|
|
41
|
+
getVariant() {
|
|
42
|
+
return this.getAttribute("variant") || "solid";
|
|
43
|
+
}
|
|
44
|
+
getTone() {
|
|
45
|
+
return this.getAttribute("tone") || "neutral";
|
|
46
|
+
}
|
|
47
|
+
isDisabled() {
|
|
48
|
+
return this.hasAttribute("disabled");
|
|
49
|
+
}
|
|
50
|
+
isLoading() {
|
|
51
|
+
return this.hasAttribute("loading");
|
|
52
|
+
}
|
|
53
|
+
getType() {
|
|
54
|
+
return (this.getAttribute("type") || this.getAttribute("button-type") || "default") === "submit" ? "submit" : "button";
|
|
55
|
+
}
|
|
56
|
+
isFullWidth() {
|
|
57
|
+
return this.hasAttribute("full-width");
|
|
58
|
+
}
|
|
59
|
+
getIconPosition() {
|
|
60
|
+
return this.getAttribute("icon-position") || "left";
|
|
61
|
+
}
|
|
62
|
+
getIcon() {
|
|
63
|
+
return this.getAttribute("icon") || "";
|
|
64
|
+
}
|
|
65
|
+
isIconOnly() {
|
|
66
|
+
if (!(this.getIcon() || this._button?.querySelector("[slot=\"icon\"], .mint-button-icon, mint-icon"))) return !1;
|
|
67
|
+
let e = this._button?.querySelector(".mint-button-content");
|
|
68
|
+
if (e && e.textContent.trim()) return !1;
|
|
69
|
+
if (this._button) {
|
|
70
|
+
for (let e = this._button.firstChild; e; e = e.nextSibling) if (e.nodeType === Node.TEXT_NODE && e.textContent.trim() || e.nodeType === Node.ELEMENT_NODE && e.tagName !== "MINT-ICON" && e.tagName !== "MINT-SPINNER" && !e.querySelector?.("mint-spinner") && !e.hasAttribute?.("slot") && e.className !== "mint-button-icon" && !(e.className === "mr-2" && e.querySelector("mint-spinner")) && e.textContent.trim()) return !1;
|
|
71
|
+
}
|
|
72
|
+
return !0;
|
|
73
|
+
}
|
|
74
|
+
getButtonClasses() {
|
|
75
|
+
return [
|
|
76
|
+
"mint-button-core",
|
|
77
|
+
"mint-button-" + this.getVariant(),
|
|
78
|
+
"mint-button-tone-" + this.getTone(),
|
|
79
|
+
this.isIconOnly() ? "mint-button-icon-only" : "",
|
|
80
|
+
this.isFullWidth() ? "mint-button-full-width" : ""
|
|
81
|
+
].filter(Boolean).join(" ");
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
let e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
85
|
+
if (!this._button) {
|
|
86
|
+
for (this._button = document.createElement("button"); this.firstChild;) this._button.appendChild(this.firstChild);
|
|
87
|
+
this.appendChild(this._button), this.setupEventListeners();
|
|
88
|
+
}
|
|
89
|
+
this._button.type = t, this._button.disabled = e;
|
|
90
|
+
let n = this._button.querySelector("mint-spinner");
|
|
91
|
+
if (this.isLoading()) if (n) n.setAttribute("data-button-variant", this.getVariant()), n.setAttribute("data-button-tone", this.getTone()), n.render();
|
|
92
|
+
else {
|
|
93
|
+
let e = document.createElement("span");
|
|
94
|
+
e.className = "mint-spinner-wrap";
|
|
95
|
+
let t = document.createElement("mint-spinner");
|
|
96
|
+
t.setAttribute("size", "default"), t.setAttribute("data-button-variant", this.getVariant()), t.setAttribute("data-button-tone", this.getTone()), t.style.width = "0.875rem", t.style.height = "0.875rem", e.appendChild(t), this._button.insertBefore(e, this._button.firstChild);
|
|
97
|
+
}
|
|
98
|
+
else n && n.parentElement?.remove();
|
|
99
|
+
for (; this.firstChild && this.firstChild !== this._button;) this._button.appendChild(this.firstChild);
|
|
100
|
+
let r = this.getIcon(), i = this._button.querySelector("[slot=\"icon\"], .mint-button-icon, mint-icon");
|
|
101
|
+
r ? (i && i.tagName !== "MINT-ICON" && (i.remove(), i = null), !i || i.tagName !== "MINT-ICON" ? (i = document.createElement("mint-icon"), i.setAttribute("name", r), i.className = "mint-button-icon") : i.setAttribute("name", r)) : i && i.tagName === "MINT-ICON" && (i.remove(), i = null), i ||= this._button.querySelector("[slot=\"icon\"], .mint-button-icon");
|
|
102
|
+
let a = this.getIconPosition(), o = this._button.querySelector(".mint-button-content");
|
|
103
|
+
if (o) {
|
|
104
|
+
let e = i && i.tagName === "MINT-ICON";
|
|
105
|
+
if (i && !i.parentElement) {
|
|
106
|
+
let t = this._button.querySelector("mint-spinner")?.parentElement;
|
|
107
|
+
e || a === "left" ? t ? t.insertAdjacentElement("afterend", i) : this._button.insertBefore(i, o) : o.insertAdjacentElement("afterend", i);
|
|
108
|
+
} else if (i && (e || a === "left") && i.nextSibling !== o) {
|
|
109
|
+
i.remove();
|
|
110
|
+
let e = this._button.querySelector("mint-spinner")?.parentElement;
|
|
111
|
+
e ? e.insertAdjacentElement("afterend", i) : this._button.insertBefore(i, o);
|
|
112
|
+
} else i && !e && a === "right" && i.previousSibling !== o && (i.remove(), o.insertAdjacentElement("afterend", i));
|
|
113
|
+
} else {
|
|
114
|
+
let e = [];
|
|
115
|
+
for (let t = this._button.firstChild; t; t = t.nextSibling) t.tagName !== "MINT-SPINNER" && !t.querySelector?.("mint-spinner") && t !== i && !t.hasAttribute?.("slot") && !(t.className === "mr-2" && t.querySelector("mint-spinner")) && e.push(t);
|
|
116
|
+
if (e.length > 0) {
|
|
117
|
+
o = document.createElement("span"), o.className = "mint-button-content", e.forEach((e) => {
|
|
118
|
+
o.appendChild(e);
|
|
119
|
+
});
|
|
120
|
+
let t = this._button.querySelector("mint-spinner")?.parentElement;
|
|
121
|
+
i && a === "left" ? t ? (t.insertAdjacentElement("afterend", i), i.insertAdjacentElement("afterend", o)) : (this._button.insertBefore(i, this._button.firstChild), i.insertAdjacentElement("afterend", o)) : i && a === "right" ? t ? (t.insertAdjacentElement("afterend", o), o.insertAdjacentElement("afterend", i)) : (this._button.insertBefore(o, this._button.firstChild), o.insertAdjacentElement("afterend", i)) : t ? t.insertAdjacentElement("afterend", o) : this._button.insertBefore(o, this._button.firstChild);
|
|
122
|
+
} else if (i && i.tagName === "MINT-ICON" && !i.parentElement) {
|
|
123
|
+
let e = this._button.querySelector("mint-spinner")?.parentElement;
|
|
124
|
+
e ? e.insertAdjacentElement("afterend", i) : this._button.insertBefore(i, this._button.firstChild);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
let s = this.isIconOnly();
|
|
128
|
+
i && (i.classList.contains("mint-button-icon") || i.classList.add("mint-button-icon"), i.classList.remove("mint-icon-leading", "mint-icon-trailing"), s ? i.tagName === "MINT-ICON" ? (i.style.width = "1rem", i.style.height = "1rem", i.style.maxWidth = "1rem", i.style.maxHeight = "1rem", i.style.flexShrink = "0") : (i.style.maxWidth = "1rem", i.style.maxHeight = "1rem", i.style.flexShrink = "0", i.tagName === "svg" && (i.style.width = "1rem", i.style.height = "1rem")) : a === "left" ? i.classList.add("mint-icon-leading") : i.classList.add("mint-icon-trailing"));
|
|
129
|
+
let c = this.getButtonClasses();
|
|
130
|
+
this._button.className = c;
|
|
131
|
+
}
|
|
132
|
+
setupEventListeners() {
|
|
133
|
+
this._button && !this._clickHandler && (this._clickHandler = this.handleClick.bind(this), this._button.addEventListener("click", this._clickHandler, !0), this._button.addEventListener("mousedown", this._handleMouseDown), this._button.addEventListener("mouseup", this._handleMouseUp), this._button.addEventListener("mouseleave", this._handleMouseLeave), this._button.addEventListener("touchstart", this._handleTouchStart), this._button.addEventListener("touchend", this._handleTouchEnd), this._button.addEventListener("touchcancel", this._handleTouchCancel));
|
|
134
|
+
}
|
|
135
|
+
removeEventListeners() {
|
|
136
|
+
this._button && (this._clickHandler &&= (this._button.removeEventListener("click", this._clickHandler, !0), null), this._button.removeEventListener("mousedown", this._handleMouseDown), this._button.removeEventListener("mouseup", this._handleMouseUp), this._button.removeEventListener("mouseleave", this._handleMouseLeave), this._button.removeEventListener("touchstart", this._handleTouchStart), this._button.removeEventListener("touchend", this._handleTouchEnd), this._button.removeEventListener("touchcancel", this._handleTouchCancel));
|
|
137
|
+
}
|
|
138
|
+
_handleMouseDown = () => {
|
|
139
|
+
this._button && !this.isDisabled() && !this.isLoading() && this._button.classList.add("mint-button-active");
|
|
140
|
+
};
|
|
141
|
+
_handleMouseUp = () => {
|
|
142
|
+
this._button && this._button.classList.remove("mint-button-active");
|
|
143
|
+
};
|
|
144
|
+
_handleMouseLeave = () => {
|
|
145
|
+
this._button && this._button.classList.remove("mint-button-active");
|
|
146
|
+
};
|
|
147
|
+
_handleTouchStart = () => {
|
|
148
|
+
this._button && !this.isDisabled() && !this.isLoading() && this._button.classList.add("mint-button-active");
|
|
149
|
+
};
|
|
150
|
+
_handleTouchEnd = () => {
|
|
151
|
+
this._button && this._button.classList.remove("mint-button-active");
|
|
152
|
+
};
|
|
153
|
+
_handleTouchCancel = () => {
|
|
154
|
+
this._button && this._button.classList.remove("mint-button-active");
|
|
155
|
+
};
|
|
156
|
+
handleClick(e) {
|
|
157
|
+
if (this.isDisabled() || this.isLoading()) {
|
|
158
|
+
e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation();
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
if (e.stopPropagation(), e.stopImmediatePropagation(), this._isHandlingClick) {
|
|
162
|
+
e.preventDefault();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
this._isHandlingClick = !0, e.preventDefault(), this.dispatchEvent(new CustomEvent("click", {
|
|
166
|
+
detail: { originalEvent: e },
|
|
167
|
+
bubbles: !0,
|
|
168
|
+
cancelable: !0,
|
|
169
|
+
composed: !0
|
|
170
|
+
})), requestAnimationFrame(() => {
|
|
171
|
+
this._isHandlingClick = !1;
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
typeof customElements < "u" && !customElements.get("mint-button") && t("mint-button", n);
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/components/back-button/BackButton.js
|
|
178
|
+
var r = class extends HTMLElement {
|
|
179
|
+
static get observedAttributes() {
|
|
180
|
+
return ["href", "fallback-href"];
|
|
181
|
+
}
|
|
182
|
+
constructor() {
|
|
183
|
+
super(), this._historyDepth = 0, this._maxBackAttempts = 10, this._backAttempts = 0;
|
|
184
|
+
}
|
|
185
|
+
connectedCallback() {
|
|
186
|
+
this.render(), this._setupHistoryTracking();
|
|
187
|
+
}
|
|
188
|
+
attributeChangedCallback(e, t, n) {
|
|
189
|
+
t !== n && this.render();
|
|
190
|
+
}
|
|
191
|
+
_setupHistoryTracking() {
|
|
192
|
+
window.addEventListener("popstate", () => {
|
|
193
|
+
this._backAttempts = 0;
|
|
194
|
+
}), this._historyDepth = window.history.length;
|
|
195
|
+
}
|
|
196
|
+
getFallbackHref() {
|
|
197
|
+
return this.getAttribute("fallback-href") || this.getAttribute("href") || "/";
|
|
198
|
+
}
|
|
199
|
+
handleClick(e) {
|
|
200
|
+
if (e.preventDefault(), e.stopPropagation(), window.history.length > 1 && this._backAttempts < this._maxBackAttempts && this._backAttempts === 0) {
|
|
201
|
+
this._backAttempts++;
|
|
202
|
+
let e = window.location.href, t = Date.now();
|
|
203
|
+
window.history.back(), setTimeout(() => {
|
|
204
|
+
Date.now() - t, window.location.href === e ? this._navigateToFallback() : setTimeout(() => {
|
|
205
|
+
this._backAttempts = 0;
|
|
206
|
+
}, 500);
|
|
207
|
+
}, 200);
|
|
208
|
+
} else this._navigateToFallback();
|
|
209
|
+
}
|
|
210
|
+
_navigateToFallback() {
|
|
211
|
+
let e = this.getFallbackHref();
|
|
212
|
+
if (this._backAttempts = 0, e.startsWith("/") && !e.startsWith("//")) try {
|
|
213
|
+
window.history.pushState({}, "", e), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
214
|
+
return;
|
|
215
|
+
} catch {}
|
|
216
|
+
window.location.href = e;
|
|
217
|
+
}
|
|
218
|
+
render() {
|
|
219
|
+
this._button || (this._button = document.createElement("mint-button"), this._button.setAttribute("variant", "solid"), this._button.setAttribute("tone", "neutral"), this._button.setAttribute("icon", "arrow-left"), this._button.setAttribute("aria-label", this.getAttribute("aria-label") || "Go back"), this._button.addEventListener("click", (e) => this.handleClick(e)), this.appendChild(this._button));
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
typeof customElements < "u" && !customElements.get("mint-back-button") && t("mint-back-button", r);
|
|
223
|
+
//#endregion
|
|
224
|
+
export { r as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./icon-DgBiEDoy.js`),t=require(`./register-element-tCL_F1YI.js`);require(`./icon-BwaKFl4e.js`),/* empty css */require(`./spinner-DfPbEa2d.js`),e.a({name:`arrow-left`,viewBox:`0 0 24 24`,path:`M19 12H5m7-7l-7 7 7 7`,strokeLinecap:`round`,strokeLinejoin:`round`});var n=class extends HTMLElement{static get observedAttributes(){return[`variant`,`tone`,`disabled`,`loading`,`button-type`,`type`,`full-width`,`icon-position`,`icon`]}constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1}connectedCallback(){this.render(),this._button&&this.setupEventListeners()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getVariant(){return this.getAttribute(`variant`)||`solid`}getTone(){return this.getAttribute(`tone`)||`neutral`}isDisabled(){return this.hasAttribute(`disabled`)}isLoading(){return this.hasAttribute(`loading`)}getType(){return(this.getAttribute(`type`)||this.getAttribute(`button-type`)||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.hasAttribute(`full-width`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}isIconOnly(){if(!(this.getIcon()||this._button?.querySelector(`[slot="icon"], .mint-button-icon, mint-icon`)))return!1;let e=this._button?.querySelector(`.mint-button-content`);if(e&&e.textContent.trim())return!1;if(this._button){for(let e=this._button.firstChild;e;e=e.nextSibling)if(e.nodeType===Node.TEXT_NODE&&e.textContent.trim()||e.nodeType===Node.ELEMENT_NODE&&e.tagName!==`MINT-ICON`&&e.tagName!==`MINT-SPINNER`&&!e.querySelector?.(`mint-spinner`)&&!e.hasAttribute?.(`slot`)&&e.className!==`mint-button-icon`&&!(e.className===`mr-2`&&e.querySelector(`mint-spinner`))&&e.textContent.trim())return!1}return!0}getButtonClasses(){return[`mint-button-core`,`mint-button-`+this.getVariant(),`mint-button-tone-`+this.getTone(),this.isIconOnly()?`mint-button-icon-only`:``,this.isFullWidth()?`mint-button-full-width`:``].filter(Boolean).join(` `)}render(){let e=this.isDisabled()||this.isLoading(),t=this.getType();if(!this._button){for(this._button=document.createElement(`button`);this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=t,this._button.disabled=e;let n=this._button.querySelector(`mint-spinner`);if(this.isLoading())if(n)n.setAttribute(`data-button-variant`,this.getVariant()),n.setAttribute(`data-button-tone`,this.getTone()),n.render();else{let e=document.createElement(`span`);e.className=`mint-spinner-wrap`;let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`default`),t.setAttribute(`data-button-variant`,this.getVariant()),t.setAttribute(`data-button-tone`,this.getTone()),t.style.width=`0.875rem`,t.style.height=`0.875rem`,e.appendChild(t),this._button.insertBefore(e,this._button.firstChild)}else n&&n.parentElement?.remove();for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);let r=this.getIcon(),i=this._button.querySelector(`[slot="icon"], .mint-button-icon, mint-icon`);r?(i&&i.tagName!==`MINT-ICON`&&(i.remove(),i=null),!i||i.tagName!==`MINT-ICON`?(i=document.createElement(`mint-icon`),i.setAttribute(`name`,r),i.className=`mint-button-icon`):i.setAttribute(`name`,r)):i&&i.tagName===`MINT-ICON`&&(i.remove(),i=null),i||=this._button.querySelector(`[slot="icon"], .mint-button-icon`);let a=this.getIconPosition(),o=this._button.querySelector(`.mint-button-content`);if(o){let e=i&&i.tagName===`MINT-ICON`;if(i&&!i.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||a===`left`?t?t.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,o):o.insertAdjacentElement(`afterend`,i)}else if(i&&(e||a===`left`)&&i.nextSibling!==o){i.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,o)}else i&&!e&&a===`right`&&i.previousSibling!==o&&(i.remove(),o.insertAdjacentElement(`afterend`,i))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling)t.tagName!==`MINT-SPINNER`&&!t.querySelector?.(`mint-spinner`)&&t!==i&&!t.hasAttribute?.(`slot`)&&!(t.className===`mr-2`&&t.querySelector(`mint-spinner`))&&e.push(t);if(e.length>0){o=document.createElement(`span`),o.className=`mint-button-content`,e.forEach(e=>{o.appendChild(e)});let t=this._button.querySelector(`mint-spinner`)?.parentElement;i&&a===`left`?t?(t.insertAdjacentElement(`afterend`,i),i.insertAdjacentElement(`afterend`,o)):(this._button.insertBefore(i,this._button.firstChild),i.insertAdjacentElement(`afterend`,o)):i&&a===`right`?t?(t.insertAdjacentElement(`afterend`,o),o.insertAdjacentElement(`afterend`,i)):(this._button.insertBefore(o,this._button.firstChild),o.insertAdjacentElement(`afterend`,i)):t?t.insertAdjacentElement(`afterend`,o):this._button.insertBefore(o,this._button.firstChild)}else if(i&&i.tagName===`MINT-ICON`&&!i.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,this._button.firstChild)}}let s=this.isIconOnly();i&&(i.classList.contains(`mint-button-icon`)||i.classList.add(`mint-button-icon`),i.classList.remove(`mint-icon-leading`,`mint-icon-trailing`),s?i.tagName===`MINT-ICON`?(i.style.width=`1rem`,i.style.height=`1rem`,i.style.maxWidth=`1rem`,i.style.maxHeight=`1rem`,i.style.flexShrink=`0`):(i.style.maxWidth=`1rem`,i.style.maxHeight=`1rem`,i.style.flexShrink=`0`,i.tagName===`svg`&&(i.style.width=`1rem`,i.style.height=`1rem`)):a===`left`?i.classList.add(`mint-icon-leading`):i.classList.add(`mint-icon-trailing`));let c=this.getButtonClasses();this._button.className=c}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._button.addEventListener(`click`,this._clickHandler,!0),this._button.addEventListener(`mousedown`,this._handleMouseDown),this._button.addEventListener(`mouseup`,this._handleMouseUp),this._button.addEventListener(`mouseleave`,this._handleMouseLeave),this._button.addEventListener(`touchstart`,this._handleTouchStart),this._button.addEventListener(`touchend`,this._handleTouchEnd),this._button.addEventListener(`touchcancel`,this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&=(this._button.removeEventListener(`click`,this._clickHandler,!0),null),this._button.removeEventListener(`mousedown`,this._handleMouseDown),this._button.removeEventListener(`mouseup`,this._handleMouseUp),this._button.removeEventListener(`mouseleave`,this._handleMouseLeave),this._button.removeEventListener(`touchstart`,this._handleTouchStart),this._button.removeEventListener(`touchend`,this._handleTouchEnd),this._button.removeEventListener(`touchcancel`,this._handleTouchCancel))}_handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)};_handleMouseUp=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleMouseLeave=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)};_handleTouchEnd=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleTouchCancel=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};handleClick(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent(`click`,{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};typeof customElements<`u`&&!customElements.get(`mint-button`)&&t.t(`mint-button`,n);var r=class extends HTMLElement{static get observedAttributes(){return[`href`,`fallback-href`]}constructor(){super(),this._historyDepth=0,this._maxBackAttempts=10,this._backAttempts=0}connectedCallback(){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(`//`))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`,`solid`),this._button.setAttribute(`tone`,`neutral`),this._button.setAttribute(`icon`,`arrow-left`),this._button.setAttribute(`aria-label`,this.getAttribute(`aria-label`)||`Go back`),this._button.addEventListener(`click`,e=>this.handleClick(e)),this.appendChild(this._button))}};typeof customElements<`u`&&!customElements.get(`mint-back-button`)&&t.t(`mint-back-button`,r),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
@@ -2,7 +2,7 @@ import "./icon-D9zLlMGu.js";
|
|
|
2
2
|
import { t as e } from "./register-element-BFYmIynH.js";
|
|
3
3
|
import "./icon-CkFfk0oc.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import "./spinner-
|
|
5
|
+
import "./spinner-BjC3nA-C.js";
|
|
6
6
|
//#region src/components/button/Button.ts
|
|
7
7
|
var t = class extends HTMLElement {
|
|
8
8
|
static get observedAttributes() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require(`./icon-DgBiEDoy.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./icon-BwaKFl4e.js`),/* empty css */require(`./spinner-DbTohC6i.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`variant`,`tone`,`disabled`,`loading`,`button-type`,`type`,`full-width`,`icon-position`,`icon`,`active`,`align`,`aria-label`]}constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1,this._mousePressed=!1,this._hostChildObserver=null,this._hostRenderFromObserverRaf=null,this._handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&(this._button.classList.add(`mint-button-active`),this._mousePressed||(this._mousePressed=!0,document.addEventListener(`mouseup`,this._handleMouseUp),window.addEventListener(`blur`,this._handleMouseCancel)))},this._handleMouseUp=()=>{this._clearMousePressedState()},this._handleMouseCancel=()=>{this._clearMousePressedState()},this._handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)},this._handleTouchEnd=()=>{this._button&&(this.isActive()||this._button.classList.remove(`mint-button-active`))},this._handleTouchCancel=()=>{this._button&&(this.isActive()||this._button.classList.remove(`mint-button-active`))}}_getGeneratedIcon(){return this._button?this._button.querySelector(`:scope > [data-generated-icon="true"]`):null}_getContentWrapperClass(e){return`mint-button-content`}connectedCallback(){this.render(),this._button&&this.setupEventListeners()}disconnectedCallback(){this._disconnectHostChildObserver(),this._hostRenderFromObserverRaf!==null&&(cancelAnimationFrame(this._hostRenderFromObserverRaf),this._hostRenderFromObserverRaf=null),this.removeEventListeners(),this._clearMousePressedState()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getVariant(){let e=this.getAttribute(`variant`);return e===`ghost`||e===`outline`?e:`solid`}getTone(){return this.getAttribute(`tone`)||`neutral`}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}getType(){let e=this.getAttribute(`type`),t=this.getAttribute(`button-type`);return(e||t||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.getAttribute(`full-width`)===`true`}isActive(){return this.getAttribute(`active`)===`true`}get active(){return this.isActive()}set active(e){e?this.setAttribute(`active`,`true`):this.removeAttribute(`active`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}getAlignment(){let e=this.getAttribute(`align`);return e===`left`||e===`center`||e===`right`?e:`center`}isIconOnly(){if(!(this.getIcon()||this._getGeneratedIcon()||this._button?.querySelector(`mint-icon`)))return!1;let e=this._button?.querySelector(`.mint-button-content`);if(e&&e.textContent?.trim())return!1;if(this._button)for(let e=this._button.firstChild;e;e=e.nextSibling){if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!1;if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.tagName!==`MINT-ICON`&&t.tagName!==`MINT-SPINNER`&&!t.querySelector(`mint-spinner`)&&!t.hasAttribute(`slot`)&&t.className!==`mint-button-icon`&&!(t.classList.contains(`mint-button-spinner-wrap`)&&t.querySelector(`mint-spinner`))&&t.textContent?.trim())return!1}}return!0}getActiveStateClasses(){let e=`${this.getVariant()}-${this.getTone()}`;return{"solid-action":[`!bg-neutral-900`,`dark:!bg-neutral-700`,`hover:!bg-neutral-900`,`dark:hover:!bg-neutral-700`,`!border-t-neutral-900`,`!border-l-neutral-900`,`!border-r-neutral-600`,`!border-b-neutral-600`,`dark:!border-t-neutral-700`,`dark:!border-l-neutral-700`,`dark:!border-r-neutral-500`,`dark:!border-b-neutral-500`],"solid-neutral":[`!bg-gray-100`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`!border-t-gray-400`,`!border-l-gray-400`,`!border-r-gray-200`,`!border-b-gray-200`,`dark:!border-t-gray-950`,`dark:!border-l-gray-950`,`dark:!border-r-mint-divider`,`dark:!border-b-mint-divider`],"solid-info":[`!bg-blue-900`,`dark:!bg-blue-700`,`hover:!bg-blue-900`,`dark:hover:!bg-blue-700`,`!border-t-blue-900`,`!border-l-blue-900`,`!border-r-blue-600`,`!border-b-blue-600`,`dark:!border-t-blue-700`,`dark:!border-l-blue-700`,`dark:!border-r-blue-500`,`dark:!border-b-blue-500`],"solid-warning":[`!bg-amber-900`,`dark:!bg-amber-700`,`hover:!bg-amber-900`,`dark:hover:!bg-amber-700`,`!border-t-amber-900`,`!border-l-amber-900`,`!border-r-amber-600`,`!border-b-amber-600`,`dark:!border-t-amber-700`,`dark:!border-l-amber-700`,`dark:!border-r-amber-500`,`dark:!border-b-amber-500`],"solid-danger":[`!bg-red-900`,`dark:!bg-red-700`,`hover:!bg-red-900`,`dark:hover:!bg-red-700`,`!border-t-red-900`,`!border-l-red-900`,`!border-r-red-600`,`!border-b-red-600`,`dark:!border-t-red-700`,`dark:!border-l-red-700`,`dark:!border-r-red-500`,`dark:!border-b-red-500`],"ghost-action":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-neutral":[`!bg-gray-50`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`!text-gray-900`,`dark:!text-white`,`hover:!bg-gray-50`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`hover:!text-gray-900`,`dark:hover:!text-white`],"ghost-info":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-warning":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-danger":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`]}[e]||[]}_disconnectHostChildObserver(){this._hostChildObserver?.disconnect()}_connectHostChildObserver(){this.isConnected&&(this._hostChildObserver||=new MutationObserver(e=>{this._onLightDomMutation(e)}),this._hostChildObserver.disconnect(),this._hostChildObserver.observe(this,{childList:!0,subtree:!0,characterData:!0}))}_onLightDomMutation(e){if(this.isConnected){if(this._button&&!this._button.isConnected){this._button=null,this._scheduleRenderFromHostObserver();return}for(let t of e){let e=t.target;if(!(this._button&&(e===this._button||this._button.contains(e)))){this._scheduleRenderFromHostObserver();return}}}}_scheduleRenderFromHostObserver(){this._hostRenderFromObserverRaf===null&&(this._hostRenderFromObserverRaf=requestAnimationFrame(()=>{this._hostRenderFromObserverRaf=null,this.isConnected&&this.render()}))}getButtonClasses(){let e=[`mint-button-core`,`mint-button-${this.getVariant()}`,`mint-button-tone-${this.getTone()}`];return this.isIconOnly()&&e.push(`mint-button-icon-only`),this.isFullWidth()&&e.push(`mint-button-full-width`),e.join(` `)}render(){this._disconnectHostChildObserver(),this._button&&!this._button.isConnected&&(this._button=null);try{let e=this.isLoading(),t=this.isDisabled()||e,n=this.getType();if(!this._button){let e=this.firstElementChild;if(e instanceof HTMLButtonElement)this._button=e;else{for(this._button=document.createElement(`button`);this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button)}this.setupEventListeners()}this._button.type=n,this._button.disabled=t,this._button.setAttribute(`aria-busy`,String(e));let r=this._button.querySelector(`mint-spinner`);if(e)if(r)r.setAttribute(`data-button-variant`,this.getVariant()),r.setAttribute(`data-button-tone`,this.getTone()),`render`in r&&typeof r.render==`function`&&r.render();else{let e=document.createElement(`span`);e.className=`mint-button-spinner-wrap`;let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`default`),t.setAttribute(`data-button-variant`,this.getVariant()),t.setAttribute(`data-button-tone`,this.getTone()),t.style.width=`0.875rem`,t.style.height=`0.875rem`,e.appendChild(t),this._button.insertBefore(e,this._button.firstChild)}else r&&r.parentElement?.remove();for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);let i=this.getIcon(),a=this._getGeneratedIcon();i?(a||(a=document.createElement(`mint-icon`),a.setAttribute(`data-generated-icon`,`true`),a.className=`mint-button-icon`),a.setAttribute(`name`,i)):a&&a.tagName===`MINT-ICON`&&(a.remove(),a=null);let o=this.getIconPosition(),s=this._button.querySelector(`.mint-button-content`);if(s){s.className=this._getContentWrapperClass(s);let e=a&&a.tagName===`MINT-ICON`;if(a&&!a.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||o===`left`?t?t.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s):s.insertAdjacentElement(`afterend`,a)}else if(a&&(e||o===`left`)&&a.nextSibling!==s){a.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s)}else a&&!e&&o===`right`&&a.previousSibling!==s&&(a.remove(),s.insertAdjacentElement(`afterend`,a))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling){if(t.nodeType!==Node.ELEMENT_NODE){e.push(t);continue}let n=t;n.tagName!==`MINT-SPINNER`&&!n.querySelector(`mint-spinner`)&&t!==a&&!n.hasAttribute(`slot`)&&!(n.classList.contains(`mint-button-spinner-wrap`)&&n.querySelector(`mint-spinner`))&&e.push(t)}if(e.length>0){s=document.createElement(`span`),s.className=this._getContentWrapperClass(s),e.forEach(e=>{s.appendChild(e)}),s.className=this._getContentWrapperClass(s);let t=this._button.querySelector(`mint-spinner`)?.parentElement;a&&o===`left`?t?(t.insertAdjacentElement(`afterend`,a),a.insertAdjacentElement(`afterend`,s)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement(`afterend`,s)):a&&o===`right`?t?(t.insertAdjacentElement(`afterend`,s),s.insertAdjacentElement(`afterend`,a)):(this._button.insertBefore(s,this._button.firstChild),s.insertAdjacentElement(`afterend`,a)):t?t.insertAdjacentElement(`afterend`,s):this._button.insertBefore(s,this._button.firstChild)}else if(a&&a.tagName===`MINT-ICON`&&!a.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,this._button.firstChild)}}let c=this.isIconOnly();if(a&&(a.classList.contains(`mint-button-icon`)||a.classList.add(`mint-button-icon`),e?a.style.display=`none`:a.style.display=``,a.setAttribute(`data-position`,o),a.toggleAttribute(`data-icon-only`,c),c&&(a.tagName===`MINT-ICON`?(a.style.width=`1em`,a.style.height=`1em`,a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`):(a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`,a.tagName===`svg`&&(a.style.width=`1em`,a.style.height=`1em`)))),e){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e&&(c?e.setAttribute(`data-icon-only`,`true`):e.removeAttribute(`data-icon-only`))}let l=this.getButtonClasses();this._button.className=l;let u=this.getAttribute(`aria-label`)?.trim();if(u)this._button.setAttribute(`aria-label`,u);else if(this.isIconOnly()){let e=this.getIcon().split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);this._button.setAttribute(`aria-label`,e||`Action`)}else this._button.removeAttribute(`aria-label`);this.hasAttribute(`active`)?this._button.setAttribute(`aria-pressed`,String(this.isActive())):this._button.removeAttribute(`aria-pressed`),this.setAttribute(`data-variant`,this.getVariant()),this.setAttribute(`data-tone`,this.getTone()),this._button.setAttribute(`data-variant`,this.getVariant()),this._button.setAttribute(`data-align`,this.getAlignment()),this._button.toggleAttribute(`data-icon-only`,c),e?this._button.setAttribute(`data-loading`,`true`):this._button.removeAttribute(`data-loading`),this.isActive()?this._button.classList.add(`mint-button-active`):this._button.classList.remove(`mint-button-active`)}finally{queueMicrotask(()=>{this.isConnected&&this._connectHostChildObserver()})}}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener(`click`,this._clickHandler,!0),this._button.addEventListener(`mousedown`,this._handleMouseDown),this._button.addEventListener(`touchstart`,this._handleTouchStart),this._button.addEventListener(`touchend`,this._handleTouchEnd),this._button.addEventListener(`touchcancel`,this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&=(this._button.removeEventListener(`click`,this._clickHandler,!0),null),this._button.removeEventListener(`mousedown`,this._handleMouseDown),this._button.removeEventListener(`touchstart`,this._handleTouchStart),this._button.removeEventListener(`touchend`,this._handleTouchEnd),this._button.removeEventListener(`touchcancel`,this._handleTouchCancel))}_clearMousePressedState(){this._mousePressed&&(this._mousePressed=!1,document.removeEventListener(`mouseup`,this._handleMouseUp),window.removeEventListener(`blur`,this._handleMouseCancel)),this._button&&(this.isActive()||this._button.classList.remove(`mint-button-active`))}handleClick(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(this.getType()===`submit`){this.dispatchEvent(new CustomEvent(`click`,{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0}));return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent(`click`,{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};customElements.get(`mint-button`)||e.t(`mint-button`,t),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
1
|
+
require(`./icon-DgBiEDoy.js`);const e=require(`./register-element-tCL_F1YI.js`);require(`./icon-BwaKFl4e.js`),/* empty css */require(`./spinner-DfPbEa2d.js`);var t=class extends HTMLElement{static get observedAttributes(){return[`variant`,`tone`,`disabled`,`loading`,`button-type`,`type`,`full-width`,`icon-position`,`icon`,`active`,`align`,`aria-label`]}constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1,this._mousePressed=!1,this._hostChildObserver=null,this._hostRenderFromObserverRaf=null,this._handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&(this._button.classList.add(`mint-button-active`),this._mousePressed||(this._mousePressed=!0,document.addEventListener(`mouseup`,this._handleMouseUp),window.addEventListener(`blur`,this._handleMouseCancel)))},this._handleMouseUp=()=>{this._clearMousePressedState()},this._handleMouseCancel=()=>{this._clearMousePressedState()},this._handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)},this._handleTouchEnd=()=>{this._button&&(this.isActive()||this._button.classList.remove(`mint-button-active`))},this._handleTouchCancel=()=>{this._button&&(this.isActive()||this._button.classList.remove(`mint-button-active`))}}_getGeneratedIcon(){return this._button?this._button.querySelector(`:scope > [data-generated-icon="true"]`):null}_getContentWrapperClass(e){return`mint-button-content`}connectedCallback(){this.render(),this._button&&this.setupEventListeners()}disconnectedCallback(){this._disconnectHostChildObserver(),this._hostRenderFromObserverRaf!==null&&(cancelAnimationFrame(this._hostRenderFromObserverRaf),this._hostRenderFromObserverRaf=null),this.removeEventListeners(),this._clearMousePressedState()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getVariant(){let e=this.getAttribute(`variant`);return e===`ghost`||e===`outline`?e:`solid`}getTone(){return this.getAttribute(`tone`)||`neutral`}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}getType(){let e=this.getAttribute(`type`),t=this.getAttribute(`button-type`);return(e||t||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.getAttribute(`full-width`)===`true`}isActive(){return this.getAttribute(`active`)===`true`}get active(){return this.isActive()}set active(e){e?this.setAttribute(`active`,`true`):this.removeAttribute(`active`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}getAlignment(){let e=this.getAttribute(`align`);return e===`left`||e===`center`||e===`right`?e:`center`}isIconOnly(){if(!(this.getIcon()||this._getGeneratedIcon()||this._button?.querySelector(`mint-icon`)))return!1;let e=this._button?.querySelector(`.mint-button-content`);if(e&&e.textContent?.trim())return!1;if(this._button)for(let e=this._button.firstChild;e;e=e.nextSibling){if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!1;if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.tagName!==`MINT-ICON`&&t.tagName!==`MINT-SPINNER`&&!t.querySelector(`mint-spinner`)&&!t.hasAttribute(`slot`)&&t.className!==`mint-button-icon`&&!(t.classList.contains(`mint-button-spinner-wrap`)&&t.querySelector(`mint-spinner`))&&t.textContent?.trim())return!1}}return!0}getActiveStateClasses(){let e=`${this.getVariant()}-${this.getTone()}`;return{"solid-action":[`!bg-neutral-900`,`dark:!bg-neutral-700`,`hover:!bg-neutral-900`,`dark:hover:!bg-neutral-700`,`!border-t-neutral-900`,`!border-l-neutral-900`,`!border-r-neutral-600`,`!border-b-neutral-600`,`dark:!border-t-neutral-700`,`dark:!border-l-neutral-700`,`dark:!border-r-neutral-500`,`dark:!border-b-neutral-500`],"solid-neutral":[`!bg-gray-100`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`!border-t-gray-400`,`!border-l-gray-400`,`!border-r-gray-200`,`!border-b-gray-200`,`dark:!border-t-gray-950`,`dark:!border-l-gray-950`,`dark:!border-r-mint-divider`,`dark:!border-b-mint-divider`],"solid-info":[`!bg-blue-900`,`dark:!bg-blue-700`,`hover:!bg-blue-900`,`dark:hover:!bg-blue-700`,`!border-t-blue-900`,`!border-l-blue-900`,`!border-r-blue-600`,`!border-b-blue-600`,`dark:!border-t-blue-700`,`dark:!border-l-blue-700`,`dark:!border-r-blue-500`,`dark:!border-b-blue-500`],"solid-warning":[`!bg-amber-900`,`dark:!bg-amber-700`,`hover:!bg-amber-900`,`dark:hover:!bg-amber-700`,`!border-t-amber-900`,`!border-l-amber-900`,`!border-r-amber-600`,`!border-b-amber-600`,`dark:!border-t-amber-700`,`dark:!border-l-amber-700`,`dark:!border-r-amber-500`,`dark:!border-b-amber-500`],"solid-danger":[`!bg-red-900`,`dark:!bg-red-700`,`hover:!bg-red-900`,`dark:hover:!bg-red-700`,`!border-t-red-900`,`!border-l-red-900`,`!border-r-red-600`,`!border-b-red-600`,`dark:!border-t-red-700`,`dark:!border-l-red-700`,`dark:!border-r-red-500`,`dark:!border-b-red-500`],"ghost-action":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-neutral":[`!bg-gray-50`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`!text-gray-900`,`dark:!text-white`,`hover:!bg-gray-50`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`hover:!text-gray-900`,`dark:hover:!text-white`],"ghost-info":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-warning":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-danger":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`]}[e]||[]}_disconnectHostChildObserver(){this._hostChildObserver?.disconnect()}_connectHostChildObserver(){this.isConnected&&(this._hostChildObserver||=new MutationObserver(e=>{this._onLightDomMutation(e)}),this._hostChildObserver.disconnect(),this._hostChildObserver.observe(this,{childList:!0,subtree:!0,characterData:!0}))}_onLightDomMutation(e){if(this.isConnected){if(this._button&&!this._button.isConnected){this._button=null,this._scheduleRenderFromHostObserver();return}for(let t of e){let e=t.target;if(!(this._button&&(e===this._button||this._button.contains(e)))){this._scheduleRenderFromHostObserver();return}}}}_scheduleRenderFromHostObserver(){this._hostRenderFromObserverRaf===null&&(this._hostRenderFromObserverRaf=requestAnimationFrame(()=>{this._hostRenderFromObserverRaf=null,this.isConnected&&this.render()}))}getButtonClasses(){let e=[`mint-button-core`,`mint-button-${this.getVariant()}`,`mint-button-tone-${this.getTone()}`];return this.isIconOnly()&&e.push(`mint-button-icon-only`),this.isFullWidth()&&e.push(`mint-button-full-width`),e.join(` `)}render(){this._disconnectHostChildObserver(),this._button&&!this._button.isConnected&&(this._button=null);try{let e=this.isLoading(),t=this.isDisabled()||e,n=this.getType();if(!this._button){let e=this.firstElementChild;if(e instanceof HTMLButtonElement)this._button=e;else{for(this._button=document.createElement(`button`);this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button)}this.setupEventListeners()}this._button.type=n,this._button.disabled=t,this._button.setAttribute(`aria-busy`,String(e));let r=this._button.querySelector(`mint-spinner`);if(e)if(r)r.setAttribute(`data-button-variant`,this.getVariant()),r.setAttribute(`data-button-tone`,this.getTone()),`render`in r&&typeof r.render==`function`&&r.render();else{let e=document.createElement(`span`);e.className=`mint-button-spinner-wrap`;let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`default`),t.setAttribute(`data-button-variant`,this.getVariant()),t.setAttribute(`data-button-tone`,this.getTone()),t.style.width=`0.875rem`,t.style.height=`0.875rem`,e.appendChild(t),this._button.insertBefore(e,this._button.firstChild)}else r&&r.parentElement?.remove();for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);let i=this.getIcon(),a=this._getGeneratedIcon();i?(a||(a=document.createElement(`mint-icon`),a.setAttribute(`data-generated-icon`,`true`),a.className=`mint-button-icon`),a.setAttribute(`name`,i)):a&&a.tagName===`MINT-ICON`&&(a.remove(),a=null);let o=this.getIconPosition(),s=this._button.querySelector(`.mint-button-content`);if(s){s.className=this._getContentWrapperClass(s);let e=a&&a.tagName===`MINT-ICON`;if(a&&!a.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||o===`left`?t?t.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s):s.insertAdjacentElement(`afterend`,a)}else if(a&&(e||o===`left`)&&a.nextSibling!==s){a.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s)}else a&&!e&&o===`right`&&a.previousSibling!==s&&(a.remove(),s.insertAdjacentElement(`afterend`,a))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling){if(t.nodeType!==Node.ELEMENT_NODE){e.push(t);continue}let n=t;n.tagName!==`MINT-SPINNER`&&!n.querySelector(`mint-spinner`)&&t!==a&&!n.hasAttribute(`slot`)&&!(n.classList.contains(`mint-button-spinner-wrap`)&&n.querySelector(`mint-spinner`))&&e.push(t)}if(e.length>0){s=document.createElement(`span`),s.className=this._getContentWrapperClass(s),e.forEach(e=>{s.appendChild(e)}),s.className=this._getContentWrapperClass(s);let t=this._button.querySelector(`mint-spinner`)?.parentElement;a&&o===`left`?t?(t.insertAdjacentElement(`afterend`,a),a.insertAdjacentElement(`afterend`,s)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement(`afterend`,s)):a&&o===`right`?t?(t.insertAdjacentElement(`afterend`,s),s.insertAdjacentElement(`afterend`,a)):(this._button.insertBefore(s,this._button.firstChild),s.insertAdjacentElement(`afterend`,a)):t?t.insertAdjacentElement(`afterend`,s):this._button.insertBefore(s,this._button.firstChild)}else if(a&&a.tagName===`MINT-ICON`&&!a.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,this._button.firstChild)}}let c=this.isIconOnly();if(a&&(a.classList.contains(`mint-button-icon`)||a.classList.add(`mint-button-icon`),e?a.style.display=`none`:a.style.display=``,a.setAttribute(`data-position`,o),a.toggleAttribute(`data-icon-only`,c),c&&(a.tagName===`MINT-ICON`?(a.style.width=`1em`,a.style.height=`1em`,a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`):(a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`,a.tagName===`svg`&&(a.style.width=`1em`,a.style.height=`1em`)))),e){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e&&(c?e.setAttribute(`data-icon-only`,`true`):e.removeAttribute(`data-icon-only`))}let l=this.getButtonClasses();this._button.className=l;let u=this.getAttribute(`aria-label`)?.trim();if(u)this._button.setAttribute(`aria-label`,u);else if(this.isIconOnly()){let e=this.getIcon().split(`-`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `);this._button.setAttribute(`aria-label`,e||`Action`)}else this._button.removeAttribute(`aria-label`);this.hasAttribute(`active`)?this._button.setAttribute(`aria-pressed`,String(this.isActive())):this._button.removeAttribute(`aria-pressed`),this.setAttribute(`data-variant`,this.getVariant()),this.setAttribute(`data-tone`,this.getTone()),this._button.setAttribute(`data-variant`,this.getVariant()),this._button.setAttribute(`data-align`,this.getAlignment()),this._button.toggleAttribute(`data-icon-only`,c),e?this._button.setAttribute(`data-loading`,`true`):this._button.removeAttribute(`data-loading`),this.isActive()?this._button.classList.add(`mint-button-active`):this._button.classList.remove(`mint-button-active`)}finally{queueMicrotask(()=>{this.isConnected&&this._connectHostChildObserver()})}}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener(`click`,this._clickHandler,!0),this._button.addEventListener(`mousedown`,this._handleMouseDown),this._button.addEventListener(`touchstart`,this._handleTouchStart),this._button.addEventListener(`touchend`,this._handleTouchEnd),this._button.addEventListener(`touchcancel`,this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&=(this._button.removeEventListener(`click`,this._clickHandler,!0),null),this._button.removeEventListener(`mousedown`,this._handleMouseDown),this._button.removeEventListener(`touchstart`,this._handleTouchStart),this._button.removeEventListener(`touchend`,this._handleTouchEnd),this._button.removeEventListener(`touchcancel`,this._handleTouchCancel))}_clearMousePressedState(){this._mousePressed&&(this._mousePressed=!1,document.removeEventListener(`mouseup`,this._handleMouseUp),window.removeEventListener(`blur`,this._handleMouseCancel)),this._button&&(this.isActive()||this._button.classList.remove(`mint-button-active`))}handleClick(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(this.getType()===`submit`){this.dispatchEvent(new CustomEvent(`click`,{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0}));return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent(`click`,{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};customElements.get(`mint-button`)||e.t(`mint-button`,t),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return t}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./register-element-tCL_F1YI.js`);require(`./text-Cpl5ljSe.js`),require(`./button-
|
|
1
|
+
const e=require(`./register-element-tCL_F1YI.js`);require(`./text-Cpl5ljSe.js`),require(`./button-DfY2Sr3-.js`),require(`./modal-CHLB5Td7.js`);var t=class extends HTMLElement{constructor(...e){super(...e),this._modal=null,this._actionsFooter=null,this._confirmButton=null,this._cancelButton=null,this._pendingResolve=null,this._modalObserver=null,this._lastAction=null,this._onConfirmClick=null,this._onCancelClick=null}connectedCallback(){this._ensureModal(),this._observeModalOpenState()}disconnectedCallback(){this._modalObserver&&=(this._modalObserver.disconnect(),null),this._pendingResolve=null}async showConfirm(e){if(this._ensureModal(),!this._modal||!this._confirmButton||!this._cancelButton)return!1;let t=e.question?.trim()||`Are you sure?`,n=e.tone||`action`,r=e.confirmLabel?.trim()||`Confirm`,i=e.cancelLabel?.trim()||`Cancel`;this._lastAction=null,this._modal.setAttribute(`heading`,t),this._cancelButton.className=`mint-button-core mint-button-ghost mint-button-tone-neutral mint-confirm-action-cancel`,this._confirmButton.className=`mint-button-core mint-button-solid mint-button-tone-${n} mint-confirm-action-confirm`,this._confirmButton.textContent=r,this._cancelButton.textContent=i;let a=new Promise(e=>{this._pendingResolve=e});return requestAnimationFrame(()=>{this._modal.open?.(),this._mountActionsFooter()}),a}_ensureModal(){this._modal||(this._modal=document.createElement(`mint-modal`),this._modal.setAttribute(`heading`,`Are you sure?`),this._modal.setAttribute(`size`,`small`),this._modal.setAttribute(`hide-close-button`,``),this._cancelButton=document.createElement(`button`),this._cancelButton.type=`button`,this._cancelButton.className=`mint-button-core mint-button-ghost mint-button-tone-neutral mint-confirm-action-cancel`,this._cancelButton.textContent=`Cancel`,this._confirmButton=document.createElement(`button`),this._confirmButton.type=`button`,this._confirmButton.className=`mint-button-core mint-button-solid mint-button-tone-action mint-confirm-action-confirm`,this._confirmButton.textContent=`Confirm`,this._actionsFooter=document.createElement(`div`),this._actionsFooter.className=`mint-confirm-action-footer`,this._actionsFooter.append(this._cancelButton,this._confirmButton),this._onCancelClick=()=>{this._lastAction=`cancel`,this._modal?.close?.()},this._onConfirmClick=()=>{this._lastAction=`confirm`,this._modal?.close?.()},this._cancelButton.addEventListener(`click`,this._onCancelClick),this._confirmButton.addEventListener(`click`,this._onConfirmClick),this.appendChild(this._modal))}_mountActionsFooter(){let e=this._modal?.querySelector(`.modal-content`);!e||!this._actionsFooter||(e.querySelectorAll(`:scope > [slot="body"], :scope > [slot="actions"]`).forEach(e=>{!e.textContent?.trim()&&!e.querySelector(`button, mint-button, a, input, select, textarea`)&&e.remove()}),this._actionsFooter.parentElement!==e&&e.appendChild(this._actionsFooter))}_observeModalOpenState(){!this._modal||this._modalObserver||(this._modalObserver=new MutationObserver(()=>{if((this._modal?.hasAttribute(`open`)??!1)||!this._pendingResolve)return;let e=this._pendingResolve;this._pendingResolve=null;let t=this._lastAction===`confirm`;this._lastAction=null,e(t)}),this._modalObserver.observe(this._modal,{attributes:!0,attributeFilter:[`open`]}))}};customElements.get(`mint-confirm-action`)||e.t(`mint-confirm-action`,t);var n=[],r=!1;function i(){return typeof document>`u`||document.body?Promise.resolve():new Promise(e=>{if(typeof window>`u`){e();return}window.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0})})}async function a(){if(await i(),typeof document>`u`)throw Error(`mintui.confirm is only available in browser environments.`);let e=document.querySelector(`mint-confirm-action[data-mint-confirm-action-root="true"]`);if(e)return e;let t=document.createElement(`mint-confirm-action`);return t.setAttribute(`data-mint-confirm-action-root`,`true`),document.body.appendChild(t),t}function o(e){let t=(e||`action`).toString().trim().toLowerCase().replace(/^tone:\s*/,``);return t===`action`||t===`info`||t===`warning`||t===`danger`?t:`action`}async function s(){if(!r){r=!0;try{for(;n.length>0;){let e=n.shift();e&&(await(await a()).showConfirm({question:e.question,tone:o(e.tone),confirmLabel:e.confirmLabel||`Confirm`,cancelLabel:e.cancelLabel||`Cancel`})?e.confirmed?.():e.cancelled?.())}}finally{r=!1}}}function c(e,t,r,i=`action`,a=`Confirm`,o=`Cancel`){typeof window>`u`||(n.push({question:e,confirmed:t,cancelled:r,tone:i,confirmLabel:a,cancelLabel:o}),s())}if(typeof window<`u`){let e=window.mintui||{};e.confirm=c,window.mintui=e}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./register-element-BFYmIynH.js";
|
|
2
2
|
import "./text-Bmfl6CxJ.js";
|
|
3
|
-
import "./button
|
|
4
|
-
import "./modal-
|
|
3
|
+
import "./button-BYkzR0uX.js";
|
|
4
|
+
import "./modal-DXviLYW_.js";
|
|
5
5
|
//#region src/components/confirm-action/ConfirmAction.ts
|
|
6
6
|
var t = class extends HTMLElement {
|
|
7
7
|
constructor(...e) {
|