Angular ユーティリティライブラリ | ng-hub-ui-utils

再利用可能な UI コンポーネント間で共有される、パイプ、フォーカス管理、オーバーレイ、トランジション、翻訳ヘルパーを備えた Angular ユーティリティライブラリ。

API リファレンス

utils の完全な仕様をここにまとめました。バインド、リッスン、プロジェクション、テーマ設定ができるすべてが一か所に集約されています。必要なものを接続し、好きなようにスタイリングしてください — standalone で signal フレンドリーです。

インプット

4 個のインプットで utils を調整。通常の Angular @Input と同じようにバインドできます。

名前デフォルト説明
HubTranslationServiceService-翻訳を管理するための注入可能なサービス。メソッド: getTranslation()、setTranslations()
HubOverlayServiceService-オーバーレイをプログラム的に作成・管理するためのサービス
HubPopupServiceService-ポップアップ要素を作成するための簡易サービス
TooltipDirectiveDirective-Directive ([tooltip]) that shows a positioned, themeable tooltip on hover/focus. Inputs: tooltip (text), placement, delay, offset.

アウトプット

utils の動作に反応 — ロジックを接続できる 7 個のイベント。

名前説明
TranslatePipePipeHubTranslationService を使用してキーを翻訳します。使い方: {{ "key" | translate }}
GetPipePipeネストされたプロパティ値を取得します。使い方: {{ object | get:"path.to.property" }}
IsStringPipePipe値が文字列かどうかを判定します。使い方: {{ value | isString }}
IsObjectPipePipe値がオブジェクトかどうかを判定します。使い方: {{ value | isObject }}
IsObservablePipePipe値が Observable かどうかを判定します。使い方: {{ value | isObservable }}
UcfirstPipePipe先頭の文字を大文字にします。使い方: {{ "hello" | ucfirst }} → "Hello"
UnwrapAsyncPipePipeテンプレート内で 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-bgvar(--hub-ref-color-black, #000)color Tooltip background colour. var(--hub-sys-color-primary)#212529
--hub-tooltip-colorvar(--hub-ref-color-white, #fff)color Tooltip text colour. #fff#f8f9fa
--hub-tooltip-opacity0.9number Opacity of the shown tooltip. 10.85
--hub-tooltip-padding-xvar(--hub-ref-space-2, 0.5rem)length Horizontal padding inside the tooltip. 0.75rem1rem
--hub-tooltip-padding-yvar(--hub-ref-space-1, 0.25rem)length Vertical padding inside the tooltip. 0.375rem0.5rem
--hub-tooltip-border-radiusvar(--hub-sys-radius-md, 0.375rem)length Corner radius of the tooltip. 0.25rem999px
--hub-tooltip-font-sizevar(--hub-ref-font-size-sm, 0.875rem)length Font size of the tooltip text. 0.75rem1rem
--hub-tooltip-font-weightvar(--hub-ref-font-weight-base, 400)number Font weight of the tooltip text. 500600
--hub-tooltip-line-heightvar(--hub-ref-line-height-base, 1.5)number Line height of the tooltip text. 1.41.6
--hub-tooltip-max-width200pxlength Maximum width before the text wraps. 160px320px
--hub-tooltip-zindexvar(--hub-sys-zindex-tooltip, 1080)number Stacking order of the tooltip element. 10802000
--hub-tooltip-transition-duration0.15stransition Fade in/out duration. 0.1s0.25s
--hub-tooltip-shadownoneshadow Box shadow of the tooltip. var(--hub-sys-shadow)0 2px 8px rgba(0,0,0,.2)
--hub-tooltip-font-familyvar(--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-bgvar(--hub-sys-surface-elevated, #f8f9fa)color Background of the overlay panel. #fffvar(--hub-sys-surface-page)
--hub-overlay-border-radiusvar(--hub-sys-radius-sm, 0.25rem)length Corner radius of the overlay panel. 0.5rem0
--hub-overlay-shadowvar(--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-zindexvar(--hub-sys-zindex-dropdown, 1000)number Stacking order of the overlay panel. 10502000
--hub-overlay-backdrop-zindexcalc(var(--hub-sys-zindex-dropdown, 1000) - 1)number Stacking order of the overlay backdrop (just below the panel). 10491999

スタイリングとテーマ設定

スタイリングのサンプルはまだドキュメント化されていません。このセクションには、カスタマイズのレシピやテーマ設定のサンプルが含まれる予定です。