haori-bootstrap 0.5.3 → 0.5.5

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Haori.js Bootstrap は、Haori.js 向けの Bootstrap ベース UI 拡張ライブラリです。
4
4
 
5
- Version: 0.5.3
5
+ Version: 0.5.5
6
6
 
7
7
  ## 概要
8
8
 
@@ -43,7 +43,7 @@ npm install haori-bootstrap
43
43
  />
44
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.3/dist/haori-bootstrap.iife.js"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/haori-bootstrap@0.5.5/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) | 任意要素の表示 | Promise<void> |
78
- | closeDialog(element) | 任意要素の非表示 | Promise<void> |
77
+ | openDialog(element) | 対象の Modal を開く(`.modal` 自身またはその子孫を渡す。非 `.modal` の場合は祖先方向で最も近い `.modal` に解決)。表示前に対象 Modal 配下の管理メッセージと `is-invalid` / `is-valid` 状態をクリアするため、再表示時はクリーンな状態で開く。 | 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.4 になる
218
+ # version が 0.5.6 になる
219
219
  npm version patch
220
220
  git push origin main --follow-tags
221
221
  ```
222
222
 
223
- その後、push 済みタグの GitHub Release を作成して published にします。例として次回は `0.5.4` タグになります。
223
+ その後、push 済みタグの GitHub Release を作成して published にします。例として次回は `0.5.6` タグになります。
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.3
5
+ Version: 0.5.5
6
6
 
7
7
  ## Overview
8
8
 
@@ -43,7 +43,7 @@ Load dependencies in this order for browser direct loading:
43
43
  />
44
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.3/dist/haori-bootstrap.iife.js"></script>
46
+ <script src="https://cdn.jsdelivr.net/npm/haori-bootstrap@0.5.5/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 an arbitrary dialog element | Promise<void> |
78
- | closeDialog(element) | Close an arbitrary dialog element | Promise<void> |
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`). Managed messages and `is-invalid` / `is-valid` state under the modal are cleared before it is shown, so a reopened form starts clean. | 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.3`:
215
+ Example next patch release after `0.5.5`:
216
216
 
217
217
  ```bash
218
- # version becomes 0.5.4
218
+ # version becomes 0.5.6
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.4`.
223
+ Create and publish the GitHub Release for the pushed tag such as `0.5.6`.
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 ce(){return globalThis.window}function U(e){return Promise.resolve(e).then(()=>{})}function R(e){const t=f.originalHaori?.[e];return typeof t=="function"?t:void 0}function _(e){console.warn(`[haori-bootstrap] ${e} skipped because Bootstrap support is unavailable.`)}function le(e){const t=C(e),n=R("dialog");if(n)return U(n(t));const o=ce();return f.options.fallbackToNative&&typeof o?.alert=="function"?(o.alert(t),Promise.resolve()):(_("dialog"),Promise.resolve())}function ue(e){const t=C(e),n=R("confirm");if(n)return Promise.resolve(n(t)).then(r=>!!r);const o=ce();return f.options.fallbackToNative&&typeof o?.confirm=="function"?Promise.resolve(o.confirm(t)):(_("confirm"),Promise.resolve(!1))}function de(e,t){const n=C(e),o=R("toast");return o?U(o(n,t)):(_("toast"),Promise.resolve())}function P(e,t){const n=R(e);return n?U(n(t)):(_(e),Promise.resolve())}function Qe(e){f=e}class fe{static dialog(t){const n=C(t);return L(f.options.bootstrap)?He(n,f.options).catch(()=>le(n)):le(n)}static confirm(t){const n=C(t);return L(f.options.bootstrap)?ke(n,f.options).catch(()=>ue(n)):ue(n)}static toast(t,n){const o=C(t);return Se(f.options.bootstrap)?Xe(o,n,f.options).catch(()=>de(o,n)):de(o,n)}static openDialog(t){return L(f.options.bootstrap)?qe(t,f.options).catch(()=>P("openDialog",t)):P("openDialog",t)}static closeDialog(t){return L(f.options.bootstrap)?Fe(t,f.options).catch(()=>P("closeDialog",t)):P("closeDialog",t)}static addErrorMessage(t,n){return Oe(t,n)}static addMessage(t,n,o){return $e(t,n,o)}static clearMessages(t){return Ue(t)}}const Ye="haori-bootstrap:collapse:",D="data-haori-persist";let x=!1,O,q;function me(e){return Ye+e}function Ze(e){try{const t=window.sessionStorage.getItem(me(e));return t==="shown"||t==="hidden"?t:void 0}catch{return}}function et(e,t){try{window.sessionStorage.setItem(me(e),t)}catch{}}function be(e,t){const n=e.id,o=[`[data-bs-toggle="collapse"][data-bs-target="#${n}"]`];if(n&&o.push(`[data-bs-toggle="collapse"][href="#${n}"]`),!n)return;e.ownerDocument.querySelectorAll(o.join(",")).forEach(i=>{i.setAttribute("aria-expanded",t?"true":"false"),i.classList.toggle("collapsed",!t)})}function he(e){const t=e.getAttribute(D);if(!t)return;const n=Ze(t);if(!n)return;const o=e.classList.contains("show");n==="shown"&&!o?(e.classList.add("show"),be(e,!0)):n==="hidden"&&o&&(e.classList.remove("show"),be(e,!1))}function pe(e){e instanceof HTMLElement&&e.hasAttribute(D)&&he(e),e.querySelectorAll(`[${D}]`).forEach(he)}function Ee(e,t){const n=e.target;if(!(n instanceof HTMLElement))return;const o=n.getAttribute(D);o&&et(o,t)}const ve=e=>Ee(e,"shown"),Te=e=>Ee(e,"hidden");function tt(e=document){if(x)return;x=!0,q=e,e.addEventListener("shown.bs.collapse",ve),e.addEventListener("hidden.bs.collapse",Te);const t=()=>{pe(e),O=new MutationObserver(n=>{for(const o of n)o.addedNodes.forEach(r=>{r instanceof HTMLElement&&pe(r)})}),e.body&&O.observe(e.body,{childList:!0,subtree:!0})};e.body?t():e.addEventListener("DOMContentLoaded",t,{once:!0})}function nt(e=q??document){x&&(x=!1,e.removeEventListener("shown.bs.collapse",ve),e.removeEventListener("hidden.bs.collapse",Te),O?.disconnect(),O=void 0,q=void 0)}const F={fallbackToNative:!0},Ae=new Set(["dialog","confirm","toast","openDialog","closeDialog","addErrorMessage","addMessage","clearMessages"]);function ot(e){const t=fe;return new Proxy(e,{get(n,o,r){return typeof o=="string"&&Ae.has(o)?t[o]:Reflect.get(n,o,r)},has(n,o){return typeof o=="string"&&Ae.has(o)?!0:Reflect.has(n,o)}})}const s={installed:!1,options:F};function z(){return globalThis.window}function rt(e,t){return{bootstrap:e.bootstrap??t?.bootstrap,fallbackToNative:e.fallbackToNative??F.fallbackToNative,runtime:e.runtime??s.options.runtime??t?.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 ge(e=z()){return!!(e?.Haori&&e.bootstrap)}function Ce(e={}){const t=z();if(!t?.Haori)throw new Error("window.Haori is required before calling install().");if(s.originalHaori||(s.originalHaori=t.Haori,s.originalRuntime=t.Haori.runtime),s.options=rt(e,t),s.options.runtime){const n=s.originalHaori??t.Haori;typeof n.setRuntime=="function"?n.setRuntime(s.options.runtime):console.warn("[haori-bootstrap] Haori.setRuntime が利用できません。runtime 設定は無視されます。")}Qe({originalHaori:s.originalHaori,options:s.options}),t.Haori=ot(s.originalHaori),tt(),s.installed=!0}function it(){const e=z();if(!e||!s.originalHaori)return;const t=s.originalHaori;typeof t.setRuntime=="function"?t.setRuntime(s.originalRuntime):t.runtime=s.originalRuntime,e.Haori=s.originalHaori,nt(),s.installed=!1,s.originalHaori=void 0,s.originalRuntime=void 0,s.options=F}function st(){return s.installed}const we="__haoriJsBootstrapAutoEnabled__";function at(){return globalThis.window}function ct(e){return!!e[we]}function lt(e){e[we]=!0}function ut(){const e=at();if(!(!e||ct(e))){if(!ge(e)){console.warn("[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing.");return}try{Ce({bootstrap:e.bootstrap}),lt(e)}catch(t){console.warn("[haori-bootstrap] Auto-enable failed.",t)}}}ut();const dt="0.5.3";return h.BootstrapHaori=fe,h.hasAutoEnablePrerequisites=ge,h.install=Ce,h.isInstalled=st,h.uninstall=it,h.version=dt,Object.defineProperty(h,Symbol.toStringTag,{value:"Module"}),h})({});
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 Ie(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 Me(e,n,t){const o=j(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}const Le="data-haori-dialog",Ne="data-haori-confirm",He="data-haori-dialog-title",V="data-haori-dialog-ok",K="data-haori-confirm-ok",J="data-haori-confirm-cancel";let ke=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?Ne:Le,"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-${++ke}`,A=e.createElement("div");A.className="modal-header";const M=e.createElement("h5");M.className="modal-title",M.id=u,M.setAttribute(He,"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 Be(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 Re(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 Pe(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=Pe(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 _e(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 De(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 xe(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 Oe(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 $e(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 Ue(e,n){return(S(e)?_e(e):y(e)?te(e):De(e)).appendChild(Z(document,n)),S(e)?oe(e):y(e)&&(e.classList.add("is-invalid"),e.setAttribute(g,"true")),Promise.resolve()}function qe(e,n,t){if((S(e)?Oe(e,t):y(e)?re(e,t):$e(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 ie(e){if(S(e)){const r=E(e)?$(e):k(e);(r?H(r):void 0)?.remove(),xe(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 se(e){return e.classList.contains("modal")?e:e.closest(".modal")}function ae(e){e.tabIndex<0&&(e.tabIndex=-1),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true")}function Fe(e,n){const t=se(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));ae(t),ie(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=se(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));ae(t);const o=N(t,void 0,n.bootstrap);return o?(o.hide(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}const ce="data-haori-toast-container",We="data-haori-toast",Ge="data-haori-toast-level",je="data-haori-toast-accent",Ve="data-haori-toast-dismiss",le={"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=le[n.toastPosition??"bottom-end"],r=t.querySelector(`[${ce}="true"]`);if(r){const c=Object.values(le).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(ce,"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=Me(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 ue(){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 de(e){const n=C(e),t=R("dialog");if(t)return U(t(n));const o=ue();return f.options.fallbackToNative&&typeof o?.alert=="function"?(o.alert(n),Promise.resolve()):(P("dialog"),Promise.resolve())}function fe(e){const n=C(e),t=R("confirm");if(t)return Promise.resolve(t(n)).then(r=>!!r);const o=ue();return f.options.fallbackToNative&&typeof o?.confirm=="function"?Promise.resolve(o.confirm(n)):(P("confirm"),Promise.resolve(!1))}function me(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 be{static dialog(n){const t=C(n);return L(f.options.bootstrap)?Be(t,f.options).catch(()=>de(t)):de(t)}static confirm(n){const t=C(n);return L(f.options.bootstrap)?Re(t,f.options).catch(()=>fe(t)):fe(t)}static toast(n,t){const o=C(n);return Ie(f.options.bootstrap)?Qe(o,t,f.options).catch(()=>me(o,t)):me(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 Ue(n,t)}static addMessage(n,t,o){return qe(n,t,o)}static clearMessages(n){return ie(n)}}const Ze="haori-bootstrap:collapse:",D="data-haori-persist";let x=!1,O,q;function he(e){return Ze+e}function et(e){try{const n=window.sessionStorage.getItem(he(e));return n==="shown"||n==="hidden"?n:void 0}catch{return}}function tt(e,n){try{window.sessionStorage.setItem(he(e),n)}catch{}}function pe(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 Ee(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"),pe(e,!0)):t==="hidden"&&o&&(e.classList.remove("show"),pe(e,!1))}function ve(e){e instanceof HTMLElement&&e.hasAttribute(D)&&Ee(e),e.querySelectorAll(`[${D}]`).forEach(Ee)}function Te(e,n){const t=e.target;if(!(t instanceof HTMLElement))return;const o=t.getAttribute(D);o&&tt(o,n)}const Ae=e=>Te(e,"shown"),ge=e=>Te(e,"hidden");function nt(e=document){if(x)return;x=!0,q=e,e.addEventListener("shown.bs.collapse",Ae),e.addEventListener("hidden.bs.collapse",ge);const n=()=>{ve(e),O=new MutationObserver(t=>{for(const o of t)o.addedNodes.forEach(r=>{r instanceof HTMLElement&&ve(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",Ae),e.removeEventListener("hidden.bs.collapse",ge),O?.disconnect(),O=void 0,q=void 0)}const F={fallbackToNative:!0},Ce=new Set(["dialog","confirm","toast","openDialog","closeDialog","addErrorMessage","addMessage","clearMessages"]);function rt(e){const n=be;return new Proxy(e,{get(t,o,r){return typeof o=="string"&&Ce.has(o)?n[o]:Reflect.get(t,o,r)},has(t,o){return typeof o=="string"&&Ce.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 we(e=z()){return!!(e?.Haori&&e.bootstrap)}function Se(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 ye="__haoriJsBootstrapAutoEnabled__";function ct(){return globalThis.window}function lt(e){return!!e[ye]}function ut(e){e[ye]=!0}function dt(){const e=ct();if(!(!e||lt(e))){if(!we(e)){console.warn("[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing.");return}try{Se({bootstrap:e.bootstrap}),ut(e)}catch(n){console.warn("[haori-bootstrap] Auto-enable failed.",n)}}}dt();const ft="0.5.5";return h.BootstrapHaori=be,h.hasAutoEnablePrerequisites=we,h.install=Se,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