haori-bootstrap 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +13 -5
- package/README.md +16 -8
- package/dist/bootstrap_haori.d.ts +9 -0
- package/dist/bootstrap_resolver.d.ts +3 -2
- package/dist/haori-bootstrap.iife.js +2 -2
- package/dist/haori-bootstrap.iife.js.map +1 -1
- package/dist/haori-bootstrap.js +376 -277
- package/dist/haori-bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/message.d.ts +9 -0
- package/dist/types.d.ts +31 -3
- package/package.json +3 -2
package/dist/haori-bootstrap.js
CHANGED
|
@@ -1,258 +1,331 @@
|
|
|
1
|
-
function
|
|
1
|
+
function V(e) {
|
|
2
2
|
return typeof e == "function";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function j(e) {
|
|
5
|
+
return V(e?.Modal) ? e?.Modal : void 0;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function K(e) {
|
|
8
|
+
return V(e?.Toast) ? e?.Toast : void 0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return !!
|
|
10
|
+
function M(e) {
|
|
11
|
+
return !!j(e);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function se(e) {
|
|
14
|
+
return !!K(e);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const n =
|
|
16
|
+
function B(e, o, t) {
|
|
17
|
+
const n = j(t);
|
|
18
18
|
if (n)
|
|
19
|
-
return typeof n.getOrCreateInstance == "function" ? n.getOrCreateInstance(e,
|
|
19
|
+
return typeof n.getOrCreateInstance == "function" ? n.getOrCreateInstance(e, o) : new n(e, o);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
const
|
|
23
|
-
if (
|
|
24
|
-
return typeof
|
|
21
|
+
function ae(e, o, t) {
|
|
22
|
+
const n = K(t);
|
|
23
|
+
if (n)
|
|
24
|
+
return typeof n.getOrCreateInstance == "function" ? n.getOrCreateInstance(e, o) : new n(e, o);
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const ce = "data-haori-bootstrap-dialog", w = "data-haori-bootstrap-action", le = "data-haori-bootstrap-dialog-title";
|
|
27
|
+
let ue = 0;
|
|
28
|
+
function J() {
|
|
28
29
|
return {
|
|
29
|
-
backdrop: "static"
|
|
30
|
+
backdrop: "static",
|
|
31
|
+
keyboard: !1
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
|
-
function
|
|
33
|
-
if (
|
|
34
|
-
const
|
|
35
|
-
|
|
34
|
+
function Q(e, o) {
|
|
35
|
+
if (o.dialogContainerSelector) {
|
|
36
|
+
const t = e.querySelector(
|
|
37
|
+
o.dialogContainerSelector
|
|
36
38
|
);
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
39
|
+
if (t)
|
|
40
|
+
return t;
|
|
39
41
|
}
|
|
40
42
|
return e.body;
|
|
41
43
|
}
|
|
42
|
-
function
|
|
43
|
-
const n = e.createElement("div");
|
|
44
|
-
n.className = "modal fade", n.tabIndex = -1, n.setAttribute(Y, "true"), n.setAttribute("aria-hidden", "true");
|
|
44
|
+
function X(e, o, t, n) {
|
|
45
45
|
const r = e.createElement("div");
|
|
46
|
-
r.className = "modal-
|
|
46
|
+
r.className = "modal fade", r.tabIndex = -1, r.setAttribute(ce, "true"), r.setAttribute("aria-hidden", "true");
|
|
47
47
|
const i = e.createElement("div");
|
|
48
|
-
i.className = "modal-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
i.className = "modal-dialog modal-dialog-centered";
|
|
49
|
+
const c = e.createElement("div");
|
|
50
|
+
if (c.className = "modal-content", n) {
|
|
51
|
+
const u = `haori-dialog-title-${++ue}`, p = e.createElement("div");
|
|
52
|
+
p.className = "modal-header";
|
|
53
|
+
const g = e.createElement("h5");
|
|
54
|
+
g.className = "modal-title", g.id = u, g.setAttribute(le, "true"), g.textContent = n, p.appendChild(g), c.appendChild(p), r.setAttribute("aria-labelledby", u);
|
|
55
|
+
}
|
|
56
|
+
const a = e.createElement("div");
|
|
57
|
+
a.className = "modal-body";
|
|
58
|
+
const d = e.createElement("p");
|
|
59
|
+
d.className = "mb-0", d.style.whiteSpace = "pre-line", d.textContent = o, a.appendChild(d);
|
|
60
|
+
const l = e.createElement("div");
|
|
61
|
+
if (l.className = "modal-footer", t) {
|
|
62
|
+
const u = e.createElement("button");
|
|
63
|
+
u.type = "button", u.className = "btn btn-secondary", u.setAttribute(w, "cancel"), u.textContent = "Cancel", l.appendChild(u);
|
|
57
64
|
}
|
|
58
|
-
const
|
|
59
|
-
return
|
|
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), i.appendChild(c), r.appendChild(i), r;
|
|
60
67
|
}
|
|
61
|
-
function
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const r =
|
|
68
|
+
function de(e, o) {
|
|
69
|
+
const t = globalThis.document, n = X(t, e, !1, o.dialogTitle);
|
|
70
|
+
Q(t, o).appendChild(n);
|
|
71
|
+
const r = B(
|
|
65
72
|
n,
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
J(),
|
|
74
|
+
o.bootstrap
|
|
68
75
|
);
|
|
69
|
-
return r ? new Promise((i,
|
|
76
|
+
return r ? new Promise((i, c) => {
|
|
70
77
|
const a = () => {
|
|
71
|
-
n.removeEventListener("hidden.bs.modal",
|
|
72
|
-
},
|
|
78
|
+
n.removeEventListener("hidden.bs.modal", d), n.remove(), r.dispose?.(), i();
|
|
79
|
+
}, d = () => {
|
|
73
80
|
a();
|
|
74
81
|
};
|
|
75
|
-
n.querySelector(`[${
|
|
82
|
+
n.querySelector(`[${w}="ok"]`)?.addEventListener(
|
|
76
83
|
"click",
|
|
77
84
|
() => {
|
|
78
85
|
r.hide();
|
|
79
86
|
},
|
|
80
87
|
{ once: !0 }
|
|
81
|
-
), n.addEventListener("hidden.bs.modal",
|
|
88
|
+
), n.addEventListener("hidden.bs.modal", d, { once: !0 });
|
|
82
89
|
try {
|
|
83
90
|
r.show();
|
|
84
|
-
} catch (
|
|
85
|
-
n.removeEventListener("hidden.bs.modal",
|
|
91
|
+
} catch (m) {
|
|
92
|
+
n.removeEventListener("hidden.bs.modal", d), n.remove(), r.dispose?.(), c(m);
|
|
86
93
|
}
|
|
87
94
|
}) : (n.remove(), Promise.reject(new Error("Bootstrap Modal is unavailable.")));
|
|
88
95
|
}
|
|
89
|
-
function
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const r =
|
|
96
|
+
function fe(e, o) {
|
|
97
|
+
const t = globalThis.document, n = X(t, e, !0, o.dialogTitle);
|
|
98
|
+
Q(t, o).appendChild(n);
|
|
99
|
+
const r = B(
|
|
93
100
|
n,
|
|
94
|
-
|
|
95
|
-
|
|
101
|
+
J(),
|
|
102
|
+
o.bootstrap
|
|
96
103
|
);
|
|
97
|
-
return r ? new Promise((i,
|
|
104
|
+
return r ? new Promise((i, c) => {
|
|
98
105
|
let a = !1;
|
|
99
|
-
const
|
|
100
|
-
n.removeEventListener("hidden.bs.modal",
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
},
|
|
104
|
-
`[${
|
|
106
|
+
const d = () => {
|
|
107
|
+
n.removeEventListener("hidden.bs.modal", l), n.remove(), r.dispose?.(), i(a);
|
|
108
|
+
}, l = () => {
|
|
109
|
+
d();
|
|
110
|
+
}, m = n.querySelector(`[${w}="ok"]`), u = n.querySelector(
|
|
111
|
+
`[${w}="cancel"]`
|
|
105
112
|
);
|
|
106
|
-
|
|
113
|
+
m?.addEventListener(
|
|
107
114
|
"click",
|
|
108
115
|
() => {
|
|
109
116
|
a = !0, r.hide();
|
|
110
117
|
},
|
|
111
118
|
{ once: !0 }
|
|
112
|
-
),
|
|
119
|
+
), u?.addEventListener(
|
|
113
120
|
"click",
|
|
114
121
|
() => {
|
|
115
122
|
a = !1, r.hide();
|
|
116
123
|
},
|
|
117
124
|
{ once: !0 }
|
|
118
|
-
), n.addEventListener("hidden.bs.modal",
|
|
125
|
+
), n.addEventListener("hidden.bs.modal", l, { once: !0 });
|
|
119
126
|
try {
|
|
120
127
|
r.show();
|
|
121
|
-
} catch (
|
|
122
|
-
n.removeEventListener("hidden.bs.modal",
|
|
128
|
+
} catch (p) {
|
|
129
|
+
n.removeEventListener("hidden.bs.modal", l), n.remove(), r.dispose?.(), c(p);
|
|
123
130
|
}
|
|
124
131
|
}) : (n.remove(), Promise.reject(new Error("Bootstrap Modal is unavailable.")));
|
|
125
132
|
}
|
|
126
|
-
const T = "data-haori-bootstrap-owned",
|
|
127
|
-
function
|
|
133
|
+
const T = "data-haori-bootstrap-owned", b = "data-haori-bootstrap-message-container", C = "data-haori-bootstrap-invalid-target", y = "data-haori-bootstrap-valid-target";
|
|
134
|
+
function S(e) {
|
|
128
135
|
return e instanceof HTMLInputElement && (e.type === "checkbox" || e.type === "radio");
|
|
129
136
|
}
|
|
130
|
-
function
|
|
137
|
+
function v(e) {
|
|
131
138
|
return e instanceof HTMLInputElement && e.type === "radio";
|
|
132
139
|
}
|
|
133
|
-
function
|
|
140
|
+
function I(e) {
|
|
134
141
|
return e instanceof HTMLInputElement || e instanceof HTMLSelectElement || e instanceof HTMLTextAreaElement;
|
|
135
142
|
}
|
|
136
|
-
function
|
|
143
|
+
function H(e) {
|
|
137
144
|
return Array.from(e.children).find(
|
|
138
|
-
(
|
|
145
|
+
(o) => o instanceof HTMLElement && o.getAttribute(b) === "true"
|
|
139
146
|
);
|
|
140
147
|
}
|
|
141
|
-
function
|
|
142
|
-
const
|
|
143
|
-
return
|
|
148
|
+
function Y(e, o) {
|
|
149
|
+
const t = e.createElement("div");
|
|
150
|
+
return t.setAttribute(T, "true"), t.textContent = o, t;
|
|
144
151
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
152
|
+
function Z(e) {
|
|
153
|
+
return H(e);
|
|
147
154
|
}
|
|
148
|
-
function
|
|
155
|
+
function N(e) {
|
|
149
156
|
if (e.name) {
|
|
150
|
-
const
|
|
151
|
-
|
|
157
|
+
const o = e.form ?? e.ownerDocument, t = typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e.name) : e.name.replace(/(["\\])/g, "\\$1"), n = Array.from(
|
|
158
|
+
o.querySelectorAll(`input[type="radio"][name="${t}"]`)
|
|
152
159
|
);
|
|
153
160
|
if (n.length > 0)
|
|
154
161
|
return n;
|
|
155
162
|
}
|
|
156
163
|
return [e];
|
|
157
164
|
}
|
|
158
|
-
function
|
|
159
|
-
const [
|
|
160
|
-
if (!
|
|
165
|
+
function me(e) {
|
|
166
|
+
const [o, ...t] = e;
|
|
167
|
+
if (!o)
|
|
161
168
|
return;
|
|
162
|
-
let n =
|
|
169
|
+
let n = o;
|
|
163
170
|
for (; n; ) {
|
|
164
|
-
if (
|
|
171
|
+
if (t.every((r) => n?.contains(r)))
|
|
165
172
|
return n;
|
|
166
173
|
n = n.parentElement;
|
|
167
174
|
}
|
|
168
175
|
}
|
|
169
|
-
function
|
|
170
|
-
const
|
|
171
|
-
if (
|
|
172
|
-
const n =
|
|
173
|
-
if (n && !
|
|
176
|
+
function _(e) {
|
|
177
|
+
const t = N(e).map((n) => n.closest(".form-check")).filter((n) => n instanceof HTMLElement);
|
|
178
|
+
if (t.length > 1) {
|
|
179
|
+
const n = me(t);
|
|
180
|
+
if (n && !t.includes(n))
|
|
174
181
|
return n;
|
|
175
182
|
}
|
|
176
|
-
return
|
|
183
|
+
return x(e);
|
|
177
184
|
}
|
|
178
|
-
function
|
|
179
|
-
const
|
|
180
|
-
return
|
|
185
|
+
function x(e) {
|
|
186
|
+
const o = e.closest(".form-check");
|
|
187
|
+
return o instanceof HTMLElement ? o : void 0;
|
|
181
188
|
}
|
|
182
|
-
function
|
|
183
|
-
const
|
|
184
|
-
if (
|
|
189
|
+
function ee(e) {
|
|
190
|
+
const o = e.nextElementSibling;
|
|
191
|
+
if (o instanceof HTMLElement && o.getAttribute(b) === "true")
|
|
192
|
+
return o;
|
|
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;
|
|
195
|
+
}
|
|
196
|
+
function be(e) {
|
|
197
|
+
const o = v(e) ? _(e) : x(e);
|
|
198
|
+
if (!o)
|
|
199
|
+
return ee(e);
|
|
200
|
+
const t = H(o);
|
|
201
|
+
if (t)
|
|
185
202
|
return t;
|
|
186
|
-
const
|
|
187
|
-
return
|
|
203
|
+
const n = document.createElement("div");
|
|
204
|
+
return n.className = "invalid-feedback d-block", n.setAttribute(T, "true"), n.setAttribute(b, "true"), o.appendChild(n), n;
|
|
188
205
|
}
|
|
189
|
-
function
|
|
190
|
-
const
|
|
191
|
-
if (!t)
|
|
192
|
-
return O(e);
|
|
193
|
-
const o = N(t);
|
|
206
|
+
function pe(e) {
|
|
207
|
+
const o = Z(e);
|
|
194
208
|
if (o)
|
|
195
209
|
return o;
|
|
196
|
-
const
|
|
197
|
-
return
|
|
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;
|
|
198
212
|
}
|
|
199
|
-
function
|
|
200
|
-
|
|
201
|
-
if (t)
|
|
202
|
-
return t;
|
|
203
|
-
const o = document.createElement("div");
|
|
204
|
-
return o.className = "alert alert-danger", o.setAttribute("role", "alert"), o.setAttribute(T, "true"), o.setAttribute(m, "true"), e.insertAdjacentElement("afterbegin", o), o;
|
|
213
|
+
function h(e) {
|
|
214
|
+
e.getAttribute(C) === "true" && (e.classList.remove("is-invalid"), e.removeAttribute(C));
|
|
205
215
|
}
|
|
206
|
-
function
|
|
207
|
-
e.getAttribute(
|
|
216
|
+
function E(e) {
|
|
217
|
+
e.getAttribute(y) === "true" && (e.classList.remove("is-valid"), e.removeAttribute(y));
|
|
208
218
|
}
|
|
209
|
-
function
|
|
210
|
-
|
|
211
|
-
|
|
219
|
+
function q(e) {
|
|
220
|
+
switch (e) {
|
|
221
|
+
case "success":
|
|
222
|
+
return "alert alert-success";
|
|
223
|
+
case "warning":
|
|
224
|
+
return "alert alert-warning";
|
|
225
|
+
case "info":
|
|
226
|
+
return "alert alert-info";
|
|
227
|
+
default:
|
|
228
|
+
return "alert alert-danger";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function L(e) {
|
|
232
|
+
return e === "success" ? "valid-feedback d-block" : "invalid-feedback d-block";
|
|
233
|
+
}
|
|
234
|
+
function te(e) {
|
|
235
|
+
(v(e) ? N(e) : [e]).forEach((t) => {
|
|
236
|
+
t.classList.add("is-invalid"), t.setAttribute(C, "true");
|
|
212
237
|
});
|
|
213
238
|
}
|
|
214
|
-
function
|
|
215
|
-
(
|
|
216
|
-
|
|
239
|
+
function he(e) {
|
|
240
|
+
(v(e) ? N(e) : [e]).forEach((t) => {
|
|
241
|
+
h(t);
|
|
217
242
|
});
|
|
218
243
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
244
|
+
function oe(e, o) {
|
|
245
|
+
const t = e.nextElementSibling;
|
|
246
|
+
if (t instanceof HTMLElement && t.getAttribute(b) === "true")
|
|
247
|
+
return t.className = L(o), t;
|
|
248
|
+
const n = document.createElement("div");
|
|
249
|
+
return n.className = L(o), n.setAttribute(T, "true"), n.setAttribute(b, "true"), e.insertAdjacentElement("afterend", n), n;
|
|
221
250
|
}
|
|
222
|
-
function
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
251
|
+
function Ee(e, o) {
|
|
252
|
+
const t = v(e) ? _(e) : x(e);
|
|
253
|
+
if (!t)
|
|
254
|
+
return oe(e, o);
|
|
255
|
+
const n = H(t);
|
|
256
|
+
if (n)
|
|
257
|
+
return n.className = L(o), n;
|
|
258
|
+
const r = document.createElement("div");
|
|
259
|
+
return r.className = L(o), r.setAttribute(T, "true"), r.setAttribute(b, "true"), t.appendChild(r), r;
|
|
260
|
+
}
|
|
261
|
+
function ve(e, o) {
|
|
262
|
+
const t = Z(e);
|
|
263
|
+
if (t)
|
|
264
|
+
return t.className = q(o), t;
|
|
265
|
+
const n = document.createElement("div");
|
|
266
|
+
return n.className = q(o), n.setAttribute("role", "alert"), n.setAttribute(T, "true"), n.setAttribute(b, "true"), e.insertAdjacentElement("afterbegin", n), n;
|
|
267
|
+
}
|
|
268
|
+
function Te(e, o) {
|
|
269
|
+
return (S(e) ? be(e) : I(e) ? ee(e) : pe(e)).appendChild(Y(document, o)), S(e) ? te(e) : I(e) && (e.classList.add("is-invalid"), e.setAttribute(C, "true")), Promise.resolve();
|
|
270
|
+
}
|
|
271
|
+
function Ae(e, o, t) {
|
|
272
|
+
if ((S(e) ? Ee(e, t) : I(e) ? oe(e, t) : ve(e, t)).appendChild(Y(document, o)), S(e)) {
|
|
273
|
+
const r = v(e) ? N(e) : [e];
|
|
274
|
+
t === "success" ? r.forEach((i) => {
|
|
275
|
+
h(i), i.classList.add("is-valid"), i.setAttribute(y, "true");
|
|
276
|
+
}) : !t || t === "error" ? (r.forEach((i) => E(i)), te(e)) : r.forEach((i) => {
|
|
277
|
+
E(i), h(i);
|
|
278
|
+
});
|
|
279
|
+
} else I(e) && (t === "success" ? (h(e), e.classList.add("is-valid"), e.setAttribute(y, "true")) : !t || t === "error" ? (E(e), e.classList.add("is-invalid"), e.setAttribute(C, "true")) : (E(e), h(e)));
|
|
280
|
+
return Promise.resolve();
|
|
281
|
+
}
|
|
282
|
+
function Ce(e) {
|
|
283
|
+
if (S(e)) {
|
|
284
|
+
const r = v(e) ? _(e) : x(e);
|
|
285
|
+
(r ? H(r) : void 0)?.remove(), he(e), (v(e) ? N(e) : [e]).forEach((a) => E(a));
|
|
286
|
+
} else if (I(e)) {
|
|
287
|
+
const r = e.nextElementSibling;
|
|
288
|
+
r instanceof HTMLElement && r.getAttribute(b) === "true" && r.remove(), h(e), E(e);
|
|
229
289
|
}
|
|
230
290
|
return e.querySelectorAll(
|
|
231
|
-
`[${
|
|
232
|
-
).forEach((
|
|
233
|
-
|
|
291
|
+
`[${b}="true"]`
|
|
292
|
+
).forEach((r) => {
|
|
293
|
+
r.remove();
|
|
234
294
|
}), e.querySelectorAll(
|
|
235
|
-
`[${
|
|
236
|
-
).forEach((
|
|
237
|
-
|
|
295
|
+
`[${C}="true"]`
|
|
296
|
+
).forEach((r) => {
|
|
297
|
+
h(r);
|
|
298
|
+
}), e.querySelectorAll(
|
|
299
|
+
`[${y}="true"]`
|
|
300
|
+
).forEach((r) => {
|
|
301
|
+
E(r);
|
|
238
302
|
}), Promise.resolve();
|
|
239
303
|
}
|
|
240
|
-
function
|
|
304
|
+
function ne(e) {
|
|
241
305
|
e.classList.contains("modal") || e.classList.add("modal"), e.tabIndex < 0 && (e.tabIndex = -1), e.hasAttribute("aria-hidden") || e.setAttribute("aria-hidden", "true");
|
|
242
306
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
return
|
|
247
|
-
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
const
|
|
251
|
-
return
|
|
252
|
-
}
|
|
253
|
-
const
|
|
254
|
-
|
|
307
|
+
function ge(e, o) {
|
|
308
|
+
ne(e);
|
|
309
|
+
const t = B(e, void 0, o.bootstrap);
|
|
310
|
+
return t ? (t.show(), Promise.resolve()) : Promise.reject(new Error("Bootstrap Modal is unavailable."));
|
|
311
|
+
}
|
|
312
|
+
function we(e, o) {
|
|
313
|
+
ne(e);
|
|
314
|
+
const t = B(e, void 0, o.bootstrap);
|
|
315
|
+
return t ? (t.hide(), Promise.resolve()) : Promise.reject(new Error("Bootstrap Modal is unavailable."));
|
|
316
|
+
}
|
|
317
|
+
const F = "data-haori-bootstrap-toast-container", ye = "data-haori-bootstrap-toast", Se = "data-haori-bootstrap-toast-accent", Ie = "data-haori-bootstrap-toast-dismiss", z = {
|
|
318
|
+
"top-start": "top-0 start-0",
|
|
319
|
+
"top-center": "top-0 start-50 translate-middle-x",
|
|
320
|
+
"top-end": "top-0 end-0",
|
|
321
|
+
"bottom-start": "bottom-0 start-0",
|
|
322
|
+
"bottom-center": "bottom-0 start-50 translate-middle-x",
|
|
323
|
+
"bottom-end": "bottom-0 end-0"
|
|
324
|
+
};
|
|
325
|
+
function Ne(e) {
|
|
255
326
|
switch (e) {
|
|
327
|
+
case "success":
|
|
328
|
+
return { accentClassName: "bg-success" };
|
|
256
329
|
case "warning":
|
|
257
330
|
return { accentClassName: "bg-warning" };
|
|
258
331
|
case "error":
|
|
@@ -261,109 +334,115 @@ function pe(e) {
|
|
|
261
334
|
return { accentClassName: "bg-info" };
|
|
262
335
|
}
|
|
263
336
|
}
|
|
264
|
-
function
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
if (
|
|
268
|
-
return
|
|
337
|
+
function Me(e, o) {
|
|
338
|
+
if (o.toastContainerSelector) {
|
|
339
|
+
const t = e.querySelector(o.toastContainerSelector);
|
|
340
|
+
if (t)
|
|
341
|
+
return t;
|
|
269
342
|
}
|
|
270
343
|
return e.body;
|
|
271
344
|
}
|
|
272
|
-
function
|
|
273
|
-
const
|
|
274
|
-
`[${
|
|
345
|
+
function ke(e, o) {
|
|
346
|
+
const t = Me(e, o), n = z[o.toastPosition ?? "bottom-end"], r = t.querySelector(
|
|
347
|
+
`[${F}="true"]`
|
|
275
348
|
);
|
|
276
|
-
if (
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
349
|
+
if (r) {
|
|
350
|
+
const c = Object.values(z).flatMap((a) => a.split(" "));
|
|
351
|
+
return r.classList.remove(...c), r.classList.add(...n.split(" ")), r;
|
|
352
|
+
}
|
|
353
|
+
const i = e.createElement("div");
|
|
354
|
+
return i.className = `toast-container position-fixed ${n} p-3`, i.setAttribute(F, "true"), t.appendChild(i), i;
|
|
280
355
|
}
|
|
281
|
-
function
|
|
282
|
-
const n = globalThis.document, r =
|
|
283
|
-
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(
|
|
284
|
-
const
|
|
285
|
-
|
|
356
|
+
function Le(e, o, t) {
|
|
357
|
+
const n = globalThis.document, r = Ne(o), i = n.createElement("div");
|
|
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(ye, "true");
|
|
359
|
+
const c = n.createElement("div");
|
|
360
|
+
c.className = "d-flex align-items-stretch";
|
|
286
361
|
const a = n.createElement("div");
|
|
287
|
-
a.className = `flex-shrink-0 rounded-start ${r.accentClassName}`, a.style.width = "0.375rem", a.setAttribute(
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
|
|
362
|
+
a.className = `flex-shrink-0 rounded-start ${r.accentClassName}`, a.style.width = "0.375rem", a.setAttribute(Se, "true");
|
|
363
|
+
const d = n.createElement("div");
|
|
364
|
+
d.className = "toast-body", d.style.whiteSpace = "pre-line", d.textContent = e;
|
|
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(Ie, "true"), c.appendChild(a), c.appendChild(d), c.appendChild(l), i.appendChild(c), ke(n, t).appendChild(i);
|
|
367
|
+
const m = t.toastDelay !== void 0 ? { delay: t.toastDelay } : void 0, u = ae(i, m, t.bootstrap);
|
|
368
|
+
if (!u)
|
|
292
369
|
return i.remove(), Promise.reject(new Error("Bootstrap Toast is unavailable."));
|
|
293
|
-
|
|
370
|
+
l.addEventListener("click", () => {
|
|
371
|
+
u.hide?.();
|
|
372
|
+
}), i.addEventListener(
|
|
294
373
|
"hidden.bs.toast",
|
|
295
374
|
() => {
|
|
296
|
-
i.remove(),
|
|
375
|
+
i.remove(), u.dispose?.();
|
|
297
376
|
},
|
|
298
377
|
{ once: !0 }
|
|
299
378
|
);
|
|
300
379
|
try {
|
|
301
|
-
return
|
|
302
|
-
} catch (
|
|
303
|
-
return i.remove(),
|
|
380
|
+
return u.show(), Promise.resolve();
|
|
381
|
+
} catch (p) {
|
|
382
|
+
return i.remove(), u.dispose?.(), Promise.reject(p);
|
|
304
383
|
}
|
|
305
384
|
}
|
|
306
|
-
const
|
|
385
|
+
const Be = {
|
|
307
386
|
options: {
|
|
308
387
|
fallbackToNative: !0
|
|
309
388
|
}
|
|
310
389
|
};
|
|
311
|
-
let
|
|
312
|
-
function
|
|
390
|
+
let f = Be;
|
|
391
|
+
function A(e) {
|
|
313
392
|
return e.replace(/\\n/g, `
|
|
314
393
|
`);
|
|
315
394
|
}
|
|
316
|
-
function
|
|
395
|
+
function re() {
|
|
317
396
|
return globalThis.window;
|
|
318
397
|
}
|
|
319
|
-
function
|
|
398
|
+
function D(e) {
|
|
320
399
|
return Promise.resolve(e).then(() => {
|
|
321
400
|
});
|
|
322
401
|
}
|
|
323
|
-
function
|
|
324
|
-
const
|
|
325
|
-
return typeof
|
|
402
|
+
function P(e) {
|
|
403
|
+
const o = f.originalHaori?.[e];
|
|
404
|
+
return typeof o == "function" ? o : void 0;
|
|
326
405
|
}
|
|
327
|
-
function
|
|
406
|
+
function R(e) {
|
|
328
407
|
console.warn(`[haori-bootstrap] ${e} skipped because Bootstrap support is unavailable.`);
|
|
329
408
|
}
|
|
330
|
-
function
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
333
|
-
return
|
|
334
|
-
const n =
|
|
335
|
-
return
|
|
409
|
+
function W(e) {
|
|
410
|
+
const o = A(e), t = P("dialog");
|
|
411
|
+
if (t)
|
|
412
|
+
return D(t(o));
|
|
413
|
+
const n = re();
|
|
414
|
+
return f.options.fallbackToNative && typeof n?.alert == "function" ? (n.alert(o), Promise.resolve()) : (R("dialog"), Promise.resolve());
|
|
336
415
|
}
|
|
337
|
-
function
|
|
338
|
-
const
|
|
339
|
-
if (
|
|
340
|
-
return Promise.resolve(o
|
|
416
|
+
function O(e) {
|
|
417
|
+
const o = A(e), t = P("confirm");
|
|
418
|
+
if (t)
|
|
419
|
+
return Promise.resolve(t(o)).then(
|
|
341
420
|
(r) => !!r
|
|
342
421
|
);
|
|
343
|
-
const n =
|
|
344
|
-
return
|
|
422
|
+
const n = re();
|
|
423
|
+
return f.options.fallbackToNative && typeof n?.confirm == "function" ? Promise.resolve(n.confirm(o)) : (R("confirm"), Promise.resolve(!1));
|
|
345
424
|
}
|
|
346
|
-
function
|
|
347
|
-
const
|
|
348
|
-
return n ?
|
|
425
|
+
function G(e, o) {
|
|
426
|
+
const t = A(e), n = P("toast");
|
|
427
|
+
return n ? D(n(t, o)) : (R("toast"), Promise.resolve());
|
|
349
428
|
}
|
|
350
|
-
function
|
|
351
|
-
const
|
|
352
|
-
return
|
|
429
|
+
function k(e, o) {
|
|
430
|
+
const t = P(e);
|
|
431
|
+
return t ? D(t(o)) : (R(e), Promise.resolve());
|
|
353
432
|
}
|
|
354
|
-
function
|
|
355
|
-
|
|
433
|
+
function He(e) {
|
|
434
|
+
f = e;
|
|
356
435
|
}
|
|
357
|
-
class
|
|
436
|
+
class xe {
|
|
358
437
|
/**
|
|
359
438
|
* 情報表示ダイアログを表示する。
|
|
360
439
|
*
|
|
361
440
|
* @param message 表示するメッセージ。
|
|
362
441
|
* @return 完了時に解決される Promise。
|
|
363
442
|
*/
|
|
364
|
-
static dialog(
|
|
365
|
-
const
|
|
366
|
-
return
|
|
443
|
+
static dialog(o) {
|
|
444
|
+
const t = A(o);
|
|
445
|
+
return M(f.options.bootstrap) ? de(t, f.options).catch(() => W(t)) : W(t);
|
|
367
446
|
}
|
|
368
447
|
/**
|
|
369
448
|
* 確認ダイアログを表示する。
|
|
@@ -371,9 +450,9 @@ class Te {
|
|
|
371
450
|
* @param message 表示するメッセージ。
|
|
372
451
|
* @return OK のみ true を返す Promise。
|
|
373
452
|
*/
|
|
374
|
-
static confirm(
|
|
375
|
-
const
|
|
376
|
-
return
|
|
453
|
+
static confirm(o) {
|
|
454
|
+
const t = A(o);
|
|
455
|
+
return M(f.options.bootstrap) ? fe(t, f.options).catch(() => O(t)) : O(t);
|
|
377
456
|
}
|
|
378
457
|
/**
|
|
379
458
|
* トースト通知を表示する。
|
|
@@ -382,11 +461,11 @@ class Te {
|
|
|
382
461
|
* @param level 通知レベル。
|
|
383
462
|
* @return 完了時に解決される Promise。
|
|
384
463
|
*/
|
|
385
|
-
static toast(
|
|
386
|
-
const n =
|
|
387
|
-
return
|
|
388
|
-
() =>
|
|
389
|
-
) :
|
|
464
|
+
static toast(o, t) {
|
|
465
|
+
const n = A(o);
|
|
466
|
+
return se(f.options.bootstrap) ? Le(n, t, f.options).catch(
|
|
467
|
+
() => G(n, t)
|
|
468
|
+
) : G(n, t);
|
|
390
469
|
}
|
|
391
470
|
/**
|
|
392
471
|
* 任意のダイアログ要素を開く。
|
|
@@ -394,10 +473,10 @@ class Te {
|
|
|
394
473
|
* @param element 開く対象の要素。
|
|
395
474
|
* @return 完了時に解決される Promise。
|
|
396
475
|
*/
|
|
397
|
-
static openDialog(
|
|
398
|
-
return
|
|
399
|
-
() =>
|
|
400
|
-
) :
|
|
476
|
+
static openDialog(o) {
|
|
477
|
+
return M(f.options.bootstrap) ? ge(o, f.options).catch(
|
|
478
|
+
() => k("openDialog", o)
|
|
479
|
+
) : k("openDialog", o);
|
|
401
480
|
}
|
|
402
481
|
/**
|
|
403
482
|
* 任意のダイアログ要素を閉じる。
|
|
@@ -405,10 +484,10 @@ class Te {
|
|
|
405
484
|
* @param element 閉じる対象の要素。
|
|
406
485
|
* @return 完了時に解決される Promise。
|
|
407
486
|
*/
|
|
408
|
-
static closeDialog(
|
|
409
|
-
return
|
|
410
|
-
() =>
|
|
411
|
-
) :
|
|
487
|
+
static closeDialog(o) {
|
|
488
|
+
return M(f.options.bootstrap) ? we(o, f.options).catch(
|
|
489
|
+
() => k("closeDialog", o)
|
|
490
|
+
) : k("closeDialog", o);
|
|
412
491
|
}
|
|
413
492
|
/**
|
|
414
493
|
* 管理対象のエラーメッセージを追加する。
|
|
@@ -417,8 +496,19 @@ class Te {
|
|
|
417
496
|
* @param message 表示するメッセージ。
|
|
418
497
|
* @return 完了時に解決される Promise。
|
|
419
498
|
*/
|
|
420
|
-
static addErrorMessage(
|
|
421
|
-
return
|
|
499
|
+
static addErrorMessage(o, t) {
|
|
500
|
+
return Te(o, t);
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* 管理対象のメッセージをレベル付きで追加する。
|
|
504
|
+
*
|
|
505
|
+
* @param target 追加先の要素。
|
|
506
|
+
* @param message 表示するメッセージ。
|
|
507
|
+
* @param level メッセージレベル (error / success / warning / info)。省略時は error。
|
|
508
|
+
* @return 完了時に解決される Promise。
|
|
509
|
+
*/
|
|
510
|
+
static addMessage(o, t, n) {
|
|
511
|
+
return Ae(o, t, n);
|
|
422
512
|
}
|
|
423
513
|
/**
|
|
424
514
|
* 管理対象のメッセージを削除する。
|
|
@@ -426,81 +516,90 @@ class Te {
|
|
|
426
516
|
* @param parentOrTarget 削除対象の親要素または対象要素。
|
|
427
517
|
* @return 完了時に解決される Promise。
|
|
428
518
|
*/
|
|
429
|
-
static clearMessages(
|
|
430
|
-
return
|
|
519
|
+
static clearMessages(o) {
|
|
520
|
+
return Ce(o);
|
|
431
521
|
}
|
|
432
522
|
}
|
|
433
|
-
const
|
|
523
|
+
const $ = {
|
|
434
524
|
fallbackToNative: !0
|
|
435
|
-
},
|
|
525
|
+
}, s = {
|
|
436
526
|
installed: !1,
|
|
437
|
-
options:
|
|
527
|
+
options: $
|
|
438
528
|
};
|
|
439
|
-
function
|
|
529
|
+
function U() {
|
|
440
530
|
return globalThis.window;
|
|
441
531
|
}
|
|
442
|
-
function
|
|
532
|
+
function Pe(e, o) {
|
|
443
533
|
return {
|
|
444
|
-
bootstrap: e.bootstrap ??
|
|
445
|
-
fallbackToNative: e.fallbackToNative ??
|
|
446
|
-
runtime: e.runtime ??
|
|
447
|
-
toastContainerSelector: e.toastContainerSelector,
|
|
448
|
-
dialogContainerSelector: e.dialogContainerSelector
|
|
534
|
+
bootstrap: e.bootstrap ?? o?.bootstrap,
|
|
535
|
+
fallbackToNative: e.fallbackToNative ?? $.fallbackToNative,
|
|
536
|
+
runtime: e.runtime ?? s.options.runtime ?? o?.Haori?.runtime,
|
|
537
|
+
toastContainerSelector: e.toastContainerSelector ?? s.options.toastContainerSelector,
|
|
538
|
+
dialogContainerSelector: e.dialogContainerSelector ?? s.options.dialogContainerSelector,
|
|
539
|
+
dialogTitle: e.dialogTitle ?? s.options.dialogTitle,
|
|
540
|
+
toastPosition: e.toastPosition ?? s.options.toastPosition,
|
|
541
|
+
toastDelay: e.toastDelay ?? s.options.toastDelay
|
|
449
542
|
};
|
|
450
543
|
}
|
|
451
|
-
function
|
|
544
|
+
function Re(e = U()) {
|
|
452
545
|
return !!(e?.Haori && e.bootstrap);
|
|
453
546
|
}
|
|
454
|
-
function
|
|
455
|
-
const
|
|
456
|
-
if (!
|
|
547
|
+
function _e(e = {}) {
|
|
548
|
+
const o = U();
|
|
549
|
+
if (!o?.Haori)
|
|
457
550
|
throw new Error("window.Haori is required before calling install().");
|
|
458
|
-
|
|
459
|
-
originalHaori
|
|
460
|
-
options:
|
|
461
|
-
|
|
551
|
+
if (s.originalHaori || (s.originalHaori = o.Haori, s.originalRuntime = o.Haori.runtime), s.options = Pe(e, o), s.options.runtime) {
|
|
552
|
+
const t = s.originalHaori ?? o.Haori;
|
|
553
|
+
typeof t.setRuntime == "function" ? t.setRuntime(s.options.runtime) : console.warn(
|
|
554
|
+
"[haori-bootstrap] Haori.setRuntime が利用できません。runtime 設定は無視されます。"
|
|
555
|
+
);
|
|
556
|
+
}
|
|
557
|
+
He({
|
|
558
|
+
originalHaori: s.originalHaori,
|
|
559
|
+
options: s.options
|
|
560
|
+
}), o.Haori = xe, s.installed = !0;
|
|
462
561
|
}
|
|
463
|
-
function
|
|
464
|
-
const e =
|
|
465
|
-
!e || !
|
|
562
|
+
function Fe() {
|
|
563
|
+
const e = U();
|
|
564
|
+
!e || !s.originalHaori || (s.originalHaori.runtime = s.originalRuntime, e.Haori = s.originalHaori, s.installed = !1, s.originalHaori = void 0, s.originalRuntime = void 0, s.options = $);
|
|
466
565
|
}
|
|
467
|
-
function
|
|
468
|
-
return
|
|
566
|
+
function ze() {
|
|
567
|
+
return s.installed;
|
|
469
568
|
}
|
|
470
|
-
const
|
|
471
|
-
function
|
|
569
|
+
const ie = "__haoriJsBootstrapAutoEnabled__";
|
|
570
|
+
function De() {
|
|
472
571
|
return globalThis.window;
|
|
473
572
|
}
|
|
474
|
-
function
|
|
475
|
-
return !!e[
|
|
573
|
+
function $e(e) {
|
|
574
|
+
return !!e[ie];
|
|
476
575
|
}
|
|
477
|
-
function
|
|
478
|
-
e[
|
|
576
|
+
function Ue(e) {
|
|
577
|
+
e[ie] = !0;
|
|
479
578
|
}
|
|
480
|
-
function
|
|
481
|
-
const e =
|
|
482
|
-
if (!(!e ||
|
|
483
|
-
if (!
|
|
579
|
+
function qe() {
|
|
580
|
+
const e = De();
|
|
581
|
+
if (!(!e || $e(e))) {
|
|
582
|
+
if (!Re(e)) {
|
|
484
583
|
console.warn(
|
|
485
584
|
"[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing."
|
|
486
585
|
);
|
|
487
586
|
return;
|
|
488
587
|
}
|
|
489
588
|
try {
|
|
490
|
-
|
|
491
|
-
} catch (
|
|
492
|
-
console.warn("[haori-bootstrap] Auto-enable failed.",
|
|
589
|
+
_e({ bootstrap: e.bootstrap }), Ue(e);
|
|
590
|
+
} catch (o) {
|
|
591
|
+
console.warn("[haori-bootstrap] Auto-enable failed.", o);
|
|
493
592
|
}
|
|
494
593
|
}
|
|
495
594
|
}
|
|
496
|
-
|
|
497
|
-
const
|
|
595
|
+
qe();
|
|
596
|
+
const We = "0.3.1";
|
|
498
597
|
export {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
598
|
+
xe as BootstrapHaori,
|
|
599
|
+
Re as hasAutoEnablePrerequisites,
|
|
600
|
+
_e as install,
|
|
601
|
+
ze as isInstalled,
|
|
602
|
+
Fe as uninstall,
|
|
603
|
+
We as version
|
|
505
604
|
};
|
|
506
605
|
//# sourceMappingURL=haori-bootstrap.js.map
|