ng-hub-ui-utils 22.3.2 → 22.5.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.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-hub-ui-utils",
3
- "version": "22.3.2",
3
+ "version": "22.5.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=18.0.0",
6
6
  "@angular/core": ">=18.0.0"
@@ -13,11 +13,11 @@
13
13
  --hub-overlay-bg: var(--hub-sys-surface-elevated, #f8f9fa);
14
14
  --hub-overlay-border-radius: var(--hub-sys-radius-sm, 0.25rem);
15
15
  --hub-overlay-shadow: var(--hub-sys-shadow, 0 0.5rem 1rem rgba(0, 0, 0, 0.15));
16
- --hub-overlay-z-index: var(--hub-sys-zindex-dropdown, 1000);
17
- --hub-overlay-backdrop-z-index: calc(var(--hub-sys-zindex-dropdown, 1000) - 1);
16
+ --hub-overlay-zindex: var(--hub-sys-zindex-dropdown, 1000);
17
+ --hub-overlay-backdrop-zindex: calc(var(--hub-sys-zindex-dropdown, 1000) - 1);
18
18
 
19
19
  position: absolute;
20
- z-index: var(--hub-overlay-z-index);
20
+ z-index: var(--hub-overlay-zindex);
21
21
  background: var(--hub-overlay-bg);
22
22
  border-radius: var(--hub-overlay-border-radius);
23
23
  box-shadow: var(--hub-overlay-shadow);
@@ -30,7 +30,7 @@
30
30
  left: 0;
31
31
  width: 100%;
32
32
  height: 100%;
33
- z-index: var(--hub-overlay-backdrop-z-index, calc(var(--hub-sys-zindex-dropdown, 1000) - 1));
33
+ z-index: var(--hub-overlay-backdrop-zindex, calc(var(--hub-sys-zindex-dropdown, 1000) - 1));
34
34
  }
35
35
 
36
36
  .hub-overlay-transparent-backdrop {
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Tooltip styles for the `[tooltip]` directive.
3
+ *
4
+ * The tooltip element is portaled to `<body>`, so it cannot inherit scoped
5
+ * variables from the host's ancestors — the directive forwards any host-resolved
6
+ * `--hub-tooltip-*` value onto the element inline. These rules provide the base
7
+ * appearance and the component-token defaults, each backed by a canonical
8
+ * `--hub-sys-*` / `--hub-ref-*` token, mirroring the `--hub-overlay-*` pattern in
9
+ * this library.
10
+ *
11
+ * Import once in your app styles:
12
+ * @use 'ng-hub-ui-utils/styles/tooltip';
13
+ */
14
+
15
+ .hub-tooltip {
16
+ /* Component tokens, each backed by a canonical token. */
17
+ --hub-tooltip-bg: var(--hub-ref-color-black, #000);
18
+ --hub-tooltip-color: var(--hub-ref-color-white, #fff);
19
+ --hub-tooltip-opacity: 0.9;
20
+ --hub-tooltip-padding-x: var(--hub-ref-space-2, 0.5rem);
21
+ --hub-tooltip-padding-y: var(--hub-ref-space-1, 0.25rem);
22
+ --hub-tooltip-border-radius: var(--hub-sys-radius-md, 0.375rem);
23
+ --hub-tooltip-font-size: var(--hub-ref-font-size-sm, 0.875rem);
24
+ --hub-tooltip-font-weight: var(--hub-ref-font-weight-base, 400);
25
+ --hub-tooltip-line-height: var(--hub-ref-line-height-base, 1.5);
26
+ --hub-tooltip-max-width: 200px;
27
+ --hub-tooltip-zindex: var(--hub-sys-zindex-tooltip, 1080);
28
+ --hub-tooltip-transition-duration: 0.15s;
29
+ --hub-tooltip-shadow: none;
30
+ --hub-tooltip-font-family: var(--hub-ref-font-family-base, inherit);
31
+
32
+ position: absolute;
33
+ z-index: var(--hub-tooltip-zindex);
34
+ display: block;
35
+ margin: 0;
36
+ max-width: var(--hub-tooltip-max-width);
37
+ padding: var(--hub-tooltip-padding-y) var(--hub-tooltip-padding-x);
38
+ font-family: var(--hub-tooltip-font-family);
39
+ font-size: var(--hub-tooltip-font-size);
40
+ font-weight: var(--hub-tooltip-font-weight);
41
+ line-height: var(--hub-tooltip-line-height);
42
+ text-align: center;
43
+ word-wrap: break-word;
44
+ white-space: normal;
45
+ color: var(--hub-tooltip-color);
46
+ background-color: var(--hub-tooltip-bg);
47
+ border-radius: var(--hub-tooltip-border-radius);
48
+ box-shadow: var(--hub-tooltip-shadow);
49
+ opacity: 0;
50
+ pointer-events: none;
51
+ transition: opacity var(--hub-tooltip-transition-duration) ease-in-out;
52
+ }
53
+
54
+ .hub-tooltip--show {
55
+ opacity: var(--hub-tooltip-opacity);
56
+ }
@@ -770,47 +770,137 @@ declare class ScrollBar {
770
770
  /** Supported tooltip placements relative to the host element. */
771
771
  type HubTooltipPlacement = 'top' | 'bottom' | 'left' | 'right';
772
772
  /**
773
- * Lightweight, dependency-free tooltip directive.
774
- *
775
- * Apply `[tooltip]` to any element to show a positioned label on hover/focus.
776
- * The tooltip element is appended to `<body>` so it is never clipped by an
777
- * overflow container, and every visual aspect is themeable through
778
- * `--hub-tooltip-*` CSS variables.
773
+ * Imperative configuration shared by the tooltip directive and any consumer that
774
+ * drives a tooltip through `HubTooltipController`.
779
775
  */
780
- declare class TooltipDirective implements OnDestroy {
781
- /** Tooltip text content. */
782
- readonly tooltipTitle: i0.InputSignal<string>;
776
+ interface HubTooltipOptions {
783
777
  /** Placement of the tooltip relative to the host. */
784
- readonly placement: i0.InputSignal<HubTooltipPlacement>;
778
+ placement?: HubTooltipPlacement;
785
779
  /** Fade duration in milliseconds, also used as the removal delay on hide. */
786
- readonly delay: i0.InputSignal<number>;
780
+ delay?: number;
787
781
  /** Gap in pixels between the host and the tooltip. */
788
- readonly offset: i0.InputSignal<number>;
782
+ offset?: number;
783
+ }
784
+ /**
785
+ * Live handle returned by `HubTooltipAdapter.attach`, used to update or tear
786
+ * down a tooltip.
787
+ */
788
+ interface HubTooltipHandle {
789
+ /** Updates the tooltip label (empty string disables it). */
790
+ update(text: string): void;
791
+ /** Detaches listeners and removes the tooltip. */
792
+ destroy(): void;
793
+ }
794
+ /**
795
+ * Minimal, framework-agnostic tooltip contract.
796
+ *
797
+ * It is deliberately defined by structure (not by import) so any primitive in
798
+ * the ecosystem — such as `ng-hub-ui-badges` — can accept this implementation
799
+ * through its own token without taking a hard dependency on this package.
800
+ */
801
+ interface HubTooltipAdapter {
802
+ /**
803
+ * Attaches a hub-ui tooltip to `host` with the given initial `text`.
804
+ * @returns A handle to update or tear down the tooltip.
805
+ */
806
+ attach(host: HTMLElement, text: string, options?: HubTooltipOptions): HubTooltipHandle;
807
+ }
808
+
809
+ /**
810
+ * Framework-agnostic tooltip engine.
811
+ *
812
+ * Binds hover/focus listeners to a host element and renders a body-portaled,
813
+ * `--hub-tooltip-*`-themeable label on demand. It owns no Angular dependency, so
814
+ * it can be reused both by the `[tooltip]` directive and by other primitives
815
+ * (e.g. a badge overflow tooltip) that want the exact same visual contract
816
+ * without re-implementing the DOM logic.
817
+ *
818
+ * Styles ship in `styles/tooltip.scss`. Import once in your app:
819
+ * `@use 'ng-hub-ui-utils/styles/tooltip';`.
820
+ */
821
+ declare class HubTooltipController {
822
+ private readonly host;
789
823
  private tooltipEl;
790
824
  private hideTimeout;
791
- private readonly host;
792
- private readonly renderer;
793
- private readonly document;
794
- constructor();
795
- ngOnDestroy(): void;
796
- protected onShow(): void;
797
- protected onHide(): void;
798
- /** Injects the shared stylesheet into `<head>` once per document. */
799
- private ensureStyles;
825
+ private text;
826
+ private placement;
827
+ private delay;
828
+ private offset;
829
+ private readonly doc;
830
+ private readonly view;
831
+ private readonly onShow;
832
+ private readonly onHide;
833
+ /**
834
+ * @param host Element the tooltip is anchored to and whose pointer/focus
835
+ * events trigger the tooltip.
836
+ * @param options Initial placement, delay and offset.
837
+ */
838
+ constructor(host: HTMLElement, options?: HubTooltipOptions);
839
+ /**
840
+ * Updates the tooltip label. An empty value disables the tooltip and hides any
841
+ * currently visible instance.
842
+ * @param text New tooltip content.
843
+ */
844
+ setText(text: string): void;
845
+ /**
846
+ * Updates placement/delay/offset. Only provided keys are overwritten.
847
+ * @param options Partial tooltip options.
848
+ */
849
+ setOptions(options?: HubTooltipOptions): void;
850
+ /** Detaches listeners and removes any live tooltip element. */
851
+ destroy(): void;
800
852
  /** Creates, positions and reveals the tooltip element. */
801
853
  private show;
802
854
  /** Fades the tooltip out and removes it after the fade completes. */
803
855
  private hide;
804
856
  /** Removes the tooltip element immediately. */
805
- private destroyTooltip;
857
+ private removeElement;
806
858
  /**
807
859
  * Copies any `--hub-tooltip-*` value defined on the host (or its scope) onto
808
860
  * the body-portaled tooltip, so scoped theming applies despite the portal.
809
861
  */
810
862
  private forwardThemeVars;
811
863
  private clearHideTimeout;
812
- /** Positions the tooltip around the host according to `placement`. */
864
+ /** Positions the tooltip around the host according to the current placement. */
813
865
  private position;
866
+ }
867
+
868
+ /**
869
+ * Ready-made {@link HubTooltipAdapter} backed by {@link HubTooltipController}.
870
+ *
871
+ * Wire it into any ng-hub-ui primitive that exposes an optional tooltip token,
872
+ * e.g. `provideHubBadgeTooltip(hubTooltipAdapter)`.
873
+ */
874
+ declare const hubTooltipAdapter: HubTooltipAdapter;
875
+
876
+ /**
877
+ * Lightweight tooltip directive.
878
+ *
879
+ * Apply `[tooltip]` to any element to show a positioned label on hover/focus.
880
+ * The tooltip element is appended to `<body>` so it is never clipped by an
881
+ * overflow container, and every visual aspect is themeable through
882
+ * `--hub-tooltip-*` CSS variables.
883
+ *
884
+ * All DOM work is delegated to {@link HubTooltipController}, so the directive and
885
+ * any imperative consumer (e.g. a badge overflow tooltip) share the exact same
886
+ * behaviour and styling.
887
+ *
888
+ * Styles ship in `styles/tooltip.scss` (mirroring `styles/overlay.scss`). Import
889
+ * it once in your app: `@use 'ng-hub-ui-utils/styles/tooltip';`.
890
+ */
891
+ declare class TooltipDirective implements OnDestroy {
892
+ /** Tooltip text content. */
893
+ readonly tooltipTitle: i0.InputSignal<string>;
894
+ /** Placement of the tooltip relative to the host. */
895
+ readonly placement: i0.InputSignal<HubTooltipPlacement>;
896
+ /** Fade duration in milliseconds, also used as the removal delay on hide. */
897
+ readonly delay: i0.InputSignal<number>;
898
+ /** Gap in pixels between the host and the tooltip. */
899
+ readonly offset: i0.InputSignal<number>;
900
+ private readonly host;
901
+ private readonly controller;
902
+ constructor();
903
+ ngOnDestroy(): void;
814
904
  static ɵfac: i0.ɵɵFactoryDeclaration<TooltipDirective, never>;
815
905
  static ɵdir: i0.ɵɵDirectiveDeclaration<TooltipDirective, "[tooltip]", never, { "tooltipTitle": { "alias": "tooltip"; "required": true; "isSignal": true; }; "placement": { "alias": "placement"; "required": false; "isSignal": true; }; "delay": { "alias": "delay"; "required": false; "isSignal": true; }; "offset": { "alias": "offset"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
816
906
  }
@@ -955,5 +1045,5 @@ declare function debouncedSignal<T>(sourceSignal: Signal<T>, debounceDelay?: num
955
1045
  */
956
1046
  declare function getActiveElement(root?: Document | ShadowRoot): Element | null;
957
1047
 
958
- export { ContentRef, FOCUSABLE_ELEMENTS_SELECTOR, GetPipe, HUB_TRANSLATION_CONFIG, HubDragDropService, HubTranslationService, IsObjectPipe, IsObservablePipe, IsStringPipe, OverlayPosition, OverlayRef, OverlayService, PopupService, ScrollBar, TooltipDirective, TranslatePipe, UcfirstPipe, UnwrapAsyncPipe, clamp, closest, computeTargetIndex, containsNode, copyArrayItem, createNativeDragImage, createPointerDragSession, debouncedSignal, equals, generateUniqueId, getActiveElement, getFocusableBoundaryElements, getValue, getValueInRange, hubCompleteTransition, hubFocusTrap, hubRunTransition, interpolateString, isDefined, isInteger, isNumber, isObject, isPromise, isString, mergeDeep, moveItemInArray, padNumber, provideHubTranslation, reflow, regExpEscape, removeAccents, resolveDropPosition, runInZone, toAbsoluteIndex, toInteger, toString, transferArrayItem };
959
- export type { ActiveDrag, ConnectionPosition, DragAxis, DragContainerRef, DragImageResult, DragPointerMode, DragRegistration, DragTarget, DropPosition, DropRect, HorizontalConnectionPos, HubTooltipPlacement, HubTranslationConfig, OverlayConfig, PointerDragSession, PointerDragSessionConfig, ScrollbarReverter, TransitionCtx, TransitionEndFn, TransitionOptions, TransitionStartFn, VerticalConnectionPos };
1048
+ export { ContentRef, FOCUSABLE_ELEMENTS_SELECTOR, GetPipe, HUB_TRANSLATION_CONFIG, HubDragDropService, HubTooltipController, HubTranslationService, IsObjectPipe, IsObservablePipe, IsStringPipe, OverlayPosition, OverlayRef, OverlayService, PopupService, ScrollBar, TooltipDirective, TranslatePipe, UcfirstPipe, UnwrapAsyncPipe, clamp, closest, computeTargetIndex, containsNode, copyArrayItem, createNativeDragImage, createPointerDragSession, debouncedSignal, equals, generateUniqueId, getActiveElement, getFocusableBoundaryElements, getValue, getValueInRange, hubCompleteTransition, hubFocusTrap, hubRunTransition, hubTooltipAdapter, interpolateString, isDefined, isInteger, isNumber, isObject, isPromise, isString, mergeDeep, moveItemInArray, padNumber, provideHubTranslation, reflow, regExpEscape, removeAccents, resolveDropPosition, runInZone, toAbsoluteIndex, toInteger, toString, transferArrayItem };
1049
+ export type { ActiveDrag, ConnectionPosition, DragAxis, DragContainerRef, DragImageResult, DragPointerMode, DragRegistration, DragTarget, DropPosition, DropRect, HorizontalConnectionPos, HubTooltipAdapter, HubTooltipHandle, HubTooltipOptions, HubTooltipPlacement, HubTranslationConfig, OverlayConfig, PointerDragSession, PointerDragSessionConfig, ScrollbarReverter, TransitionCtx, TransitionEndFn, TransitionOptions, TransitionStartFn, VerticalConnectionPos };
Binary file