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