compostrap 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/auth.css +166 -0
- package/dist/css/blog.css +512 -0
- package/dist/css/chart.css +99 -0
- package/dist/css/compostrap.css +5052 -0
- package/dist/css/dashboard.css +360 -0
- package/dist/css/datagrid.css +64 -0
- package/dist/css/datepicker.css +514 -0
- package/dist/css/dialogs.css +185 -0
- package/dist/css/dropzone.css +86 -0
- package/dist/css/elements.css +181 -0
- package/dist/css/empty.css +94 -0
- package/dist/css/gallery.css +122 -0
- package/dist/css/lightbox.css +144 -0
- package/dist/css/number-input.css +100 -0
- package/dist/css/otp-input.css +177 -0
- package/dist/css/password-toggle.css +52 -0
- package/dist/css/rating.css +95 -0
- package/dist/css/selection.css +59 -0
- package/dist/css/settings.css +85 -0
- package/dist/css/shop.css +1026 -0
- package/dist/css/sidebar-menu.css +439 -0
- package/dist/css/sidebar.css +95 -0
- package/dist/css/spinner.css +102 -0
- package/dist/css/strength.css +118 -0
- package/dist/css/theme-switcher.css +5 -0
- package/dist/css/theme.css +13034 -0
- package/dist/css/tooltip.css +158 -0
- package/dist/js/chart.js +257 -0
- package/dist/js/datepicker.js +82 -0
- package/dist/js/dialogs.js +7 -0
- package/dist/js/dropzone.js +15 -0
- package/dist/js/index.js +24 -0
- package/dist/js/lightbox.js +77 -0
- package/dist/js/number-input.js +44 -0
- package/dist/js/otp-input.js +182 -0
- package/dist/js/password-toggle.js +16 -0
- package/dist/js/selection.js +32 -0
- package/dist/js/sidebar-menu.js +76 -0
- package/dist/js/sidebar.js +120 -0
- package/dist/js/spinner.js +27 -0
- package/dist/js/strength.js +87 -0
- package/dist/js/theme-switcher.js +98 -0
- package/dist/js/tooltip.js +17 -0
- package/docs/auth.md +25 -0
- package/docs/blog.md +85 -0
- package/docs/chart.md +39 -0
- package/docs/datagrid.md +64 -0
- package/docs/datepicker.md +35 -0
- package/docs/dialogs.md +81 -0
- package/docs/dropzone.md +23 -0
- package/docs/elements.md +38 -0
- package/docs/empty.md +25 -0
- package/docs/gallery.md +23 -0
- package/docs/layout.md +143 -0
- package/docs/lightbox.md +18 -0
- package/docs/number-input.md +19 -0
- package/docs/otp-input.md +52 -0
- package/docs/password-toggle.md +21 -0
- package/docs/rating.md +15 -0
- package/docs/selection.md +52 -0
- package/docs/settings.md +25 -0
- package/docs/shop.md +140 -0
- package/docs/spinner.md +51 -0
- package/docs/strength.md +26 -0
- package/docs/theme-switcher.md +60 -0
- package/docs/theme.md +100 -0
- package/docs/tooltip.md +30 -0
- package/license +21 -0
- package/package.json +106 -6
- package/readme.md +198 -0
- package/src/illustrations/empty.svg +15 -0
- package/src/illustrations/forbidden.svg +16 -0
- package/src/illustrations/maintenance.svg +14 -0
- package/src/illustrations/not-found.svg +22 -0
- package/src/illustrations/server-error.svg +21 -0
- package/src/js/chart.js +359 -0
- package/src/js/datepicker.js +154 -0
- package/src/js/dialogs.js +25 -0
- package/src/js/dropzone.js +35 -0
- package/src/js/index.js +29 -0
- package/src/js/lightbox.js +165 -0
- package/src/js/number-input.js +87 -0
- package/src/js/otp-input.js +401 -0
- package/src/js/password-toggle.js +45 -0
- package/src/js/selection.js +114 -0
- package/src/js/sidebar-menu.js +178 -0
- package/src/js/sidebar.js +326 -0
- package/src/js/spinner.js +76 -0
- package/src/js/strength.js +115 -0
- package/src/js/theme-switcher.js +197 -0
- package/src/js/tooltip.js +46 -0
- package/src/scss/_bootstrap.scss +9 -0
- package/src/scss/_variables.scss +58 -0
- package/src/scss/auth/_index.scss +210 -0
- package/src/scss/auth.scss +5 -0
- package/src/scss/blog/_article.scss +181 -0
- package/src/scss/blog/_comments.scss +108 -0
- package/src/scss/blog/_index.scss +18 -0
- package/src/scss/blog/_list.scss +246 -0
- package/src/scss/blog/_page.scss +138 -0
- package/src/scss/blog.scss +5 -0
- package/src/scss/chart/_index.scss +114 -0
- package/src/scss/chart.scss +5 -0
- package/src/scss/compostrap.scss +29 -0
- package/src/scss/dashboard/_content.scss +25 -0
- package/src/scss/dashboard/_dropdown.scss +71 -0
- package/src/scss/dashboard/_index.scss +9 -0
- package/src/scss/dashboard/_nanobar.scss +34 -0
- package/src/scss/dashboard/_navbar.scss +314 -0
- package/src/scss/dashboard/_theme.scss +27 -0
- package/src/scss/dashboard.scss +5 -0
- package/src/scss/datagrid/_index.scss +111 -0
- package/src/scss/datagrid.scss +5 -0
- package/src/scss/datepicker/_index.scss +557 -0
- package/src/scss/datepicker.scss +5 -0
- package/src/scss/dialogs/_index.scss +8 -0
- package/src/scss/dialogs/_modal.scss +82 -0
- package/src/scss/dialogs/_offcanvas.scss +13 -0
- package/src/scss/dialogs/_search.scss +79 -0
- package/src/scss/dialogs/_toast.scss +61 -0
- package/src/scss/dialogs.scss +5 -0
- package/src/scss/dropzone/_index.scss +111 -0
- package/src/scss/dropzone.scss +5 -0
- package/src/scss/elements/_datagrid-filter.scss +21 -0
- package/src/scss/elements/_index.scss +9 -0
- package/src/scss/elements/_list-row.scss +40 -0
- package/src/scss/elements/_loading.scss +47 -0
- package/src/scss/elements/_stat.scss +73 -0
- package/src/scss/elements/_status-dot.scss +38 -0
- package/src/scss/elements.scss +5 -0
- package/src/scss/empty/_index.scss +117 -0
- package/src/scss/empty.scss +5 -0
- package/src/scss/gallery/_index.scss +162 -0
- package/src/scss/gallery.scss +5 -0
- package/src/scss/lightbox/_index.scss +171 -0
- package/src/scss/lightbox.scss +5 -0
- package/src/scss/number-input/_index.scss +143 -0
- package/src/scss/number-input.scss +5 -0
- package/src/scss/otp-input/_index.scss +214 -0
- package/src/scss/otp-input.scss +5 -0
- package/src/scss/password-toggle/_index.scss +82 -0
- package/src/scss/password-toggle.scss +5 -0
- package/src/scss/rating/_index.scss +121 -0
- package/src/scss/rating.scss +5 -0
- package/src/scss/selection/_index.scss +84 -0
- package/src/scss/selection.scss +5 -0
- package/src/scss/settings/_index.scss +6 -0
- package/src/scss/settings/_nav-list.scss +52 -0
- package/src/scss/settings/_setting-row.scss +50 -0
- package/src/scss/settings.scss +5 -0
- package/src/scss/shop/_bar.scss +64 -0
- package/src/scss/shop/_catalog.scss +308 -0
- package/src/scss/shop/_checkout.scss +204 -0
- package/src/scss/shop/_filters.scss +116 -0
- package/src/scss/shop/_hero.scss +130 -0
- package/src/scss/shop/_index.scss +22 -0
- package/src/scss/shop/_page.scss +154 -0
- package/src/scss/shop/_reviews.scss +165 -0
- package/src/scss/shop/_stepper.scss +159 -0
- package/src/scss/shop.scss +5 -0
- package/src/scss/sidebar/_body.scss +8 -0
- package/src/scss/sidebar/_index.scss +8 -0
- package/src/scss/sidebar/_sidebar.scss +89 -0
- package/src/scss/sidebar/_theme.scss +7 -0
- package/src/scss/sidebar/_wrapper.scss +17 -0
- package/src/scss/sidebar-menu/_compact.scss +174 -0
- package/src/scss/sidebar-menu/_index.scss +9 -0
- package/src/scss/sidebar-menu/_list.scss +131 -0
- package/src/scss/sidebar-menu/_pills.scss +82 -0
- package/src/scss/sidebar-menu/_scrollbar.scss +53 -0
- package/src/scss/sidebar-menu/_theme.scss +109 -0
- package/src/scss/sidebar-menu.scss +5 -0
- package/src/scss/sidebar.scss +5 -0
- package/src/scss/spinner/_index.scss +130 -0
- package/src/scss/spinner.scss +5 -0
- package/src/scss/strength/_index.scss +118 -0
- package/src/scss/strength.scss +5 -0
- package/src/scss/theme/_accordion.scss +20 -0
- package/src/scss/theme/_alerts.scss +24 -0
- package/src/scss/theme/_avatar.scss +37 -0
- package/src/scss/theme/_badges.scss +53 -0
- package/src/scss/theme/_base.scss +9 -0
- package/src/scss/theme/_breadcrumb.scss +64 -0
- package/src/scss/theme/_buttons.scss +200 -0
- package/src/scss/theme/_cards.scss +17 -0
- package/src/scss/theme/_colors.scss +139 -0
- package/src/scss/theme/_forms.scss +175 -0
- package/src/scss/theme/_index.scss +18 -0
- package/src/scss/theme/_navs.scss +15 -0
- package/src/scss/theme/_overlays.scss +128 -0
- package/src/scss/theme/_tables.scss +59 -0
- package/src/scss/theme/_variables.scss +194 -0
- package/src/scss/theme-switcher/_index.scss +9 -0
- package/src/scss/theme-switcher.scss +5 -0
- package/src/scss/theme.scss +9 -0
- package/src/scss/tooltip/_index.scss +177 -0
- package/src/scss/tooltip.scss +5 -0
- package/README.md +0 -3
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// src/js/otp-input.js
|
|
2
|
+
var e = {
|
|
3
|
+
numeric: {
|
|
4
|
+
inputmode: "numeric",
|
|
5
|
+
pattern: "[0-9]*",
|
|
6
|
+
filter: /[^0-9]/g
|
|
7
|
+
},
|
|
8
|
+
alphanumeric: {
|
|
9
|
+
inputmode: "text",
|
|
10
|
+
pattern: "[A-Za-z0-9]*",
|
|
11
|
+
filter: /[^A-Za-z0-9]/g
|
|
12
|
+
},
|
|
13
|
+
alpha: {
|
|
14
|
+
inputmode: "text",
|
|
15
|
+
pattern: "[A-Za-z]*",
|
|
16
|
+
filter: /[^A-Za-z]/g
|
|
17
|
+
}
|
|
18
|
+
}, t = class t {
|
|
19
|
+
static Default = {
|
|
20
|
+
groups: null,
|
|
21
|
+
length: null,
|
|
22
|
+
mask: !1,
|
|
23
|
+
separator: "·",
|
|
24
|
+
type: "numeric"
|
|
25
|
+
};
|
|
26
|
+
static _instances = /* @__PURE__ */ new WeakMap();
|
|
27
|
+
static _initialized = !1;
|
|
28
|
+
static init(e = document) {
|
|
29
|
+
if (!this._initialized) {
|
|
30
|
+
this._initialized = !0;
|
|
31
|
+
let e = (e, t) => document.addEventListener(e, (e) => this._of(e.target)?.[t](e), !0);
|
|
32
|
+
e("beforeinput", "_handleBeforeInput"), e("input", "_handleInput"), e("paste", "_handlePaste"), e("pointerdown", "_handlePointerDown"), e("focus", "_handleFocus"), e("blur", "_render"), e("keyup", "_render"), e("select", "_render"), document.addEventListener("selectionchange", () => this._of(document.activeElement)?._render()), document.addEventListener("reset", (e) => setTimeout(() => this.update(e.target)));
|
|
33
|
+
}
|
|
34
|
+
this.update(e);
|
|
35
|
+
}
|
|
36
|
+
static update(e = document) {
|
|
37
|
+
e.querySelectorAll("[data-bs-otp]").forEach((e) => {
|
|
38
|
+
let t = this.getOrCreateInstance(e);
|
|
39
|
+
t._input && t._render();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
static getInstance(e) {
|
|
43
|
+
return this._instances.get(e) ?? null;
|
|
44
|
+
}
|
|
45
|
+
static getOrCreateInstance(e, t = {}) {
|
|
46
|
+
return this.getInstance(e) ?? new this(e, t);
|
|
47
|
+
}
|
|
48
|
+
static _of(e) {
|
|
49
|
+
if (!(e instanceof HTMLInputElement)) return null;
|
|
50
|
+
let t = e.closest("[data-bs-otp]"), n = t ? this.getOrCreateInstance(t) : null;
|
|
51
|
+
return n?._input === e ? n : null;
|
|
52
|
+
}
|
|
53
|
+
constructor(n, r = {}) {
|
|
54
|
+
this._element = n, this._input = n.querySelector("input"), this._input && (this._config = {
|
|
55
|
+
...t.Default,
|
|
56
|
+
...this._dataConfig(),
|
|
57
|
+
...r
|
|
58
|
+
}, this._type = e[this._config.type] || e.numeric, this._length = this._resolveLength(), this._slots = [], this._pointerActive = !1, this._pointerIndex = 0, t._instances.set(n, this), this._setupInput(), this._renderSlots(), this._render());
|
|
59
|
+
}
|
|
60
|
+
getValue() {
|
|
61
|
+
return this._input.value;
|
|
62
|
+
}
|
|
63
|
+
setValue(e) {
|
|
64
|
+
this._input.value = this._sanitize(String(e)), this._render(), this._checkComplete();
|
|
65
|
+
}
|
|
66
|
+
clear() {
|
|
67
|
+
this._input.value = "", this._render(), this._input.focus();
|
|
68
|
+
}
|
|
69
|
+
focus() {
|
|
70
|
+
this._input.focus(), this._selectSlot(this._firstEmptyIndex()), this._render();
|
|
71
|
+
}
|
|
72
|
+
dispose() {
|
|
73
|
+
this._slotsContainer?.remove(), this._element.classList.remove("otp-rendered"), t._instances.delete(this._element);
|
|
74
|
+
}
|
|
75
|
+
_dataConfig() {
|
|
76
|
+
let { bsLength: e, bsType: t, bsMask: n, bsGroups: r, bsSeparator: i } = this._element.dataset, a = {};
|
|
77
|
+
if (e && (a.length = Number.parseInt(e, 10) || null), t && (a.type = t), n !== void 0 && (a.mask = n === "true" || n === ""), i !== void 0 && (a.separator = i), r) try {
|
|
78
|
+
a.groups = JSON.parse(r);
|
|
79
|
+
} catch {
|
|
80
|
+
a.groups = null;
|
|
81
|
+
}
|
|
82
|
+
return a;
|
|
83
|
+
}
|
|
84
|
+
_resolveLength() {
|
|
85
|
+
if (this._config.length) return this._config.length;
|
|
86
|
+
let e = Number.parseInt(this._input.getAttribute("maxlength"), 10);
|
|
87
|
+
return Number.isNaN(e) || e < 1 ? 6 : e;
|
|
88
|
+
}
|
|
89
|
+
_setupInput() {
|
|
90
|
+
let e = this._input;
|
|
91
|
+
(e.type === "number" || e.type === "password") && (e.type = "text"), e.classList.add("otp-input"), e.setAttribute("maxlength", String(this._length)), e.setAttribute("inputmode", this._type.inputmode), e.setAttribute("pattern", this._type.pattern), e.getAttribute("autocomplete") || e.setAttribute("autocomplete", "one-time-code"), e.value &&= this._sanitize(e.value);
|
|
92
|
+
}
|
|
93
|
+
_renderSlots() {
|
|
94
|
+
let e = document.createElement("div");
|
|
95
|
+
e.className = "otp-slots", e.setAttribute("aria-hidden", "true");
|
|
96
|
+
let { groups: t } = this._config, n = 0, r = 0;
|
|
97
|
+
for (let i = 0; i < this._length; i++) {
|
|
98
|
+
let a = document.createElement("div");
|
|
99
|
+
if (a.className = "otp-slot", e.append(a), this._slots.push(a), Array.isArray(t) && t.length > 0 && (r++, r === t[n] && i < this._length - 1)) {
|
|
100
|
+
let i = document.createElement("div");
|
|
101
|
+
i.className = "otp-separator", i.textContent = this._config.separator, e.append(i), n = Math.min(n + 1, t.length - 1), r = 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this._slotsContainer = e, this._element.append(e), this._element.classList.add("otp-rendered");
|
|
105
|
+
}
|
|
106
|
+
_handleFocus() {
|
|
107
|
+
this._pointerActive ? (this._pointerActive = !1, this._selectSlot(this._pointerIndex)) : this._selectSlot(this._firstEmptyIndex()), this._render();
|
|
108
|
+
}
|
|
109
|
+
_handleInput() {
|
|
110
|
+
let e = this._sanitize(this._input.value);
|
|
111
|
+
e !== this._input.value && (this._input.value = e), document.activeElement === this._input && this._selectSlot(this._firstEmptyIndex()), this._afterValueChange();
|
|
112
|
+
}
|
|
113
|
+
_handlePaste(e) {
|
|
114
|
+
let t = e.clipboardData?.getData("text");
|
|
115
|
+
if (!t || !this._isEditable()) return;
|
|
116
|
+
let n = this._sanitize(t), r = this._input.selectionStart ?? this._input.value.length, i = this._input.selectionEnd ?? r;
|
|
117
|
+
n.length === this._length && (r = 0, i = this._input.value.length);
|
|
118
|
+
let a = n.slice(0, this._length - this._input.value.length + i - r);
|
|
119
|
+
e.preventDefault(), a && (this._input.setRangeText(a, r, i, "end"), this._selectSlot(this._input.selectionStart), this._afterValueChange());
|
|
120
|
+
}
|
|
121
|
+
_handleBeforeInput(e) {
|
|
122
|
+
if (!this._isEditable()) return;
|
|
123
|
+
let { inputType: t, data: n } = e;
|
|
124
|
+
if (t === "insertText" && n && n.length === 1) {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
let t = this._sanitize(n);
|
|
127
|
+
if (!t) return;
|
|
128
|
+
let r = Math.min(this._input.selectionStart ?? 0, this._length - 1), i = [...this._input.value];
|
|
129
|
+
i[r] = t, this._input.value = i.join("").slice(0, this._length), this._selectSlot(r + 1), this._afterValueChange();
|
|
130
|
+
} else if (t === "deleteContentBackward" || t === "deleteContentForward") {
|
|
131
|
+
e.preventDefault();
|
|
132
|
+
let n = this._input.selectionStart ?? 0, r = this._input.selectionEnd ?? n;
|
|
133
|
+
r === n && (t === "deleteContentBackward" ? --n : r += 1);
|
|
134
|
+
let i = [...this._input.value];
|
|
135
|
+
if (n < 0 || r > i.length) return;
|
|
136
|
+
i.splice(n, r - n), this._input.value = i.join(""), this._selectSlot(n), this._afterValueChange();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
_handlePointerDown(e) {
|
|
140
|
+
if (this._input.matches(":disabled")) return;
|
|
141
|
+
let t = Math.min(this._slotIndexFromPoint(e.clientX), this._firstEmptyIndex());
|
|
142
|
+
document.activeElement === this._input ? (e.preventDefault(), this._selectSlot(t), this._render()) : (this._pointerActive = !0, this._pointerIndex = t);
|
|
143
|
+
}
|
|
144
|
+
_slotIndexFromPoint(e) {
|
|
145
|
+
let t = this._slots.findIndex((t) => e <= t.getBoundingClientRect().right);
|
|
146
|
+
return t === -1 ? this._slots.length - 1 : t;
|
|
147
|
+
}
|
|
148
|
+
_afterValueChange() {
|
|
149
|
+
this._render(), this._trigger("input.bs.otpInput"), this._checkComplete();
|
|
150
|
+
}
|
|
151
|
+
_checkComplete() {
|
|
152
|
+
this._input.value.length === this._length && this._trigger("complete.bs.otpInput");
|
|
153
|
+
}
|
|
154
|
+
_trigger(e) {
|
|
155
|
+
let t = this._input.value, n = new CustomEvent(e, {
|
|
156
|
+
bubbles: !0,
|
|
157
|
+
detail: { value: t }
|
|
158
|
+
});
|
|
159
|
+
n.value = t, this._element.dispatchEvent(n);
|
|
160
|
+
}
|
|
161
|
+
_firstEmptyIndex() {
|
|
162
|
+
return Math.min(this._input.value.length, this._length - 1);
|
|
163
|
+
}
|
|
164
|
+
_isEditable() {
|
|
165
|
+
return !this._input.readOnly && !this._input.matches(":disabled");
|
|
166
|
+
}
|
|
167
|
+
_selectSlot(e) {
|
|
168
|
+
let t = Math.max(0, Math.min(e, this._length - 1)), n = t < this._input.value.length ? t + 1 : t;
|
|
169
|
+
this._input.setSelectionRange(t, n);
|
|
170
|
+
}
|
|
171
|
+
_sanitize(e) {
|
|
172
|
+
return e.replace(this._type.filter, "").slice(0, this._length);
|
|
173
|
+
}
|
|
174
|
+
_render() {
|
|
175
|
+
let { value: e } = this._input, t = document.activeElement === this._input, n = Math.min(this._input.selectionStart ?? e.length, this._length - 1);
|
|
176
|
+
this._slots.forEach((r, i) => {
|
|
177
|
+
let a = e[i] ?? "";
|
|
178
|
+
r.textContent = a && this._config.mask ? "•" : a, r.classList.toggle("otp-slot-filled", !!a), r.classList.toggle("otp-slot-active", t && i === n);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
export { t as OtpInput };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// src/js/password-toggle.js
|
|
2
|
+
var e = class {
|
|
3
|
+
static _initialized = !1;
|
|
4
|
+
static init() {
|
|
5
|
+
this._initialized || (this._initialized = !0, document.documentElement.setAttribute("data-password-toggle", ""), document.addEventListener("click", (e) => {
|
|
6
|
+
let t = e.target.closest("[data-password-toggle]")?.closest(".password-toggle")?.querySelector("input");
|
|
7
|
+
t && this.toggle(t);
|
|
8
|
+
}), document.addEventListener("submit", (e) => {
|
|
9
|
+
e.target.querySelectorAll(".password-toggle > input[type=\"text\"]").forEach((e) => this.toggle(e, !1));
|
|
10
|
+
}, !0));
|
|
11
|
+
}
|
|
12
|
+
static toggle(e, t = e.type === "password") {
|
|
13
|
+
e.type = t ? "text" : "password", e.closest(".password-toggle")?.querySelector("[data-password-toggle]")?.setAttribute("aria-pressed", String(t));
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export { e as PasswordToggle };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/js/selection.js
|
|
2
|
+
var e = class {
|
|
3
|
+
static _initialized = !1;
|
|
4
|
+
static init() {
|
|
5
|
+
this._initialized || (this._initialized = !0, document.addEventListener("change", (e) => {
|
|
6
|
+
let t = e.target.closest?.("[data-selection-all], [data-selection-item]"), n = t?.closest("[data-selection]");
|
|
7
|
+
n && (t.matches("[data-selection-all]") && this.items(n).forEach((e) => e.checked = t.checked), this.update(n));
|
|
8
|
+
}), document.addEventListener("click", (e) => {
|
|
9
|
+
let t = e.target.closest("[data-selection-clear]")?.closest("[data-selection]");
|
|
10
|
+
t ? this.clear(t) : this._clickRow(e);
|
|
11
|
+
}), document.querySelectorAll("[data-selection]").forEach((e) => this.update(e)));
|
|
12
|
+
}
|
|
13
|
+
static _clickRow(e) {
|
|
14
|
+
let t = e.target.closest("tbody tr");
|
|
15
|
+
if (!t?.closest("[data-selection-rows]") || e.target.closest("a, button, input, select, textarea, label, [data-bs-toggle]") || e.target.closest("td")?.querySelector("button, .btn") || !window.getSelection()?.isCollapsed) return;
|
|
16
|
+
let n = t.querySelector("[data-selection-item]:not(:disabled)");
|
|
17
|
+
n && (n.checked = !n.checked, n.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
18
|
+
}
|
|
19
|
+
static items(e) {
|
|
20
|
+
return [...e.querySelectorAll("[data-selection-item]:not(:disabled)")];
|
|
21
|
+
}
|
|
22
|
+
static clear(e) {
|
|
23
|
+
this.items(e).forEach((e) => e.checked = !1), this.update(e);
|
|
24
|
+
}
|
|
25
|
+
static update(e) {
|
|
26
|
+
let t = this.items(e), n = t.filter((e) => e.checked).length;
|
|
27
|
+
t.forEach((e) => e.closest("tr")?.classList.toggle("table-active", e.checked)), e.querySelectorAll("[data-selection-all]").forEach((e) => {
|
|
28
|
+
e.checked = n > 0 && n === t.length, e.indeterminate = n > 0 && n < t.length;
|
|
29
|
+
}), e.querySelectorAll("[data-selection-count]").forEach((e) => e.textContent = String(n)), e.querySelectorAll("[data-selection-single]").forEach((e) => e.disabled = n !== 1), e.querySelectorAll("[data-selection-bar]").forEach((e) => e.hidden = n === 0);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export { e as RowSelection };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// src/js/sidebar-menu.js
|
|
2
|
+
var e = class {
|
|
3
|
+
static slideDuration = 0;
|
|
4
|
+
static _slideStates = /* @__PURE__ */ new WeakMap();
|
|
5
|
+
static _submenuId = 0;
|
|
6
|
+
static init() {
|
|
7
|
+
let e = document.querySelectorAll(".list-item"), t = window.matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : this.slideDuration;
|
|
8
|
+
e.forEach((e) => {
|
|
9
|
+
e.querySelectorAll("a.link-arrow").forEach((e) => {
|
|
10
|
+
let n = e.nextElementSibling;
|
|
11
|
+
n && e.dataset.sidebarMenuInitialized !== "true" && (e.dataset.sidebarMenuInitialized = "true", e.classList.add("up"), n.id ||= `sidebar-submenu-${++this._submenuId}`, e.setAttribute("aria-controls", n.id), e.classList.contains("link-current") && (e.classList.add("active", "down"), n.style.display = "block"), e.setAttribute("aria-expanded", String(n.style.display === "block")), e.hasAttribute("href") || (e.setAttribute("role", "button"), e.tabIndex = 0, e.addEventListener("keydown", (t) => {
|
|
12
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), e.click());
|
|
13
|
+
})), e.addEventListener("click", (r) => {
|
|
14
|
+
if (this._isCompact()) return;
|
|
15
|
+
r.preventDefault();
|
|
16
|
+
let i = this._slideToggle(n, t);
|
|
17
|
+
e.setAttribute("aria-expanded", String(i)), e.classList.contains("down") && e.classList.toggle("rotate-revert"), e.classList.add("transition"), e.classList.toggle("active"), e.classList.toggle("rotate");
|
|
18
|
+
}));
|
|
19
|
+
});
|
|
20
|
+
}), document.querySelectorAll(".list-link.link-current:not(.link-arrow)").forEach((e) => {
|
|
21
|
+
e.setAttribute("aria-current", "page");
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
static _isCompact() {
|
|
25
|
+
return document.documentElement.classList.contains("sidebar-compact") && window.matchMedia("(min-width: 768px)").matches;
|
|
26
|
+
}
|
|
27
|
+
static _slideToggle(e, t) {
|
|
28
|
+
let n = this._slideStates.get(e), r = n ? n.open : window.getComputedStyle(e).display !== "none";
|
|
29
|
+
return r ? this._slideUp(e, t) : this._slideDown(e, t), !r;
|
|
30
|
+
}
|
|
31
|
+
static _slideUp(e, t) {
|
|
32
|
+
this._animate(e, !1, t);
|
|
33
|
+
}
|
|
34
|
+
static _slideDown(e, t) {
|
|
35
|
+
this._animate(e, !0, t);
|
|
36
|
+
}
|
|
37
|
+
static _animate(e, t, n) {
|
|
38
|
+
let r = this._slideStates.get(e), i = e.getBoundingClientRect().height;
|
|
39
|
+
r?.timer && clearTimeout(r.timer), t && (e.style.display = "block"), [
|
|
40
|
+
"height",
|
|
41
|
+
"padding-top",
|
|
42
|
+
"padding-bottom",
|
|
43
|
+
"margin-top",
|
|
44
|
+
"margin-bottom",
|
|
45
|
+
"overflow",
|
|
46
|
+
"box-sizing",
|
|
47
|
+
"transition-duration",
|
|
48
|
+
"transition-property"
|
|
49
|
+
].forEach((t) => e.style.removeProperty(t));
|
|
50
|
+
let a = e.offsetHeight;
|
|
51
|
+
e.style.overflow = "hidden", e.style.boxSizing = "border-box", e.style.height = i + "px", e.style.paddingTop = t ? "0" : "", e.style.paddingBottom = t ? "0" : "", e.style.marginTop = t ? "0" : "", e.style.marginBottom = t ? "0" : "", e.offsetHeight, e.style.transitionProperty = "height, margin, padding", e.style.transitionDuration = n + "ms", e.style.height = t ? a + "px" : "0", t ? (e.style.removeProperty("padding-top"), e.style.removeProperty("padding-bottom"), e.style.removeProperty("margin-top"), e.style.removeProperty("margin-bottom")) : (e.style.paddingTop = "0", e.style.paddingBottom = "0", e.style.marginTop = "0", e.style.marginBottom = "0");
|
|
52
|
+
let o = {
|
|
53
|
+
open: t,
|
|
54
|
+
timer: null
|
|
55
|
+
};
|
|
56
|
+
this._slideStates.set(e, o);
|
|
57
|
+
let s = () => {
|
|
58
|
+
this._slideStates.get(e) === o && (t || (e.style.display = "none"), [
|
|
59
|
+
"height",
|
|
60
|
+
"padding-top",
|
|
61
|
+
"padding-bottom",
|
|
62
|
+
"margin-top",
|
|
63
|
+
"margin-bottom",
|
|
64
|
+
"overflow",
|
|
65
|
+
"box-sizing",
|
|
66
|
+
"transition-duration",
|
|
67
|
+
"transition-property"
|
|
68
|
+
].forEach((t) => e.style.removeProperty(t)), this._slideStates.set(e, {
|
|
69
|
+
open: t,
|
|
70
|
+
timer: null
|
|
71
|
+
}));
|
|
72
|
+
};
|
|
73
|
+
n === 0 ? s() : o.timer = setTimeout(s, n);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
export { e as SidebarMenu };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// src/js/sidebar.js
|
|
2
|
+
var e = class {
|
|
3
|
+
static compactStorageKey = "sidebar-compact";
|
|
4
|
+
static _compactInitialized = !1;
|
|
5
|
+
static _label = null;
|
|
6
|
+
static _flyout = null;
|
|
7
|
+
static _flyoutGroup = null;
|
|
8
|
+
static init() {
|
|
9
|
+
this._initCompact();
|
|
10
|
+
let e = document.getElementById("sidebar"), t = document.getElementById("navigation");
|
|
11
|
+
if (!e || !t || t.dataset.sidebarInitialized === "true") return;
|
|
12
|
+
t.dataset.sidebarInitialized = "true", e.setAttribute("aria-controls", t.id);
|
|
13
|
+
let n = document.createElement("div");
|
|
14
|
+
n.className = "sidebar-backdrop", t.after(n);
|
|
15
|
+
let r = (t) => {
|
|
16
|
+
e.setAttribute("aria-expanded", String(t));
|
|
17
|
+
}, i = window.matchMedia("(min-width: 768px)"), a = () => t.classList.contains("sidebar-toggle"), o = () => {
|
|
18
|
+
t.inert = !i.matches && !a() && !t.classList.contains("sidebar-toggle-visible");
|
|
19
|
+
};
|
|
20
|
+
r(a()), n.classList.toggle("show", a()), o();
|
|
21
|
+
let s = () => {
|
|
22
|
+
t.classList.remove("sidebar-toggle"), n.classList.remove("show"), r(!1), o();
|
|
23
|
+
};
|
|
24
|
+
e.addEventListener("click", () => {
|
|
25
|
+
let e = !a();
|
|
26
|
+
t.classList.toggle("sidebar-toggle", e), n.classList.toggle("show", e), r(e), o(), e && !i.matches && t.querySelector("a[href], button, [tabindex=\"0\"]")?.focus({ preventScroll: !0 });
|
|
27
|
+
}), document.addEventListener("focusin", (n) => {
|
|
28
|
+
!i.matches && a() && n.target !== e && !t.contains(n.target) && s();
|
|
29
|
+
}), n.addEventListener("click", () => {
|
|
30
|
+
s(), e.focus();
|
|
31
|
+
}), document.addEventListener("keydown", (t) => {
|
|
32
|
+
t.key === "Escape" && a() && (s(), e.focus());
|
|
33
|
+
}), i.addEventListener("change", (e) => {
|
|
34
|
+
e.matches && s(), o();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
static setCompact(e) {
|
|
38
|
+
document.documentElement.classList.toggle("sidebar-compact", e), document.querySelectorAll("[data-sidebar-compact]").forEach((t) => t.setAttribute("aria-pressed", String(e)));
|
|
39
|
+
try {
|
|
40
|
+
localStorage.setItem(this.compactStorageKey, e ? "1" : "0");
|
|
41
|
+
} catch {}
|
|
42
|
+
this._hideLabel(), this._closeFlyout(), window.dispatchEvent(new Event("resize"));
|
|
43
|
+
}
|
|
44
|
+
static isCompact() {
|
|
45
|
+
return document.documentElement.classList.contains("sidebar-compact") && window.matchMedia("(min-width: 768px)").matches;
|
|
46
|
+
}
|
|
47
|
+
static _initCompact() {
|
|
48
|
+
if (this._compactInitialized) return;
|
|
49
|
+
this._compactInitialized = !0;
|
|
50
|
+
let e = null;
|
|
51
|
+
try {
|
|
52
|
+
e = localStorage.getItem(this.compactStorageKey);
|
|
53
|
+
} catch {}
|
|
54
|
+
e !== null && document.documentElement.classList.toggle("sidebar-compact", e === "1");
|
|
55
|
+
let t = document.documentElement.classList.contains("sidebar-compact");
|
|
56
|
+
document.querySelectorAll("[data-sidebar-compact]").forEach((e) => e.setAttribute("aria-pressed", String(t))), document.addEventListener("click", (e) => {
|
|
57
|
+
if (e.target.closest("[data-sidebar-compact]")) {
|
|
58
|
+
this.setCompact(!document.documentElement.classList.contains("sidebar-compact"));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let t = e.target.closest(".sidebar .list-link.link-arrow");
|
|
62
|
+
t && this.isCompact() ? (e.preventDefault(), this._flyoutGroup === t ? this._closeFlyout() : this._openFlyout(t, e.detail === 0)) : this._flyout && !this._flyout.contains(e.target) && this._closeFlyout();
|
|
63
|
+
}), document.addEventListener("keydown", (e) => {
|
|
64
|
+
if (!this._flyout) return;
|
|
65
|
+
let t = [...this._flyout.querySelectorAll(".sidebar-compact-menu-item")], n = t.indexOf(e.target);
|
|
66
|
+
e.key === "Escape" ? this._closeFlyout(!0) : (e.key === "ArrowDown" || e.key === "ArrowUp") && (n !== -1 || e.target === this._flyoutGroup) ? (e.preventDefault(), t[Math.min(Math.max(n + (e.key === "ArrowDown" ? 1 : -1), 0), t.length - 1)].focus()) : e.key === "Tab" && e.shiftKey && n === 0 ? (e.preventDefault(), this._closeFlyout(!0)) : e.key === "Tab" && !e.shiftKey && n === t.length - 1 && this._closeFlyout(!0);
|
|
67
|
+
}), document.addEventListener("focusin", (e) => {
|
|
68
|
+
this._flyout && !this._flyout.contains(e.target) && e.target !== this._flyoutGroup && this._closeFlyout();
|
|
69
|
+
}), window.addEventListener("resize", () => this._closeFlyout()), document.addEventListener("scroll", (e) => {
|
|
70
|
+
this._hideLabel(), this._flyout?.contains(e.target) || this._closeFlyout();
|
|
71
|
+
}, !0);
|
|
72
|
+
let n = (e) => {
|
|
73
|
+
let t = e.target.closest?.(".sidebar .list-link");
|
|
74
|
+
t && t !== this._flyoutGroup && this.isCompact() && this._showLabel(t);
|
|
75
|
+
}, r = (e) => {
|
|
76
|
+
e.target.closest?.(".sidebar .list-link") && this._hideLabel();
|
|
77
|
+
};
|
|
78
|
+
document.addEventListener("mouseover", n), document.addEventListener("focusin", n), document.addEventListener("mouseout", r), document.addEventListener("focusout", r);
|
|
79
|
+
}
|
|
80
|
+
static _linkText(e) {
|
|
81
|
+
return (e.querySelector(".float-start") || e).textContent.trim();
|
|
82
|
+
}
|
|
83
|
+
static _place(e, t, n) {
|
|
84
|
+
let r = t.getBoundingClientRect();
|
|
85
|
+
e.style.left = `${r.right + 8}px`, e.style.top = `${n ?? r.top + r.height / 2}px`;
|
|
86
|
+
}
|
|
87
|
+
static _showLabel(e) {
|
|
88
|
+
this._label || (this._label = document.createElement("div"), this._label.className = "sidebar-compact-label", this._label.setAttribute("aria-hidden", "true"), document.body.append(this._label)), this._label.textContent = this._linkText(e), this._place(this._label, e), this._label.hidden = !1;
|
|
89
|
+
}
|
|
90
|
+
static _hideLabel() {
|
|
91
|
+
this._label && (this._label.hidden = !0);
|
|
92
|
+
}
|
|
93
|
+
static _openFlyout(e, t = !1) {
|
|
94
|
+
this._closeFlyout();
|
|
95
|
+
let n = e.nextElementSibling;
|
|
96
|
+
if (!n) return;
|
|
97
|
+
let r = document.createElement("ul");
|
|
98
|
+
r.className = "sidebar-compact-menu", r.id = "sidebar-compact-menu";
|
|
99
|
+
let i = (t, n) => {
|
|
100
|
+
let i = document.createElement("li"), a = t === e || t.classList.contains("link-arrow"), o = document.createElement(a ? "h6" : "a");
|
|
101
|
+
o.className = a ? "sidebar-compact-menu-header" : "sidebar-compact-menu-item", o.textContent = this._linkText(t), n && (o.style.paddingLeft = `${1 + n}rem`), a || (o.href = t.getAttribute("href") || "#", t.classList.contains("link-current") && (o.classList.add("active"), o.setAttribute("aria-current", "page"))), i.append(o), r.append(i);
|
|
102
|
+
};
|
|
103
|
+
i(e, 0), n.querySelectorAll(".list-link").forEach((e) => i(e, this._depth(e, n))), document.body.append(r);
|
|
104
|
+
let a = Math.max(8, Math.min(e.getBoundingClientRect().top - 8, window.innerHeight - r.offsetHeight - 8));
|
|
105
|
+
this._place(r, e, a), this._flyout = r, this._flyoutGroup = e, e.setAttribute("aria-controls", r.id), e.setAttribute("aria-expanded", "true"), e.classList.add("sidebar-compact-open"), this._hideLabel(), t && r.querySelector(".sidebar-compact-menu-item")?.focus({ preventScroll: !0 });
|
|
106
|
+
}
|
|
107
|
+
static _closeFlyout(e = !1) {
|
|
108
|
+
let t = this._flyoutGroup;
|
|
109
|
+
if (!t) return;
|
|
110
|
+
(e || this._flyout.contains(document.activeElement)) && t.focus({ preventScroll: !0 });
|
|
111
|
+
let n = t.nextElementSibling;
|
|
112
|
+
t.classList.remove("sidebar-compact-open"), t.setAttribute("aria-expanded", String(n?.style.display === "block")), n?.id ? t.setAttribute("aria-controls", n.id) : t.removeAttribute("aria-controls"), this._flyout.remove(), this._flyout = null, this._flyoutGroup = null;
|
|
113
|
+
}
|
|
114
|
+
static _depth(e, t) {
|
|
115
|
+
let n = 0;
|
|
116
|
+
for (let r = e.parentElement; r && r !== t; r = r.parentElement) n += +!!r.classList.contains("list-hidden");
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
export { e as Sidebar };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/js/spinner.js
|
|
2
|
+
var e = class {
|
|
3
|
+
_count = 0;
|
|
4
|
+
_focused = null;
|
|
5
|
+
constructor({ overlay: e = !1, label: t = "Loading", parent: n = document.body } = {}) {
|
|
6
|
+
this.overlay = e, this.parent = n, this.element = document.createElement("div"), this.element.className = e ? "spinner-overlay" : "spinner", this.element.setAttribute("role", "status"), this.label = t, this._label = document.createElement("span"), this._label.className = "spinner-label", this.element.append(this._label);
|
|
7
|
+
}
|
|
8
|
+
get active() {
|
|
9
|
+
return this._count > 0;
|
|
10
|
+
}
|
|
11
|
+
show() {
|
|
12
|
+
this._count++ > 0 || (this.parent.appendChild(this.element), this._timer = setTimeout(() => {
|
|
13
|
+
this._label.textContent = this.label;
|
|
14
|
+
}, 100), this.overlay && (this._focused = document.activeElement, this._focused?.blur?.(), document.addEventListener("keydown", this._stopKeys, !0)));
|
|
15
|
+
}
|
|
16
|
+
hide() {
|
|
17
|
+
this._count === 0 || --this._count > 0 || (clearTimeout(this._timer), this._label.textContent = "", this.element.remove(), this.overlay && (document.removeEventListener("keydown", this._stopKeys, !0), this._focused?.isConnected && this._focused.focus({ preventScroll: !0 }), this._focused = null));
|
|
18
|
+
}
|
|
19
|
+
_stopKeys = (e) => {
|
|
20
|
+
[
|
|
21
|
+
"Tab",
|
|
22
|
+
"Enter",
|
|
23
|
+
" "
|
|
24
|
+
].includes(e.key) && (e.preventDefault(), e.stopPropagation());
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export { e as Spinner };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/js/strength.js
|
|
2
|
+
var e = [
|
|
3
|
+
"weak",
|
|
4
|
+
"fair",
|
|
5
|
+
"good",
|
|
6
|
+
"strong"
|
|
7
|
+
], t = /[!@#$%^&*(),.?":{}|<>]/, n = class {
|
|
8
|
+
static options = {
|
|
9
|
+
minLength: 8,
|
|
10
|
+
thresholds: [
|
|
11
|
+
2,
|
|
12
|
+
4,
|
|
13
|
+
6
|
|
14
|
+
],
|
|
15
|
+
messages: {
|
|
16
|
+
weak: "Weak",
|
|
17
|
+
fair: "Fair",
|
|
18
|
+
good: "Good",
|
|
19
|
+
strong: "Strong"
|
|
20
|
+
},
|
|
21
|
+
scorer: null
|
|
22
|
+
};
|
|
23
|
+
static _initialized = !1;
|
|
24
|
+
static init(e = {}) {
|
|
25
|
+
if (this.options = {
|
|
26
|
+
...this.options,
|
|
27
|
+
...e,
|
|
28
|
+
messages: {
|
|
29
|
+
...this.options.messages,
|
|
30
|
+
...e.messages
|
|
31
|
+
}
|
|
32
|
+
}, this._initialized) return;
|
|
33
|
+
this._initialized = !0;
|
|
34
|
+
let t = (e) => {
|
|
35
|
+
e.target instanceof HTMLInputElement && (e.target.type === "password" || e.target.closest(".password-toggle")) && this.evaluate(e.target);
|
|
36
|
+
};
|
|
37
|
+
document.addEventListener("input", t), document.addEventListener("change", t);
|
|
38
|
+
}
|
|
39
|
+
static evaluate(t) {
|
|
40
|
+
let n = this._meterOf(t);
|
|
41
|
+
if (!n) return null;
|
|
42
|
+
let r = this.score(t.value), i = this._level(r);
|
|
43
|
+
if ((n.dataset.bsStrength || null) !== i) {
|
|
44
|
+
n.dataset.bsStrength = i ?? "";
|
|
45
|
+
let t = i ? e.indexOf(i) : -1;
|
|
46
|
+
n.querySelectorAll(".strength-segment").forEach((e, n) => e.classList.toggle("active", n <= t));
|
|
47
|
+
let a = n.parentElement.querySelector(":scope > .strength-text");
|
|
48
|
+
a && (a.textContent = i ? this.options.messages[i] : "", a.dataset.bsStrength = i ?? ""), n.dispatchEvent(new CustomEvent("strengthChange", {
|
|
49
|
+
bubbles: !0,
|
|
50
|
+
detail: {
|
|
51
|
+
strength: i,
|
|
52
|
+
score: r
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
return i;
|
|
57
|
+
}
|
|
58
|
+
static score(e) {
|
|
59
|
+
if (!e) return 0;
|
|
60
|
+
if (typeof this.options.scorer == "function") return this.options.scorer(e);
|
|
61
|
+
let { minLength: n } = this.options;
|
|
62
|
+
return [
|
|
63
|
+
e.length >= n,
|
|
64
|
+
e.length >= n + 4,
|
|
65
|
+
/[a-z]/.test(e),
|
|
66
|
+
/[A-Z]/.test(e),
|
|
67
|
+
/\d/.test(e),
|
|
68
|
+
t.test(e),
|
|
69
|
+
RegExp(`${t.source}.*${t.source}`).test(e),
|
|
70
|
+
e.length >= 16
|
|
71
|
+
].filter(Boolean).length;
|
|
72
|
+
}
|
|
73
|
+
static _level(e) {
|
|
74
|
+
if (e === 0) return null;
|
|
75
|
+
let [t, n, r] = this.options.thresholds;
|
|
76
|
+
return e <= t ? "weak" : e <= n ? "fair" : e <= r ? "good" : "strong";
|
|
77
|
+
}
|
|
78
|
+
static _meterOf(e) {
|
|
79
|
+
let t = e.parentElement;
|
|
80
|
+
for (let e = 0; t && e < 3; e++, t = t.parentElement) {
|
|
81
|
+
let e = t.querySelector(":scope > [data-bs-strength]");
|
|
82
|
+
if (e) return e;
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
export { n as Strength };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// src/js/theme-switcher.js
|
|
2
|
+
var e = /* @__PURE__ */ new WeakMap(), t = [
|
|
3
|
+
"light",
|
|
4
|
+
"dark",
|
|
5
|
+
"auto"
|
|
6
|
+
], n = class {
|
|
7
|
+
constructor(e = {}) {
|
|
8
|
+
this.options = {
|
|
9
|
+
selector: "[data-theme-switcher]",
|
|
10
|
+
choiceSelector: "[data-theme-value]",
|
|
11
|
+
storageKey: "bootstrap-theme",
|
|
12
|
+
defaultTheme: "auto",
|
|
13
|
+
lightIcon: "",
|
|
14
|
+
darkIcon: "",
|
|
15
|
+
lightLabel: "Light mode",
|
|
16
|
+
darkLabel: "Dark mode",
|
|
17
|
+
autoLightTitle: "System theme: light",
|
|
18
|
+
autoDarkTitle: "System theme: dark",
|
|
19
|
+
...e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
initialize(t = document) {
|
|
23
|
+
this.root = t, this.documentElement = document.documentElement, this.switchers = [...t.querySelectorAll(this.options.selector)], this.choices = [...t.querySelectorAll(this.options.choiceSelector)], this.media = window.matchMedia("(prefers-color-scheme: dark)"), this.setTheme(this.getInitialTheme(), !1);
|
|
24
|
+
let n = (t, n) => {
|
|
25
|
+
let r = e.get(t);
|
|
26
|
+
r && t.removeEventListener("click", r), t.addEventListener("click", n), e.set(t, n);
|
|
27
|
+
};
|
|
28
|
+
for (let e of this.switchers) n(e, () => this.toggle());
|
|
29
|
+
for (let e of this.choices) n(e, () => this.setTheme(e.dataset.themeValue));
|
|
30
|
+
return this.mediaHandler || (this.mediaHandler = () => {
|
|
31
|
+
this.mode === "auto" ? this.setTheme("auto", !1) : this.updateChoices();
|
|
32
|
+
}, this.media.addEventListener("change", this.mediaHandler), window.addEventListener("storage", (e) => {
|
|
33
|
+
(e.key === this.options.storageKey || e.key === null) && this.setTheme(this.getInitialTheme(), !1);
|
|
34
|
+
})), this;
|
|
35
|
+
}
|
|
36
|
+
getInitialTheme() {
|
|
37
|
+
let e;
|
|
38
|
+
try {
|
|
39
|
+
e = localStorage.getItem(this.options.storageKey);
|
|
40
|
+
} catch {}
|
|
41
|
+
return t.includes(e) ? e : this.options.defaultTheme;
|
|
42
|
+
}
|
|
43
|
+
getSystemTheme() {
|
|
44
|
+
return this.media.matches ? "dark" : "light";
|
|
45
|
+
}
|
|
46
|
+
getCurrentTheme() {
|
|
47
|
+
return this.documentElement.getAttribute("data-bs-theme") === "dark" ? "dark" : "light";
|
|
48
|
+
}
|
|
49
|
+
getNextTheme() {
|
|
50
|
+
return this.getCurrentTheme() === "dark" ? "light" : "dark";
|
|
51
|
+
}
|
|
52
|
+
toggle() {
|
|
53
|
+
let e = this.getNextTheme();
|
|
54
|
+
this.setTheme(e === this.getSystemTheme() ? "auto" : e);
|
|
55
|
+
}
|
|
56
|
+
setTheme(e, n = !0) {
|
|
57
|
+
this.mode = t.includes(e) ? e : "auto";
|
|
58
|
+
let r = this.mode === "auto" ? this.getSystemTheme() : this.mode;
|
|
59
|
+
if (this.documentElement.setAttribute("data-bs-theme", r), n) try {
|
|
60
|
+
localStorage.setItem(this.options.storageKey, this.mode);
|
|
61
|
+
} catch {}
|
|
62
|
+
this.updateSwitchers(r), this.updateChoices(), this.dispatchChange(r);
|
|
63
|
+
}
|
|
64
|
+
updateChoices() {
|
|
65
|
+
for (let e of this.choices) {
|
|
66
|
+
let t = e.dataset.themeValue === this.mode;
|
|
67
|
+
if (e.classList.toggle("active", t), e.setAttribute("aria-pressed", String(t)), e.dataset.themeValue === "auto") {
|
|
68
|
+
let t = this.getSystemTheme();
|
|
69
|
+
e.dataset.themeSystem = t, e.title = this.getOption(e, t === "dark" ? "autoDarkTitle" : "autoLightTitle");
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
updateSwitchers(e) {
|
|
74
|
+
let t = e === "dark" ? "light" : "dark";
|
|
75
|
+
for (let n of this.switchers) n.setAttribute("aria-pressed", String(e === "dark")), n.dataset.theme = e, this.updateIcon(n, t), this.updateLabel(n, t);
|
|
76
|
+
}
|
|
77
|
+
updateIcon(e, t) {
|
|
78
|
+
let n = e.querySelector("[data-theme-switcher-icon]");
|
|
79
|
+
if (!n) return;
|
|
80
|
+
let r = t === "light" ? this.getOption(e, "lightIcon") : this.getOption(e, "darkIcon");
|
|
81
|
+
r && (n.className = r);
|
|
82
|
+
}
|
|
83
|
+
updateLabel(e, t) {
|
|
84
|
+
let n = e.querySelector("[data-theme-switcher-label]");
|
|
85
|
+
n && (n.textContent = t === "light" ? this.getOption(e, "lightLabel") : this.getOption(e, "darkLabel"));
|
|
86
|
+
}
|
|
87
|
+
getOption(e, t) {
|
|
88
|
+
let n = `theme${t.charAt(0).toUpperCase()}${t.slice(1)}`;
|
|
89
|
+
return e.dataset[n] || e.dataset[t] || this.options[t];
|
|
90
|
+
}
|
|
91
|
+
dispatchChange(e) {
|
|
92
|
+
window.dispatchEvent(new CustomEvent("theme-switcher:change", { detail: {
|
|
93
|
+
theme: e,
|
|
94
|
+
mode: this.mode
|
|
95
|
+
} }));
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export { n as ThemeSwitcher };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/js/tooltip.js
|
|
2
|
+
var e = class {
|
|
3
|
+
static _initialized = !1;
|
|
4
|
+
static init() {
|
|
5
|
+
if (this._initialized) return;
|
|
6
|
+
this._initialized = !0, document.addEventListener("keydown", (e) => {
|
|
7
|
+
if (e.key !== "Escape") return;
|
|
8
|
+
let t = document.querySelectorAll("[data-tooltip]:is(:hover, :focus-visible):not([aria-expanded=\"true\"], [data-tooltip-hidden])");
|
|
9
|
+
t.length && (t.forEach((e) => e.setAttribute("data-tooltip-hidden", "")), e.preventDefault(), e.stopPropagation());
|
|
10
|
+
}, !0);
|
|
11
|
+
let e = () => setTimeout(() => {
|
|
12
|
+
document.querySelectorAll("[data-tooltip-hidden]:not(:hover, :focus-visible)").forEach((e) => e.removeAttribute("data-tooltip-hidden"));
|
|
13
|
+
});
|
|
14
|
+
document.addEventListener("mouseout", e, !0), document.addEventListener("focusout", e, !0);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export { e as CssTooltip };
|