Angular ユーティリティライブラリ | ng-hub-ui-utils
再利用可能な UI コンポーネント間で共有される、パイプ、フォーカス管理、オーバーレイ、トランジション、翻訳ヘルパーを備えた Angular ユーティリティライブラリ。
API リファレンス
utils の完全な仕様をここにまとめました。バインド、リッスン、プロジェクション、テーマ設定ができるすべてが一か所に集約されています。必要なものを接続し、好きなようにスタイリングしてください — standalone で signal フレンドリーです。
インプット
4 個のインプットで utils を調整。通常の Angular @Input と同じようにバインドできます。
| 名前 | 型 | デフォルト | 説明 |
|---|---|---|---|
HubTranslationService | Service | - | 翻訳を管理するための注入可能なサービス。メソッド: getTranslation()、setTranslations() |
HubOverlayService | Service | - | オーバーレイをプログラム的に作成・管理するためのサービス |
HubPopupService | Service | - | ポップアップ要素を作成するための簡易サービス |
TooltipDirective | Directive | - | Directive ([tooltip]) that shows a positioned, themeable tooltip on hover/focus. Inputs: tooltip (text), placement, delay, offset. |
アウトプット
utils の動作に反応 — ロジックを接続できる 7 個のイベント。
| 名前 | 型 | 説明 |
|---|---|---|
TranslatePipe | Pipe | HubTranslationService を使用してキーを翻訳します。使い方: {{ "key" | translate }} |
GetPipe | Pipe | ネストされたプロパティ値を取得します。使い方: {{ object | get:"path.to.property" }} |
IsStringPipe | Pipe | 値が文字列かどうかを判定します。使い方: {{ value | isString }} |
IsObjectPipe | Pipe | 値がオブジェクトかどうかを判定します。使い方: {{ value | isObject }} |
IsObservablePipe | Pipe | 値が Observable かどうかを判定します。使い方: {{ value | isObservable }} |
UcfirstPipe | Pipe | 先頭の文字を大文字にします。使い方: {{ "hello" | ucfirst }} → "Hello" |
UnwrapAsyncPipe | Pipe | テンプレート内で Observable または Promise の値をアンラップします |
テンプレート
自分好みに — 4 個のテンプレートスロットでカスタムマークアップをプロジェクションできます。
| 名前 | 説明 | サンプル |
|---|---|---|
hubFocusTrap() | 要素内にキーボードフォーカスを閉じ込めます。モーダルやダイアログに役立ちます。 | hubFocusTrap(zone, element, stopFocusTrap$, refocusOnClick) |
interpolateString() | {{ placeholders }} をオブジェクトの値で置き換えます | interpolateString("Hello {{name}}", { name: "World" }) → "Hello World" |
getValue() | ドット記法を使用してネストされたプロパティを取得します | getValue(obj, "user.profile.name") |
equals() | オブジェクトおよび配列の深い等価比較 | equals({ a: 1 }, { a: 1 }) → true |
CSS 変数
19 個の CSS 変数であらゆるピクセルをテーマ設定。:root で上書きするか、ラッパーにスコープを限定できます。
Tooltip
Theming tokens for the [tooltip] directive.
| 変数 | デフォルト | 型 | 説明 |
|---|---|---|---|
--hub-tooltip-bg | var(--hub-ref-color-black, #000) | color | Tooltip background colour. var(--hub-sys-color-primary)#212529 |
--hub-tooltip-color | var(--hub-ref-color-white, #fff) | color | Tooltip text colour. #fff#f8f9fa |
--hub-tooltip-opacity | 0.9 | number | Opacity of the shown tooltip. 10.85 |
--hub-tooltip-padding-x | var(--hub-ref-space-2, 0.5rem) | length | Horizontal padding inside the tooltip. 0.75rem1rem |
--hub-tooltip-padding-y | var(--hub-ref-space-1, 0.25rem) | length | Vertical padding inside the tooltip. 0.375rem0.5rem |
--hub-tooltip-border-radius | var(--hub-sys-radius-md, 0.375rem) | length | Corner radius of the tooltip. 0.25rem999px |
--hub-tooltip-font-size | var(--hub-ref-font-size-sm, 0.875rem) | length | Font size of the tooltip text. 0.75rem1rem |
--hub-tooltip-font-weight | var(--hub-ref-font-weight-base, 400) | number | Font weight of the tooltip text. 500600 |
--hub-tooltip-line-height | var(--hub-ref-line-height-base, 1.5) | number | Line height of the tooltip text. 1.41.6 |
--hub-tooltip-max-width | 200px | length | Maximum width before the text wraps. 160px320px |
--hub-tooltip-zindex | var(--hub-sys-zindex-tooltip, 1080) | number | Stacking order of the tooltip element. 10802000 |
--hub-tooltip-transition-duration | 0.15s | transition | Fade in/out duration. 0.1s0.25s |
--hub-tooltip-shadow | none | shadow | Box shadow of the tooltip. var(--hub-sys-shadow)0 2px 8px rgba(0,0,0,.2) |
--hub-tooltip-font-family | var(--hub-ref-font-family-base, inherit) | string | Font family of the tooltip text. inheritmonospace |
Overlay
CSS variables consumed by the overlay/popup system (`.hub-overlay-container` / `.hub-overlay-backdrop`).
| 変数 | デフォルト | 型 | 説明 |
|---|---|---|---|
--hub-overlay-bg | var(--hub-sys-surface-elevated, #f8f9fa) | color | Background of the overlay panel. #fffvar(--hub-sys-surface-page) |
--hub-overlay-border-radius | var(--hub-sys-radius-sm, 0.25rem) | length | Corner radius of the overlay panel. 0.5rem0 |
--hub-overlay-shadow | var(--hub-sys-shadow, 0 0.5rem 1rem rgba(0,0,0,.15)) | shadow | Elevation shadow of the overlay panel. var(--hub-sys-shadow-lg)none |
--hub-overlay-zindex | var(--hub-sys-zindex-dropdown, 1000) | number | Stacking order of the overlay panel. 10502000 |
--hub-overlay-backdrop-zindex | calc(var(--hub-sys-zindex-dropdown, 1000) - 1) | number | Stacking order of the overlay backdrop (just below the panel). 10491999 |
スタイリングとテーマ設定
スタイリングのサンプルはまだドキュメント化されていません。このセクションには、カスタマイズのレシピやテーマ設定のサンプルが含まれる予定です。