haori-bootstrap 0.5.25 → 0.5.26
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 +31 -5
- package/README.md +32 -6
- package/dist/config.d.ts +13 -0
- package/dist/haori-bootstrap.iife.js +2 -2
- package/dist/haori-bootstrap.iife.js.map +1 -1
- package/dist/haori-bootstrap.js +227 -199
- package/dist/haori-bootstrap.js.map +1 -1
- package/dist/index.d.ts +1 -1
- 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.26
|
|
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.
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/haori@0.43.0/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.26/dist/haori-bootstrap.iife.js"></script>
|
|
47
47
|
```
|
|
48
48
|
|
|
49
49
|
IIFE 版は、window.Haori と window.bootstrap が利用可能な場合に自動で有効化されます。
|
|
@@ -94,6 +94,32 @@ install({
|
|
|
94
94
|
|
|
95
95
|
ボタンの識別属性(`data-haori-confirm-ok` / `data-haori-confirm-cancel` / `data-haori-dialog-ok`)は文言を変えても変わりません。文言で要素を探していない限り、既存のセレクターはそのまま動きます。
|
|
96
96
|
|
|
97
|
+
### 宣言だけでボタン文言を設定する
|
|
98
|
+
|
|
99
|
+
ボタンの文言は **HTML の属性だけ**で設定できます。`install()` を呼ぶための JavaScript は不要です。
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
<!-- 自身の <script> タグの属性で設定する(IIFE 版) -->
|
|
103
|
+
<script src="/js/haori.iife.js"></script>
|
|
104
|
+
<script
|
|
105
|
+
src="/js/haori-bootstrap.iife.js"
|
|
106
|
+
data-dialog-ok-label="OK"
|
|
107
|
+
data-dialog-cancel-label="キャンセル"
|
|
108
|
+
></script>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<!-- <html>(または <body>)の属性で設定する。ESM 版を import する構成でも効きます -->
|
|
113
|
+
<html lang="ja" data-haori-dialog-ok-label="OK" data-haori-dialog-cancel-label="キャンセル"></html>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- 優先順位は「`install()` の引数 > `<script>` タグの属性 > `<html>` > `<body>` > 既定値(英語)」です。
|
|
117
|
+
- 一度 `install()` の引数で指定した文言は、その後に文言を省略して `install()` を呼び直しても保持され、宣言では上書きされません(`uninstall()` で解除されます)。
|
|
118
|
+
- `<script>` タグの属性が効くのは **IIFE 版**(`haori-bootstrap.iife.js`)を `<script src>` で読み込んだ場合だけです。ESM 版を `type="module"` や `import` で読み込むと、HTML 仕様により自身のタグを特定できないため、`<html>` / `<body>` の属性を使ってください。
|
|
119
|
+
- `<body>` の属性は、読み込みの時点で `<body>` が解析済みである必要があります。`<head>` で読み込む構成では `<html>` か `<script>` タグの属性を使ってください。
|
|
120
|
+
- 空文字(空白のみ)は未指定として扱い、既定値を使います(文言の無いボタンを作らないため)。
|
|
121
|
+
- 宣言で設定できるのはボタンの 2 文言です。他の `install` オプションは引数で指定してください。
|
|
122
|
+
|
|
97
123
|
## Procedure 連携例
|
|
98
124
|
|
|
99
125
|
既存の Procedure は、data-click-* と data-click-*-message をそのまま利用できます。
|
|
@@ -220,12 +246,12 @@ push 後に、そのタグから GitHub Release を published にします。公
|
|
|
220
246
|
次回 patch リリースの例:
|
|
221
247
|
|
|
222
248
|
```bash
|
|
223
|
-
# version が 0.5.
|
|
249
|
+
# version が 0.5.27 になる
|
|
224
250
|
npm version patch
|
|
225
251
|
git push origin main --follow-tags
|
|
226
252
|
```
|
|
227
253
|
|
|
228
|
-
その後、push 済みタグの GitHub Release を作成して published にします。例として次回は `0.5.
|
|
254
|
+
その後、push 済みタグの GitHub Release を作成して published にします。例として次回は `0.5.27` タグになります。
|
|
229
255
|
|
|
230
256
|
自動公開:
|
|
231
257
|
|
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.26
|
|
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.
|
|
44
|
+
<script src="https://cdn.jsdelivr.net/npm/haori@0.43.0/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.26/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.
|
|
@@ -94,6 +94,32 @@ install({
|
|
|
94
94
|
|
|
95
95
|
The identifying attributes (`data-haori-confirm-ok`, `data-haori-confirm-cancel`, `data-haori-dialog-ok`) do not change with the label, so selectors keep working.
|
|
96
96
|
|
|
97
|
+
### Setting the button labels declaratively
|
|
98
|
+
|
|
99
|
+
The button labels can be set with **HTML attributes alone** — no JavaScript is needed to call `install()`.
|
|
100
|
+
|
|
101
|
+
```html
|
|
102
|
+
<!-- On the script tag itself (IIFE build) -->
|
|
103
|
+
<script src="/js/haori.iife.js"></script>
|
|
104
|
+
<script
|
|
105
|
+
src="/js/haori-bootstrap.iife.js"
|
|
106
|
+
data-dialog-ok-label="OK"
|
|
107
|
+
data-dialog-cancel-label="Abbrechen"
|
|
108
|
+
></script>
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<!-- On <html> (or <body>) — this also works when importing the ESM build -->
|
|
113
|
+
<html lang="de" data-haori-dialog-ok-label="OK" data-haori-dialog-cancel-label="Abbrechen"></html>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- Precedence is: `install()` argument > script tag attribute > `<html>` > `<body>` > default (English).
|
|
117
|
+
- A label once passed to `install()` is kept when `install()` is called again without it, and is not overridden by the declaration (`uninstall()` clears it).
|
|
118
|
+
- The script tag attributes only apply to the **IIFE build** (`haori-bootstrap.iife.js`) loaded with `<script src>`. When the ESM build is loaded with `type="module"` or `import`, the HTML specification makes the own tag unavailable, so use the `<html>` / `<body>` attributes.
|
|
119
|
+
- `<body>` attributes require `<body>` to be parsed at load time. Use `<html>` or the script tag when loading from `<head>`.
|
|
120
|
+
- A blank value (whitespace only) is treated as unspecified and falls back to the default, so a label-less button is never produced.
|
|
121
|
+
- Only the two button labels can be declared; pass the other install options as arguments.
|
|
122
|
+
|
|
97
123
|
## Procedure Integration Example
|
|
98
124
|
|
|
99
125
|
Existing Procedure flows can keep using data-click-* and data-click-*-message attributes.
|
|
@@ -217,15 +243,15 @@ git push origin main --follow-tags
|
|
|
217
243
|
|
|
218
244
|
After pushing, publish a GitHub Release from the generated version tag. The release workflow then publishes the package and uploads `dist.zip` automatically.
|
|
219
245
|
|
|
220
|
-
Example next patch release after `0.5.
|
|
246
|
+
Example next patch release after `0.5.26`:
|
|
221
247
|
|
|
222
248
|
```bash
|
|
223
|
-
# version becomes 0.5.
|
|
249
|
+
# version becomes 0.5.27
|
|
224
250
|
npm version patch
|
|
225
251
|
git push origin main --follow-tags
|
|
226
252
|
```
|
|
227
253
|
|
|
228
|
-
Create and publish the GitHub Release for the pushed tag such as `0.5.
|
|
254
|
+
Create and publish the GitHub Release for the pushed tag such as `0.5.27`.
|
|
229
255
|
|
|
230
256
|
Release automation:
|
|
231
257
|
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InstallOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* 宣言(HTML の属性)から導入設定を読み取る。
|
|
4
|
+
*
|
|
5
|
+
* <p>優先順位は「自身の `<script>` タグ > `<html>` > `<body>`」で、最初に見つかった値を
|
|
6
|
+
* 採用する。`<body>` は読み取りの時点で解析済みである必要があるため、`<head>` で
|
|
7
|
+
* 読み込む構成では `<html>` か `<script>` タグの属性を使う。
|
|
8
|
+
*
|
|
9
|
+
* @param documentObject 読み取りに使用する document。省略時は現在の document。
|
|
10
|
+
* @param scriptElement 自身の `<script>` タグ。省略時は読み込み時に捕捉したもの。
|
|
11
|
+
* @return 宣言された導入設定。宣言が無ければ空オブジェクト。
|
|
12
|
+
*/
|
|
13
|
+
export declare function readDeclaredInstallOptions(documentObject?: Document | null, scriptElement?: HTMLScriptElement | null): InstallOptions;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var HaoriBootstrap=(function(E){"use strict";function V(e){return typeof e=="function"}function J(e){return V(e?.Modal)?e?.Modal:void 0}function X(e){return V(e?.Toast)?e?.Toast:void 0}function N(e){return!!J(e)}function Be(e){return!!X(e)}function k(e,n,t){const o=J(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}function _e(e,n,t){const o=X(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}const Pe="data-haori-dialog",De="data-haori-confirm",xe="data-haori-dialog-title",Q="data-haori-dialog-ok",Y="data-haori-confirm-ok",Z="data-haori-confirm-cancel",Oe="OK",qe="Cancel";let Ue=0;function ee(){return{backdrop:"static",keyboard:!1}}function te(e,n){if(n.dialogContainerSelector){const t=e.querySelector(n.dialogContainerSelector);if(t)return t}return e.body}function ne(e,n,t,o){const r=o.dialogTitle,s=e.createElement("div");s.className="modal fade",s.tabIndex=-1,s.setAttribute(t?De:Pe,"true"),s.setAttribute("aria-hidden","true");const c=e.createElement("div");c.className="modal-dialog modal-dialog-centered";const a=e.createElement("div");if(a.className="modal-content",r){const b=`haori-dialog-title-${++Ue}`,y=e.createElement("div");y.className="modal-header";const A=e.createElement("h5");A.className="modal-title",A.id=b,A.setAttribute(xe,"true"),A.textContent=r,y.appendChild(A),a.appendChild(y),s.setAttribute("aria-labelledby",b)}const f=e.createElement("div");f.className="modal-body";const l=e.createElement("p");l.className="mb-0",l.style.whiteSpace="pre-line",l.textContent=n,f.appendChild(l);const m=e.createElement("div");if(m.className="modal-footer",t){const b=e.createElement("button");b.type="button",b.className="btn btn-secondary",b.setAttribute(Z,"true"),b.textContent=o.dialogCancelLabel??qe,m.appendChild(b)}const d=e.createElement("button");return d.type="button",d.className="btn btn-primary",d.setAttribute(t?Y:Q,"true"),d.textContent=o.dialogOkLabel??Oe,m.appendChild(d),a.append(f,m),c.appendChild(a),s.appendChild(c),s}function oe(e){let n=!1,t=!1;return{requestClose:o=>{n||(n=!0,o?.(),t&&e.hide())},handleShown:()=>{t=!0,n&&e.hide()}}}function $e(e,n){const t=globalThis.document,o=ne(t,e,!1,n);te(t,n).appendChild(o);const r=k(o,ee(),n.bootstrap);return r?new Promise((s,c)=>{const a=()=>{o.removeEventListener("shown.bs.modal",m),o.removeEventListener("hidden.bs.modal",f),o.remove(),r.dispose?.(),s()},f=()=>{a()},l=oe(r),m=l.handleShown;o.querySelector(`[${Q}]`)?.addEventListener("click",()=>{l.requestClose()}),o.addEventListener("shown.bs.modal",m),o.addEventListener("hidden.bs.modal",f,{once:!0});try{r.show()}catch(b){o.removeEventListener("shown.bs.modal",m),o.removeEventListener("hidden.bs.modal",f),o.remove(),r.dispose?.(),c(b)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}function Fe(e,n){const t=globalThis.document,o=ne(t,e,!0,n);te(t,n).appendChild(o);const r=k(o,ee(),n.bootstrap);return r?new Promise((s,c)=>{let a=!1;const f=()=>{o.removeEventListener("shown.bs.modal",d),o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),s(a)},l=()=>{f()},m=oe(r),d=m.handleShown,b=o.querySelector(`[${Y}]`),y=o.querySelector(`[${Z}]`);b?.addEventListener("click",()=>{m.requestClose(()=>{a=!0})}),y?.addEventListener("click",()=>{m.requestClose(()=>{a=!1})}),o.addEventListener("shown.bs.modal",d),o.addEventListener("hidden.bs.modal",l,{once:!0});try{r.show()}catch(A){o.removeEventListener("shown.bs.modal",d),o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),c(A)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}const v="data-haori-owned",h="data-haori-message-container",w="data-haori-invalid-target",L="data-haori-valid-target";function S(e){return e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")}function p(e){return e instanceof HTMLInputElement&&e.type==="radio"}function M(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(h)==="true")}function re(e,n){const t=e.createElement("div");return t.setAttribute(v,"true"),t.textContent=n,t}function se(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 ze(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=ze(t);if(o&&!t.includes(o))return o}return R(e)}function R(e){const n=e.closest(".form-check");return n instanceof HTMLElement?n:void 0}function ie(e){const n=e.nextElementSibling;if(n instanceof HTMLElement&&n.getAttribute(h)==="true")return n;const t=document.createElement("div");return t.className="invalid-feedback d-block",t.setAttribute(v,"true"),t.setAttribute(h,"true"),e.insertAdjacentElement("afterend",t),t}function We(e){const n=p(e)?$(e):R(e);if(!n)return ie(e);const t=H(n);if(t)return t;const o=document.createElement("div");return o.className="invalid-feedback d-block",o.setAttribute(v,"true"),o.setAttribute(h,"true"),n.appendChild(o),o}function Ge(e){const n=se(e);if(n)return n;const t=document.createElement("div");return t.className="alert alert-danger",t.setAttribute("role","alert"),t.setAttribute(v,"true"),t.setAttribute(h,"true"),e.insertAdjacentElement("afterbegin",t),t}function T(e){e.getAttribute(w)==="true"&&(e.classList.remove("is-invalid"),e.removeAttribute(w))}function g(e){e.getAttribute(L)==="true"&&(e.classList.remove("is-valid"),e.removeAttribute(L))}function ae(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 le(e){(p(e)?I(e):[e]).forEach(t=>{t.classList.add("is-invalid"),t.setAttribute(w,"true")})}function je(e){(p(e)?I(e):[e]).forEach(t=>{T(t)})}function ce(e,n){const t=e.nextElementSibling;if(t instanceof HTMLElement&&t.getAttribute(h)==="true")return t.className=B(n),t;const o=document.createElement("div");return o.className=B(n),o.setAttribute(v,"true"),o.setAttribute(h,"true"),e.insertAdjacentElement("afterend",o),o}function Ke(e,n){const t=p(e)?$(e):R(e);if(!t)return ce(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(v,"true"),r.setAttribute(h,"true"),t.appendChild(r),r}function Ve(e,n){const t=se(e);if(t)return t.className=ae(n),t;const o=document.createElement("div");return o.className=ae(n),o.setAttribute("role","alert"),o.setAttribute(v,"true"),o.setAttribute(h,"true"),e.insertAdjacentElement("afterbegin",o),o}function Je(e,n){return(S(e)?We(e):M(e)?ie(e):Ge(e)).appendChild(re(document,n)),S(e)?le(e):M(e)&&(e.classList.add("is-invalid"),e.setAttribute(w,"true")),Promise.resolve()}function Xe(e,n,t){if((S(e)?Ke(e,t):M(e)?ce(e,t):Ve(e,t)).appendChild(re(document,n)),S(e)){const r=p(e)?I(e):[e];t==="success"?r.forEach(s=>{T(s),s.classList.add("is-valid"),s.setAttribute(L,"true")}):!t||t==="error"?(r.forEach(s=>g(s)),le(e)):r.forEach(s=>{g(s),T(s)})}else M(e)&&(t==="success"?(T(e),e.classList.add("is-valid"),e.setAttribute(L,"true")):!t||t==="error"?(g(e),e.classList.add("is-invalid"),e.setAttribute(w,"true")):(g(e),T(e)));return Promise.resolve()}function de(e){if(S(e)){const r=p(e)?$(e):R(e);(r?H(r):void 0)?.remove(),je(e),(p(e)?I(e):[e]).forEach(a=>g(a))}else if(M(e)){const r=e.nextElementSibling;r instanceof HTMLElement&&r.getAttribute(h)==="true"&&r.remove(),T(e),g(e)}return e.querySelectorAll(`[${h}="true"]`).forEach(r=>{r.remove()}),e.querySelectorAll(`[${w}="true"]`).forEach(r=>{T(r)}),e.querySelectorAll(`[${L}="true"]`).forEach(r=>{g(r)}),Promise.resolve()}const F=new WeakSet;let _=!1,z;const ue=e=>{e.target instanceof HTMLElement&&F.add(e.target)},fe=e=>{e.target instanceof HTMLElement&&F.delete(e.target)};function Qe(e=document){_||(_=!0,z=e,e.addEventListener("show.bs.modal",ue),e.addEventListener("shown.bs.modal",fe))}function Ye(e=z??document){_&&(_=!1,e.removeEventListener("show.bs.modal",ue),e.removeEventListener("shown.bs.modal",fe),z=void 0)}function me(e){return e.classList.contains("modal")?e:e.closest(".modal")}function be(e){e.tabIndex<0&&(e.tabIndex=-1),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true")}function Ze(e,n){const t=me(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));be(t),de(t);const o=k(t,void 0,n.bootstrap);return o?(o.show(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}function et(e,n){const t=me(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));be(t);const o=k(t,void 0,n.bootstrap);return o?F.has(t)?(t.addEventListener("shown.bs.modal",()=>{o.hide()},{once:!0}),Promise.resolve()):(o.hide(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}const he="data-haori-toast-container",tt="data-haori-toast",nt="data-haori-toast-level",ot="data-haori-toast-accent",rt="data-haori-toast-dismiss",Ee={"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 st(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 it(e,n){if(n.toastContainerSelector){const t=e.querySelector(n.toastContainerSelector);if(t)return t}return e.body}function at(e,n){const t=it(e,n),o=Ee[n.toastPosition??"bottom-end"],r=t.querySelector(`[${he}="true"]`);if(r){const c=Object.values(Ee).flatMap(a=>a.split(" "));return r.classList.remove(...c),r.classList.add(...o.split(" ")),r}const s=e.createElement("div");return s.className=`toast-container position-fixed ${o} p-3`,s.setAttribute(he,"true"),t.appendChild(s),s}function lt(e,n,t){const o=globalThis.document,r=st(n),s=o.createElement("div");s.className="toast border bg-body text-body shadow-sm",s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.setAttribute(tt,"true"),s.setAttribute(nt,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(ot,"true");const f=o.createElement("div");f.className="toast-body",f.style.whiteSpace="pre-line",f.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(rt,"true"),c.appendChild(a),c.appendChild(f),c.appendChild(l),s.appendChild(c),at(o,t).appendChild(s);const m=t.toastDelay!==void 0?{delay:t.toastDelay}:void 0,d=_e(s,m,t.bootstrap);if(!d)return s.remove(),Promise.reject(new Error("Bootstrap Toast is unavailable."));l.addEventListener("click",()=>{d.hide?.()}),s.addEventListener("hidden.bs.toast",()=>{s.remove(),d.dispose?.()},{once:!0});try{return d.show(),Promise.resolve()}catch(b){return s.remove(),d.dispose?.(),Promise.reject(b)}}let u={options:{fallbackToNative:!0}};function C(e){return e.replace(/\\n/g,`
|
|
2
|
-
`)}function ve(){return globalThis.window}function W(e){return Promise.resolve(e).then(()=>{})}function
|
|
1
|
+
var HaoriBootstrap=(function(E){"use strict";function J(e){return typeof e=="function"}function X(e){return J(e?.Modal)?e?.Modal:void 0}function Q(e){return J(e?.Toast)?e?.Toast:void 0}function N(e){return!!X(e)}function _e(e){return!!Q(e)}function k(e,n,t){const o=X(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}function De(e,n,t){const o=Q(t);if(o)return typeof o.getOrCreateInstance=="function"?o.getOrCreateInstance(e,n):new o(e,n)}const Pe="data-haori-dialog",xe="data-haori-confirm",Oe="data-haori-dialog-title",Y="data-haori-dialog-ok",Z="data-haori-confirm-ok",ee="data-haori-confirm-cancel",qe="OK",$e="Cancel";let Ue=0;function te(){return{backdrop:"static",keyboard:!1}}function ne(e,n){if(n.dialogContainerSelector){const t=e.querySelector(n.dialogContainerSelector);if(t)return t}return e.body}function oe(e,n,t,o){const r=o.dialogTitle,s=e.createElement("div");s.className="modal fade",s.tabIndex=-1,s.setAttribute(t?xe:Pe,"true"),s.setAttribute("aria-hidden","true");const c=e.createElement("div");c.className="modal-dialog modal-dialog-centered";const a=e.createElement("div");if(a.className="modal-content",r){const b=`haori-dialog-title-${++Ue}`,I=e.createElement("div");I.className="modal-header";const A=e.createElement("h5");A.className="modal-title",A.id=b,A.setAttribute(Oe,"true"),A.textContent=r,I.appendChild(A),a.appendChild(I),s.setAttribute("aria-labelledby",b)}const f=e.createElement("div");f.className="modal-body";const l=e.createElement("p");l.className="mb-0",l.style.whiteSpace="pre-line",l.textContent=n,f.appendChild(l);const m=e.createElement("div");if(m.className="modal-footer",t){const b=e.createElement("button");b.type="button",b.className="btn btn-secondary",b.setAttribute(ee,"true"),b.textContent=o.dialogCancelLabel??$e,m.appendChild(b)}const d=e.createElement("button");return d.type="button",d.className="btn btn-primary",d.setAttribute(t?Z:Y,"true"),d.textContent=o.dialogOkLabel??qe,m.appendChild(d),a.append(f,m),c.appendChild(a),s.appendChild(c),s}function re(e){let n=!1,t=!1;return{requestClose:o=>{n||(n=!0,o?.(),t&&e.hide())},handleShown:()=>{t=!0,n&&e.hide()}}}function Fe(e,n){const t=globalThis.document,o=oe(t,e,!1,n);ne(t,n).appendChild(o);const r=k(o,te(),n.bootstrap);return r?new Promise((s,c)=>{const a=()=>{o.removeEventListener("shown.bs.modal",m),o.removeEventListener("hidden.bs.modal",f),o.remove(),r.dispose?.(),s()},f=()=>{a()},l=re(r),m=l.handleShown;o.querySelector(`[${Y}]`)?.addEventListener("click",()=>{l.requestClose()}),o.addEventListener("shown.bs.modal",m),o.addEventListener("hidden.bs.modal",f,{once:!0});try{r.show()}catch(b){o.removeEventListener("shown.bs.modal",m),o.removeEventListener("hidden.bs.modal",f),o.remove(),r.dispose?.(),c(b)}}):(o.remove(),Promise.reject(new Error("Bootstrap Modal is unavailable.")))}function ze(e,n){const t=globalThis.document,o=oe(t,e,!0,n);ne(t,n).appendChild(o);const r=k(o,te(),n.bootstrap);return r?new Promise((s,c)=>{let a=!1;const f=()=>{o.removeEventListener("shown.bs.modal",d),o.removeEventListener("hidden.bs.modal",l),o.remove(),r.dispose?.(),s(a)},l=()=>{f()},m=re(r),d=m.handleShown,b=o.querySelector(`[${Z}]`),I=o.querySelector(`[${ee}]`);b?.addEventListener("click",()=>{m.requestClose(()=>{a=!0})}),I?.addEventListener("click",()=>{m.requestClose(()=>{a=!1})}),o.addEventListener("shown.bs.modal",d),o.addEventListener("hidden.bs.modal",l,{once:!0});try{r.show()}catch(A){o.removeEventListener("shown.bs.modal",d),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",h="data-haori-message-container",w="data-haori-invalid-target",L="data-haori-valid-target";function S(e){return e instanceof HTMLInputElement&&(e.type==="checkbox"||e.type==="radio")}function v(e){return e instanceof HTMLInputElement&&e.type==="radio"}function M(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(h)==="true")}function se(e,n){const t=e.createElement("div");return t.setAttribute(p,"true"),t.textContent=n,t}function ie(e){return H(e)}function y(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 We(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 U(e){const t=y(e).map(o=>o.closest(".form-check")).filter(o=>o instanceof HTMLElement);if(t.length>1){const o=We(t);if(o&&!t.includes(o))return o}return R(e)}function R(e){const n=e.closest(".form-check");return n instanceof HTMLElement?n:void 0}function ae(e){const n=e.nextElementSibling;if(n instanceof HTMLElement&&n.getAttribute(h)==="true")return n;const t=document.createElement("div");return t.className="invalid-feedback d-block",t.setAttribute(p,"true"),t.setAttribute(h,"true"),e.insertAdjacentElement("afterend",t),t}function Ge(e){const n=v(e)?U(e):R(e);if(!n)return ae(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(h,"true"),n.appendChild(o),o}function Ke(e){const n=ie(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(h,"true"),e.insertAdjacentElement("afterbegin",t),t}function T(e){e.getAttribute(w)==="true"&&(e.classList.remove("is-invalid"),e.removeAttribute(w))}function g(e){e.getAttribute(L)==="true"&&(e.classList.remove("is-valid"),e.removeAttribute(L))}function le(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 ce(e){(v(e)?y(e):[e]).forEach(t=>{t.classList.add("is-invalid"),t.setAttribute(w,"true")})}function Ve(e){(v(e)?y(e):[e]).forEach(t=>{T(t)})}function de(e,n){const t=e.nextElementSibling;if(t instanceof HTMLElement&&t.getAttribute(h)==="true")return t.className=B(n),t;const o=document.createElement("div");return o.className=B(n),o.setAttribute(p,"true"),o.setAttribute(h,"true"),e.insertAdjacentElement("afterend",o),o}function je(e,n){const t=v(e)?U(e):R(e);if(!t)return de(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(h,"true"),t.appendChild(r),r}function Je(e,n){const t=ie(e);if(t)return t.className=le(n),t;const o=document.createElement("div");return o.className=le(n),o.setAttribute("role","alert"),o.setAttribute(p,"true"),o.setAttribute(h,"true"),e.insertAdjacentElement("afterbegin",o),o}function Xe(e,n){return(S(e)?Ge(e):M(e)?ae(e):Ke(e)).appendChild(se(document,n)),S(e)?ce(e):M(e)&&(e.classList.add("is-invalid"),e.setAttribute(w,"true")),Promise.resolve()}function Qe(e,n,t){if((S(e)?je(e,t):M(e)?de(e,t):Je(e,t)).appendChild(se(document,n)),S(e)){const r=v(e)?y(e):[e];t==="success"?r.forEach(s=>{T(s),s.classList.add("is-valid"),s.setAttribute(L,"true")}):!t||t==="error"?(r.forEach(s=>g(s)),ce(e)):r.forEach(s=>{g(s),T(s)})}else M(e)&&(t==="success"?(T(e),e.classList.add("is-valid"),e.setAttribute(L,"true")):!t||t==="error"?(g(e),e.classList.add("is-invalid"),e.setAttribute(w,"true")):(g(e),T(e)));return Promise.resolve()}function ue(e){if(S(e)){const r=v(e)?U(e):R(e);(r?H(r):void 0)?.remove(),Ve(e),(v(e)?y(e):[e]).forEach(a=>g(a))}else if(M(e)){const r=e.nextElementSibling;r instanceof HTMLElement&&r.getAttribute(h)==="true"&&r.remove(),T(e),g(e)}return e.querySelectorAll(`[${h}="true"]`).forEach(r=>{r.remove()}),e.querySelectorAll(`[${w}="true"]`).forEach(r=>{T(r)}),e.querySelectorAll(`[${L}="true"]`).forEach(r=>{g(r)}),Promise.resolve()}const F=new WeakSet;let _=!1,z;const fe=e=>{e.target instanceof HTMLElement&&F.add(e.target)},me=e=>{e.target instanceof HTMLElement&&F.delete(e.target)};function Ye(e=document){_||(_=!0,z=e,e.addEventListener("show.bs.modal",fe),e.addEventListener("shown.bs.modal",me))}function Ze(e=z??document){_&&(_=!1,e.removeEventListener("show.bs.modal",fe),e.removeEventListener("shown.bs.modal",me),z=void 0)}function be(e){return e.classList.contains("modal")?e:e.closest(".modal")}function he(e){e.tabIndex<0&&(e.tabIndex=-1),e.hasAttribute("aria-hidden")||e.setAttribute("aria-hidden","true")}function et(e,n){const t=be(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));he(t),ue(t);const o=k(t,void 0,n.bootstrap);return o?(o.show(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}function tt(e,n){const t=be(e);if(!t)return Promise.reject(new Error('No ancestor ".modal" element was found for the target.'));he(t);const o=k(t,void 0,n.bootstrap);return o?F.has(t)?(t.addEventListener("shown.bs.modal",()=>{o.hide()},{once:!0}),Promise.resolve()):(o.hide(),Promise.resolve()):Promise.reject(new Error("Bootstrap Modal is unavailable."))}const Ee="data-haori-toast-container",nt="data-haori-toast",ot="data-haori-toast-level",rt="data-haori-toast-accent",st="data-haori-toast-dismiss",pe={"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 it(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 at(e,n){if(n.toastContainerSelector){const t=e.querySelector(n.toastContainerSelector);if(t)return t}return e.body}function lt(e,n){const t=at(e,n),o=pe[n.toastPosition??"bottom-end"],r=t.querySelector(`[${Ee}="true"]`);if(r){const c=Object.values(pe).flatMap(a=>a.split(" "));return r.classList.remove(...c),r.classList.add(...o.split(" ")),r}const s=e.createElement("div");return s.className=`toast-container position-fixed ${o} p-3`,s.setAttribute(Ee,"true"),t.appendChild(s),s}function ct(e,n,t){const o=globalThis.document,r=it(n),s=o.createElement("div");s.className="toast border bg-body text-body shadow-sm",s.setAttribute("role","status"),s.setAttribute("aria-live","polite"),s.setAttribute("aria-atomic","true"),s.setAttribute(nt,"true"),s.setAttribute(ot,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(rt,"true");const f=o.createElement("div");f.className="toast-body",f.style.whiteSpace="pre-line",f.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(st,"true"),c.appendChild(a),c.appendChild(f),c.appendChild(l),s.appendChild(c),lt(o,t).appendChild(s);const m=t.toastDelay!==void 0?{delay:t.toastDelay}:void 0,d=De(s,m,t.bootstrap);if(!d)return s.remove(),Promise.reject(new Error("Bootstrap Toast is unavailable."));l.addEventListener("click",()=>{d.hide?.()}),s.addEventListener("hidden.bs.toast",()=>{s.remove(),d.dispose?.()},{once:!0});try{return d.show(),Promise.resolve()}catch(b){return s.remove(),d.dispose?.(),Promise.reject(b)}}let u={options:{fallbackToNative:!0}};function C(e){return e.replace(/\\n/g,`
|
|
2
|
+
`)}function ve(){return globalThis.window}function W(e){return Promise.resolve(e).then(()=>{})}function D(e){const n=u.originalHaori?.[e];return typeof n=="function"?n:void 0}function P(e){console.warn(`[haori-bootstrap] ${e} skipped because Bootstrap support is unavailable.`)}function Te(e){const n=C(e),t=D("dialog");if(t)return W(t(n));const o=ve();return u.options.fallbackToNative&&typeof o?.alert=="function"?(o.alert(n),Promise.resolve()):(P("dialog"),Promise.resolve())}function ge(e){const n=C(e),t=D("confirm");if(t)return Promise.resolve(t(n)).then(r=>!!r);const o=ve();return u.options.fallbackToNative&&typeof o?.confirm=="function"?Promise.resolve(o.confirm(n)):(P("confirm"),Promise.resolve(!1))}function Ae(e,n){const t=C(e),o=D("toast");return o?W(o(t,n)):(P("toast"),Promise.resolve())}function x(e,n){const t=D(e);return t?W(t(n)):(P(e),Promise.resolve())}function dt(e){u=e}class we{static dialog(n){const t=C(n);return N(u.options.bootstrap)?Fe(t,u.options).catch(()=>Te(t)):Te(t)}static confirm(n){const t=C(n);return N(u.options.bootstrap)?ze(t,u.options).catch(()=>ge(t)):ge(t)}static toast(n,t){const o=C(n);return _e(u.options.bootstrap)?ct(o,t,u.options).catch(()=>Ae(o,t)):Ae(o,t)}static openDialog(n){return N(u.options.bootstrap)?et(n,u.options).catch(()=>x("openDialog",n)):x("openDialog",n)}static closeDialog(n){return N(u.options.bootstrap)?tt(n,u.options).catch(()=>x("closeDialog",n)):x("closeDialog",n)}static addErrorMessage(n,t){return Xe(n,t)}static addMessage(n,t,o){return Qe(n,t,o)}static clearMessages(n){return ue(n)}}const ut="haori-bootstrap:collapse:",O="data-haori-persist";let q=!1,$,G;function Ce(e){return ut+e}function ft(e){try{const n=window.sessionStorage.getItem(Ce(e));return n==="shown"||n==="hidden"?n:void 0}catch{return}}function mt(e,n){try{window.sessionStorage.setItem(Ce(e),n)}catch{}}function Le(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(s=>{s.setAttribute("aria-expanded",n?"true":"false"),s.classList.toggle("collapsed",!n)})}function Se(e){const n=e.getAttribute(O);if(!n)return;const t=ft(n);if(!t)return;const o=e.classList.contains("show");t==="shown"&&!o?(e.classList.add("show"),Le(e,!0)):t==="hidden"&&o&&(e.classList.remove("show"),Le(e,!1))}function Me(e){e instanceof HTMLElement&&e.hasAttribute(O)&&Se(e),e.querySelectorAll(`[${O}]`).forEach(Se)}function ye(e,n){const t=e.target;if(!(t instanceof HTMLElement))return;const o=t.getAttribute(O);o&&mt(o,n)}const Ie=e=>ye(e,"shown"),Ne=e=>ye(e,"hidden");function bt(e=document){if(q)return;q=!0,G=e,e.addEventListener("shown.bs.collapse",Ie),e.addEventListener("hidden.bs.collapse",Ne);const n=()=>{Me(e),$=new MutationObserver(t=>{for(const o of t)o.addedNodes.forEach(r=>{r instanceof HTMLElement&&Me(r)})}),e.body&&$.observe(e.body,{childList:!0,subtree:!0})};e.body?n():e.addEventListener("DOMContentLoaded",n,{once:!0})}function ht(e=G??document){q&&(q=!1,e.removeEventListener("shown.bs.collapse",Ie),e.removeEventListener("hidden.bs.collapse",Ne),$?.disconnect(),$=void 0,G=void 0)}const Et=[{attribute:"dialog-ok-label",apply:(e,n)=>{e.dialogOkLabel=n}},{attribute:"dialog-cancel-label",apply:(e,n)=>{e.dialogCancelLabel=n}}],pt=typeof document<"u"&&document.currentScript instanceof HTMLScriptElement?document.currentScript:null;function K(e,n){const t=e?.getAttribute(n)??null;if(!(t===null||t.trim()===""))return t}function vt(e=typeof document>"u"?null:document,n=pt){const t={};for(const{attribute:o,apply:r}of Et){const s=K(n,`data-${o}`)??K(e?.documentElement??null,`data-haori-${o}`)??K(e?.body??null,`data-haori-${o}`);s!==void 0&&r(t,s)}return t}const V={fallbackToNative:!0},ke=new Set(["dialog","confirm","toast","openDialog","closeDialog","addErrorMessage","addMessage","clearMessages"]);function Tt(e){const n=we;return new Proxy(e,{get(t,o,r){return typeof o=="string"&&ke.has(o)?n[o]:Reflect.get(t,o,r)},has(t,o){return typeof o=="string"&&ke.has(o)?!0:Reflect.has(t,o)}})}const i={installed:!1,options:V};function j(){return globalThis.window}function gt(e,n){const t=vt();return{bootstrap:e.bootstrap??n?.bootstrap,fallbackToNative:e.fallbackToNative??V.fallbackToNative,runtime:e.runtime??i.options.runtime??n?.Haori?.runtime,toastContainerSelector:e.toastContainerSelector??i.options.toastContainerSelector,dialogContainerSelector:e.dialogContainerSelector??i.options.dialogContainerSelector,dialogTitle:e.dialogTitle??i.options.dialogTitle,dialogOkLabel:e.dialogOkLabel??i.options.dialogOkLabel??t.dialogOkLabel,dialogCancelLabel:e.dialogCancelLabel??i.options.dialogCancelLabel??t.dialogCancelLabel,toastPosition:e.toastPosition??i.options.toastPosition,toastDelay:e.toastDelay??i.options.toastDelay}}function He(e=j()){return!!(e?.Haori&&e.bootstrap)}function Re(e={}){const n=j();if(!n?.Haori)throw new Error("window.Haori is required before calling install().");if(i.originalHaori||(i.originalHaori=n.Haori,i.originalRuntime=n.Haori.runtime),i.options=gt(e,n),i.options.runtime){const t=i.originalHaori??n.Haori;typeof t.setRuntime=="function"?t.setRuntime(i.options.runtime):console.warn("[haori-bootstrap] Haori.setRuntime が利用できません。runtime 設定は無視されます。")}dt({originalHaori:i.originalHaori,options:i.options}),n.Haori=Tt(i.originalHaori),bt(),Ye(),i.installed=!0}function At(){const e=j();if(!e||!i.originalHaori)return;const n=i.originalHaori;typeof n.setRuntime=="function"?n.setRuntime(i.originalRuntime):n.runtime=i.originalRuntime,e.Haori=i.originalHaori,ht(),Ze(),i.installed=!1,i.originalHaori=void 0,i.originalRuntime=void 0,i.options=V}function wt(){return i.installed}const Be="__haoriJsBootstrapAutoEnabled__";function Ct(){return globalThis.window}function Lt(e){return!!e[Be]}function St(e){e[Be]=!0}function Mt(){const e=Ct();if(!(!e||Lt(e))){if(!He(e)){console.warn("[haori-bootstrap] Auto-enable skipped because window.Haori or window.bootstrap is missing.");return}try{Re({bootstrap:e.bootstrap}),St(e)}catch(n){console.warn("[haori-bootstrap] Auto-enable failed.",n)}}}Mt();const yt="0.5.26";return E.BootstrapHaori=we,E.hasAutoEnablePrerequisites=He,E.install=Re,E.isInstalled=wt,E.uninstall=At,E.version=yt,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"}),E})({});
|
|
3
3
|
//# sourceMappingURL=haori-bootstrap.iife.js.map
|