@ethlete/cdk 4.30.0 → 4.31.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.
- package/CHANGELOG.md +8 -0
- package/esm2022/lib/components/overlay/components/overlay/types/overlay.types.mjs +1 -1
- package/esm2022/lib/components/overlay/components/overlay/utils/index.mjs +2 -1
- package/esm2022/lib/components/overlay/components/overlay/utils/overlay-handler.mjs +46 -0
- package/fesm2022/ethlete-cdk.mjs +673 -632
- package/fesm2022/ethlete-cdk.mjs.map +1 -1
- package/lib/components/overlay/components/overlay/types/overlay.types.d.ts +9 -0
- package/lib/components/overlay/components/overlay/utils/index.d.ts +1 -0
- package/lib/components/overlay/components/overlay/utils/overlay-handler.d.ts +27 -0
- package/package.json +1 -1
|
@@ -2,6 +2,7 @@ import { Direction } from '@angular/cdk/bidi';
|
|
|
2
2
|
import { PositionStrategy, ScrollStrategy } from '@angular/cdk/overlay';
|
|
3
3
|
import { Injector, StaticProvider, ViewContainerRef } from '@angular/core';
|
|
4
4
|
import { Breakpoint } from '@ethlete/core';
|
|
5
|
+
import { EmptyObject } from '@ethlete/query';
|
|
5
6
|
/** Options for where to set focus to automatically on overlay open */
|
|
6
7
|
export type OverlayAutoFocusTarget = 'dialog' | 'first-tabbable' | 'first-heading';
|
|
7
8
|
/** Valid ARIA roles for a overlay element. */
|
|
@@ -194,3 +195,11 @@ export interface OverlayConfig<D = unknown> {
|
|
|
194
195
|
*/
|
|
195
196
|
origin?: HTMLElement | MouseEvent | TouchEvent | KeyboardEvent | PointerEvent;
|
|
196
197
|
}
|
|
198
|
+
/**
|
|
199
|
+
* Configuration utility type for overlays.
|
|
200
|
+
* To be used inside your overlay opener method as a param to be passed to the overlay.open method.
|
|
201
|
+
*/
|
|
202
|
+
export type OverlayConsumerConfig<D = void> = Omit<OverlayConfig<D>, 'positions' | 'data'> & MaybeOverlayConsumerConfigWithData<D>;
|
|
203
|
+
export type MaybeOverlayConsumerConfigWithData<D> = D extends void ? EmptyObject : {
|
|
204
|
+
data: D;
|
|
205
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComponentType } from '@angular/cdk/overlay';
|
|
2
|
+
import { TemplateRef } from '@angular/core';
|
|
3
|
+
import { OverlayBreakpointConfigEntry, OverlayConfig, OverlayConsumerConfig } from '../types';
|
|
4
|
+
import { OverlayPositionBuilder } from './overlay-position-builder';
|
|
5
|
+
import { OverlayRef } from './overlay-ref';
|
|
6
|
+
export type CreateOverlayHandlerConfig<T, D = unknown, R = unknown> = Omit<OverlayConfig<D>, 'positions'> & {
|
|
7
|
+
/** The overlay component. Use either this or the `template` property */
|
|
8
|
+
component?: ComponentType<T>;
|
|
9
|
+
/** The overlay template. Use either this or the `component` property */
|
|
10
|
+
template?: TemplateRef<T>;
|
|
11
|
+
/** The overlay positions using the position builder provided via argument */
|
|
12
|
+
positions: (builder: OverlayPositionBuilder) => OverlayBreakpointConfigEntry[];
|
|
13
|
+
};
|
|
14
|
+
export type OverlayHandler<T, D = unknown, R = unknown> = {
|
|
15
|
+
/** Open the overlay using a combination of the given configs */
|
|
16
|
+
open: (config?: OverlayConsumerConfig<D>) => OverlayRef<T, R>;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the typed overlay ref.
|
|
19
|
+
* @throws Error if the overlay ref gets accessed outside of the overlay component or templateRef
|
|
20
|
+
*/
|
|
21
|
+
getOverlayRef: () => OverlayRef<T, R>;
|
|
22
|
+
};
|
|
23
|
+
export type CreateOverlayHandlerInnerConfig<R = unknown> = {
|
|
24
|
+
/** A callback function to be executed once the overlay has been closed */
|
|
25
|
+
afterClosed?: (result: R | null) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const createOverlayHandler: <T, D = unknown, R = unknown>(rootConfig: CreateOverlayHandlerConfig<T, D, R>) => (innerConfig?: CreateOverlayHandlerInnerConfig<R>) => OverlayHandler<T, D, R>;
|