@diniz/webcomponents 1.1.2 → 1.1.4
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/README.md +959 -959
- package/dist/README.md +959 -0
- package/dist/style.css +1256 -0
- package/dist/webcomponents.es.js +1721 -0
- package/dist/webcomponents.umd.js +326 -0
- package/package.json +1 -1
- package/dist/assets/checkbox-demo-page-C-tPBGML.js +0 -152
- package/dist/assets/dashboard-page-DG9XqSlN.js +0 -34
- package/dist/assets/date-picker-demo-BFqT8vXb.js +0 -146
- package/dist/assets/index-BiVNQ5Fp.js +0 -343
- package/dist/assets/index-DFxj0POj.css +0 -1
- package/dist/assets/input-demo-C8SDvXHc.js +0 -113
- package/dist/assets/modal-demo-page-DdQtx_aK.js +0 -164
- package/dist/assets/modal-h8khzJNk.js +0 -36
- package/dist/assets/select-demo-page-yyBh86Yw.js +0 -186
- package/dist/assets/table-DAobVRE7.js +0 -12
- package/dist/assets/table-demo-Dv1cyM0s.js +0 -74
- package/dist/assets/tabs-demo-BZZ6mTYB.js +0 -68
- package/dist/assets/vendor-BvJLUv9i.js +0 -5
- package/dist/index.html +0 -35
|
@@ -0,0 +1,1721 @@
|
|
|
1
|
+
var $ = Object.defineProperty;
|
|
2
|
+
var A = (l, i, t) => i in l ? $(l, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[i] = t;
|
|
3
|
+
var p = (l, i, t) => A(l, typeof i != "symbol" ? i + "" : i, t);
|
|
4
|
+
import k from "feather-icons";
|
|
5
|
+
function E(l) {
|
|
6
|
+
let i = l;
|
|
7
|
+
const t = /* @__PURE__ */ new Set();
|
|
8
|
+
return {
|
|
9
|
+
get: () => i,
|
|
10
|
+
set: (e) => {
|
|
11
|
+
Object.is(i, e) || (i = e, t.forEach((a) => a(i)));
|
|
12
|
+
},
|
|
13
|
+
subscribe: (e) => (t.add(e), () => t.delete(e))
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
class g extends HTMLElement {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
p(this, "state");
|
|
20
|
+
p(this, "signalUnsubs");
|
|
21
|
+
this.attachShadow({ mode: "open" }), this.state = {}, this.signalUnsubs = /* @__PURE__ */ new Set();
|
|
22
|
+
}
|
|
23
|
+
useSignal(t) {
|
|
24
|
+
const e = E(t), a = e.subscribe(() => this.render());
|
|
25
|
+
return this.signalUnsubs.add(a), e;
|
|
26
|
+
}
|
|
27
|
+
setState(t) {
|
|
28
|
+
this.state = { ...this.state, ...t }, this.render();
|
|
29
|
+
}
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
this.render();
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
this.signalUnsubs.forEach((t) => t()), this.signalUnsubs.clear();
|
|
35
|
+
}
|
|
36
|
+
render() {
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const f = ':root{--color-primary: #24ec71;--color-primary-contrast: #ffffff;--color-ink: #0f172a;--color-muted: #f1f5f9;--color-header: #34a8eb;--color-border: #f3f5f7;--color-border-strong: #cbd5f5;--color-nav-bg: #222222;--color-nav-text: #ffffff;--shadow-primary: 0 8px 18px rgba(31, 111, 235, .25);--focus-ring: #9ec5ff;--radius-pill: 999px;--radius-md: 12px;--color-page-bg: #ffffff;--color-page-text: #0f172a}body{background:var(--color-page-bg);color:var(--color-page-text);margin:0;font-family:Segoe UI,system-ui,-apple-system,sans-serif}:host([data-ui="button"]){display:inline-block}:host([data-ui="table"]){display:block}:host([data-ui="layout"]){display:block}:host([data-ui="sidebar"]){display:block}.btn{align-items:center;border:1px solid transparent;border-radius:var(--radius-pill);cursor:pointer;display:inline-flex;font-family:inherit;font-size:.95rem;font-weight:600;gap:.5rem;line-height:1;padding:.65rem 1.2rem;transition:transform .12s ease,box-shadow .12s ease,background-color .12s ease}.btn:focus-visible{outline:3px solid var(--focus-ring);outline-offset:2px}.btn:active:not(:disabled){transform:translateY(1px)}.btn:disabled{cursor:not-allowed;opacity:.6}.btn.primary{background:var(--color-primary);color:var(--color-primary-contrast);box-shadow:var(--shadow-primary)}.btn.secondary{background:var(--color-muted);color:var(--color-ink);border-color:var(--color-border-strong)}.btn.ghost{background:transparent;color:var(--color-primary);border-color:var(--color-border-strong)}.btn.danger{background:#ef4444;color:#fff;border-color:#ef4444}.btn-danger:hover{background:#6626dc;border-color:#dc2626}.btn.has-icon{line-height:1.2}.btn .btn-icon{width:18px;height:18px;flex-shrink:0}.btn .btn-icon svg{width:100%;height:100%}.btn.icon-only{padding:.65rem;aspect-ratio:1}.btn.icon-only.sm{padding:.45rem}.btn.icon-only.lg{padding:.8rem}.btn.sm .btn-icon{width:14px;height:14px}.btn.lg .btn-icon{width:22px;height:22px}.btn.sm{font-size:.85rem;padding:.45rem .9rem;box-shadow:0 4px 12px #a7124426}.btn.md{font-size:.95rem;padding:.65rem 1.2rem}.btn.lg{font-size:1.05rem;padding:.8rem 1.5rem}.table-wrap{border:1px solid var(--color-border);border-radius:var(--radius-md);overflow:hidden}table{border-collapse:collapse;width:100%}thead{background:var(--color-header)}th,td{padding:.75rem 1rem;text-align:left;border-bottom:1px solid var(--color-border);font-size:.95rem;border-right:1px solid var(--color-border)}tr:last-child td{border-bottom:none}.align-left{text-align:left}.align-center{text-align:center}.align-right{text-align:right}.actions-cell{display:flex;gap:.5rem;justify-content:center}.app-nav{padding:1rem;background:var(--color-nav-bg);color:var(--color-nav-text)}.app-link{color:var(--color-nav-text);margin-right:1rem;text-decoration:none}.signal-demo,.theme-toggle{margin-top:16px;display:flex;align-items:center;gap:12px}.data-table{margin-top:15px}.dashboard-layout{display:grid;grid-template-columns:220px minmax(0,1fr);gap:24px;padding:24px}.dashboard-sidebar{background:var(--color-muted);border:1px solid var(--color-border);border-radius:var(--radius-md);padding:18px}.sidebar-title{margin:0 0 12px;font-size:1rem}.sidebar-nav{display:flex;flex-direction:column;gap:10px}.sidebar-link{color:var(--color-ink);text-decoration:none;font-weight:600}.dashboard-main{display:flex;flex-direction:column;gap:12px}.dashboard-actions{display:flex;flex-wrap:wrap;gap:12px}@media (max-width: 900px){.dashboard-layout{grid-template-columns:1fr}}:host([data-ui="input"]){display:block}.input-wrapper{display:flex;flex-direction:column;gap:.35rem}.input-label{font-size:.9rem;font-weight:600;color:var(--color-ink)}.input-field{padding:.6rem .85rem;font-size:.95rem;font-family:inherit;border:1.5px solid var(--color-border);border-radius:6px;background:var(--color-page-bg);color:var(--color-page-text);transition:border-color .15s ease,box-shadow .15s ease;outline:none}.input-field::placeholder{color:#94a3b8}.input-field:focus{border-color:var(--color-primary);box-shadow:0 0 0 3px #24ec7126}.input-field:disabled{background:var(--color-muted);cursor:not-allowed;opacity:.7}.input-wrapper.invalid .input-field{border-color:#ef4444}.input-wrapper.invalid .input-field:focus{box-shadow:0 0 0 3px #ef444426}.input-error{font-size:.8rem;color:#ef4444;display:flex;align-items:center;gap:.25rem}.input-error.hidden{display:none}:host([data-ui="checkbox"]){display:inline-flex;align-items:center;cursor:pointer;-webkit-user-select:none;user-select:none}:host([data-ui="checkbox"][disabled]){cursor:not-allowed;opacity:.6}.checkbox-container{display:inline-flex;align-items:center;gap:.75rem}.checkbox-box{position:relative;display:inline-flex;align-items:center;justify-content:center;border:2px solid var(--color-border, #cbd5e1);border-radius:var(--radius-sm, 4px);background:#fff;transition:all .2s;flex-shrink:0;box-sizing:border-box}.checkbox-box.size-sm{min-width:16px;max-width:16px;min-height:16px;max-height:16px}.checkbox-box.size-md{min-width:18px;max-width:18px;min-height:18px;max-height:18px}.checkbox-box.size-lg{min-width:20px;max-width:20px;min-height:20px;max-height:20px}.checkbox-box:hover:not(.disabled){border-color:var(--color-primary, #24ec71)}.checkbox-box.checked,.checkbox-box.indeterminate{background:var(--color-primary, #24ec71);border-color:var(--color-primary, #24ec71)}.checkbox-box.disabled{background:var(--color-muted, #f1f5f9);cursor:not-allowed}.checkbox-icon{display:none;color:#fff;position:absolute}.checkbox-box.checked .checkbox-icon.check,.checkbox-box.indeterminate .checkbox-icon.minus{display:block}.checkbox-icon.check{width:12px;height:12px}.checkbox-icon.minus{width:10px;height:10px}.checkbox-label{font-size:.95rem;color:var(--color-ink, #0f172a);line-height:1.5}.checkbox-container.size-sm .checkbox-label{font-size:.875rem}.checkbox-container.size-lg .checkbox-label{font-size:1rem}input[type=checkbox]{position:absolute;opacity:0;pointer-events:none}.modal-backdrop{display:none;position:fixed;top:0;right:0;bottom:0;left:0;background:#00000080;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);z-index:9999;animation:fadeIn .2s ease-out}.modal-backdrop.open{display:flex;align-items:center;justify-content:center;padding:1rem}.modal-content{background:var(--color-surface, white);border-radius:var(--radius-lg, 16px);box-shadow:0 20px 25px -5px #0000001a,0 10px 10px -5px #0000000a;max-height:90vh;display:flex;flex-direction:column;width:100%;animation:slideUp .2s ease-out}.modal-content.sm{max-width:400px}.modal-content.md{max-width:600px}.modal-content.lg{max-width:800px}.modal-content.xl{max-width:1200px}.modal-content.full{max-width:95vw}.modal-header{padding:1.5rem;border-bottom:1px solid var(--color-border, #e2e8f0);display:flex;align-items:center;justify-content:space-between}.modal-title{font-size:1.25rem;font-weight:600;color:var(--color-ink, #0f172a);margin:0}.modal-close{background:none;border:none;cursor:pointer;padding:.5rem;display:flex;align-items:center;justify-content:center;border-radius:var(--radius-md, 8px);color:var(--color-text-muted, #64748b);transition:all .2s}.modal-close:hover{background:var(--color-muted, #f1f5f9);color:var(--color-ink, #0f172a)}.modal-body{padding:1.5rem;overflow-y:auto;flex:1}.modal-footer{padding:1.5rem;border-top:1px solid var(--color-border, #e2e8f0);display:flex;gap:.75rem;justify-content:flex-end}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideUp{0%{opacity:0;transform:translateY(20px)}to{opacity:1;transform:translateY(0)}}:host([data-ui="select"]){display:block;width:90%}.select-container{position:relative;width:100%}.select-label{display:block;margin-bottom:.5rem;font-size:.875rem;font-weight:500;color:var(--color-ink, #0f172a)}.select-trigger{width:100%;padding:.625rem 1rem;background:#fff;border:1px solid var(--color-border, #e2e8f0);border-radius:var(--radius-md, 8px);display:flex;align-items:center;justify-content:space-between;cursor:pointer;transition:all .2s;font-size:.95rem;color:var(--color-ink, #0f172a)}.select-trigger:hover:not(:disabled){border-color:var(--color-primary, #24ec71)}.select-trigger:focus{outline:none;border-color:var(--color-primary, #24ec71);box-shadow:0 0 0 3px #24ec711a}.select-trigger:disabled{background:var(--color-muted, #f1f5f9);cursor:not-allowed;opacity:.6}.select-trigger.open{border-color:var(--color-primary, #24ec71)}.select-placeholder{color:var(--color-text-muted, #94a3b8);flex:1;text-align:left}.select-placeholder.has-selection{color:var(--color-ink, #0f172a)}.select-arrow{display:flex;transition:transform .2s;color:var(--color-text-muted, #64748b)}.select-arrow.open{transform:rotate(180deg)}.select-dropdown{position:absolute;top:calc(100% + .25rem);left:0;right:0;background:#fff;border:1px solid var(--color-border, #e2e8f0);border-radius:var(--radius-md, 8px);box-shadow:0 10px 15px -3px #0000001a,0 4px 6px -2px #0000000d;max-height:300px;overflow-y:auto;z-index:1000;display:none;animation:slideDown .15s ease-out}.select-dropdown.open{display:block}.select-search{width:100%;padding:.625rem 1rem;border:none;border-bottom:1px solid var(--color-border, #e2e8f0);font-size:.95rem;outline:none}.select-search:focus{background:var(--color-muted, #f1f5f9)}.select-option{padding:.625rem 1rem;cursor:pointer;transition:background .15s;color:var(--color-ink, #0f172a);font-size:.95rem}.select-option:hover:not(.disabled){background:var(--color-muted, #f1f5f9)}.select-option.selected{background:#24ec711a;color:var(--color-primary, #24ec71);font-weight:500}.select-option.disabled{opacity:.5;cursor:not-allowed}.select-empty{padding:1rem;text-align:center;color:var(--color-text-muted, #94a3b8);font-size:.875rem}@keyframes slideDown{0%{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}:host([data-ui="upload"]){display:block;width:100%}.upload{display:flex;flex-direction:column;gap:.75rem}.upload-label{font-size:.9rem;font-weight:700;color:var(--color-ink)}.upload-drop{border:1.5px dashed rgba(36,236,113,.55);border-radius:16px;background:linear-gradient(135deg,#24ec7114,#34a8eb14);padding:1.25rem 1.5rem;position:relative;transition:border-color .2s ease,box-shadow .2s ease,transform .2s ease}.upload-drop.dragging{border-color:var(--color-primary);box-shadow:0 16px 30px #24ec712e;transform:translateY(-2px)}.upload-drop.disabled{opacity:.6;cursor:not-allowed}.upload-input{position:absolute;top:0;right:0;bottom:0;left:0;opacity:0;cursor:pointer}.upload-content{display:grid;grid-template-columns:auto 1fr auto;gap:1rem;align-items:center}.upload-icon{width:46px;height:46px;border-radius:14px;display:grid;place-items:center;background:#0f172a;color:#fff;box-shadow:0 12px 20px #0f172a2e}.upload-icon svg{width:20px;height:20px}.upload-title{font-weight:700;color:var(--color-ink)}.upload-sub{font-size:.85rem;color:var(--color-text-muted, #64748b);margin-top:.2rem}.upload-btn{border:none;border-radius:999px;padding:.45rem 1rem;font-size:.85rem;font-weight:700;background:#0f172a;color:#fff;cursor:pointer;transition:transform .2s ease,box-shadow .2s ease}.upload-btn:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 10px 16px #0f172a2e}.upload-btn:disabled{cursor:not-allowed;opacity:.5}.upload-helper{font-size:.85rem;color:var(--color-text-muted, #64748b)}.upload-list{list-style:none;padding:0;margin:0;display:grid;gap:.5rem}.upload-list li{display:grid;grid-template-columns:1fr auto auto;gap:.75rem;align-items:center;padding:.6rem .75rem;border-radius:12px;background:#fff;border:1px solid rgba(148,163,184,.35);font-size:.9rem;color:var(--color-ink)}.upload-meta{font-size:.78rem;color:var(--color-text-muted, #64748b)}.upload-remove{border:none;background:#ef44441a;color:#b91c1c;padding:.25rem .65rem;border-radius:999px;font-size:.75rem;font-weight:600;cursor:pointer}.upload-remove:hover{background:#ef444433}:host([data-ui="pagination"]){display:block}.pagination-container{display:flex;align-items:center;justify-content:space-between;gap:1rem;flex-wrap:wrap}.pagination-info{font-size:.9rem;color:var(--color-ink);opacity:.7}.pagination{display:flex;align-items:center;gap:.25rem}.page-btn{min-width:2.5rem;height:2.5rem;padding:.5rem;border:1px solid var(--color-border);background:#fff;color:var(--color-ink);font-size:.9rem;font-weight:500;border-radius:6px;cursor:pointer;transition:all .2s ease;display:flex;align-items:center;justify-content:center}.page-btn:hover:not(:disabled):not(.active){background:var(--color-muted);border-color:var(--color-border-strong)}.page-btn:disabled{opacity:.4;cursor:not-allowed}.page-btn.active{background:var(--color-primary);color:var(--color-primary-contrast);border-color:var(--color-primary);font-weight:600}.page-btn.ellipsis{border:none;background:transparent;cursor:default;pointer-events:none}.nav-btn{padding:.5rem .75rem}.nav-btn svg{width:16px;height:16px}:host([data-ui="stepper"]){display:block}.stepper-wrap{width:100%}.stepper-empty{padding:1rem;border:1px dashed var(--color-border);border-radius:var(--radius-md);color:var(--color-text-muted, #64748b);text-align:center;font-size:.9rem}.stepper{list-style:none;padding:0;margin:0;display:flex;flex-wrap:wrap;gap:1.25rem}.stepper.vertical{flex-direction:column;gap:1rem}.step{display:flex;align-items:center;position:relative}.stepper.vertical .step{flex-direction:column;align-items:flex-start}.step-trigger{display:flex;align-items:center;gap:.75rem;background:transparent;border:none;padding:0;cursor:pointer;text-align:left;font-family:inherit;color:var(--color-ink)}.step-trigger:disabled{cursor:not-allowed;opacity:.5}.step-node{width:2.1rem;height:2.1rem;border-radius:12px;background:var(--color-muted);border:1px solid var(--color-border-strong);display:inline-flex;align-items:center;justify-content:center;font-weight:700;font-size:.9rem;color:var(--color-ink);box-shadow:inset 0 0 0 1px #fff9}.step-text{display:flex;flex-direction:column;gap:.2rem}.step-title{font-weight:700;letter-spacing:.2px;font-size:.98rem}.step-desc{font-size:.85rem;color:var(--color-text-muted, #64748b)}.step-connector{width:48px;height:2px;margin:0 .65rem;background:linear-gradient(90deg,var(--color-border),rgba(255,255,255,0));flex-shrink:0}.stepper.vertical .step-connector{width:2px;height:28px;margin:.65rem 0 .25rem 1.05rem;background:linear-gradient(180deg,var(--color-border),rgba(255,255,255,0))}.step.complete .step-node{background:linear-gradient(135deg,#24ec71,#34a8eb);color:#0f172a;border-color:transparent;box-shadow:0 8px 18px #24ec7140}.step.complete .step-connector{background:linear-gradient(90deg,#24ec71,#34a8eb)}.stepper.vertical .step.complete .step-connector{background:linear-gradient(180deg,#24ec71,#34a8eb)}.step.active .step-node{background:#fff;color:var(--color-ink);border-color:var(--color-primary);box-shadow:0 0 0 4px #24ec712e,0 12px 20px #24ec7138;animation:stepGlow 1.6s ease-in-out infinite}.step.active .step-title{color:var(--color-ink)}.step.upcoming .step-title{color:var(--color-ink);opacity:.7}.step.error .step-node{background:#fee2e2;border-color:#f87171;color:#991b1b;box-shadow:0 8px 16px #ef444433}.step.warning .step-node{background:#fef3c7;border-color:#f59e0b;color:#92400e;box-shadow:0 8px 16px #f59e0b33}.stepper.sm .step-node{width:1.65rem;height:1.65rem;font-size:.75rem;border-radius:10px}.stepper.sm .step-title{font-size:.9rem}.stepper.sm .step-desc{font-size:.78rem}.stepper.lg .step-node{width:2.6rem;height:2.6rem;font-size:1.05rem;border-radius:14px}.stepper.lg .step-title{font-size:1.1rem}.stepper.lg .step-desc{font-size:.92rem}@keyframes stepGlow{0%,to{transform:translateY(0)}50%{transform:translateY(-2px)}}:host([data-ui="date-picker"]){display:block;width:100%}.date-picker-label{display:block;font-size:.9rem;font-weight:500;color:var(--color-ink);margin-bottom:.5rem}.date-picker-container{position:relative;display:flex;flex-direction:column;gap:.5rem}.date-input-wrapper{position:relative;display:flex;align-items:center;border:1px solid var(--color-border);border-radius:var(--radius-md);background:#fff;transition:all .2s ease}.date-input-wrapper:hover:not(.disabled){border-color:var(--color-border-strong)}.date-input-wrapper:focus-within{border-color:var(--color-primary);box-shadow:0 0 0 3px #24ec711a;outline:none}.date-input-wrapper.disabled{background:var(--color-muted);cursor:not-allowed;opacity:.6}.formatted-input{flex:1;border:none;padding:.75rem 1rem;font-size:.95rem;font-family:inherit;background:transparent;color:var(--color-ink);outline:none}.formatted-input:disabled{cursor:not-allowed;color:var(--color-ink);opacity:.7}.formatted-input::placeholder{color:#94a3b8;opacity:.7}.formatted-input.invalid{color:#dc2626}.hidden-date-input{position:absolute;opacity:0;width:100%;height:100%;top:0;left:0;pointer-events:none;cursor:pointer}.calendar-btn{padding:.5rem;margin-right:.5rem;border:none;background:transparent;cursor:pointer;display:flex;align-items:center;justify-content:center;color:var(--color-ink);opacity:.6;transition:all .2s ease;border-radius:6px}.calendar-btn:hover:not(:disabled){background:var(--color-muted);opacity:1}.calendar-btn:disabled{cursor:not-allowed;opacity:.3}.calendar-icon{width:20px;height:20px}.format-label{font-size:.75rem;color:var(--color-ink);opacity:.6;padding:0 .25rem;font-weight:500}#ui-datepicker-div,.datepicker,.react-datepicker-popper{z-index:99999!important}';
|
|
40
|
+
class C extends g {
|
|
41
|
+
connectedCallback() {
|
|
42
|
+
this.setAttribute("data-ui", "button"), super.connectedCallback(), this.attachClickHandler();
|
|
43
|
+
}
|
|
44
|
+
static get observedAttributes() {
|
|
45
|
+
return ["variant", "size", "disabled", "type", "icon", "icon-position"];
|
|
46
|
+
}
|
|
47
|
+
attributeChangedCallback() {
|
|
48
|
+
this.render(), this.attachClickHandler();
|
|
49
|
+
}
|
|
50
|
+
attachClickHandler() {
|
|
51
|
+
if (!this.shadowRoot) return;
|
|
52
|
+
const i = this.shadowRoot.querySelector("button");
|
|
53
|
+
if (!i) return;
|
|
54
|
+
const t = i._clickHandler;
|
|
55
|
+
t && i.removeEventListener("click", t);
|
|
56
|
+
const e = (a) => {
|
|
57
|
+
const s = this.getType();
|
|
58
|
+
if (this.hasAttribute("disabled")) {
|
|
59
|
+
a.preventDefault(), a.stopPropagation();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (s === "submit") {
|
|
63
|
+
a.preventDefault(), a.stopPropagation();
|
|
64
|
+
let r = this.closest("form");
|
|
65
|
+
if (!r) {
|
|
66
|
+
let o = this.parentElement;
|
|
67
|
+
for (; o; ) {
|
|
68
|
+
if (o.tagName === "FORM") {
|
|
69
|
+
r = o;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
o = o.parentElement;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (r) {
|
|
76
|
+
const o = new Event("submit", {
|
|
77
|
+
bubbles: !0,
|
|
78
|
+
cancelable: !0
|
|
79
|
+
});
|
|
80
|
+
r.dispatchEvent(o);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
i._clickHandler = e, i.addEventListener("click", e);
|
|
85
|
+
}
|
|
86
|
+
getVariant() {
|
|
87
|
+
const i = this.getAttribute("variant");
|
|
88
|
+
return i === "secondary" || i === "ghost" || i === "danger" ? i : "primary";
|
|
89
|
+
}
|
|
90
|
+
getSize() {
|
|
91
|
+
const i = this.getAttribute("size");
|
|
92
|
+
return i === "sm" || i === "lg" ? i : "md";
|
|
93
|
+
}
|
|
94
|
+
getType() {
|
|
95
|
+
return this.getAttribute("type") ?? "button";
|
|
96
|
+
}
|
|
97
|
+
getIcon() {
|
|
98
|
+
var a;
|
|
99
|
+
const i = this.getAttribute("icon");
|
|
100
|
+
if (!i) return null;
|
|
101
|
+
const t = i.trim();
|
|
102
|
+
return { html: `<span class="btn-icon">${((a = k.icons[t]) == null ? void 0 : a.toSvg()) || ""}</span>`, name: t };
|
|
103
|
+
}
|
|
104
|
+
getIconPosition() {
|
|
105
|
+
return this.getAttribute("icon-position") === "right" ? "right" : "left";
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
const i = this.getVariant(), t = this.getSize(), e = this.hasAttribute("disabled"), a = this.getType(), s = this.getIcon(), n = this.getIconPosition(), r = s !== null, o = s ? s.html : "", d = this.innerHTML.trim(), c = r && !d;
|
|
109
|
+
let h;
|
|
110
|
+
r && d ? h = n === "left" ? `${o}<span>${d}</span>` : `<span>${d}</span>${o}` : r ? h = o : h = d, this.shadowRoot.innerHTML = `
|
|
111
|
+
<style>${f}</style>
|
|
112
|
+
<button
|
|
113
|
+
part="button"
|
|
114
|
+
class="btn ${i} ${t}${r ? " has-icon" : ""}${c ? " icon-only" : ""}"
|
|
115
|
+
type="${a}"
|
|
116
|
+
${e ? "disabled" : ""}
|
|
117
|
+
>
|
|
118
|
+
${h}
|
|
119
|
+
</button>
|
|
120
|
+
`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
customElements.define("ui-button", C);
|
|
124
|
+
class S extends g {
|
|
125
|
+
constructor() {
|
|
126
|
+
super();
|
|
127
|
+
p(this, "inputEl", null);
|
|
128
|
+
p(this, "customValidator", null);
|
|
129
|
+
p(this, "validationRule", null);
|
|
130
|
+
this.state = {
|
|
131
|
+
value: "",
|
|
132
|
+
valid: !0,
|
|
133
|
+
touched: !1,
|
|
134
|
+
error: ""
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
static get observedAttributes() {
|
|
138
|
+
return ["type", "label", "placeholder", "required", "pattern", "minlength", "maxlength", "min", "max", "error-message", "custom-error", "disabled", "name", "validate"];
|
|
139
|
+
}
|
|
140
|
+
connectedCallback() {
|
|
141
|
+
this.setAttribute("data-ui", "input"), super.connectedCallback();
|
|
142
|
+
}
|
|
143
|
+
attributeChangedCallback(t, e, a) {
|
|
144
|
+
e !== a && t !== "value" && this.render();
|
|
145
|
+
}
|
|
146
|
+
setCustomValidator(t) {
|
|
147
|
+
this.customValidator = t, this.validate();
|
|
148
|
+
}
|
|
149
|
+
get value() {
|
|
150
|
+
return this.state.value;
|
|
151
|
+
}
|
|
152
|
+
set value(t) {
|
|
153
|
+
this.state.value = t, this.inputEl && this.inputEl.value !== t && (this.inputEl.value = t), this.validate();
|
|
154
|
+
}
|
|
155
|
+
get isValid() {
|
|
156
|
+
return this.state.valid;
|
|
157
|
+
}
|
|
158
|
+
checkValidity() {
|
|
159
|
+
return this.state.touched = !0, this.validate();
|
|
160
|
+
}
|
|
161
|
+
reportValidity() {
|
|
162
|
+
this.state.touched = !0;
|
|
163
|
+
const t = this.validate();
|
|
164
|
+
return this.updateErrorDisplay(), !t && this.inputEl && this.inputEl.focus(), t;
|
|
165
|
+
}
|
|
166
|
+
getType() {
|
|
167
|
+
const t = this.getAttribute("type");
|
|
168
|
+
return ["text", "email", "password", "number", "tel", "url"].includes(t || "") ? t : "text";
|
|
169
|
+
}
|
|
170
|
+
getLabel() {
|
|
171
|
+
return this.getAttribute("label") || "";
|
|
172
|
+
}
|
|
173
|
+
getPlaceholder() {
|
|
174
|
+
return this.getAttribute("placeholder") || "";
|
|
175
|
+
}
|
|
176
|
+
getName() {
|
|
177
|
+
return this.getAttribute("name") || "";
|
|
178
|
+
}
|
|
179
|
+
getErrorMessage() {
|
|
180
|
+
return this.state.error ? this.state.error : this.getAttribute("error-message") || this.getAttribute("custom-error") || "";
|
|
181
|
+
}
|
|
182
|
+
getCustomError() {
|
|
183
|
+
return this.getAttribute("custom-error") || "";
|
|
184
|
+
}
|
|
185
|
+
parseValidationRule(t) {
|
|
186
|
+
return t.startsWith("email:") ? { type: "emailDomain", domain: t.slice(6) } : t.startsWith("match:") ? { type: "match", selector: t.slice(6) } : t.startsWith("min:") ? { type: "minLength", length: parseInt(t.slice(4), 10) } : t.startsWith("max:") ? { type: "maxLength", length: parseInt(t.slice(4), 10) } : t.startsWith("regex:") ? { type: "regex", pattern: t.slice(6) } : null;
|
|
187
|
+
}
|
|
188
|
+
applyValidationRule(t) {
|
|
189
|
+
const e = this.state.value;
|
|
190
|
+
switch (t.type) {
|
|
191
|
+
case "emailDomain":
|
|
192
|
+
if (!e.endsWith(`@${t.domain}`))
|
|
193
|
+
return { valid: !1, message: `Must end with @${t.domain}` };
|
|
194
|
+
break;
|
|
195
|
+
case "match":
|
|
196
|
+
const a = document.querySelector(t.selector);
|
|
197
|
+
if (a && e !== a.value)
|
|
198
|
+
return { valid: !1, message: "Values do not match" };
|
|
199
|
+
break;
|
|
200
|
+
case "minLength":
|
|
201
|
+
if (e.length < t.length)
|
|
202
|
+
return { valid: !1, message: `Must be at least ${t.length} characters` };
|
|
203
|
+
break;
|
|
204
|
+
case "maxLength":
|
|
205
|
+
if (e.length > t.length)
|
|
206
|
+
return { valid: !1, message: `Must be no more than ${t.length} characters` };
|
|
207
|
+
break;
|
|
208
|
+
case "regex":
|
|
209
|
+
try {
|
|
210
|
+
if (!new RegExp(t.pattern).test(e))
|
|
211
|
+
return { valid: !1, message: "Invalid format" };
|
|
212
|
+
} catch {
|
|
213
|
+
return { valid: !1, message: "Invalid validation pattern" };
|
|
214
|
+
}
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
return { valid: !0 };
|
|
218
|
+
}
|
|
219
|
+
validate() {
|
|
220
|
+
if (!this.inputEl) return !0;
|
|
221
|
+
const t = this.getAttribute("validate");
|
|
222
|
+
if (t && (this.validationRule || (this.validationRule = this.parseValidationRule(t)), this.validationRule)) {
|
|
223
|
+
const e = this.applyValidationRule(this.validationRule);
|
|
224
|
+
return this.state.valid = e.valid, !e.valid && e.message && (this.state.error = e.message), this.state.valid;
|
|
225
|
+
}
|
|
226
|
+
if (this.customValidator) {
|
|
227
|
+
const e = this.customValidator(this.state.value, this.inputEl);
|
|
228
|
+
this.state.valid = e.valid, !e.valid && e.message && (this.state.error = e.message);
|
|
229
|
+
} else {
|
|
230
|
+
const e = this.inputEl.checkValidity();
|
|
231
|
+
this.state.valid = e, !e && this.state.touched && (this.state.error = this.inputEl.validationMessage || this.getErrorMessage()), e && (this.state.error = "");
|
|
232
|
+
}
|
|
233
|
+
return this.state.valid;
|
|
234
|
+
}
|
|
235
|
+
handleInput(t) {
|
|
236
|
+
const e = t.target;
|
|
237
|
+
this.state.value = e.value, this.state.touched = !0, this.validate(), this.updateErrorDisplay();
|
|
238
|
+
}
|
|
239
|
+
handleBlur() {
|
|
240
|
+
this.state.touched = !0, this.validate(), this.updateErrorDisplay();
|
|
241
|
+
}
|
|
242
|
+
updateErrorDisplay() {
|
|
243
|
+
if (!this.inputEl) return;
|
|
244
|
+
const t = this.shadowRoot.querySelector(".input-error"), e = this.shadowRoot.querySelector(".input-wrapper"), a = this.getName();
|
|
245
|
+
e && e.classList.toggle("invalid", !this.state.valid && this.state.touched), t && (!this.state.valid && this.state.touched && this.state.error ? (t.textContent = this.state.error, t.classList.remove("hidden")) : t.classList.add("hidden")), this.inputEl.setAttribute("aria-invalid", String(!this.state.valid && this.state.touched)), a && this.inputEl.setAttribute("aria-describedby", `${a}-error`);
|
|
246
|
+
}
|
|
247
|
+
needsRender() {
|
|
248
|
+
return this.hasAttribute("type") || this.hasAttribute("label") || this.hasAttribute("placeholder") || this.hasAttribute("required") || this.hasAttribute("pattern") || this.hasAttribute("disabled") || this.hasAttribute("name") || this.hasAttribute("minlength") || this.hasAttribute("maxlength") || this.hasAttribute("min") || this.hasAttribute("max") || this.hasAttribute("error-message") || this.hasAttribute("custom-error") || this.hasAttribute("validate");
|
|
249
|
+
}
|
|
250
|
+
render() {
|
|
251
|
+
const t = this.getType(), e = this.getLabel(), a = this.getPlaceholder(), s = this.getName(), n = this.getErrorMessage(), r = this.hasAttribute("required"), o = this.getAttribute("pattern"), d = this.getAttribute("minlength"), c = this.getAttribute("maxlength"), h = this.getAttribute("min"), u = this.getAttribute("max"), b = this.hasAttribute("disabled"), m = !this.state.valid && this.state.touched, v = e !== "";
|
|
252
|
+
this.shadowRoot.innerHTML = `
|
|
253
|
+
<style>${f}</style>
|
|
254
|
+
<div class="input-wrapper${m ? " invalid" : ""}${b ? " disabled" : ""}">
|
|
255
|
+
${v ? `<label class="input-label">${e}${r ? " *" : ""}</label>` : ""}
|
|
256
|
+
<input
|
|
257
|
+
part="input"
|
|
258
|
+
class="input-field"
|
|
259
|
+
type="${t}"
|
|
260
|
+
placeholder="${a}"
|
|
261
|
+
name="${s}"
|
|
262
|
+
.value="${this.state.value}"
|
|
263
|
+
${r ? "required" : ""}
|
|
264
|
+
${o ? `pattern="${o}"` : ""}
|
|
265
|
+
${d ? `minlength="${d}"` : ""}
|
|
266
|
+
${c ? `maxlength="${c}"` : ""}
|
|
267
|
+
${h ? `min="${h}"` : ""}
|
|
268
|
+
${u ? `max="${u}"` : ""}
|
|
269
|
+
${b ? "disabled" : ""}
|
|
270
|
+
aria-invalid="${m}"
|
|
271
|
+
aria-describedby="${s}-error"
|
|
272
|
+
/>
|
|
273
|
+
<span class="input-error${m && n ? "" : " hidden"}" id="${s}-error" role="alert">${n}</span>
|
|
274
|
+
</div>
|
|
275
|
+
`, this.inputEl = this.shadowRoot.querySelector(".input-field"), this.inputEl && (this.inputEl.addEventListener("input", this.handleInput.bind(this)), this.inputEl.addEventListener("blur", this.handleBlur.bind(this)));
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
customElements.define("ui-input", S);
|
|
279
|
+
class z extends g {
|
|
280
|
+
constructor() {
|
|
281
|
+
super(...arguments);
|
|
282
|
+
p(this, "columns", []);
|
|
283
|
+
p(this, "rows", []);
|
|
284
|
+
}
|
|
285
|
+
connectedCallback() {
|
|
286
|
+
this.setAttribute("data-ui", "table"), super.connectedCallback();
|
|
287
|
+
}
|
|
288
|
+
set data(t) {
|
|
289
|
+
this.columns = t.columns, this.rows = t.rows, this.render();
|
|
290
|
+
}
|
|
291
|
+
get data() {
|
|
292
|
+
return { columns: this.columns, rows: this.rows };
|
|
293
|
+
}
|
|
294
|
+
render() {
|
|
295
|
+
const t = this.columns.filter((s) => s.visible !== !1), e = t.map(
|
|
296
|
+
(s) => `<th class="align-${s.align ?? "left"}">${s.label}</th>`
|
|
297
|
+
).join(""), a = this.rows.map(
|
|
298
|
+
(s, n) => `<tr data-row-index="${n}">${t.map(
|
|
299
|
+
(r) => r.actions ? `<td class="align-center actions-cell">
|
|
300
|
+
${r.actions.edit ? `<ui-button variant="primary" class='action-btn' icon='edit' size="sm" data-action="edit" data-row-index="${n}">Edit</ui-button>` : ""}
|
|
301
|
+
${r.actions.delete ? `<ui-button variant="danger" class='action-btn' icon='trash' size="sm" data-action="delete" data-row-index="${n}">Delete</ui-button>` : ""}
|
|
302
|
+
</td>` : `<td class="align-${r.align ?? "left"}">${String(
|
|
303
|
+
s[r.key] ?? ""
|
|
304
|
+
)}</td>`
|
|
305
|
+
).join("")}</tr>`
|
|
306
|
+
).join("");
|
|
307
|
+
this.shadowRoot.innerHTML = `
|
|
308
|
+
<style>${f}</style>
|
|
309
|
+
<div class="table-wrap">
|
|
310
|
+
<table>
|
|
311
|
+
<thead><tr>${e}</tr></thead>
|
|
312
|
+
<tbody>${a}</tbody>
|
|
313
|
+
</table>
|
|
314
|
+
</div>
|
|
315
|
+
`, this.shadowRoot.querySelectorAll(".action-btn").forEach((s) => {
|
|
316
|
+
s.addEventListener("click", (n) => {
|
|
317
|
+
const r = n.currentTarget, o = r.dataset.action, d = parseInt(r.dataset.rowIndex || "0", 10), c = o === "edit" ? "edit-action" : "delete-action";
|
|
318
|
+
this.dispatchEvent(new CustomEvent(c, {
|
|
319
|
+
bubbles: !0,
|
|
320
|
+
composed: !0,
|
|
321
|
+
detail: { row: this.rows[d], rowIndex: d }
|
|
322
|
+
}));
|
|
323
|
+
});
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
customElements.define("ui-table", z);
|
|
328
|
+
class L extends g {
|
|
329
|
+
constructor() {
|
|
330
|
+
super(...arguments);
|
|
331
|
+
p(this, "inputElement", null);
|
|
332
|
+
p(this, "isConnected", !1);
|
|
333
|
+
p(this, "isInternalUpdate", !1);
|
|
334
|
+
p(this, "hasRendered", !1);
|
|
335
|
+
}
|
|
336
|
+
connectedCallback() {
|
|
337
|
+
this.setAttribute("data-ui", "date-picker"), super.connectedCallback(), this.isConnected = !0;
|
|
338
|
+
}
|
|
339
|
+
static get observedAttributes() {
|
|
340
|
+
return ["value", "format", "min", "max", "disabled", "placeholder", "label"];
|
|
341
|
+
}
|
|
342
|
+
attributeChangedCallback(t, e, a) {
|
|
343
|
+
if (!(!this.isConnected || e === a)) {
|
|
344
|
+
if (this.isInternalUpdate && t === "value") {
|
|
345
|
+
this.isInternalUpdate = !1;
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
t === "value" ? this.updateInputValues() : this.render();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
updateInputValues() {
|
|
352
|
+
if (!this.shadowRoot) return;
|
|
353
|
+
const t = this.shadowRoot.querySelector(".formatted-input"), e = this.shadowRoot.querySelector('input[type="date"]');
|
|
354
|
+
if (t && e) {
|
|
355
|
+
const a = this.getValue(), s = this.getFormat(), n = this.formatDate(a, s);
|
|
356
|
+
t.value = n, e.value = a;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
getFormat() {
|
|
360
|
+
const t = this.getAttribute("format");
|
|
361
|
+
return t === "DD/MM/YYYY" || t === "MM/DD/YYYY" || t === "DD-MM-YYYY" || t === "MM-DD-YYYY" ? t : "YYYY-MM-DD";
|
|
362
|
+
}
|
|
363
|
+
getValue() {
|
|
364
|
+
return this.getAttribute("value") || "";
|
|
365
|
+
}
|
|
366
|
+
getMin() {
|
|
367
|
+
return this.getAttribute("min") || "";
|
|
368
|
+
}
|
|
369
|
+
getMax() {
|
|
370
|
+
return this.getAttribute("max") || "";
|
|
371
|
+
}
|
|
372
|
+
getPlaceholder() {
|
|
373
|
+
return this.getAttribute("placeholder") || this.getFormat();
|
|
374
|
+
}
|
|
375
|
+
getLabel() {
|
|
376
|
+
return this.getAttribute("label") || "";
|
|
377
|
+
}
|
|
378
|
+
isDisabled() {
|
|
379
|
+
return this.hasAttribute("disabled");
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Convert date from ISO format (YYYY-MM-DD) to specified format
|
|
383
|
+
*/
|
|
384
|
+
formatDate(t, e) {
|
|
385
|
+
if (!t) return "";
|
|
386
|
+
const a = t.split("-");
|
|
387
|
+
if (a.length !== 3) return t;
|
|
388
|
+
const [s, n, r] = a;
|
|
389
|
+
switch (e) {
|
|
390
|
+
case "DD/MM/YYYY":
|
|
391
|
+
return `${r}/${n}/${s}`;
|
|
392
|
+
case "MM/DD/YYYY":
|
|
393
|
+
return `${n}/${r}/${s}`;
|
|
394
|
+
case "DD-MM-YYYY":
|
|
395
|
+
return `${r}-${n}-${s}`;
|
|
396
|
+
case "MM-DD-YYYY":
|
|
397
|
+
return `${n}-${r}-${s}`;
|
|
398
|
+
case "YYYY-MM-DD":
|
|
399
|
+
default:
|
|
400
|
+
return t;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Convert date from specified format to ISO format (YYYY-MM-DD)
|
|
405
|
+
*/
|
|
406
|
+
parseDate(t, e) {
|
|
407
|
+
if (!t) return "";
|
|
408
|
+
let a, s, n, r;
|
|
409
|
+
switch (e) {
|
|
410
|
+
case "DD/MM/YYYY":
|
|
411
|
+
if (a = t.split("/"), a.length !== 3) return "";
|
|
412
|
+
[r, n, s] = a;
|
|
413
|
+
break;
|
|
414
|
+
case "MM/DD/YYYY":
|
|
415
|
+
if (a = t.split("/"), a.length !== 3) return "";
|
|
416
|
+
[n, r, s] = a;
|
|
417
|
+
break;
|
|
418
|
+
case "DD-MM-YYYY":
|
|
419
|
+
if (a = t.split("-"), a.length !== 3) return "";
|
|
420
|
+
[r, n, s] = a;
|
|
421
|
+
break;
|
|
422
|
+
case "MM-DD-YYYY":
|
|
423
|
+
if (a = t.split("-"), a.length !== 3) return "";
|
|
424
|
+
[n, r, s] = a;
|
|
425
|
+
break;
|
|
426
|
+
case "YYYY-MM-DD":
|
|
427
|
+
default:
|
|
428
|
+
return t;
|
|
429
|
+
}
|
|
430
|
+
return n = n.padStart(2, "0"), r = r.padStart(2, "0"), `${s}-${n}-${r}`;
|
|
431
|
+
}
|
|
432
|
+
attachEventListeners() {
|
|
433
|
+
if (!this.shadowRoot) return;
|
|
434
|
+
const t = this.shadowRoot.querySelector(".formatted-input"), e = this.shadowRoot.querySelector('input[type="date"]'), a = this.shadowRoot.querySelector(".calendar-btn");
|
|
435
|
+
if (!t || !e) return;
|
|
436
|
+
const s = () => {
|
|
437
|
+
const n = t.value, r = this.getFormat(), o = this.parseDate(n, r);
|
|
438
|
+
this.isValidDate(o) ? (e.value = o, t.classList.remove("invalid"), this.dispatchDateChange(o)) : n === "" ? (e.value = "", t.classList.remove("invalid"), this.dispatchDateChange("")) : t.classList.add("invalid");
|
|
439
|
+
};
|
|
440
|
+
t.addEventListener("blur", s), t.addEventListener("keydown", (n) => {
|
|
441
|
+
n.key === "Enter" && (s(), t.blur());
|
|
442
|
+
}), e.addEventListener("change", (n) => {
|
|
443
|
+
const o = n.target.value, d = this.getFormat(), c = this.formatDate(o, d);
|
|
444
|
+
t.value = c, t.classList.remove("invalid"), this.dispatchDateChange(o);
|
|
445
|
+
}), a && a.addEventListener("click", async (n) => {
|
|
446
|
+
n.preventDefault(), n.stopPropagation(), e.style.pointerEvents = "auto";
|
|
447
|
+
try {
|
|
448
|
+
typeof e.showPicker == "function" ? e.showPicker() : (e.focus(), e.click());
|
|
449
|
+
} catch (r) {
|
|
450
|
+
console.log("Date picker error:", r), e.focus(), e.click();
|
|
451
|
+
} finally {
|
|
452
|
+
setTimeout(() => {
|
|
453
|
+
e.style.pointerEvents = "none";
|
|
454
|
+
}, 100);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
isValidDate(t) {
|
|
459
|
+
if (!t) return !1;
|
|
460
|
+
const e = new Date(t);
|
|
461
|
+
return e instanceof Date && !isNaN(e.getTime());
|
|
462
|
+
}
|
|
463
|
+
dispatchDateChange(t) {
|
|
464
|
+
const e = this.getFormat(), a = this.formatDate(t, e);
|
|
465
|
+
this.dispatchEvent(
|
|
466
|
+
new CustomEvent("date-change", {
|
|
467
|
+
detail: {
|
|
468
|
+
value: t,
|
|
469
|
+
formattedValue: a,
|
|
470
|
+
format: e
|
|
471
|
+
},
|
|
472
|
+
bubbles: !0,
|
|
473
|
+
composed: !0
|
|
474
|
+
})
|
|
475
|
+
), this.isInternalUpdate = !0, this.setAttribute("value", t);
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Get the current value in ISO format (YYYY-MM-DD)
|
|
479
|
+
*/
|
|
480
|
+
getISOValue() {
|
|
481
|
+
return this.getValue();
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Get the current value in the specified format
|
|
485
|
+
*/
|
|
486
|
+
getFormattedValue() {
|
|
487
|
+
const t = this.getValue(), e = this.getFormat();
|
|
488
|
+
return this.formatDate(t, e);
|
|
489
|
+
}
|
|
490
|
+
/**
|
|
491
|
+
* Set the date value (accepts ISO format)
|
|
492
|
+
*/
|
|
493
|
+
setValue(t) {
|
|
494
|
+
this.setAttribute("value", t);
|
|
495
|
+
}
|
|
496
|
+
/**
|
|
497
|
+
* Clear the date value
|
|
498
|
+
*/
|
|
499
|
+
clear() {
|
|
500
|
+
this.setAttribute("value", "");
|
|
501
|
+
}
|
|
502
|
+
render() {
|
|
503
|
+
const t = this.getValue(), e = this.getFormat(), a = this.getMin(), s = this.getMax(), n = this.isDisabled(), r = this.getPlaceholder(), o = this.getLabel(), d = this.formatDate(t, e), c = o !== "";
|
|
504
|
+
this.shadowRoot.innerHTML = `
|
|
505
|
+
<style>${f}</style>
|
|
506
|
+
<div class="date-picker-container">
|
|
507
|
+
${c ? `<label class="date-picker-label">${o}</label>` : ""}
|
|
508
|
+
<div class="date-input-wrapper ${n ? "disabled" : ""}">
|
|
509
|
+
<input
|
|
510
|
+
type="text"
|
|
511
|
+
class="formatted-input"
|
|
512
|
+
part="input"
|
|
513
|
+
value="${d}"
|
|
514
|
+
placeholder="${r}"
|
|
515
|
+
${n ? "disabled" : ""}
|
|
516
|
+
/>
|
|
517
|
+
<button
|
|
518
|
+
class="calendar-btn"
|
|
519
|
+
type="button"
|
|
520
|
+
${n ? "disabled" : ""}
|
|
521
|
+
title="Open calendar"
|
|
522
|
+
>
|
|
523
|
+
<svg class="calendar-icon" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
524
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
|
|
525
|
+
</svg>
|
|
526
|
+
</button>
|
|
527
|
+
<input
|
|
528
|
+
type="date"
|
|
529
|
+
class="hidden-date-input"
|
|
530
|
+
value="${t}"
|
|
531
|
+
${a ? `min="${a}"` : ""}
|
|
532
|
+
${s ? `max="${s}"` : ""}
|
|
533
|
+
${n ? "disabled" : ""}
|
|
534
|
+
/>
|
|
535
|
+
</div>
|
|
536
|
+
<div class="format-label">Format: ${e}</div>
|
|
537
|
+
</div>
|
|
538
|
+
`, this.attachEventListeners(), this.hasRendered = !0;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
customElements.define("ui-date-picker", L);
|
|
542
|
+
class I extends g {
|
|
543
|
+
constructor() {
|
|
544
|
+
super(...arguments);
|
|
545
|
+
p(this, "_total", 0);
|
|
546
|
+
p(this, "_currentPage", 1);
|
|
547
|
+
p(this, "_pageSize", 10);
|
|
548
|
+
}
|
|
549
|
+
connectedCallback() {
|
|
550
|
+
this.setAttribute("data-ui", "pagination"), super.connectedCallback();
|
|
551
|
+
}
|
|
552
|
+
static get observedAttributes() {
|
|
553
|
+
return ["total", "current-page", "page-size"];
|
|
554
|
+
}
|
|
555
|
+
attributeChangedCallback(t, e, a) {
|
|
556
|
+
switch (t) {
|
|
557
|
+
case "total":
|
|
558
|
+
this._total = parseInt(a, 10) || 0;
|
|
559
|
+
break;
|
|
560
|
+
case "current-page":
|
|
561
|
+
this._currentPage = parseInt(a, 10) || 1;
|
|
562
|
+
break;
|
|
563
|
+
case "page-size":
|
|
564
|
+
this._pageSize = parseInt(a, 10) || 10;
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
this.render();
|
|
568
|
+
}
|
|
569
|
+
get total() {
|
|
570
|
+
return this._total;
|
|
571
|
+
}
|
|
572
|
+
set total(t) {
|
|
573
|
+
this._total = t, this.setAttribute("total", String(t));
|
|
574
|
+
}
|
|
575
|
+
get currentPage() {
|
|
576
|
+
return this._currentPage;
|
|
577
|
+
}
|
|
578
|
+
set currentPage(t) {
|
|
579
|
+
this._currentPage = t, this.setAttribute("current-page", String(t));
|
|
580
|
+
}
|
|
581
|
+
get pageSize() {
|
|
582
|
+
return this._pageSize;
|
|
583
|
+
}
|
|
584
|
+
set pageSize(t) {
|
|
585
|
+
this._pageSize = t, this.setAttribute("page-size", String(t));
|
|
586
|
+
}
|
|
587
|
+
get totalPages() {
|
|
588
|
+
return Math.ceil(this._total / this._pageSize);
|
|
589
|
+
}
|
|
590
|
+
handlePageChange(t) {
|
|
591
|
+
t < 1 || t > this.totalPages || t === this._currentPage || (this.currentPage = t, this.dispatchEvent(
|
|
592
|
+
new CustomEvent("page-change", {
|
|
593
|
+
detail: {
|
|
594
|
+
page: t,
|
|
595
|
+
pageSize: this._pageSize,
|
|
596
|
+
total: this._total,
|
|
597
|
+
totalPages: this.totalPages
|
|
598
|
+
},
|
|
599
|
+
bubbles: !0,
|
|
600
|
+
composed: !0
|
|
601
|
+
})
|
|
602
|
+
));
|
|
603
|
+
}
|
|
604
|
+
getPageNumbers() {
|
|
605
|
+
const t = this.totalPages, e = this._currentPage;
|
|
606
|
+
if (t <= 7)
|
|
607
|
+
return Array.from({ length: t }, (s, n) => n + 1);
|
|
608
|
+
const a = [];
|
|
609
|
+
return e <= 3 ? a.push(1, 2, 3, 4, "...", t) : e >= t - 2 ? a.push(1, "...", t - 3, t - 2, t - 1, t) : a.push(1, "...", e - 1, e, e + 1, "...", t), a;
|
|
610
|
+
}
|
|
611
|
+
render() {
|
|
612
|
+
const t = this.totalPages, e = this._currentPage, a = this.getPageNumbers(), s = (e - 1) * this._pageSize + 1, n = Math.min(e * this._pageSize, this._total);
|
|
613
|
+
this.shadowRoot.innerHTML = `
|
|
614
|
+
<style>${f}</style>
|
|
615
|
+
<div class="pagination-container">
|
|
616
|
+
<div class="pagination-info">
|
|
617
|
+
${this._total > 0 ? `Showing ${s} to ${n} of ${this._total}` : "No results"}
|
|
618
|
+
</div>
|
|
619
|
+
${t > 1 ? `
|
|
620
|
+
<nav class="pagination" role="navigation" aria-label="Pagination">
|
|
621
|
+
<button
|
|
622
|
+
class="page-btn nav-btn"
|
|
623
|
+
${e === 1 ? "disabled" : ""}
|
|
624
|
+
data-page="prev"
|
|
625
|
+
aria-label="Previous page"
|
|
626
|
+
>
|
|
627
|
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
628
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
|
|
629
|
+
</svg>
|
|
630
|
+
</button>
|
|
631
|
+
${a.map((r) => r === "..." ? '<button class="page-btn ellipsis" disabled>...</button>' : `
|
|
632
|
+
<button
|
|
633
|
+
class="page-btn ${r === e ? "active" : ""}"
|
|
634
|
+
data-page="${r}"
|
|
635
|
+
aria-label="Page ${r}"
|
|
636
|
+
${r === e ? 'aria-current="page"' : ""}
|
|
637
|
+
>
|
|
638
|
+
${r}
|
|
639
|
+
</button>
|
|
640
|
+
`).join("")}
|
|
641
|
+
<button
|
|
642
|
+
class="page-btn nav-btn"
|
|
643
|
+
${e === t ? "disabled" : ""}
|
|
644
|
+
data-page="next"
|
|
645
|
+
aria-label="Next page"
|
|
646
|
+
>
|
|
647
|
+
<svg fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
648
|
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
|
|
649
|
+
</svg>
|
|
650
|
+
</button>
|
|
651
|
+
</nav>
|
|
652
|
+
` : ""}
|
|
653
|
+
</div>
|
|
654
|
+
`, this.attachEventListeners();
|
|
655
|
+
}
|
|
656
|
+
attachEventListeners() {
|
|
657
|
+
this.shadowRoot && this.shadowRoot.addEventListener("click", (t) => {
|
|
658
|
+
const a = t.target.closest(".page-btn");
|
|
659
|
+
if (!a || a.disabled) return;
|
|
660
|
+
const s = a.dataset.page;
|
|
661
|
+
if (s === "prev")
|
|
662
|
+
this.handlePageChange(this._currentPage - 1);
|
|
663
|
+
else if (s === "next")
|
|
664
|
+
this.handlePageChange(this._currentPage + 1);
|
|
665
|
+
else if (s) {
|
|
666
|
+
const n = parseInt(s, 10);
|
|
667
|
+
isNaN(n) || this.handlePageChange(n);
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
customElements.define("ui-pagination", I);
|
|
673
|
+
class M extends g {
|
|
674
|
+
constructor() {
|
|
675
|
+
super(...arguments);
|
|
676
|
+
p(this, "isOpen", this.useSignal(!1));
|
|
677
|
+
}
|
|
678
|
+
connectedCallback() {
|
|
679
|
+
this.setAttribute("data-ui", "modal"), super.connectedCallback(), this.setupEventListeners();
|
|
680
|
+
}
|
|
681
|
+
static get observedAttributes() {
|
|
682
|
+
return ["open"];
|
|
683
|
+
}
|
|
684
|
+
attributeChangedCallback(t, e, a) {
|
|
685
|
+
t === "open" && e !== a && this.isOpen.set(a !== null);
|
|
686
|
+
}
|
|
687
|
+
setupEventListeners() {
|
|
688
|
+
document.addEventListener("keydown", (t) => {
|
|
689
|
+
t.key === "Escape" && this.isOpen.get() && !this.hasAttribute("no-close-on-escape") && this.close();
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
open() {
|
|
693
|
+
this.isOpen.set(!0), this.setAttribute("open", ""), this.dispatchEvent(new CustomEvent("modal-open", { bubbles: !0, composed: !0 })), document.body.style.overflow = "hidden";
|
|
694
|
+
}
|
|
695
|
+
close() {
|
|
696
|
+
this.isOpen.set(!1), this.removeAttribute("open"), this.dispatchEvent(new CustomEvent("modal-close", { bubbles: !0, composed: !0 })), document.body.style.overflow = "";
|
|
697
|
+
}
|
|
698
|
+
handleBackdropClick(t) {
|
|
699
|
+
t.target.classList.contains("modal-backdrop") && !this.hasAttribute("no-close-on-backdrop") && this.close();
|
|
700
|
+
}
|
|
701
|
+
render() {
|
|
702
|
+
const t = this.isOpen.get(), e = this.getAttribute("title") || "", a = this.getAttribute("size") || "md";
|
|
703
|
+
this.shadowRoot.innerHTML = `
|
|
704
|
+
<style>
|
|
705
|
+
${f}
|
|
706
|
+
|
|
707
|
+
::slotted([slot="footer"]) {
|
|
708
|
+
display: flex;
|
|
709
|
+
gap: 0.75rem;
|
|
710
|
+
width: 100%;
|
|
711
|
+
justify-content: flex-end;
|
|
712
|
+
}
|
|
713
|
+
</style>
|
|
714
|
+
|
|
715
|
+
<div class="modal-backdrop ${t ? "open" : ""}" part="backdrop">
|
|
716
|
+
<div class="modal-content ${a}" part="content" @click="${(r) => r.stopPropagation()}">
|
|
717
|
+
${e ? `
|
|
718
|
+
<div class="modal-header" part="header">
|
|
719
|
+
<h2 class="modal-title">${e}</h2>
|
|
720
|
+
<button class="modal-close" part="close" aria-label="Close modal">
|
|
721
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
722
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
723
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
724
|
+
</svg>
|
|
725
|
+
</button>
|
|
726
|
+
</div>
|
|
727
|
+
` : ""}
|
|
728
|
+
|
|
729
|
+
<div class="modal-body" part="body">
|
|
730
|
+
<slot></slot>
|
|
731
|
+
</div>
|
|
732
|
+
|
|
733
|
+
<div class="modal-footer" part="footer">
|
|
734
|
+
<slot name="footer"></slot>
|
|
735
|
+
</div>
|
|
736
|
+
</div>
|
|
737
|
+
</div>
|
|
738
|
+
`;
|
|
739
|
+
const s = this.shadowRoot.querySelector(".modal-backdrop"), n = this.shadowRoot.querySelector(".modal-close");
|
|
740
|
+
s == null || s.addEventListener("click", (r) => this.handleBackdropClick(r)), n == null || n.addEventListener("click", () => this.close());
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
customElements.define("ui-modal", M);
|
|
744
|
+
class R extends g {
|
|
745
|
+
constructor() {
|
|
746
|
+
super(...arguments);
|
|
747
|
+
p(this, "isOpen", this.useSignal(!1));
|
|
748
|
+
p(this, "selectedValue", this.useSignal(""));
|
|
749
|
+
p(this, "searchTerm", this.useSignal(""));
|
|
750
|
+
p(this, "options", []);
|
|
751
|
+
}
|
|
752
|
+
connectedCallback() {
|
|
753
|
+
this.setAttribute("data-ui", "select"), super.connectedCallback(), this.parseOptions(), this.setupClickOutside();
|
|
754
|
+
}
|
|
755
|
+
static get observedAttributes() {
|
|
756
|
+
return ["value", "disabled", "placeholder", "options"];
|
|
757
|
+
}
|
|
758
|
+
attributeChangedCallback(t, e, a) {
|
|
759
|
+
t === "value" && e !== a && this.selectedValue.set(a || ""), t === "options" && e !== a && this.parseOptions(), this.render();
|
|
760
|
+
}
|
|
761
|
+
parseOptions() {
|
|
762
|
+
const t = this.getAttribute("options");
|
|
763
|
+
if (t)
|
|
764
|
+
try {
|
|
765
|
+
this.options = JSON.parse(t);
|
|
766
|
+
} catch (e) {
|
|
767
|
+
console.error("Invalid options JSON", e), this.options = [];
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
setupClickOutside() {
|
|
771
|
+
document.addEventListener("click", (t) => {
|
|
772
|
+
!t.composedPath().includes(this) && this.isOpen.get() && this.isOpen.set(!1);
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
toggleDropdown() {
|
|
776
|
+
this.hasAttribute("disabled") || (this.isOpen.set(!this.isOpen.get()), this.isOpen.get() || this.searchTerm.set(""));
|
|
777
|
+
}
|
|
778
|
+
selectOption(t) {
|
|
779
|
+
this.selectedValue.set(t), this.setAttribute("value", t), this.isOpen.set(!1), this.searchTerm.set(""), this.dispatchEvent(new CustomEvent("select-change", {
|
|
780
|
+
bubbles: !0,
|
|
781
|
+
composed: !0,
|
|
782
|
+
detail: {
|
|
783
|
+
value: t,
|
|
784
|
+
option: this.options.find((e) => e.value === t)
|
|
785
|
+
}
|
|
786
|
+
}));
|
|
787
|
+
}
|
|
788
|
+
handleSearch(t) {
|
|
789
|
+
this.searchTerm.set(t.toLowerCase());
|
|
790
|
+
}
|
|
791
|
+
getFilteredOptions() {
|
|
792
|
+
const t = this.searchTerm.get();
|
|
793
|
+
return t ? this.options.filter(
|
|
794
|
+
(e) => e.label.toLowerCase().includes(t) || e.value.toLowerCase().includes(t)
|
|
795
|
+
) : this.options;
|
|
796
|
+
}
|
|
797
|
+
getSelectedLabel() {
|
|
798
|
+
const t = this.selectedValue.get(), e = this.options.find((a) => a.value === t);
|
|
799
|
+
return (e == null ? void 0 : e.label) || this.getAttribute("placeholder") || "Select an option";
|
|
800
|
+
}
|
|
801
|
+
render() {
|
|
802
|
+
const t = this.isOpen.get(), e = this.hasAttribute("disabled"), a = this.hasAttribute("searchable"), s = this.getAttribute("label") || "", n = this.getSelectedLabel(), r = this.getFilteredOptions(), o = this.selectedValue.get() !== "";
|
|
803
|
+
this.shadowRoot.innerHTML = `
|
|
804
|
+
<style>${f}</style>
|
|
805
|
+
|
|
806
|
+
<div class="select-container">
|
|
807
|
+
${s ? `<label class="select-label">${s}</label>` : ""}
|
|
808
|
+
|
|
809
|
+
<div class="select-trigger ${t ? "open" : ""}" part="trigger" tabindex="0" ${e ? "disabled" : ""}>
|
|
810
|
+
<span class="select-placeholder ${o ? "has-selection" : ""}">${n}</span>
|
|
811
|
+
<span class="select-arrow ${t ? "open" : ""}">
|
|
812
|
+
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
813
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
814
|
+
</svg>
|
|
815
|
+
</span>
|
|
816
|
+
</div>
|
|
817
|
+
|
|
818
|
+
<div class="select-dropdown ${t ? "open" : ""}" part="dropdown">
|
|
819
|
+
${a ? `
|
|
820
|
+
<input
|
|
821
|
+
type="text"
|
|
822
|
+
class="select-search"
|
|
823
|
+
placeholder="Search..."
|
|
824
|
+
part="search"
|
|
825
|
+
>
|
|
826
|
+
` : ""}
|
|
827
|
+
|
|
828
|
+
${r.length > 0 ? r.map((u) => `
|
|
829
|
+
<div
|
|
830
|
+
class="select-option ${u.value === this.selectedValue.get() ? "selected" : ""} ${u.disabled ? "disabled" : ""}"
|
|
831
|
+
data-value="${u.value}"
|
|
832
|
+
part="option"
|
|
833
|
+
>
|
|
834
|
+
${u.label}
|
|
835
|
+
</div>
|
|
836
|
+
`).join("") : `
|
|
837
|
+
<div class="select-empty">No options found</div>
|
|
838
|
+
`}
|
|
839
|
+
</div>
|
|
840
|
+
</div>
|
|
841
|
+
`;
|
|
842
|
+
const d = this.shadowRoot.querySelector(".select-trigger"), c = this.shadowRoot.querySelector(".select-search"), h = this.shadowRoot.querySelectorAll(".select-option:not(.disabled)");
|
|
843
|
+
d == null || d.addEventListener("click", () => this.toggleDropdown()), d == null || d.addEventListener("keydown", (u) => {
|
|
844
|
+
(u.key === "Enter" || u.key === " ") && (u.preventDefault(), this.toggleDropdown());
|
|
845
|
+
}), c == null || c.addEventListener("input", (u) => {
|
|
846
|
+
this.handleSearch(u.target.value);
|
|
847
|
+
}), c == null || c.addEventListener("click", (u) => u.stopPropagation()), h.forEach((u) => {
|
|
848
|
+
u.addEventListener("click", () => {
|
|
849
|
+
const b = u.getAttribute("data-value");
|
|
850
|
+
b && this.selectOption(b);
|
|
851
|
+
});
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
customElements.define("ui-select", R);
|
|
856
|
+
class D extends g {
|
|
857
|
+
constructor() {
|
|
858
|
+
super(...arguments);
|
|
859
|
+
p(this, "checked", this.useSignal(!1));
|
|
860
|
+
p(this, "indeterminate", this.useSignal(!1));
|
|
861
|
+
}
|
|
862
|
+
connectedCallback() {
|
|
863
|
+
this.setAttribute("data-ui", "checkbox"), super.connectedCallback();
|
|
864
|
+
}
|
|
865
|
+
static get observedAttributes() {
|
|
866
|
+
return ["checked", "disabled", "indeterminate"];
|
|
867
|
+
}
|
|
868
|
+
attributeChangedCallback(t, e, a) {
|
|
869
|
+
t === "checked" && e !== a && this.checked.set(a !== null), t === "indeterminate" && e !== a && this.indeterminate.set(a !== null), this.render();
|
|
870
|
+
}
|
|
871
|
+
handleChange() {
|
|
872
|
+
if (this.hasAttribute("disabled")) return;
|
|
873
|
+
this.indeterminate.get() && (this.indeterminate.set(!1), this.removeAttribute("indeterminate"));
|
|
874
|
+
const t = !this.checked.get();
|
|
875
|
+
this.checked.set(t), t ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.dispatchEvent(new CustomEvent("checkbox-change", {
|
|
876
|
+
bubbles: !0,
|
|
877
|
+
composed: !0,
|
|
878
|
+
detail: { checked: t }
|
|
879
|
+
}));
|
|
880
|
+
}
|
|
881
|
+
setChecked(t) {
|
|
882
|
+
this.checked.set(t), t ? this.setAttribute("checked", "") : this.removeAttribute("checked"), this.indeterminate.set(!1), this.removeAttribute("indeterminate");
|
|
883
|
+
}
|
|
884
|
+
setIndeterminate(t) {
|
|
885
|
+
this.indeterminate.set(t), t ? this.setAttribute("indeterminate", "") : this.removeAttribute("indeterminate");
|
|
886
|
+
}
|
|
887
|
+
render() {
|
|
888
|
+
const t = this.checked.get(), e = this.indeterminate.get(), a = this.hasAttribute("disabled"), s = this.getAttribute("label") || "", n = this.getAttribute("size") || "md", r = {
|
|
889
|
+
sm: "size-sm",
|
|
890
|
+
md: "size-md",
|
|
891
|
+
lg: "size-lg"
|
|
892
|
+
};
|
|
893
|
+
this.shadowRoot.innerHTML = `
|
|
894
|
+
<style>${f}</style>
|
|
895
|
+
|
|
896
|
+
<label class="checkbox-container ${r[n]}">
|
|
897
|
+
<input
|
|
898
|
+
type="checkbox"
|
|
899
|
+
${t ? "checked" : ""}
|
|
900
|
+
${a ? "disabled" : ""}
|
|
901
|
+
>
|
|
902
|
+
<div class="checkbox-box ${r[n]} ${t ? "checked" : ""} ${e ? "indeterminate" : ""} ${a ? "disabled" : ""}" part="checkbox">
|
|
903
|
+
<svg class="checkbox-icon check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
|
|
904
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
905
|
+
</svg>
|
|
906
|
+
<svg class="checkbox-icon minus" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
|
|
907
|
+
<line x1="5" y1="12" x2="19" y2="12"></line>
|
|
908
|
+
</svg>
|
|
909
|
+
</div>
|
|
910
|
+
${s ? `<span class="checkbox-label">${s}</span>` : "<slot></slot>"}
|
|
911
|
+
</label>
|
|
912
|
+
`;
|
|
913
|
+
const o = this.shadowRoot.querySelector(".checkbox-container");
|
|
914
|
+
o == null || o.addEventListener("click", (d) => {
|
|
915
|
+
d.preventDefault(), this.handleChange();
|
|
916
|
+
});
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
customElements.define("ui-checkbox", D);
|
|
920
|
+
const T = ':host{display:block}.tabs{background:var(--color-page-bg);border-radius:16px;box-shadow:0 1px 3px #0000000a,0 4px 12px #00000008;overflow:hidden;position:relative}.tablist{display:flex;position:relative;padding:8px;gap:4px;background:linear-gradient(180deg,#fafafa,#f5f5f5);border-bottom:1px solid rgba(0,0,0,.04)}.tab-indicator{position:absolute;bottom:8px;height:calc(100% - 16px);background:var(--color-page-bg);border-radius:10px;box-shadow:0 2px 8px #0000000f,0 1px 2px #0000000a;transition:transform .28s cubic-bezier(.4,0,.2,1),width .28s cubic-bezier(.4,0,.2,1);pointer-events:none;z-index:0}::slotted([slot="tab"]){-webkit-appearance:none;-moz-appearance:none;appearance:none;background:transparent;border:none;color:#64748b;cursor:pointer;font:600 13px/1 DM Sans,system-ui,-apple-system,sans-serif;letter-spacing:.02em;padding:10px 18px;position:relative;transition:color .2s ease;-webkit-user-select:none;user-select:none;white-space:nowrap;z-index:1}::slotted([slot="tab"]:hover){color:var(--color-ink)}::slotted([slot="tab"].is-active){color:var(--color-ink)}::slotted([slot="tab"]:focus-visible){outline:none}::slotted([slot="tab"]:focus-visible):after{content:"";position:absolute;top:6px;right:6px;bottom:6px;left:6px;border:2px solid var(--color-primary);border-radius:8px;pointer-events:none}.panels{padding:24px 28px;min-height:200px}::slotted([slot="panel"]){animation:fadeIn .3s ease}::slotted([slot="panel"]:not(.is-active)){display:none}@keyframes fadeIn{0%{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}@media (prefers-reduced-motion: reduce){.tab-indicator{transition:none}::slotted([slot="panel"]){animation:none}}';
|
|
921
|
+
class Y extends g {
|
|
922
|
+
constructor() {
|
|
923
|
+
super(...arguments);
|
|
924
|
+
p(this, "activeId", null);
|
|
925
|
+
p(this, "indicator", null);
|
|
926
|
+
p(this, "handleTabClick", (t) => {
|
|
927
|
+
const e = t.target;
|
|
928
|
+
if (!e) return;
|
|
929
|
+
const a = e.closest('[slot="tab"][data-tab]');
|
|
930
|
+
if (!a) return;
|
|
931
|
+
t.preventDefault();
|
|
932
|
+
const s = a.getAttribute("data-tab");
|
|
933
|
+
s && this.setActive(s);
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
static get observedAttributes() {
|
|
937
|
+
return ["active"];
|
|
938
|
+
}
|
|
939
|
+
connectedCallback() {
|
|
940
|
+
this.setAttribute("data-ui", "tabs"), super.connectedCallback(), this.addEventListener("click", this.handleTabClick);
|
|
941
|
+
}
|
|
942
|
+
disconnectedCallback() {
|
|
943
|
+
this.removeEventListener("click", this.handleTabClick), super.disconnectedCallback();
|
|
944
|
+
}
|
|
945
|
+
attributeChangedCallback(t, e, a) {
|
|
946
|
+
t === "active" && e !== a && (this.activeId = a, this.syncTabs());
|
|
947
|
+
}
|
|
948
|
+
setActive(t) {
|
|
949
|
+
this.activeId !== t && (this.activeId = t, this.setAttribute("active", t), this.syncTabs(), this.dispatchEvent(new CustomEvent("tab-change", {
|
|
950
|
+
bubbles: !0,
|
|
951
|
+
composed: !0,
|
|
952
|
+
detail: { id: t }
|
|
953
|
+
})));
|
|
954
|
+
}
|
|
955
|
+
getTabs() {
|
|
956
|
+
var e;
|
|
957
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector('slot[name="tab"]');
|
|
958
|
+
return t ? t.assignedElements({ flatten: !0 }) : [];
|
|
959
|
+
}
|
|
960
|
+
getPanels() {
|
|
961
|
+
var e;
|
|
962
|
+
const t = (e = this.shadowRoot) == null ? void 0 : e.querySelector('slot[name="panel"]');
|
|
963
|
+
return t ? t.assignedElements({ flatten: !0 }) : [];
|
|
964
|
+
}
|
|
965
|
+
getActiveId(t) {
|
|
966
|
+
const e = this.getAttribute("active");
|
|
967
|
+
if (e && t.some((s) => s.getAttribute("data-tab") === e))
|
|
968
|
+
return e;
|
|
969
|
+
if (this.activeId && t.some((s) => s.getAttribute("data-tab") === this.activeId))
|
|
970
|
+
return this.activeId;
|
|
971
|
+
const a = t.find((s) => s.getAttribute("data-tab"));
|
|
972
|
+
return (a == null ? void 0 : a.getAttribute("data-tab")) ?? null;
|
|
973
|
+
}
|
|
974
|
+
syncTabs() {
|
|
975
|
+
const t = this.getTabs(), e = this.getPanels();
|
|
976
|
+
if (t.length === 0) return;
|
|
977
|
+
const a = this.getActiveId(t);
|
|
978
|
+
a && (this.activeId = a, this.getAttribute("active") !== a && this.setAttribute("active", a), t.forEach((s) => {
|
|
979
|
+
const n = s.getAttribute("data-tab");
|
|
980
|
+
if (!n) return;
|
|
981
|
+
const r = s.id || `tab-${n}`, o = n === a;
|
|
982
|
+
s.id = r, s.setAttribute("role", "tab"), s.setAttribute("aria-selected", String(o)), s.setAttribute("tabindex", o ? "0" : "-1"), s.classList.toggle("is-active", o);
|
|
983
|
+
}), e.forEach((s) => {
|
|
984
|
+
const n = s.getAttribute("data-tab");
|
|
985
|
+
if (!n) return;
|
|
986
|
+
const r = s.id || `panel-${n}`, o = n === a;
|
|
987
|
+
s.id = r, s.setAttribute("role", "tabpanel"), s.toggleAttribute("hidden", !o), s.classList.toggle("is-active", o);
|
|
988
|
+
const d = t.find((c) => c.getAttribute("data-tab") === n);
|
|
989
|
+
d && (d.setAttribute("aria-controls", r), s.setAttribute("aria-labelledby", d.id));
|
|
990
|
+
}), this.updateIndicator(t, a));
|
|
991
|
+
}
|
|
992
|
+
updateIndicator(t, e) {
|
|
993
|
+
if (!this.indicator) return;
|
|
994
|
+
const a = t.find((o) => o.getAttribute("data-tab") === e);
|
|
995
|
+
if (!a) return;
|
|
996
|
+
const s = this.shadowRoot.querySelector(".tablist");
|
|
997
|
+
if (!s) return;
|
|
998
|
+
a.getBoundingClientRect(), s.getBoundingClientRect();
|
|
999
|
+
const n = t.indexOf(a);
|
|
1000
|
+
let r = 0;
|
|
1001
|
+
for (let o = 0; o < n; o++)
|
|
1002
|
+
r += t[o].offsetWidth;
|
|
1003
|
+
this.indicator.style.transform = `translateX(${r}px)`, this.indicator.style.width = `${a.offsetWidth}px`;
|
|
1004
|
+
}
|
|
1005
|
+
render() {
|
|
1006
|
+
this.shadowRoot.innerHTML = `
|
|
1007
|
+
<style>${f}${T}</style>
|
|
1008
|
+
<div class="tabs">
|
|
1009
|
+
<div class="tablist" role="tablist">
|
|
1010
|
+
<div class="tab-indicator"></div>
|
|
1011
|
+
<slot name="tab"></slot>
|
|
1012
|
+
</div>
|
|
1013
|
+
<div class="panels">
|
|
1014
|
+
<slot name="panel"></slot>
|
|
1015
|
+
</div>
|
|
1016
|
+
</div>
|
|
1017
|
+
`, this.indicator = this.shadowRoot.querySelector(".tab-indicator");
|
|
1018
|
+
const t = this.shadowRoot.querySelector('slot[name="tab"]'), e = this.shadowRoot.querySelector('slot[name="panel"]');
|
|
1019
|
+
t == null || t.addEventListener("slotchange", () => this.syncTabs()), e == null || e.addEventListener("slotchange", () => this.syncTabs()), requestAnimationFrame(() => this.syncTabs());
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
customElements.define("ui-tabs", Y);
|
|
1023
|
+
const q = ':host{display:block;--card-transition: all .3s cubic-bezier(.4, 0, .2, 1)}:host([data-ui="card"]){display:block}.card{background:#fff;padding:24px;box-sizing:border-box;width:100%;position:relative;transition:var(--card-transition);overflow:hidden}.card.rounded{border-radius:16px}.card.square{border-radius:0}.card.default{border:1px solid #e5e7eb;background:#fff}.card.elevated{border:none;background:linear-gradient(to bottom,#fff,#fafbfc)}.card.bordered{border:2px solid #e5e7eb;background:#fff}.card.ghost{border:1px dashed #d1d5db;background:transparent}.card.default:hover{border-color:#d1d5db;transform:translateY(-2px)}.card.elevated:hover{transform:translateY(-4px)}.card.bordered:hover{border-color:#9ca3af;background:#fafbfc}.card.ghost:hover{border-color:#9ca3af;background:#f9fafb80}.card.elevated:before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:inherit;padding:2px;background:linear-gradient(135deg,#6366f11a,#ec48991a);-webkit-mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);mask:linear-gradient(#fff 0 0) content-box,linear-gradient(#fff 0 0);-webkit-mask-composite:xor;mask-composite:exclude;opacity:0;transition:opacity .3s ease;pointer-events:none}.card.elevated:hover:before{opacity:1}.card ::slotted(*:first-child){margin-top:0}.card ::slotted(*:last-child){margin-bottom:0}.card:focus-within{outline:2px solid #9ec5ff;outline-offset:2px}@media (max-width: 768px){.card{padding:20px}.card.rounded{border-radius:12px}}@media (max-width: 480px){.card{padding:16px}.card.rounded{border-radius:10px}}@media print{.card{border:1px solid #e5e7eb;box-shadow:none!important;page-break-inside:avoid}}';
|
|
1024
|
+
class P extends g {
|
|
1025
|
+
connectedCallback() {
|
|
1026
|
+
this.setAttribute("data-ui", "card"), super.connectedCallback();
|
|
1027
|
+
}
|
|
1028
|
+
static get observedAttributes() {
|
|
1029
|
+
return ["shadow", "shadow-color", "rounded", "variant", "elevation"];
|
|
1030
|
+
}
|
|
1031
|
+
attributeChangedCallback() {
|
|
1032
|
+
this.render();
|
|
1033
|
+
}
|
|
1034
|
+
getShadow() {
|
|
1035
|
+
return this.hasAttribute("shadow") && this.getAttribute("shadow") !== "false";
|
|
1036
|
+
}
|
|
1037
|
+
getShadowColor() {
|
|
1038
|
+
return this.getAttribute("shadow-color") ?? "0, 0, 0";
|
|
1039
|
+
}
|
|
1040
|
+
getRounded() {
|
|
1041
|
+
return this.getAttribute("rounded") !== "false";
|
|
1042
|
+
}
|
|
1043
|
+
getVariant() {
|
|
1044
|
+
const i = this.getAttribute("variant");
|
|
1045
|
+
return i === "elevated" || i === "bordered" || i === "ghost" ? i : "default";
|
|
1046
|
+
}
|
|
1047
|
+
getElevation() {
|
|
1048
|
+
const i = this.getAttribute("elevation");
|
|
1049
|
+
return i === "none" || i === "sm" || i === "md" || i === "lg" || i === "xl" ? i : "sm";
|
|
1050
|
+
}
|
|
1051
|
+
render() {
|
|
1052
|
+
const i = this.getShadow(), t = this.getShadowColor(), e = this.getRounded(), a = this.getVariant(), s = this.getElevation();
|
|
1053
|
+
let n = "none";
|
|
1054
|
+
if (i)
|
|
1055
|
+
switch (s) {
|
|
1056
|
+
case "sm":
|
|
1057
|
+
n = `0 1px 2px rgba(${t}, 0.05), 0 1px 3px rgba(${t}, 0.1)`;
|
|
1058
|
+
break;
|
|
1059
|
+
case "md":
|
|
1060
|
+
n = `0 4px 6px rgba(${t}, 0.07), 0 2px 4px rgba(${t}, 0.06)`;
|
|
1061
|
+
break;
|
|
1062
|
+
case "lg":
|
|
1063
|
+
n = `0 10px 15px rgba(${t}, 0.1), 0 4px 6px rgba(${t}, 0.05)`;
|
|
1064
|
+
break;
|
|
1065
|
+
case "xl":
|
|
1066
|
+
n = `0 20px 25px rgba(${t}, 0.15), 0 10px 10px rgba(${t}, 0.04)`;
|
|
1067
|
+
break;
|
|
1068
|
+
default:
|
|
1069
|
+
n = "none";
|
|
1070
|
+
}
|
|
1071
|
+
this.shadowRoot.innerHTML = `
|
|
1072
|
+
<style>
|
|
1073
|
+
${f}
|
|
1074
|
+
${q}
|
|
1075
|
+
|
|
1076
|
+
.card.custom-shadow {
|
|
1077
|
+
box-shadow: ${n};
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
.card.custom-shadow:hover {
|
|
1081
|
+
box-shadow: ${i && s !== "none" ? n.replace(/rgba\(([^)]+), ([\d.]+)\)/g, (r, o, d) => `rgba(${o}, ${Math.min(parseFloat(d) * 1.3, 0.25)})`) : "none"};
|
|
1082
|
+
}
|
|
1083
|
+
</style>
|
|
1084
|
+
<div class="card ${a} ${e ? "rounded" : "square"} ${i ? "custom-shadow" : "no-shadow"}">
|
|
1085
|
+
<slot></slot>
|
|
1086
|
+
</div>
|
|
1087
|
+
`;
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
customElements.define("ui-card", P);
|
|
1091
|
+
const O = ":host{--toast-success: #10b981;--toast-error: #ef4444;--toast-warning: #f59e0b;--toast-info: #3b82f6;--toast-bg: rgba(255, 255, 255, .95);--toast-blur: blur(12px);--toast-shadow: 0 8px 32px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .08);--toast-border: rgba(255, 255, 255, .3);--toast-text: #1e293b;--toast-radius: 14px;--toast-icon-size: 20px}.toast-container{position:fixed;z-index:10000;pointer-events:none;display:flex;flex-direction:column;gap:12px;max-width:420px;padding:16px}.toast-container.top-right{top:0;right:0}.toast-container.top-left{top:0;left:0}.toast-container.bottom-right{bottom:0;right:0;flex-direction:column-reverse}.toast-container.bottom-left{bottom:0;left:0;flex-direction:column-reverse}.toast-container.top-center{top:0;left:50%;transform:translate(-50%)}.toast-container.bottom-center{bottom:0;left:50%;transform:translate(-50%);flex-direction:column-reverse}.toast{pointer-events:auto;background:var(--toast-bg);backdrop-filter:var(--toast-blur);-webkit-backdrop-filter:var(--toast-blur);border:1px solid var(--toast-border);border-radius:var(--toast-radius);box-shadow:var(--toast-shadow);padding:16px 20px;min-width:300px;max-width:100%;display:flex;align-items:flex-start;gap:14px;position:relative;overflow:hidden;opacity:0;transform:translate(100px);animation:toastSlideIn .4s cubic-bezier(.16,1,.3,1) forwards}.toast.closing{animation:toastSlideOut .3s cubic-bezier(.5,0,.75,0) forwards}.toast-container.top-left .toast,.toast-container.bottom-left .toast{transform:translate(-100px);animation:toastSlideInLeft .4s cubic-bezier(.16,1,.3,1) forwards}.toast-container.top-left .toast.closing,.toast-container.bottom-left .toast.closing{animation:toastSlideOutLeft .3s cubic-bezier(.5,0,.75,0) forwards}.toast-container.top-center .toast,.toast-container.bottom-center .toast{transform:translateY(-50px);animation:toastSlideInTop .4s cubic-bezier(.16,1,.3,1) forwards}.toast-container.top-center .toast.closing,.toast-container.bottom-center .toast.closing{animation:toastSlideOutTop .3s cubic-bezier(.5,0,.75,0) forwards}.toast-icon{flex-shrink:0;width:var(--toast-icon-size);height:var(--toast-icon-size);display:flex;align-items:center;justify-content:center;margin-top:2px}.toast-icon svg{width:100%;height:100%;stroke-width:2.5}.toast.success .toast-icon{color:var(--toast-success)}.toast.error .toast-icon{color:var(--toast-error)}.toast.warning .toast-icon{color:var(--toast-warning)}.toast.info .toast-icon{color:var(--toast-info)}.toast.success:before{background:linear-gradient(135deg,var(--toast-success),rgba(16,185,129,.7))}.toast.error:before{background:linear-gradient(135deg,var(--toast-error),rgba(239,68,68,.7))}.toast.warning:before{background:linear-gradient(135deg,var(--toast-warning),rgba(245,158,11,.7))}.toast.info:before{background:linear-gradient(135deg,var(--toast-info),rgba(59,130,246,.7))}.toast-content{flex:1;min-width:0}.toast-title{margin:0 0 4px;font-size:15px;font-weight:600;color:var(--toast-text);line-height:1.4}.toast-description{margin:0;font-size:13.5px;color:#64748b;line-height:1.5}.toast-close{flex-shrink:0;width:20px;height:20px;padding:0;border:none;background:transparent;color:#94a3b8;cursor:pointer;display:flex;align-items:center;justify-content:center;border-radius:4px;transition:all .15s ease;margin-top:2px}.toast-close:hover{background:#0000000d;color:var(--toast-text)}.toast-close svg{width:14px;height:14px;stroke-width:2.5}.toast-progress{position:absolute;bottom:0;left:0;height:3px;width:100%;border-radius:0 0 var(--toast-radius) var(--toast-radius);overflow:hidden;background:#0000000d}.toast-progress-bar{height:100%;width:100%;transform-origin:left;animation:toastProgress var(--duration) linear forwards}.toast.success .toast-progress-bar{background:var(--toast-success)}.toast.error .toast-progress-bar{background:var(--toast-error)}.toast.warning .toast-progress-bar{background:var(--toast-warning)}.toast.info .toast-progress-bar{background:var(--toast-info)}@keyframes toastSlideIn{0%{opacity:0;transform:translate(100px) scale(.95)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes toastSlideOut{0%{opacity:1;transform:translate(0) scale(1)}to{opacity:0;transform:translate(100px) scale(.95)}}@keyframes toastSlideInLeft{0%{opacity:0;transform:translate(-100px) scale(.95)}to{opacity:1;transform:translate(0) scale(1)}}@keyframes toastSlideOutLeft{0%{opacity:1;transform:translate(0) scale(1)}to{opacity:0;transform:translate(-100px) scale(.95)}}@keyframes toastSlideInTop{0%{opacity:0;transform:translateY(-50px) scale(.95)}to{opacity:1;transform:translateY(0) scale(1)}}@keyframes toastSlideOutTop{0%{opacity:1;transform:translateY(0) scale(1)}to{opacity:0;transform:translateY(-50px) scale(.95)}}@keyframes toastProgress{0%{transform:scaleX(1)}to{transform:scaleX(0)}}@media (prefers-color-scheme: dark){:host{--toast-bg: rgba(30, 41, 59, .95);--toast-border: rgba(255, 255, 255, .1);--toast-text: #f1f5f9;--toast-shadow: 0 8px 32px rgba(0, 0, 0, .4), 0 2px 8px rgba(0, 0, 0, .2)}.toast-description{color:#94a3b8}.toast-close{color:#64748b}.toast-close:hover{background:#ffffff1a;color:var(--toast-text)}.toast-progress{background:#ffffff1a}}@media (max-width: 480px){.toast-container{max-width:calc(100vw - 32px);left:16px!important;right:16px!important;transform:none!important;padding:12px}.toast{min-width:0;width:100%}}";
|
|
1092
|
+
class H extends g {
|
|
1093
|
+
constructor() {
|
|
1094
|
+
super(...arguments);
|
|
1095
|
+
p(this, "toasts", /* @__PURE__ */ new Map());
|
|
1096
|
+
p(this, "toastCounter", 0);
|
|
1097
|
+
}
|
|
1098
|
+
connectedCallback() {
|
|
1099
|
+
this.setAttribute("data-ui", "toast"), super.connectedCallback();
|
|
1100
|
+
}
|
|
1101
|
+
static get observedAttributes() {
|
|
1102
|
+
return ["position"];
|
|
1103
|
+
}
|
|
1104
|
+
attributeChangedCallback() {
|
|
1105
|
+
this.render();
|
|
1106
|
+
}
|
|
1107
|
+
getPosition() {
|
|
1108
|
+
const t = this.getAttribute("position");
|
|
1109
|
+
return t === "top-left" || t === "bottom-right" || t === "bottom-left" || t === "top-center" || t === "bottom-center" ? t : "top-right";
|
|
1110
|
+
}
|
|
1111
|
+
getIcon(t) {
|
|
1112
|
+
var s;
|
|
1113
|
+
const a = {
|
|
1114
|
+
success: "check-circle",
|
|
1115
|
+
error: "x-circle",
|
|
1116
|
+
warning: "alert-triangle",
|
|
1117
|
+
info: "info"
|
|
1118
|
+
}[t];
|
|
1119
|
+
return ((s = k.icons[a]) == null ? void 0 : s.toSvg()) || "";
|
|
1120
|
+
}
|
|
1121
|
+
/**
|
|
1122
|
+
* Show a toast notification
|
|
1123
|
+
* @param config Toast configuration
|
|
1124
|
+
* @returns Toast ID for manual dismissal
|
|
1125
|
+
*/
|
|
1126
|
+
show(t) {
|
|
1127
|
+
const {
|
|
1128
|
+
title: e,
|
|
1129
|
+
description: a = "",
|
|
1130
|
+
type: s = "info",
|
|
1131
|
+
duration: n = 5e3,
|
|
1132
|
+
closable: r = !0
|
|
1133
|
+
} = t, o = `toast-${++this.toastCounter}`, d = this.getIcon(s), c = document.createElement("div");
|
|
1134
|
+
c.className = `toast ${s}`, c.setAttribute("role", "alert"), c.setAttribute("aria-live", "polite"), c.innerHTML = `
|
|
1135
|
+
<div class="toast-icon">${d}</div>
|
|
1136
|
+
<div class="toast-content">
|
|
1137
|
+
<div class="toast-title">${this.escapeHtml(e)}</div>
|
|
1138
|
+
${a ? `<div class="toast-description">${this.escapeHtml(a)}</div>` : ""}
|
|
1139
|
+
</div>
|
|
1140
|
+
${r ? `
|
|
1141
|
+
<button class="toast-close" aria-label="Close notification">
|
|
1142
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
|
1143
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
1144
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
1145
|
+
</svg>
|
|
1146
|
+
</button>
|
|
1147
|
+
` : ""}
|
|
1148
|
+
${n > 0 ? `
|
|
1149
|
+
<div class="toast-progress">
|
|
1150
|
+
<div class="toast-progress-bar" style="--duration: ${n}ms"></div>
|
|
1151
|
+
</div>
|
|
1152
|
+
` : ""}
|
|
1153
|
+
`;
|
|
1154
|
+
const h = this.shadowRoot.querySelector(".toast-container");
|
|
1155
|
+
if (h && h.appendChild(c), r) {
|
|
1156
|
+
const b = c.querySelector(".toast-close");
|
|
1157
|
+
b == null || b.addEventListener("click", () => this.dismiss(o));
|
|
1158
|
+
}
|
|
1159
|
+
let u;
|
|
1160
|
+
return n > 0 && (u = window.setTimeout(() => {
|
|
1161
|
+
this.dismiss(o);
|
|
1162
|
+
}, n)), this.toasts.set(o, { element: c, timer: u }), this.dispatchEvent(
|
|
1163
|
+
new CustomEvent("toast-show", {
|
|
1164
|
+
bubbles: !0,
|
|
1165
|
+
composed: !0,
|
|
1166
|
+
detail: { id: o, ...t }
|
|
1167
|
+
})
|
|
1168
|
+
), o;
|
|
1169
|
+
}
|
|
1170
|
+
/**
|
|
1171
|
+
* Dismiss a specific toast
|
|
1172
|
+
*/
|
|
1173
|
+
dismiss(t) {
|
|
1174
|
+
const e = this.toasts.get(t);
|
|
1175
|
+
e && (e.timer && clearTimeout(e.timer), e.element.classList.add("closing"), setTimeout(() => {
|
|
1176
|
+
e.element.remove(), this.toasts.delete(t), this.dispatchEvent(
|
|
1177
|
+
new CustomEvent("toast-dismiss", {
|
|
1178
|
+
bubbles: !0,
|
|
1179
|
+
composed: !0,
|
|
1180
|
+
detail: { id: t }
|
|
1181
|
+
})
|
|
1182
|
+
);
|
|
1183
|
+
}, 300));
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Dismiss all toasts
|
|
1187
|
+
*/
|
|
1188
|
+
dismissAll() {
|
|
1189
|
+
Array.from(this.toasts.keys()).forEach((e) => this.dismiss(e));
|
|
1190
|
+
}
|
|
1191
|
+
/**
|
|
1192
|
+
* Convenience methods for different toast types
|
|
1193
|
+
*/
|
|
1194
|
+
success(t, e, a) {
|
|
1195
|
+
return this.show({ title: t, description: e, type: "success", duration: a });
|
|
1196
|
+
}
|
|
1197
|
+
error(t, e, a) {
|
|
1198
|
+
return this.show({ title: t, description: e, type: "error", duration: a });
|
|
1199
|
+
}
|
|
1200
|
+
warning(t, e, a) {
|
|
1201
|
+
return this.show({ title: t, description: e, type: "warning", duration: a });
|
|
1202
|
+
}
|
|
1203
|
+
info(t, e, a) {
|
|
1204
|
+
return this.show({ title: t, description: e, type: "info", duration: a });
|
|
1205
|
+
}
|
|
1206
|
+
escapeHtml(t) {
|
|
1207
|
+
const e = document.createElement("div");
|
|
1208
|
+
return e.textContent = t, e.innerHTML;
|
|
1209
|
+
}
|
|
1210
|
+
render() {
|
|
1211
|
+
const t = this.getPosition();
|
|
1212
|
+
this.shadowRoot.innerHTML = `
|
|
1213
|
+
<style>
|
|
1214
|
+
${f}
|
|
1215
|
+
${O}
|
|
1216
|
+
</style>
|
|
1217
|
+
<div class="toast-container ${t}"></div>
|
|
1218
|
+
`;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
customElements.define("ui-toast", H);
|
|
1222
|
+
class F extends g {
|
|
1223
|
+
constructor() {
|
|
1224
|
+
super(...arguments);
|
|
1225
|
+
p(this, "steps", []);
|
|
1226
|
+
}
|
|
1227
|
+
connectedCallback() {
|
|
1228
|
+
this.setAttribute("data-ui", "stepper"), super.connectedCallback(), this.parseSteps();
|
|
1229
|
+
}
|
|
1230
|
+
static get observedAttributes() {
|
|
1231
|
+
return ["steps", "active", "orientation", "size"];
|
|
1232
|
+
}
|
|
1233
|
+
attributeChangedCallback(t, e, a) {
|
|
1234
|
+
if (t === "steps" && e !== a && this.parseSteps(), t === "active" && e !== a) {
|
|
1235
|
+
this.render();
|
|
1236
|
+
return;
|
|
1237
|
+
}
|
|
1238
|
+
this.render();
|
|
1239
|
+
}
|
|
1240
|
+
parseSteps() {
|
|
1241
|
+
const t = this.getAttribute("steps");
|
|
1242
|
+
if (!t) {
|
|
1243
|
+
this.steps = [];
|
|
1244
|
+
return;
|
|
1245
|
+
}
|
|
1246
|
+
try {
|
|
1247
|
+
const e = JSON.parse(t);
|
|
1248
|
+
this.steps = Array.isArray(e) ? e : [];
|
|
1249
|
+
} catch (e) {
|
|
1250
|
+
console.error("Invalid steps JSON", e), this.steps = [];
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
getOrientation() {
|
|
1254
|
+
return this.getAttribute("orientation") === "vertical" ? "vertical" : "horizontal";
|
|
1255
|
+
}
|
|
1256
|
+
getSize() {
|
|
1257
|
+
const t = this.getAttribute("size");
|
|
1258
|
+
return t === "sm" || t === "lg" ? t : "md";
|
|
1259
|
+
}
|
|
1260
|
+
getActiveIndex(t) {
|
|
1261
|
+
const e = parseInt(this.getAttribute("active") || "1", 10);
|
|
1262
|
+
return Number.isNaN(e) || t <= 0 ? 1 : Math.min(Math.max(e, 1), t);
|
|
1263
|
+
}
|
|
1264
|
+
resolveState(t, e, a) {
|
|
1265
|
+
return t.state ? t.state : e + 1 < a ? "complete" : e + 1 === a ? "active" : "upcoming";
|
|
1266
|
+
}
|
|
1267
|
+
setActive(t) {
|
|
1268
|
+
const e = this.steps.length;
|
|
1269
|
+
if (e === 0) return;
|
|
1270
|
+
const a = Math.min(Math.max(t, 1), e);
|
|
1271
|
+
if (a === this.getActiveIndex(e)) return;
|
|
1272
|
+
this.setAttribute("active", String(a));
|
|
1273
|
+
const s = this.steps[a - 1], n = this.resolveState(s, a - 1, a);
|
|
1274
|
+
this.dispatchEvent(
|
|
1275
|
+
new CustomEvent("step-change", {
|
|
1276
|
+
bubbles: !0,
|
|
1277
|
+
composed: !0,
|
|
1278
|
+
detail: { index: a, step: s, state: n }
|
|
1279
|
+
})
|
|
1280
|
+
);
|
|
1281
|
+
}
|
|
1282
|
+
escapeHtml(t) {
|
|
1283
|
+
const e = document.createElement("div");
|
|
1284
|
+
return e.textContent = t, e.innerHTML;
|
|
1285
|
+
}
|
|
1286
|
+
render() {
|
|
1287
|
+
const t = this.getOrientation(), e = this.getSize(), a = this.steps, s = a.length, n = this.getActiveIndex(s);
|
|
1288
|
+
this.shadowRoot.innerHTML = `
|
|
1289
|
+
<style>${f}</style>
|
|
1290
|
+
<div class="stepper-wrap">
|
|
1291
|
+
${s === 0 ? '<div class="stepper-empty">No steps configured</div>' : `
|
|
1292
|
+
<ol class="stepper ${t} ${e}" role="list">
|
|
1293
|
+
${a.map((r, o) => {
|
|
1294
|
+
const d = this.resolveState(r, o, n), c = d === "active", h = r.disabled ? "disabled" : "";
|
|
1295
|
+
return `
|
|
1296
|
+
<li class="step ${d} ${h}" data-state="${d}">
|
|
1297
|
+
<button class="step-trigger" data-index="${o}" ${r.disabled ? "disabled" : ""} aria-current="${c ? "step" : "false"}">
|
|
1298
|
+
<span class="step-node">${o + 1}</span>
|
|
1299
|
+
<span class="step-text">
|
|
1300
|
+
<span class="step-title">${this.escapeHtml(r.title || `Step ${o + 1}`)}</span>
|
|
1301
|
+
${r.description ? `<span class="step-desc">${this.escapeHtml(r.description)}</span>` : ""}
|
|
1302
|
+
</span>
|
|
1303
|
+
</button>
|
|
1304
|
+
${o < s - 1 ? '<span class="step-connector" aria-hidden="true"></span>' : ""}
|
|
1305
|
+
</li>
|
|
1306
|
+
`;
|
|
1307
|
+
}).join("")}
|
|
1308
|
+
</ol>
|
|
1309
|
+
`}
|
|
1310
|
+
</div>
|
|
1311
|
+
`, this.shadowRoot.querySelectorAll(".step-trigger").forEach((r) => {
|
|
1312
|
+
r.addEventListener("click", () => {
|
|
1313
|
+
const o = parseInt(r.dataset.index || "0", 10);
|
|
1314
|
+
Number.isNaN(o) || this.setActive(o + 1);
|
|
1315
|
+
});
|
|
1316
|
+
});
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
customElements.define("ui-stepper", F);
|
|
1320
|
+
class V extends g {
|
|
1321
|
+
constructor() {
|
|
1322
|
+
super(...arguments);
|
|
1323
|
+
p(this, "files", this.useSignal([]));
|
|
1324
|
+
p(this, "isDragging", this.useSignal(!1));
|
|
1325
|
+
}
|
|
1326
|
+
connectedCallback() {
|
|
1327
|
+
this.setAttribute("data-ui", "upload"), super.connectedCallback();
|
|
1328
|
+
}
|
|
1329
|
+
static get observedAttributes() {
|
|
1330
|
+
return ["accept", "multiple", "disabled", "label", "helper", "name"];
|
|
1331
|
+
}
|
|
1332
|
+
attributeChangedCallback() {
|
|
1333
|
+
this.render();
|
|
1334
|
+
}
|
|
1335
|
+
get value() {
|
|
1336
|
+
return this.files.get().map((t) => t.name).join(", ");
|
|
1337
|
+
}
|
|
1338
|
+
get filesValue() {
|
|
1339
|
+
return this.files.get();
|
|
1340
|
+
}
|
|
1341
|
+
set filesValue(t) {
|
|
1342
|
+
this.setFiles(t);
|
|
1343
|
+
}
|
|
1344
|
+
clear() {
|
|
1345
|
+
this.setFiles([]);
|
|
1346
|
+
}
|
|
1347
|
+
isDisabled() {
|
|
1348
|
+
return this.hasAttribute("disabled");
|
|
1349
|
+
}
|
|
1350
|
+
isMultiple() {
|
|
1351
|
+
return this.hasAttribute("multiple");
|
|
1352
|
+
}
|
|
1353
|
+
getAccept() {
|
|
1354
|
+
return this.getAttribute("accept") || "";
|
|
1355
|
+
}
|
|
1356
|
+
getLabel() {
|
|
1357
|
+
return this.getAttribute("label") || "Upload files";
|
|
1358
|
+
}
|
|
1359
|
+
getHelper() {
|
|
1360
|
+
return this.getAttribute("helper") || "";
|
|
1361
|
+
}
|
|
1362
|
+
setFiles(t) {
|
|
1363
|
+
const e = this.isMultiple() ? t : t.slice(0, 1);
|
|
1364
|
+
this.files.set(e), this.dispatchEvent(
|
|
1365
|
+
new CustomEvent("upload-change", {
|
|
1366
|
+
bubbles: !0,
|
|
1367
|
+
composed: !0,
|
|
1368
|
+
detail: { files: e }
|
|
1369
|
+
})
|
|
1370
|
+
);
|
|
1371
|
+
}
|
|
1372
|
+
formatSize(t) {
|
|
1373
|
+
if (t < 1024) return `${t} B`;
|
|
1374
|
+
const e = t / 1024;
|
|
1375
|
+
return e < 1024 ? `${e.toFixed(1)} KB` : `${(e / 1024).toFixed(1)} MB`;
|
|
1376
|
+
}
|
|
1377
|
+
syncInputFiles(t, e) {
|
|
1378
|
+
const a = new DataTransfer();
|
|
1379
|
+
e.forEach((s) => a.items.add(s)), t.files = a.files;
|
|
1380
|
+
}
|
|
1381
|
+
render() {
|
|
1382
|
+
const t = this.getAccept(), e = this.getLabel(), a = this.getHelper(), s = this.isDisabled(), n = this.isMultiple(), r = this.isDragging.get(), o = this.files.get();
|
|
1383
|
+
this.shadowRoot.innerHTML = `
|
|
1384
|
+
<style>${f}</style>
|
|
1385
|
+
<div class="upload">
|
|
1386
|
+
${e ? `<label class="upload-label">${e}</label>` : ""}
|
|
1387
|
+
<div class="upload-drop ${r ? "dragging" : ""} ${s ? "disabled" : ""}" part="dropzone">
|
|
1388
|
+
<input
|
|
1389
|
+
class="upload-input"
|
|
1390
|
+
type="file"
|
|
1391
|
+
${n ? "multiple" : ""}
|
|
1392
|
+
${t ? `accept="${t}"` : ""}
|
|
1393
|
+
${s ? "disabled" : ""}
|
|
1394
|
+
>
|
|
1395
|
+
<div class="upload-content">
|
|
1396
|
+
<div class="upload-icon" aria-hidden="true">
|
|
1397
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
|
1398
|
+
<path d="M12 16V4"></path>
|
|
1399
|
+
<path d="M8 8l4-4 4 4"></path>
|
|
1400
|
+
<path d="M4 16v4h16v-4"></path>
|
|
1401
|
+
</svg>
|
|
1402
|
+
</div>
|
|
1403
|
+
<div class="upload-text">
|
|
1404
|
+
<div class="upload-title">Drop files here or browse</div>
|
|
1405
|
+
<div class="upload-sub">
|
|
1406
|
+
${t ? `Accepted: ${t}` : "Any file type supported"}
|
|
1407
|
+
</div>
|
|
1408
|
+
</div>
|
|
1409
|
+
<button class="upload-btn" type="button" ${s ? "disabled" : ""}>Browse</button>
|
|
1410
|
+
</div>
|
|
1411
|
+
</div>
|
|
1412
|
+
${a ? `<div class="upload-helper">${a}</div>` : ""}
|
|
1413
|
+
${o.length ? `
|
|
1414
|
+
<ul class="upload-list">
|
|
1415
|
+
${o.map(
|
|
1416
|
+
(b, m) => `
|
|
1417
|
+
<li>
|
|
1418
|
+
<span>${b.name}</span>
|
|
1419
|
+
<span class="upload-meta">${this.formatSize(b.size)}</span>
|
|
1420
|
+
<button class="upload-remove" data-index="${m}" type="button">Remove</button>
|
|
1421
|
+
</li>
|
|
1422
|
+
`
|
|
1423
|
+
).join("")}
|
|
1424
|
+
</ul>
|
|
1425
|
+
` : ""}
|
|
1426
|
+
</div>
|
|
1427
|
+
`;
|
|
1428
|
+
const d = this.shadowRoot.querySelector(".upload-drop"), c = this.shadowRoot.querySelector(".upload-input"), h = this.shadowRoot.querySelector(".upload-btn"), u = this.shadowRoot.querySelectorAll(".upload-remove");
|
|
1429
|
+
!d || !c || (o.length ? this.syncInputFiles(c, o) : c.value = "", d.addEventListener("dragover", (b) => {
|
|
1430
|
+
s || (b.preventDefault(), this.isDragging.set(!0));
|
|
1431
|
+
}), d.addEventListener("dragleave", () => {
|
|
1432
|
+
this.isDragging.set(!1);
|
|
1433
|
+
}), d.addEventListener("drop", (b) => {
|
|
1434
|
+
var v;
|
|
1435
|
+
if (s) return;
|
|
1436
|
+
b.preventDefault(), this.isDragging.set(!1);
|
|
1437
|
+
const m = Array.from(((v = b.dataTransfer) == null ? void 0 : v.files) ?? []);
|
|
1438
|
+
m.length && (this.setFiles(m), this.syncInputFiles(c, this.files.get()));
|
|
1439
|
+
}), c.addEventListener("change", () => {
|
|
1440
|
+
const b = Array.from(c.files ?? []);
|
|
1441
|
+
this.setFiles(b);
|
|
1442
|
+
}), h == null || h.addEventListener("click", () => {
|
|
1443
|
+
s || c.click();
|
|
1444
|
+
}), u.forEach((b) => {
|
|
1445
|
+
b.addEventListener("click", () => {
|
|
1446
|
+
const m = parseInt(b.dataset.index || "0", 10), v = this.files.get().filter((_, w) => w !== m);
|
|
1447
|
+
this.setFiles(v), this.syncInputFiles(c, v);
|
|
1448
|
+
});
|
|
1449
|
+
}));
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
customElements.define("ui-upload", V);
|
|
1453
|
+
class U {
|
|
1454
|
+
constructor() {
|
|
1455
|
+
p(this, "baseURL", "");
|
|
1456
|
+
p(this, "defaultHeaders", {
|
|
1457
|
+
"Content-Type": "application/json"
|
|
1458
|
+
});
|
|
1459
|
+
p(this, "defaultTimeout", 3e4);
|
|
1460
|
+
p(this, "interceptors", {
|
|
1461
|
+
request: {
|
|
1462
|
+
handlers: [],
|
|
1463
|
+
use: (i, t) => {
|
|
1464
|
+
this.interceptors.request.handlers.push({ onFulfilled: i, onRejected: t });
|
|
1465
|
+
}
|
|
1466
|
+
},
|
|
1467
|
+
response: {
|
|
1468
|
+
handlers: [],
|
|
1469
|
+
use: (i, t) => {
|
|
1470
|
+
this.interceptors.response.handlers.push({ onFulfilled: i, onRejected: t });
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Set base URL for all requests
|
|
1477
|
+
*/
|
|
1478
|
+
setBaseURL(i) {
|
|
1479
|
+
this.baseURL = i;
|
|
1480
|
+
}
|
|
1481
|
+
/**
|
|
1482
|
+
* Get currently set base URL
|
|
1483
|
+
*/
|
|
1484
|
+
getBaseURL() {
|
|
1485
|
+
return this.baseURL;
|
|
1486
|
+
}
|
|
1487
|
+
/**
|
|
1488
|
+
* Set default headers for all requests
|
|
1489
|
+
*/
|
|
1490
|
+
setDefaultHeaders(i) {
|
|
1491
|
+
this.defaultHeaders = { ...this.defaultHeaders, ...i };
|
|
1492
|
+
}
|
|
1493
|
+
/**
|
|
1494
|
+
* Set default timeout for all requests (in ms)
|
|
1495
|
+
*/
|
|
1496
|
+
setDefaultTimeout(i) {
|
|
1497
|
+
this.defaultTimeout = i;
|
|
1498
|
+
}
|
|
1499
|
+
/**
|
|
1500
|
+
* Execute request with interceptors
|
|
1501
|
+
*/
|
|
1502
|
+
async executeRequest(i, t) {
|
|
1503
|
+
const e = i.startsWith("http") ? i : this.baseURL + i;
|
|
1504
|
+
let a = {
|
|
1505
|
+
method: "GET",
|
|
1506
|
+
headers: { ...this.defaultHeaders },
|
|
1507
|
+
timeout: this.defaultTimeout,
|
|
1508
|
+
...t
|
|
1509
|
+
};
|
|
1510
|
+
for (const r of this.interceptors.request.handlers)
|
|
1511
|
+
try {
|
|
1512
|
+
a = await r.onFulfilled(a);
|
|
1513
|
+
} catch (o) {
|
|
1514
|
+
if (r.onRejected)
|
|
1515
|
+
a = await r.onRejected(o);
|
|
1516
|
+
else
|
|
1517
|
+
throw o;
|
|
1518
|
+
}
|
|
1519
|
+
const s = new AbortController(), n = setTimeout(() => s.abort(), a.timeout || this.defaultTimeout);
|
|
1520
|
+
try {
|
|
1521
|
+
const r = {
|
|
1522
|
+
method: a.method,
|
|
1523
|
+
headers: a.headers,
|
|
1524
|
+
signal: s.signal
|
|
1525
|
+
};
|
|
1526
|
+
a.body && a.method !== "GET" && (r.body = (typeof a.body == "string", a.body));
|
|
1527
|
+
const o = await fetch(e, r);
|
|
1528
|
+
let d;
|
|
1529
|
+
const c = o.headers.get("content-type");
|
|
1530
|
+
c != null && c.includes("application/json") ? d = o.ok ? await o.json() : null : c != null && c.includes("text") ? d = await o.text() : d = await o.blob();
|
|
1531
|
+
let h = {
|
|
1532
|
+
status: o.status,
|
|
1533
|
+
statusText: o.statusText,
|
|
1534
|
+
headers: o.headers,
|
|
1535
|
+
data: d
|
|
1536
|
+
};
|
|
1537
|
+
if (!o.ok) {
|
|
1538
|
+
const u = new Error(`HTTP ${o.status}: ${o.statusText}`);
|
|
1539
|
+
throw u.response = h, u.config = a, u;
|
|
1540
|
+
}
|
|
1541
|
+
for (const u of this.interceptors.response.handlers)
|
|
1542
|
+
try {
|
|
1543
|
+
h = await u.onFulfilled(h);
|
|
1544
|
+
} catch (b) {
|
|
1545
|
+
if (u.onRejected)
|
|
1546
|
+
h = await u.onRejected(b);
|
|
1547
|
+
else
|
|
1548
|
+
throw b;
|
|
1549
|
+
}
|
|
1550
|
+
return h.data;
|
|
1551
|
+
} catch (r) {
|
|
1552
|
+
throw r instanceof Error && r.name === "AbortError" ? new Error(`Request timeout after ${a.timeout}ms`) : r;
|
|
1553
|
+
} finally {
|
|
1554
|
+
clearTimeout(n);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* GET request
|
|
1559
|
+
*/
|
|
1560
|
+
async get(i, t) {
|
|
1561
|
+
return this.executeRequest(i, { ...t, method: "GET" });
|
|
1562
|
+
}
|
|
1563
|
+
/**
|
|
1564
|
+
* POST request
|
|
1565
|
+
*/
|
|
1566
|
+
async post(i, t, e) {
|
|
1567
|
+
return this.executeRequest(i, {
|
|
1568
|
+
...e,
|
|
1569
|
+
method: "POST",
|
|
1570
|
+
body: typeof t == "string" || t instanceof FormData ? t : JSON.stringify(t)
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* PUT request
|
|
1575
|
+
*/
|
|
1576
|
+
async put(i, t, e) {
|
|
1577
|
+
return this.executeRequest(i, {
|
|
1578
|
+
...e,
|
|
1579
|
+
method: "PUT",
|
|
1580
|
+
body: typeof t == "string" || t instanceof FormData ? t : JSON.stringify(t)
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
/**
|
|
1584
|
+
* PATCH request
|
|
1585
|
+
*/
|
|
1586
|
+
async patch(i, t, e) {
|
|
1587
|
+
return this.executeRequest(i, {
|
|
1588
|
+
...e,
|
|
1589
|
+
method: "PATCH",
|
|
1590
|
+
body: typeof t == "string" || t instanceof FormData ? t : JSON.stringify(t)
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
/**
|
|
1594
|
+
* DELETE request
|
|
1595
|
+
*/
|
|
1596
|
+
async delete(i, t) {
|
|
1597
|
+
return this.executeRequest(i, { ...t, method: "DELETE" });
|
|
1598
|
+
}
|
|
1599
|
+
/**
|
|
1600
|
+
* HEAD request
|
|
1601
|
+
*/
|
|
1602
|
+
async head(i, t) {
|
|
1603
|
+
return this.executeRequest(i, { ...t, method: "HEAD" });
|
|
1604
|
+
}
|
|
1605
|
+
}
|
|
1606
|
+
const J = new U();
|
|
1607
|
+
function x(l, i) {
|
|
1608
|
+
return l ? l.querySelector(i) : null;
|
|
1609
|
+
}
|
|
1610
|
+
function G(l, i) {
|
|
1611
|
+
return l ? l.querySelectorAll(i) : [];
|
|
1612
|
+
}
|
|
1613
|
+
function X(l, i) {
|
|
1614
|
+
return l ? l.querySelector(`#${i}`) : null;
|
|
1615
|
+
}
|
|
1616
|
+
function K(l, i, t, e, a) {
|
|
1617
|
+
if (!l) return null;
|
|
1618
|
+
const s = l.querySelector(`#${i}`);
|
|
1619
|
+
return s ? (s.addEventListener(t, e, a), s) : null;
|
|
1620
|
+
}
|
|
1621
|
+
function Q(l, i) {
|
|
1622
|
+
return x(l, i);
|
|
1623
|
+
}
|
|
1624
|
+
function Z(l, i) {
|
|
1625
|
+
return x(l, i);
|
|
1626
|
+
}
|
|
1627
|
+
function tt(l, i) {
|
|
1628
|
+
return x(l, i);
|
|
1629
|
+
}
|
|
1630
|
+
const N = "input, select, textarea, ui-input, ui-select, ui-date-picker, ui-checkbox, ui-upload";
|
|
1631
|
+
function y(l) {
|
|
1632
|
+
return l.getAttribute("name") || l.getAttribute("id") || "";
|
|
1633
|
+
}
|
|
1634
|
+
function j(l) {
|
|
1635
|
+
const i = l.tagName.toLowerCase();
|
|
1636
|
+
if (i === "ui-checkbox")
|
|
1637
|
+
return l.hasAttribute("checked");
|
|
1638
|
+
if (i === "ui-upload") {
|
|
1639
|
+
const a = l == null ? void 0 : l.filesValue;
|
|
1640
|
+
return Array.isArray(a) && a.length > 0 ? a : [];
|
|
1641
|
+
}
|
|
1642
|
+
const t = l == null ? void 0 : l.value;
|
|
1643
|
+
if (typeof t == "string" && t !== "")
|
|
1644
|
+
return t;
|
|
1645
|
+
const e = l.getAttribute("value");
|
|
1646
|
+
return e || "";
|
|
1647
|
+
}
|
|
1648
|
+
function et(l, i = {}) {
|
|
1649
|
+
const { includeDisabled: t = !1, includeEmpty: e = !0 } = i, a = {}, s = /* @__PURE__ */ new Map();
|
|
1650
|
+
l.querySelectorAll('input[type="checkbox"]').forEach((r) => {
|
|
1651
|
+
const o = y(r);
|
|
1652
|
+
o && s.set(o, (s.get(o) || 0) + 1);
|
|
1653
|
+
});
|
|
1654
|
+
const n = Array.from(l.querySelectorAll(N));
|
|
1655
|
+
for (const r of n) {
|
|
1656
|
+
if (!t && (r.disabled || r.hasAttribute("disabled"))) continue;
|
|
1657
|
+
const o = y(r);
|
|
1658
|
+
if (!o) continue;
|
|
1659
|
+
if (r instanceof HTMLInputElement) {
|
|
1660
|
+
const c = r.type;
|
|
1661
|
+
if (c === "checkbox") {
|
|
1662
|
+
if ((s.get(o) || 0) > 1) {
|
|
1663
|
+
const u = a[o] || [];
|
|
1664
|
+
r.checked && u.push(r.value || "on"), a[o] = u;
|
|
1665
|
+
} else
|
|
1666
|
+
a[o] = r.checked;
|
|
1667
|
+
continue;
|
|
1668
|
+
}
|
|
1669
|
+
if (c === "radio") {
|
|
1670
|
+
r.checked && (a[o] = r.value);
|
|
1671
|
+
continue;
|
|
1672
|
+
}
|
|
1673
|
+
if (c === "file") {
|
|
1674
|
+
const h = Array.from(r.files ?? []);
|
|
1675
|
+
(e || h.length > 0) && (a[o] = h);
|
|
1676
|
+
continue;
|
|
1677
|
+
}
|
|
1678
|
+
(e || r.value !== "") && (a[o] = r.value);
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
if (r instanceof HTMLSelectElement) {
|
|
1682
|
+
if (r.multiple) {
|
|
1683
|
+
const c = Array.from(r.selectedOptions).map((h) => h.value);
|
|
1684
|
+
(e || c.length > 0) && (a[o] = c);
|
|
1685
|
+
} else (e || r.value !== "") && (a[o] = r.value);
|
|
1686
|
+
continue;
|
|
1687
|
+
}
|
|
1688
|
+
if (r instanceof HTMLTextAreaElement) {
|
|
1689
|
+
(e || r.value !== "") && (a[o] = r.value);
|
|
1690
|
+
continue;
|
|
1691
|
+
}
|
|
1692
|
+
const d = j(r);
|
|
1693
|
+
(e || (Array.isArray(d) ? d.length > 0 : d !== "")) && (a[o] = d);
|
|
1694
|
+
}
|
|
1695
|
+
return a;
|
|
1696
|
+
}
|
|
1697
|
+
export {
|
|
1698
|
+
U as HTTPClient,
|
|
1699
|
+
C as UIButton,
|
|
1700
|
+
P as UICard,
|
|
1701
|
+
D as UICheckbox,
|
|
1702
|
+
L as UIDatePicker,
|
|
1703
|
+
S as UIInput,
|
|
1704
|
+
M as UIModal,
|
|
1705
|
+
I as UIPagination,
|
|
1706
|
+
R as UISelect,
|
|
1707
|
+
F as UIStepper,
|
|
1708
|
+
z as UITable,
|
|
1709
|
+
Y as UITabs,
|
|
1710
|
+
H as UIToast,
|
|
1711
|
+
V as UIUpload,
|
|
1712
|
+
K as addEventListenerById,
|
|
1713
|
+
X as getElementById,
|
|
1714
|
+
et as getFormValues,
|
|
1715
|
+
J as http,
|
|
1716
|
+
x as queryElement,
|
|
1717
|
+
G as queryElements,
|
|
1718
|
+
tt as queryModal,
|
|
1719
|
+
Z as queryPagination,
|
|
1720
|
+
Q as queryTable
|
|
1721
|
+
};
|