ember-attacher 4.4.0 → 5.0.0-beta.2
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.
- package/README.md +416 -0
- package/dist/{attacher-core-m7x5g04q.js → attacher-core-DIAMEQR6.js} +1001 -978
- package/dist/attacher-core-DIAMEQR6.js.map +1 -0
- package/dist/attacher-overlay-BCAfauc_.js +40 -0
- package/dist/attacher-overlay-BCAfauc_.js.map +1 -0
- package/dist/components/attach-popover.d.ts +10 -12
- package/dist/components/attach-popover.js +7 -4
- package/dist/components/attach-popover.js.map +1 -1
- package/dist/components/attach-tooltip.d.ts +11 -13
- package/dist/components/attach-tooltip.js +10 -7
- package/dist/components/attach-tooltip.js.map +1 -1
- package/dist/components/attacher.d.ts +12 -12
- package/dist/components/attacher.js +7 -15
- package/dist/components/attacher.js.map +1 -1
- package/dist/defaults.d.ts +27 -28
- package/dist/defaults.js +11 -11
- package/dist/defaults.js.map +1 -1
- package/dist/index.d.ts +9 -60
- package/dist/index.js +13 -3
- package/dist/index.js.map +1 -1
- package/dist/{is-visible-DQGdmVDv.js → is-visible-CeN9qZyc.js} +6 -3
- package/dist/is-visible-CeN9qZyc.js.map +1 -0
- package/dist/lib/a11y.d.ts +77 -0
- package/dist/lib/attacher-core.d.ts +342 -0
- package/dist/lib/attacher-overlay.d.ts +18 -0
- package/dist/lib/attachment-tree.d.ts +32 -0
- package/dist/lib/delay-group.d.ts +15 -0
- package/dist/lib/dom.d.ts +40 -0
- package/dist/lib/host.d.ts +21 -0
- package/dist/lib/positioning.d.ts +27 -0
- package/dist/lib/schedule.d.ts +12 -0
- package/dist/lib/singleton-tooltip-pool.d.ts +32 -0
- package/dist/lib/target-resolution.d.ts +44 -0
- package/dist/modifiers/tooltip.d.ts +18 -15
- package/dist/modifiers/tooltip.js +55 -67
- package/dist/modifiers/tooltip.js.map +1 -1
- package/dist/styles/ember-attacher.css +1 -1
- package/dist/template-registry.d.ts +7 -11
- package/dist/test-support/assert-attached.d.ts +27 -0
- package/dist/test-support/index.d.ts +2 -2
- package/dist/test-support/index.js +95 -1
- package/dist/test-support/index.js.map +1 -1
- package/dist/test-support/is-visible.d.ts +1 -2
- package/package.json +18 -7
- package/dist/_app_/components/basic-attacher.js +0 -1
- package/dist/attacher-core-m7x5g04q.js.map +0 -1
- package/dist/components/basic-attacher.d.ts +0 -151
- package/dist/components/basic-attacher.js +0 -44
- package/dist/components/basic-attacher.js.map +0 -1
- package/dist/is-visible-DQGdmVDv.js.map +0 -1
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import type Owner from '@ember/owner';
|
|
2
|
+
import { type AutoUpdateOptions, type ComputePositionConfig, type MiddlewareData, type Placement, type Strategy } from '@floating-ui/dom';
|
|
3
|
+
import { type FunctionBasedModifier } from 'ember-modifier';
|
|
4
|
+
import { type AttacherAnimation } from '../defaults';
|
|
5
|
+
import { AttachmentAriaController } from './a11y';
|
|
6
|
+
import { type PointerOrigin } from './dom';
|
|
7
|
+
import { type ScheduledHandle } from './schedule';
|
|
8
|
+
import { type AttachmentTarget, type AttachmentTargetInput } from './target-resolution';
|
|
9
|
+
export type { AttacherAnimation };
|
|
10
|
+
export type AttacherTarget = AttachmentTargetInput;
|
|
11
|
+
export type AttacherTargetModifier<TData = unknown> = FunctionBasedModifier<{
|
|
12
|
+
Element: Element;
|
|
13
|
+
Args: {
|
|
14
|
+
Positional: [data?: TData];
|
|
15
|
+
Named: {
|
|
16
|
+
data?: TData;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
export interface AttacherBlockParams<TData = unknown> {
|
|
21
|
+
/** Element modifier registering an element as a Target and associating optional `data`. */
|
|
22
|
+
target: AttacherTargetModifier<TData>;
|
|
23
|
+
/** Element modifier marking the caller's Attachment DOM element (headless `<Attacher>`). */
|
|
24
|
+
attachment: FunctionBasedModifier<{
|
|
25
|
+
Element: HTMLElement;
|
|
26
|
+
}>;
|
|
27
|
+
/** Element modifier registering a custom arrow element. */
|
|
28
|
+
arrow: FunctionBasedModifier<{
|
|
29
|
+
Element: HTMLElement;
|
|
30
|
+
}>;
|
|
31
|
+
/** Programmatically registers an explicit target Element or VirtualElement and optional `data`. */
|
|
32
|
+
setTarget: (target: AttachmentTarget | null | undefined, data?: TData) => void;
|
|
33
|
+
/** Programmatically shows the attachment (optionally switching target and data). */
|
|
34
|
+
show: (target?: AttachmentTarget, data?: TData) => void;
|
|
35
|
+
/** Programmatically hides the attachment. */
|
|
36
|
+
hide: () => void;
|
|
37
|
+
/** Programmatically toggles visibility of the attachment. */
|
|
38
|
+
toggle: () => void;
|
|
39
|
+
/** Recomputes Floating UI positioning immediately. */
|
|
40
|
+
update: () => void;
|
|
41
|
+
/** Current open visibility state. */
|
|
42
|
+
readonly isShown: boolean;
|
|
43
|
+
/** Whether inner content should render (respecting `@lazyRender`). */
|
|
44
|
+
readonly shouldRender: boolean;
|
|
45
|
+
/** Payload associated with the currently active Target (`{{a.target data}}` / `setTarget`). */
|
|
46
|
+
readonly data: TData | undefined;
|
|
47
|
+
/** Resolved Floating UI placement after middleware execution. */
|
|
48
|
+
readonly placement: Placement;
|
|
49
|
+
/** Latest Floating UI `middlewareData` from `computePosition()`. */
|
|
50
|
+
readonly middlewareData: MiddlewareData;
|
|
51
|
+
}
|
|
52
|
+
export interface AttacherNamedBlocks<TData = unknown> {
|
|
53
|
+
default: [attacher: AttacherBlockParams<TData>];
|
|
54
|
+
target: [target: AttacherTargetModifier<TData>, attacher: AttacherBlockParams<TData>];
|
|
55
|
+
content: [attacher: AttacherBlockParams<TData>];
|
|
56
|
+
}
|
|
57
|
+
export interface AttacherArgs {
|
|
58
|
+
/** Animation applied when showing and hiding the attachment. Defaults to `'fill'`. */
|
|
59
|
+
animation?: AttacherAnimation | null;
|
|
60
|
+
/** ARIA role attribute applied to the attachment element (`'dialog'` by default for `<AttachPopover>`, `'tooltip'` for `<AttachTooltip>`). */
|
|
61
|
+
ariaRole?: string;
|
|
62
|
+
/** Whether to render an arrow element positioned by Floating UI. Defaults to `false`. */
|
|
63
|
+
arrow?: boolean;
|
|
64
|
+
/** Keeps attachment position synced via Floating UI `autoUpdate`. Defaults to `true`. */
|
|
65
|
+
autoUpdate?: boolean | AutoUpdateOptions;
|
|
66
|
+
/** CSS class(es) applied to the inner attachment container. */
|
|
67
|
+
class?: string | null;
|
|
68
|
+
/** Target DOM Element, single-match CSS selector string, or Floating UI `VirtualElement`. */
|
|
69
|
+
target?: AttacherTarget | null;
|
|
70
|
+
/** Delay in ms (number or numeric string) before hiding. Defaults to `0`. */
|
|
71
|
+
hideDelay?: number | string;
|
|
72
|
+
/** Exit transition duration in ms (number or numeric string). Defaults to `300`. */
|
|
73
|
+
hideDuration?: number | string;
|
|
74
|
+
/** Space-separated hide triggers (`click`, `clickout`, `mouseleave`, `blur`, `focusout`, `escapekey`), or `null` to disable. */
|
|
75
|
+
hideOn?: string | null;
|
|
76
|
+
/** DOM `id` on the attachment element (also used for ARIA linkage, `[popovertarget]`, and `[interestfor]`). */
|
|
77
|
+
id?: string;
|
|
78
|
+
/** Keeps attachment open when pointer/focus enters it or traverses the `safePolygon` corridor. Defaults to `true`. */
|
|
79
|
+
interactive?: boolean;
|
|
80
|
+
/** Controlled visibility flag. */
|
|
81
|
+
isShown?: boolean;
|
|
82
|
+
/** Defers rendering inner block content until the attachment is first triggered. */
|
|
83
|
+
lazyRender?: boolean;
|
|
84
|
+
/** Floating UI middleware pipeline (merged and deduplicated by `m.name`). */
|
|
85
|
+
middleware?: ComputePositionConfig['middleware'] | null;
|
|
86
|
+
/** Callback invoked when attachment visibility toggles. */
|
|
87
|
+
onChange?: (isVisible: boolean) => unknown;
|
|
88
|
+
/** Floating UI placement. Defaults to `'top'`. */
|
|
89
|
+
placement?: Placement;
|
|
90
|
+
/** Renders the attachment in place within its parent DOM instead of promoting to the Top Layer. */
|
|
91
|
+
renderInPlace?: boolean;
|
|
92
|
+
/** Delay in ms (number or numeric string) before showing. Defaults to `0`. */
|
|
93
|
+
showDelay?: number | string;
|
|
94
|
+
/** Enter transition duration in ms (number or numeric string). Defaults to `300`. */
|
|
95
|
+
showDuration?: number | string;
|
|
96
|
+
/** Space-separated show triggers (`click`, `mouseenter`, `focus`), or `null` to disable. */
|
|
97
|
+
showOn?: string | null;
|
|
98
|
+
/** CSS positioning strategy (`'absolute'` or `'fixed'`). Defaults to `'absolute'`. */
|
|
99
|
+
strategy?: Strategy;
|
|
100
|
+
/** Attaches event listeners in the capture phase (`true`) or bubble phase (`false`). */
|
|
101
|
+
useCapture?: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface HostRenderState {
|
|
104
|
+
activeElement: AttachmentTarget | null;
|
|
105
|
+
hasContent: boolean;
|
|
106
|
+
id?: string;
|
|
107
|
+
role?: string;
|
|
108
|
+
popoverAttr?: 'manual';
|
|
109
|
+
className?: string;
|
|
110
|
+
text?: string;
|
|
111
|
+
arrow?: boolean;
|
|
112
|
+
isFillAnimation?: boolean;
|
|
113
|
+
isShown?: boolean;
|
|
114
|
+
isHiding?: boolean;
|
|
115
|
+
container?: Element | null;
|
|
116
|
+
}
|
|
117
|
+
type ConfigKey = 'tooltip' | 'popover';
|
|
118
|
+
export interface EmberAttacherConfigGroup {
|
|
119
|
+
animation?: AttacherAnimation | null;
|
|
120
|
+
arrow?: boolean;
|
|
121
|
+
autoUpdate?: boolean | AutoUpdateOptions;
|
|
122
|
+
class?: string | null;
|
|
123
|
+
hideDelay?: number | string;
|
|
124
|
+
hideDuration?: number | string;
|
|
125
|
+
hideOn?: string | null;
|
|
126
|
+
interactive?: boolean;
|
|
127
|
+
isShown?: boolean;
|
|
128
|
+
lazyRender?: boolean;
|
|
129
|
+
middleware?: ComputePositionConfig['middleware'] | null;
|
|
130
|
+
placement?: Placement;
|
|
131
|
+
renderInPlace?: boolean;
|
|
132
|
+
showDelay?: number | string;
|
|
133
|
+
showDuration?: number | string;
|
|
134
|
+
showOn?: string | null;
|
|
135
|
+
strategy?: Strategy;
|
|
136
|
+
tooltipClass?: string;
|
|
137
|
+
useCapture?: boolean;
|
|
138
|
+
}
|
|
139
|
+
export interface EmberAttacherEnvConfig extends EmberAttacherConfigGroup {
|
|
140
|
+
tooltip?: EmberAttacherConfigGroup;
|
|
141
|
+
popover?: EmberAttacherConfigGroup;
|
|
142
|
+
}
|
|
143
|
+
interface AttacherCoreOptions {
|
|
144
|
+
defaultConfigKey?: ConfigKey | null;
|
|
145
|
+
defaultAriaRole?: string;
|
|
146
|
+
getDefaultClass?: (() => string) | null;
|
|
147
|
+
isComponentHost?: boolean;
|
|
148
|
+
onRenderStateChange?: ((state: HostRenderState) => void) | null;
|
|
149
|
+
}
|
|
150
|
+
interface RegisteredEntry {
|
|
151
|
+
element: Element;
|
|
152
|
+
data: unknown;
|
|
153
|
+
options: AttacherArgs | null;
|
|
154
|
+
owner: Owner | null;
|
|
155
|
+
showListeners: Record<string, EventListener>;
|
|
156
|
+
showOnKey: string | null;
|
|
157
|
+
useCapture: boolean | null;
|
|
158
|
+
updateHandle: ScheduledHandle | null;
|
|
159
|
+
}
|
|
160
|
+
export declare function resolveTooltipClass(envConfig: EmberAttacherEnvConfig | null | undefined): string;
|
|
161
|
+
/**
|
|
162
|
+
* Shared reactive controller backing `<AttachTooltip>`, `<AttachPopover>`,
|
|
163
|
+
* `<Attacher>`, and the `{{tooltip}}` singleton pool.
|
|
164
|
+
*/
|
|
165
|
+
export default class AttacherCore {
|
|
166
|
+
_arrowElement: HTMLElement | null;
|
|
167
|
+
_currentTarget: AttachmentTarget | null;
|
|
168
|
+
_registeredTarget: AttachmentTarget | null;
|
|
169
|
+
_mustRender: boolean;
|
|
170
|
+
_modalContainer: Element | null;
|
|
171
|
+
_isShown: boolean;
|
|
172
|
+
_data: unknown;
|
|
173
|
+
_resolvedPlacement: Placement | undefined;
|
|
174
|
+
_middlewareData: MiddlewareData;
|
|
175
|
+
private _ownerContext;
|
|
176
|
+
private _owner;
|
|
177
|
+
private _getArgs;
|
|
178
|
+
private _defaultConfigKey;
|
|
179
|
+
private _defaultAriaRole;
|
|
180
|
+
private _getDefaultClass;
|
|
181
|
+
private _isComponentHost;
|
|
182
|
+
private _onRenderStateChange;
|
|
183
|
+
_defaultId: string;
|
|
184
|
+
_elementId: string | null;
|
|
185
|
+
_hasTargetBlock: boolean;
|
|
186
|
+
_usedTargetModifier: boolean;
|
|
187
|
+
_usedSetTarget: boolean;
|
|
188
|
+
_hasCheckedInitialTarget: boolean;
|
|
189
|
+
_setTargetHandle: ScheduledHandle | null;
|
|
190
|
+
_syncArgsHandle: ScheduledHandle | null;
|
|
191
|
+
_listenerTarget: Element | null;
|
|
192
|
+
_floatingElement: HTMLElement | null;
|
|
193
|
+
_registeredEntries: Map<Element, RegisteredEntry>;
|
|
194
|
+
_popoverTargetEntries: Map<Element, EventListener>;
|
|
195
|
+
_activeEntryOptions: AttacherArgs | null;
|
|
196
|
+
_pendingRegisteredData: unknown;
|
|
197
|
+
_hasPendingData: boolean;
|
|
198
|
+
_pendingPopoverTrigger: Element | null;
|
|
199
|
+
_syncingPopoverHost: boolean;
|
|
200
|
+
_skipNativePopoverToggle: boolean;
|
|
201
|
+
_addedManagedPopover: boolean;
|
|
202
|
+
_attachedPopoverEventsOn: Element | null;
|
|
203
|
+
_prevSyncedIsShown: boolean | undefined;
|
|
204
|
+
_prevSyncedTargetKey: string | undefined;
|
|
205
|
+
_prevSyncedTarget: AttacherTarget | null | undefined;
|
|
206
|
+
_closeGeneration: number;
|
|
207
|
+
_activeCloseCancel: (() => void) | null;
|
|
208
|
+
_delayedVisibilityToggle: ScheduledHandle | null;
|
|
209
|
+
_isHidden: boolean;
|
|
210
|
+
_isHiding: boolean;
|
|
211
|
+
_positioningSuspended: boolean;
|
|
212
|
+
_isDestroyed: boolean;
|
|
213
|
+
_hideListenersOnDocumentByEvent: Record<string, EventListener>;
|
|
214
|
+
_hideListenersOnTargetByEvent: Record<string, EventListener>;
|
|
215
|
+
_targetShowListenersByEvent: Record<string, EventListener>;
|
|
216
|
+
_aria: AttachmentAriaController;
|
|
217
|
+
_ariaOpen: boolean;
|
|
218
|
+
_mouseLeaveOrigin: PointerOrigin | null;
|
|
219
|
+
_restoreFocusOnHide: boolean;
|
|
220
|
+
_suppressFocusShow: boolean;
|
|
221
|
+
_lastUseCaptureArgumentValue: boolean;
|
|
222
|
+
_warnedRemovedArgs: Set<string>;
|
|
223
|
+
_cleanup: (() => void) | null;
|
|
224
|
+
readonly api: AttacherBlockParams;
|
|
225
|
+
/** Tracks template args read inside `<template>` and schedules an idle args sync. */
|
|
226
|
+
syncArgs: (..._positional: unknown[]) => "";
|
|
227
|
+
constructor(ownerContext: object | null, getArgs: () => AttacherArgs, { defaultConfigKey, defaultAriaRole, getDefaultClass, isComponentHost, onRenderStateChange, }?: AttacherCoreOptions);
|
|
228
|
+
private _setTracked;
|
|
229
|
+
_arg<K extends keyof AttacherArgs>(key: K): AttacherArgs[K];
|
|
230
|
+
_defaultFor<K extends keyof AttacherArgs>(key: K): unknown;
|
|
231
|
+
_opt<K extends keyof AttacherArgs>(key: K): unknown;
|
|
232
|
+
get ariaRole(): string | undefined;
|
|
233
|
+
get targetArg(): AttacherTarget | null | undefined;
|
|
234
|
+
get configKey(): ConfigKey;
|
|
235
|
+
get _isTooltip(): boolean;
|
|
236
|
+
get arrow(): boolean;
|
|
237
|
+
get isFillAnimation(): boolean;
|
|
238
|
+
get shouldRenderFloatingElement(): boolean;
|
|
239
|
+
get id(): string;
|
|
240
|
+
get popoverAttr(): 'manual' | undefined;
|
|
241
|
+
get liveIsShown(): boolean;
|
|
242
|
+
get innerClass(): string;
|
|
243
|
+
get isDestroyed(): boolean;
|
|
244
|
+
get isDestroying(): boolean;
|
|
245
|
+
get isHidden(): boolean;
|
|
246
|
+
get entryCount(): number;
|
|
247
|
+
isActiveTarget(element: AttachmentTarget): boolean;
|
|
248
|
+
setHostElements(floatingElement: HTMLElement | null, arrowElement?: HTMLElement | null): void;
|
|
249
|
+
getHostRenderState(): HostRenderState;
|
|
250
|
+
_notifyRenderStateChange(): void;
|
|
251
|
+
get envConfig(): EmberAttacherEnvConfig;
|
|
252
|
+
get _envConfig(): EmberAttacherEnvConfig;
|
|
253
|
+
get _hideOn(): string[];
|
|
254
|
+
get _showOn(): string[];
|
|
255
|
+
get _middleware(): {
|
|
256
|
+
name: string;
|
|
257
|
+
options?: any;
|
|
258
|
+
fn: (state: import("@floating-ui/dom").MiddlewareState) => import("@floating-ui/dom").MiddlewareReturn | Promise<import("@floating-ui/dom").MiddlewareReturn>;
|
|
259
|
+
}[];
|
|
260
|
+
get _usePopoverHost(): boolean;
|
|
261
|
+
get _renderInPlace(): boolean;
|
|
262
|
+
get _delayGroupOwner(): object | null;
|
|
263
|
+
_hasSuppliedTargetBinding(): boolean;
|
|
264
|
+
_assertInitialTargetBinding(): void;
|
|
265
|
+
setupFloatingElement: FunctionBasedModifier<{
|
|
266
|
+
Element: HTMLElement;
|
|
267
|
+
Args: {
|
|
268
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
269
|
+
Positional: [hasTargetBlock?: boolean | undefined];
|
|
270
|
+
};
|
|
271
|
+
}>;
|
|
272
|
+
attachment: FunctionBasedModifier<{
|
|
273
|
+
Element: HTMLElement;
|
|
274
|
+
Args: {
|
|
275
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
276
|
+
Positional: [];
|
|
277
|
+
};
|
|
278
|
+
}>;
|
|
279
|
+
arrowModifier: FunctionBasedModifier<{
|
|
280
|
+
Element: HTMLElement;
|
|
281
|
+
Args: {
|
|
282
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
283
|
+
Positional: [];
|
|
284
|
+
};
|
|
285
|
+
}>;
|
|
286
|
+
insertArrow: FunctionBasedModifier<{
|
|
287
|
+
Element: HTMLElement;
|
|
288
|
+
Args: {
|
|
289
|
+
Named: import("ember-modifier/-private/signature").EmptyObject;
|
|
290
|
+
Positional: [];
|
|
291
|
+
};
|
|
292
|
+
}>;
|
|
293
|
+
scheduleArgsSync(): void;
|
|
294
|
+
target: AttacherTargetModifier;
|
|
295
|
+
registerTargetElement(element: Element, data: unknown, options?: AttacherArgs | null, owner?: Owner | null): RegisteredEntry;
|
|
296
|
+
unregisterTargetElement(element: Element): void;
|
|
297
|
+
_onRegisteredEntryMounted(element: Element, data: unknown): void;
|
|
298
|
+
_syncHeadlessAttachmentElement(element: HTMLElement | null): void;
|
|
299
|
+
_attachPopoverEvents(element: Element | null): void;
|
|
300
|
+
_detachPopoverEvents(element: Element | null): void;
|
|
301
|
+
_onPopoverBeforeToggle(rawEvent: Event): void;
|
|
302
|
+
_onPopoverTargetClick(event: Event): void;
|
|
303
|
+
_syncEntryShowListeners(entry: RegisteredEntry): void;
|
|
304
|
+
_removeEntryShowListeners(entry: RegisteredEntry): void;
|
|
305
|
+
_activateRegisteredEntry(entry: RegisteredEntry): void;
|
|
306
|
+
_switchTargetFromEvent(targetEl: AttachmentTarget, data: unknown, options: AttacherArgs | null): void;
|
|
307
|
+
_syncPopoverTargetListeners(popoverTargets: readonly Element[]): void;
|
|
308
|
+
_clearPopoverTargetListeners(): void;
|
|
309
|
+
_syncModalContainer(): boolean;
|
|
310
|
+
_applyVisibility(isVisible: boolean): void;
|
|
311
|
+
_waitForExitAnimations(element: HTMLElement | null, hideDuration: number, onDone: () => void): void;
|
|
312
|
+
_finishHide(): void;
|
|
313
|
+
_cancelCloseAnimation(): void;
|
|
314
|
+
show(target?: AttachmentTarget | Event | undefined, data?: unknown): void;
|
|
315
|
+
hide(): void;
|
|
316
|
+
toggle(): void;
|
|
317
|
+
update(): void;
|
|
318
|
+
setTarget(target: AttachmentTarget | null | undefined, data?: unknown): void;
|
|
319
|
+
_warnRemoved4xArgs(args: Record<string, unknown> | undefined): void;
|
|
320
|
+
_ensureArgumentsAreValid(): void;
|
|
321
|
+
_syncAria(): void;
|
|
322
|
+
_initializeAttacher(): void;
|
|
323
|
+
_addShowListenersIfUnregistered(): void;
|
|
324
|
+
_removeTargetShowEventListeners(): void;
|
|
325
|
+
_removeHideEventListeners({ restoreClickShow }?: {
|
|
326
|
+
restoreClickShow?: boolean | undefined;
|
|
327
|
+
}): void;
|
|
328
|
+
_syncIsShown(): void;
|
|
329
|
+
_showAfterDelay(event?: Event): void;
|
|
330
|
+
_show(): void;
|
|
331
|
+
_hideAfterDelay(): void;
|
|
332
|
+
_hide(): void;
|
|
333
|
+
_addListenersForHideEvents(): void;
|
|
334
|
+
_hideOnMouseLeaveTarget(rawEvent: Event): void;
|
|
335
|
+
_hideIfMouseOutsideTargetOrAttachment(rawEvent: Event): void;
|
|
336
|
+
_hideOnClickOut(event: Event): void;
|
|
337
|
+
_hideOnEscapeKey(rawEvent: Event): void;
|
|
338
|
+
_hideOnLostFocus(rawEvent: Event): void;
|
|
339
|
+
_update(): void;
|
|
340
|
+
_updatePosition(): void;
|
|
341
|
+
destroy(): void;
|
|
342
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import type Owner from '@ember/owner';
|
|
3
|
+
import AttacherCore, { type AttacherArgs, type AttacherNamedBlocks } from './attacher-core';
|
|
4
|
+
export interface AttacherOverlaySignature {
|
|
5
|
+
Element: HTMLDivElement;
|
|
6
|
+
Args: AttacherArgs;
|
|
7
|
+
Blocks: AttacherNamedBlocks;
|
|
8
|
+
}
|
|
9
|
+
/** Internal shared Host component class for `<AttachPopover>` and `<AttachTooltip>`. */
|
|
10
|
+
export default class AttacherOverlay extends Component<AttacherOverlaySignature> {
|
|
11
|
+
readonly core: AttacherCore;
|
|
12
|
+
constructor(owner: Owner, args: AttacherArgs);
|
|
13
|
+
get _defaultConfigKey(): 'popover' | 'tooltip' | null;
|
|
14
|
+
get _defaultAriaRole(): string | undefined;
|
|
15
|
+
get _defaultClass(): string;
|
|
16
|
+
get ariaRole(): string | undefined;
|
|
17
|
+
get id(): string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type AttacherCore from './attacher-core';
|
|
2
|
+
/** Register a mounted `AttacherCore` instance in the in-process attachment tree. */
|
|
3
|
+
export declare function registerAttacher(attacher: AttacherCore): void;
|
|
4
|
+
/** Unregister a destroyed `AttacherCore` instance from the in-process attachment tree. */
|
|
5
|
+
export declare function unregisterAttacher(attacher: AttacherCore): void;
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the logical parent `AttacherCore` whose floating element contains
|
|
8
|
+
* this attacher's listener target.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getParentAttacher(child: AttacherCore): AttacherCore | null;
|
|
11
|
+
/**
|
|
12
|
+
* Cache the parent attachment relationship on the child's floating element so
|
|
13
|
+
* clicks that unmount the child mid-event still trace back to the parent via `composedPath`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function syncParentAttachment(attacher: AttacherCore): void;
|
|
16
|
+
/** Check whether `candidate` is a logical descendant of `ancestor` in the attachment tree. */
|
|
17
|
+
export declare function isDescendantOf(candidate: AttacherCore, ancestor: AttacherCore): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Determine whether a DOM event originated inside any logical descendant Attachment
|
|
20
|
+
* (or its Target) of `parent`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function descendantAttachmentContainsEvent(parent: AttacherCore, event: Event): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Determine whether a DOM node is contained inside any logical descendant Attachment
|
|
25
|
+
* (or its Target) of `parent`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function descendantAttachmentContainsNode(parent: AttacherCore, node: Node | null | undefined): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Enforce LIFO Escape dismissal across nested Attachments: only the deepest
|
|
30
|
+
* currently open escapable Attachment handles a given Escape keydown event.
|
|
31
|
+
*/
|
|
32
|
+
export declare function shouldHandleEscapeKey(attacher: AttacherCore, event: KeyboardEvent): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const DEFAULT_WARM_WINDOW_MS = 300;
|
|
2
|
+
export interface DelayGroupCloseOptions {
|
|
3
|
+
markWarm?: boolean;
|
|
4
|
+
windowMs?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare class TooltipDelayGroup {
|
|
7
|
+
private _openTooltips;
|
|
8
|
+
private _closedAt;
|
|
9
|
+
private _windowMs;
|
|
10
|
+
open(instance: object): void;
|
|
11
|
+
close(instance: object, { markWarm, windowMs }?: DelayGroupCloseOptions): void;
|
|
12
|
+
isWarmFor(): boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function peekDelayGroup(owner: unknown): TooltipDelayGroup | null;
|
|
15
|
+
export declare function getDelayGroup(owner: unknown): TooltipDelayGroup | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DOM and event helpers for attachment boundary and cursor detection.
|
|
3
|
+
*/
|
|
4
|
+
import type { VirtualElement } from '@floating-ui/dom';
|
|
5
|
+
type RectSource = Element | Pick<VirtualElement, 'getBoundingClientRect'>;
|
|
6
|
+
export interface PointerOrigin {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Determine whether an event originated from or traversed through a given DOM element.
|
|
12
|
+
*
|
|
13
|
+
* Uses `event.composedPath()` to safely detect clicks on elements that were subsequently
|
|
14
|
+
* removed from the DOM during event handling (e.g. self-disappearing buttons).
|
|
15
|
+
* Falls back to `element.contains(event.target)` when `composedPath` is unavailable.
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export declare function elementContainsEvent(element: Element | null | undefined, event: Event | null | undefined): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Determine whether a click/touch event landed inside a floating host element.
|
|
21
|
+
*
|
|
22
|
+
* Unlike `elementContainsEvent`, direct hits targeting a Top-Layer `[popover]`'s
|
|
23
|
+
* `::backdrop` (`event.target === element` with pointer coordinates outside the
|
|
24
|
+
* popover's rendered boxes) return `false` so clickout dismisses the popover.
|
|
25
|
+
*/
|
|
26
|
+
export declare function floatingElementContainsEvent(element: Element | null | undefined, event: Event | null | undefined): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Determine whether the cursor lies inside either rect or the diagonal safe-polygon
|
|
29
|
+
* corridor between the mouseleave exit point on the Target (or the Target's facing edge
|
|
30
|
+
* when synthetic events omit pointer coordinates) and the facing edge of the Attachment.
|
|
31
|
+
*
|
|
32
|
+
* Unlike an 8-corner bounding convex hull, this corridor only spans the gap between
|
|
33
|
+
* the Target's facing edge and the Attachment's facing edge, so exiting laterally
|
|
34
|
+
* into adjacent UI beside the Target never keeps the Attachment stuck open.
|
|
35
|
+
*
|
|
36
|
+
* Supports both DOM Elements and Floating UI VirtualElements via `getBoundingClientRect()`.
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
39
|
+
export declare function isCursorInSafePolygon(event: Pick<MouseEvent, 'clientX' | 'clientY'> | null | undefined, origin: PointerOrigin | null | undefined, target: RectSource | null | undefined, floatingElement: RectSource | null | undefined): boolean;
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether the current browser environment supports Top-Layer `[popover="manual"]`.
|
|
3
|
+
*/
|
|
4
|
+
export declare function supportsPopoverHost(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Find the nearest open modal `<dialog>` (`dialog:modal`) enclosing a context node,
|
|
7
|
+
* so Top-Layer attachments opened inside `showModal()` stay DOM-inside the modal
|
|
8
|
+
* and do not become inert.
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export declare function getModalDialogContainer(contextNode: unknown): Element | null;
|
|
12
|
+
/**
|
|
13
|
+
* Promote a `[popover]` host element into the browser Top Layer.
|
|
14
|
+
* If `showPopover()` throws, logs a debug warning and removes `[popover]` so the
|
|
15
|
+
* in-place host remains visible instead of matching UA `:not(:popover-open)`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function showPopoverHost(el: Element | null | undefined): void;
|
|
18
|
+
/**
|
|
19
|
+
* Remove a `[popover]` host element from the browser Top Layer.
|
|
20
|
+
*/
|
|
21
|
+
export declare function hidePopoverHost(el: Element | null | undefined): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type ComputePositionConfig, type Middleware, type MiddlewareData, type Placement, type Strategy } from '@floating-ui/dom';
|
|
2
|
+
import { type AttachmentTarget } from './target-resolution';
|
|
3
|
+
/** Check whether an attachment target (DOM Element or VirtualElement) is still connected. */
|
|
4
|
+
export declare function isTargetConnected(target: AttachmentTarget | null | undefined): boolean;
|
|
5
|
+
export interface BuildMiddlewareOptions {
|
|
6
|
+
rawMiddleware?: ComputePositionConfig['middleware'] | null;
|
|
7
|
+
arrowElement: Element | null;
|
|
8
|
+
arrowEnabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Normalize and deduplicate the Floating UI middleware array without mutating
|
|
12
|
+
* caller-supplied middleware objects.
|
|
13
|
+
*/
|
|
14
|
+
export declare function buildMiddleware({ rawMiddleware, arrowElement, arrowEnabled, }: BuildMiddlewareOptions): Middleware[];
|
|
15
|
+
export interface ApplyPositionResultOptions {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
placement: Placement;
|
|
19
|
+
strategy: Strategy;
|
|
20
|
+
middlewareData: MiddlewareData;
|
|
21
|
+
isHidden: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Apply the resolved `computePosition` coordinates, arrow offset, `middlewareData.hide`
|
|
25
|
+
* attributes, `data-placement`, and `x-placement` to the floating and arrow elements.
|
|
26
|
+
*/
|
|
27
|
+
export declare function applyPositionResult(floatingElement: HTMLElement, arrowElement: HTMLElement | null, { x, y, placement, strategy, middlewareData, isHidden }: ApplyPositionResultOptions): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ScheduledHandle {
|
|
2
|
+
cancel: () => void;
|
|
3
|
+
}
|
|
4
|
+
export declare const attacherWaiter: import("@ember/test-waiters").TestWaiter<unknown>;
|
|
5
|
+
/** Cancel a scheduled task handle if present. */
|
|
6
|
+
export declare function cancelScheduled(handle: Partial<ScheduledHandle> | null | undefined): void;
|
|
7
|
+
/** Defer a callback to a microtask while holding a test-waiter token until it runs or cancels. */
|
|
8
|
+
export declare function scheduleMicrotask(fn: () => void): ScheduledHandle;
|
|
9
|
+
/** Schedule a `setTimeout` tracked by `@ember/test-waiters`, returning a cancellable handle. */
|
|
10
|
+
export declare function scheduleTimeout(fn: () => void, ms: number): ScheduledHandle;
|
|
11
|
+
/** Cancel any existing handle and either run synchronously (`immediate` or `!ms`) or after `ms`. */
|
|
12
|
+
export declare function debounceTimeout(currentHandle: Partial<ScheduledHandle> | null | undefined, fn: () => void, ms: number, immediate?: boolean): ScheduledHandle | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type Owner from '@ember/owner';
|
|
2
|
+
import AttacherCore, { type HostRenderState } from './attacher-core';
|
|
3
|
+
type HostMountCallback = (floatingEl: HTMLElement, arrowEl: HTMLElement | null) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Imperative DOM host rendering the shared singleton tooltip element from
|
|
6
|
+
* read-only `AttacherCore` render snapshots.
|
|
7
|
+
*/
|
|
8
|
+
declare class TooltipDomHost {
|
|
9
|
+
doc: Document;
|
|
10
|
+
hostEl: HTMLDivElement | null;
|
|
11
|
+
innerEl: HTMLDivElement | null;
|
|
12
|
+
contentEl: HTMLSpanElement | null;
|
|
13
|
+
arrowEl: HTMLDivElement | null;
|
|
14
|
+
fillEl: HTMLDivElement | null;
|
|
15
|
+
constructor(doc: Document);
|
|
16
|
+
_createElements(): void;
|
|
17
|
+
sync(state: HostRenderState, onHostMounted: HostMountCallback): void;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
export declare class SingletonTooltipPool {
|
|
21
|
+
doc: Document | null;
|
|
22
|
+
host: TooltipDomHost | null;
|
|
23
|
+
core: AttacherCore | null;
|
|
24
|
+
private _visibilitySyncHandles;
|
|
25
|
+
constructor(doc: Document);
|
|
26
|
+
register(element: Element, text: string, namedOptions: Record<string, unknown> | null | undefined, owner: Owner | null | undefined): void;
|
|
27
|
+
unregister(element: Element): void;
|
|
28
|
+
destroy(): void;
|
|
29
|
+
}
|
|
30
|
+
/** Get or create the document-scoped singleton tooltip pool. */
|
|
31
|
+
export declare function getTooltipPool(element: Element): SingletonTooltipPool | null;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VirtualElement } from '@floating-ui/dom';
|
|
2
|
+
/**
|
|
3
|
+
* Target resolution seam.
|
|
4
|
+
*
|
|
5
|
+
* Keeps listener target and Floating UI reference selection in one private
|
|
6
|
+
* module so targets (elements, virtual references, and selectors) can be
|
|
7
|
+
* resolved cleanly without cluttering positioning or lifecycle logic.
|
|
8
|
+
*/
|
|
9
|
+
export type AttachmentTarget = Element | VirtualElement;
|
|
10
|
+
export type AttachmentTargetInput = AttachmentTarget | string;
|
|
11
|
+
export declare function isElementTarget(value: unknown): value is Element;
|
|
12
|
+
/** Floating UI virtual references are plain objects with `getBoundingClientRect`. */
|
|
13
|
+
export declare function isVirtualReference(value: unknown): value is VirtualElement;
|
|
14
|
+
/**
|
|
15
|
+
* Resolve a public `@target` value (Element | selector | virtual ref).
|
|
16
|
+
*
|
|
17
|
+
* Selector strings use `querySelectorAll` and must match exactly one node.
|
|
18
|
+
*/
|
|
19
|
+
export declare function coerceTarget(value: AttachmentTargetInput | null | undefined, root?: ParentNode | null): AttachmentTarget | null;
|
|
20
|
+
export declare function escapeAttributeSelectorValue(value: string): string;
|
|
21
|
+
export interface TriggerTargets {
|
|
22
|
+
popoverTargets: Element[];
|
|
23
|
+
interestTargets: Element[];
|
|
24
|
+
allTargets: Element[];
|
|
25
|
+
}
|
|
26
|
+
/** Find native `[popovertarget="<id>"]` / `[interestfor="<id>"]` triggers for an attachment id. */
|
|
27
|
+
export declare function findTriggerTargetElements(id: string | null | undefined, root?: ParentNode | null): TriggerTargets;
|
|
28
|
+
export interface ResolveAttachmentTargetOptions {
|
|
29
|
+
/** `@target` arg: Element, selector, or virtual reference. */
|
|
30
|
+
target?: AttachmentTargetInput | null;
|
|
31
|
+
/** Element registered via `{{a.target}}` / `a.setTarget()`. */
|
|
32
|
+
registeredTarget?: AttachmentTarget | null;
|
|
33
|
+
/** Native `[popovertarget]` / `[interestfor]` triggers. */
|
|
34
|
+
triggerTargets?: readonly Element[];
|
|
35
|
+
root?: ParentNode | null;
|
|
36
|
+
}
|
|
37
|
+
/** Pick the Floating UI reference: `@target`, then yielded registration, then native triggers. */
|
|
38
|
+
export declare function resolveAttachmentTarget({ target, registeredTarget, triggerTargets, root, }: ResolveAttachmentTargetOptions): AttachmentTarget | null;
|
|
39
|
+
/**
|
|
40
|
+
* Extract the DOM Element that should receive event listeners.
|
|
41
|
+
* Real Elements receive events directly. Virtual references may provide a
|
|
42
|
+
* `contextElement`; virtual references without a contextElement attach no listeners.
|
|
43
|
+
*/
|
|
44
|
+
export declare function getListenerTarget(target: AttachmentTarget | null | undefined): Element | null;
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
export type TooltipModifierOptions = Omit<
|
|
5
|
-
AttachPopoverArgs,
|
|
6
|
-
'target' | 'explicitTarget' | 'additionalClass'
|
|
7
|
-
>;
|
|
8
|
-
|
|
1
|
+
import Modifier from 'ember-modifier';
|
|
2
|
+
import type { AttacherArgs } from '../lib/attacher-core';
|
|
3
|
+
export type TooltipModifierOptions = Omit<AttacherArgs, 'target'>;
|
|
9
4
|
export interface TooltipModifierSignature {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
Element: Element;
|
|
6
|
+
Args: {
|
|
7
|
+
Positional: [text: string | null | undefined];
|
|
8
|
+
Named: TooltipModifierOptions;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `{{tooltip "Text" class="..." ...}}` modifier for void and simple targets.
|
|
13
|
+
* Shares a single Top-Layer Attachment DOM node per document via `SingletonTooltipPool` (#64).
|
|
14
|
+
*/
|
|
15
|
+
export default class TooltipModifier extends Modifier<TooltipModifierSignature> {
|
|
16
|
+
private _element;
|
|
17
|
+
private _pool;
|
|
18
|
+
constructor(owner: ConstructorParameters<typeof Modifier<TooltipModifierSignature>>[0], args: ConstructorParameters<typeof Modifier<TooltipModifierSignature>>[1]);
|
|
19
|
+
modify(element: Element, [text]: TooltipModifierSignature['Args']['Positional'], named: TooltipModifierSignature['Args']['Named']): void;
|
|
15
20
|
}
|
|
16
|
-
|
|
17
|
-
export default class TooltipModifier extends Modifier<TooltipModifierSignature> {}
|