Angular Utility-Bibliothek | ng-hub-ui-utils
Angular Utility-Bibliothek mit Pipes, Fokusmanagement, Overlays, Transitions und Übersetzungs-Helfern, die von wiederverwendbaren UI-Komponenten gemeinsam genutzt werden.
Übersicht
Warum Teams nach dieser Bibliothek suchen
Nutze diese Angular Utility-Bibliothek, um die Low-Level-Bausteine hinter Overlays, Fokus-Traps, Übersetzungs-Helfern und gängigen Template-Utilities nicht neu schreiben zu müssen.
Installieren
npm install ng-hub-ui-utilsSpringen zu
Ideal für
- gemeinsame UI-Infrastruktur
- Overlay-Systeme
- Fokusmanagement
- Template-Helfer
Über utils
ng-hub-ui-utils ist die gemeinsame Grundlage hinter vielen wiederverwendbaren UI-Mustern. Es ist nützlich, wenn Angular-Teams die Low-Level-Bausteine zentralisieren wollen, die Overlay-Systeme, Fokusmanagement, Pipes und Übersetzungs-Helfer projektübergreifend konsistent halten.
Funktionsleitfäden
Focus Management
Tastaturfokus innerhalb von Elementen einfangen und verwalten
Beispiele:
Fokusfalle
Den Fokus mit hubFocusTrap() innerhalb eines Modals oder Dialogs halten.
Focus Trap Demo
Click "Enable Focus Trap" and try to Tab outside the blue box. Focus will stay trapped inside.
Focus Trap Area
Status: 🔓 Free
Focusable Elements
The selector FOCUSABLE_ELEMENTS_SELECTOR finds all focusable elements.
getFocusableBoundaryElements(container)→ [first, last] elementsFokussierbare Elemente
Die fokussierbaren Randelemente mit getFocusableBoundaryElements() abfragen.
Focus Trap Demo
Click "Enable Focus Trap" and try to Tab outside the blue box. Focus will stay trapped inside.
Focus Trap Area
Status: 🔓 Free
Focusable Elements
The selector FOCUSABLE_ELEMENTS_SELECTOR finds all focusable elements.
getFocusableBoundaryElements(container)→ [first, last] elementsInternationalisierung (i18n)
Übersetzungsservices und -Pipes für mehrsprachige Unterstützung
Beispiele:
Übersetzungsservice
HubTranslationService zur Verwaltung von Übersetzungen
TranslatePipe - Basic usage
'welcome' | translate→ Welcome to ng-hub-uiTranslatePipe - With parameters
'greeting' | translate:{ name: 'Carlos' }→ Hello, Carlos!TranslatePipe - Nested keys
'buttons.save' | translate→ Save'buttons.cancel' | translate→ CancelProgrammatic access
translationService.getTranslation('buttons.delete')→ DeleteTranslate-Pipe
TranslatePipe für template-basierte Übersetzungen
TranslatePipe - Basic usage
'welcome' | translate→ Welcome to ng-hub-uiTranslatePipe - With parameters
'greeting' | translate:{ name: 'Carlos' }→ Hello, Carlos!TranslatePipe - Nested keys
'buttons.save' | translate→ Save'buttons.cancel' | translate→ CancelProgrammatic access
translationService.getTranslation('buttons.delete')→ DeleteÜbersetzungs-Provider
provideHubTranslations() für die App-Konfiguration
TranslatePipe - Basic usage
'welcome' | translate→ Welcome to ng-hub-uiTranslatePipe - With parameters
'greeting' | translate:{ name: 'Carlos' }→ Hello, Carlos!TranslatePipe - Nested keys
'buttons.save' | translate→ Save'buttons.cancel' | translate→ CancelProgrammatic access
translationService.getTranslation('buttons.delete')→ DeleteOverlay-System
Positionierte Overlays und schwebende Elemente erstellen
Beispiele:
Overlay-Service
HubOverlayService zur programmatischen Erstellung von Overlays
A connected overlay positioned below the trigger, with a backdrop that closes it on outside click.
Overlay-Referenz
OverlayRef zur Verwaltung des Overlay-Lebenszyklus
A connected overlay positioned below the trigger, with a backdrop that closes it on outside click.
Positionierung
ConnectionPositionPair für flexible Positionierung
A connected overlay positioned below the trigger, with a backdrop that closes it on outside click.
Popup-Service
Vereinfachte Popup-Verwaltung
Beispiele:
Popup-Erstellung
HubPopupService zur schnellen Popup-Erstellung
A connected overlay positioned below the trigger, with a backdrop that closes it on outside click.
Pipes
Utility-Pipes für Templates
Beispiele:
Pipes zur Typprüfung
IsStringPipe, IsObjectPipe, IsObservablePipe
GetPipe - Access nested properties
user | get:'profile.name'→ John Doeuser | get:'profile.address.city'→ New YorkIsStringPipe - Type checking
'Hello' | isString→ true123 | isString→ falseIsObjectPipe - Object detection
{ a: 1 } | isObject→ true'string' | isObject→ falseUcfirstPipe - Capitalize first letter
'hello world' | ucfirst→ Hello worldGetPipe
Auf verschachtelte Objekteigenschaften per Punktnotation zugreifen
GetPipe - Access nested properties
user | get:'profile.name'→ John Doeuser | get:'profile.address.city'→ New YorkIsStringPipe - Type checking
'Hello' | isString→ true123 | isString→ falseIsObjectPipe - Object detection
{ a: 1 } | isObject→ true'string' | isObject→ falseUcfirstPipe - Capitalize first letter
'hello world' | ucfirst→ Hello worldUcfirstPipe
Den ersten Buchstaben eines Strings großschreiben
GetPipe - Access nested properties
user | get:'profile.name'→ John Doeuser | get:'profile.address.city'→ New YorkIsStringPipe - Type checking
'Hello' | isString→ true123 | isString→ falseIsObjectPipe - Object detection
{ a: 1 } | isObject→ true'string' | isObject→ falseUcfirstPipe - Capitalize first letter
'hello world' | ucfirst→ Hello worldUnwrapAsyncPipe
Observables und Promises in Templates entpacken
GetPipe - Access nested properties
user | get:'profile.name'→ John Doeuser | get:'profile.address.city'→ New YorkIsStringPipe - Type checking
'Hello' | isString→ true123 | isString→ falseIsObjectPipe - Object detection
{ a: 1 } | isObject→ true'string' | isObject→ falseUcfirstPipe - Capitalize first letter
'hello world' | ucfirst→ Hello worldHilfsfunktionen
Hilfsfunktionen für allgemeine Zwecke
Beispiele:
Type Guards
isString(), isNumber(), isDefined(), isPromise()
Type Guards
isString('hello')→ trueisNumber(42)→ trueisDefined(null)→ falseisDefined('value')→ trueDeep Equality
equals({a:1}, {a:1})→ trueequals([1,2], [1,2])→ trueObject Access
getValue(user, 'profile.name')→ John DoeString Interpolation
interpolateString('Hello {{name}}', {name: 'World'})→ Hello WorldString Utilities
removeAccents('Ñoño café')→ Nono cafepadNumber(5)→ 05String-Utilities
removeAccents(), interpolateString(), regExpEscape()
Type Guards
isString('hello')→ trueisNumber(42)→ trueisDefined(null)→ falseisDefined('value')→ trueDeep Equality
equals({a:1}, {a:1})→ trueequals([1,2], [1,2])→ trueObject Access
getValue(user, 'profile.name')→ John DoeString Interpolation
interpolateString('Hello {{name}}', {name: 'World'})→ Hello WorldString Utilities
removeAccents('Ñoño café')→ Nono cafepadNumber(5)→ 05Objekt-Utilities
equals() für tiefen Vergleich, getValue() für Punktnotation
Type Guards
isString('hello')→ trueisNumber(42)→ trueisDefined(null)→ falseisDefined('value')→ trueDeep Equality
equals({a:1}, {a:1})→ trueequals([1,2], [1,2])→ trueObject Access
getValue(user, 'profile.name')→ John DoeString Interpolation
interpolateString('Hello {{name}}', {name: 'World'})→ Hello WorldString Utilities
removeAccents('Ñoño café')→ Nono cafepadNumber(5)→ 05DOM-Utilities
closest(), reflow(), getActiveElement()
Type Guards
isString('hello')→ trueisNumber(42)→ trueisDefined(null)→ falseisDefined('value')→ trueDeep Equality
equals({a:1}, {a:1})→ trueequals([1,2], [1,2])→ trueObject Access
getValue(user, 'profile.name')→ John DoeString Interpolation
interpolateString('Hello {{name}}', {name: 'World'})→ Hello WorldString Utilities
removeAccents('Ñoño café')→ Nono cafepadNumber(5)→ 05RxJS-Utilities
runInZone()-Operator für die NgZone-Integration
Type Guards
isString('hello')→ trueisNumber(42)→ trueisDefined(null)→ falseisDefined('value')→ trueDeep Equality
equals({a:1}, {a:1})→ trueequals([1,2], [1,2])→ trueObject Access
getValue(user, 'profile.name')→ John DoeString Interpolation
interpolateString('Hello {{name}}', {name: 'World'})→ Hello WorldString Utilities
removeAccents('Ñoño café')→ Nono cafepadNumber(5)→ 05Scrollbar-Utilities
Scrollbar-Breite messen und kompensieren
Beispiele:
Scrollbar-Breite
Funktionen scrollbarWidth() und scrollbarPadding()
ScrollBar Service
The ScrollBar service helps manage scrollbar visibility and compensate for layout shifts when hiding scrollbars (e.g., when opening modals).
Use Case: Modal Body Lock
When opening a modal, you typically hide the body scrollbar. The ScrollBar.hide() method handles this automatically and returns a reverter function.
Status: 🔓 Normal scrolling
Code Example
import { inject } from '@angular/core';
import { ScrollBar } from 'ng-hub-ui-utils';
export class ModalService {
private scrollBar = inject(ScrollBar);
private revertScrollbar: (() => void) | null = null;
openModal() {
// Hide scrollbar and get reverter function
this.revertScrollbar = this.scrollBar.hide();
}
closeModal() {
// Restore scrollbar
if (this.revertScrollbar) {
this.revertScrollbar();
this.revertScrollbar = null;
}
}
}Transitions
CSS-Transition-Helfer
Beispiele:
Transition ausführen
hubRunTransition() für programmatische CSS-Transitions
Die Live-Vorschau ist für dieses Beispiel noch nicht verfügbar.
Tooltip
Lightweight, themeable tooltips for any element via the [tooltip] directive.
Beispiele:
Tooltip Directive
Apply [tooltip] with a placement to show a positioned label on hover or focus, themed with --hub-tooltip-* variables.
--hub-tooltip-* variablesHauptfunktionen
Letzte Änderungen
Keine Changelog-Einträge verfügbar.