haori 0.67.0 → 0.69.0
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 +2 -1
- package/README.md +2 -1
- package/dist/haori.cjs.js +15 -15
- package/dist/haori.es.js +1237 -1007
- package/dist/haori.iife.js +15 -15
- package/dist/index.d.ts +109 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js は、HTML 属性を中心にして動的な UI を実現する軽量なライブラリです。JavaScript をほとんど書かずに、データバインディング、条件分岐、繰り返し処理、フォームの双方向バインディング、サーバー通信などを HTML 属性で宣言できます。
|
|
4
4
|
|
|
5
|
-
バージョン: 0.
|
|
5
|
+
バージョン: 0.69.0
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -137,6 +137,7 @@ Haori.mount(document.body, {items: [{name: 'りんご'}, {name: 'みかん'}]});
|
|
|
137
137
|
- **CSS セレクタ**を値に取る属性(`data-{event}-bind`・`-form`・`-copy`・`-copy-source`・`-reset`・`-refetch`・`-click`・`-open`・`-close`・`-adjust`・`-row-*`・`data-fetch-bind`・`data-fetch-state` など)は、照会の前に `{{ ... }}` を評価します。`data-each` の行の中から「その行の要素」を対象にでき(`id="plan-scope-{{i}}"` と `data-change-bind="#plan-scope-{{i}}"` の組み合わせ)、行ごとのバインドや住所複写が属性だけで書けます。不正なセレクタは例外にせずログしてスキップし、単体プレースホルダの未解決参照は「値の指定なし」として扱います(値を省略したときの既定動作になります)。`-bind-arg`・`-copy-params` のようなキー名を並べる属性は評価しません。
|
|
138
138
|
- `data-click-copy-source` — `data-click-copy` のコピー元要素を明示指定します(既定は `data-click-form` のフォーム、無ければイベント発火元の binding)。
|
|
139
139
|
- `data-click-no-disabled` / `data-click-defer` — 他ライブラリとの併用補助です。`no-disabled` はクリック手続き実行中に `disabled` 属性を付与せず実行します(Bootstrap collapse など disabled 要素を無視するライブラリ・CSS が動作し続けます。多重実行は内部マーカーで防止)。`defer` はクリック手続きを次フレーム(`requestAnimationFrame`/`setTimeout(0)`)で実行し、他ライブラリの同期 click ハンドラを先に完了させます。遅延後は `preventDefault()` できないため、`<a href>` や `type="submit"` への `defer` 併用は避けてください。
|
|
140
|
+
- `data-click-lock="名前"` — 同じ名前の要素で、`click` 手続きの実行中のロックを 1 つ共有します。どれかの手続きが実行中の間は、同じ名前のほかの要素を押しても手続きを実行せず、それらの要素にも `disabled` を付けます(`data-click-no-disabled` を付けた要素には付けません)。終わると各要素の `data-attr-disabled` の評価結果へ揃えます。同じものを書き換える別々のボタン(「休憩開始」と「退勤」など)を、遅い応答を待つ間に続けて押しても、両方が走りません。名前は文書全体で共有し、名前の無い要素は今までどおり要素ごとのロックです。
|
|
140
141
|
- `data-{event}-click-await` — `data-{event}-click` が起動した手続きの完了を待ってから次の対象をクリックします。複数の更新を**宣言した順に直列で**送り(`#b, #a` のようにカンマで区切った対象は、文書の並びによらず書いた順に押します)、**いずれかが失敗した時点で後続を止めます**(HTTP エラー・通信の例外・検証エラー・確認ダイアログのキャンセル)。表示順を 2 件更新する並べ替えが JavaScript なしで書けます。止めた場合は呼び出し元の後続アクション(ダイアログ・トースト・リダイレクト)も実行しません。`data-{event}-if` が偽でスキップされた対象は失敗として扱いません。手続きが同期に起動しない対象(`data-click-defer`、クリックが発火しない `disabled` 要素)は待てず、その旨を記録します。
|
|
141
142
|
- `data-{event}-error-click` / `-error-click-await` / `-error-close` / `-error-toast` / `-error-toast-level` / `-error-status` / `-error-no-message` / `-error-bind` — 取得が失敗したとき(2xx 以外の応答と通信の例外。認証ガードで遷移する 401 / 403 を除く)にだけ、別要素のクリック・ダイアログを閉じる・トーストをこの順に実行します。「取り直しが 404 なら、ダイアログを閉じて検索し直す」が JavaScript なしで書けます。`-error-status="404&410"` で対象のステータスを絞れます(宣言すると通信の例外は対象外)。実行しても手続きは失敗のままで、エラー表示も今までどおり行います(`-error-no-message` で止められます)。`-error-bind` を宣言すると、応答本文を表示する代わりに `data-{event}-bind` と同じ規則でバインドします(400 で返る検証結果を表に出すなど)。応答本文のサーバのメッセージは `_fetch.responseMessage` で参照でき、`data-click-error-toast="{{_fetch.responseMessage}}"` でトーストに出せます。`data-click-error-404-close` のようにステータスを付けた組(`-click` / `-click-await` / `-close` / `-toast` / `-toast-level` / `-no-message` / `-bind`)は、そのステータスの失敗でだけ、ステータスの付かない属性の代わりに使います。`-toast-level` と `-error-toast-level` には式を書けます(例: `{{_fetch.statusCode === 409 ? 'warning' : 'error'}}`)。`data-poll-*` と非イベントの `data-fetch` では、応答本文の表示を止める宣言(`data-fetch-error-no-message` / `data-poll-error-no-message` と、その `-error-status`・`-error-{ステータス}-no-message`)だけを使えます。
|
|
142
143
|
- `data-{event}-clear-messages` — 取得が成功したときに、前回の失敗の表示を消します(範囲は失敗の表示と同じ)。値・バインドデータには触れないため、検索の条件を残したまま、前回の失敗の文言だけを消せます。ダウンロード(`-fetch-download`)では保存に成功した後に消します。
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Haori.js is a lightweight, HTML-first UI library that enables dynamic user interfaces primarily through HTML attributes. It lets you declare data bindings, conditional rendering, list rendering, form two-way binding, server fetches, and HTML imports without writing much JavaScript.
|
|
4
4
|
|
|
5
|
-
Version: 0.
|
|
5
|
+
Version: 0.69.0
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -137,6 +137,7 @@ Event-driven actions:
|
|
|
137
137
|
- Attributes that take a **CSS selector** (`data-{event}-bind`, `-form`, `-copy`, `-copy-source`, `-reset`, `-refetch`, `-click`, `-open`, `-close`, `-adjust`, `-row-*`, `data-fetch-bind`, `data-fetch-state`, …) evaluate `{{ ... }}` before querying, so a row inside `data-each` can target *its own* elements (`data-change-bind="#plan-scope-{{i}}"` paired with `id="plan-scope-{{i}}"`). An invalid selector is logged and skipped instead of throwing, and an unresolved single placeholder is treated as "no value given" (falling back to the attribute's default behaviour). Key-list attributes such as `-bind-arg` / `-copy-params` are not evaluated.
|
|
138
138
|
- `data-click-copy-source` — explicitly set the copy source element for `data-click-copy` (defaults to the form given by `data-click-form`, otherwise the event element's binding).
|
|
139
139
|
- `data-click-no-disabled` / `data-click-defer` — coexistence helpers for other libraries. `no-disabled` runs the click procedure without adding the `disabled` attribute (so libraries/CSS that ignore disabled elements, e.g. Bootstrap collapse, keep working; double execution is still prevented internally). `defer` runs the click procedure on the next frame (`requestAnimationFrame`/`setTimeout(0)`) so other libraries' synchronous click handlers complete first. Avoid `defer` on `<a href>` / `type="submit"` because the deferred procedure cannot `preventDefault()` the default action.
|
|
140
|
+
- `data-click-lock="name"` — share one running-procedure lock among elements with the same name. While any of their `click` procedures is running, clicking another element with the same name does not run its procedure, and those elements get `disabled` (except with `data-click-no-disabled`); afterwards each one returns to the result of its own `data-attr-disabled`. This stops separate buttons that update the same thing (for example "start break" and "clock out") from both running while a slow response is pending. Names are shared across the document; elements without a name keep the per-element lock.
|
|
140
141
|
- `data-{event}-click-await` — wait for the procedure started by `data-{event}-click` before clicking the next target, so several updates are sent **serially in declaration order** (comma-separated targets such as `#b, #a` are clicked in the written order, regardless of document order) and **the rest is stopped as soon as one fails** (HTTP error, network exception, validation error, or a cancelled confirmation). Row reordering that has to persist two display orders no longer needs JavaScript. When it stops, the calling procedure also skips its remaining actions (dialog, toast, redirect). A target skipped by a false `data-{event}-if` is not a failure. Targets whose procedure does not start synchronously (`data-click-defer`, or a `disabled` element that fires no click) cannot be waited for; that is logged.
|
|
141
142
|
- `data-{event}-error-click` / `-error-click-await` / `-error-close` / `-error-toast` / `-error-toast-level` / `-error-status` / `-error-no-message` / `-error-bind` — run a click on another element, a dialog close and a toast, in that order, only when the fetch fails (a non-2xx response or a network exception, except 401 / 403 handled by the auth guard redirect). "If the reload returns 404, close the dialog and search again" no longer needs JavaScript. `-error-status="404&410"` narrows the statuses (once declared, network exceptions are excluded). The procedure still ends as a failure and the error display works as before, unless `-error-no-message` turns it off. `-error-bind` binds the response body by the same rules as `data-{event}-bind` instead of showing it (for example, a validation result returned with 400). The server's message in the response body is available as `_fetch.responseMessage`, so `data-click-error-toast="{{_fetch.responseMessage}}"` shows it in a toast. A group with a status in its name, such as `data-click-error-404-close` (`-click` / `-click-await` / `-close` / `-toast` / `-toast-level` / `-no-message` / `-bind`), replaces the attributes without a status only for failures with that status. `-toast-level` and `-error-toast-level` accept expressions (for example `{{_fetch.statusCode === 409 ? 'warning' : 'error'}}`). On `data-poll-*` and the non-event `data-fetch`, only the declarations that turn off the error display are read (`data-fetch-error-no-message` / `data-poll-error-no-message`, with their `-error-status` and `-error-{status}-no-message`).
|
|
142
143
|
- `data-{event}-clear-messages` — on a successful fetch, clear the messages left by the previous failure (in the same scope the failure was shown in). Input values and binding data are untouched, so a search form keeps its conditions while the stale error disappears. With `-fetch-download` it clears after the file is saved.
|