monobill-mintui 0.2.98 → 0.3.1
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/components/button/Button.d.ts +4 -0
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/card/Card.d.ts.map +1 -1
- package/dist/components/checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/icon/Icon.d.ts +2 -1
- package/dist/components/icon/Icon.d.ts.map +1 -1
- package/dist/components/icon/icons/index.cjs +1 -1
- package/dist/components/icon/icons/index.d.ts +1 -0
- package/dist/components/icon/icons/index.d.ts.map +1 -1
- package/dist/components/icon/icons/index.js +16 -2
- package/dist/components/icon/icons/sort-arrows.d.ts +3 -0
- package/dist/components/icon/icons/sort-arrows.d.ts.map +1 -0
- package/dist/components/input/Input.d.ts.map +1 -1
- package/dist/components/resource-table/ResourceTable.d.ts +130 -0
- package/dist/components/resource-table/ResourceTable.d.ts.map +1 -0
- package/dist/components/resource-table/index.d.ts +3 -0
- package/dist/components/resource-table/index.d.ts.map +1 -0
- package/dist/components/table/Table.d.ts.map +1 -1
- package/dist/icons/edit.svg +1 -1
- package/dist/icons/sort-arrows.svg +3 -0
- package/dist/index.cjs +14 -4
- package/dist/index.js +694 -501
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35,8 +35,8 @@ class O extends HTMLElement {
|
|
|
35
35
|
const e = this.getSize(), t = this.getAttribute("size") || "default", i = !!(this.style.width && this.style.height), s = this.getAttribute("data-button-variant"), n = document.documentElement.classList.contains("dark");
|
|
36
36
|
let r;
|
|
37
37
|
if (i) {
|
|
38
|
-
const
|
|
39
|
-
s === "solid" ?
|
|
38
|
+
const c = this.getAttribute("data-button-tone") || "neutral";
|
|
39
|
+
s === "solid" ? c === "neutral" ? r = n ? "#ffffff" : "#0f172a" : r = "#ffffff" : r = n ? "#ffffff" : "#0f172a";
|
|
40
40
|
} else
|
|
41
41
|
r = n ? "#e2e8f0" : "#0f172a";
|
|
42
42
|
const a = t === "large" ? "2" : "4", l = !!(this.style.width && this.style.height), o = `
|
|
@@ -118,39 +118,51 @@ class B extends HTMLElement {
|
|
|
118
118
|
getName() {
|
|
119
119
|
return this.getAttribute("name") || "";
|
|
120
120
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
121
|
+
generateSVGMarkup(e) {
|
|
122
|
+
let t;
|
|
123
|
+
return e.fill && e.strokeWidth ? t = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${e.viewBox}" fill="none" stroke="currentColor" stroke-width="${e.strokeWidth}" stroke-linecap="${e.strokeLinecap || "round"}" stroke-linejoin="${e.strokeLinejoin || "round"}">
|
|
124
|
+
<path d="${e.path}" />
|
|
125
|
+
</svg>` : e.fill ? e.viewBox === "0 0 512 512" ? t = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
|
126
|
+
<g transform="scale(0.046875)">
|
|
127
|
+
<path d="${e.path}" />
|
|
128
|
+
</g>
|
|
129
|
+
</svg>` : t = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${e.viewBox}" fill="currentColor">
|
|
130
|
+
<path d="${e.path}" />
|
|
131
|
+
</svg>` : t = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="${e.viewBox}" fill="none" stroke="currentColor" stroke-width="${e.strokeWidth || "2"}" stroke-linecap="${e.strokeLinecap || "round"}" stroke-linejoin="${e.strokeLinejoin || "round"}">
|
|
132
|
+
<path d="${e.path}" />
|
|
133
|
+
</svg>`, t;
|
|
125
134
|
}
|
|
126
135
|
render() {
|
|
127
|
-
var
|
|
136
|
+
var o, c, h;
|
|
128
137
|
const e = this.getName();
|
|
129
138
|
if (!e) {
|
|
130
|
-
this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "";
|
|
139
|
+
this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "", this.style.backgroundColor = "";
|
|
131
140
|
return;
|
|
132
141
|
}
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
const t = q(e);
|
|
143
|
+
if (!t) {
|
|
144
|
+
console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`), this.innerHTML = "", this.style.maskImage = "", this.style.webkitMaskImage = "", this.style.backgroundColor = "";
|
|
135
145
|
return;
|
|
136
146
|
}
|
|
137
|
-
const i = this.closest("mint-button") || ((
|
|
147
|
+
const i = this.closest("mint-button") || ((o = this.parentElement) == null ? void 0 : o.closest("mint-button")), s = this.closest("mint-switch") || ((c = this.parentElement) == null ? void 0 : c.closest("mint-switch")), n = this.closest("mint-select") || ((h = this.parentElement) == null ? void 0 : h.closest("mint-select"));
|
|
138
148
|
if (!Array.from(this.classList).some(
|
|
139
|
-
(
|
|
149
|
+
(d) => d.startsWith("w-") || d.startsWith("h-")
|
|
140
150
|
) && !n) {
|
|
141
|
-
let
|
|
142
|
-
s ?
|
|
143
|
-
|
|
151
|
+
let d;
|
|
152
|
+
s ? d = "w-3 h-3" : i ? d = "w-5 h-5" : d = "w-[1.3em] h-[1.3em]", this.classList.remove("w-4", "h-4", "w-5", "h-5", "w-[1em]", "h-[1em]", "w-[1.3em]", "h-[1.3em]", "w-3", "h-3"), d.split(" ").forEach((u) => {
|
|
153
|
+
u && this.classList.add(u);
|
|
144
154
|
});
|
|
145
155
|
}
|
|
146
|
-
const a = this.
|
|
147
|
-
|
|
156
|
+
const a = this.generateSVGMarkup(t);
|
|
157
|
+
this.innerHTML = a, this.style.maskImage = "", this.style.webkitMaskImage = "", this.style.maskSize = "", this.style.webkitMaskSize = "", this.style.maskRepeat = "", this.style.webkitMaskRepeat = "", this.style.maskPosition = "", this.style.webkitMaskPosition = "", this.style.backgroundColor = "", this.style.aspectRatio = "1 / 1";
|
|
158
|
+
const l = this.querySelector("svg");
|
|
159
|
+
if (l && (l.style.width = "100%", l.style.height = "100%"), s)
|
|
148
160
|
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add("text-gray-900");
|
|
149
161
|
else if (i)
|
|
150
162
|
this.classList.remove("text-gray-100", "text-gray-900");
|
|
151
163
|
else {
|
|
152
|
-
const
|
|
153
|
-
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(
|
|
164
|
+
const u = document.documentElement.classList.contains("dark") ? "text-gray-100" : "text-gray-900";
|
|
165
|
+
this.classList.remove("text-gray-100", "text-gray-900"), this.classList.add(u);
|
|
154
166
|
}
|
|
155
167
|
}
|
|
156
168
|
}
|
|
@@ -172,7 +184,7 @@ class z extends HTMLElement {
|
|
|
172
184
|
};
|
|
173
185
|
}
|
|
174
186
|
static get observedAttributes() {
|
|
175
|
-
return ["variant", "tone", "disabled", "loading", "button-type", "type", "full-width", "icon-position", "icon"];
|
|
187
|
+
return ["variant", "tone", "disabled", "loading", "button-type", "type", "full-width", "icon-position", "icon", "active"];
|
|
176
188
|
}
|
|
177
189
|
connectedCallback() {
|
|
178
190
|
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render(), this._button && this.setupEventListeners(), this.isFullWidth() && this.classList.add("w-full");
|
|
@@ -202,6 +214,17 @@ class z extends HTMLElement {
|
|
|
202
214
|
isFullWidth() {
|
|
203
215
|
return this.hasAttribute("full-width");
|
|
204
216
|
}
|
|
217
|
+
isActive() {
|
|
218
|
+
const e = this.getAttribute("active");
|
|
219
|
+
return !(e === null || e === "false" || e === "0");
|
|
220
|
+
}
|
|
221
|
+
// Convenience property for programmatic usage: button.active = true/false
|
|
222
|
+
get active() {
|
|
223
|
+
return this.isActive();
|
|
224
|
+
}
|
|
225
|
+
set active(e) {
|
|
226
|
+
e ? this.setAttribute("active", "true") : this.removeAttribute("active");
|
|
227
|
+
}
|
|
205
228
|
getIconPosition() {
|
|
206
229
|
return this.getAttribute("icon-position") || "left";
|
|
207
230
|
}
|
|
@@ -225,6 +248,151 @@ class z extends HTMLElement {
|
|
|
225
248
|
}
|
|
226
249
|
return !0;
|
|
227
250
|
}
|
|
251
|
+
getActiveStateClasses() {
|
|
252
|
+
const e = this.getVariant(), t = this.getTone(), i = `${e}-${t}`;
|
|
253
|
+
return {
|
|
254
|
+
"solid-action": [
|
|
255
|
+
"!bg-slate-900",
|
|
256
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]",
|
|
257
|
+
"dark:!bg-slate-700",
|
|
258
|
+
"hover:!bg-slate-900",
|
|
259
|
+
// Override hover to match active
|
|
260
|
+
"dark:hover:!bg-slate-700",
|
|
261
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"
|
|
262
|
+
// Override hover shadow with inset
|
|
263
|
+
],
|
|
264
|
+
"solid-neutral": [
|
|
265
|
+
"!bg-gray-100",
|
|
266
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
267
|
+
"dark:!bg-gray-800",
|
|
268
|
+
"hover:!bg-gray-100",
|
|
269
|
+
// Override hover to match active
|
|
270
|
+
"dark:hover:!bg-gray-800",
|
|
271
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"
|
|
272
|
+
// Override hover shadow with inset
|
|
273
|
+
],
|
|
274
|
+
"solid-info": [
|
|
275
|
+
"!bg-blue-900",
|
|
276
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]",
|
|
277
|
+
"dark:!bg-blue-700",
|
|
278
|
+
"hover:!bg-blue-900",
|
|
279
|
+
// Override hover to match active
|
|
280
|
+
"dark:hover:!bg-blue-700",
|
|
281
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"
|
|
282
|
+
// Override hover shadow with inset
|
|
283
|
+
],
|
|
284
|
+
"solid-warning": [
|
|
285
|
+
"!bg-amber-900",
|
|
286
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]",
|
|
287
|
+
"dark:!bg-amber-700",
|
|
288
|
+
"hover:!bg-amber-900",
|
|
289
|
+
// Override hover to match active
|
|
290
|
+
"dark:hover:!bg-amber-700",
|
|
291
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"
|
|
292
|
+
// Override hover shadow with inset
|
|
293
|
+
],
|
|
294
|
+
"solid-danger": [
|
|
295
|
+
"!bg-red-900",
|
|
296
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]",
|
|
297
|
+
"dark:!bg-red-700",
|
|
298
|
+
"hover:!bg-red-900",
|
|
299
|
+
// Override hover to match active
|
|
300
|
+
"dark:hover:!bg-red-700",
|
|
301
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"
|
|
302
|
+
// Override hover shadow with inset
|
|
303
|
+
],
|
|
304
|
+
"ghost-action": [
|
|
305
|
+
"!bg-gray-100",
|
|
306
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
307
|
+
"dark:!bg-gray-800",
|
|
308
|
+
"hover:!bg-gray-100",
|
|
309
|
+
// Override hover to match active
|
|
310
|
+
"dark:hover:!bg-gray-800",
|
|
311
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"
|
|
312
|
+
// Override hover shadow
|
|
313
|
+
],
|
|
314
|
+
"ghost-neutral": [
|
|
315
|
+
"!bg-gray-50",
|
|
316
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
317
|
+
"dark:!bg-gray-800",
|
|
318
|
+
"!text-gray-900",
|
|
319
|
+
"dark:!text-white",
|
|
320
|
+
"hover:!bg-gray-50",
|
|
321
|
+
// Override hover to match active
|
|
322
|
+
"dark:hover:!bg-gray-800",
|
|
323
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
324
|
+
// Override hover shadow
|
|
325
|
+
"hover:!text-gray-900",
|
|
326
|
+
// Override hover text color
|
|
327
|
+
"dark:hover:!text-white"
|
|
328
|
+
],
|
|
329
|
+
"ghost-info": [
|
|
330
|
+
"!bg-gray-100",
|
|
331
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
332
|
+
"dark:!bg-gray-800",
|
|
333
|
+
"hover:!bg-gray-100",
|
|
334
|
+
// Override hover to match active
|
|
335
|
+
"dark:hover:!bg-gray-800",
|
|
336
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"
|
|
337
|
+
// Override hover shadow
|
|
338
|
+
],
|
|
339
|
+
"ghost-warning": [
|
|
340
|
+
"!bg-gray-100",
|
|
341
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
342
|
+
"dark:!bg-gray-800",
|
|
343
|
+
"hover:!bg-gray-100",
|
|
344
|
+
// Override hover to match active
|
|
345
|
+
"dark:hover:!bg-gray-800",
|
|
346
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"
|
|
347
|
+
// Override hover shadow
|
|
348
|
+
],
|
|
349
|
+
"ghost-danger": [
|
|
350
|
+
"!bg-gray-100",
|
|
351
|
+
"!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]",
|
|
352
|
+
"dark:!bg-gray-800",
|
|
353
|
+
"hover:!bg-gray-100",
|
|
354
|
+
// Override hover to match active
|
|
355
|
+
"dark:hover:!bg-gray-800",
|
|
356
|
+
"hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"
|
|
357
|
+
// Override hover shadow
|
|
358
|
+
],
|
|
359
|
+
"link-action": [
|
|
360
|
+
"!text-slate-900",
|
|
361
|
+
"dark:!text-slate-300",
|
|
362
|
+
"hover:!text-slate-900",
|
|
363
|
+
// Override hover to match active
|
|
364
|
+
"dark:hover:!text-slate-300"
|
|
365
|
+
],
|
|
366
|
+
"link-neutral": [
|
|
367
|
+
"!text-gray-950",
|
|
368
|
+
"dark:!text-gray-200",
|
|
369
|
+
"hover:!text-gray-950",
|
|
370
|
+
// Override hover to match active
|
|
371
|
+
"dark:hover:!text-gray-200"
|
|
372
|
+
],
|
|
373
|
+
"link-info": [
|
|
374
|
+
"!text-blue-900",
|
|
375
|
+
"dark:!text-blue-200",
|
|
376
|
+
"hover:!text-blue-900",
|
|
377
|
+
// Override hover to match active
|
|
378
|
+
"dark:hover:!text-blue-200"
|
|
379
|
+
],
|
|
380
|
+
"link-warning": [
|
|
381
|
+
"!text-amber-900",
|
|
382
|
+
"dark:!text-amber-200",
|
|
383
|
+
"hover:!text-amber-900",
|
|
384
|
+
// Override hover to match active
|
|
385
|
+
"dark:hover:!text-amber-200"
|
|
386
|
+
],
|
|
387
|
+
"link-danger": [
|
|
388
|
+
"!text-red-900",
|
|
389
|
+
"dark:!text-red-200",
|
|
390
|
+
"hover:!text-red-900",
|
|
391
|
+
// Override hover to match active
|
|
392
|
+
"dark:hover:!text-red-200"
|
|
393
|
+
]
|
|
394
|
+
}[i] || [];
|
|
395
|
+
}
|
|
228
396
|
getButtonClasses() {
|
|
229
397
|
const e = this.isIconOnly(), t = this.getVariant(), i = [
|
|
230
398
|
"inline-flex",
|
|
@@ -235,7 +403,7 @@ class z extends HTMLElement {
|
|
|
235
403
|
// All buttons have rounded corners
|
|
236
404
|
"box-border",
|
|
237
405
|
// Ensure border is included in size calculation
|
|
238
|
-
...e ? ["p-1.5", "aspect-square", "w-[
|
|
406
|
+
...e ? ["p-1.5", "aspect-square", "w-[2.25rem]", "h-[2.25rem]"] : ["px-3.5", "py-1.5", "min-h-[2.25rem]"],
|
|
239
407
|
// Square for icon-only, normal padding otherwise
|
|
240
408
|
"text-sm",
|
|
241
409
|
"transition-all",
|
|
@@ -538,10 +706,14 @@ class z extends HTMLElement {
|
|
|
538
706
|
...i,
|
|
539
707
|
...a
|
|
540
708
|
];
|
|
709
|
+
if (this.isActive()) {
|
|
710
|
+
const o = this.getActiveStateClasses();
|
|
711
|
+
l.push(...o), l.push("[&>*]:scale-95");
|
|
712
|
+
}
|
|
541
713
|
return this.isFullWidth() && l.push("w-full"), l.join(" ");
|
|
542
714
|
}
|
|
543
715
|
render() {
|
|
544
|
-
var
|
|
716
|
+
var c, h, d, u, m;
|
|
545
717
|
const e = this.isDisabled() || this.isLoading(), t = this.getType();
|
|
546
718
|
if (!this._button) {
|
|
547
719
|
for (this._button = document.createElement("button"); this.firstChild; )
|
|
@@ -554,12 +726,12 @@ class z extends HTMLElement {
|
|
|
554
726
|
if (i)
|
|
555
727
|
i.setAttribute("data-button-variant", this.getVariant()), i.setAttribute("data-button-tone", this.getTone()), "render" in i && typeof i.render == "function" && i.render();
|
|
556
728
|
else {
|
|
557
|
-
const
|
|
558
|
-
|
|
559
|
-
const
|
|
560
|
-
|
|
729
|
+
const p = document.createElement("span");
|
|
730
|
+
p.className = "mr-2 inline-flex items-center";
|
|
731
|
+
const f = document.createElement("mint-spinner");
|
|
732
|
+
f.setAttribute("size", "default"), f.setAttribute("data-button-variant", this.getVariant()), f.setAttribute("data-button-tone", this.getTone()), f.style.width = "0.875rem", f.style.height = "0.875rem", p.appendChild(f), this._button.insertBefore(p, this._button.firstChild);
|
|
561
733
|
}
|
|
562
|
-
else i && ((
|
|
734
|
+
else i && ((c = i.parentElement) == null || c.remove());
|
|
563
735
|
for (; this.firstChild && this.firstChild !== this._button; )
|
|
564
736
|
this._button.appendChild(this.firstChild);
|
|
565
737
|
const s = this.getIcon();
|
|
@@ -568,34 +740,34 @@ class z extends HTMLElement {
|
|
|
568
740
|
const r = this.getIconPosition();
|
|
569
741
|
let a = this._button.querySelector(".mint-button-content");
|
|
570
742
|
if (a) {
|
|
571
|
-
const
|
|
743
|
+
const p = n && n.tagName === "MINT-ICON";
|
|
572
744
|
if (n && !n.parentElement) {
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
} else if (n && (
|
|
745
|
+
const f = (u = this._button.querySelector("mint-spinner")) == null ? void 0 : u.parentElement;
|
|
746
|
+
p || r === "left" ? f ? f.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a) : a.insertAdjacentElement("afterend", n);
|
|
747
|
+
} else if (n && (p || r === "left") && n.nextSibling !== a) {
|
|
576
748
|
n.remove();
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
} else n && !
|
|
749
|
+
const f = (m = this._button.querySelector("mint-spinner")) == null ? void 0 : m.parentElement;
|
|
750
|
+
f ? f.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, a);
|
|
751
|
+
} else n && !p && r === "right" && n.previousSibling !== a && (n.remove(), a.insertAdjacentElement("afterend", n));
|
|
580
752
|
} else {
|
|
581
|
-
const
|
|
582
|
-
for (let
|
|
583
|
-
if (
|
|
584
|
-
|
|
753
|
+
const p = [];
|
|
754
|
+
for (let f = this._button.firstChild; f; f = f.nextSibling) {
|
|
755
|
+
if (f.nodeType !== Node.ELEMENT_NODE) {
|
|
756
|
+
p.push(f);
|
|
585
757
|
continue;
|
|
586
758
|
}
|
|
587
|
-
const
|
|
588
|
-
|
|
759
|
+
const b = f;
|
|
760
|
+
b.tagName !== "MINT-SPINNER" && !b.querySelector("mint-spinner") && f !== n && !b.hasAttribute("slot") && !(b.className === "mr-2" && b.querySelector("mint-spinner")) && p.push(f);
|
|
589
761
|
}
|
|
590
|
-
if (
|
|
591
|
-
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center",
|
|
592
|
-
a.appendChild(
|
|
762
|
+
if (p.length > 0) {
|
|
763
|
+
a = document.createElement("span"), a.className = "mint-button-content inline-flex items-center", p.forEach((b) => {
|
|
764
|
+
a.appendChild(b);
|
|
593
765
|
});
|
|
594
|
-
const
|
|
595
|
-
n && r === "left" ?
|
|
766
|
+
const f = (h = this._button.querySelector("mint-spinner")) == null ? void 0 : h.parentElement;
|
|
767
|
+
n && r === "left" ? f ? (f.insertAdjacentElement("afterend", n), n.insertAdjacentElement("afterend", a)) : (this._button.insertBefore(n, this._button.firstChild), n.insertAdjacentElement("afterend", a)) : n && r === "right" ? f ? (f.insertAdjacentElement("afterend", a), a.insertAdjacentElement("afterend", n)) : (this._button.insertBefore(a, this._button.firstChild), a.insertAdjacentElement("afterend", n)) : f ? f.insertAdjacentElement("afterend", a) : this._button.insertBefore(a, this._button.firstChild);
|
|
596
768
|
} else if (n && n.tagName === "MINT-ICON" && !n.parentElement) {
|
|
597
|
-
const
|
|
598
|
-
|
|
769
|
+
const f = (d = this._button.querySelector("mint-spinner")) == null ? void 0 : d.parentElement;
|
|
770
|
+
f ? f.insertAdjacentElement("afterend", n) : this._button.insertBefore(n, this._button.firstChild);
|
|
599
771
|
}
|
|
600
772
|
}
|
|
601
773
|
const l = this.isIconOnly();
|
|
@@ -775,17 +947,17 @@ class W extends HTMLElement {
|
|
|
775
947
|
this._button ? this._button.parentElement !== l && l.appendChild(this._button) : (this._button = document.createElement("button"), l.appendChild(this._button), this.setupEventListeners());
|
|
776
948
|
let o = l.querySelector(".mint-switch-label");
|
|
777
949
|
s ? (o || (o = document.createElement("label"), o.className = "mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", this._button && this._button.parentElement === l ? l.insertBefore(o, this._button.nextSibling) : l.appendChild(o)), o.textContent = s, o.setAttribute("for", a), this.isDisabled() ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove(), this._button.className = t, this._button.disabled = this.isDisabled(), this._button.id = a, this._button.setAttribute("aria-checked", String(this._checked)), this._button.setAttribute("aria-label", s || "Toggle switch"), this._button.setAttribute("role", "switch"), this._button.type = "button";
|
|
778
|
-
let
|
|
779
|
-
|
|
780
|
-
const
|
|
950
|
+
let c = this._button.querySelector("span");
|
|
951
|
+
c || (c = document.createElement("span"), this._button.appendChild(c)), c.className = i;
|
|
952
|
+
const h = c.querySelector("span");
|
|
781
953
|
if (r) {
|
|
782
|
-
let
|
|
783
|
-
|
|
784
|
-
let
|
|
785
|
-
|
|
786
|
-
} else
|
|
787
|
-
let
|
|
788
|
-
n ? (
|
|
954
|
+
let u = h;
|
|
955
|
+
u || (u = document.createElement("span"), u.className = this.getIconClasses(), c.appendChild(u));
|
|
956
|
+
let m = u.querySelector("mint-icon");
|
|
957
|
+
m || (m = document.createElement("mint-icon"), u.appendChild(m)), m.setAttribute("name", r);
|
|
958
|
+
} else h && h.remove();
|
|
959
|
+
let d = this.querySelector(".mint-switch-info");
|
|
960
|
+
n ? (d || (d = document.createElement("span"), d.className = "mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block", l && l.parentElement === this ? this.insertBefore(d, l.nextSibling) : this.appendChild(d)), d.textContent = n, this.isDisabled() ? d.classList.add("opacity-40") : d.classList.remove("opacity-40")) : d && d.remove(), this._renderErrorState(), this._renderSkeleton(e);
|
|
789
961
|
}
|
|
790
962
|
setupEventListeners() {
|
|
791
963
|
this._button && this._button.addEventListener("click", this.handleToggle.bind(this));
|
|
@@ -1087,7 +1259,7 @@ class j extends HTMLElement {
|
|
|
1087
1259
|
);
|
|
1088
1260
|
}
|
|
1089
1261
|
render() {
|
|
1090
|
-
this.classList.add("rounded-lg", "shadow", "bg-white", "dark:bg-gray-800", "border", "border-gray-200", "dark:border-gray-700", "overflow-hidden", "transition-colors", "duration-200"), this.hasPaddingClass() || this.classList.add("p-
|
|
1262
|
+
this.classList.add("rounded-lg", "shadow", "bg-white", "dark:bg-gray-800", "border", "border-gray-200", "dark:border-gray-700", "overflow-hidden", "transition-colors", "duration-200", "mb-6"), this.hasPaddingClass() || this.classList.add("p-4");
|
|
1091
1263
|
const e = this.getHeading();
|
|
1092
1264
|
e ? (this._headingElement || (this._headingElement = document.createElement("mint-text"), this._headingElement.setAttribute("size", "sub-heading"), this.insertBefore(this._headingElement, this.firstChild)), this._headingElement.textContent = e) : this._headingElement && this._headingElement.parentNode && (this._headingElement.remove(), this._headingElement = null);
|
|
1093
1265
|
}
|
|
@@ -1384,31 +1556,31 @@ class J extends HTMLElement {
|
|
|
1384
1556
|
render() {
|
|
1385
1557
|
const e = this.getId(), t = this.getHeading(), i = this.isOpen();
|
|
1386
1558
|
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)), i) {
|
|
1387
|
-
let
|
|
1388
|
-
|
|
1559
|
+
let h = this._modal.querySelector(".modal-content");
|
|
1560
|
+
h || (h = document.createElement("div"), h.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(h)), this._animateEnter();
|
|
1389
1561
|
} else
|
|
1390
1562
|
this._animateExit();
|
|
1391
1563
|
let s = this._modal.querySelector(".modal-content");
|
|
1392
1564
|
s || (s = document.createElement("div"), s.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(s)), 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", s.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));
|
|
1393
1565
|
let n = this._headingSlot.querySelector("mint-text");
|
|
1394
1566
|
t ? (n || (n = document.createElement("mint-text"), n.setAttribute("size", "sub-heading"), n.setAttribute("bold", ""), this._headingSlot.appendChild(n)), n.textContent = t) : n && n.remove(), Array.from(this.children).filter(
|
|
1395
|
-
(
|
|
1396
|
-
).forEach((
|
|
1397
|
-
this._headingSlot &&
|
|
1567
|
+
(h) => h !== this._overlay && h !== this._modal && h !== this._headingSlot && h.getAttribute("slot") === "heading"
|
|
1568
|
+
).forEach((h) => {
|
|
1569
|
+
this._headingSlot && h.parentElement !== this._headingSlot && this._headingSlot.appendChild(h);
|
|
1398
1570
|
}), 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"), s.appendChild(this._bodySlot)), Array.from(this.children).filter(
|
|
1399
|
-
(
|
|
1400
|
-
).forEach((
|
|
1401
|
-
this._bodySlot &&
|
|
1571
|
+
(h) => h !== this._overlay && h !== this._modal && h !== this._bodySlot && h.getAttribute("slot") === "body"
|
|
1572
|
+
).forEach((h) => {
|
|
1573
|
+
this._bodySlot && h.parentElement !== this._bodySlot && this._bodySlot.appendChild(h);
|
|
1402
1574
|
}), 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"), s.appendChild(this._actionsSlot));
|
|
1403
1575
|
let l = this._actionsSlot.querySelector("mint-stack");
|
|
1404
1576
|
l || (l = document.createElement("mint-stack"), l.setAttribute("direction", "horizontal"), l.className = "justify-end", this._actionsSlot.appendChild(l)), Array.from(this.children).filter(
|
|
1405
|
-
(
|
|
1406
|
-
).forEach((
|
|
1407
|
-
Array.from(
|
|
1408
|
-
|
|
1409
|
-
}),
|
|
1410
|
-
}), Array.from(this.children).forEach((
|
|
1411
|
-
|
|
1577
|
+
(h) => h !== this._overlay && h !== this._modal && h !== this._actionsSlot && h.getAttribute("slot") === "actions"
|
|
1578
|
+
).forEach((h) => {
|
|
1579
|
+
Array.from(h.children).forEach((u) => {
|
|
1580
|
+
u.parentElement !== l && l.appendChild(u);
|
|
1581
|
+
}), h.parentElement && h.remove();
|
|
1582
|
+
}), Array.from(this.children).forEach((h) => {
|
|
1583
|
+
h !== this._overlay && h !== this._modal && h.getAttribute("slot") !== "heading" && h.getAttribute("slot") !== "body" && h.getAttribute("slot") !== "actions" && h !== this._headingSlot && h !== this._bodySlot && h !== this._actionsSlot && h.parentElement !== this._bodySlot && this._bodySlot.appendChild(h);
|
|
1412
1584
|
}), this._updateBackgroundColor();
|
|
1413
1585
|
}
|
|
1414
1586
|
_updateBackgroundColor() {
|
|
@@ -1558,38 +1730,38 @@ class X extends HTMLElement {
|
|
|
1558
1730
|
if (!t) return { top: 0, left: 0, direction: "down" };
|
|
1559
1731
|
this.classList.contains("hidden") && (this.classList.remove("hidden"), this._popover.style.visibility = "hidden");
|
|
1560
1732
|
const s = t.getBoundingClientRect(), n = window.innerWidth, r = window.innerHeight, a = 8;
|
|
1561
|
-
let l = this.getDirection(), o = 0,
|
|
1733
|
+
let l = this.getDirection(), o = 0, c = 0;
|
|
1562
1734
|
switch (l) {
|
|
1563
1735
|
case "down":
|
|
1564
|
-
if (o = e.bottom + a,
|
|
1565
|
-
const
|
|
1566
|
-
|
|
1736
|
+
if (o = e.bottom + a, c = e.left + e.width / 2 - s.width / 2, o + s.height > r) {
|
|
1737
|
+
const h = e.top - s.height - a;
|
|
1738
|
+
h >= 0 ? (l = "up", o = h) : (o = Math.max(0, r - s.height - a), o + s.height > r && (o = 0));
|
|
1567
1739
|
}
|
|
1568
|
-
|
|
1740
|
+
c < 0 && (c = a), c + s.width > n && (c = Math.max(a, n - s.width - a), c + s.width > n && (c = n - s.width));
|
|
1569
1741
|
break;
|
|
1570
1742
|
case "up":
|
|
1571
|
-
if (o = e.top - s.height - a,
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1743
|
+
if (o = e.top - s.height - a, c = e.left + e.width / 2 - s.width / 2, o < 0) {
|
|
1744
|
+
const h = e.bottom + a;
|
|
1745
|
+
h + s.height <= r ? (l = "down", o = h) : (o = Math.min(r - s.height - a, r - s.height), o < 0 && (o = r - s.height));
|
|
1574
1746
|
}
|
|
1575
|
-
|
|
1747
|
+
c < 0 && (c = a), c + s.width > n && (c = Math.max(a, n - s.width - a), c + s.width > n && (c = n - s.width));
|
|
1576
1748
|
break;
|
|
1577
1749
|
case "right":
|
|
1578
|
-
if (o = e.top + e.height / 2 - s.height / 2,
|
|
1579
|
-
const
|
|
1580
|
-
|
|
1750
|
+
if (o = e.top + e.height / 2 - s.height / 2, c = e.right + a, c + s.width > n) {
|
|
1751
|
+
const h = e.left - s.width - a;
|
|
1752
|
+
h >= 0 ? (l = "left", c = h) : (c = Math.max(0, n - s.width - a), c + s.width > n && (c = n - s.width));
|
|
1581
1753
|
}
|
|
1582
1754
|
o < 0 && (o = a), o + s.height > r && (o = Math.max(a, r - s.height - a), o + s.height > r && (o = r - s.height));
|
|
1583
1755
|
break;
|
|
1584
1756
|
case "left":
|
|
1585
|
-
if (o = e.top + e.height / 2 - s.height / 2,
|
|
1586
|
-
const
|
|
1587
|
-
|
|
1757
|
+
if (o = e.top + e.height / 2 - s.height / 2, c = e.left - s.width - a, c < 0) {
|
|
1758
|
+
const h = e.right + a;
|
|
1759
|
+
h + s.width <= n ? (l = "right", c = h) : (c = Math.min(n - s.width - a, n - s.width), c < 0 && (c = 0));
|
|
1588
1760
|
}
|
|
1589
1761
|
o < 0 && (o = a), o + s.height > r && (o = Math.max(a, r - s.height - a), o + s.height > r && (o = r - s.height));
|
|
1590
1762
|
break;
|
|
1591
1763
|
}
|
|
1592
|
-
return { top: o, left:
|
|
1764
|
+
return { top: o, left: c, direction: l };
|
|
1593
1765
|
}
|
|
1594
1766
|
render() {
|
|
1595
1767
|
const e = this.getId(), t = this.isOpen(), i = this.getPadding();
|
|
@@ -1790,26 +1962,30 @@ class K extends HTMLElement {
|
|
|
1790
1962
|
const l = this.getName();
|
|
1791
1963
|
l ? this._checkbox.name = l : this._checkbox.removeAttribute("name");
|
|
1792
1964
|
const o = this.getValue();
|
|
1793
|
-
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), t ? this._checkbox.setAttribute("aria-label", t) : this._checkbox.removeAttribute("aria-label"), r.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, r.style.pointerEvents = "
|
|
1965
|
+
o ? this._checkbox.value = o : this._checkbox.removeAttribute("value"), t ? this._checkbox.setAttribute("aria-label", t) : this._checkbox.removeAttribute("aria-label"), r.className = `mint-checkbox-wrapper ${this.getCheckboxClasses()}`, r.style.cursor = "pointer", r.style.pointerEvents = "auto", this._checkbox.style.pointerEvents = "auto";
|
|
1966
|
+
const c = r;
|
|
1967
|
+
c._wrapperClickHandler || (c._wrapperClickHandler = (m) => {
|
|
1968
|
+
m.target === r && !s && (m.preventDefault(), m.stopPropagation(), this.toggle());
|
|
1969
|
+
}, r.addEventListener("click", c._wrapperClickHandler));
|
|
1794
1970
|
let h = r.querySelector("mint-icon");
|
|
1795
1971
|
h || (h = document.createElement("mint-icon"), h.setAttribute("name", "check"), h.className = "w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto", h.style.transition = "opacity 200ms ease-out, transform 200ms ease-out", h.style.zIndex = "1", r.appendChild(h)), this.updateVisualState();
|
|
1796
|
-
let
|
|
1797
|
-
const
|
|
1972
|
+
let d = this.querySelector(".mint-checkbox-label-container");
|
|
1973
|
+
const u = this.querySelector(".mint-checkbox-container");
|
|
1798
1974
|
if (t || i) {
|
|
1799
|
-
|
|
1800
|
-
let
|
|
1801
|
-
t ? (
|
|
1802
|
-
let
|
|
1803
|
-
if (i ? (
|
|
1804
|
-
|
|
1975
|
+
d ? u && d.parentElement !== u && u.appendChild(d) : (d = document.createElement("div"), d.className = "mint-checkbox-label-container flex flex-col gap-0.5 flex-1", u ? u.appendChild(d) : this.appendChild(d));
|
|
1976
|
+
let m = d.querySelector(".mint-checkbox-label");
|
|
1977
|
+
t ? (m || (m = document.createElement("span"), m.className = "mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none", d.insertBefore(m, d.firstChild)), m.textContent = t, s ? m.classList.add("opacity-40") : m.classList.remove("opacity-40")) : m && m.remove();
|
|
1978
|
+
let p = d.querySelector(".mint-checkbox-info");
|
|
1979
|
+
if (i ? (p || (p = document.createElement("span"), p.className = "mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none", d.appendChild(p)), p.textContent = i, s ? p.classList.add("opacity-40") : p.classList.remove("opacity-40")) : p && p.remove(), s)
|
|
1980
|
+
d.style.cursor = "default", d._clickHandler && (d.removeEventListener("click", d._clickHandler), d._clickHandler = null);
|
|
1805
1981
|
else {
|
|
1806
|
-
|
|
1807
|
-
const
|
|
1808
|
-
|
|
1809
|
-
this._checkbox && (
|
|
1810
|
-
},
|
|
1982
|
+
d.style.cursor = "pointer";
|
|
1983
|
+
const f = d._clickHandler;
|
|
1984
|
+
f && d.removeEventListener("click", f), d._clickHandler = (b) => {
|
|
1985
|
+
this._checkbox && (b.target === this._checkbox || this._checkbox.contains(b.target) || b.composedPath().includes(this._checkbox)) || this.toggle();
|
|
1986
|
+
}, d.addEventListener("click", d._clickHandler);
|
|
1811
1987
|
}
|
|
1812
|
-
} else
|
|
1988
|
+
} else d && d.remove();
|
|
1813
1989
|
this._renderErrorState(), this._renderSkeleton(e);
|
|
1814
1990
|
}
|
|
1815
1991
|
setupEventListeners() {
|
|
@@ -1852,6 +2028,11 @@ class K extends HTMLElement {
|
|
|
1852
2028
|
}
|
|
1853
2029
|
removeEventListeners() {
|
|
1854
2030
|
this._checkbox && (this._changeHandler && (this._checkbox.removeEventListener("change", this._changeHandler), this._changeHandler = null), this._mousedownHandler && (this._checkbox.removeEventListener("mousedown", this._mousedownHandler), this._mousedownHandler = null), this._mouseupHandler && (this._checkbox.removeEventListener("mouseup", this._mouseupHandler), this._mouseupHandler = null), this._mouseleaveHandler && (this._checkbox.removeEventListener("mouseleave", this._mouseleaveHandler), this._mouseleaveHandler = null), this._touchstartHandler && (this._checkbox.removeEventListener("touchstart", this._touchstartHandler), this._touchstartHandler = null), this._touchendHandler && (this._checkbox.removeEventListener("touchend", this._touchendHandler), this._touchendHandler = null), this._focusHandler && (this._checkbox.removeEventListener("focus", this._focusHandler), this._focusHandler = null), this._blurHandler && (this._checkbox.removeEventListener("blur", this._blurHandler), this._blurHandler = null));
|
|
2031
|
+
const e = this.querySelector(".mint-checkbox-wrapper");
|
|
2032
|
+
if (e) {
|
|
2033
|
+
const t = e;
|
|
2034
|
+
t._wrapperClickHandler && (e.removeEventListener("click", t._wrapperClickHandler), t._wrapperClickHandler = null);
|
|
2035
|
+
}
|
|
1855
2036
|
}
|
|
1856
2037
|
updateVisualState() {
|
|
1857
2038
|
const e = this.querySelector(".mint-checkbox-wrapper"), t = e == null ? void 0 : e.querySelector("mint-icon");
|
|
@@ -1951,69 +2132,69 @@ class Z extends HTMLElement {
|
|
|
1951
2132
|
}, this.addEventListener("click", this._clickHandler));
|
|
1952
2133
|
}
|
|
1953
2134
|
render() {
|
|
1954
|
-
var
|
|
2135
|
+
var m;
|
|
1955
2136
|
const e = this.isLoading(), t = this.isDisabled(), i = this.getValue(), s = this.closest("mint-choice"), n = (s == null ? void 0 : s.getAttribute("name")) || "";
|
|
1956
2137
|
let r = "";
|
|
1957
2138
|
const a = this.querySelector(".mint-choice-option-label");
|
|
1958
|
-
a ? r = ((
|
|
1959
|
-
var
|
|
1960
|
-
if (
|
|
1961
|
-
const
|
|
1962
|
-
|
|
2139
|
+
a ? r = ((m = a.textContent) == null ? void 0 : m.trim()) || "" : Array.from(this.childNodes).forEach((p) => {
|
|
2140
|
+
var f;
|
|
2141
|
+
if (p.nodeType === Node.TEXT_NODE) {
|
|
2142
|
+
const b = (f = p.textContent) == null ? void 0 : f.trim();
|
|
2143
|
+
b && (r += b);
|
|
1963
2144
|
}
|
|
1964
2145
|
});
|
|
1965
2146
|
const l = this.querySelectorAll(".mint-choice-option-wrapper");
|
|
1966
2147
|
let o = null;
|
|
1967
|
-
if (l.length > 0 && (this._radio && (o = Array.from(l).find((
|
|
1968
|
-
|
|
1969
|
-
})), o || (o = document.createElement("div"), o.className = "mint-choice-option-wrapper", o.style.position = "relative", this.insertBefore(o, this.firstChild)), o.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`, o.style.position = "relative", this.querySelectorAll('input[type="radio"]').forEach((
|
|
1970
|
-
|
|
2148
|
+
if (l.length > 0 && (this._radio && (o = Array.from(l).find((p) => p.contains(this._radio))), o || (o = l[0]), l.forEach((p, f) => {
|
|
2149
|
+
p !== o && p.remove();
|
|
2150
|
+
})), o || (o = document.createElement("div"), o.className = "mint-choice-option-wrapper", o.style.position = "relative", this.insertBefore(o, this.firstChild)), o.className = `mint-choice-option-wrapper ${this._getWrapperClasses()}`, o.style.position = "relative", this.querySelectorAll('input[type="radio"]').forEach((p) => {
|
|
2151
|
+
p !== this._radio && p.remove();
|
|
1971
2152
|
}), this._radio)
|
|
1972
|
-
this._radio.parentElement !== o && o.appendChild(this._radio), this._radio && this._changeHandler && (this._radio.removeEventListener("change", this._changeHandler), this._radio.addEventListener("change", this._changeHandler)), this._radio && (this._focusHandler || (this._focusHandler = (
|
|
1973
|
-
const
|
|
1974
|
-
|
|
2153
|
+
this._radio.parentElement !== o && o.appendChild(this._radio), this._radio && this._changeHandler && (this._radio.removeEventListener("change", this._changeHandler), this._radio.addEventListener("change", this._changeHandler)), this._radio && (this._focusHandler || (this._focusHandler = (p) => {
|
|
2154
|
+
const f = this.querySelector(".mint-choice-option-wrapper");
|
|
2155
|
+
f && !this.isDisabled() && f.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
1975
2156
|
}), this._blurHandler || (this._blurHandler = () => {
|
|
1976
|
-
const
|
|
1977
|
-
|
|
1978
|
-
}), this._keydownHandler || (this._keydownHandler = (
|
|
1979
|
-
this.isDisabled() || (
|
|
2157
|
+
const p = this.querySelector(".mint-choice-option-wrapper");
|
|
2158
|
+
p && p.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2159
|
+
}), this._keydownHandler || (this._keydownHandler = (p) => {
|
|
2160
|
+
this.isDisabled() || (p.key === "ArrowDown" || p.key === "ArrowRight" ? (p.preventDefault(), this._focusNextOption()) : (p.key === "ArrowUp" || p.key === "ArrowLeft") && (p.preventDefault(), this._focusPreviousOption()));
|
|
1980
2161
|
}), this._radio.removeEventListener("focus", this._focusHandler), this._radio.removeEventListener("blur", this._blurHandler), this._radio.removeEventListener("keydown", this._keydownHandler), this._radio.addEventListener("focus", this._focusHandler), this._radio.addEventListener("blur", this._blurHandler), this._radio.addEventListener("keydown", this._keydownHandler));
|
|
1981
2162
|
else {
|
|
1982
|
-
this._radio = document.createElement("input"), this._radio.type = "radio", this._radio.className = "sr-only", this._radio.style.position = "absolute", this._radio.style.width = "1px", this._radio.style.height = "1px", this._radio.style.padding = "0", this._radio.style.margin = "-1px", this._radio.style.overflow = "hidden", this._radio.style.clip = "rect(0, 0, 0, 0)", this._radio.style.whiteSpace = "nowrap", this._radio.style.border = "0", o.appendChild(this._radio), this._changeHandler = (
|
|
1983
|
-
const
|
|
2163
|
+
this._radio = document.createElement("input"), this._radio.type = "radio", this._radio.className = "sr-only", this._radio.style.position = "absolute", this._radio.style.width = "1px", this._radio.style.height = "1px", this._radio.style.padding = "0", this._radio.style.margin = "-1px", this._radio.style.overflow = "hidden", this._radio.style.clip = "rect(0, 0, 0, 0)", this._radio.style.whiteSpace = "nowrap", this._radio.style.border = "0", o.appendChild(this._radio), this._changeHandler = (f) => {
|
|
2164
|
+
const b = this._checked;
|
|
1984
2165
|
this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState();
|
|
1985
|
-
const
|
|
1986
|
-
|
|
1987
|
-
|
|
2166
|
+
const g = this.closest("mint-choice");
|
|
2167
|
+
b !== this._checked && g && setTimeout(() => {
|
|
2168
|
+
g.dispatchEvent(new CustomEvent("choice-change", {
|
|
1988
2169
|
detail: { checked: this._checked, value: this.getValue() },
|
|
1989
2170
|
bubbles: !0,
|
|
1990
2171
|
cancelable: !0
|
|
1991
2172
|
}));
|
|
1992
2173
|
}, 0);
|
|
1993
2174
|
}, this._radio.addEventListener("change", this._changeHandler);
|
|
1994
|
-
const
|
|
2175
|
+
const p = () => {
|
|
1995
2176
|
this._radio && this._radio.checked !== this._checked && (this._checked = this._radio.checked, this._checked ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this._updateVisualState(), this._updateGroupState());
|
|
1996
2177
|
};
|
|
1997
|
-
this._radio.addEventListener("click",
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2178
|
+
this._radio.addEventListener("click", p), this._focusHandler = (f) => {
|
|
2179
|
+
const b = this.querySelector(".mint-choice-option-wrapper");
|
|
2180
|
+
b && !this.isDisabled() && b.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2000
2181
|
}, this._radio.addEventListener("focus", this._focusHandler), this._blurHandler = () => {
|
|
2001
|
-
const
|
|
2002
|
-
|
|
2003
|
-
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (
|
|
2004
|
-
this.isDisabled() || (
|
|
2182
|
+
const f = this.querySelector(".mint-choice-option-wrapper");
|
|
2183
|
+
f && f.classList.remove("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500");
|
|
2184
|
+
}, this._radio.addEventListener("blur", this._blurHandler), this._keydownHandler = (f) => {
|
|
2185
|
+
this.isDisabled() || (f.key === "ArrowDown" || f.key === "ArrowRight" ? (f.preventDefault(), this._focusNextOption()) : (f.key === "ArrowUp" || f.key === "ArrowLeft") && (f.preventDefault(), this._focusPreviousOption()));
|
|
2005
2186
|
}, this._radio.addEventListener("keydown", this._keydownHandler);
|
|
2006
2187
|
}
|
|
2007
|
-
this._radio.name = n, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = t, t ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((
|
|
2008
|
-
|
|
2188
|
+
this._radio.name = n, this._radio.value = i, this._radio.checked !== this._checked ? (this._checked = this._radio.checked, this._checked ? this.hasAttribute("checked") || this.setAttribute("checked", "") : this.hasAttribute("checked") && this.removeAttribute("checked")) : this._radio.checked = this._checked, this._radio.disabled = t, t ? this._radio.setAttribute("tabindex", "-1") : this._radio.removeAttribute("tabindex"), r ? this._radio.setAttribute("aria-label", r) : this._radio.removeAttribute("aria-label"), o.querySelectorAll(".mint-choice-option-indicator").forEach((p, f) => {
|
|
2189
|
+
f > 0 && p.remove();
|
|
2009
2190
|
});
|
|
2010
|
-
let
|
|
2011
|
-
|
|
2012
|
-
let
|
|
2013
|
-
r && (
|
|
2014
|
-
var
|
|
2015
|
-
|
|
2016
|
-
})),
|
|
2191
|
+
let d = o.querySelector(".mint-choice-option-indicator");
|
|
2192
|
+
d || (d = document.createElement("div"), d.className = "mint-choice-option-indicator", o.appendChild(d)), d.className = "mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none", d.style.position = "absolute", d.style.top = "50%", d.style.left = "50%", d.style.transform = this._checked ? "translate(-50%, -50%) scale(1)" : "translate(-50%, -50%) scale(0)", d.style.opacity = this._checked ? "1" : "0", this._updateVisualState(), this._renderSkeleton(e);
|
|
2193
|
+
let u = this.querySelector(".mint-choice-option-label");
|
|
2194
|
+
r && (u || (u = document.createElement("span"), u.className = "mint-choice-option-label", this.appendChild(u), Array.from(this.childNodes).forEach((p) => {
|
|
2195
|
+
var f;
|
|
2196
|
+
p.nodeType === Node.TEXT_NODE && ((f = p.textContent) != null && f.trim()) && (p.textContent = "");
|
|
2197
|
+
})), u.className = `mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t ? "opacity-40" : ""}`, u.textContent = r), t ? (this.classList.add("cursor-not-allowed"), this.classList.remove("cursor-pointer")) : (this.classList.add("cursor-pointer"), this.classList.remove("cursor-not-allowed")), this._updateVisualState();
|
|
2017
2198
|
}
|
|
2018
2199
|
_getWrapperClasses() {
|
|
2019
2200
|
const e = this.isDisabled(), t = [
|
|
@@ -2218,8 +2399,8 @@ class Q extends HTMLElement {
|
|
|
2218
2399
|
r || (r = document.createElement("div"), r.className = "mint-choice-label-container flex flex-col gap-0.5 mb-2", this.insertBefore(r, this.firstChild));
|
|
2219
2400
|
let o = r.querySelector(".mint-choice-label");
|
|
2220
2401
|
t ? (o || (o = document.createElement("label"), o.className = "mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", r.insertBefore(o, r.firstChild)), o.textContent = t, o.setAttribute("for", s), n ? o.classList.add("opacity-40") : o.classList.remove("opacity-40")) : o && o.remove();
|
|
2221
|
-
let
|
|
2222
|
-
i ? (
|
|
2402
|
+
let c = r.querySelector(".mint-choice-info");
|
|
2403
|
+
i ? (c || (c = document.createElement("span"), c.className = "mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none", r.appendChild(c)), c.textContent = i, n ? c.classList.add("opacity-40") : c.classList.remove("opacity-40")) : c && c.remove();
|
|
2223
2404
|
} else r && r.remove();
|
|
2224
2405
|
let a = this.querySelector(".mint-choice-options-wrapper");
|
|
2225
2406
|
if (!a) {
|
|
@@ -2265,7 +2446,7 @@ class ee extends HTMLElement {
|
|
|
2265
2446
|
return ["type", "placeholder", "value", "disabled", "id", "name", "required", "readonly", "rows", "icon", "label", "info", "error", "error-message", "loading"];
|
|
2266
2447
|
}
|
|
2267
2448
|
connectedCallback() {
|
|
2268
|
-
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.
|
|
2449
|
+
this.classList.add("box-border", "m-0", "p-0", "border-0", "align-baseline", "inline-block"), this.render();
|
|
2269
2450
|
}
|
|
2270
2451
|
disconnectedCallback() {
|
|
2271
2452
|
this.removeEventListeners();
|
|
@@ -2391,9 +2572,9 @@ class ee extends HTMLElement {
|
|
|
2391
2572
|
render() {
|
|
2392
2573
|
var y, x, k, E;
|
|
2393
2574
|
this.getType();
|
|
2394
|
-
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(),
|
|
2395
|
-
if (this._renderSkeleton(
|
|
2396
|
-
this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor =
|
|
2575
|
+
const e = this._getNormalizedType(), t = this._isTextarea(), i = this._isMoney(), s = this._isColor(), n = this.getPlaceholder(), r = this.isDisabled(), a = this.isReadonly(), l = this.isRequired(), o = this.getId(), c = this.getName(), h = this.getAttribute("value") || (s ? "#000000" : ""), d = this.getRows(), u = this.getIcon(), m = this.getLabel(), p = this.getInfo(), f = this.isLoading();
|
|
2576
|
+
if (this._renderSkeleton(f), s) {
|
|
2577
|
+
this._input && (this._input.remove(), this._input = null), this._textarea && (this._textarea.remove(), this._textarea = null), this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null), this._colorPickerWrapper || (this._colorPickerWrapper = document.createElement("div"), this._colorPickerWrapper.className = "mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", this._colorPickerWrapper.style.backgroundColor = h || "#000000", this._wrapper.appendChild(this._colorPickerWrapper), this._colorPicker = document.createElement("input"), this._colorPicker.type = "color", this._colorPicker.className = "absolute inset-0 w-full h-full opacity-0 cursor-pointer", this._colorPicker.style.cssText = "position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;", this._colorPickerWrapper.appendChild(this._colorPicker), this._focusHandler = (v) => {
|
|
2397
2578
|
this._colorPickerWrapper && this._colorPicker && this._colorPicker.matches(":focus-visible") && requestAnimationFrame(() => {
|
|
2398
2579
|
var C;
|
|
2399
2580
|
this._colorPicker && this._colorPicker.matches(":focus-visible") && ((C = this._colorPickerWrapper) == null || C.classList.add("ring-2", "ring-offset-1", "ring-gray-400", "dark:ring-gray-500"));
|
|
@@ -2433,64 +2614,64 @@ class ee extends HTMLElement {
|
|
|
2433
2614
|
cancelable: !0
|
|
2434
2615
|
}));
|
|
2435
2616
|
}));
|
|
2436
|
-
const
|
|
2437
|
-
if (this._colorPicker && this._colorPicker.value !==
|
|
2617
|
+
const _ = h || "#000000";
|
|
2618
|
+
if (this._colorPicker && this._colorPicker.value !== _ && (this._colorPicker.value = _), this._colorPickerWrapper && (this._colorPickerWrapper.style.backgroundColor = _), this._colorTextInput && this._colorTextInput.value !== _ && (this._colorTextInput.value = _), this._colorPicker && (this._colorPicker.disabled = r), this._colorPickerWrapper && (r ? (this._colorPickerWrapper.classList.add("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.remove("cursor-pointer")) : (this._colorPickerWrapper.classList.remove("opacity-40", "cursor-not-allowed"), this._colorPickerWrapper.classList.add("cursor-pointer"))), this._colorTextInput && (this._colorTextInput.disabled = r, this._colorTextInput.readOnly = a, this._colorTextInput.required = l), this._colorTextInput) {
|
|
2438
2619
|
const v = this._colorTextInput;
|
|
2439
|
-
o ? v.id = o : v.removeAttribute("id"),
|
|
2620
|
+
o ? v.id = o : v.removeAttribute("id"), c ? v.name = c : v.removeAttribute("name"), v.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), this._element = v;
|
|
2440
2621
|
}
|
|
2441
2622
|
this._renderErrorState();
|
|
2442
2623
|
return;
|
|
2443
2624
|
}
|
|
2444
|
-
if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null),
|
|
2625
|
+
if (this._wrapper || (this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper)), this._colorContainer && (this._colorContainer.remove(), this._colorContainer = null, this._colorPicker = null, this._colorTextInput = null), this._colorPickerWrapper && !s && (this._colorPickerWrapper.remove(), this._colorPickerWrapper = null, this._colorPicker = null, this._colorTextInput = null), u && !t ? this._icon ? this._icon.setAttribute("name", u) : (this._icon = document.createElement("mint-icon"), this._icon.setAttribute("name", u), this._icon.className = "absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none", this._wrapper.appendChild(this._icon)) : this._icon && (this._icon.remove(), this._icon = null), this._isNumber() && !t) {
|
|
2445
2626
|
if (!this._numberSpinnerContainer) {
|
|
2446
2627
|
this._numberSpinnerContainer = document.createElement("div"), this._numberSpinnerContainer.className = "absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none", this._wrapper.appendChild(this._numberSpinnerContainer), this._numberIncrementButton = document.createElement("button"), this._numberIncrementButton.type = "button", this._numberIncrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2447
|
-
const
|
|
2448
|
-
|
|
2628
|
+
const _ = document.createElement("mint-icon");
|
|
2629
|
+
_.setAttribute("name", "caret-up"), _.className = "w-[1rem] h-[1rem]", this._numberIncrementButton.appendChild(_), this._numberSpinnerContainer.appendChild(this._numberIncrementButton), this._numberDecrementButton = document.createElement("button"), this._numberDecrementButton.type = "button", this._numberDecrementButton.className = "flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";
|
|
2449
2630
|
const v = document.createElement("mint-icon");
|
|
2450
2631
|
v.setAttribute("name", "caret-down"), v.className = "w-[1rem] h-[1rem]", this._numberDecrementButton.appendChild(v), this._numberSpinnerContainer.appendChild(this._numberDecrementButton), this._numberIncrementButton.addEventListener("click", (C) => {
|
|
2451
2632
|
if (C.preventDefault(), C.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2452
|
-
const A = parseFloat(this._input.value) || 0, D = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0,
|
|
2633
|
+
const A = parseFloat(this._input.value) || 0, D = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, I = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2453
2634
|
let L = A + D;
|
|
2454
|
-
|
|
2635
|
+
I !== void 0 && L > I && (L = I), S !== void 0 && L < S && (L = S), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2455
2636
|
}
|
|
2456
2637
|
}), this._numberDecrementButton.addEventListener("click", (C) => {
|
|
2457
2638
|
if (C.preventDefault(), C.stopPropagation(), this._input && !this._input.disabled && !this._input.readOnly) {
|
|
2458
|
-
const A = parseFloat(this._input.value) || 0, D = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0,
|
|
2639
|
+
const A = parseFloat(this._input.value) || 0, D = parseFloat(this._input.step) || 1, S = this._input.min ? parseFloat(this._input.min) : void 0, I = this._input.max ? parseFloat(this._input.max) : void 0;
|
|
2459
2640
|
let L = A - D;
|
|
2460
|
-
S !== void 0 && L < S && (L = S),
|
|
2641
|
+
S !== void 0 && L < S && (L = S), I !== void 0 && L > I && (L = I), this._input.value = L.toString(), this.setAttribute("value", L.toString()), this._input.dispatchEvent(new Event("input", { bubbles: !0 })), this._input.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2461
2642
|
}
|
|
2462
2643
|
});
|
|
2463
2644
|
}
|
|
2464
2645
|
this._numberIncrementButton && (this._numberIncrementButton.disabled = r || a), this._numberDecrementButton && (this._numberDecrementButton.disabled = r || a);
|
|
2465
2646
|
} else this._numberSpinnerContainer && (this._numberSpinnerContainer.remove(), this._numberSpinnerContainer = null, this._numberIncrementButton = null, this._numberDecrementButton = null);
|
|
2466
2647
|
if (t) {
|
|
2467
|
-
if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = n, this._textarea.disabled = r, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows =
|
|
2468
|
-
const
|
|
2469
|
-
|
|
2648
|
+
if (this._input && (this._input.remove(), this._input = null), this._textarea || (this._textarea = document.createElement("textarea"), this._wrapper.appendChild(this._textarea), this.setupEventListeners()), this._element = this._textarea, this._textarea.placeholder = n, this._textarea.disabled = r, this._textarea.readOnly = a, this._textarea.required = l, this._textarea.rows = d, this._textarea.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), h !== this._textarea.value && (this._textarea.value = h), o ? this._textarea.id = o : this._textarea.removeAttribute("id"), c ? this._textarea.name = c : this._textarea.removeAttribute("name"), this._textarea.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2649
|
+
const _ = this.firstChild.textContent;
|
|
2650
|
+
_ && !this._textarea.value && (this._textarea.value = _.trim()), this.removeChild(this.firstChild);
|
|
2470
2651
|
}
|
|
2471
|
-
} else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder = n, this._input.disabled = r, this._input.readOnly = a, this._input.required = l, this._input.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), i ? (this._input.inputMode = "decimal", this._input.pattern = "[0-9]*\\.?[0-9]*") : (this._input.removeAttribute("inputmode"), this._input.removeAttribute("pattern")),
|
|
2472
|
-
const
|
|
2473
|
-
|
|
2652
|
+
} else if (this._textarea && (this._textarea.remove(), this._textarea = null), this._input || (this._input = document.createElement("input"), this._wrapper.appendChild(this._input), this.setupEventListeners()), this._element = this._input, this._input.type = e, this._input.placeholder = n, this._input.disabled = r, this._input.readOnly = a, this._input.required = l, this._input.setAttribute("aria-invalid", this.hasError() ? "true" : "false"), i ? (this._input.inputMode = "decimal", this._input.pattern = "[0-9]*\\.?[0-9]*") : (this._input.removeAttribute("inputmode"), this._input.removeAttribute("pattern")), h !== this._input.value && (this._input.value = h), o ? this._input.id = o : this._input.removeAttribute("id"), c ? this._input.name = c : this._input.removeAttribute("name"), this._input.className = this.getInputClasses(), this.firstChild && this.firstChild !== this._wrapper && this.firstChild.nodeType === Node.TEXT_NODE) {
|
|
2653
|
+
const _ = this.firstChild.textContent;
|
|
2654
|
+
_ && !this._input.value && (this._input.value = _.trim()), this.removeChild(this.firstChild);
|
|
2474
2655
|
}
|
|
2475
|
-
let
|
|
2476
|
-
if (
|
|
2477
|
-
|
|
2478
|
-
let
|
|
2479
|
-
if (
|
|
2480
|
-
|
|
2656
|
+
let g = this.querySelector(".mint-input-label-container");
|
|
2657
|
+
if (m || p) {
|
|
2658
|
+
g || (g = document.createElement("div"), g.className = "mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]", this._wrapper && this._wrapper.parentElement === this ? this.insertBefore(g, this._wrapper) : this.insertBefore(g, this.firstChild));
|
|
2659
|
+
let _ = g.querySelector(".mint-input-label");
|
|
2660
|
+
if (m) {
|
|
2661
|
+
_ || (_ = document.createElement("label"), _.className = "mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", g.insertBefore(_, g.firstChild)), _.textContent = m;
|
|
2481
2662
|
const C = o || ((y = this._element) == null ? void 0 : y.id) || ((x = this._colorTextInput) == null ? void 0 : x.id) || ((k = this._input) == null ? void 0 : k.id) || ((E = this._textarea) == null ? void 0 : E.id);
|
|
2482
2663
|
if (C)
|
|
2483
|
-
|
|
2664
|
+
_.setAttribute("for", C);
|
|
2484
2665
|
else {
|
|
2485
2666
|
const A = `mint-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
2486
|
-
this._element ? this._element.id = A : this._colorTextInput ? this._colorTextInput.id = A : this._input ? this._input.id = A : this._textarea && (this._textarea.id = A),
|
|
2667
|
+
this._element ? this._element.id = A : this._colorTextInput ? this._colorTextInput.id = A : this._input ? this._input.id = A : this._textarea && (this._textarea.id = A), _.setAttribute("for", A);
|
|
2487
2668
|
}
|
|
2488
|
-
r ?
|
|
2489
|
-
} else
|
|
2490
|
-
let v =
|
|
2491
|
-
|
|
2492
|
-
} else
|
|
2493
|
-
this._renderErrorState(), this._renderSkeleton(
|
|
2669
|
+
r ? _.classList.add("opacity-40") : _.classList.remove("opacity-40");
|
|
2670
|
+
} else _ && _.remove();
|
|
2671
|
+
let v = g.querySelector(".mint-input-info");
|
|
2672
|
+
p ? (v || (v = document.createElement("span"), v.className = "mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none", g.appendChild(v)), v.textContent = p, r ? v.classList.add("opacity-40") : v.classList.remove("opacity-40")) : v && v.remove();
|
|
2673
|
+
} else g && g.remove();
|
|
2674
|
+
this._renderErrorState(), this._renderSkeleton(f);
|
|
2494
2675
|
}
|
|
2495
2676
|
_renderErrorState() {
|
|
2496
2677
|
const e = this.hasError(), t = this.getErrorMessage();
|
|
@@ -2758,17 +2939,17 @@ class te extends HTMLElement {
|
|
|
2758
2939
|
}), s.addEventListener("keydown", (a) => {
|
|
2759
2940
|
a.key === "Backspace" && s.selectionStart === 0 && s.selectionEnd === 0 && this._focusPrev(e, n), a.key === "ArrowLeft" && s.selectionStart === 0 && s.selectionEnd === 0 && (this._focusPrev(e, n), a.preventDefault()), a.key === "ArrowRight" && s.selectionStart === s.value.length && s.selectionEnd === s.value.length && (this._focusNext(e, n), a.preventDefault());
|
|
2760
2941
|
}), s.addEventListener("blur", (a) => {
|
|
2761
|
-
var
|
|
2942
|
+
var c, h;
|
|
2762
2943
|
this._syncHiddenInput();
|
|
2763
2944
|
const l = a.relatedTarget;
|
|
2764
|
-
l && (this.contains(l) || (
|
|
2945
|
+
l && (this.contains(l) || (c = this._popover) != null && c.contains(l) || this._calendarContainer && this._calendarContainer.contains(l)) || (this._handleBlur(((h = this._hiddenInput) == null ? void 0 : h.value) || ""), this._exitInputMode(), setTimeout(() => {
|
|
2765
2946
|
if (this._hiddenInput) {
|
|
2766
|
-
const
|
|
2947
|
+
const d = new FocusEvent("blur", {
|
|
2767
2948
|
bubbles: !0,
|
|
2768
2949
|
cancelable: !0,
|
|
2769
2950
|
relatedTarget: a.relatedTarget
|
|
2770
2951
|
});
|
|
2771
|
-
this._hiddenInput.dispatchEvent(
|
|
2952
|
+
this._hiddenInput.dispatchEvent(d);
|
|
2772
2953
|
}
|
|
2773
2954
|
}, 0));
|
|
2774
2955
|
});
|
|
@@ -2796,55 +2977,55 @@ class te extends HTMLElement {
|
|
|
2796
2977
|
_parseDateString(e, t) {
|
|
2797
2978
|
const i = /[\/\-\.\s]+/;
|
|
2798
2979
|
if (i.test(e)) {
|
|
2799
|
-
const
|
|
2800
|
-
if (
|
|
2801
|
-
let
|
|
2802
|
-
for (let k = 0; k <
|
|
2803
|
-
const E =
|
|
2980
|
+
const f = e.split(i).filter((g) => g.length > 0), b = t.split(/[\/\-\.\s]+/).filter((g) => g.length > 0);
|
|
2981
|
+
if (f.length === b.length) {
|
|
2982
|
+
let g = 0, y = 0, x = 0;
|
|
2983
|
+
for (let k = 0; k < b.length; k++) {
|
|
2984
|
+
const E = b[k].toLowerCase(), _ = f[k];
|
|
2804
2985
|
if (E.includes("d"))
|
|
2805
|
-
|
|
2986
|
+
g = parseInt(_, 10);
|
|
2806
2987
|
else if (E.includes("m"))
|
|
2807
|
-
y = parseInt(
|
|
2988
|
+
y = parseInt(_, 10) - 1;
|
|
2808
2989
|
else if (E.includes("y")) {
|
|
2809
|
-
let v = parseInt(
|
|
2810
|
-
const C = E.length, A =
|
|
2990
|
+
let v = parseInt(_, 10);
|
|
2991
|
+
const C = E.length, A = _.length;
|
|
2811
2992
|
A === 2 && C === 4 ? v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v : A === 2 && C === 2 && (v = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + v), x = v;
|
|
2812
2993
|
}
|
|
2813
2994
|
}
|
|
2814
|
-
if (
|
|
2815
|
-
const k = new Date(x, y,
|
|
2816
|
-
if (!isNaN(k.getTime()) && k.getDate() ===
|
|
2995
|
+
if (g && y >= 0 && y <= 11 && x) {
|
|
2996
|
+
const k = new Date(x, y, g);
|
|
2997
|
+
if (!isNaN(k.getTime()) && k.getDate() === g && k.getMonth() === y && k.getFullYear() === x)
|
|
2817
2998
|
return k;
|
|
2818
2999
|
}
|
|
2819
3000
|
}
|
|
2820
3001
|
}
|
|
2821
3002
|
const n = e.replace(/[\/\-\.]/g, ""), r = t.replace(/[\/\-\.]/g, "").toLowerCase();
|
|
2822
3003
|
let a = r.indexOf("d"), l = r.indexOf("m"), o = r.indexOf("y");
|
|
2823
|
-
const
|
|
3004
|
+
const c = [
|
|
2824
3005
|
{ char: "d", index: a },
|
|
2825
3006
|
{ char: "m", index: l },
|
|
2826
3007
|
{ char: "y", index: o }
|
|
2827
|
-
].sort((
|
|
2828
|
-
let
|
|
3008
|
+
].sort((f, b) => f.index - b.index);
|
|
3009
|
+
let h = 0, d = 0, u = 0, m = 0;
|
|
2829
3010
|
r.length, n.length;
|
|
2830
|
-
for (const
|
|
2831
|
-
if (
|
|
2832
|
-
const
|
|
2833
|
-
if (
|
|
2834
|
-
|
|
2835
|
-
} else if (
|
|
2836
|
-
const
|
|
2837
|
-
if (
|
|
2838
|
-
|
|
2839
|
-
} else if (
|
|
2840
|
-
const
|
|
3011
|
+
for (const f of c)
|
|
3012
|
+
if (f.char === "d") {
|
|
3013
|
+
const b = r.lastIndexOf("d") - r.indexOf("d") + 1, g = n.substr(m, b);
|
|
3014
|
+
if (g.length === 0) return null;
|
|
3015
|
+
h = parseInt(g, 10), m += g.length;
|
|
3016
|
+
} else if (f.char === "m") {
|
|
3017
|
+
const b = r.lastIndexOf("m") - r.indexOf("m") + 1, g = n.substr(m, b);
|
|
3018
|
+
if (g.length === 0) return null;
|
|
3019
|
+
d = parseInt(g, 10) - 1, m += g.length;
|
|
3020
|
+
} else if (f.char === "y") {
|
|
3021
|
+
const b = r.lastIndexOf("y") - r.indexOf("y") + 1, g = n.substr(m), y = Math.min(b, g.length), x = g.substr(0, y);
|
|
2841
3022
|
if (x.length === 0) return null;
|
|
2842
3023
|
let k = parseInt(x, 10);
|
|
2843
|
-
y === 2 &&
|
|
3024
|
+
y === 2 && b === 4 ? k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k : y === 2 && b === 2 && (k = Math.floor((/* @__PURE__ */ new Date()).getFullYear() / 100) * 100 + k), u = k, m += y;
|
|
2844
3025
|
}
|
|
2845
|
-
if (!
|
|
2846
|
-
const
|
|
2847
|
-
return isNaN(
|
|
3026
|
+
if (!h || d < 0 || d > 11 || !u) return null;
|
|
3027
|
+
const p = new Date(u, d, h);
|
|
3028
|
+
return isNaN(p.getTime()) || p.getDate() !== h || p.getMonth() !== d || p.getFullYear() !== u ? null : p;
|
|
2848
3029
|
}
|
|
2849
3030
|
_formatDate(e, t) {
|
|
2850
3031
|
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = t.toLowerCase();
|
|
@@ -2853,104 +3034,104 @@ class te extends HTMLElement {
|
|
|
2853
3034
|
}
|
|
2854
3035
|
// PHP-style formatter for display mode
|
|
2855
3036
|
_formatDatePhp(e, t) {
|
|
2856
|
-
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
|
2857
|
-
const
|
|
2858
|
-
return
|
|
3037
|
+
const i = e.getDate(), s = e.getMonth() + 1, n = e.getFullYear(), r = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], a = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], l = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], o = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], c = (u, m = 2) => u.toString().padStart(m, "0"), h = (u) => {
|
|
3038
|
+
const m = u % 10, p = u % 100;
|
|
3039
|
+
return m === 1 && p !== 11 ? "st" : m === 2 && p !== 12 ? "nd" : m === 3 && p !== 13 ? "rd" : "th";
|
|
2859
3040
|
};
|
|
2860
|
-
let
|
|
2861
|
-
for (let
|
|
2862
|
-
const
|
|
2863
|
-
if (
|
|
2864
|
-
|
|
3041
|
+
let d = "";
|
|
3042
|
+
for (let u = 0; u < t.length; u++) {
|
|
3043
|
+
const m = t[u];
|
|
3044
|
+
if (m === "\\" && u + 1 < t.length) {
|
|
3045
|
+
d += t[u + 1], u++;
|
|
2865
3046
|
continue;
|
|
2866
3047
|
}
|
|
2867
|
-
switch (
|
|
3048
|
+
switch (m) {
|
|
2868
3049
|
case "Y":
|
|
2869
|
-
|
|
3050
|
+
d += n.toString();
|
|
2870
3051
|
break;
|
|
2871
3052
|
case "y":
|
|
2872
|
-
|
|
3053
|
+
d += n.toString().slice(-2);
|
|
2873
3054
|
break;
|
|
2874
3055
|
case "m":
|
|
2875
|
-
|
|
3056
|
+
d += c(s);
|
|
2876
3057
|
break;
|
|
2877
3058
|
case "n":
|
|
2878
|
-
|
|
3059
|
+
d += s.toString();
|
|
2879
3060
|
break;
|
|
2880
3061
|
case "M":
|
|
2881
|
-
|
|
3062
|
+
d += o[s - 1];
|
|
2882
3063
|
break;
|
|
2883
3064
|
case "F":
|
|
2884
|
-
|
|
3065
|
+
d += l[s - 1];
|
|
2885
3066
|
break;
|
|
2886
3067
|
case "d":
|
|
2887
|
-
|
|
3068
|
+
d += c(i);
|
|
2888
3069
|
break;
|
|
2889
3070
|
case "j":
|
|
2890
|
-
|
|
3071
|
+
d += i.toString();
|
|
2891
3072
|
break;
|
|
2892
3073
|
case "D":
|
|
2893
|
-
|
|
3074
|
+
d += a[e.getDay()];
|
|
2894
3075
|
break;
|
|
2895
3076
|
case "l":
|
|
2896
|
-
|
|
3077
|
+
d += r[e.getDay()];
|
|
2897
3078
|
break;
|
|
2898
3079
|
case "S":
|
|
2899
|
-
|
|
3080
|
+
d += h(i);
|
|
2900
3081
|
break;
|
|
2901
3082
|
default:
|
|
2902
|
-
|
|
3083
|
+
d += m;
|
|
2903
3084
|
break;
|
|
2904
3085
|
}
|
|
2905
3086
|
}
|
|
2906
|
-
return
|
|
3087
|
+
return d;
|
|
2907
3088
|
}
|
|
2908
3089
|
_validateDateString(e, t) {
|
|
2909
3090
|
const i = this._parseDateString(e, t);
|
|
2910
3091
|
return i !== null && !isNaN(i.getTime());
|
|
2911
3092
|
}
|
|
2912
3093
|
render() {
|
|
2913
|
-
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(),
|
|
3094
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getInfo(), s = this.getValue(), n = this.isDisabled(), r = this.isReadonly(), a = this.isRequired(), l = this.getId(), o = this.getName(), c = this.getFormat(), h = this.hasError(), d = this.getErrorMessage();
|
|
2914
3095
|
this._isRange = this.isRange(), this._input || (this._input = document.createElement("div"), this._input.className = "relative w-full", this.appendChild(this._input));
|
|
2915
|
-
let
|
|
3096
|
+
let u = this.querySelector(".mint-date-picker-label-container");
|
|
2916
3097
|
if (t || i) {
|
|
2917
|
-
|
|
2918
|
-
let y =
|
|
2919
|
-
t ? (y || (y = document.createElement("label"), y.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",
|
|
2920
|
-
let x =
|
|
2921
|
-
i ? (x || (x = document.createElement("span"), x.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",
|
|
2922
|
-
} else
|
|
2923
|
-
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = s || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), l && (this._hiddenInput.id = l), o && (this._hiddenInput.name = o), this._hiddenInput.value = s || "", this._hiddenInput.setAttribute("aria-invalid",
|
|
2924
|
-
let
|
|
2925
|
-
|
|
2926
|
-
const
|
|
2927
|
-
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${
|
|
3098
|
+
u || (u = document.createElement("div"), u.className = "mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]", this.contains(this._input) ? this.insertBefore(u, this._input) : this.appendChild(u));
|
|
3099
|
+
let y = u.querySelector(".mint-date-picker-label");
|
|
3100
|
+
t ? (y || (y = document.createElement("label"), y.className = "mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none", u.insertBefore(y, u.firstChild)), y.textContent = t, l && this._textInput && y.setAttribute("for", l)) : y && y.remove();
|
|
3101
|
+
let x = u.querySelector(".mint-date-picker-info");
|
|
3102
|
+
i ? (x || (x = document.createElement("span"), x.className = "mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none", u.appendChild(x)), x.textContent = i) : x && x.remove();
|
|
3103
|
+
} else u && u.remove();
|
|
3104
|
+
this._hiddenInput || (this._hiddenInput = document.createElement("input"), this._hiddenInput.type = "hidden", this._hiddenInput.value = s || "", this._textInput = this._hiddenInput, this._input.appendChild(this._hiddenInput)), l && (this._hiddenInput.id = l), o && (this._hiddenInput.name = o), this._hiddenInput.value = s || "", this._hiddenInput.setAttribute("aria-invalid", h ? "true" : "false");
|
|
3105
|
+
let m = this._input.querySelector(".mint-date-fields");
|
|
3106
|
+
m || (m = document.createElement("div"), this._input.appendChild(m)), this._fieldsContainer = m, this._applyErrorVisuals(h, d, n), m.innerHTML = "", this._displayEl = document.createElement("div");
|
|
3107
|
+
const p = r ? "select-text" : "select-none";
|
|
3108
|
+
this._displayEl.className = `flex-1 text-gray-900 dark:text-white ${r ? "cursor-default" : "cursor-text"} ${p} focus:outline-none`, this._displayEl.tabIndex = n || r ? -1 : 0, this._displayEl.addEventListener("click", () => {
|
|
2928
3109
|
n || r || this._enterInputMode();
|
|
2929
3110
|
}), this._displayEl.addEventListener("keydown", (y) => {
|
|
2930
3111
|
n || r || (y.key === "Enter" || y.key === " ") && (y.preventDefault(), this._enterInputMode());
|
|
2931
3112
|
}), this._inputsWrapperEl = document.createElement("div"), this._inputsWrapperEl.className = "flex items-center gap-1 w-full";
|
|
2932
|
-
const
|
|
3113
|
+
const f = this._getFormatTokens(c);
|
|
2933
3114
|
this._startPartInputs = [], this._endPartInputs = [];
|
|
2934
|
-
const
|
|
3115
|
+
const b = (y) => {
|
|
2935
3116
|
const x = document.createDocumentFragment();
|
|
2936
|
-
return
|
|
3117
|
+
return f.forEach((k) => {
|
|
2937
3118
|
if (k.type === "sep") {
|
|
2938
3119
|
const E = document.createElement("span");
|
|
2939
3120
|
E.textContent = k.value, E.className = "text-gray-400 dark:text-gray-500 select-none", x.appendChild(E);
|
|
2940
3121
|
} else {
|
|
2941
|
-
const E = k.part === "d" ? "dd" : k.part === "m" ? "mm" : k.len === 2 ? "yy" : "yyyy",
|
|
2942
|
-
y === "start" ? this._startPartInputs.push(
|
|
3122
|
+
const E = k.part === "d" ? "dd" : k.part === "m" ? "mm" : k.len === 2 ? "yy" : "yyyy", _ = this._createPartInput(k.len, E, n, r, a);
|
|
3123
|
+
y === "start" ? this._startPartInputs.push(_) : this._endPartInputs.push(_), x.appendChild(_);
|
|
2943
3124
|
}
|
|
2944
3125
|
}), x;
|
|
2945
3126
|
};
|
|
2946
|
-
if (this._inputsWrapperEl.appendChild(
|
|
3127
|
+
if (this._inputsWrapperEl.appendChild(b("start")), this._isRange) {
|
|
2947
3128
|
const y = document.createElement("span");
|
|
2948
|
-
y.textContent = " - ", y.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(y), this._inputsWrapperEl.appendChild(
|
|
3129
|
+
y.textContent = " - ", y.className = "text-gray-400 dark:text-gray-500 select-none", this._inputsWrapperEl.appendChild(y), this._inputsWrapperEl.appendChild(b("end"));
|
|
2949
3130
|
}
|
|
2950
|
-
const
|
|
2951
|
-
if (
|
|
3131
|
+
const g = document.createElement("div");
|
|
3132
|
+
if (g.className = "flex flex-col w-full", this._displayEl.style.display = this._isInputMode ? "none" : "flex", this._inputsWrapperEl.style.display = this._isInputMode ? "flex" : "none", g.appendChild(this._displayEl), g.appendChild(this._inputsWrapperEl), m.appendChild(g), m.addEventListener("click", () => {
|
|
2952
3133
|
this._isInputMode || n || r || this._enterInputMode();
|
|
2953
|
-
}), this._attachPartInputHandlers(this._startPartInputs,
|
|
3134
|
+
}), this._attachPartInputHandlers(this._startPartInputs, f, m), this._isRange && this._attachPartInputHandlers(this._endPartInputs, f, m), this._parseValue(s), this._syncHiddenInput(), this._updateDisplayText(), this._iconButton)
|
|
2954
3135
|
this._iconButton.disabled = n || r, !n && !r ? this._iconButton.tabIndex = 0 : this._iconButton.tabIndex = -1;
|
|
2955
3136
|
else {
|
|
2956
3137
|
this._iconButton = document.createElement("button"), this._iconButton.type = "button", this._iconButton.tabIndex = 0, this._iconButton.className = "absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";
|
|
@@ -2961,7 +3142,7 @@ class te extends HTMLElement {
|
|
|
2961
3142
|
n || r || this._enterInputMode();
|
|
2962
3143
|
}), this._input.prepend(this._iconButton), this._iconButton.disabled = n || r;
|
|
2963
3144
|
}
|
|
2964
|
-
this._renderErrorState(
|
|
3145
|
+
this._renderErrorState(h, d), this._renderSkeleton(e);
|
|
2965
3146
|
}
|
|
2966
3147
|
_renderErrorState(e, t) {
|
|
2967
3148
|
let i = this.querySelector(".mint-date-picker-error");
|
|
@@ -3009,8 +3190,8 @@ class te extends HTMLElement {
|
|
|
3009
3190
|
if (this._isRange) {
|
|
3010
3191
|
const [i, s] = this._splitRangeInput(e, t), n = i ? this._parseDateString(i, t) : null, r = s ? this._parseDateString(s, t) : null;
|
|
3011
3192
|
if (n && r) {
|
|
3012
|
-
const [a, l] = n <= r ? [n, r] : [r, n], o = this._formatDate(a, t),
|
|
3013
|
-
this.setValue(
|
|
3193
|
+
const [a, l] = n <= r ? [n, r] : [r, n], o = this._formatDate(a, t), c = this._formatDate(l, t), h = `${o} - ${c}`;
|
|
3194
|
+
this.setValue(h), this._applyDateToParts(a, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(l, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = a, this._selectedEndDate = l, this._currentMonth = a.getMonth(), this._currentYear = a.getFullYear();
|
|
3014
3195
|
} else if (n) {
|
|
3015
3196
|
const a = this._formatDate(n, t);
|
|
3016
3197
|
this.setValue(a), this._applyDateToParts(n, this._startPartInputs, this._getFormatTokens(t), t), this._applyDateToParts(null, this._endPartInputs, this._getFormatTokens(t), t), this._selectedStartDate = n, this._selectedEndDate = null, this._currentMonth = n.getMonth(), this._currentYear = n.getFullYear();
|
|
@@ -3121,59 +3302,59 @@ class te extends HTMLElement {
|
|
|
3121
3302
|
l.className = "flex-1 min-w-0";
|
|
3122
3303
|
const o = document.createElement("div");
|
|
3123
3304
|
o.className = "flex items-center justify-between mb-4";
|
|
3124
|
-
const
|
|
3125
|
-
|
|
3126
|
-
const
|
|
3127
|
-
|
|
3305
|
+
const c = document.createElement("button");
|
|
3306
|
+
c.type = "button", c.tabIndex = 0, c.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", c.setAttribute("data-keep-popover-open", "true");
|
|
3307
|
+
const h = document.createElement("mint-icon");
|
|
3308
|
+
h.setAttribute("name", "caret-left"), h.className = "w-4 h-4", c.appendChild(h), c.addEventListener("click", () => {
|
|
3128
3309
|
this._currentMonth === 0 ? (this._currentMonth = 11, this._currentYear--) : this._currentMonth--, this._buildCalendar();
|
|
3129
|
-
}), o.appendChild(
|
|
3130
|
-
const
|
|
3131
|
-
|
|
3132
|
-
const
|
|
3133
|
-
|
|
3310
|
+
}), o.appendChild(c);
|
|
3311
|
+
const d = document.createElement("div");
|
|
3312
|
+
d.className = "flex items-center gap-2";
|
|
3313
|
+
const u = document.createElement("button");
|
|
3314
|
+
u.type = "button", u.tabIndex = 0, u.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", u.setAttribute("data-keep-popover-open", "true"), u.textContent = i[this._currentMonth], u.addEventListener("click", () => {
|
|
3134
3315
|
this._viewMode = "month", this._buildCalendar();
|
|
3135
|
-
}),
|
|
3136
|
-
const
|
|
3137
|
-
|
|
3316
|
+
}), d.appendChild(u);
|
|
3317
|
+
const m = document.createElement("button");
|
|
3318
|
+
m.type = "button", m.tabIndex = 0, m.className = "text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", m.setAttribute("data-keep-popover-open", "true"), m.textContent = String(this._currentYear), m.addEventListener("click", () => {
|
|
3138
3319
|
this._viewMode = "year", this._buildCalendar();
|
|
3139
|
-
}),
|
|
3140
|
-
const
|
|
3141
|
-
|
|
3142
|
-
const
|
|
3143
|
-
|
|
3320
|
+
}), d.appendChild(m), o.appendChild(d);
|
|
3321
|
+
const p = document.createElement("button");
|
|
3322
|
+
p.type = "button", p.tabIndex = 0, p.className = "p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", p.setAttribute("data-keep-popover-open", "true");
|
|
3323
|
+
const f = document.createElement("mint-icon");
|
|
3324
|
+
f.setAttribute("name", "caret-right"), f.className = "w-4 h-4", p.appendChild(f), p.addEventListener("click", () => {
|
|
3144
3325
|
this._currentMonth === 11 ? (this._currentMonth = 0, this._currentYear++) : this._currentMonth++, this._buildCalendar();
|
|
3145
|
-
}), o.appendChild(
|
|
3146
|
-
const
|
|
3147
|
-
|
|
3326
|
+
}), o.appendChild(p);
|
|
3327
|
+
const b = document.createElement("div");
|
|
3328
|
+
b.className = "grid grid-cols-7 mb-2", s.forEach((k) => {
|
|
3148
3329
|
const E = document.createElement("div");
|
|
3149
|
-
E.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", E.textContent = k,
|
|
3330
|
+
E.className = "text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1", E.textContent = k, b.appendChild(E);
|
|
3150
3331
|
});
|
|
3151
|
-
const
|
|
3152
|
-
|
|
3332
|
+
const g = document.createElement("div");
|
|
3333
|
+
g.className = "grid grid-cols-7";
|
|
3153
3334
|
for (let k = 0; k < t; k++) {
|
|
3154
3335
|
const E = document.createElement("div");
|
|
3155
|
-
E.className = "w-8 h-8",
|
|
3336
|
+
E.className = "w-8 h-8", g.appendChild(E);
|
|
3156
3337
|
}
|
|
3157
3338
|
const y = this.getMin() ? this._parseDateString(this.getMin(), this.getFormat()) : null, x = this.getMax() ? this._parseDateString(this.getMax(), this.getFormat()) : null;
|
|
3158
3339
|
for (let k = 1; k <= e; k++) {
|
|
3159
|
-
const E = new Date(this._currentYear, this._currentMonth, k),
|
|
3340
|
+
const E = new Date(this._currentYear, this._currentMonth, k), _ = this._isToday(E), v = this._isDateSelected(E), C = this._isDateInRange(E), A = y && E < y || x && E > x;
|
|
3160
3341
|
let D = "rounded-md";
|
|
3161
3342
|
if (this._isRange && this._selectedStartDate && this._selectedEndDate) {
|
|
3162
|
-
const
|
|
3163
|
-
|
|
3343
|
+
const I = this._isSameDate(E, this._selectedStartDate), L = this._isSameDate(E, this._selectedEndDate);
|
|
3344
|
+
I && L ? D = "rounded-md" : I ? D = "rounded-l-md" : L ? D = "rounded-r-md" : C && (D = "rounded-none");
|
|
3164
3345
|
} else v && !this._isRange && (D = "rounded-md");
|
|
3165
3346
|
const S = document.createElement("button");
|
|
3166
|
-
S.type = "button", S.disabled = !!A, S.tabIndex = A ? -1 : 0, S.className = `w-full h-8 ${D} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${v ? "bg-slate-800 dark:bg-slate-600 text-white" : C ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" :
|
|
3347
|
+
S.type = "button", S.disabled = !!A, S.tabIndex = A ? -1 : 0, S.className = `w-full h-8 ${D} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${v ? "bg-slate-800 dark:bg-slate-600 text-white" : C ? "bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200" : _ ? "text-gray-900 dark:text-gray-100 font-semibold" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"} ${A ? "opacity-40 cursor-not-allowed" : ""}`, S.textContent = k.toString(), A || S.addEventListener("click", () => {
|
|
3167
3348
|
this._handleDateClick(E);
|
|
3168
|
-
}),
|
|
3349
|
+
}), g.appendChild(S);
|
|
3169
3350
|
}
|
|
3170
3351
|
if (r) {
|
|
3171
3352
|
const k = document.createElement("div");
|
|
3172
3353
|
k.className = "mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";
|
|
3173
3354
|
const E = document.createElement("div");
|
|
3174
3355
|
E.className = "relative md:relative md:flex-1 md:min-h-0";
|
|
3175
|
-
const
|
|
3176
|
-
|
|
3356
|
+
const _ = document.createElement("div");
|
|
3357
|
+
_.className = "flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2", _.style.scrollbarWidth = "none", _.style.msOverflowStyle = "none", _.style.setProperty("-webkit-overflow-scrolling", "touch");
|
|
3177
3358
|
const v = document.createElement("style");
|
|
3178
3359
|
v.textContent = `
|
|
3179
3360
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
@@ -3199,7 +3380,7 @@ class te extends HTMLElement {
|
|
|
3199
3380
|
background: rgba(255, 255, 255, 0.2);
|
|
3200
3381
|
}
|
|
3201
3382
|
}
|
|
3202
|
-
`,
|
|
3383
|
+
`, _.classList.add("mint-date-shortcuts-row"), document.head.querySelector("style[data-mint-date-shortcuts]") || (v.setAttribute("data-mint-date-shortcuts", "true"), document.head.appendChild(v));
|
|
3203
3384
|
const C = document.createElement("div");
|
|
3204
3385
|
C.className = "absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden", E.appendChild(C);
|
|
3205
3386
|
const A = document.createElement("div");
|
|
@@ -3208,28 +3389,28 @@ class te extends HTMLElement {
|
|
|
3208
3389
|
D.className = "hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200", E.appendChild(D);
|
|
3209
3390
|
const S = document.createElement("div");
|
|
3210
3391
|
S.className = "hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200", E.appendChild(S);
|
|
3211
|
-
const
|
|
3392
|
+
const I = () => {
|
|
3212
3393
|
if (window.innerWidth >= 768) {
|
|
3213
|
-
const H =
|
|
3214
|
-
H > 0 ? D.style.opacity = "1" : D.style.opacity = "0", H + N <
|
|
3394
|
+
const H = _.scrollTop, T = _.scrollHeight, N = _.clientHeight;
|
|
3395
|
+
H > 0 ? D.style.opacity = "1" : D.style.opacity = "0", H + N < T - 1 ? S.style.opacity = "1" : S.style.opacity = "0", C.style.opacity = "0", A.style.opacity = "0";
|
|
3215
3396
|
} else {
|
|
3216
|
-
const H =
|
|
3217
|
-
H > 0 ? C.style.opacity = "1" : C.style.opacity = "0", H + N <
|
|
3397
|
+
const H = _.scrollLeft, T = _.scrollWidth, N = _.clientWidth;
|
|
3398
|
+
H > 0 ? C.style.opacity = "1" : C.style.opacity = "0", H + N < T - 1 ? A.style.opacity = "1" : A.style.opacity = "0", D.style.opacity = "0", S.style.opacity = "0";
|
|
3218
3399
|
}
|
|
3219
3400
|
};
|
|
3220
|
-
|
|
3401
|
+
_.addEventListener("scroll", I), window.addEventListener("resize", I), setTimeout(I, 0), n.forEach((L) => {
|
|
3221
3402
|
const H = document.createElement("button");
|
|
3222
3403
|
H.type = "button", H.tabIndex = 0, H.className = "px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500", H.textContent = L.label, H.setAttribute("data-keep-popover-open", "true"), H.addEventListener("click", () => {
|
|
3223
|
-
const
|
|
3224
|
-
if (
|
|
3225
|
-
if (this._isRange && "start" in
|
|
3226
|
-
this._selectedStartDate =
|
|
3227
|
-
const N = this.getFormat(), M = this._formatDate(
|
|
3228
|
-
this.setValue(P), this._currentMonth =
|
|
3229
|
-
} else if (
|
|
3230
|
-
this._selectedStartDate =
|
|
3231
|
-
const N = this.getFormat(), M = this._formatDate(
|
|
3232
|
-
this.setValue(M), this._currentMonth =
|
|
3404
|
+
const T = L.action();
|
|
3405
|
+
if (T) {
|
|
3406
|
+
if (this._isRange && "start" in T && "end" in T) {
|
|
3407
|
+
this._selectedStartDate = T.start, this._selectedEndDate = T.end;
|
|
3408
|
+
const N = this.getFormat(), M = this._formatDate(T.start, N), F = this._formatDate(T.end, N), P = `${M} - ${F}`;
|
|
3409
|
+
this.setValue(P), this._currentMonth = T.start.getMonth(), this._currentYear = T.start.getFullYear();
|
|
3410
|
+
} else if (T instanceof Date) {
|
|
3411
|
+
this._selectedStartDate = T, this._selectedEndDate = null;
|
|
3412
|
+
const N = this.getFormat(), M = this._formatDate(T, N);
|
|
3413
|
+
this.setValue(M), this._currentMonth = T.getMonth(), this._currentYear = T.getFullYear();
|
|
3233
3414
|
}
|
|
3234
3415
|
this._buildCalendar(), this._popover && typeof this._popover.close == "function" && this._popover.close(), this.dispatchEvent(new CustomEvent("input", {
|
|
3235
3416
|
detail: { value: this.getValue() },
|
|
@@ -3241,10 +3422,10 @@ class te extends HTMLElement {
|
|
|
3241
3422
|
cancelable: !0
|
|
3242
3423
|
}));
|
|
3243
3424
|
}
|
|
3244
|
-
}),
|
|
3245
|
-
}), E.appendChild(
|
|
3425
|
+
}), _.appendChild(H);
|
|
3426
|
+
}), E.appendChild(_), k.appendChild(E), a.appendChild(k);
|
|
3246
3427
|
}
|
|
3247
|
-
l.appendChild(o), l.appendChild(
|
|
3428
|
+
l.appendChild(o), l.appendChild(b), l.appendChild(g), a.appendChild(l), this._calendarContainer.appendChild(a);
|
|
3248
3429
|
}
|
|
3249
3430
|
_buildMonthView() {
|
|
3250
3431
|
if (!this._calendarContainer) return;
|
|
@@ -3267,13 +3448,13 @@ class te extends HTMLElement {
|
|
|
3267
3448
|
this._currentYear++, this._buildCalendar();
|
|
3268
3449
|
}), t.appendChild(r);
|
|
3269
3450
|
const l = document.createElement("div");
|
|
3270
|
-
l.className = "grid grid-cols-3 gap-2", e.forEach((o,
|
|
3271
|
-
const
|
|
3272
|
-
|
|
3273
|
-
const
|
|
3274
|
-
|
|
3275
|
-
this._currentMonth =
|
|
3276
|
-
}), l.appendChild(
|
|
3451
|
+
l.className = "grid grid-cols-3 gap-2", e.forEach((o, c) => {
|
|
3452
|
+
const h = document.createElement("button");
|
|
3453
|
+
h.type = "button", h.tabIndex = 0, h.setAttribute("data-keep-popover-open", "true");
|
|
3454
|
+
const d = this._currentMonth === c;
|
|
3455
|
+
h.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${d ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, h.textContent = o, h.addEventListener("click", () => {
|
|
3456
|
+
this._currentMonth = c, this._viewMode = "calendar", this._buildCalendar();
|
|
3457
|
+
}), l.appendChild(h);
|
|
3277
3458
|
}), this._calendarContainer.appendChild(t), this._calendarContainer.appendChild(l);
|
|
3278
3459
|
}
|
|
3279
3460
|
_buildYearView() {
|
|
@@ -3296,13 +3477,13 @@ class te extends HTMLElement {
|
|
|
3296
3477
|
}), i.appendChild(a);
|
|
3297
3478
|
const o = document.createElement("div");
|
|
3298
3479
|
o.className = "grid grid-cols-3 gap-2";
|
|
3299
|
-
for (let
|
|
3300
|
-
const
|
|
3301
|
-
|
|
3302
|
-
const
|
|
3303
|
-
|
|
3304
|
-
this._currentYear =
|
|
3305
|
-
}), o.appendChild(
|
|
3480
|
+
for (let c = e; c <= t; c++) {
|
|
3481
|
+
const h = document.createElement("button");
|
|
3482
|
+
h.type = "button", h.tabIndex = 0, h.setAttribute("data-keep-popover-open", "true");
|
|
3483
|
+
const d = this._currentYear === c;
|
|
3484
|
+
h.className = `p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${d ? "bg-slate-800 dark:bg-slate-600 text-white" : "text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`, h.textContent = String(c), h.addEventListener("click", () => {
|
|
3485
|
+
this._currentYear = c, this._viewMode = "calendar", this._buildCalendar();
|
|
3486
|
+
}), o.appendChild(h);
|
|
3306
3487
|
}
|
|
3307
3488
|
this._calendarContainer.appendChild(i), this._calendarContainer.appendChild(o);
|
|
3308
3489
|
}
|
|
@@ -3541,45 +3722,45 @@ class ie extends HTMLElement {
|
|
|
3541
3722
|
}
|
|
3542
3723
|
render() {
|
|
3543
3724
|
const e = this.isLoading(), t = [];
|
|
3544
|
-
this._select && Array.from(this._select.children).forEach((
|
|
3545
|
-
(
|
|
3725
|
+
this._select && Array.from(this._select.children).forEach((u) => {
|
|
3726
|
+
(u.tagName === "OPTION" || u.tagName === "OPTGROUP") && t.push(u.cloneNode(!0));
|
|
3546
3727
|
});
|
|
3547
|
-
const i = Array.from(this.children).filter((
|
|
3728
|
+
const i = Array.from(this.children).filter((u) => u.tagName === "OPTION" || u.tagName === "OPTGROUP").map((u) => u.cloneNode(!0));
|
|
3548
3729
|
for (; this.firstChild; )
|
|
3549
3730
|
this.removeChild(this.firstChild);
|
|
3550
3731
|
this._wrapper = null, this._select = null;
|
|
3551
|
-
const s = this.getLabel(), n = this.getInfo(), r = this.getId(), a = this.getName(), l = this.getValue(), o = this.isDisabled(),
|
|
3732
|
+
const s = this.getLabel(), n = this.getInfo(), r = this.getId(), a = this.getName(), l = this.getValue(), o = this.isDisabled(), c = this.isMultiple(), h = this.hasError();
|
|
3552
3733
|
if (s) {
|
|
3553
|
-
const
|
|
3554
|
-
|
|
3555
|
-
const
|
|
3556
|
-
|
|
3734
|
+
const u = document.createElement("label");
|
|
3735
|
+
u.className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1", r && u.setAttribute("for", r);
|
|
3736
|
+
const m = document.createTextNode(s);
|
|
3737
|
+
u.appendChild(m), this.appendChild(u);
|
|
3557
3738
|
}
|
|
3558
|
-
this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), a && (this._select.name = a), o && (this._select.disabled = !0),
|
|
3559
|
-
const
|
|
3560
|
-
if (
|
|
3561
|
-
this._select.appendChild(
|
|
3739
|
+
this._wrapper = document.createElement("div"), this._wrapper.className = "relative w-full", this.appendChild(this._wrapper), this._select = document.createElement("select"), this._select.className = this.getSelectClasses(), r && (this._select.id = r), a && (this._select.name = a), o && (this._select.disabled = !0), c && (this._select.multiple = !0), this._select.setAttribute("aria-invalid", h ? "true" : "false");
|
|
3740
|
+
const d = t.length > 0 ? t : i;
|
|
3741
|
+
if (d.length > 0 && d.forEach((u) => {
|
|
3742
|
+
this._select.appendChild(u);
|
|
3562
3743
|
}), this._select.options.length === 0) {
|
|
3563
|
-
const
|
|
3564
|
-
|
|
3744
|
+
const u = document.createElement("option");
|
|
3745
|
+
u.value = "", u.textContent = "Select an option", u.disabled = !0, u.selected = !0, this._select.appendChild(u);
|
|
3565
3746
|
}
|
|
3566
|
-
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (
|
|
3567
|
-
const
|
|
3568
|
-
|
|
3569
|
-
detail: { value:
|
|
3747
|
+
if (this._select.value = l || "", this._changeHandler && this._select && this._select.removeEventListener("change", this._changeHandler), this._changeHandler = (u) => {
|
|
3748
|
+
const p = u.target.value;
|
|
3749
|
+
p ? this.setAttribute("value", p) : this.removeAttribute("value"), this.dispatchEvent(new CustomEvent("change", {
|
|
3750
|
+
detail: { value: p },
|
|
3570
3751
|
bubbles: !0,
|
|
3571
3752
|
cancelable: !0,
|
|
3572
3753
|
composed: !0
|
|
3573
3754
|
}));
|
|
3574
|
-
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select),
|
|
3755
|
+
}, this._select.addEventListener("change", this._changeHandler), this._wrapper.appendChild(this._select), c)
|
|
3575
3756
|
this._caretUpIcon = null, this._caretDownIcon = null;
|
|
3576
3757
|
else {
|
|
3577
|
-
const
|
|
3578
|
-
|
|
3758
|
+
const u = document.createElement("div");
|
|
3759
|
+
u.className = "absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col", this._caretUpIcon = document.createElement("mint-icon"), this._caretUpIcon.setAttribute("name", "caret-up"), this._caretUpIcon.className = "w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]", u.appendChild(this._caretUpIcon), this._caretDownIcon = document.createElement("mint-icon"), this._caretDownIcon.setAttribute("name", "caret-down"), this._caretDownIcon.className = "w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]", u.appendChild(this._caretDownIcon), this._wrapper.appendChild(u);
|
|
3579
3760
|
}
|
|
3580
3761
|
if (n) {
|
|
3581
|
-
const
|
|
3582
|
-
|
|
3762
|
+
const u = document.createElement("div");
|
|
3763
|
+
u.className = "mt-1 text-xs text-gray-500 dark:text-gray-400", u.textContent = n, this.appendChild(u);
|
|
3583
3764
|
}
|
|
3584
3765
|
this._renderErrorState(), this._renderSkeleton(e);
|
|
3585
3766
|
}
|
|
@@ -3704,18 +3885,18 @@ class se extends HTMLElement {
|
|
|
3704
3885
|
return this.hasAttribute("loading");
|
|
3705
3886
|
}
|
|
3706
3887
|
render() {
|
|
3707
|
-
const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), n = this.isDisabled(), r = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(),
|
|
3888
|
+
const e = this.isLoading(), t = this.getLabel(), i = this.getAccept(), s = this.isMultiple(), n = this.isDisabled(), r = this.getWidth(), a = this.getHeight(), l = this.getName(), o = this.hasError(), c = this.getErrorMessage();
|
|
3708
3889
|
this._dropzone || (this._dropzone = document.createElement("div"), this.appendChild(this._dropzone)), this._updateDragStateClass(), this._dropzone.setAttribute("aria-invalid", o ? "true" : "false"), n ? (this._dropzone.setAttribute("tabindex", "-1"), this._dropzone.removeAttribute("role")) : (this._dropzone.setAttribute("tabindex", "0"), this._dropzone.setAttribute("role", "button"), this._dropzone.setAttribute("aria-label", t || "File upload dropzone")), this._dropzone.style.width = r, this._dropzone.style.height = a, this._dropzone.style.minWidth = r, this._dropzone.style.minHeight = a, this._fileInput || (this._fileInput = document.createElement("input"), this._fileInput.type = "file", this._fileInput.style.display = "none", this._fileInput.setAttribute("tabindex", "-1"), this._fileInput.setAttribute("aria-hidden", "true"), this._dropzone.appendChild(this._fileInput)), this._fileInput.accept = i, this._fileInput.multiple = s, this._fileInput.disabled = n, l ? this._fileInput.name = l : this._fileInput.removeAttribute("name"), this._fileInput.setAttribute("aria-invalid", o ? "true" : "false");
|
|
3709
|
-
const
|
|
3710
|
-
|
|
3711
|
-
const
|
|
3712
|
-
|
|
3713
|
-
const
|
|
3714
|
-
if (
|
|
3715
|
-
const
|
|
3716
|
-
|
|
3890
|
+
const h = this._dropzone.querySelector(".mint-dropzone-icon"), d = this._dropzone.querySelector(".mint-dropzone-label");
|
|
3891
|
+
h && h.remove(), d && d.remove();
|
|
3892
|
+
const u = document.createElement("div");
|
|
3893
|
+
u.className = "mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";
|
|
3894
|
+
const m = document.createElement("mint-icon");
|
|
3895
|
+
if (m.setAttribute("name", "upload"), m.className = "w-12 h-12 text-gray-400 dark:text-gray-500", u.appendChild(m), this._dropzone.appendChild(u), t) {
|
|
3896
|
+
const p = document.createElement("div");
|
|
3897
|
+
p.className = "mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0", p.textContent = t, this._dropzone.appendChild(p);
|
|
3717
3898
|
}
|
|
3718
|
-
this.setupEventListeners(), this._renderErrorState(o,
|
|
3899
|
+
this.setupEventListeners(), this._renderErrorState(o, c), this._renderPreviews(), this._renderSkeleton(e);
|
|
3719
3900
|
}
|
|
3720
3901
|
_updateDragState() {
|
|
3721
3902
|
this._dropzone && this._updateDragStateClass();
|
|
@@ -3868,25 +4049,25 @@ class se extends HTMLElement {
|
|
|
3868
4049
|
const e = document.createElement("div");
|
|
3869
4050
|
e.className = "mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";
|
|
3870
4051
|
const t = document.createElement("div");
|
|
3871
|
-
t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((o,
|
|
3872
|
-
const
|
|
3873
|
-
if (
|
|
3874
|
-
const
|
|
3875
|
-
|
|
3876
|
-
const
|
|
3877
|
-
this._previewUrls.push(
|
|
4052
|
+
t.className = "mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2", this._selectedFiles.forEach((o, c) => {
|
|
4053
|
+
const h = document.createElement("div");
|
|
4054
|
+
if (h.className = "flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800", o.type.startsWith("image/")) {
|
|
4055
|
+
const p = document.createElement("img");
|
|
4056
|
+
p.className = "w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";
|
|
4057
|
+
const f = URL.createObjectURL(o);
|
|
4058
|
+
this._previewUrls.push(f), p.src = f, h.appendChild(p);
|
|
3878
4059
|
} else {
|
|
3879
|
-
const
|
|
3880
|
-
|
|
4060
|
+
const p = document.createElement("mint-icon");
|
|
4061
|
+
p.setAttribute("name", "attach"), p.className = "w-5 h-5 text-gray-500 dark:text-gray-300", h.appendChild(p);
|
|
3881
4062
|
}
|
|
3882
|
-
const
|
|
3883
|
-
|
|
3884
|
-
const
|
|
3885
|
-
|
|
3886
|
-
const
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
}),
|
|
4063
|
+
const d = document.createElement("div");
|
|
4064
|
+
d.className = "flex-1 text-sm text-gray-800 dark:text-gray-100 truncate", d.textContent = o.name, h.appendChild(d);
|
|
4065
|
+
const u = document.createElement("button");
|
|
4066
|
+
u.type = "button", u.className = "text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";
|
|
4067
|
+
const m = document.createElement("mint-icon");
|
|
4068
|
+
m.setAttribute("name", "close"), m.className = "w-4 h-4", u.appendChild(m), u.addEventListener("click", (p) => {
|
|
4069
|
+
p.preventDefault(), p.stopPropagation(), this._removeFileAt(c);
|
|
4070
|
+
}), h.appendChild(u), t.appendChild(h);
|
|
3890
4071
|
});
|
|
3891
4072
|
const i = this.hasError(), s = this._isDragging;
|
|
3892
4073
|
let n = "from-white dark:from-gray-700";
|
|
@@ -3896,8 +4077,8 @@ class se extends HTMLElement {
|
|
|
3896
4077
|
const a = document.createElement("div");
|
|
3897
4078
|
a.className = `absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`, e.appendChild(a);
|
|
3898
4079
|
const l = () => {
|
|
3899
|
-
const o = t.scrollTop,
|
|
3900
|
-
o > 0 ? r.style.opacity = "1" : r.style.opacity = "0", o +
|
|
4080
|
+
const o = t.scrollTop, c = t.scrollHeight, h = t.clientHeight;
|
|
4081
|
+
o > 0 ? r.style.opacity = "1" : r.style.opacity = "0", o + h < c - 1 ? a.style.opacity = "1" : a.style.opacity = "0";
|
|
3901
4082
|
};
|
|
3902
4083
|
l(), t.addEventListener("scroll", l), e.appendChild(t), this._previewContainer = e, this._dropzone.appendChild(e), this._updateDragStateClass();
|
|
3903
4084
|
}
|
|
@@ -4074,99 +4255,99 @@ class re extends HTMLElement {
|
|
|
4074
4255
|
}
|
|
4075
4256
|
}
|
|
4076
4257
|
async _submitData(e, t) {
|
|
4077
|
-
var
|
|
4258
|
+
var h, d, u;
|
|
4078
4259
|
const i = this.getAttribute("action"), s = this.getAttribute("method"), n = this.getAttribute("enctype") || "application/x-www-form-urlencoded";
|
|
4079
4260
|
if (!i)
|
|
4080
4261
|
return { status: 0, ok: !0, data: { values: t } };
|
|
4081
|
-
const r = Array.from(e.values()).some((
|
|
4262
|
+
const r = Array.from(e.values()).some((m) => m instanceof File);
|
|
4082
4263
|
let a = null;
|
|
4083
4264
|
const l = {};
|
|
4084
4265
|
let o = i;
|
|
4085
|
-
if (typeof window < "u" && ((
|
|
4086
|
-
const
|
|
4087
|
-
e.forEach((
|
|
4088
|
-
|
|
4089
|
-
}), o += (i.includes("?") ? "&" : "?") +
|
|
4266
|
+
if (typeof window < "u" && ((u = (d = (h = window.mintForm) == null ? void 0 : h.defaults) == null ? void 0 : d.headers) != null && u.common) && Object.assign(l, window.mintForm.defaults.headers.common), this._headers && Object.assign(l, this._headers), s === "GET") {
|
|
4267
|
+
const m = new URLSearchParams();
|
|
4268
|
+
e.forEach((p, f) => {
|
|
4269
|
+
p instanceof File || m.append(f, String(p));
|
|
4270
|
+
}), o += (i.includes("?") ? "&" : "?") + m.toString();
|
|
4090
4271
|
} else if (n === "multipart/form-data" || r)
|
|
4091
4272
|
a = e;
|
|
4092
4273
|
else if (n === "application/json")
|
|
4093
4274
|
a = JSON.stringify(t), l["Content-Type"] = "application/json";
|
|
4094
4275
|
else {
|
|
4095
|
-
const
|
|
4096
|
-
e.forEach((
|
|
4097
|
-
|
|
4098
|
-
}), a =
|
|
4276
|
+
const m = new URLSearchParams();
|
|
4277
|
+
e.forEach((p, f) => {
|
|
4278
|
+
p instanceof File || m.append(f, String(p));
|
|
4279
|
+
}), a = m, l["Content-Type"] = "application/x-www-form-urlencoded";
|
|
4099
4280
|
}
|
|
4100
4281
|
if (typeof fetch == "function")
|
|
4101
4282
|
try {
|
|
4102
|
-
const
|
|
4283
|
+
const m = await fetch(o, {
|
|
4103
4284
|
method: s || "POST",
|
|
4104
4285
|
body: s === "GET" ? null : a,
|
|
4105
4286
|
headers: l
|
|
4106
|
-
}),
|
|
4107
|
-
let
|
|
4287
|
+
}), p = await m.text().catch(() => "");
|
|
4288
|
+
let f = p;
|
|
4108
4289
|
try {
|
|
4109
|
-
|
|
4290
|
+
f = JSON.parse(p);
|
|
4110
4291
|
} catch {
|
|
4111
4292
|
}
|
|
4112
|
-
if (!
|
|
4113
|
-
const
|
|
4114
|
-
throw await this._applyErrorInterceptors(
|
|
4293
|
+
if (!m.ok) {
|
|
4294
|
+
const g = { status: m.status, data: f, response: { status: m.status, data: f } };
|
|
4295
|
+
throw await this._applyErrorInterceptors(g);
|
|
4115
4296
|
}
|
|
4116
|
-
const
|
|
4117
|
-
return await this._applySuccessInterceptors(
|
|
4118
|
-
} catch (
|
|
4119
|
-
if (
|
|
4120
|
-
throw
|
|
4121
|
-
const
|
|
4122
|
-
status:
|
|
4123
|
-
data:
|
|
4124
|
-
response: { status:
|
|
4297
|
+
const b = { status: m.status, ok: m.ok, data: f };
|
|
4298
|
+
return await this._applySuccessInterceptors(b);
|
|
4299
|
+
} catch (m) {
|
|
4300
|
+
if (m.response)
|
|
4301
|
+
throw m;
|
|
4302
|
+
const p = {
|
|
4303
|
+
status: m.status || 0,
|
|
4304
|
+
data: m.data || m.message || "Network error",
|
|
4305
|
+
response: { status: m.status || 0, data: m.data || m.message || "Network error" }
|
|
4125
4306
|
};
|
|
4126
|
-
throw await this._applyErrorInterceptors(
|
|
4307
|
+
throw await this._applyErrorInterceptors(p);
|
|
4127
4308
|
}
|
|
4128
|
-
const
|
|
4129
|
-
return await new Promise(async (
|
|
4130
|
-
const
|
|
4131
|
-
|
|
4132
|
-
const { status:
|
|
4133
|
-
if (
|
|
4134
|
-
let y =
|
|
4309
|
+
const c = this;
|
|
4310
|
+
return await new Promise(async (m, p) => {
|
|
4311
|
+
const f = new XMLHttpRequest();
|
|
4312
|
+
f.open(s || "POST", o, !0), Object.entries(l).forEach(([b, g]) => f.setRequestHeader(b, g)), f.onload = async function() {
|
|
4313
|
+
const { status: b, responseText: g } = f;
|
|
4314
|
+
if (b >= 200 && b < 300) {
|
|
4315
|
+
let y = g;
|
|
4135
4316
|
try {
|
|
4136
|
-
y = JSON.parse(
|
|
4317
|
+
y = JSON.parse(g);
|
|
4137
4318
|
} catch {
|
|
4138
4319
|
}
|
|
4139
4320
|
try {
|
|
4140
|
-
const x = { status:
|
|
4141
|
-
|
|
4321
|
+
const x = { status: b, ok: !0, data: y }, k = await c._applySuccessInterceptors(x);
|
|
4322
|
+
m(k);
|
|
4142
4323
|
} catch (x) {
|
|
4143
|
-
|
|
4324
|
+
p(x);
|
|
4144
4325
|
}
|
|
4145
4326
|
} else {
|
|
4146
|
-
let y =
|
|
4327
|
+
let y = g;
|
|
4147
4328
|
try {
|
|
4148
|
-
y = JSON.parse(
|
|
4329
|
+
y = JSON.parse(g);
|
|
4149
4330
|
} catch {
|
|
4150
4331
|
}
|
|
4151
4332
|
try {
|
|
4152
|
-
const x = { status:
|
|
4153
|
-
|
|
4333
|
+
const x = { status: b, data: y, response: { status: b, data: y } }, k = await c._applyErrorInterceptors(x);
|
|
4334
|
+
p(k);
|
|
4154
4335
|
} catch (x) {
|
|
4155
|
-
|
|
4336
|
+
p(x);
|
|
4156
4337
|
}
|
|
4157
4338
|
}
|
|
4158
|
-
},
|
|
4339
|
+
}, f.onerror = async function() {
|
|
4159
4340
|
try {
|
|
4160
|
-
const
|
|
4161
|
-
status:
|
|
4162
|
-
data:
|
|
4163
|
-
response: { status:
|
|
4164
|
-
},
|
|
4165
|
-
|
|
4166
|
-
} catch (
|
|
4167
|
-
|
|
4341
|
+
const b = {
|
|
4342
|
+
status: f.status || 0,
|
|
4343
|
+
data: f.responseText || "Network error",
|
|
4344
|
+
response: { status: f.status || 0, data: f.responseText || "Network error" }
|
|
4345
|
+
}, g = await c._applyErrorInterceptors(b);
|
|
4346
|
+
p(g);
|
|
4347
|
+
} catch (b) {
|
|
4348
|
+
p(b);
|
|
4168
4349
|
}
|
|
4169
|
-
},
|
|
4350
|
+
}, f.send(s === "GET" ? null : a);
|
|
4170
4351
|
});
|
|
4171
4352
|
}
|
|
4172
4353
|
async _applySuccessInterceptors(e) {
|
|
@@ -4207,10 +4388,10 @@ class re extends HTMLElement {
|
|
|
4207
4388
|
const l = r.files;
|
|
4208
4389
|
if (l.length > 0) {
|
|
4209
4390
|
const o = Array.from(l);
|
|
4210
|
-
t[a] && Array.isArray(t[a]) ? o.forEach((
|
|
4391
|
+
t[a] && Array.isArray(t[a]) ? o.forEach((c) => {
|
|
4211
4392
|
t[a].some(
|
|
4212
|
-
(
|
|
4213
|
-
) || t[a].push(
|
|
4393
|
+
(d) => d.name === c.name && d.size === c.size && d.lastModified === c.lastModified
|
|
4394
|
+
) || t[a].push(c);
|
|
4214
4395
|
}) : t[a] = o;
|
|
4215
4396
|
}
|
|
4216
4397
|
}
|
|
@@ -4220,7 +4401,7 @@ class re extends HTMLElement {
|
|
|
4220
4401
|
const l = Array.from(r.files);
|
|
4221
4402
|
t[a] && Array.isArray(t[a]) ? l.forEach((o) => {
|
|
4222
4403
|
t[a].some(
|
|
4223
|
-
(
|
|
4404
|
+
(h) => h.name === o.name && h.size === o.size && h.lastModified === o.lastModified
|
|
4224
4405
|
) || t[a].push(o);
|
|
4225
4406
|
}) : t[a] = l;
|
|
4226
4407
|
}
|
|
@@ -4229,7 +4410,7 @@ class re extends HTMLElement {
|
|
|
4229
4410
|
if (a) {
|
|
4230
4411
|
let l = [];
|
|
4231
4412
|
if (typeof r.tags < "u" ? l = r.tags : typeof r.getTags == "function" && (l = r.getTags()), Array.isArray(l) && l.length > 0) {
|
|
4232
|
-
const o = l.map((
|
|
4413
|
+
const o = l.map((c) => typeof c == "string" ? c : (c == null ? void 0 : c.value) || (c == null ? void 0 : c.label) || "").filter((c) => c.trim() !== "");
|
|
4233
4414
|
t[a] = o;
|
|
4234
4415
|
} else
|
|
4235
4416
|
t[a] = [];
|
|
@@ -4556,8 +4737,8 @@ class re extends HTMLElement {
|
|
|
4556
4737
|
if (!n) return;
|
|
4557
4738
|
const r = this._getFieldName(n);
|
|
4558
4739
|
if (!r || !this._collectValidationRules()[r]) return;
|
|
4559
|
-
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0),
|
|
4560
|
-
(o ||
|
|
4740
|
+
const l = this._extractFieldValue([n]), o = l != null && (typeof l == "string" ? l.trim() !== "" : l instanceof FileList || Array.isArray(l) ? l.length > 0 : !0), c = n.hasAttribute("data-mint-form-error") || s instanceof HTMLElement && (s.hasAttribute("aria-invalid") || s.closest("[data-mint-form-error]")), h = !!n.closest("mint-tags"), d = n.tagName === "MINT-CHECKBOX" || n.tagName === "MINT-SWITCH" || n.tagName === "MINT-CHOICE" || s instanceof HTMLElement && (s.closest("mint-checkbox, mint-switch, mint-choice") || s.closest("mint-choice-option")), u = n.tagName === "MINT-DATE-PICKER" || s instanceof HTMLElement && s.closest("mint-date-picker");
|
|
4741
|
+
(o || c || h || d || u) && setTimeout(() => {
|
|
4561
4742
|
this._validateField(r);
|
|
4562
4743
|
}, 0);
|
|
4563
4744
|
};
|
|
@@ -4566,38 +4747,38 @@ class re extends HTMLElement {
|
|
|
4566
4747
|
const s = i.target;
|
|
4567
4748
|
if (!s) return;
|
|
4568
4749
|
if (i.type === "tags-change" && s.tagName === "MINT-TAGS") {
|
|
4569
|
-
const
|
|
4570
|
-
if (!
|
|
4750
|
+
const c = s, h = this._getFieldName(c);
|
|
4751
|
+
if (!h || !this._collectValidationRules()[h]) return;
|
|
4571
4752
|
setTimeout(() => {
|
|
4572
|
-
this._validateField(
|
|
4753
|
+
this._validateField(h);
|
|
4573
4754
|
}, 0);
|
|
4574
4755
|
return;
|
|
4575
4756
|
}
|
|
4576
4757
|
if (s instanceof HTMLSelectElement || s.tagName === "MINT-SELECT" || s.closest("mint-select")) {
|
|
4577
|
-
const
|
|
4578
|
-
if (!
|
|
4579
|
-
const
|
|
4580
|
-
if (!
|
|
4758
|
+
const c = this._findFieldElement(s);
|
|
4759
|
+
if (!c) return;
|
|
4760
|
+
const h = this._getFieldName(c);
|
|
4761
|
+
if (!h || !this._collectValidationRules()[h]) return;
|
|
4581
4762
|
setTimeout(() => {
|
|
4582
|
-
this._validateField(
|
|
4763
|
+
this._validateField(h);
|
|
4583
4764
|
}, 0);
|
|
4584
4765
|
return;
|
|
4585
4766
|
}
|
|
4586
4767
|
if (i.type === "choice-change" && s.tagName === "MINT-CHOICE") {
|
|
4587
|
-
const
|
|
4588
|
-
if (!
|
|
4768
|
+
const c = s, h = this._getFieldName(c);
|
|
4769
|
+
if (!h || !this._collectValidationRules()[h]) return;
|
|
4589
4770
|
setTimeout(() => {
|
|
4590
|
-
this._validateField(
|
|
4771
|
+
this._validateField(h);
|
|
4591
4772
|
}, 0);
|
|
4592
4773
|
return;
|
|
4593
4774
|
}
|
|
4594
4775
|
if (s instanceof HTMLInputElement && s.type === "checkbox" || s.tagName === "MINT-CHECKBOX" || s.tagName === "MINT-SWITCH" || s.closest("mint-checkbox, mint-switch")) {
|
|
4595
|
-
const
|
|
4596
|
-
if (!
|
|
4597
|
-
const
|
|
4598
|
-
if (!
|
|
4776
|
+
const c = this._findFieldElement(s);
|
|
4777
|
+
if (!c) return;
|
|
4778
|
+
const h = this._getFieldName(c);
|
|
4779
|
+
if (!h || !this._collectValidationRules()[h]) return;
|
|
4599
4780
|
setTimeout(() => {
|
|
4600
|
-
this._validateField(
|
|
4781
|
+
this._validateField(h);
|
|
4601
4782
|
}, 0);
|
|
4602
4783
|
return;
|
|
4603
4784
|
}
|
|
@@ -4787,11 +4968,7 @@ class ne extends HTMLElement {
|
|
|
4787
4968
|
"align-baseline",
|
|
4788
4969
|
"block",
|
|
4789
4970
|
"w-full",
|
|
4790
|
-
"overflow-x-auto"
|
|
4791
|
-
"border",
|
|
4792
|
-
"border-gray-200",
|
|
4793
|
-
"rounded-lg",
|
|
4794
|
-
"dark:border-gray-700"
|
|
4971
|
+
"overflow-x-auto"
|
|
4795
4972
|
), this.hasAttribute("collapse") && !this.hasAttribute("scroll") && this._ensureResponsiveStyles(), this._observeChanges(), this._applyStyles(), requestAnimationFrame(() => {
|
|
4796
4973
|
this._applyStyles(), setTimeout(() => this._applyStyles(), 0);
|
|
4797
4974
|
});
|
|
@@ -4819,52 +4996,56 @@ class ne extends HTMLElement {
|
|
|
4819
4996
|
const t = this.hasAttribute("collapse") && !this.hasAttribute("scroll"), i = this.hasAttribute("scroll");
|
|
4820
4997
|
i ? this.classList.add("relative") : this.classList.remove("relative");
|
|
4821
4998
|
const s = [], n = e.querySelector("thead tr");
|
|
4822
|
-
n && n.querySelectorAll("th").forEach((
|
|
4999
|
+
n && n.querySelectorAll("th").forEach((c) => s.push((c.textContent || "").trim())), this._setClasses(e, [
|
|
4823
5000
|
"w-full",
|
|
4824
5001
|
i ? "min-w-[1200px]" : "",
|
|
4825
5002
|
"border-collapse",
|
|
4826
5003
|
"text-sm",
|
|
4827
5004
|
"font-medium",
|
|
4828
|
-
"rounded-lg",
|
|
4829
|
-
"border-2",
|
|
4830
|
-
"border-gray-200",
|
|
4831
|
-
"dark:border-gray-700",
|
|
4832
5005
|
"overflow-hidden"
|
|
4833
5006
|
]);
|
|
4834
5007
|
const r = e.querySelector("thead");
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
this._setClasses(h, [
|
|
4840
|
-
"text-left",
|
|
4841
|
-
"font-semibold",
|
|
4842
|
-
"text-gray-900",
|
|
4843
|
-
"dark:text-white",
|
|
4844
|
-
"px-3",
|
|
4845
|
-
"py-2",
|
|
4846
|
-
"border-b",
|
|
4847
|
-
"border-gray-200",
|
|
4848
|
-
"dark:border-gray-700"
|
|
5008
|
+
if (r) {
|
|
5009
|
+
this._setClasses(r, [
|
|
5010
|
+
"bg-[#F7F7F7]",
|
|
5011
|
+
"dark:bg-gray-800"
|
|
4849
5012
|
]);
|
|
4850
|
-
|
|
5013
|
+
const o = r.querySelectorAll("th");
|
|
5014
|
+
o.forEach((c, h) => {
|
|
5015
|
+
const d = c.querySelector("mint-icon"), u = (d == null ? void 0 : d.getAttribute("name")) || "", m = d !== null && u !== "ellipsis";
|
|
5016
|
+
this._setClasses(c, [
|
|
5017
|
+
"text-left",
|
|
5018
|
+
"font-semibold",
|
|
5019
|
+
"text-gray-900",
|
|
5020
|
+
"dark:text-white",
|
|
5021
|
+
"px-3",
|
|
5022
|
+
"py-2",
|
|
5023
|
+
"border-b",
|
|
5024
|
+
"border-gray-200",
|
|
5025
|
+
"dark:border-gray-700"
|
|
5026
|
+
]), m && c.classList.add("cursor-pointer", "hover:bg-gray-100", "dark:hover:bg-gray-700", "transition-colors"), h === 0 && c.classList.add("pl-6"), h === o.length - 1 && c.classList.add("pr-6");
|
|
5027
|
+
});
|
|
5028
|
+
}
|
|
4851
5029
|
const a = e.querySelector("tbody");
|
|
4852
5030
|
if (a) {
|
|
4853
5031
|
const o = Array.from(a.querySelectorAll("tr"));
|
|
4854
|
-
o.forEach((
|
|
4855
|
-
|
|
5032
|
+
o.forEach((c, h) => {
|
|
5033
|
+
const d = c.hasAttribute("data-row-clickable");
|
|
5034
|
+
this._setClasses(c, [
|
|
4856
5035
|
"bg-white",
|
|
4857
5036
|
"dark:bg-gray-900",
|
|
4858
5037
|
"border-b",
|
|
4859
5038
|
"border-gray-200",
|
|
4860
5039
|
"dark:border-gray-700"
|
|
4861
|
-
]), c === o.length - 1 &&
|
|
4862
|
-
|
|
5040
|
+
]), d && c.classList.add("cursor-pointer", "hover:bg-gray-50", "dark:hover:bg-gray-800", "transition-colors"), h === o.length - 1 && c.classList.remove("border-b");
|
|
5041
|
+
const u = c.querySelectorAll("td");
|
|
5042
|
+
u.forEach((m, p) => {
|
|
5043
|
+
this._setClasses(m, [
|
|
4863
5044
|
"text-gray-900",
|
|
4864
5045
|
"dark:text-gray-100",
|
|
4865
5046
|
"px-3",
|
|
4866
5047
|
"py-2"
|
|
4867
|
-
]), t ? this._applyMobileCell(
|
|
5048
|
+
]), p === 0 && m.classList.add("pl-6"), p === u.length - 1 && m.classList.add("pr-6"), t ? this._applyMobileCell(m, s) : this._restoreCell(m);
|
|
4868
5049
|
});
|
|
4869
5050
|
});
|
|
4870
5051
|
}
|
|
@@ -4873,8 +5054,8 @@ class ne extends HTMLElement {
|
|
|
4873
5054
|
"bg-[#F7F7F7]",
|
|
4874
5055
|
"dark:bg-gray-800",
|
|
4875
5056
|
"font-semibold"
|
|
4876
|
-
]), l.querySelectorAll("td").forEach((
|
|
4877
|
-
this._setClasses(
|
|
5057
|
+
]), l.querySelectorAll("td").forEach((c) => {
|
|
5058
|
+
this._setClasses(c, [
|
|
4878
5059
|
"text-gray-900",
|
|
4879
5060
|
"dark:text-gray-100",
|
|
4880
5061
|
"px-3",
|
|
@@ -4882,22 +5063,34 @@ class ne extends HTMLElement {
|
|
|
4882
5063
|
"border-t",
|
|
4883
5064
|
"border-gray-200",
|
|
4884
5065
|
"dark:border-gray-700"
|
|
4885
|
-
]), this._restoreCell(
|
|
5066
|
+
]), this._restoreCell(c);
|
|
4886
5067
|
})), this._observer && this._observeChanges();
|
|
4887
5068
|
}
|
|
4888
5069
|
_applyMobileCell(e, t) {
|
|
4889
5070
|
if (e.closest("tfoot") || e.dataset.mtProcessed === "true") return;
|
|
4890
|
-
const i = t[e.cellIndex] || "", s =
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
5071
|
+
const i = t[e.cellIndex] || "", s = {};
|
|
5072
|
+
Array.from(e.attributes).forEach((o) => {
|
|
5073
|
+
o.name.startsWith("data-") && o.name !== "data-original" && o.name !== "data-mt-processed" && (s[o.name] = o.value);
|
|
5074
|
+
});
|
|
5075
|
+
const n = e.getAttribute("data-original"), r = n !== null ? n : e.innerHTML;
|
|
5076
|
+
e.setAttribute("data-original", r), e.dataset.mtProcessed = "true", e.innerHTML = "";
|
|
4894
5077
|
const a = document.createElement("span");
|
|
4895
|
-
a.className = "mt-
|
|
5078
|
+
a.className = "mt-label font-semibold text-gray-700 dark:text-gray-200 hidden", a.textContent = i;
|
|
5079
|
+
const l = document.createElement("span");
|
|
5080
|
+
l.className = "mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full", l.innerHTML = r, e.appendChild(a), e.appendChild(l), Object.entries(s).forEach(([o, c]) => {
|
|
5081
|
+
e.setAttribute(o, c);
|
|
5082
|
+
});
|
|
4896
5083
|
}
|
|
4897
5084
|
_restoreCell(e) {
|
|
4898
5085
|
if (e.dataset.mtProcessed !== "true") return;
|
|
4899
|
-
const t =
|
|
4900
|
-
e.
|
|
5086
|
+
const t = {};
|
|
5087
|
+
Array.from(e.attributes).forEach((s) => {
|
|
5088
|
+
s.name.startsWith("data-") && s.name !== "data-original" && s.name !== "data-mt-processed" && (t[s.name] = s.value);
|
|
5089
|
+
});
|
|
5090
|
+
const i = e.getAttribute("data-original") || "";
|
|
5091
|
+
e.dataset.mtProcessed = "", e.innerHTML = i, Object.entries(t).forEach(([s, n]) => {
|
|
5092
|
+
e.setAttribute(s, n);
|
|
5093
|
+
});
|
|
4901
5094
|
}
|
|
4902
5095
|
_setClasses(e, t) {
|
|
4903
5096
|
e.className = "", t.filter(Boolean).forEach((i) => e.classList.add(...i.split(" ")));
|
|
@@ -5165,10 +5358,10 @@ class oe extends HTMLElement {
|
|
|
5165
5358
|
"transition-colors",
|
|
5166
5359
|
"duration-200"
|
|
5167
5360
|
];
|
|
5168
|
-
this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (
|
|
5169
|
-
this.hasAttribute("sortable") &&
|
|
5170
|
-
}), this._chipsWrap.addEventListener("drop", (
|
|
5171
|
-
this.hasAttribute("sortable") &&
|
|
5361
|
+
this._container.className = o.join(" "), this._chipsWrap = document.createElement("div"), this._chipsWrap.className = "flex flex-wrap items-center gap-2", this._chipsWrap.addEventListener("dragover", (c) => {
|
|
5362
|
+
this.hasAttribute("sortable") && c.preventDefault();
|
|
5363
|
+
}), this._chipsWrap.addEventListener("drop", (c) => {
|
|
5364
|
+
this.hasAttribute("sortable") && c.preventDefault();
|
|
5172
5365
|
}), this._input = document.createElement("input"), this._input.type = "text", this._input.placeholder = this._placeholder, this._input.className = [
|
|
5173
5366
|
"min-w-[6rem]",
|
|
5174
5367
|
"flex-1",
|
|
@@ -5181,8 +5374,8 @@ class oe extends HTMLElement {
|
|
|
5181
5374
|
"placeholder:text-gray-400",
|
|
5182
5375
|
"dark:placeholder:text-gray-500",
|
|
5183
5376
|
"p-1.5"
|
|
5184
|
-
].join(" "), this._input.addEventListener("keydown", (
|
|
5185
|
-
|
|
5377
|
+
].join(" "), this._input.addEventListener("keydown", (c) => {
|
|
5378
|
+
c.key === "Enter" && (c.preventDefault(), this._addFromInput());
|
|
5186
5379
|
}), this._container.appendChild(this._chipsWrap), this.appendChild(this._container);
|
|
5187
5380
|
}
|
|
5188
5381
|
if (this._container) {
|