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/README.ja.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js Bootstrap は、Haori.js 向けの Bootstrap ベース UI 拡張ライブラリです。
|
|
4
4
|
|
|
5
|
-
Version: 0.5.
|
|
5
|
+
Version: 0.5.4
|
|
6
6
|
|
|
7
7
|
## 概要
|
|
8
8
|
|
|
@@ -41,9 +41,9 @@ npm install haori-bootstrap
|
|
|
41
41
|
rel="stylesheet"
|
|
42
42
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css"
|
|
43
43
|
/>
|
|
44
|
-
<script src="https://cdn.jsdelivr.net/npm/haori@0.22.
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/haori@0.22.1/dist/haori.iife.js"></script>
|
|
45
45
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script>
|
|
46
|
-
<script src="https://cdn.jsdelivr.net/npm/haori-bootstrap@0.5.
|
|
46
|
+
<script src="https://cdn.jsdelivr.net/npm/haori-bootstrap@0.5.4/dist/haori-bootstrap.iife.js"></script>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
IIFE 版は、window.Haori と window.bootstrap が利用可能な場合に自動で有効化されます。
|
|
@@ -74,8 +74,8 @@ install({
|
|
|
74
74
|
| dialog(message) | 情報表示ダイアログ | Promise<void> |
|
|
75
75
|
| confirm(message) | 確認ダイアログ | Promise<boolean> |
|
|
76
76
|
| toast(message, level) | トースト通知 | Promise<void> |
|
|
77
|
-
| openDialog(element) |
|
|
78
|
-
| closeDialog(element) |
|
|
77
|
+
| openDialog(element) | 対象の Modal を開く(`.modal` 自身またはその子孫を渡す。非 `.modal` の場合は祖先方向で最も近い `.modal` に解決) | Promise<void> |
|
|
78
|
+
| closeDialog(element) | 対象の Modal を閉じる(`.modal` 自身またはその子孫を渡す。非 `.modal` の場合は祖先方向で最も近い `.modal` に解決) | Promise<void> |
|
|
79
79
|
| addErrorMessage(target, message) | 管理対象エラーメッセージの追加 | Promise<void> |
|
|
80
80
|
| addMessage(target, message, level?) | レベル付き管理対象メッセージを追加(`'error'` \| `'success'` \| `'warning'` \| `'info'`)。再呼び出し時は Bootstrap 検証クラス(`is-invalid` / `is-valid`)も切り替わります。 | Promise<void> |
|
|
81
81
|
| clearMessages(parentOrTarget) | 管理対象メッセージのみ削除 | Promise<void> |
|
|
@@ -215,12 +215,12 @@ push 後に、そのタグから GitHub Release を published にします。公
|
|
|
215
215
|
次回 patch リリースの例:
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
|
-
# version が 0.5.
|
|
218
|
+
# version が 0.5.5 になる
|
|
219
219
|
npm version patch
|
|
220
220
|
git push origin main --follow-tags
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
その後、push 済みタグの GitHub Release を作成して published にします。例として次回は `0.5.
|
|
223
|
+
その後、push 済みタグの GitHub Release を作成して published にします。例として次回は `0.5.5` タグになります。
|
|
224
224
|
|
|
225
225
|
自動公開:
|
|
226
226
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js Bootstrap is a Bootstrap-based UI extension library for Haori.js.
|
|
4
4
|
|
|
5
|
-
Version: 0.5.
|
|
5
|
+
Version: 0.5.4
|
|
6
6
|
|
|
7
7
|
## Overview
|
|
8
8
|
|
|
@@ -41,9 +41,9 @@ Load dependencies in this order for browser direct loading:
|
|
|
41
41
|
rel="stylesheet"
|
|
42
42
|
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css"
|
|
43
43
|
/>
|
|
44
|
-
<script src="https://cdn.jsdelivr.net/npm/haori@0.22.
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/haori@0.22.1/dist/haori.iife.js"></script>
|
|
45
45
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/js/bootstrap.bundle.min.js"></script>
|
|
46
|
-
<script src="https://cdn.jsdelivr.net/npm/haori-bootstrap@0.5.
|
|
46
|
+
<script src="https://cdn.jsdelivr.net/npm/haori-bootstrap@0.5.4/dist/haori-bootstrap.iife.js"></script>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
The IIFE build auto-enables when both window.Haori and window.bootstrap are available.
|
|
@@ -74,8 +74,8 @@ install({
|
|
|
74
74
|
| dialog(message) | Informational dialog | Promise<void> |
|
|
75
75
|
| confirm(message) | Confirmation dialog | Promise<boolean> |
|
|
76
76
|
| toast(message, level) | Toast notification | Promise<void> |
|
|
77
|
-
| openDialog(element) | Open
|
|
78
|
-
| closeDialog(element) | Close
|
|
77
|
+
| openDialog(element) | Open the target's modal (pass the `.modal` itself or a descendant; a non-`.modal` element resolves to its nearest ancestor `.modal`) | Promise<void> |
|
|
78
|
+
| closeDialog(element) | Close the target's modal (pass the `.modal` itself or a descendant; a non-`.modal` element resolves to its nearest ancestor `.modal`) | Promise<void> |
|
|
79
79
|
| addErrorMessage(target, message) | Append managed error messages | Promise<void> |
|
|
80
80
|
| addMessage(target, message, level?) | Append a level-aware managed message (`'error'` \| `'success'` \| `'warning'` \| `'info'`). Switches Bootstrap validation classes (`is-invalid` / `is-valid`) on re-call. | Promise<void> |
|
|
81
81
|
| clearMessages(parentOrTarget) | Remove only managed messages | Promise<void> |
|
|
@@ -212,15 +212,15 @@ git push origin main --follow-tags
|
|
|
212
212
|
|
|
213
213
|
After pushing, publish a GitHub Release from the generated version tag. The release workflow then publishes the package and uploads `dist.zip` automatically.
|
|
214
214
|
|
|
215
|
-
Example next patch release after `0.5.
|
|
215
|
+
Example next patch release after `0.5.4`:
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
|
-
# version becomes 0.5.
|
|
218
|
+
# version becomes 0.5.5
|
|
219
219
|
npm version patch
|
|
220
220
|
git push origin main --follow-tags
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
Create and publish the GitHub Release for the pushed tag such as `0.5.
|
|
223
|
+
Create and publish the GitHub Release for the pushed tag such as `0.5.5`.
|
|
224
224
|
|
|
225
225
|
Release automation:
|
|
226
226
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var HaoriBootstrap=(function(h){"use strict";function W(e){return typeof e=="function"}function G(e){return W(e?.Modal)?e?.Modal:void 0}function V(e){return W(e?.Toast)?e?.Toast:void 0}function L(e){return!!G(e)}function Se(e){return!!V(e)}function N(e,t,n){const o=G(n);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,t):new o(e,t)}function ye(e,t,n){const o=V(n);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,t):new o(e,t)}const Ie="data-haori-dialog",Me="data-haori-confirm",Le="data-haori-dialog-title",K="data-haori-dialog-ok",j="data-haori-confirm-ok",J="data-haori-confirm-cancel";let Ne=0;function X(){return{backdrop:"static",keyboard:!1}}function Q(e,t){if(t.dialogContainerSelector){const n=e.querySelector(t.dialogContainerSelector);if(n)return n}return e.body}function Y(e,t,n,o){const r=e.createElement("div");r.className="modal fade",r.tabIndex=-1,r.setAttribute(n?Me:Ie,"true"),r.setAttribute("aria-hidden","true");const i=e.createElement("div");i.className="modal-dialog modal-dialog-centered";const c=e.createElement("div");if(c.className="modal-content",o){const u=`haori-dialog-title-${++Ne}`,A=e.createElement("div");A.className="modal-header";const M=e.createElement("h5");M.className="modal-title",M.id=u,M.setAttribute(Le,"true"),M.textContent=o,A.appendChild(M),c.appendChild(A),r.setAttribute("aria-labelledby",u)}const a=e.createElement("div");a.className="modal-body";const d=e.createElement("p");d.className="mb-0",d.style.whiteSpace="pre-line",d.textContent=t,a.appendChild(d);const l=e.createElement("div");if(l.className="modal-footer",n){const u=e.createElement("button");u.type="button",u.className="btn btn-secondary",u.setAttribute(J,"true"),u.textContent="Cancel",l.appendChild(u)}const b=e.createElement("button");return b.type="button",b.className="btn btn-primary",b.setAttribute(n?j:K,"true"),b.textContent="OK",l.appendChild(b),c.append(a,l),i.appendChild(c),r.appendChild(i),r}function He(e,t){const n=globalThis.document,o=Y(n,e,!1,t.dialogTitle);Q(n,t).appendChild(o);const r=N(o,X(),t.bootstrap);return r?new Promise((i,c)=>{const a=()=>{o.removeEventListener("hidden.bs.modal",d),o.remove(),r.dispose?.(),i()},d=()=>{a()};o.querySelector(`[${K}]`)?.addEventListener("click",()=>{r.hide()},{once:!0}),o.addEventListener("hidden.bs.modal",d,{once:!0});try{r.show()}catch(b){o.removeEventListener("hidden.bs.modal",d),o.remove(),r.dispose?.(),c(b)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}function ke(e,t){const n=globalThis.document,o=Y(n,e,!0,t.dialogTitle);Q(n,t).appendChild(o);const r=N(o,X(),t.bootstrap);return r?new Promise((i,c)=>{let a=!1;const d=()=>{o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),i(a)},l=()=>{d()},b=o.querySelector(`[${j}]`),u=o.querySelector(`[${J}]`);b?.addEventListener("click",()=>{a=!0,r.hide()},{once:!0}),u?.addEventListener("click",()=>{a=!1,r.hide()},{once:!0}),o.addEventListener("hidden.bs.modal",l,{once:!0});try{r.show()}catch(A){o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),c(A)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}const p="data-haori-owned",m="data-haori-message-container",g="data-haori-invalid-target",w="data-haori-valid-target";function S(e){return e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")}function E(e){return e instanceof HTMLInputElement&&e.type==="radio"}function y(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function H(e){return Array.from(e.children).find(t=>t instanceof HTMLElement&&t.getAttribute(m)==="true")}function Z(e,t){const n=e.createElement("div");return n.setAttribute(p,"true"),n.textContent=t,n}function ee(e){return H(e)}function I(e){if(e.name){const t=e.form??e.ownerDocument,n=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e.name):e.name.replace(/(["\\])/g,"\\$1"),o=Array.from(t.querySelectorAll(`input[type="radio"][name="${n}"]`));if(o.length>0)return o}return[e]}function Be(e){const[t,...n]=e;if(!t)return;let o=t;for(;o;){if(n.every(r=>o?.contains(r)))return o;o=o.parentElement}}function $(e){const n=I(e).map(o=>o.closest(".form-check")).filter(o=>o instanceof HTMLElement);if(n.length>1){const o=Be(n);if(o&&!n.includes(o))return o}return k(e)}function k(e){const t=e.closest(".form-check");return t instanceof HTMLElement?t:void 0}function te(e){const t=e.nextElementSibling;if(t instanceof HTMLElement&&t.getAttribute(m)==="true")return t;const n=document.createElement("div");return n.className="invalid-feedback d-block",n.setAttribute(p,"true"),n.setAttribute(m,"true"),e.insertAdjacentElement("afterend",n),n}function Re(e){const t=E(e)?$(e):k(e);if(!t)return te(e);const n=H(t);if(n)return n;const o=document.createElement("div");return o.className="invalid-feedback d-block",o.setAttribute(p,"true"),o.setAttribute(m,"true"),t.appendChild(o),o}function _e(e){const t=ee(e);if(t)return t;const n=document.createElement("div");return n.className="alert alert-danger",n.setAttribute("role","alert"),n.setAttribute(p,"true"),n.setAttribute(m,"true"),e.insertAdjacentElement("afterbegin",n),n}function v(e){e.getAttribute(g)==="true"&&(e.classList.remove("is-invalid"),e.removeAttribute(g))}function T(e){e.getAttribute(w)==="true"&&(e.classList.remove("is-valid"),e.removeAttribute(w))}function ne(e){switch(e){case"success":return"alert alert-success";case"warning":return"alert alert-warning";case"info":return"alert alert-info";default:return"alert alert-danger"}}function B(e){return e==="success"?"valid-feedback d-block":"invalid-feedback d-block"}function oe(e){(E(e)?I(e):[e]).forEach(n=>{n.classList.add("is-invalid"),n.setAttribute(g,"true")})}function Pe(e){(E(e)?I(e):[e]).forEach(n=>{v(n)})}function re(e,t){const n=e.nextElementSibling;if(n instanceof HTMLElement&&n.getAttribute(m)==="true")return n.className=B(t),n;const o=document.createElement("div");return o.className=B(t),o.setAttribute(p,"true"),o.setAttribute(m,"true"),e.insertAdjacentElement("afterend",o),o}function De(e,t){const n=E(e)?$(e):k(e);if(!n)return re(e,t);const o=H(n);if(o)return o.className=B(t),o;const r=document.createElement("div");return r.className=B(t),r.setAttribute(p,"true"),r.setAttribute(m,"true"),n.appendChild(r),r}function xe(e,t){const n=ee(e);if(n)return n.className=ne(t),n;const o=document.createElement("div");return o.className=ne(t),o.setAttribute("role","alert"),o.setAttribute(p,"true"),o.setAttribute(m,"true"),e.insertAdjacentElement("afterbegin",o),o}function Oe(e,t){return(S(e)?Re(e):y(e)?te(e):_e(e)).appendChild(Z(document,t)),S(e)?oe(e):y(e)&&(e.classList.add("is-invalid"),e.setAttribute(g,"true")),Promise.resolve()}function $e(e,t,n){if((S(e)?De(e,n):y(e)?re(e,n):xe(e,n)).appendChild(Z(document,t)),S(e)){const r=E(e)?I(e):[e];n==="success"?r.forEach(i=>{v(i),i.classList.add("is-valid"),i.setAttribute(w,"true")}):!n||n==="error"?(r.forEach(i=>T(i)),oe(e)):r.forEach(i=>{T(i),v(i)})}else y(e)&&(n==="success"?(v(e),e.classList.add("is-valid"),e.setAttribute(w,"true")):!n||n==="error"?(T(e),e.classList.add("is-invalid"),e.setAttribute(g,"true")):(T(e),v(e)));return Promise.resolve()}function Ue(e){if(S(e)){const r=E(e)?$(e):k(e);(r?H(r):void 0)?.remove(),Pe(e),(E(e)?I(e):[e]).forEach(a=>T(a))}else if(y(e)){const r=e.nextElementSibling;r instanceof HTMLElement&&r.getAttribute(m)==="true"&&r.remove(),v(e),T(e)}return e.querySelectorAll(`[${m}="true"]`).forEach(r=>{r.remove()}),e.querySelectorAll(`[${g}="true"]`).forEach(r=>{v(r)}),e.querySelectorAll(`[${w}="true"]`).forEach(r=>{T(r)}),Promise.resolve()}function ie(e){e.classList.contains("modal")||e.classList.add("modal"),e.tabIndex<0&&(e.tabIndex=-1),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true")}function qe(e,t){ie(e);const n=N(e,void 0,t.bootstrap);return n?(n.show(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}function Fe(e,t){ie(e);const n=N(e,void 0,t.bootstrap);return n?(n.hide(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}const se="data-haori-toast-container",ze="data-haori-toast",We="data-haori-toast-level",Ge="data-haori-toast-accent",Ve="data-haori-toast-dismiss",ae={"top-start":"top-0 start-0","top-center":"top-0 start-50 translate-middle-x","top-end":"top-0 end-0","bottom-start":"bottom-0 start-0","bottom-center":"bottom-0 start-50 translate-middle-x","bottom-end":"bottom-0 end-0"};function Ke(e){switch(e){case"success":return{accentClassName:"bg-success",level:"success"};case"warning":return{accentClassName:"bg-warning",level:"warning"};case"error":return{accentClassName:"bg-danger",level:"error"};default:return{accentClassName:"bg-info",level:"info"}}}function je(e,t){if(t.toastContainerSelector){const n=e.querySelector(t.toastContainerSelector);if(n)return n}return e.body}function Je(e,t){const n=je(e,t),o=ae[t.toastPosition??"bottom-end"],r=n.querySelector(`[${se}="true"]`);if(r){const c=Object.values(ae).flatMap(a=>a.split(" "));return r.classList.remove(...c),r.classList.add(...o.split(" ")),r}const i=e.createElement("div");return i.className=`toast-container position-fixed ${o} p-3`,i.setAttribute(se,"true"),n.appendChild(i),i}function Xe(e,t,n){const o=globalThis.document,r=Ke(t),i=o.createElement("div");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(ze,"true"),i.setAttribute(We,r.level);const c=o.createElement("div");c.className="d-flex align-items-stretch";const a=o.createElement("div");a.className=`flex-shrink-0 rounded-start ${r.accentClassName}`,a.style.width="0.375rem",a.setAttribute(Ge,"true");const d=o.createElement("div");d.className="toast-body",d.style.whiteSpace="pre-line",d.textContent=e;const l=o.createElement("button");l.type="button",l.className="btn-close me-2 m-auto flex-shrink-0",l.setAttribute("aria-label","Close"),l.setAttribute(Ve,"true"),c.appendChild(a),c.appendChild(d),c.appendChild(l),i.appendChild(c),Je(o,n).appendChild(i);const b=n.toastDelay!==void 0?{delay:n.toastDelay}:void 0,u=ye(i,b,n.bootstrap);if(!u)return i.remove(),Promise.reject(new Error("Bootstrap Toast is unavailable."));l.addEventListener("click",()=>{u.hide?.()}),i.addEventListener("hidden.bs.toast",()=>{i.remove(),u.dispose?.()},{once:!0});try{return u.show(),Promise.resolve()}catch(A){return i.remove(),u.dispose?.(),Promise.reject(A)}}let f={options:{fallbackToNative:!0}};function C(e){return e.replace(/\\n/g,`
|
|
2
|
-
`)}function
|
|
1
|
+
var HaoriBootstrap=(function(h){"use strict";function W(e){return typeof e=="function"}function G(e){return W(e?.Modal)?e?.Modal:void 0}function j(e){return W(e?.Toast)?e?.Toast:void 0}function L(e){return!!G(e)}function ye(e){return!!j(e)}function N(e,n,t){const o=G(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}function Ie(e,n,t){const o=j(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}const Me="data-haori-dialog",Le="data-haori-confirm",Ne="data-haori-dialog-title",V="data-haori-dialog-ok",K="data-haori-confirm-ok",J="data-haori-confirm-cancel";let He=0;function X(){return{backdrop:"static",keyboard:!1}}function Q(e,n){if(n.dialogContainerSelector){const t=e.querySelector(n.dialogContainerSelector);if(t)return t}return e.body}function Y(e,n,t,o){const r=e.createElement("div");r.className="modal fade",r.tabIndex=-1,r.setAttribute(t?Le:Me,"true"),r.setAttribute("aria-hidden","true");const i=e.createElement("div");i.className="modal-dialog modal-dialog-centered";const c=e.createElement("div");if(c.className="modal-content",o){const u=`haori-dialog-title-${++He}`,A=e.createElement("div");A.className="modal-header";const M=e.createElement("h5");M.className="modal-title",M.id=u,M.setAttribute(Ne,"true"),M.textContent=o,A.appendChild(M),c.appendChild(A),r.setAttribute("aria-labelledby",u)}const a=e.createElement("div");a.className="modal-body";const d=e.createElement("p");d.className="mb-0",d.style.whiteSpace="pre-line",d.textContent=n,a.appendChild(d);const l=e.createElement("div");if(l.className="modal-footer",t){const u=e.createElement("button");u.type="button",u.className="btn btn-secondary",u.setAttribute(J,"true"),u.textContent="Cancel",l.appendChild(u)}const b=e.createElement("button");return b.type="button",b.className="btn btn-primary",b.setAttribute(t?K:V,"true"),b.textContent="OK",l.appendChild(b),c.append(a,l),i.appendChild(c),r.appendChild(i),r}function ke(e,n){const t=globalThis.document,o=Y(t,e,!1,n.dialogTitle);Q(t,n).appendChild(o);const r=N(o,X(),n.bootstrap);return r?new Promise((i,c)=>{const a=()=>{o.removeEventListener("hidden.bs.modal",d),o.remove(),r.dispose?.(),i()},d=()=>{a()};o.querySelector(`[${V}]`)?.addEventListener("click",()=>{r.hide()},{once:!0}),o.addEventListener("hidden.bs.modal",d,{once:!0});try{r.show()}catch(b){o.removeEventListener("hidden.bs.modal",d),o.remove(),r.dispose?.(),c(b)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}function Be(e,n){const t=globalThis.document,o=Y(t,e,!0,n.dialogTitle);Q(t,n).appendChild(o);const r=N(o,X(),n.bootstrap);return r?new Promise((i,c)=>{let a=!1;const d=()=>{o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),i(a)},l=()=>{d()},b=o.querySelector(`[${K}]`),u=o.querySelector(`[${J}]`);b?.addEventListener("click",()=>{a=!0,r.hide()},{once:!0}),u?.addEventListener("click",()=>{a=!1,r.hide()},{once:!0}),o.addEventListener("hidden.bs.modal",l,{once:!0});try{r.show()}catch(A){o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),c(A)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}const p="data-haori-owned",m="data-haori-message-container",g="data-haori-invalid-target",w="data-haori-valid-target";function S(e){return e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")}function E(e){return e instanceof HTMLInputElement&&e.type==="radio"}function y(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function H(e){return Array.from(e.children).find(n=>n instanceof HTMLElement&&n.getAttribute(m)==="true")}function Z(e,n){const t=e.createElement("div");return t.setAttribute(p,"true"),t.textContent=n,t}function ee(e){return H(e)}function I(e){if(e.name){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(n.querySelectorAll(`input[type="radio"][name="${t}"]`));if(o.length>0)return o}return[e]}function Re(e){const[n,...t]=e;if(!n)return;let o=n;for(;o;){if(t.every(r=>o?.contains(r)))return o;o=o.parentElement}}function $(e){const t=I(e).map(o=>o.closest(".form-check")).filter(o=>o instanceof HTMLElement);if(t.length>1){const o=Re(t);if(o&&!t.includes(o))return o}return k(e)}function k(e){const n=e.closest(".form-check");return n instanceof HTMLElement?n:void 0}function te(e){const n=e.nextElementSibling;if(n instanceof HTMLElement&&n.getAttribute(m)==="true")return n;const t=document.createElement("div");return t.className="invalid-feedback d-block",t.setAttribute(p,"true"),t.setAttribute(m,"true"),e.insertAdjacentElement("afterend",t),t}function Pe(e){const n=E(e)?$(e):k(e);if(!n)return te(e);const t=H(n);if(t)return t;const o=document.createElement("div");return o.className="invalid-feedback d-block",o.setAttribute(p,"true"),o.setAttribute(m,"true"),n.appendChild(o),o}function _e(e){const n=ee(e);if(n)return n;const t=document.createElement("div");return t.className="alert alert-danger",t.setAttribute("role","alert"),t.setAttribute(p,"true"),t.setAttribute(m,"true"),e.insertAdjacentElement("afterbegin",t),t}function v(e){e.getAttribute(g)==="true"&&(e.classList.remove("is-invalid"),e.removeAttribute(g))}function T(e){e.getAttribute(w)==="true"&&(e.classList.remove("is-valid"),e.removeAttribute(w))}function ne(e){switch(e){case"success":return"alert alert-success";case"warning":return"alert alert-warning";case"info":return"alert alert-info";default:return"alert alert-danger"}}function B(e){return e==="success"?"valid-feedback d-block":"invalid-feedback d-block"}function oe(e){(E(e)?I(e):[e]).forEach(t=>{t.classList.add("is-invalid"),t.setAttribute(g,"true")})}function De(e){(E(e)?I(e):[e]).forEach(t=>{v(t)})}function re(e,n){const t=e.nextElementSibling;if(t instanceof HTMLElement&&t.getAttribute(m)==="true")return t.className=B(n),t;const o=document.createElement("div");return o.className=B(n),o.setAttribute(p,"true"),o.setAttribute(m,"true"),e.insertAdjacentElement("afterend",o),o}function xe(e,n){const t=E(e)?$(e):k(e);if(!t)return re(e,n);const o=H(t);if(o)return o.className=B(n),o;const r=document.createElement("div");return r.className=B(n),r.setAttribute(p,"true"),r.setAttribute(m,"true"),t.appendChild(r),r}function Oe(e,n){const t=ee(e);if(t)return t.className=ne(n),t;const o=document.createElement("div");return o.className=ne(n),o.setAttribute("role","alert"),o.setAttribute(p,"true"),o.setAttribute(m,"true"),e.insertAdjacentElement("afterbegin",o),o}function $e(e,n){return(S(e)?Pe(e):y(e)?te(e):_e(e)).appendChild(Z(document,n)),S(e)?oe(e):y(e)&&(e.classList.add("is-invalid"),e.setAttribute(g,"true")),Promise.resolve()}function Ue(e,n,t){if((S(e)?xe(e,t):y(e)?re(e,t):Oe(e,t)).appendChild(Z(document,n)),S(e)){const r=E(e)?I(e):[e];t==="success"?r.forEach(i=>{v(i),i.classList.add("is-valid"),i.setAttribute(w,"true")}):!t||t==="error"?(r.forEach(i=>T(i)),oe(e)):r.forEach(i=>{T(i),v(i)})}else y(e)&&(t==="success"?(v(e),e.classList.add("is-valid"),e.setAttribute(w,"true")):!t||t==="error"?(T(e),e.classList.add("is-invalid"),e.setAttribute(g,"true")):(T(e),v(e)));return Promise.resolve()}function qe(e){if(S(e)){const r=E(e)?$(e):k(e);(r?H(r):void 0)?.remove(),De(e),(E(e)?I(e):[e]).forEach(a=>T(a))}else if(y(e)){const r=e.nextElementSibling;r instanceof HTMLElement&&r.getAttribute(m)==="true"&&r.remove(),v(e),T(e)}return e.querySelectorAll(`[${m}="true"]`).forEach(r=>{r.remove()}),e.querySelectorAll(`[${g}="true"]`).forEach(r=>{v(r)}),e.querySelectorAll(`[${w}="true"]`).forEach(r=>{T(r)}),Promise.resolve()}function ie(e){return e.classList.contains("modal")?e:e.closest(".modal")}function se(e){e.tabIndex<0&&(e.tabIndex=-1),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true")}function Fe(e,n){const t=ie(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));se(t);const o=N(t,void 0,n.bootstrap);return o?(o.show(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}function ze(e,n){const t=ie(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));se(t);const o=N(t,void 0,n.bootstrap);return o?(o.hide(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}const ae="data-haori-toast-container",We="data-haori-toast",Ge="data-haori-toast-level",je="data-haori-toast-accent",Ve="data-haori-toast-dismiss",ce={"top-start":"top-0 start-0","top-center":"top-0 start-50 translate-middle-x","top-end":"top-0 end-0","bottom-start":"bottom-0 start-0","bottom-center":"bottom-0 start-50 translate-middle-x","bottom-end":"bottom-0 end-0"};function Ke(e){switch(e){case"success":return{accentClassName:"bg-success",level:"success"};case"warning":return{accentClassName:"bg-warning",level:"warning"};case"error":return{accentClassName:"bg-danger",level:"error"};default:return{accentClassName:"bg-info",level:"info"}}}function Je(e,n){if(n.toastContainerSelector){const t=e.querySelector(n.toastContainerSelector);if(t)return t}return e.body}function Xe(e,n){const t=Je(e,n),o=ce[n.toastPosition??"bottom-end"],r=t.querySelector(`[${ae}="true"]`);if(r){const c=Object.values(ce).flatMap(a=>a.split(" "));return r.classList.remove(...c),r.classList.add(...o.split(" ")),r}const i=e.createElement("div");return i.className=`toast-container position-fixed ${o} p-3`,i.setAttribute(ae,"true"),t.appendChild(i),i}function Qe(e,n,t){const o=globalThis.document,r=Ke(n),i=o.createElement("div");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(We,"true"),i.setAttribute(Ge,r.level);const c=o.createElement("div");c.className="d-flex align-items-stretch";const a=o.createElement("div");a.className=`flex-shrink-0 rounded-start ${r.accentClassName}`,a.style.width="0.375rem",a.setAttribute(je,"true");const d=o.createElement("div");d.className="toast-body",d.style.whiteSpace="pre-line",d.textContent=e;const l=o.createElement("button");l.type="button",l.className="btn-close me-2 m-auto flex-shrink-0",l.setAttribute("aria-label","Close"),l.setAttribute(Ve,"true"),c.appendChild(a),c.appendChild(d),c.appendChild(l),i.appendChild(c),Xe(o,t).appendChild(i);const b=t.toastDelay!==void 0?{delay:t.toastDelay}:void 0,u=Ie(i,b,t.bootstrap);if(!u)return i.remove(),Promise.reject(new Error("Bootstrap Toast is unavailable."));l.addEventListener("click",()=>{u.hide?.()}),i.addEventListener("hidden.bs.toast",()=>{i.remove(),u.dispose?.()},{once:!0});try{return u.show(),Promise.resolve()}catch(A){return i.remove(),u.dispose?.(),Promise.reject(A)}}let f={options:{fallbackToNative:!0}};function C(e){return e.replace(/\\n/g,`
|
|
2
|
+
`)}function le(){return globalThis.window}function U(e){return Promise.resolve(e).then(()=>{})}function R(e){const n=f.originalHaori?.[e];return typeof n=="function"?n:void 0}function P(e){console.warn(`[haori-bootstrap] ${e} skipped because Bootstrap support is unavailable.`)}function ue(e){const n=C(e),t=R("dialog");if(t)return U(t(n));const o=le();return f.options.fallbackToNative&&typeof o?.alert=="function"?(o.alert(n),Promise.resolve()):(P("dialog"),Promise.resolve())}function de(e){const n=C(e),t=R("confirm");if(t)return Promise.resolve(t(n)).then(r=>!!r);const o=le();return f.options.fallbackToNative&&typeof o?.confirm=="function"?Promise.resolve(o.confirm(n)):(P("confirm"),Promise.resolve(!1))}function fe(e,n){const t=C(e),o=R("toast");return o?U(o(t,n)):(P("toast"),Promise.resolve())}function _(e,n){const t=R(e);return t?U(t(n)):(P(e),Promise.resolve())}function Ye(e){f=e}class me{static dialog(n){const t=C(n);return L(f.options.bootstrap)?ke(t,f.options).catch(()=>ue(t)):ue(t)}static confirm(n){const t=C(n);return L(f.options.bootstrap)?Be(t,f.options).catch(()=>de(t)):de(t)}static toast(n,t){const o=C(n);return ye(f.options.bootstrap)?Qe(o,t,f.options).catch(()=>fe(o,t)):fe(o,t)}static openDialog(n){return L(f.options.bootstrap)?Fe(n,f.options).catch(()=>_("openDialog",n)):_("openDialog",n)}static closeDialog(n){return L(f.options.bootstrap)?ze(n,f.options).catch(()=>_("closeDialog",n)):_("closeDialog",n)}static addErrorMessage(n,t){return $e(n,t)}static addMessage(n,t,o){return Ue(n,t,o)}static clearMessages(n){return qe(n)}}const Ze="haori-bootstrap:collapse:",D="data-haori-persist";let x=!1,O,q;function be(e){return Ze+e}function et(e){try{const n=window.sessionStorage.getItem(be(e));return n==="shown"||n==="hidden"?n:void 0}catch{return}}function tt(e,n){try{window.sessionStorage.setItem(be(e),n)}catch{}}function he(e,n){const t=e.id,o=[`[data-bs-toggle="collapse"][data-bs-target="#${t}"]`];if(t&&o.push(`[data-bs-toggle="collapse"][href="#${t}"]`),!t)return;e.ownerDocument.querySelectorAll(o.join(",")).forEach(i=>{i.setAttribute("aria-expanded",n?"true":"false"),i.classList.toggle("collapsed",!n)})}function pe(e){const n=e.getAttribute(D);if(!n)return;const t=et(n);if(!t)return;const o=e.classList.contains("show");t==="shown"&&!o?(e.classList.add("show"),he(e,!0)):t==="hidden"&&o&&(e.classList.remove("show"),he(e,!1))}function Ee(e){e instanceof HTMLElement&&e.hasAttribute(D)&&pe(e),e.querySelectorAll(`[${D}]`).forEach(pe)}function ve(e,n){const t=e.target;if(!(t instanceof HTMLElement))return;const o=t.getAttribute(D);o&&tt(o,n)}const Te=e=>ve(e,"shown"),Ae=e=>ve(e,"hidden");function nt(e=document){if(x)return;x=!0,q=e,e.addEventListener("shown.bs.collapse",Te),e.addEventListener("hidden.bs.collapse",Ae);const n=()=>{Ee(e),O=new MutationObserver(t=>{for(const o of t)o.addedNodes.forEach(r=>{r instanceof HTMLElement&&Ee(r)})}),e.body&&O.observe(e.body,{childList:!0,subtree:!0})};e.body?n():e.addEventListener("DOMContentLoaded",n,{once:!0})}function ot(e=q??document){x&&(x=!1,e.removeEventListener("shown.bs.collapse",Te),e.removeEventListener("hidden.bs.collapse",Ae),O?.disconnect(),O=void 0,q=void 0)}const F={fallbackToNative:!0},ge=new Set(["dialog","confirm","toast","openDialog","closeDialog","addErrorMessage","addMessage","clearMessages"]);function rt(e){const n=me;return new Proxy(e,{get(t,o,r){return typeof o=="string"&&ge.has(o)?n[o]:Reflect.get(t,o,r)},has(t,o){return typeof o=="string"&&ge.has(o)?!0:Reflect.has(t,o)}})}const s={installed:!1,options:F};function z(){return globalThis.window}function it(e,n){return{bootstrap:e.bootstrap??n?.bootstrap,fallbackToNative:e.fallbackToNative??F.fallbackToNative,runtime:e.runtime??s.options.runtime??n?.Haori?.runtime,toastContainerSelector:e.toastContainerSelector??s.options.toastContainerSelector,dialogContainerSelector:e.dialogContainerSelector??s.options.dialogContainerSelector,dialogTitle:e.dialogTitle??s.options.dialogTitle,toastPosition:e.toastPosition??s.options.toastPosition,toastDelay:e.toastDelay??s.options.toastDelay}}function Ce(e=z()){return!!(e?.Haori&&e.bootstrap)}function we(e={}){const n=z();if(!n?.Haori)throw new Error("window.Haori is required before calling install().");if(s.originalHaori||(s.originalHaori=n.Haori,s.originalRuntime=n.Haori.runtime),s.options=it(e,n),s.options.runtime){const t=s.originalHaori??n.Haori;typeof t.setRuntime=="function"?t.setRuntime(s.options.runtime):console.warn("[haori-bootstrap] Haori.setRuntime が利用できません。runtime 設定は無視されます。")}Ye({originalHaori:s.originalHaori,options:s.options}),n.Haori=rt(s.originalHaori),nt(),s.installed=!0}function st(){const e=z();if(!e||!s.originalHaori)return;const n=s.originalHaori;typeof n.setRuntime=="function"?n.setRuntime(s.originalRuntime):n.runtime=s.originalRuntime,e.Haori=s.originalHaori,ot(),s.installed=!1,s.originalHaori=void 0,s.originalRuntime=void 0,s.options=F}function at(){return s.installed}const Se="__haoriJsBootstrapAutoEnabled__";function ct(){return globalThis.window}function lt(e){return!!e[Se]}function ut(e){e[Se]=!0}function dt(){const e=ct();if(!(!e||lt(e))){if(!Ce(e)){console.warn("[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing.");return}try{we({bootstrap:e.bootstrap}),ut(e)}catch(n){console.warn("[haori-bootstrap] Auto-enable failed.",n)}}}dt();const ft="0.5.4";return h.BootstrapHaori=me,h.hasAutoEnablePrerequisites=Ce,h.install=we,h.isInstalled=at,h.uninstall=st,h.version=ft,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),h})({});
|
|
3
3
|
//# sourceMappingURL=haori-bootstrap.iife.js.map
|