@ngutil/floating 0.0.34 → 0.0.36
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/esm2022/floating/floating-ref.mjs +4 -1
- package/esm2022/floating/floating.service.mjs +1 -2
- package/esm2022/floating/traits/_base.mjs +2 -3
- package/esm2022/floating/traits/animation.mjs +2 -4
- package/esm2022/floating/traits/attribute.mjs +2 -4
- package/esm2022/floating/traits/backdrop.mjs +2 -4
- package/esm2022/floating/traits/dim-contraint.mjs +15 -6
- package/esm2022/floating/traits/focus.mjs +48 -0
- package/esm2022/floating/traits/index.mjs +2 -2
- package/esm2022/floating/traits/keystroke.mjs +2 -4
- package/esm2022/floating/traits/modal.mjs +3 -3
- package/esm2022/floating/traits/position.mjs +4 -5
- package/esm2022/floating/traits/style.mjs +2 -4
- package/fesm2022/ngutil-floating.mjs +57 -32
- package/fesm2022/ngutil-floating.mjs.map +1 -1
- package/floating/floating.service.d.ts +2 -1
- package/floating/traits/_base.d.ts +3 -3
- package/floating/traits/animation.d.ts +2 -2
- package/floating/traits/attribute.d.ts +2 -2
- package/floating/traits/backdrop.d.ts +2 -2
- package/floating/traits/dim-contraint.d.ts +1 -1
- package/floating/traits/focus.d.ts +19 -0
- package/floating/traits/index.d.ts +1 -1
- package/floating/traits/keystroke.d.ts +1 -1
- package/floating/traits/modal.d.ts +1 -1
- package/floating/traits/position.d.ts +3 -3
- package/floating/traits/style.d.ts +2 -2
- package/package.json +4 -4
- package/esm2022/floating/traits/focus-trap.mjs +0 -27
- package/floating/traits/focus-trap.d.ts +0 -8
|
@@ -6,9 +6,9 @@ export type AnimationSet = {
|
|
|
6
6
|
show: AnimationMetadata[];
|
|
7
7
|
hide: AnimationMetadata[];
|
|
8
8
|
};
|
|
9
|
-
export declare class AnimationTrait
|
|
9
|
+
export declare class AnimationTrait implements FloatingTrait<unknown> {
|
|
10
10
|
readonly animation: AnimationSet;
|
|
11
|
-
name
|
|
11
|
+
readonly name = "animation";
|
|
12
12
|
constructor(animation: AnimationSet);
|
|
13
13
|
connect(floatingRef: FloatingRef): Observable<unknown>;
|
|
14
14
|
}
|
|
@@ -9,9 +9,9 @@ export type Attributes = {
|
|
|
9
9
|
[key: string]: Primitive;
|
|
10
10
|
};
|
|
11
11
|
};
|
|
12
|
-
export declare class AttributeTrait
|
|
12
|
+
export declare class AttributeTrait implements FloatingTrait<Attributes> {
|
|
13
13
|
readonly attrs: Attributes;
|
|
14
|
-
name
|
|
14
|
+
readonly name = "attribute";
|
|
15
15
|
constructor(attrs: Attributes);
|
|
16
16
|
connect(floatingRef: FloatingRef): Observable<Attributes>;
|
|
17
17
|
}
|
|
@@ -10,10 +10,10 @@ export interface BackdropTraitOptions {
|
|
|
10
10
|
export declare class BackdropState {
|
|
11
11
|
onClick: Observable<void>;
|
|
12
12
|
}
|
|
13
|
-
export declare class BackdropTrait
|
|
13
|
+
export declare class BackdropTrait implements FloatingTrait<BackdropState> {
|
|
14
14
|
#private;
|
|
15
15
|
readonly options: BackdropTraitOptions;
|
|
16
|
-
name
|
|
16
|
+
readonly name = "backdrop";
|
|
17
17
|
constructor(options: BackdropTraitOptions);
|
|
18
18
|
connect(floatingRef: FloatingRef<any>): Observable<BackdropState>;
|
|
19
19
|
}
|
|
@@ -11,7 +11,7 @@ interface DimMapEntry {
|
|
|
11
11
|
declare const DIM_MAP: {
|
|
12
12
|
[key: string]: DimMapEntry;
|
|
13
13
|
};
|
|
14
|
-
export declare class DimensionConstraintTrait
|
|
14
|
+
export declare class DimensionConstraintTrait implements FloatingTrait<number> {
|
|
15
15
|
#private;
|
|
16
16
|
readonly value: DimensionConstraintInput;
|
|
17
17
|
readonly name: string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Observable } from "rxjs";
|
|
2
|
+
import { Focusable, FocusState } from "@ngutil/aria";
|
|
3
|
+
import { ElementInput } from "@ngutil/common";
|
|
4
|
+
import { FloatingRef } from "../floating-ref";
|
|
5
|
+
import { FloatingTrait } from "./_base";
|
|
6
|
+
export interface FocusOptions {
|
|
7
|
+
trap?: boolean;
|
|
8
|
+
connect?: Focusable | FocusState;
|
|
9
|
+
tabindex?: number;
|
|
10
|
+
focusOnClose?: ElementInput;
|
|
11
|
+
}
|
|
12
|
+
export declare class FocusTrait implements FloatingTrait<unknown> {
|
|
13
|
+
#private;
|
|
14
|
+
readonly options: FocusOptions;
|
|
15
|
+
readonly name = "focus";
|
|
16
|
+
constructor(options: FocusOptions);
|
|
17
|
+
connect(floatingRef: FloatingRef): Observable<unknown>;
|
|
18
|
+
}
|
|
19
|
+
export declare function focus(options: FocusOptions): FocusTrait;
|
|
@@ -2,7 +2,7 @@ export * from "./_base";
|
|
|
2
2
|
export * from "./animation";
|
|
3
3
|
export * from "./backdrop";
|
|
4
4
|
export * from "./dim-contraint";
|
|
5
|
-
export * from "./focus
|
|
5
|
+
export * from "./focus";
|
|
6
6
|
export * from "./keystroke";
|
|
7
7
|
export * from "./modal";
|
|
8
8
|
export * from "./position-calc";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { FloatingRef } from "../floating-ref";
|
|
3
3
|
import { FloatingTrait } from "./_base";
|
|
4
|
-
export declare class KeystrokeTrait
|
|
4
|
+
export declare class KeystrokeTrait implements FloatingTrait<unknown> {
|
|
5
5
|
name: string;
|
|
6
6
|
connect(floatingRef: FloatingRef): Observable<unknown>;
|
|
7
7
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export interface ModalOptions {
|
|
2
2
|
closeOnBackdropClick?: boolean;
|
|
3
3
|
}
|
|
4
|
-
export declare function modal(options?: ModalOptions): (import("./animation").AnimationTrait | import("./position").PositionTrait | import("./backdrop").BackdropTrait | import("./focus
|
|
4
|
+
export declare function modal(options?: ModalOptions): (import("./animation").AnimationTrait | (import("@ngutil/floating").DimensionConstraintTrait | import("./position").PositionTrait)[] | import("./backdrop").BackdropTrait | import("./focus").FocusTrait | import("./keystroke").KeystrokeTrait)[];
|
|
@@ -41,13 +41,13 @@ export type FloatingPositionOptionsNormalized = FloatingPositionOptions & {
|
|
|
41
41
|
content: FloatingContent;
|
|
42
42
|
placement: FloatingPlacement;
|
|
43
43
|
};
|
|
44
|
-
export declare class PositionTrait
|
|
45
|
-
name
|
|
44
|
+
export declare class PositionTrait implements FloatingTrait<FloatingPosition> {
|
|
45
|
+
readonly name = "position";
|
|
46
46
|
readonly options: FloatingPositionOptionsNormalized;
|
|
47
47
|
constructor(options: FloatingPositionOptions);
|
|
48
48
|
connect(floatingRef: FloatingRef<any>): Observable<FloatingPosition>;
|
|
49
49
|
}
|
|
50
|
-
export declare function position(options: FloatingPositionOptions): PositionTrait;
|
|
50
|
+
export declare function position(options: FloatingPositionOptions): (import("./dim-contraint").DimensionConstraintTrait | PositionTrait)[];
|
|
51
51
|
export declare class FloatingPosition {
|
|
52
52
|
readonly options: FloatingPositionOptionsNormalized;
|
|
53
53
|
readonly floating: Dimension;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Observable } from "rxjs";
|
|
2
2
|
import { FloatingRef } from "../floating-ref";
|
|
3
3
|
import { FloatingTrait } from "./_base";
|
|
4
|
-
export declare class StyleTrait
|
|
4
|
+
export declare class StyleTrait implements FloatingTrait<Partial<CSSStyleDeclaration>> {
|
|
5
5
|
readonly styles: Partial<CSSStyleDeclaration>;
|
|
6
|
-
name
|
|
6
|
+
readonly name = "style";
|
|
7
7
|
constructor(styles: Partial<CSSStyleDeclaration>);
|
|
8
8
|
connect(floatingRef: FloatingRef): Observable<Partial<CSSStyleDeclaration>>;
|
|
9
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngutil/floating",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"tslib": "^2.6.2"
|
|
6
6
|
},
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"@angular/cdk": "^17.3.6",
|
|
9
9
|
"@angular/common": "^17.3.6",
|
|
10
10
|
"@angular/core": "^17.3.6",
|
|
11
|
-
"@ngutil/
|
|
12
|
-
"@ngutil/
|
|
13
|
-
"@ngutil/style": "0.0.
|
|
11
|
+
"@ngutil/common": "0.0.36",
|
|
12
|
+
"@ngutil/aria": "0.0.36",
|
|
13
|
+
"@ngutil/style": "0.0.36"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
import { FocusService } from "@ngutil/aria";
|
|
3
|
-
import { FloatingTrait } from "./_base";
|
|
4
|
-
export class FocusTrapTrait extends FloatingTrait {
|
|
5
|
-
constructor() {
|
|
6
|
-
super(...arguments);
|
|
7
|
-
this.name = "focus-trap";
|
|
8
|
-
}
|
|
9
|
-
connect(floatingRef) {
|
|
10
|
-
return new Observable(() => {
|
|
11
|
-
const svc = floatingRef.container.injector.get(FocusService);
|
|
12
|
-
const trap = svc.focusTrap(floatingRef.container.nativeElement);
|
|
13
|
-
const originallyFocused = document.activeElement;
|
|
14
|
-
floatingRef.state.on("shown", () => {
|
|
15
|
-
trap.focusInitialElement();
|
|
16
|
-
});
|
|
17
|
-
return () => {
|
|
18
|
-
trap.destroy();
|
|
19
|
-
originallyFocused && svc.focus(originallyFocused, "program");
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export function focusTrap() {
|
|
25
|
-
return new FocusTrapTrait();
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZm9jdXMtdHJhcC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3BhY2thZ2VzL2Zsb2F0aW5nL3NyYy9mbG9hdGluZy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gICB9KVxuXG4gICAgICAgICAgICByZXR1cm4gKCkgPT4ge1xuICAgICAgICAgICAgICAgIHRyYXAuZGVzdHJveSgpXG4gICAgICAgICAgICAgICAgb3JpZ2luYWxseUZvY3VzZWQgJiYgc3ZjLmZvY3VzKG9yaWdpbmFsbHlGb2N1c2VkLCBcInByb2dyYW1cIilcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSlcbiAgICB9XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBmb2N1c1RyYXAoKSB7XG4gICAgcmV0dXJuIG5ldyBGb2N1c1RyYXBUcmFpdCgpXG59XG4iXX0=
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Observable } from "rxjs";
|
|
2
|
-
import { FloatingRef } from "../floating-ref";
|
|
3
|
-
import { FloatingTrait } from "./_base";
|
|
4
|
-
export declare class FocusTrapTrait extends FloatingTrait<unknown> {
|
|
5
|
-
name: string;
|
|
6
|
-
connect(floatingRef: FloatingRef): Observable<unknown>;
|
|
7
|
-
}
|
|
8
|
-
export declare function focusTrap(): FocusTrapTrait;
|