haori-bootstrap 0.3.0 → 0.3.2
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 +15 -7
- 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 +351 -228
- 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,35 +1,37 @@
|
|
|
1
|
-
function
|
|
1
|
+
function j(e) {
|
|
2
2
|
return typeof e == "function";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
5
|
-
return
|
|
4
|
+
function K(e) {
|
|
5
|
+
return j(e?.Modal) ? e?.Modal : void 0;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
return
|
|
7
|
+
function J(e) {
|
|
8
|
+
return j(e?.Toast) ? e?.Toast : void 0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return !!
|
|
10
|
+
function y(e) {
|
|
11
|
+
return !!K(e);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return
|
|
13
|
+
function ae(e) {
|
|
14
|
+
return !!J(e);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const n =
|
|
16
|
+
function H(e, t, o) {
|
|
17
|
+
const n = K(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
|
|
23
|
-
if (
|
|
24
|
-
return typeof
|
|
21
|
+
function ce(e, t, o) {
|
|
22
|
+
const n = J(o);
|
|
23
|
+
if (n)
|
|
24
|
+
return typeof n.getOrCreateInstance == "function" ? n.getOrCreateInstance(e, t) : new n(e, t);
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const le = "data-haori-bootstrap-dialog", w = "data-haori-bootstrap-action", ue = "data-haori-bootstrap-dialog-title";
|
|
27
|
+
let de = 0;
|
|
28
|
+
function Q() {
|
|
28
29
|
return {
|
|
29
|
-
backdrop: "static"
|
|
30
|
+
backdrop: "static",
|
|
31
|
+
keyboard: !1
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
|
-
function
|
|
34
|
+
function X(e, t) {
|
|
33
35
|
if (t.dialogContainerSelector) {
|
|
34
36
|
const o = e.querySelector(
|
|
35
37
|
t.dialogContainerSelector
|
|
@@ -39,113 +41,118 @@ function U(e, 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 Y(e, t, o, n) {
|
|
45
45
|
const r = e.createElement("div");
|
|
46
|
-
r.className = "modal-
|
|
46
|
+
r.className = "modal fade", r.tabIndex = -1, r.setAttribute(le, "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
|
-
const f = e.createElement("button");
|
|
56
|
-
f.type = "button", f.className = "btn btn-secondary", f.setAttribute(b, "cancel"), f.textContent = "Cancel", s.appendChild(f);
|
|
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-${++de}`, 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(ue, "true"), g.textContent = n, p.appendChild(g), c.appendChild(p), r.setAttribute("aria-labelledby", u);
|
|
57
55
|
}
|
|
58
|
-
const
|
|
59
|
-
|
|
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 = t, a.appendChild(d);
|
|
60
|
+
const l = e.createElement("div");
|
|
61
|
+
if (l.className = "modal-footer", o) {
|
|
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);
|
|
64
|
+
}
|
|
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 o = globalThis.document, n =
|
|
63
|
-
|
|
64
|
-
const r =
|
|
68
|
+
function fe(e, t) {
|
|
69
|
+
const o = globalThis.document, n = Y(o, e, !1, t.dialogTitle);
|
|
70
|
+
X(o, t).appendChild(n);
|
|
71
|
+
const r = H(
|
|
65
72
|
n,
|
|
66
|
-
|
|
73
|
+
Q(),
|
|
67
74
|
t.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 o = globalThis.document, n =
|
|
91
|
-
|
|
92
|
-
const r =
|
|
96
|
+
function me(e, t) {
|
|
97
|
+
const o = globalThis.document, n = Y(o, e, !0, t.dialogTitle);
|
|
98
|
+
X(o, t).appendChild(n);
|
|
99
|
+
const r = H(
|
|
93
100
|
n,
|
|
94
|
-
|
|
101
|
+
Q(),
|
|
95
102
|
t.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", M = "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 B(e) {
|
|
137
144
|
return Array.from(e.children).find(
|
|
138
|
-
(t) => t instanceof HTMLElement && t.getAttribute(
|
|
145
|
+
(t) => t instanceof HTMLElement && t.getAttribute(b) === "true"
|
|
139
146
|
);
|
|
140
147
|
}
|
|
141
|
-
function
|
|
148
|
+
function Z(e, t) {
|
|
142
149
|
const o = e.createElement("div");
|
|
143
150
|
return o.setAttribute(T, "true"), o.textContent = t, o;
|
|
144
151
|
}
|
|
145
|
-
function
|
|
146
|
-
return
|
|
152
|
+
function ee(e) {
|
|
153
|
+
return B(e);
|
|
147
154
|
}
|
|
148
|
-
function
|
|
155
|
+
function N(e) {
|
|
149
156
|
if (e.name) {
|
|
150
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(
|
|
151
158
|
t.querySelectorAll(`input[type="radio"][name="${o}"]`)
|
|
@@ -155,7 +162,7 @@ function S(e) {
|
|
|
155
162
|
}
|
|
156
163
|
return [e];
|
|
157
164
|
}
|
|
158
|
-
function
|
|
165
|
+
function be(e) {
|
|
159
166
|
const [t, ...o] = e;
|
|
160
167
|
if (!t)
|
|
161
168
|
return;
|
|
@@ -166,93 +173,159 @@ function ne(e) {
|
|
|
166
173
|
n = n.parentElement;
|
|
167
174
|
}
|
|
168
175
|
}
|
|
169
|
-
function
|
|
170
|
-
const o =
|
|
176
|
+
function P(e) {
|
|
177
|
+
const o = N(e).map((n) => n.closest(".form-check")).filter((n) => n instanceof HTMLElement);
|
|
171
178
|
if (o.length > 1) {
|
|
172
|
-
const n =
|
|
179
|
+
const n = be(o);
|
|
173
180
|
if (n && !o.includes(n))
|
|
174
181
|
return n;
|
|
175
182
|
}
|
|
176
|
-
return
|
|
183
|
+
return x(e);
|
|
177
184
|
}
|
|
178
|
-
function
|
|
185
|
+
function x(e) {
|
|
179
186
|
const t = e.closest(".form-check");
|
|
180
187
|
return t instanceof HTMLElement ? t : void 0;
|
|
181
188
|
}
|
|
182
|
-
function
|
|
189
|
+
function te(e) {
|
|
183
190
|
const t = e.nextElementSibling;
|
|
184
|
-
if (t instanceof HTMLElement && t.getAttribute(
|
|
191
|
+
if (t instanceof HTMLElement && t.getAttribute(b) === "true")
|
|
185
192
|
return t;
|
|
186
193
|
const o = document.createElement("div");
|
|
187
|
-
return o.className = "invalid-feedback d-block", o.setAttribute(T, "true"), o.setAttribute(
|
|
194
|
+
return o.className = "invalid-feedback d-block", o.setAttribute(T, "true"), o.setAttribute(b, "true"), e.insertAdjacentElement("afterend", o), o;
|
|
188
195
|
}
|
|
189
|
-
function
|
|
190
|
-
const t =
|
|
196
|
+
function pe(e) {
|
|
197
|
+
const t = v(e) ? P(e) : x(e);
|
|
191
198
|
if (!t)
|
|
192
|
-
return
|
|
193
|
-
const o =
|
|
199
|
+
return te(e);
|
|
200
|
+
const o = B(t);
|
|
194
201
|
if (o)
|
|
195
202
|
return o;
|
|
196
203
|
const n = document.createElement("div");
|
|
197
|
-
return n.className = "invalid-feedback d-block", n.setAttribute(T, "true"), n.setAttribute(
|
|
204
|
+
return n.className = "invalid-feedback d-block", n.setAttribute(T, "true"), n.setAttribute(b, "true"), t.appendChild(n), n;
|
|
198
205
|
}
|
|
199
|
-
function
|
|
200
|
-
const t =
|
|
206
|
+
function he(e) {
|
|
207
|
+
const t = ee(e);
|
|
201
208
|
if (t)
|
|
202
209
|
return t;
|
|
203
210
|
const o = document.createElement("div");
|
|
204
|
-
return o.className = "alert alert-danger", o.setAttribute("role", "alert"), o.setAttribute(T, "true"), o.setAttribute(
|
|
211
|
+
return o.className = "alert alert-danger", o.setAttribute("role", "alert"), o.setAttribute(T, "true"), o.setAttribute(b, "true"), e.insertAdjacentElement("afterbegin", o), o;
|
|
205
212
|
}
|
|
206
|
-
function
|
|
207
|
-
e.getAttribute(
|
|
213
|
+
function h(e) {
|
|
214
|
+
e.getAttribute(C) === "true" && (e.classList.remove("is-invalid"), e.removeAttribute(C));
|
|
208
215
|
}
|
|
209
|
-
function
|
|
210
|
-
(
|
|
211
|
-
|
|
216
|
+
function E(e) {
|
|
217
|
+
e.getAttribute(M) === "true" && (e.classList.remove("is-valid"), e.removeAttribute(M));
|
|
218
|
+
}
|
|
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 oe(e) {
|
|
235
|
+
(v(e) ? N(e) : [e]).forEach((o) => {
|
|
236
|
+
o.classList.add("is-invalid"), o.setAttribute(C, "true");
|
|
212
237
|
});
|
|
213
238
|
}
|
|
214
|
-
function
|
|
215
|
-
(
|
|
216
|
-
|
|
239
|
+
function Ee(e) {
|
|
240
|
+
(v(e) ? N(e) : [e]).forEach((o) => {
|
|
241
|
+
h(o);
|
|
217
242
|
});
|
|
218
243
|
}
|
|
219
|
-
function
|
|
220
|
-
|
|
244
|
+
function ne(e, t) {
|
|
245
|
+
const o = e.nextElementSibling;
|
|
246
|
+
if (o instanceof HTMLElement && o.getAttribute(b) === "true")
|
|
247
|
+
return o.className = L(t), o;
|
|
248
|
+
const n = document.createElement("div");
|
|
249
|
+
return n.className = L(t), 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 ve(e, t) {
|
|
252
|
+
const o = v(e) ? P(e) : x(e);
|
|
253
|
+
if (!o)
|
|
254
|
+
return ne(e, t);
|
|
255
|
+
const n = B(o);
|
|
256
|
+
if (n)
|
|
257
|
+
return n.className = L(t), n;
|
|
258
|
+
const r = document.createElement("div");
|
|
259
|
+
return r.className = L(t), r.setAttribute(T, "true"), r.setAttribute(b, "true"), o.appendChild(r), r;
|
|
260
|
+
}
|
|
261
|
+
function Te(e, t) {
|
|
262
|
+
const o = ee(e);
|
|
263
|
+
if (o)
|
|
264
|
+
return o.className = q(t), o;
|
|
265
|
+
const n = document.createElement("div");
|
|
266
|
+
return n.className = q(t), n.setAttribute("role", "alert"), n.setAttribute(T, "true"), n.setAttribute(b, "true"), e.insertAdjacentElement("afterbegin", n), n;
|
|
267
|
+
}
|
|
268
|
+
function Ae(e, t) {
|
|
269
|
+
return (S(e) ? pe(e) : I(e) ? te(e) : he(e)).appendChild(Z(document, t)), S(e) ? oe(e) : I(e) && (e.classList.add("is-invalid"), e.setAttribute(C, "true")), Promise.resolve();
|
|
270
|
+
}
|
|
271
|
+
function Ce(e, t, o) {
|
|
272
|
+
if ((S(e) ? ve(e, o) : I(e) ? ne(e, o) : Te(e, o)).appendChild(Z(document, t)), S(e)) {
|
|
273
|
+
const r = v(e) ? N(e) : [e];
|
|
274
|
+
o === "success" ? r.forEach((i) => {
|
|
275
|
+
h(i), i.classList.add("is-valid"), i.setAttribute(M, "true");
|
|
276
|
+
}) : !o || o === "error" ? (r.forEach((i) => E(i)), oe(e)) : r.forEach((i) => {
|
|
277
|
+
E(i), h(i);
|
|
278
|
+
});
|
|
279
|
+
} else I(e) && (o === "success" ? (h(e), e.classList.add("is-valid"), e.setAttribute(M, "true")) : !o || o === "error" ? (E(e), e.classList.add("is-invalid"), e.setAttribute(C, "true")) : (E(e), h(e)));
|
|
280
|
+
return Promise.resolve();
|
|
281
|
+
}
|
|
282
|
+
function ge(e) {
|
|
283
|
+
if (S(e)) {
|
|
284
|
+
const r = v(e) ? P(e) : x(e);
|
|
285
|
+
(r ? B(r) : void 0)?.remove(), Ee(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();
|
|
294
|
+
}), e.querySelectorAll(
|
|
295
|
+
`[${C}="true"]`
|
|
296
|
+
).forEach((r) => {
|
|
297
|
+
h(r);
|
|
234
298
|
}), e.querySelectorAll(
|
|
235
|
-
`[${
|
|
236
|
-
).forEach((
|
|
237
|
-
|
|
299
|
+
`[${M}="true"]`
|
|
300
|
+
).forEach((r) => {
|
|
301
|
+
E(r);
|
|
238
302
|
}), Promise.resolve();
|
|
239
303
|
}
|
|
240
|
-
function
|
|
304
|
+
function re(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 o =
|
|
307
|
+
function we(e, t) {
|
|
308
|
+
re(e);
|
|
309
|
+
const o = H(e, void 0, t.bootstrap);
|
|
246
310
|
return o ? (o.show(), Promise.resolve()) : Promise.reject(new Error("Bootstrap Modal is unavailable."));
|
|
247
311
|
}
|
|
248
|
-
function
|
|
249
|
-
|
|
250
|
-
const o =
|
|
312
|
+
function Me(e, t) {
|
|
313
|
+
re(e);
|
|
314
|
+
const o = H(e, void 0, t.bootstrap);
|
|
251
315
|
return o ? (o.hide(), Promise.resolve()) : Promise.reject(new Error("Bootstrap Modal is unavailable."));
|
|
252
316
|
}
|
|
253
|
-
const
|
|
254
|
-
|
|
317
|
+
const F = "data-haori-bootstrap-toast-container", Se = "data-haori-bootstrap-toast", Ie = "data-haori-bootstrap-toast-accent", Ne = "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 ye(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,7 +334,7 @@ function pe(e) {
|
|
|
261
334
|
return { accentClassName: "bg-info" };
|
|
262
335
|
}
|
|
263
336
|
}
|
|
264
|
-
function
|
|
337
|
+
function ke(e, t) {
|
|
265
338
|
if (t.toastContainerSelector) {
|
|
266
339
|
const o = e.querySelector(t.toastContainerSelector);
|
|
267
340
|
if (o)
|
|
@@ -269,92 +342,98 @@ function be(e, t) {
|
|
|
269
342
|
}
|
|
270
343
|
return e.body;
|
|
271
344
|
}
|
|
272
|
-
function
|
|
273
|
-
const o =
|
|
274
|
-
`[${
|
|
345
|
+
function Le(e, t) {
|
|
346
|
+
const o = ke(e, t), n = z[t.toastPosition ?? "bottom-end"], r = o.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"), o.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 He(e, t, o) {
|
|
357
|
+
const n = globalThis.document, r = ye(t), 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(Se, "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(Ie, "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(Ne, "true"), c.appendChild(a), c.appendChild(d), c.appendChild(l), i.appendChild(c), Le(n, o).appendChild(i);
|
|
367
|
+
const m = o.toastDelay !== void 0 ? { delay: o.toastDelay } : void 0, u = ce(i, m, o.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 ie() {
|
|
317
396
|
return globalThis.window;
|
|
318
397
|
}
|
|
319
|
-
function
|
|
398
|
+
function _(e) {
|
|
320
399
|
return Promise.resolve(e).then(() => {
|
|
321
400
|
});
|
|
322
401
|
}
|
|
323
|
-
function
|
|
324
|
-
const t =
|
|
402
|
+
function R(e) {
|
|
403
|
+
const t = f.originalHaori?.[e];
|
|
325
404
|
return typeof t == "function" ? t : void 0;
|
|
326
405
|
}
|
|
327
|
-
function
|
|
406
|
+
function D(e) {
|
|
328
407
|
console.warn(`[haori-bootstrap] ${e} skipped because Bootstrap support is unavailable.`);
|
|
329
408
|
}
|
|
330
|
-
function
|
|
331
|
-
const t =
|
|
409
|
+
function O(e) {
|
|
410
|
+
const t = A(e), o = R("dialog");
|
|
332
411
|
if (o)
|
|
333
|
-
return
|
|
334
|
-
const n =
|
|
335
|
-
return
|
|
412
|
+
return _(o(t));
|
|
413
|
+
const n = ie();
|
|
414
|
+
return f.options.fallbackToNative && typeof n?.alert == "function" ? (n.alert(t), Promise.resolve()) : (D("dialog"), Promise.resolve());
|
|
336
415
|
}
|
|
337
|
-
function
|
|
338
|
-
const t =
|
|
416
|
+
function W(e) {
|
|
417
|
+
const t = A(e), o = R("confirm");
|
|
339
418
|
if (o)
|
|
340
419
|
return Promise.resolve(o(t)).then(
|
|
341
420
|
(r) => !!r
|
|
342
421
|
);
|
|
343
|
-
const n =
|
|
344
|
-
return
|
|
422
|
+
const n = ie();
|
|
423
|
+
return f.options.fallbackToNative && typeof n?.confirm == "function" ? Promise.resolve(n.confirm(t)) : (D("confirm"), Promise.resolve(!1));
|
|
345
424
|
}
|
|
346
|
-
function
|
|
347
|
-
const o =
|
|
348
|
-
return n ?
|
|
425
|
+
function G(e, t) {
|
|
426
|
+
const o = A(e), n = R("toast");
|
|
427
|
+
return n ? _(n(o, t)) : (D("toast"), Promise.resolve());
|
|
349
428
|
}
|
|
350
|
-
function
|
|
351
|
-
const o =
|
|
352
|
-
return o ?
|
|
429
|
+
function k(e, t) {
|
|
430
|
+
const o = R(e);
|
|
431
|
+
return o ? _(o(t)) : (D(e), Promise.resolve());
|
|
353
432
|
}
|
|
354
|
-
function
|
|
355
|
-
|
|
433
|
+
function xe(e) {
|
|
434
|
+
f = e;
|
|
356
435
|
}
|
|
357
|
-
class
|
|
436
|
+
class Re {
|
|
358
437
|
/**
|
|
359
438
|
* 情報表示ダイアログを表示する。
|
|
360
439
|
*
|
|
@@ -362,8 +441,8 @@ class Te {
|
|
|
362
441
|
* @return 完了時に解決される Promise。
|
|
363
442
|
*/
|
|
364
443
|
static dialog(t) {
|
|
365
|
-
const o =
|
|
366
|
-
return
|
|
444
|
+
const o = A(t);
|
|
445
|
+
return y(f.options.bootstrap) ? fe(o, f.options).catch(() => O(o)) : O(o);
|
|
367
446
|
}
|
|
368
447
|
/**
|
|
369
448
|
* 確認ダイアログを表示する。
|
|
@@ -372,8 +451,8 @@ class Te {
|
|
|
372
451
|
* @return OK のみ true を返す Promise。
|
|
373
452
|
*/
|
|
374
453
|
static confirm(t) {
|
|
375
|
-
const o =
|
|
376
|
-
return
|
|
454
|
+
const o = A(t);
|
|
455
|
+
return y(f.options.bootstrap) ? me(o, f.options).catch(() => W(o)) : W(o);
|
|
377
456
|
}
|
|
378
457
|
/**
|
|
379
458
|
* トースト通知を表示する。
|
|
@@ -383,10 +462,10 @@ class Te {
|
|
|
383
462
|
* @return 完了時に解決される Promise。
|
|
384
463
|
*/
|
|
385
464
|
static toast(t, o) {
|
|
386
|
-
const n =
|
|
387
|
-
return
|
|
388
|
-
() =>
|
|
389
|
-
) :
|
|
465
|
+
const n = A(t);
|
|
466
|
+
return ae(f.options.bootstrap) ? He(n, o, f.options).catch(
|
|
467
|
+
() => G(n, o)
|
|
468
|
+
) : G(n, o);
|
|
390
469
|
}
|
|
391
470
|
/**
|
|
392
471
|
* 任意のダイアログ要素を開く。
|
|
@@ -395,9 +474,9 @@ class Te {
|
|
|
395
474
|
* @return 完了時に解決される Promise。
|
|
396
475
|
*/
|
|
397
476
|
static openDialog(t) {
|
|
398
|
-
return
|
|
399
|
-
() =>
|
|
400
|
-
) :
|
|
477
|
+
return y(f.options.bootstrap) ? we(t, f.options).catch(
|
|
478
|
+
() => k("openDialog", t)
|
|
479
|
+
) : k("openDialog", t);
|
|
401
480
|
}
|
|
402
481
|
/**
|
|
403
482
|
* 任意のダイアログ要素を閉じる。
|
|
@@ -406,9 +485,9 @@ class Te {
|
|
|
406
485
|
* @return 完了時に解決される Promise。
|
|
407
486
|
*/
|
|
408
487
|
static closeDialog(t) {
|
|
409
|
-
return
|
|
410
|
-
() =>
|
|
411
|
-
) :
|
|
488
|
+
return y(f.options.bootstrap) ? Me(t, f.options).catch(
|
|
489
|
+
() => k("closeDialog", t)
|
|
490
|
+
) : k("closeDialog", t);
|
|
412
491
|
}
|
|
413
492
|
/**
|
|
414
493
|
* 管理対象のエラーメッセージを追加する。
|
|
@@ -418,7 +497,18 @@ class Te {
|
|
|
418
497
|
* @return 完了時に解決される Promise。
|
|
419
498
|
*/
|
|
420
499
|
static addErrorMessage(t, o) {
|
|
421
|
-
return
|
|
500
|
+
return Ae(t, o);
|
|
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(t, o, n) {
|
|
511
|
+
return Ce(t, o, n);
|
|
422
512
|
}
|
|
423
513
|
/**
|
|
424
514
|
* 管理対象のメッセージを削除する。
|
|
@@ -427,80 +517,113 @@ class Te {
|
|
|
427
517
|
* @return 完了時に解決される Promise。
|
|
428
518
|
*/
|
|
429
519
|
static clearMessages(t) {
|
|
430
|
-
return
|
|
520
|
+
return ge(t);
|
|
431
521
|
}
|
|
432
522
|
}
|
|
433
|
-
const
|
|
523
|
+
const $ = {
|
|
434
524
|
fallbackToNative: !0
|
|
435
|
-
},
|
|
525
|
+
}, V = /* @__PURE__ */ new Set([
|
|
526
|
+
"dialog",
|
|
527
|
+
"confirm",
|
|
528
|
+
"toast",
|
|
529
|
+
"openDialog",
|
|
530
|
+
"closeDialog",
|
|
531
|
+
"addErrorMessage",
|
|
532
|
+
"addMessage",
|
|
533
|
+
"clearMessages"
|
|
534
|
+
]);
|
|
535
|
+
function De(e) {
|
|
536
|
+
const t = Re;
|
|
537
|
+
return new Proxy(e, {
|
|
538
|
+
get(o, n, r) {
|
|
539
|
+
return typeof n == "string" && V.has(n) ? t[n] : Reflect.get(o, n, r);
|
|
540
|
+
},
|
|
541
|
+
has(o, n) {
|
|
542
|
+
return typeof n == "string" && V.has(n) ? !0 : Reflect.has(o, n);
|
|
543
|
+
}
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
const s = {
|
|
436
547
|
installed: !1,
|
|
437
|
-
options:
|
|
548
|
+
options: $
|
|
438
549
|
};
|
|
439
|
-
function
|
|
550
|
+
function U() {
|
|
440
551
|
return globalThis.window;
|
|
441
552
|
}
|
|
442
|
-
function
|
|
553
|
+
function Pe(e, t) {
|
|
443
554
|
return {
|
|
444
555
|
bootstrap: e.bootstrap ?? t?.bootstrap,
|
|
445
|
-
fallbackToNative: e.fallbackToNative ??
|
|
446
|
-
runtime: e.runtime ??
|
|
447
|
-
toastContainerSelector: e.toastContainerSelector,
|
|
448
|
-
dialogContainerSelector: e.dialogContainerSelector
|
|
556
|
+
fallbackToNative: e.fallbackToNative ?? $.fallbackToNative,
|
|
557
|
+
runtime: e.runtime ?? s.options.runtime ?? t?.Haori?.runtime,
|
|
558
|
+
toastContainerSelector: e.toastContainerSelector ?? s.options.toastContainerSelector,
|
|
559
|
+
dialogContainerSelector: e.dialogContainerSelector ?? s.options.dialogContainerSelector,
|
|
560
|
+
dialogTitle: e.dialogTitle ?? s.options.dialogTitle,
|
|
561
|
+
toastPosition: e.toastPosition ?? s.options.toastPosition,
|
|
562
|
+
toastDelay: e.toastDelay ?? s.options.toastDelay
|
|
449
563
|
};
|
|
450
564
|
}
|
|
451
|
-
function
|
|
565
|
+
function _e(e = U()) {
|
|
452
566
|
return !!(e?.Haori && e.bootstrap);
|
|
453
567
|
}
|
|
454
|
-
function
|
|
455
|
-
const t =
|
|
568
|
+
function $e(e = {}) {
|
|
569
|
+
const t = U();
|
|
456
570
|
if (!t?.Haori)
|
|
457
571
|
throw new Error("window.Haori is required before calling install().");
|
|
458
|
-
|
|
459
|
-
originalHaori
|
|
460
|
-
options:
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
572
|
+
if (s.originalHaori || (s.originalHaori = t.Haori, s.originalRuntime = t.Haori.runtime), s.options = Pe(e, t), s.options.runtime) {
|
|
573
|
+
const o = s.originalHaori ?? t.Haori;
|
|
574
|
+
typeof o.setRuntime == "function" ? o.setRuntime(s.options.runtime) : console.warn(
|
|
575
|
+
"[haori-bootstrap] Haori.setRuntime が利用できません。runtime 設定は無視されます。"
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
xe({
|
|
579
|
+
originalHaori: s.originalHaori,
|
|
580
|
+
options: s.options
|
|
581
|
+
}), t.Haori = De(s.originalHaori), s.installed = !0;
|
|
582
|
+
}
|
|
583
|
+
function Oe() {
|
|
584
|
+
const e = U();
|
|
585
|
+
if (!e || !s.originalHaori)
|
|
586
|
+
return;
|
|
587
|
+
const t = s.originalHaori;
|
|
588
|
+
typeof t.setRuntime == "function" ? t.setRuntime(s.originalRuntime) : t.runtime = s.originalRuntime, e.Haori = s.originalHaori, s.installed = !1, s.originalHaori = void 0, s.originalRuntime = void 0, s.options = $;
|
|
466
589
|
}
|
|
467
|
-
function
|
|
468
|
-
return
|
|
590
|
+
function We() {
|
|
591
|
+
return s.installed;
|
|
469
592
|
}
|
|
470
|
-
const
|
|
471
|
-
function
|
|
593
|
+
const se = "__haoriJsBootstrapAutoEnabled__";
|
|
594
|
+
function Ue() {
|
|
472
595
|
return globalThis.window;
|
|
473
596
|
}
|
|
474
|
-
function
|
|
475
|
-
return !!e[
|
|
597
|
+
function qe(e) {
|
|
598
|
+
return !!e[se];
|
|
476
599
|
}
|
|
477
|
-
function
|
|
478
|
-
e[
|
|
600
|
+
function Fe(e) {
|
|
601
|
+
e[se] = !0;
|
|
479
602
|
}
|
|
480
|
-
function
|
|
481
|
-
const e =
|
|
482
|
-
if (!(!e ||
|
|
483
|
-
if (!
|
|
603
|
+
function ze() {
|
|
604
|
+
const e = Ue();
|
|
605
|
+
if (!(!e || qe(e))) {
|
|
606
|
+
if (!_e(e)) {
|
|
484
607
|
console.warn(
|
|
485
608
|
"[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing."
|
|
486
609
|
);
|
|
487
610
|
return;
|
|
488
611
|
}
|
|
489
612
|
try {
|
|
490
|
-
|
|
613
|
+
$e({ bootstrap: e.bootstrap }), Fe(e);
|
|
491
614
|
} catch (t) {
|
|
492
615
|
console.warn("[haori-bootstrap] Auto-enable failed.", t);
|
|
493
616
|
}
|
|
494
617
|
}
|
|
495
618
|
}
|
|
496
|
-
|
|
497
|
-
const
|
|
619
|
+
ze();
|
|
620
|
+
const Ge = "0.3.2";
|
|
498
621
|
export {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
622
|
+
Re as BootstrapHaori,
|
|
623
|
+
_e as hasAutoEnablePrerequisites,
|
|
624
|
+
$e as install,
|
|
625
|
+
We as isInstalled,
|
|
626
|
+
Oe as uninstall,
|
|
627
|
+
Ge as version
|
|
505
628
|
};
|
|
506
629
|
//# sourceMappingURL=haori-bootstrap.js.map
|