Angular Utility Library | ng-hub-ui-utils
Angular utility library with pipes, focus management, overlays, transitions and translation helpers shared across reusable UI components.
API reference
Here's the full contract for utils: everything you can bind, listen to, project and theme, gathered in one place. Wire up what you need and style what you want — it's standalone and signal-friendly.
Inputs
Dial utils in with 8 inputs. Bind them like any Angular @Input.
| Name | Type | Default | Description |
|---|---|---|---|
hubTooltip · hubTooltipRequired | string | — | Tooltip text. An empty string leaves the host without a tooltip. Bound with the directive attribute itself: [hubTooltip]="label". |
hubTooltip · hubTooltipPlacement | HubTooltipPlacement | 'top' | Placement of the tooltip relative to the host: top, bottom, left or right. |
hubTooltip · hubTooltipDelay | number | 150 | Fade duration in milliseconds, also used as the removal delay when the tooltip hides. |
hubTooltip · hubTooltipShowDelay | number | 0 | Wait in milliseconds before a pointer hover shows the tooltip. Keyboard focus always shows it immediately. |
hubTooltip · hubTooltipOffset | number | 8 | Gap in pixels between the host and the tooltip. |
hubOverflowTooltip · hubOverflowTooltip | string | '' | Tooltip text, shown only while the host content is truncated. Bound with the directive attribute itself: [hubOverflowTooltip]="label". |
hubOverflowTooltip · placement | HubTooltipPlacement | 'top' | Placement of the tooltip relative to the host: top, bottom, left or right. |
hubOverflowTooltip · hubOverflowTooltipMeasure | string | undefined | undefined | CSS selector, resolved inside the host, of the element whose truncation decides whether the tooltip shows. Unset, or matching nothing, the host measures itself. |
Outputs
No outputs documented yet.
Methods
Drive utils from code — 20 methods on its programmatic surface.
| Name | Signature | Returns | Description |
|---|---|---|---|
HubTranslatePipe | {{ key | hubTranslate: params }} | string | Translates a key through HubTranslationService and re-renders when the translations change. The unprefixed `translate` pipe (TranslatePipe) still works but is deprecated. |
HubGetPipe | {{ object | hubGet: 'path.to.property' : defaultValue }} | any | Reads a nested property by dot path, returning defaultValue when the path does not resolve. The unprefixed `get` pipe (GetPipe) is deprecated. |
HubIsStringPipe | {{ value | hubIsString }} | boolean | Whether the value is a string. The unprefixed `isString` pipe (IsStringPipe) is deprecated. |
HubIsObjectPipe | {{ value | hubIsObject }} | boolean | Whether the value is an object. The unprefixed `isObject` pipe (IsObjectPipe) is deprecated. |
HubIsObservablePipe | {{ value | hubIsObservable }} | boolean | Whether the value is an Observable. The unprefixed `isObservable` pipe (IsObservablePipe) is deprecated. |
HubUnwrapAsyncPipe | {{ valueOrObservable | hubUnwrapAsync }} | T | null | Returns plain values as they are and subscribes to Observables, unsubscribing on destroy. The unprefixed `unwrapAsync` pipe (UnwrapAsyncPipe) is deprecated. |
UcfirstPipe | {{ 'hello' | ucfirst }} | string | Capitalises the first letter of a string: 'hello' becomes 'Hello'. |
HubTranslationService | getTranslation(key: string): any · setTranslations(translations: Record<string, string>): void | — | Holds the translations every Hub UI library reads. It is not provided in root: it comes with the translation adapter providers, and translationObserver emits on every change. |
OverlayService | create(config?: OverlayConfig): OverlayRef · position(): OverlayPosition | — | Root-provided service that creates overlays programmatically and builds their position strategy. |
PopupService<T> | open(content?: string | TemplateRef<any>, templateContext?: any, animation?: boolean) · close(animation?: boolean): Observable<void> | { windowRef: ComponentRef<T>; transition$: Observable<void> } | Opens one popup window component with projected content and closes it, optionally animated. |
hubFocusTrap | hubFocusTrap(zone: NgZone, element: HTMLElement, stopFocusTrap$: Observable<any>, refocusOnClick = false) | — | Keeps keyboard focus inside an element until stopFocusTrap$ emits; used by modals and dialogs. |
interpolateString | interpolateString(expr = '', params = {}, templateMatcher = /{{\s?([^{}\s]*)\s?}}/g) | string | Replaces {{ placeholders }} with values from params: interpolateString('Hello {{name}}', { name: 'World' }) gives 'Hello World'. |
getValue | getValue(target: any, key: string): any | any | Reads a nested property with dot notation, e.g. getValue(obj, 'user.profile.name'). |
equals | equals(o1: any, o2: any): boolean | boolean | Deep equality for objects and arrays. |
hubAnchorToViewport | hubAnchorToViewport({ anchor, box, viewport, side, offset }) | { x, y, side, flipped } | Places a box against an anchor on the preferred side, flips to the opposite only when that side cannot hold it and the opposite has more room, and clamps on the cross axis. |
hubViewportOf | hubViewportOf(element) | { width, height } | null | Reads the viewport through the element's own view; null where there is none, such as a server render. |
hubFitsInViewport | hubFitsInViewport(point, size, viewport, margin) | boolean | Whether a box of that size placed at that point lies entirely inside the viewport, once the margin is paid. |
hubClampToViewport | hubClampToViewport(point, size, viewport, margin) | { x, y } | Pulls a box back inside the viewport without moving it further than it has to. |
hubOppositeSide | hubOppositeSide('inline-start') | HubAnchorSide | The side directly across the anchor: 'inline-start' gives 'inline-end'. |
hubToAnchorSide / hubToPhysicalSide | hubToAnchorSide('left', rtl) · hubToPhysicalSide('inline-end', rtl) | — | Round-trips a physical edge through the logical axis, so an API spelled in top/bottom/left/right keeps its meaning under RTL. |
Templates
No templates documented yet.