@agorapulse/ui-components 22.0.30 → 22.0.32

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.
@@ -0,0 +1,167 @@
1
+ import { Side, Placement, Middleware } from '@floating-ui/dom';
2
+ import * as _angular_core from '@angular/core';
3
+ import { TemplateRef, Type, ComponentRef } from '@angular/core';
4
+ import { OverlayRef } from '@angular/cdk/overlay';
5
+
6
+ /**
7
+ * The twelve placements, aliased from Floating UI rather than redeclared. The trade-off: this puts
8
+ * `@floating-ui/dom` in our **public** type surface, so its next major would move our types too.
9
+ *
10
+ * There is no `'auto'`; an unset placement is derived by `defaultPlacementFor`.
11
+ */
12
+ type FloatingPlacement = Placement;
13
+ /** The four opening sides. Floating UI's `Side`, for the same reason. */
14
+ type FloatingSide = Side;
15
+ declare function sideOf(placement: FloatingPlacement): FloatingSide;
16
+ declare function isVertical(placement: FloatingPlacement): boolean;
17
+
18
+ /** A minimal rect — neither `DOMRect` nor any DOM dependency, so the pure units stay pure. */
19
+ interface FloatingRect {
20
+ x: number;
21
+ y: number;
22
+ width: number;
23
+ height: number;
24
+ }
25
+
26
+ /** What the panel connects to. */
27
+ type FloatingAnchorMode = 'trigger' | 'pointer' | 'pointer-free';
28
+ /**
29
+ * The placement derived when `placement` is unset. Reads the **configured** anchor mode, not the
30
+ * resolved one: a keyboard opening falls back to the trigger, and if the alignment followed, the
31
+ * component would change shape between mouse and keyboard.
32
+ */
33
+ declare function defaultPlacementFor(anchor: FloatingAnchorMode): FloatingPlacement;
34
+ /**
35
+ * `'pointer'` is a hybrid whose zero dimension is the **cross-axis** one; a lateral panel built
36
+ * from a fully point-like anchor would sit inside its own trigger. `'pointer-free'` is the point
37
+ * itself. Both fall back to the trigger when there is no click.
38
+ *
39
+ * @param vertical The opening axis. Invariant under the flip, which only swaps the main axis.
40
+ */
41
+ declare function resolveAnchorRect(anchor: FloatingAnchorMode, triggerRect: FloatingRect, vertical: boolean, clickPoint?: {
42
+ x: number;
43
+ y: number;
44
+ }): FloatingRect;
45
+ /** A point expressed as a proportion of the trigger, on each axis. */
46
+ interface ClickRatio {
47
+ x: number;
48
+ y: number;
49
+ }
50
+
51
+ interface ApArrowOptions {
52
+ /** What the tip aims at — see {@link resolveArrowOffset}. */
53
+ targetMode: 'anchor' | 'pointer';
54
+ /** The configured anchor mode. Decides how the click is recovered from the reference rect. */
55
+ anchorMode: FloatingAnchorMode;
56
+ /** The clicked point as a proportion of the trigger. Absent on a keyboard opening. */
57
+ clickRatio?: ClickRatio;
58
+ }
59
+ /** What the middleware leaves in `middlewareData.apArrow`. */
60
+ interface ApArrowData {
61
+ /** The arrow's offset from the panel's start edge, along the cross axis. */
62
+ offset: number;
63
+ /** The side of the panel the arrow sits on — read from the **resolved** placement. */
64
+ side: FloatingSide;
65
+ /** The panel covers its **anchor** — in the POI mode the trigger may be covered on purpose. */
66
+ hidden: boolean;
67
+ }
68
+ /**
69
+ * Replaces Floating UI's `arrow`, which aims at the centre of the *reference*: on a 280px trigger
70
+ * with a 100px panel that centre is out of reach and the tip clamps to a corner at 80, where the
71
+ * intersection's centre is 42 (plate 22). {@link resolveArrowOffset} holds the rule.
72
+ *
73
+ * Must run last, after `shift`, since it reads the panel's final position.
74
+ */
75
+ declare function apArrow(options: ApArrowOptions): Middleware;
76
+
77
+ interface ArrowOffsetInput {
78
+ /** The side of the panel the arrow sits on — the **resolved** side, not the wanted one. */
79
+ side: FloatingSide;
80
+ anchorRect: FloatingRect;
81
+ floatingRect: FloatingRect;
82
+ /** `'anchor'` aims at the anchor ∩ panel intersection's centre, `'pointer'` at the click. */
83
+ targetMode: 'anchor' | 'pointer';
84
+ clickPoint?: {
85
+ x: number;
86
+ y: number;
87
+ };
88
+ }
89
+ interface ArrowOffsetResult {
90
+ /** The arrow's offset from the panel's start edge, along the cross axis. */
91
+ offset: number;
92
+ clamped: boolean;
93
+ /** The click fell outside the panel, so the intersection centre was used instead. */
94
+ fellBack: boolean;
95
+ /** The panel is too narrow: the clamp range inverts and the arrow is centred outright. */
96
+ centered: boolean;
97
+ }
98
+ /**
99
+ * Three rules, in order:
100
+ *
101
+ * 1. Aim at the centre of the **anchor ∩ panel intersection**, never the anchor's own centre —
102
+ * `apArrow` documents why this diverges from Floating UI.
103
+ * 2. In `'pointer'` mode, aim at the click, falling back to rule 1 — discontinuously, as the
104
+ * plates specify — when the click lands outside the panel.
105
+ * 3. Clamp to leave the corner radius clear. Below `arrow + 2 × radius` = 24px the range inverts,
106
+ * and the arrow is centred outright.
107
+ *
108
+ * The flags say which rule applied, so the generated plate cases can assert the path taken.
109
+ */
110
+ declare function resolveArrowOffset(input: ArrowOffsetInput): ArrowOffsetResult;
111
+
112
+ /**
113
+ * The panel edge an arrow sits on: a panel placed `bottom` hangs below its anchor, so its tip is on
114
+ * its top edge. Give it the **resolved** placement, or a flipped panel grows its arrow away.
115
+ */
116
+ declare function arrowSideFor(placement: FloatingPlacement): FloatingSide;
117
+ /** Ready-to-use CSS values, `'auto'` for the sides that do not apply. */
118
+ interface ArrowPlacement {
119
+ top: string;
120
+ right: string;
121
+ bottom: string;
122
+ left: string;
123
+ rotate: string;
124
+ }
125
+ /**
126
+ * The insets and rotation `_floating-arrow.scss` reads off the pane. The rotation-centre
127
+ * compensation lives here rather than in the stylesheet, where it could not be tested.
128
+ *
129
+ * @param side The panel edge the arrow sits on — the **resolved** side, not the wanted one.
130
+ * @param offset The offset from the panel's start edge, along the cross axis.
131
+ */
132
+ declare function resolveArrowPlacement(side: FloatingSide, offset: number): ArrowPlacement;
133
+
134
+ interface FloatingOverlayConfig {
135
+ /** Unset means derived from `anchor`. There is no `'auto'` value. */
136
+ placement?: FloatingPlacement;
137
+ anchor?: FloatingAnchorMode;
138
+ arrow?: boolean;
139
+ arrowTarget?: 'anchor' | 'pointer';
140
+ showBackdrop?: boolean;
141
+ panelClass?: string | string[];
142
+ /** Fallback for the two handlers below. */
143
+ onClose?: () => void;
144
+ /** Escape, which always closes. Unset means `onClose`. */
145
+ onEscape?: () => void;
146
+ /** Outside click. Unset means `onClose`. */
147
+ onOutsideClick?: () => void;
148
+ /**
149
+ * Elements that carry their own toggle, so a click on them is not "the outside". Read on every
150
+ * event, since the list may change while the floating is open.
151
+ *
152
+ * Without this, the CDK's capture-phase dispatcher closes before a secondary trigger sees the
153
+ * click, that trigger reopens, and the toggle never closes again.
154
+ */
155
+ additionalTriggers?: () => readonly HTMLElement[];
156
+ }
157
+ declare function createFloatingOverlay(): {
158
+ readonly overlayRef: OverlayRef | null;
159
+ isOpen: _angular_core.Signal<boolean>;
160
+ open: <T = unknown>(content: TemplateRef<unknown> | Type<T>, triggerElement?: HTMLElement, config?: FloatingOverlayConfig, event?: MouseEvent) => ComponentRef<T> | null;
161
+ close: () => void;
162
+ updatePosition: () => void;
163
+ };
164
+ type FloatingOverlayInstance = ReturnType<typeof createFloatingOverlay>;
165
+
166
+ export { apArrow, arrowSideFor, createFloatingOverlay, defaultPlacementFor, isVertical, resolveAnchorRect, resolveArrowOffset, resolveArrowPlacement, sideOf };
167
+ export type { ApArrowData, ApArrowOptions, ArrowOffsetInput, ArrowOffsetResult, ArrowPlacement, FloatingAnchorMode, FloatingOverlayConfig, FloatingOverlayInstance, FloatingPlacement, FloatingRect, FloatingSide };