haori-bootstrap 0.5.4 → 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 +5 -5
- package/README.md +6 -6
- package/dist/haori-bootstrap.iife.js +2 -2
- package/dist/haori-bootstrap.iife.js.map +1 -1
- package/dist/haori-bootstrap.js +49 -49
- package/dist/haori-bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/modal.d.ts +4 -0
- 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.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.
|
|
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,7 +74,7 @@ install({
|
|
|
74
74
|
| dialog(message) | 情報表示ダイアログ | Promise<void> |
|
|
75
75
|
| confirm(message) | 確認ダイアログ | Promise<boolean> |
|
|
76
76
|
| toast(message, level) | トースト通知 | Promise<void> |
|
|
77
|
-
| openDialog(element) | 対象の Modal を開く(`.modal` 自身またはその子孫を渡す。非 `.modal` の場合は祖先方向で最も近い `.modal`
|
|
77
|
+
| openDialog(element) | 対象の Modal を開く(`.modal` 自身またはその子孫を渡す。非 `.modal` の場合は祖先方向で最も近い `.modal` に解決)。表示前に対象 Modal 配下の管理メッセージと `is-invalid` / `is-valid` 状態をクリアするため、再表示時はクリーンな状態で開く。 | Promise<void> |
|
|
78
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> |
|
|
@@ -215,12 +215,12 @@ push 後に、そのタグから GitHub Release を published にします。公
|
|
|
215
215
|
次回 patch リリースの例:
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
|
-
# version が 0.5.
|
|
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.
|
|
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.
|
|
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.
|
|
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,7 +74,7 @@ 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 the target's modal (pass the `.modal` itself or a descendant; a non-`.modal` element resolves to its nearest ancestor `.modal`) | 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
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> |
|
|
@@ -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.5`:
|
|
216
216
|
|
|
217
217
|
```bash
|
|
218
|
-
# version becomes 0.5.
|
|
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.
|
|
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 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
|
|
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
|