@ngutil/floating 0.0.102 → 0.0.104

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/index.d.ts CHANGED
@@ -1,7 +1,417 @@
1
- import { Provider } from "@angular/core";
2
- export * from "./floating";
3
- export * from "./layer";
4
- export interface ProvideFloatingOptions {
1
+ import * as i0 from '@angular/core';
2
+ import { ElementRef, Injector, Provider, ViewContainerRef, TemplateRef, InjectionToken } from '@angular/core';
3
+ import * as rxjs from 'rxjs';
4
+ import { Observable, ReplaySubject, ObservableInput } from 'rxjs';
5
+ import { Lifecycle, ElementInput } from '@ngutil/common';
6
+ import { PortalOutlet, ComponentType, ComponentPortal, TemplatePortal } from '@angular/cdk/portal';
7
+ import { CoverOptions, CoverRef } from '@ngutil/graphics';
8
+ import { AnimationMetadata } from '@angular/animations';
9
+ import { FloatingPosition, Position, FloatingPositionContentOptions, FloatingPositionAnchorOptions, FloatingPositionPlacementOptions, FloatingPositionAltInput } from '@ngutil/style';
10
+ import { Focusable, FocusState } from '@ngutil/aria';
11
+ import * as _ngutil_floating from '@ngutil/floating';
12
+ import { Primitive } from 'utility-types';
13
+
14
+ type DisposeHandler<T> = (ref: T) => Observable<void>;
15
+ declare enum AlwaysOnTop {
16
+ /**
17
+ * Display as open order
18
+ */
19
+ None = 0,
20
+ /**
21
+ * Modals
22
+ */
23
+ Modal = 2,
24
+ /**
25
+ * User access control
26
+ */
27
+ UAC = 3,
28
+ /**
29
+ * Toast...
30
+ */
31
+ Toast = 4,
32
+ /**
33
+ * Like select drop down, tooltip, stb...
34
+ */
35
+ Control = 5
36
+ }
37
+ declare abstract class ChildRef<T extends HTMLElement = HTMLElement> extends ElementRef<T> {
38
+ readonly alwaysOnTop: AlwaysOnTop;
39
+ readonly state: Lifecycle<{
40
+ showing: {};
41
+ shown: {};
42
+ disposing: {
43
+ cancellable: false;
44
+ };
45
+ disposed: {
46
+ cancellable: false;
47
+ order: "sequential";
48
+ };
49
+ }, "showing" | "shown" | "disposing" | "disposed">;
50
+ get zIndex(): number;
51
+ private _zIndex;
52
+ protected readonly disposed$: Observable<"disposed">;
53
+ constructor(nativeElement: T, alwaysOnTop?: AlwaysOnTop);
54
+ dispose(): Observable<void>;
55
+ }
56
+
57
+ interface ContainerOptions {
58
+ alwaysOnTop?: AlwaysOnTop;
59
+ elevation?: number;
60
+ classes?: string[];
61
+ attributes?: Record<string, string>;
62
+ injector?: Injector;
63
+ providers?: Provider[];
64
+ }
65
+ declare class ContainerRef extends ChildRef {
66
+ readonly options: ContainerOptions;
67
+ readonly injector: Injector;
68
+ protected injectorName: string;
69
+ constructor(options: ContainerOptions);
70
+ protected getProviders(): Provider[];
71
+ }
72
+
73
+ type BackdropOptions = CoverOptions;
74
+ declare class BackdropRef extends ChildRef {
75
+ #private;
76
+ readonly coverRef: CoverRef<any>;
77
+ readonly under: ChildRef;
78
+ readonly options: CoverOptions;
79
+ readonly group: string;
80
+ set visible(visible: boolean);
81
+ get visible(): boolean;
82
+ constructor(coverRef: CoverRef<any>, under: ChildRef, options: CoverOptions);
83
+ show(): rxjs.Observable<void>;
84
+ }
85
+
86
+ declare class ExternalRef extends ChildRef {
87
+ }
88
+
89
+ interface PortalOptions extends ContainerOptions {
90
+ }
91
+ declare abstract class PortalRef extends ContainerRef {
92
+ protected injectorName: string;
93
+ protected outlet: PortalOutlet;
94
+ constructor(options: PortalOptions);
95
+ protected getProviders(): Provider[];
96
+ }
97
+ interface ComponentPortalOptions<T = any> extends PortalOptions {
98
+ viewContainerRef?: ViewContainerRef;
99
+ }
100
+ declare class ComponentPortalRef<T = any> extends PortalRef {
101
+ readonly component: ComponentType<T>;
102
+ protected injectorName: string;
103
+ protected readonly portal: ComponentPortal<T>;
104
+ constructor(component: ComponentType<T>, options: ComponentPortalOptions<T>);
105
+ protected getProviders(): Provider[];
106
+ }
107
+ interface TemplatePortalOptions<T = any> extends PortalOptions {
108
+ viewContainerRef: ViewContainerRef;
109
+ context?: T;
110
+ }
111
+ declare class TemplatePortalRef<T = any> extends PortalRef {
112
+ readonly template: TemplateRef<T>;
113
+ protected injectorName: string;
114
+ protected readonly portal: TemplatePortal<T>;
115
+ constructor(template: TemplateRef<T>, options: TemplatePortalOptions<T>);
116
+ protected getProviders(): Provider[];
117
+ }
118
+
119
+ declare class LayerService {
120
+ #private;
121
+ get root(): HTMLElement;
122
+ newComponentPortal<T>(component: ComponentType<T>, options: ComponentPortalOptions<T>): ComponentPortalRef<T>;
123
+ newTemplatePortal<T>(tpl: TemplateRef<T>, options: TemplatePortalOptions<T>): TemplatePortalRef<T>;
124
+ newContainer(options: ContainerOptions): ContainerRef;
125
+ newBackdrop(under: ChildRef, options: BackdropOptions): BackdropRef;
126
+ addExternal(element: ElementInput, alwaysOnTop?: AlwaysOnTop): ExternalRef;
127
+ static ɵfac: i0.ɵɵFactoryDeclaration<LayerService, never>;
128
+ static ɵprov: i0.ɵɵInjectableDeclaration<LayerService>;
129
+ }
130
+
131
+ type Traits = {
132
+ [key: string]: FloatingTrait;
133
+ };
134
+ declare const TRAITS: InjectionToken<Traits>;
135
+ interface FloatingChannel {
136
+ floatingRef: FloatingRef;
137
+ type: string;
138
+ data?: any;
139
+ }
140
+ interface FloatingTraitEvent {
141
+ name: string;
142
+ data: object;
143
+ }
144
+ type TraitState = {
145
+ [key: string]: FloatingTraitEvent | null;
146
+ };
147
+ declare class FloatingRef<C extends FloatingChannel = FloatingChannel, T extends HTMLElement = HTMLElement> {
148
+ #private;
149
+ readonly layerSvc: LayerService;
150
+ readonly container: ContainerRef;
151
+ readonly channel: ReplaySubject<FloatingChannel>;
152
+ readonly state: Lifecycle<{
153
+ init: {};
154
+ showing: {};
155
+ shown: {};
156
+ closing: {
157
+ cancellable: false;
158
+ order: "sequential";
159
+ };
160
+ disposing: {
161
+ cancellable: false;
162
+ };
163
+ disposed: {
164
+ cancellable: false;
165
+ order: "sequential";
166
+ };
167
+ cleanup: {
168
+ cancellable: false;
169
+ order: "sequential";
170
+ };
171
+ }, "showing" | "shown" | "disposing" | "disposed" | "init" | "closing" | "cleanup">;
172
+ readonly traitState$: Observable<TraitState>;
173
+ readonly uid: string;
174
+ constructor(layerSvc: LayerService, container: ContainerRef, traits: Traits);
175
+ show(): Observable<void>;
176
+ /**
177
+ * @deprecated
178
+ */
179
+ hide(): Observable<void>;
180
+ close(force?: boolean): Observable<void>;
181
+ emit(event: Omit<C, "floatingRef">): void;
182
+ setResult(data: any): void;
183
+ watchTrait<T>(name: string): Observable<T>;
184
+ static ɵfac: i0.ɵɵFactoryDeclaration<FloatingRef<any, any>, never>;
185
+ static ɵprov: i0.ɵɵInjectableDeclaration<FloatingRef<any, any>>;
186
+ }
187
+
188
+ interface FloatingTrait<T = any> {
189
+ readonly name: string;
190
+ connect(floatingRef: FloatingRef<any>): Observable<T>;
191
+ }
192
+
193
+ type AnimationSet = {
194
+ show: AnimationMetadata[];
195
+ hide: AnimationMetadata[];
196
+ };
197
+ type AnimationTraitParams = (position: FloatingPosition) => object;
198
+ declare class AnimationTrait implements FloatingTrait<void> {
199
+ readonly animation: AnimationSet;
200
+ readonly params?: AnimationTraitParams | undefined;
201
+ readonly name = "animation";
202
+ constructor(animation: AnimationSet, params?: AnimationTraitParams | undefined);
203
+ connect(floatingRef: FloatingRef): Observable<void>;
204
+ }
205
+ declare const FallAnimation: AnimationSet;
206
+ declare function fallAnimation(scale?: number): AnimationTrait;
207
+ declare const FadeAnimation: AnimationSet;
208
+ declare function fadeAnimation(): AnimationTrait;
209
+ declare function slideNearAnimation(size?: number): AnimationTrait;
210
+ declare function slideAwayAnimation(size?: number): AnimationTrait;
211
+ type RippleRevealAnimationOptions = {
212
+ origin: Position;
213
+ initialRadius?: number;
214
+ duration?: number;
215
+ };
216
+ declare function rippleRevealAnimation(options: RippleRevealAnimationOptions): AnimationTrait;
217
+
218
+ declare const LAYER_CONTAINER_ZINDEX_START: InjectionToken<number>;
219
+ declare abstract class LayerContainer {
220
+ #private;
221
+ abstract readonly root: HTMLElement;
222
+ readonly zIndexStart: number;
223
+ append<T extends ChildRef>(ref: T): T;
224
+ static ɵfac: i0.ɵɵFactoryDeclaration<LayerContainer, never>;
225
+ static ɵdir: i0.ɵɵDirectiveDeclaration<LayerContainer, never, never, {}, {}, never, never, true, never>;
226
+ }
227
+ declare class RootLayer extends LayerContainer {
228
+ readonly root: HTMLElement;
229
+ static ɵfac: i0.ɵɵFactoryDeclaration<RootLayer, never>;
230
+ static ɵprov: i0.ɵɵInjectableDeclaration<RootLayer>;
231
+ }
232
+ declare class IndividualLayer extends LayerContainer {
233
+ readonly root: any;
234
+ static ɵfac: i0.ɵɵFactoryDeclaration<IndividualLayer, never>;
235
+ static ɵdir: i0.ɵɵDirectiveDeclaration<IndividualLayer, never, never, {}, {}, never, never, true, never>;
236
+ }
237
+
238
+ interface CommonOptions {
239
+ }
240
+ type BackdropTraitOptions = CoverOptions & CommonOptions;
241
+ declare class BackdropTrait implements FloatingTrait<BackdropRef> {
242
+ readonly options: BackdropTraitOptions;
243
+ readonly name = "backdrop";
244
+ constructor(options: BackdropTraitOptions);
245
+ connect(floatingRef: FloatingRef<any>): Observable<BackdropRef>;
246
+ }
247
+ declare function backdrop(options: BackdropTraitOptions): BackdropTrait;
248
+
249
+ interface ClickOutsideOptions {
250
+ /**
251
+ * If clicks happened on this element, that not trigger the close event
252
+ */
253
+ allowedElements?: ElementInput[];
254
+ }
255
+ interface CloseTriggerOptions {
256
+ /**
257
+ * Close floating when click outside of floating element
258
+ */
259
+ clickOutside?: boolean | ClickOutsideOptions;
260
+ /**
261
+ * Only works when the floating element is focused
262
+ */
263
+ keystroke?: boolean;
264
+ /**
265
+ * Close when emitting any value
266
+ */
267
+ trigger?: ObservableInput<any>;
268
+ }
269
+ interface CloseTriggerEvent {
270
+ source: "click" | "keystroke" | "backbutton" | "trigger";
271
+ }
272
+ declare class CloseTriggerTrait implements FloatingTrait {
273
+ readonly options: CloseTriggerOptions;
274
+ readonly name = "close-trigger";
275
+ constructor(options?: CloseTriggerOptions);
276
+ connect(floatingRef: FloatingRef): Observable<CloseTriggerEvent | void>;
277
+ }
278
+ declare function closeTrigger(options?: CloseTriggerOptions): CloseTriggerTrait;
279
+
280
+ interface FocusOptions {
281
+ trap?: boolean;
282
+ connect?: Focusable | FocusState;
283
+ tabindex?: number;
284
+ focusOnClose?: ElementInput;
285
+ }
286
+ declare class FocusTrait implements FloatingTrait<void> {
287
+ #private;
288
+ readonly options: FocusOptions;
289
+ readonly name = "focus";
290
+ constructor(options: FocusOptions);
291
+ connect(floatingRef: FloatingRef): Observable<void>;
292
+ }
293
+ declare function focus(options: FocusOptions): FocusTrait;
294
+
295
+ type PositionTraitElementRef = ElementInput | Window | "layer" | "viewport";
296
+ type PositionTraitOptions = {
297
+ content?: Omit<FloatingPositionContentOptions, "constraints"> & {
298
+ constraints?: SizeConstraintsInput;
299
+ };
300
+ anchor?: FloatingPositionAnchorOptions & {
301
+ ref: PositionTraitElementRef;
302
+ };
303
+ placement?: FloatingPositionPlacementOptions & {
304
+ ref: PositionTraitElementRef;
305
+ };
306
+ horizontalAlt?: FloatingPositionAltInput;
307
+ verticalAlt?: FloatingPositionAltInput;
308
+ };
309
+ /**
310
+ * Width ot height input values
311
+ *
312
+ * - `number`: excact value
313
+ * - `ElementInput`: element reference, and take the dimension from it
314
+ * - `link`: take the dimension from the anchor element and only apply on connection dimension.
315
+ * eg.: `anchor.link = "left bottom"` and `content.link = "left top"`, in this case only width will be applied.
316
+ */
317
+ type SizeInputConst = number | ElementInput | "link" | "viewport";
318
+ type SizeInput = SizeInputConst | Observable<SizeInputConst>;
319
+ interface SizeConstraintsInput {
320
+ minWidth?: SizeInput;
321
+ maxWidth?: SizeInput;
322
+ minHeight?: SizeInput;
323
+ maxHeight?: SizeInput;
324
+ }
325
+ declare class PositionTrait implements FloatingTrait<FloatingPosition> {
326
+ readonly name = "position";
327
+ readonly options: Required<PositionTraitOptions>;
328
+ constructor(options: PositionTraitOptions);
329
+ connect(floatingRef: FloatingRef<any>): Observable<FloatingPosition>;
330
+ }
331
+ declare function position(options: PositionTraitOptions): PositionTrait;
332
+
333
+ declare function modal(): (AnimationTrait | BackdropTrait | {
334
+ readonly name: "close-trigger";
335
+ readonly options: CloseTriggerOptions;
336
+ connect(floatingRef: _ngutil_floating.FloatingRef): rxjs.Observable<CloseTriggerEvent | void>;
337
+ } | FocusTrait | PositionTrait)[];
338
+
339
+ declare class StyleTrait implements FloatingTrait<Partial<CSSStyleDeclaration>> {
340
+ readonly styles: Partial<CSSStyleDeclaration>;
341
+ readonly name = "style";
342
+ constructor(styles: Partial<CSSStyleDeclaration>);
343
+ connect(floatingRef: FloatingRef): Observable<Partial<CSSStyleDeclaration>>;
344
+ }
345
+ declare function style(styles: Partial<CSSStyleDeclaration>): StyleTrait;
346
+
347
+ type Attributes = {
348
+ [key: string]: Primitive;
349
+ } | {
350
+ dataset: {
351
+ [key: string]: Primitive;
352
+ };
353
+ };
354
+ declare class AttributeTrait implements FloatingTrait<Attributes> {
355
+ readonly attrs: Attributes;
356
+ readonly name = "attribute";
357
+ constructor(attrs: Attributes);
358
+ connect(floatingRef: FloatingRef): Observable<Attributes>;
359
+ }
360
+ declare function attribute(attrs: Attributes): AttributeTrait;
361
+
362
+ type FloatingTraitInput = FloatingTrait | Array<FloatingTraitInput>;
363
+ declare abstract class FloatingFactory {
364
+ #private;
365
+ protected readonly floatingSvc: FloatingService;
366
+ protected readonly traits: {
367
+ [key: string]: FloatingTrait;
368
+ };
369
+ constructor(floatingSvc: FloatingService);
370
+ trait(...traits: Array<FloatingTraitInput>): this;
371
+ show(): Observable<FloatingChannel>;
372
+ subscribe: Observable<FloatingChannel>["subscribe"];
373
+ protected providers(providers?: Provider[]): Provider[];
374
+ protected abstract create(): FloatingRef<FloatingChannel>;
375
+ position(options: PositionTraitOptions): this;
376
+ provides(providers: Provider | Provider[]): this;
377
+ }
378
+ declare class FloatingTemplateFactory<T extends object> extends FloatingFactory {
379
+ readonly tpl: TemplateRef<T>;
380
+ readonly options: TemplatePortalOptions<T>;
381
+ constructor(floatingSvc: FloatingService, tpl: TemplateRef<T>, options: TemplatePortalOptions<T>);
382
+ protected create(): FloatingRef<FloatingChannel>;
383
+ }
384
+ declare class FloatingComponentFactory<T extends ComponentType<any>> extends FloatingFactory {
385
+ readonly component: T;
386
+ readonly options: ComponentPortalOptions<T>;
387
+ constructor(floatingSvc: FloatingService, component: T, options: ComponentPortalOptions<T>);
388
+ protected create(): FloatingRef<FloatingChannel>;
389
+ }
390
+ /**
391
+ * @example
392
+ * ```typescript
393
+ * class SomeComponent {}
394
+ *
395
+ * class SomeList {
396
+ * readonly floating = inject(FloatingService)
397
+ *
398
+ * showComponent() {
399
+ * this.floating.from(SomeComponent).traits(position(), backdrop()).subscribe()
400
+ * }
401
+ * ```
402
+ */
403
+ declare class FloatingService {
404
+ readonly layer: LayerService;
405
+ from<T extends ComponentType<any>>(component: T, opts?: ComponentPortalOptions<T>): FloatingComponentFactory<T>;
406
+ from<T extends object>(tpl: TemplateRef<T>, opts?: TemplatePortalOptions<T>): FloatingTemplateFactory<T>;
407
+ static ɵfac: i0.ɵɵFactoryDeclaration<FloatingService, never>;
408
+ static ɵprov: i0.ɵɵInjectableDeclaration<FloatingService>;
409
+ }
410
+
411
+ interface ProvideFloatingOptions {
5
412
  zIndexStart?: number;
6
413
  }
7
- export declare function provideFloating(options?: ProvideFloatingOptions): Provider[];
414
+ declare function provideFloating(options?: ProvideFloatingOptions): Provider[];
415
+
416
+ export { AlwaysOnTop, AnimationTrait, AttributeTrait, BackdropRef, BackdropTrait, ChildRef, ComponentPortalRef, ContainerRef, FadeAnimation, FallAnimation, FloatingComponentFactory, FloatingFactory, FloatingRef, FloatingService, FloatingTemplateFactory, FocusTrait, IndividualLayer, LAYER_CONTAINER_ZINDEX_START, LayerContainer, LayerService, PortalRef, PositionTrait, RootLayer, StyleTrait, TRAITS, TemplatePortalRef, attribute, backdrop, closeTrigger, fadeAnimation, fallAnimation, focus, modal, position, provideFloating, rippleRevealAnimation, slideAwayAnimation, slideNearAnimation, style };
417
+ export type { AnimationSet, AnimationTraitParams, Attributes, BackdropOptions, BackdropTraitOptions, ClickOutsideOptions, CloseTriggerEvent, CloseTriggerOptions, ComponentPortalOptions, ContainerOptions, DisposeHandler, FloatingChannel, FloatingTrait, FloatingTraitEvent, FloatingTraitInput, FocusOptions, PortalOptions, PositionTraitElementRef, PositionTraitOptions, ProvideFloatingOptions, TemplatePortalOptions, Traits };
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@ngutil/floating",
3
- "version": "0.0.102",
3
+ "version": "0.0.104",
4
4
  "dependencies": {
5
5
  "tslib": "^2.6.2"
6
6
  },
7
7
  "peerDependencies": {
8
- "@angular/cdk": "19.2.11",
9
- "@angular/common": "19.2.8",
10
- "@angular/core": "19.2.8",
8
+ "@angular/cdk": "20.2.14",
9
+ "@angular/common": "20.3.13",
10
+ "@angular/core": "20.3.13",
11
11
  "es-toolkit": "^1.35.0",
12
- "@ngutil/aria": "0.0.102",
13
- "@ngutil/common": "0.0.102",
14
- "@ngutil/style": "0.0.102"
12
+ "@ngutil/style": "0.0.104",
13
+ "@ngutil/aria": "0.0.104",
14
+ "@ngutil/common": "0.0.104"
15
15
  },
16
16
  "publishConfig": {
17
17
  "access": "public",
@@ -1,64 +0,0 @@
1
- import { InjectionToken } from "@angular/core";
2
- import { Observable, ReplaySubject } from "rxjs";
3
- import { Lifecycle } from "@ngutil/common";
4
- import { ContainerRef } from "../layer/container-ref";
5
- import { LayerService } from "../layer/layer.service";
6
- import { FloatingTrait } from "./traits/_base";
7
- import * as i0 from "@angular/core";
8
- export type Traits = {
9
- [key: string]: FloatingTrait;
10
- };
11
- export declare const TRAITS: InjectionToken<Traits>;
12
- export interface FloatingChannel {
13
- floatingRef: FloatingRef;
14
- type: string;
15
- data?: any;
16
- }
17
- export interface FloatingTraitEvent {
18
- name: string;
19
- data: object;
20
- }
21
- type TraitState = {
22
- [key: string]: FloatingTraitEvent | null;
23
- };
24
- export declare class FloatingRef<C extends FloatingChannel = FloatingChannel, T extends HTMLElement = HTMLElement> {
25
- #private;
26
- readonly layerSvc: LayerService;
27
- readonly container: ContainerRef;
28
- readonly channel: ReplaySubject<FloatingChannel>;
29
- readonly state: Lifecycle<{
30
- init: {};
31
- showing: {};
32
- shown: {};
33
- closing: {
34
- cancellable: false;
35
- order: "sequential";
36
- };
37
- disposing: {
38
- cancellable: false;
39
- };
40
- disposed: {
41
- cancellable: false;
42
- order: "sequential";
43
- };
44
- cleanup: {
45
- cancellable: false;
46
- order: "sequential";
47
- };
48
- }, "showing" | "shown" | "disposing" | "disposed" | "init" | "closing" | "cleanup">;
49
- readonly traitState$: Observable<TraitState>;
50
- readonly uid: string;
51
- constructor(layerSvc: LayerService, container: ContainerRef, traits: Traits);
52
- show(): Observable<void>;
53
- /**
54
- * @deprecated
55
- */
56
- hide(): Observable<void>;
57
- close(force?: boolean): Observable<void>;
58
- emit(event: Omit<C, "floatingRef">): void;
59
- setResult(data: any): void;
60
- watchTrait<T>(name: string): Observable<T>;
61
- static ɵfac: i0.ɵɵFactoryDeclaration<FloatingRef<any, any>, never>;
62
- static ɵprov: i0.ɵɵInjectableDeclaration<FloatingRef<any, any>>;
63
- }
64
- export {};
@@ -1,57 +0,0 @@
1
- import { ComponentType } from "@angular/cdk/portal";
2
- import { Provider, TemplateRef } from "@angular/core";
3
- import { Observable } from "rxjs";
4
- import { LayerService } from "../layer/layer.service";
5
- import { ComponentPortalOptions, TemplatePortalOptions } from "../layer/portal-ref";
6
- import { FloatingChannel, FloatingRef } from "./floating-ref";
7
- import { type FloatingTrait } from "./traits/_base";
8
- import { type PositionTraitOptions } from "./traits/position";
9
- import * as i0 from "@angular/core";
10
- export type FloatingTraitInput = FloatingTrait | Array<FloatingTraitInput>;
11
- export declare abstract class FloatingFactory {
12
- #private;
13
- protected readonly floatingSvc: FloatingService;
14
- protected readonly traits: {
15
- [key: string]: FloatingTrait;
16
- };
17
- constructor(floatingSvc: FloatingService);
18
- trait(...traits: Array<FloatingTraitInput>): this;
19
- show(): Observable<FloatingChannel>;
20
- subscribe: Observable<FloatingChannel>["subscribe"];
21
- protected providers(providers?: Provider[]): Provider[];
22
- protected abstract create(): FloatingRef<FloatingChannel>;
23
- position(options: PositionTraitOptions): this;
24
- provides(providers: Provider | Provider[]): this;
25
- }
26
- export declare class FloatingTemplateFactory<T extends object> extends FloatingFactory {
27
- readonly tpl: TemplateRef<T>;
28
- readonly options: TemplatePortalOptions<T>;
29
- constructor(floatingSvc: FloatingService, tpl: TemplateRef<T>, options: TemplatePortalOptions<T>);
30
- protected create(): FloatingRef<FloatingChannel>;
31
- }
32
- export declare class FloatingComponentFactory<T extends ComponentType<any>> extends FloatingFactory {
33
- readonly component: T;
34
- readonly options: ComponentPortalOptions<T>;
35
- constructor(floatingSvc: FloatingService, component: T, options: ComponentPortalOptions<T>);
36
- protected create(): FloatingRef<FloatingChannel>;
37
- }
38
- /**
39
- * @example
40
- * ```typescript
41
- * class SomeComponent {}
42
- *
43
- * class SomeList {
44
- * readonly floating = inject(FloatingService)
45
- *
46
- * showComponent() {
47
- * this.floating.from(SomeComponent).traits(position(), backdrop()).subscribe()
48
- * }
49
- * ```
50
- */
51
- export declare class FloatingService {
52
- readonly layer: LayerService;
53
- from<T extends ComponentType<any>>(component: T, opts?: ComponentPortalOptions<T>): FloatingComponentFactory<T>;
54
- from<T extends object>(tpl: TemplateRef<T>, opts?: TemplatePortalOptions<T>): FloatingTemplateFactory<T>;
55
- static ɵfac: i0.ɵɵFactoryDeclaration<FloatingService, never>;
56
- static ɵprov: i0.ɵɵInjectableDeclaration<FloatingService>;
57
- }
@@ -1,3 +0,0 @@
1
- export * from "./traits";
2
- export * from "./floating-ref";
3
- export * from "./floating.service";
@@ -1,6 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import type { FloatingRef } from "../floating-ref";
3
- export interface FloatingTrait<T = any> {
4
- readonly name: string;
5
- connect(floatingRef: FloatingRef<any>): Observable<T>;
6
- }
@@ -1,30 +0,0 @@
1
- import { AnimationMetadata } from "@angular/animations";
2
- import { Observable } from "rxjs";
3
- import { FloatingPosition, Position } from "@ngutil/style";
4
- import { FloatingRef } from "../floating-ref";
5
- import { FloatingTrait } from "./_base";
6
- export type AnimationSet = {
7
- show: AnimationMetadata[];
8
- hide: AnimationMetadata[];
9
- };
10
- export type AnimationTraitParams = (position: FloatingPosition) => object;
11
- export declare class AnimationTrait implements FloatingTrait<unknown> {
12
- readonly animation: AnimationSet;
13
- readonly params?: AnimationTraitParams | undefined;
14
- readonly name = "animation";
15
- constructor(animation: AnimationSet, params?: AnimationTraitParams | undefined);
16
- connect(floatingRef: FloatingRef): Observable<unknown>;
17
- }
18
- export declare const FallAnimation: AnimationSet;
19
- export declare function fallAnimation(scale?: number): AnimationTrait;
20
- export declare const FadeAnimation: AnimationSet;
21
- export declare function fadeAnimation(): AnimationTrait;
22
- export declare function slideNearAnimation(size?: number): AnimationTrait;
23
- export declare function slideAwayAnimation(size?: number): AnimationTrait;
24
- type RippleRevealAnimationOptions = {
25
- origin: Position;
26
- initialRadius?: number;
27
- duration?: number;
28
- };
29
- export declare function rippleRevealAnimation(options: RippleRevealAnimationOptions): AnimationTrait;
30
- export {};
@@ -1,18 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { Primitive } from "utility-types";
3
- import { FloatingRef } from "../floating-ref";
4
- import { FloatingTrait } from "./_base";
5
- export type Attributes = {
6
- [key: string]: Primitive;
7
- } | {
8
- dataset: {
9
- [key: string]: Primitive;
10
- };
11
- };
12
- export declare class AttributeTrait implements FloatingTrait<Attributes> {
13
- readonly attrs: Attributes;
14
- readonly name = "attribute";
15
- constructor(attrs: Attributes);
16
- connect(floatingRef: FloatingRef): Observable<Attributes>;
17
- }
18
- export declare function attribute(attrs: Attributes): AttributeTrait;
@@ -1,16 +0,0 @@
1
- import { Observable } from "rxjs";
2
- import { CoverOptions } from "@ngutil/graphics";
3
- import { BackdropRef } from "../../layer";
4
- import { type FloatingRef } from "../floating-ref";
5
- import { FloatingTrait } from "./_base";
6
- interface CommonOptions {
7
- }
8
- export type BackdropTraitOptions = CoverOptions & CommonOptions;
9
- export declare class BackdropTrait implements FloatingTrait<BackdropRef> {
10
- readonly options: BackdropTraitOptions;
11
- readonly name = "backdrop";
12
- constructor(options: BackdropTraitOptions);
13
- connect(floatingRef: FloatingRef<any>): Observable<BackdropRef>;
14
- }
15
- export declare function backdrop(options: BackdropTraitOptions): BackdropTrait;
16
- export {};
@@ -1,35 +0,0 @@
1
- import { Observable, ObservableInput } from "rxjs";
2
- import { ElementInput } from "@ngutil/common";
3
- import { FloatingRef } from "../floating-ref";
4
- import { FloatingTrait } from "./_base";
5
- export interface ClickOutsideOptions {
6
- /**
7
- * If clicks happened on this element, that not trigger the close event
8
- */
9
- allowedElements?: ElementInput[];
10
- }
11
- export interface CloseTriggerOptions {
12
- /**
13
- * Close floating when click outside of floating element
14
- */
15
- clickOutside?: boolean | ClickOutsideOptions;
16
- /**
17
- * Only works when the floating element is focused
18
- */
19
- keystroke?: boolean;
20
- /**
21
- * Close when emitting any value
22
- */
23
- trigger?: ObservableInput<any>;
24
- }
25
- export interface CloseTriggerEvent {
26
- source: "click" | "keystroke" | "backbutton" | "trigger";
27
- }
28
- declare class CloseTriggerTrait implements FloatingTrait {
29
- readonly options: CloseTriggerOptions;
30
- readonly name = "close-trigger";
31
- constructor(options?: CloseTriggerOptions);
32
- connect(floatingRef: FloatingRef): Observable<CloseTriggerEvent | void>;
33
- }
34
- export declare function closeTrigger(options?: CloseTriggerOptions): CloseTriggerTrait;
35
- export {};