haori-bootstrap 0.3.2 → 0.4.0
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.ja.md +22 -4
- package/README.md +23 -5
- package/dist/collapse_persist.d.ts +26 -0
- package/dist/haori-bootstrap.iife.js +2 -2
- package/dist/haori-bootstrap.iife.js.map +1 -1
- package/dist/haori-bootstrap.js +283 -218
- package/dist/haori-bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/haori-bootstrap.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
function
|
|
1
|
+
function ee(e) {
|
|
2
2
|
return typeof e == "function";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function te(e) {
|
|
5
|
+
return ee(e?.Modal) ? e?.Modal : void 0;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function oe(e) {
|
|
8
|
+
return ee(e?.Toast) ? e?.Toast : void 0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return !!
|
|
10
|
+
function I(e) {
|
|
11
|
+
return !!te(e);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return !!
|
|
13
|
+
function ve(e) {
|
|
14
|
+
return !!oe(e);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const n =
|
|
16
|
+
function x(e, t, o) {
|
|
17
|
+
const n = te(o);
|
|
18
18
|
if (n)
|
|
19
19
|
return typeof n.getOrCreateInstance == "function" ? n.getOrCreateInstance(e, t) : new n(e, t);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const n =
|
|
21
|
+
function Te(e, t, o) {
|
|
22
|
+
const n = oe(o);
|
|
23
23
|
if (n)
|
|
24
24
|
return typeof n.getOrCreateInstance == "function" ? n.getOrCreateInstance(e, t) : new n(e, t);
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
let
|
|
28
|
-
function
|
|
26
|
+
const Ae = "data-haori-bootstrap-dialog", w = "data-haori-bootstrap-action", ge = "data-haori-bootstrap-dialog-title";
|
|
27
|
+
let Ce = 0;
|
|
28
|
+
function ne() {
|
|
29
29
|
return {
|
|
30
30
|
backdrop: "static",
|
|
31
31
|
keyboard: !1
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
function
|
|
34
|
+
function re(e, t) {
|
|
35
35
|
if (t.dialogContainerSelector) {
|
|
36
36
|
const o = e.querySelector(
|
|
37
37
|
t.dialogContainerSelector
|
|
@@ -41,17 +41,17 @@ function X(e, t) {
|
|
|
41
41
|
}
|
|
42
42
|
return e.body;
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function se(e, t, o, n) {
|
|
45
45
|
const r = e.createElement("div");
|
|
46
|
-
r.className = "modal fade", r.tabIndex = -1, r.setAttribute(
|
|
47
|
-
const
|
|
48
|
-
|
|
46
|
+
r.className = "modal fade", r.tabIndex = -1, r.setAttribute(Ae, "true"), r.setAttribute("aria-hidden", "true");
|
|
47
|
+
const s = e.createElement("div");
|
|
48
|
+
s.className = "modal-dialog modal-dialog-centered";
|
|
49
49
|
const c = e.createElement("div");
|
|
50
50
|
if (c.className = "modal-content", n) {
|
|
51
|
-
const u = `haori-dialog-title-${++
|
|
51
|
+
const u = `haori-dialog-title-${++Ce}`, p = e.createElement("div");
|
|
52
52
|
p.className = "modal-header";
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const C = e.createElement("h5");
|
|
54
|
+
C.className = "modal-title", C.id = u, C.setAttribute(ge, "true"), C.textContent = n, p.appendChild(C), c.appendChild(p), r.setAttribute("aria-labelledby", u);
|
|
55
55
|
}
|
|
56
56
|
const a = e.createElement("div");
|
|
57
57
|
a.className = "modal-body";
|
|
@@ -63,19 +63,19 @@ function Y(e, t, o, n) {
|
|
|
63
63
|
u.type = "button", u.className = "btn btn-secondary", u.setAttribute(w, "cancel"), u.textContent = "Cancel", l.appendChild(u);
|
|
64
64
|
}
|
|
65
65
|
const m = e.createElement("button");
|
|
66
|
-
return m.type = "button", m.className = "btn btn-primary", m.setAttribute(w, "ok"), m.textContent = "OK", l.appendChild(m), c.append(a, l),
|
|
66
|
+
return m.type = "button", m.className = "btn btn-primary", m.setAttribute(w, "ok"), m.textContent = "OK", l.appendChild(m), c.append(a, l), s.appendChild(c), r.appendChild(s), r;
|
|
67
67
|
}
|
|
68
|
-
function
|
|
69
|
-
const o = globalThis.document, n =
|
|
70
|
-
|
|
71
|
-
const r =
|
|
68
|
+
function we(e, t) {
|
|
69
|
+
const o = globalThis.document, n = se(o, e, !1, t.dialogTitle);
|
|
70
|
+
re(o, t).appendChild(n);
|
|
71
|
+
const r = x(
|
|
72
72
|
n,
|
|
73
|
-
|
|
73
|
+
ne(),
|
|
74
74
|
t.bootstrap
|
|
75
75
|
);
|
|
76
|
-
return r ? new Promise((
|
|
76
|
+
return r ? new Promise((s, c) => {
|
|
77
77
|
const a = () => {
|
|
78
|
-
n.removeEventListener("hidden.bs.modal", d), n.remove(), r.dispose?.(),
|
|
78
|
+
n.removeEventListener("hidden.bs.modal", d), n.remove(), r.dispose?.(), s();
|
|
79
79
|
}, d = () => {
|
|
80
80
|
a();
|
|
81
81
|
};
|
|
@@ -93,18 +93,18 @@ function fe(e, t) {
|
|
|
93
93
|
}
|
|
94
94
|
}) : (n.remove(), Promise.reject(new Error("Bootstrap Modal is unavailable.")));
|
|
95
95
|
}
|
|
96
|
-
function
|
|
97
|
-
const o = globalThis.document, n =
|
|
98
|
-
|
|
99
|
-
const r =
|
|
96
|
+
function Se(e, t) {
|
|
97
|
+
const o = globalThis.document, n = se(o, e, !0, t.dialogTitle);
|
|
98
|
+
re(o, t).appendChild(n);
|
|
99
|
+
const r = x(
|
|
100
100
|
n,
|
|
101
|
-
|
|
101
|
+
ne(),
|
|
102
102
|
t.bootstrap
|
|
103
103
|
);
|
|
104
|
-
return r ? new Promise((
|
|
104
|
+
return r ? new Promise((s, c) => {
|
|
105
105
|
let a = !1;
|
|
106
106
|
const d = () => {
|
|
107
|
-
n.removeEventListener("hidden.bs.modal", l), n.remove(), r.dispose?.(),
|
|
107
|
+
n.removeEventListener("hidden.bs.modal", l), n.remove(), r.dispose?.(), s(a);
|
|
108
108
|
}, l = () => {
|
|
109
109
|
d();
|
|
110
110
|
}, m = n.querySelector(`[${w}="ok"]`), u = n.querySelector(
|
|
@@ -130,29 +130,29 @@ function me(e, t) {
|
|
|
130
130
|
}
|
|
131
131
|
}) : (n.remove(), Promise.reject(new Error("Bootstrap Modal is unavailable.")));
|
|
132
132
|
}
|
|
133
|
-
const T = "data-haori-bootstrap-owned", b = "data-haori-bootstrap-message-container",
|
|
134
|
-
function
|
|
133
|
+
const T = "data-haori-bootstrap-owned", b = "data-haori-bootstrap-message-container", g = "data-haori-bootstrap-invalid-target", S = "data-haori-bootstrap-valid-target";
|
|
134
|
+
function y(e) {
|
|
135
135
|
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio");
|
|
136
136
|
}
|
|
137
137
|
function v(e) {
|
|
138
138
|
return e instanceof HTMLInputElement && e.type === "radio";
|
|
139
139
|
}
|
|
140
|
-
function
|
|
140
|
+
function M(e) {
|
|
141
141
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function P(e) {
|
|
144
144
|
return Array.from(e.children).find(
|
|
145
145
|
(t) => t instanceof HTMLElement && t.getAttribute(b) === "true"
|
|
146
146
|
);
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function ie(e, t) {
|
|
149
149
|
const o = e.createElement("div");
|
|
150
150
|
return o.setAttribute(T, "true"), o.textContent = t, o;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
return
|
|
152
|
+
function ae(e) {
|
|
153
|
+
return P(e);
|
|
154
154
|
}
|
|
155
|
-
function
|
|
155
|
+
function L(e) {
|
|
156
156
|
if (e.name) {
|
|
157
157
|
const t = e.form ?? e.ownerDocument, o = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e.name) : e.name.replace(/(["\\])/g, "\\$1"), n = Array.from(
|
|
158
158
|
t.querySelectorAll(`input[type="radio"][name="${o}"]`)
|
|
@@ -162,7 +162,7 @@ function N(e) {
|
|
|
162
162
|
}
|
|
163
163
|
return [e];
|
|
164
164
|
}
|
|
165
|
-
function
|
|
165
|
+
function ye(e) {
|
|
166
166
|
const [t, ...o] = e;
|
|
167
167
|
if (!t)
|
|
168
168
|
return;
|
|
@@ -173,50 +173,50 @@ function be(e) {
|
|
|
173
173
|
n = n.parentElement;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
|
-
function
|
|
177
|
-
const o =
|
|
176
|
+
function U(e) {
|
|
177
|
+
const o = L(e).map((n) => n.closest(".form-check")).filter((n) => n instanceof HTMLElement);
|
|
178
178
|
if (o.length > 1) {
|
|
179
|
-
const n =
|
|
179
|
+
const n = ye(o);
|
|
180
180
|
if (n && !o.includes(n))
|
|
181
181
|
return n;
|
|
182
182
|
}
|
|
183
|
-
return
|
|
183
|
+
return D(e);
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function D(e) {
|
|
186
186
|
const t = e.closest(".form-check");
|
|
187
187
|
return t instanceof HTMLElement ? t : void 0;
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function ce(e) {
|
|
190
190
|
const t = e.nextElementSibling;
|
|
191
191
|
if (t instanceof HTMLElement && t.getAttribute(b) === "true")
|
|
192
192
|
return t;
|
|
193
193
|
const o = document.createElement("div");
|
|
194
194
|
return o.className = "invalid-feedback d-block", o.setAttribute(T, "true"), o.setAttribute(b, "true"), e.insertAdjacentElement("afterend", o), o;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
const t = v(e) ?
|
|
196
|
+
function Me(e) {
|
|
197
|
+
const t = v(e) ? U(e) : D(e);
|
|
198
198
|
if (!t)
|
|
199
|
-
return
|
|
200
|
-
const o =
|
|
199
|
+
return ce(e);
|
|
200
|
+
const o = P(t);
|
|
201
201
|
if (o)
|
|
202
202
|
return o;
|
|
203
203
|
const n = document.createElement("div");
|
|
204
204
|
return n.className = "invalid-feedback d-block", n.setAttribute(T, "true"), n.setAttribute(b, "true"), t.appendChild(n), n;
|
|
205
205
|
}
|
|
206
|
-
function
|
|
207
|
-
const t =
|
|
206
|
+
function Le(e) {
|
|
207
|
+
const t = ae(e);
|
|
208
208
|
if (t)
|
|
209
209
|
return t;
|
|
210
210
|
const o = document.createElement("div");
|
|
211
211
|
return o.className = "alert alert-danger", o.setAttribute("role", "alert"), o.setAttribute(T, "true"), o.setAttribute(b, "true"), e.insertAdjacentElement("afterbegin", o), o;
|
|
212
212
|
}
|
|
213
213
|
function h(e) {
|
|
214
|
-
e.getAttribute(
|
|
214
|
+
e.getAttribute(g) === "true" && (e.classList.remove("is-invalid"), e.removeAttribute(g));
|
|
215
215
|
}
|
|
216
216
|
function E(e) {
|
|
217
|
-
e.getAttribute(
|
|
217
|
+
e.getAttribute(S) === "true" && (e.classList.remove("is-valid"), e.removeAttribute(S));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function W(e) {
|
|
220
220
|
switch (e) {
|
|
221
221
|
case "success":
|
|
222
222
|
return "alert alert-success";
|
|
@@ -228,62 +228,62 @@ function q(e) {
|
|
|
228
228
|
return "alert alert-danger";
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
function
|
|
231
|
+
function k(e) {
|
|
232
232
|
return e === "success" ? "valid-feedback d-block" : "invalid-feedback d-block";
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
(v(e) ?
|
|
236
|
-
o.classList.add("is-invalid"), o.setAttribute(
|
|
234
|
+
function le(e) {
|
|
235
|
+
(v(e) ? L(e) : [e]).forEach((o) => {
|
|
236
|
+
o.classList.add("is-invalid"), o.setAttribute(g, "true");
|
|
237
237
|
});
|
|
238
238
|
}
|
|
239
|
-
function
|
|
240
|
-
(v(e) ?
|
|
239
|
+
function Ie(e) {
|
|
240
|
+
(v(e) ? L(e) : [e]).forEach((o) => {
|
|
241
241
|
h(o);
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
function
|
|
244
|
+
function ue(e, t) {
|
|
245
245
|
const o = e.nextElementSibling;
|
|
246
246
|
if (o instanceof HTMLElement && o.getAttribute(b) === "true")
|
|
247
|
-
return o.className =
|
|
247
|
+
return o.className = k(t), o;
|
|
248
248
|
const n = document.createElement("div");
|
|
249
|
-
return n.className =
|
|
249
|
+
return n.className = k(t), n.setAttribute(T, "true"), n.setAttribute(b, "true"), e.insertAdjacentElement("afterend", n), n;
|
|
250
250
|
}
|
|
251
|
-
function
|
|
252
|
-
const o = v(e) ?
|
|
251
|
+
function Ne(e, t) {
|
|
252
|
+
const o = v(e) ? U(e) : D(e);
|
|
253
253
|
if (!o)
|
|
254
|
-
return
|
|
255
|
-
const n =
|
|
254
|
+
return ue(e, t);
|
|
255
|
+
const n = P(o);
|
|
256
256
|
if (n)
|
|
257
|
-
return n.className =
|
|
257
|
+
return n.className = k(t), n;
|
|
258
258
|
const r = document.createElement("div");
|
|
259
|
-
return r.className =
|
|
259
|
+
return r.className = k(t), r.setAttribute(T, "true"), r.setAttribute(b, "true"), o.appendChild(r), r;
|
|
260
260
|
}
|
|
261
|
-
function
|
|
262
|
-
const o =
|
|
261
|
+
function ke(e, t) {
|
|
262
|
+
const o = ae(e);
|
|
263
263
|
if (o)
|
|
264
|
-
return o.className =
|
|
264
|
+
return o.className = W(t), o;
|
|
265
265
|
const n = document.createElement("div");
|
|
266
|
-
return n.className =
|
|
267
|
-
}
|
|
268
|
-
function
|
|
269
|
-
return (
|
|
270
|
-
}
|
|
271
|
-
function
|
|
272
|
-
if ((
|
|
273
|
-
const r = v(e) ?
|
|
274
|
-
o === "success" ? r.forEach((
|
|
275
|
-
h(
|
|
276
|
-
}) : !o || o === "error" ? (r.forEach((
|
|
277
|
-
E(
|
|
266
|
+
return n.className = W(t), n.setAttribute("role", "alert"), n.setAttribute(T, "true"), n.setAttribute(b, "true"), e.insertAdjacentElement("afterbegin", n), n;
|
|
267
|
+
}
|
|
268
|
+
function He(e, t) {
|
|
269
|
+
return (y(e) ? Me(e) : M(e) ? ce(e) : Le(e)).appendChild(ie(document, t)), y(e) ? le(e) : M(e) && (e.classList.add("is-invalid"), e.setAttribute(g, "true")), Promise.resolve();
|
|
270
|
+
}
|
|
271
|
+
function Be(e, t, o) {
|
|
272
|
+
if ((y(e) ? Ne(e, o) : M(e) ? ue(e, o) : ke(e, o)).appendChild(ie(document, t)), y(e)) {
|
|
273
|
+
const r = v(e) ? L(e) : [e];
|
|
274
|
+
o === "success" ? r.forEach((s) => {
|
|
275
|
+
h(s), s.classList.add("is-valid"), s.setAttribute(S, "true");
|
|
276
|
+
}) : !o || o === "error" ? (r.forEach((s) => E(s)), le(e)) : r.forEach((s) => {
|
|
277
|
+
E(s), h(s);
|
|
278
278
|
});
|
|
279
|
-
} else
|
|
279
|
+
} else M(e) && (o === "success" ? (h(e), e.classList.add("is-valid"), e.setAttribute(S, "true")) : !o || o === "error" ? (E(e), e.classList.add("is-invalid"), e.setAttribute(g, "true")) : (E(e), h(e)));
|
|
280
280
|
return Promise.resolve();
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
if (
|
|
284
|
-
const r = v(e) ?
|
|
285
|
-
(r ?
|
|
286
|
-
} else if (
|
|
282
|
+
function Re(e) {
|
|
283
|
+
if (y(e)) {
|
|
284
|
+
const r = v(e) ? U(e) : D(e);
|
|
285
|
+
(r ? P(r) : void 0)?.remove(), Ie(e), (v(e) ? L(e) : [e]).forEach((a) => E(a));
|
|
286
|
+
} else if (M(e)) {
|
|
287
287
|
const r = e.nextElementSibling;
|
|
288
288
|
r instanceof HTMLElement && r.getAttribute(b) === "true" && r.remove(), h(e), E(e);
|
|
289
289
|
}
|
|
@@ -292,29 +292,29 @@ function ge(e) {
|
|
|
292
292
|
).forEach((r) => {
|
|
293
293
|
r.remove();
|
|
294
294
|
}), e.querySelectorAll(
|
|
295
|
-
`[${
|
|
295
|
+
`[${g}="true"]`
|
|
296
296
|
).forEach((r) => {
|
|
297
297
|
h(r);
|
|
298
298
|
}), e.querySelectorAll(
|
|
299
|
-
`[${
|
|
299
|
+
`[${S}="true"]`
|
|
300
300
|
).forEach((r) => {
|
|
301
301
|
E(r);
|
|
302
302
|
}), Promise.resolve();
|
|
303
303
|
}
|
|
304
|
-
function
|
|
304
|
+
function de(e) {
|
|
305
305
|
e.classList.contains("modal") || e.classList.add("modal"), e.tabIndex < 0 && (e.tabIndex = -1), e.hasAttribute("aria-hidden") || e.setAttribute("aria-hidden", "true");
|
|
306
306
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
309
|
-
const o =
|
|
307
|
+
function xe(e, t) {
|
|
308
|
+
de(e);
|
|
309
|
+
const o = x(e, void 0, t.bootstrap);
|
|
310
310
|
return o ? (o.show(), Promise.resolve()) : Promise.reject(new Error("Bootstrap Modal is unavailable."));
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
|
|
314
|
-
const o =
|
|
312
|
+
function Pe(e, t) {
|
|
313
|
+
de(e);
|
|
314
|
+
const o = x(e, void 0, t.bootstrap);
|
|
315
315
|
return o ? (o.hide(), Promise.resolve()) : Promise.reject(new Error("Bootstrap Modal is unavailable."));
|
|
316
316
|
}
|
|
317
|
-
const
|
|
317
|
+
const G = "data-haori-bootstrap-toast-container", De = "data-haori-bootstrap-toast", _e = "data-haori-bootstrap-toast-accent", $e = "data-haori-bootstrap-toast-dismiss", V = {
|
|
318
318
|
"top-start": "top-0 start-0",
|
|
319
319
|
"top-center": "top-0 start-50 translate-middle-x",
|
|
320
320
|
"top-end": "top-0 end-0",
|
|
@@ -322,7 +322,7 @@ const F = "data-haori-bootstrap-toast-container", Se = "data-haori-bootstrap-toa
|
|
|
322
322
|
"bottom-center": "bottom-0 start-50 translate-middle-x",
|
|
323
323
|
"bottom-end": "bottom-0 end-0"
|
|
324
324
|
};
|
|
325
|
-
function
|
|
325
|
+
function qe(e) {
|
|
326
326
|
switch (e) {
|
|
327
327
|
case "success":
|
|
328
328
|
return { accentClassName: "bg-success" };
|
|
@@ -334,7 +334,7 @@ function ye(e) {
|
|
|
334
334
|
return { accentClassName: "bg-info" };
|
|
335
335
|
}
|
|
336
336
|
}
|
|
337
|
-
function
|
|
337
|
+
function Ue(e, t) {
|
|
338
338
|
if (t.toastContainerSelector) {
|
|
339
339
|
const o = e.querySelector(t.toastContainerSelector);
|
|
340
340
|
if (o)
|
|
@@ -342,98 +342,98 @@ function ke(e, t) {
|
|
|
342
342
|
}
|
|
343
343
|
return e.body;
|
|
344
344
|
}
|
|
345
|
-
function
|
|
346
|
-
const o =
|
|
347
|
-
`[${
|
|
345
|
+
function Oe(e, t) {
|
|
346
|
+
const o = Ue(e, t), n = V[t.toastPosition ?? "bottom-end"], r = o.querySelector(
|
|
347
|
+
`[${G}="true"]`
|
|
348
348
|
);
|
|
349
349
|
if (r) {
|
|
350
|
-
const c = Object.values(
|
|
350
|
+
const c = Object.values(V).flatMap((a) => a.split(" "));
|
|
351
351
|
return r.classList.remove(...c), r.classList.add(...n.split(" ")), r;
|
|
352
352
|
}
|
|
353
|
-
const
|
|
354
|
-
return
|
|
353
|
+
const s = e.createElement("div");
|
|
354
|
+
return s.className = `toast-container position-fixed ${n} p-3`, s.setAttribute(G, "true"), o.appendChild(s), s;
|
|
355
355
|
}
|
|
356
|
-
function
|
|
357
|
-
const n = globalThis.document, r =
|
|
358
|
-
|
|
356
|
+
function Fe(e, t, o) {
|
|
357
|
+
const n = globalThis.document, r = qe(t), s = n.createElement("div");
|
|
358
|
+
s.className = "toast border bg-body text-body shadow-sm", s.setAttribute("role", "status"), s.setAttribute("aria-live", "polite"), s.setAttribute("aria-atomic", "true"), s.setAttribute(De, "true");
|
|
359
359
|
const c = n.createElement("div");
|
|
360
360
|
c.className = "d-flex align-items-stretch";
|
|
361
361
|
const a = n.createElement("div");
|
|
362
|
-
a.className = `flex-shrink-0 rounded-start ${r.accentClassName}`, a.style.width = "0.375rem", a.setAttribute(
|
|
362
|
+
a.className = `flex-shrink-0 rounded-start ${r.accentClassName}`, a.style.width = "0.375rem", a.setAttribute(_e, "true");
|
|
363
363
|
const d = n.createElement("div");
|
|
364
364
|
d.className = "toast-body", d.style.whiteSpace = "pre-line", d.textContent = e;
|
|
365
365
|
const l = n.createElement("button");
|
|
366
|
-
l.type = "button", l.className = "btn-close me-2 m-auto flex-shrink-0", l.setAttribute("aria-label", "Close"), l.setAttribute(
|
|
367
|
-
const m = o.toastDelay !== void 0 ? { delay: o.toastDelay } : void 0, u =
|
|
366
|
+
l.type = "button", l.className = "btn-close me-2 m-auto flex-shrink-0", l.setAttribute("aria-label", "Close"), l.setAttribute($e, "true"), c.appendChild(a), c.appendChild(d), c.appendChild(l), s.appendChild(c), Oe(n, o).appendChild(s);
|
|
367
|
+
const m = o.toastDelay !== void 0 ? { delay: o.toastDelay } : void 0, u = Te(s, m, o.bootstrap);
|
|
368
368
|
if (!u)
|
|
369
|
-
return
|
|
369
|
+
return s.remove(), Promise.reject(new Error("Bootstrap Toast is unavailable."));
|
|
370
370
|
l.addEventListener("click", () => {
|
|
371
371
|
u.hide?.();
|
|
372
|
-
}),
|
|
372
|
+
}), s.addEventListener(
|
|
373
373
|
"hidden.bs.toast",
|
|
374
374
|
() => {
|
|
375
|
-
|
|
375
|
+
s.remove(), u.dispose?.();
|
|
376
376
|
},
|
|
377
377
|
{ once: !0 }
|
|
378
378
|
);
|
|
379
379
|
try {
|
|
380
380
|
return u.show(), Promise.resolve();
|
|
381
381
|
} catch (p) {
|
|
382
|
-
return
|
|
382
|
+
return s.remove(), u.dispose?.(), Promise.reject(p);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
const
|
|
385
|
+
const ze = {
|
|
386
386
|
options: {
|
|
387
387
|
fallbackToNative: !0
|
|
388
388
|
}
|
|
389
389
|
};
|
|
390
|
-
let f =
|
|
390
|
+
let f = ze;
|
|
391
391
|
function A(e) {
|
|
392
392
|
return e.replace(/\\n/g, `
|
|
393
393
|
`);
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function fe() {
|
|
396
396
|
return globalThis.window;
|
|
397
397
|
}
|
|
398
|
-
function
|
|
398
|
+
function O(e) {
|
|
399
399
|
return Promise.resolve(e).then(() => {
|
|
400
400
|
});
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function _(e) {
|
|
403
403
|
const t = f.originalHaori?.[e];
|
|
404
404
|
return typeof t == "function" ? t : void 0;
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function $(e) {
|
|
407
407
|
console.warn(`[haori-bootstrap] ${e} skipped because Bootstrap support is unavailable.`);
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
const t = A(e), o =
|
|
409
|
+
function j(e) {
|
|
410
|
+
const t = A(e), o = _("dialog");
|
|
411
411
|
if (o)
|
|
412
|
-
return
|
|
413
|
-
const n =
|
|
414
|
-
return f.options.fallbackToNative && typeof n?.alert == "function" ? (n.alert(t), Promise.resolve()) : (
|
|
412
|
+
return O(o(t));
|
|
413
|
+
const n = fe();
|
|
414
|
+
return f.options.fallbackToNative && typeof n?.alert == "function" ? (n.alert(t), Promise.resolve()) : ($("dialog"), Promise.resolve());
|
|
415
415
|
}
|
|
416
|
-
function
|
|
417
|
-
const t = A(e), o =
|
|
416
|
+
function K(e) {
|
|
417
|
+
const t = A(e), o = _("confirm");
|
|
418
418
|
if (o)
|
|
419
419
|
return Promise.resolve(o(t)).then(
|
|
420
420
|
(r) => !!r
|
|
421
421
|
);
|
|
422
|
-
const n =
|
|
423
|
-
return f.options.fallbackToNative && typeof n?.confirm == "function" ? Promise.resolve(n.confirm(t)) : (
|
|
422
|
+
const n = fe();
|
|
423
|
+
return f.options.fallbackToNative && typeof n?.confirm == "function" ? Promise.resolve(n.confirm(t)) : ($("confirm"), Promise.resolve(!1));
|
|
424
424
|
}
|
|
425
|
-
function
|
|
426
|
-
const o = A(e), n =
|
|
427
|
-
return n ?
|
|
425
|
+
function J(e, t) {
|
|
426
|
+
const o = A(e), n = _("toast");
|
|
427
|
+
return n ? O(n(o, t)) : ($("toast"), Promise.resolve());
|
|
428
428
|
}
|
|
429
|
-
function
|
|
430
|
-
const o =
|
|
431
|
-
return o ?
|
|
429
|
+
function N(e, t) {
|
|
430
|
+
const o = _(e);
|
|
431
|
+
return o ? O(o(t)) : ($(e), Promise.resolve());
|
|
432
432
|
}
|
|
433
|
-
function
|
|
433
|
+
function We(e) {
|
|
434
434
|
f = e;
|
|
435
435
|
}
|
|
436
|
-
class
|
|
436
|
+
class Ge {
|
|
437
437
|
/**
|
|
438
438
|
* 情報表示ダイアログを表示する。
|
|
439
439
|
*
|
|
@@ -442,7 +442,7 @@ class Re {
|
|
|
442
442
|
*/
|
|
443
443
|
static dialog(t) {
|
|
444
444
|
const o = A(t);
|
|
445
|
-
return
|
|
445
|
+
return I(f.options.bootstrap) ? we(o, f.options).catch(() => j(o)) : j(o);
|
|
446
446
|
}
|
|
447
447
|
/**
|
|
448
448
|
* 確認ダイアログを表示する。
|
|
@@ -452,7 +452,7 @@ class Re {
|
|
|
452
452
|
*/
|
|
453
453
|
static confirm(t) {
|
|
454
454
|
const o = A(t);
|
|
455
|
-
return
|
|
455
|
+
return I(f.options.bootstrap) ? Se(o, f.options).catch(() => K(o)) : K(o);
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
458
|
* トースト通知を表示する。
|
|
@@ -463,9 +463,9 @@ class Re {
|
|
|
463
463
|
*/
|
|
464
464
|
static toast(t, o) {
|
|
465
465
|
const n = A(t);
|
|
466
|
-
return
|
|
467
|
-
() =>
|
|
468
|
-
) :
|
|
466
|
+
return ve(f.options.bootstrap) ? Fe(n, o, f.options).catch(
|
|
467
|
+
() => J(n, o)
|
|
468
|
+
) : J(n, o);
|
|
469
469
|
}
|
|
470
470
|
/**
|
|
471
471
|
* 任意のダイアログ要素を開く。
|
|
@@ -474,9 +474,9 @@ class Re {
|
|
|
474
474
|
* @return 完了時に解決される Promise。
|
|
475
475
|
*/
|
|
476
476
|
static openDialog(t) {
|
|
477
|
-
return
|
|
478
|
-
() =>
|
|
479
|
-
) :
|
|
477
|
+
return I(f.options.bootstrap) ? xe(t, f.options).catch(
|
|
478
|
+
() => N("openDialog", t)
|
|
479
|
+
) : N("openDialog", t);
|
|
480
480
|
}
|
|
481
481
|
/**
|
|
482
482
|
* 任意のダイアログ要素を閉じる。
|
|
@@ -485,9 +485,9 @@ class Re {
|
|
|
485
485
|
* @return 完了時に解決される Promise。
|
|
486
486
|
*/
|
|
487
487
|
static closeDialog(t) {
|
|
488
|
-
return
|
|
489
|
-
() =>
|
|
490
|
-
) :
|
|
488
|
+
return I(f.options.bootstrap) ? Pe(t, f.options).catch(
|
|
489
|
+
() => N("closeDialog", t)
|
|
490
|
+
) : N("closeDialog", t);
|
|
491
491
|
}
|
|
492
492
|
/**
|
|
493
493
|
* 管理対象のエラーメッセージを追加する。
|
|
@@ -497,7 +497,7 @@ class Re {
|
|
|
497
497
|
* @return 完了時に解決される Promise。
|
|
498
498
|
*/
|
|
499
499
|
static addErrorMessage(t, o) {
|
|
500
|
-
return
|
|
500
|
+
return He(t, o);
|
|
501
501
|
}
|
|
502
502
|
/**
|
|
503
503
|
* 管理対象のメッセージをレベル付きで追加する。
|
|
@@ -508,7 +508,7 @@ class Re {
|
|
|
508
508
|
* @return 完了時に解決される Promise。
|
|
509
509
|
*/
|
|
510
510
|
static addMessage(t, o, n) {
|
|
511
|
-
return
|
|
511
|
+
return Be(t, o, n);
|
|
512
512
|
}
|
|
513
513
|
/**
|
|
514
514
|
* 管理対象のメッセージを削除する。
|
|
@@ -517,12 +517,77 @@ class Re {
|
|
|
517
517
|
* @return 完了時に解決される Promise。
|
|
518
518
|
*/
|
|
519
519
|
static clearMessages(t) {
|
|
520
|
-
return
|
|
520
|
+
return Re(t);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const Ve = "haori-bootstrap:collapse:", H = "data-haori-bootstrap-persist";
|
|
524
|
+
let B = !1, R, q;
|
|
525
|
+
function me(e) {
|
|
526
|
+
return Ve + e;
|
|
527
|
+
}
|
|
528
|
+
function je(e) {
|
|
529
|
+
try {
|
|
530
|
+
const t = window.sessionStorage.getItem(me(e));
|
|
531
|
+
return t === "shown" || t === "hidden" ? t : void 0;
|
|
532
|
+
} catch {
|
|
533
|
+
return;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function Ke(e, t) {
|
|
537
|
+
try {
|
|
538
|
+
window.sessionStorage.setItem(me(e), t);
|
|
539
|
+
} catch {
|
|
521
540
|
}
|
|
522
541
|
}
|
|
523
|
-
|
|
542
|
+
function X(e, t) {
|
|
543
|
+
const o = e.id, n = [`[data-bs-toggle="collapse"][data-bs-target="#${o}"]`];
|
|
544
|
+
if (o && n.push(`[data-bs-toggle="collapse"][href="#${o}"]`), !o)
|
|
545
|
+
return;
|
|
546
|
+
e.ownerDocument.querySelectorAll(n.join(",")).forEach((s) => {
|
|
547
|
+
s.setAttribute("aria-expanded", t ? "true" : "false"), s.classList.toggle("collapsed", !t);
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function Q(e) {
|
|
551
|
+
const t = e.getAttribute(H);
|
|
552
|
+
if (!t)
|
|
553
|
+
return;
|
|
554
|
+
const o = je(t);
|
|
555
|
+
if (!o)
|
|
556
|
+
return;
|
|
557
|
+
const n = e.classList.contains("show");
|
|
558
|
+
o === "shown" && !n ? (e.classList.add("show"), X(e, !0)) : o === "hidden" && n && (e.classList.remove("show"), X(e, !1));
|
|
559
|
+
}
|
|
560
|
+
function Y(e) {
|
|
561
|
+
e instanceof HTMLElement && e.hasAttribute(H) && Q(e), e.querySelectorAll(`[${H}]`).forEach(Q);
|
|
562
|
+
}
|
|
563
|
+
function be(e, t) {
|
|
564
|
+
const o = e.target;
|
|
565
|
+
if (!(o instanceof HTMLElement))
|
|
566
|
+
return;
|
|
567
|
+
const n = o.getAttribute(H);
|
|
568
|
+
n && Ke(n, t);
|
|
569
|
+
}
|
|
570
|
+
const pe = (e) => be(e, "shown"), he = (e) => be(e, "hidden");
|
|
571
|
+
function Je(e = document) {
|
|
572
|
+
if (B)
|
|
573
|
+
return;
|
|
574
|
+
B = !0, q = e, e.addEventListener("shown.bs.collapse", pe), e.addEventListener("hidden.bs.collapse", he);
|
|
575
|
+
const t = () => {
|
|
576
|
+
Y(e), R = new MutationObserver((o) => {
|
|
577
|
+
for (const n of o)
|
|
578
|
+
n.addedNodes.forEach((r) => {
|
|
579
|
+
r instanceof HTMLElement && Y(r);
|
|
580
|
+
});
|
|
581
|
+
}), e.body && R.observe(e.body, { childList: !0, subtree: !0 });
|
|
582
|
+
};
|
|
583
|
+
e.body ? t() : e.addEventListener("DOMContentLoaded", t, { once: !0 });
|
|
584
|
+
}
|
|
585
|
+
function Xe(e = q ?? document) {
|
|
586
|
+
B && (B = !1, e.removeEventListener("shown.bs.collapse", pe), e.removeEventListener("hidden.bs.collapse", he), R?.disconnect(), R = void 0, q = void 0);
|
|
587
|
+
}
|
|
588
|
+
const F = {
|
|
524
589
|
fallbackToNative: !0
|
|
525
|
-
},
|
|
590
|
+
}, Z = /* @__PURE__ */ new Set([
|
|
526
591
|
"dialog",
|
|
527
592
|
"confirm",
|
|
528
593
|
"toast",
|
|
@@ -532,98 +597,98 @@ const $ = {
|
|
|
532
597
|
"addMessage",
|
|
533
598
|
"clearMessages"
|
|
534
599
|
]);
|
|
535
|
-
function
|
|
536
|
-
const t =
|
|
600
|
+
function Qe(e) {
|
|
601
|
+
const t = Ge;
|
|
537
602
|
return new Proxy(e, {
|
|
538
603
|
get(o, n, r) {
|
|
539
|
-
return typeof n == "string" &&
|
|
604
|
+
return typeof n == "string" && Z.has(n) ? t[n] : Reflect.get(o, n, r);
|
|
540
605
|
},
|
|
541
606
|
has(o, n) {
|
|
542
|
-
return typeof n == "string" &&
|
|
607
|
+
return typeof n == "string" && Z.has(n) ? !0 : Reflect.has(o, n);
|
|
543
608
|
}
|
|
544
609
|
});
|
|
545
610
|
}
|
|
546
|
-
const
|
|
611
|
+
const i = {
|
|
547
612
|
installed: !1,
|
|
548
|
-
options:
|
|
613
|
+
options: F
|
|
549
614
|
};
|
|
550
|
-
function
|
|
615
|
+
function z() {
|
|
551
616
|
return globalThis.window;
|
|
552
617
|
}
|
|
553
|
-
function
|
|
618
|
+
function Ye(e, t) {
|
|
554
619
|
return {
|
|
555
620
|
bootstrap: e.bootstrap ?? t?.bootstrap,
|
|
556
|
-
fallbackToNative: e.fallbackToNative ??
|
|
557
|
-
runtime: e.runtime ??
|
|
558
|
-
toastContainerSelector: e.toastContainerSelector ??
|
|
559
|
-
dialogContainerSelector: e.dialogContainerSelector ??
|
|
560
|
-
dialogTitle: e.dialogTitle ??
|
|
561
|
-
toastPosition: e.toastPosition ??
|
|
562
|
-
toastDelay: e.toastDelay ??
|
|
621
|
+
fallbackToNative: e.fallbackToNative ?? F.fallbackToNative,
|
|
622
|
+
runtime: e.runtime ?? i.options.runtime ?? t?.Haori?.runtime,
|
|
623
|
+
toastContainerSelector: e.toastContainerSelector ?? i.options.toastContainerSelector,
|
|
624
|
+
dialogContainerSelector: e.dialogContainerSelector ?? i.options.dialogContainerSelector,
|
|
625
|
+
dialogTitle: e.dialogTitle ?? i.options.dialogTitle,
|
|
626
|
+
toastPosition: e.toastPosition ?? i.options.toastPosition,
|
|
627
|
+
toastDelay: e.toastDelay ?? i.options.toastDelay
|
|
563
628
|
};
|
|
564
629
|
}
|
|
565
|
-
function
|
|
630
|
+
function Ze(e = z()) {
|
|
566
631
|
return !!(e?.Haori && e.bootstrap);
|
|
567
632
|
}
|
|
568
|
-
function
|
|
569
|
-
const t =
|
|
633
|
+
function et(e = {}) {
|
|
634
|
+
const t = z();
|
|
570
635
|
if (!t?.Haori)
|
|
571
636
|
throw new Error("window.Haori is required before calling install().");
|
|
572
|
-
if (
|
|
573
|
-
const o =
|
|
574
|
-
typeof o.setRuntime == "function" ? o.setRuntime(
|
|
637
|
+
if (i.originalHaori || (i.originalHaori = t.Haori, i.originalRuntime = t.Haori.runtime), i.options = Ye(e, t), i.options.runtime) {
|
|
638
|
+
const o = i.originalHaori ?? t.Haori;
|
|
639
|
+
typeof o.setRuntime == "function" ? o.setRuntime(i.options.runtime) : console.warn(
|
|
575
640
|
"[haori-bootstrap] Haori.setRuntime が利用できません。runtime 設定は無視されます。"
|
|
576
641
|
);
|
|
577
642
|
}
|
|
578
|
-
|
|
579
|
-
originalHaori:
|
|
580
|
-
options:
|
|
581
|
-
}), t.Haori =
|
|
582
|
-
}
|
|
583
|
-
function
|
|
584
|
-
const e =
|
|
585
|
-
if (!e || !
|
|
643
|
+
We({
|
|
644
|
+
originalHaori: i.originalHaori,
|
|
645
|
+
options: i.options
|
|
646
|
+
}), t.Haori = Qe(i.originalHaori), Je(), i.installed = !0;
|
|
647
|
+
}
|
|
648
|
+
function st() {
|
|
649
|
+
const e = z();
|
|
650
|
+
if (!e || !i.originalHaori)
|
|
586
651
|
return;
|
|
587
|
-
const t =
|
|
588
|
-
typeof t.setRuntime == "function" ? t.setRuntime(
|
|
652
|
+
const t = i.originalHaori;
|
|
653
|
+
typeof t.setRuntime == "function" ? t.setRuntime(i.originalRuntime) : t.runtime = i.originalRuntime, e.Haori = i.originalHaori, Xe(), i.installed = !1, i.originalHaori = void 0, i.originalRuntime = void 0, i.options = F;
|
|
589
654
|
}
|
|
590
|
-
function
|
|
591
|
-
return
|
|
655
|
+
function it() {
|
|
656
|
+
return i.installed;
|
|
592
657
|
}
|
|
593
|
-
const
|
|
594
|
-
function
|
|
658
|
+
const Ee = "__haoriJsBootstrapAutoEnabled__";
|
|
659
|
+
function tt() {
|
|
595
660
|
return globalThis.window;
|
|
596
661
|
}
|
|
597
|
-
function
|
|
598
|
-
return !!e[
|
|
662
|
+
function ot(e) {
|
|
663
|
+
return !!e[Ee];
|
|
599
664
|
}
|
|
600
|
-
function
|
|
601
|
-
e[
|
|
665
|
+
function nt(e) {
|
|
666
|
+
e[Ee] = !0;
|
|
602
667
|
}
|
|
603
|
-
function
|
|
604
|
-
const e =
|
|
605
|
-
if (!(!e ||
|
|
606
|
-
if (!
|
|
668
|
+
function rt() {
|
|
669
|
+
const e = tt();
|
|
670
|
+
if (!(!e || ot(e))) {
|
|
671
|
+
if (!Ze(e)) {
|
|
607
672
|
console.warn(
|
|
608
673
|
"[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing."
|
|
609
674
|
);
|
|
610
675
|
return;
|
|
611
676
|
}
|
|
612
677
|
try {
|
|
613
|
-
|
|
678
|
+
et({ bootstrap: e.bootstrap }), nt(e);
|
|
614
679
|
} catch (t) {
|
|
615
680
|
console.warn("[haori-bootstrap] Auto-enable failed.", t);
|
|
616
681
|
}
|
|
617
682
|
}
|
|
618
683
|
}
|
|
619
|
-
|
|
620
|
-
const
|
|
684
|
+
rt();
|
|
685
|
+
const at = "0.4.0";
|
|
621
686
|
export {
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
687
|
+
Ge as BootstrapHaori,
|
|
688
|
+
Ze as hasAutoEnablePrerequisites,
|
|
689
|
+
et as install,
|
|
690
|
+
it as isInstalled,
|
|
691
|
+
st as uninstall,
|
|
692
|
+
at as version
|
|
628
693
|
};
|
|
629
694
|
//# sourceMappingURL=haori-bootstrap.js.map
|