@filip.mazev/modal 0.0.1

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.
Files changed (37) hide show
  1. package/README.md +63 -0
  2. package/fesm2022/filip.mazev-modal.mjs +932 -0
  3. package/fesm2022/filip.mazev-modal.mjs.map +1 -0
  4. package/index.d.ts +5 -0
  5. package/lib/classes/generic-modal-config.d.ts +26 -0
  6. package/lib/classes/generic-modal-ref.d.ts +52 -0
  7. package/lib/classes/generic-modal-style.config.d.ts +17 -0
  8. package/lib/classes/generic-modal.d.ts +19 -0
  9. package/lib/components/generic-modal.d.ts +60 -0
  10. package/lib/components/views/backdrop/modal-backdrop.d.ts +8 -0
  11. package/lib/components/views/banner/modal-banner.d.ts +9 -0
  12. package/lib/components/views/centered/modal-centered.d.ts +23 -0
  13. package/lib/components/views/side/modal-side.d.ts +26 -0
  14. package/lib/components/views/swipeable/modal-swipeable.d.ts +32 -0
  15. package/lib/constants/generic-modal-animation.constants.d.ts +4 -0
  16. package/lib/constants/generic-modal-common.constants.d.ts +1 -0
  17. package/lib/constants/generic-modal-swipe.constants.d.ts +3 -0
  18. package/lib/constants/generic-modal-text.constants.d.ts +4 -0
  19. package/lib/enums/generic-modal-errors.enum.d.ts +6 -0
  20. package/lib/enums/generic-modal-state.enum.d.ts +6 -0
  21. package/lib/enums/generic-modal-warnings.enum.d.ts +7 -0
  22. package/lib/interfaces/igeneric-close-result.interface.d.ts +5 -0
  23. package/lib/interfaces/igeneric-confirm-close.interface.d.ts +24 -0
  24. package/lib/interfaces/igeneric-confirm-modal-data.interface.d.ts +3 -0
  25. package/lib/interfaces/igeneric-modal-component.interface.d.ts +28 -0
  26. package/lib/interfaces/igeneric-modal-config.interface.d.ts +45 -0
  27. package/lib/interfaces/igeneric-modal-ref.interface.d.ts +25 -0
  28. package/lib/interfaces/igeneric-modal-service.interface.d.ts +22 -0
  29. package/lib/interfaces/igeneric-modal-style-config.interface.d.ts +28 -0
  30. package/lib/interfaces/igeneric-modal-view.interface.d.ts +18 -0
  31. package/lib/interfaces/igeneric-swipeable-modal-config.d.ts +5 -0
  32. package/lib/services/generic-modal.service.d.ts +40 -0
  33. package/lib/tokens/generic-modal-data.token.d.ts +2 -0
  34. package/lib/types/modal.types.d.ts +2 -0
  35. package/package.json +24 -0
  36. package/public-api.d.ts +30 -0
  37. package/src/assets/default-theme.css +5 -0
@@ -0,0 +1,28 @@
1
+ import { ComponentRef, OnDestroy, OnInit } from "@angular/core";
2
+ import { Subject, Observable } from "rxjs";
3
+ import { GenericModal } from "../classes/generic-modal";
4
+ import { GenericModalConfig } from "../classes/generic-modal-config";
5
+ import { ModalCloseMode } from "../types/modal.types";
6
+ /**
7
+ * Interface for the Generic Modal Component
8
+ * @param {ComponentRef<any>} componentRef (optional) The component reference (the component that is being displayed in the modal), will default to undefined (for non-dynamic modals)
9
+ * @param {GenericModalConfig} config (optional) The configuration for the modal, will default to default values for the configuration
10
+ * @param {boolean} isOpen (required) Whether the modal is open or not
11
+ * @param {number} animationDuration (required) The duration of the animation (in milliseconds)
12
+ * @param {boolean} isSwipeableModalActive (required) Whether the swipeable modal is active (open) or not
13
+ * @param {Subject<MouseEvent>} backdropClickSubject (required) The subject for the backdrop click event, will be used to listen for backdrop clicks
14
+ * @param {Observable<MouseEvent>} backdropClick (required) The observable for the backdrop click event, will be used to listen for backdrop clicks (subscribed to the backdropClickSubject)
15
+ * @param {Function} closeFunction (optional) The outside function to run when the modal closes (received from the config)
16
+ * @param {Function} close (required) The function to run when the modal closes, will return the result of the modal
17
+ */
18
+ export interface IGenericModalComponenet<D = any, R = any, C extends GenericModal<D, R> = GenericModal<D, R>> extends OnInit, OnDestroy {
19
+ componentRef?: ComponentRef<C>;
20
+ config?: GenericModalConfig<D>;
21
+ isOpen: boolean;
22
+ animationDuration: number;
23
+ isSwipeableModalActive: boolean;
24
+ backdropClickSubject: Subject<MouseEvent>;
25
+ backdropClick: Observable<MouseEvent>;
26
+ closeFunction?: Function;
27
+ close: (state: ModalCloseMode, result: R | undefined, fromInsideInteraction: boolean, forceClose: boolean) => void;
28
+ }
@@ -0,0 +1,45 @@
1
+ import { GenericModal } from "../classes/generic-modal";
2
+ import { IGenericConfirmCloseConfig } from "./igeneric-confirm-close.interface";
3
+ import { IGenericModalStyleConfig } from "./igeneric-modal-style-config.interface";
4
+ /**
5
+ * IGenericModalConfig<D>, the configuration for the generic modal
6
+ * @param {boolean} open (optional) Whether the modal should be open or not, will default to true
7
+ * @param {Function} afterClose (optional) The function to run after the modal closes
8
+ * @param {IGenericConfirmCloseConfig<ConfirmComponent, ConfirmComponentData>} confirmCloseConfig (optional) The configuration for the confirm close modal, will default to { confirmClose: false }
9
+ * @param {boolean} disableClose (optional) Whether the modal should be closable or not, will default to false (this applies to the close button and backdrop)
10
+ * @param {boolean} disableCloseOnBackdropClick (optional) Whether the modal shouldn't be closable when the user clicks on the backdrop, will default to false
11
+ * @param {boolean} disableCloseOnNavigation (optional) Whether the modal should be closable or not when the user navigates away from the page, will default to false
12
+ * @param {boolean} enableExtremeOverflowHandling (optional) Whether the modal should enable the extreme overflow handling (may cause issues with keypress registration) or not, will default to false
13
+ * @param {boolean} webkitOnlyOverflowMobileHandling (optional) Whether the modal should only handle overflow for webkit browsers on mobile or should it handle it for all browsers, will default to true
14
+ * @param {boolean} closeOnSwipeBack (optional) Whether the modal should close when swiped back on mobile devices, will default to false
15
+ * @param {D | null} data (optional) The data to pass to the component of the modal, the component needs to have the @Inject(GENERIC_MODAL_DATA) data: any; decorator to receive this data
16
+ * @param {IGenericModalStyleConfig} style (optional) The style configuration for the modal, will default to an empty object
17
+ * @param {boolean} showCloseButton (optional) Whether the modal should show a close button or not, will default to true
18
+ * @param {string} bannerText (optional) The text to display in the banner of the modal
19
+ * @param {string} bannerTextAnnotatedString (optional) The annotated string (in bold style, in addition to some text) to display in the banner of the modal, will default to an empty string
20
+ * @param {string[]} bannerIcons (optional) The icons to display in the banner of the modal
21
+ * @param {string} contentClasses (optional) The classes to apply to the content of the modal
22
+ * @param {string} contentStyles (optional) The styles to apply to the content of the modal
23
+ * @param {string} id (optional) The id of the modal (set at the top level of the modal), will default to a random string
24
+ */
25
+ export interface IGenericModalConfig<D = undefined, ConfirmComponentData = any, ConfirmComponent extends GenericModal<ConfirmComponentData, undefined> = GenericModal<ConfirmComponentData, undefined>> {
26
+ open?: boolean;
27
+ afterClose?: Function;
28
+ confirmCloseConfig?: IGenericConfirmCloseConfig<ConfirmComponentData, ConfirmComponent>;
29
+ disableClose?: boolean;
30
+ disableCloseOnBackdropClick?: boolean;
31
+ disableCloseOnNavigation?: boolean;
32
+ enableExtremeOverflowHandling?: boolean;
33
+ webkitOnlyOverflowMobileHandling?: boolean;
34
+ closeOnSwipeBack?: boolean;
35
+ data?: D | null;
36
+ style?: IGenericModalStyleConfig;
37
+ bannerText?: string;
38
+ bannerTextAnnotatedString?: string;
39
+ bannerIcons?: string[];
40
+ contentClasses?: string;
41
+ contentStyles?: string;
42
+ disableConsoleWarnings?: boolean;
43
+ disableConsoleInfo?: boolean;
44
+ id?: string;
45
+ }
@@ -0,0 +1,25 @@
1
+ import { Observable } from "rxjs";
2
+ import { ComponentRef, Type } from "@angular/core";
3
+ import { GenericModal } from "../classes/generic-modal";
4
+ import { GenericModalConfig } from "../classes/generic-modal-config";
5
+ import { GenericModalComponent } from "../components/generic-modal";
6
+ import { GenericModalState } from "../enums/generic-modal-state.enum";
7
+ import { IGenericCloseResult } from "./igeneric-close-result.interface";
8
+ export interface IGenericModalRef<D = any, R = any, C extends GenericModal<D, R> = GenericModal<D, R>> {
9
+ modalContainer: Type<GenericModalComponent<D, R, C>>;
10
+ modalContainerRef: ComponentRef<GenericModalComponent<D, R, C>>;
11
+ modalContainerElement: HTMLElement;
12
+ parentElement?: HTMLElement;
13
+ componentRef: ComponentRef<C>;
14
+ modalState$(): Observable<GenericModalState>;
15
+ selfIdentifier: {
16
+ constructor: Function;
17
+ };
18
+ modalConfig?: GenericModalConfig<D>;
19
+ afterClosed(): Observable<IGenericCloseResult<R>>;
20
+ backdropClick(): Observable<MouseEvent>;
21
+ open(): void;
22
+ close: (state: "confirm" | "cancel", result: R | undefined, forceClose: boolean, fromSelf: boolean, from: {
23
+ constructor: Function;
24
+ } | undefined) => void;
25
+ }
@@ -0,0 +1,22 @@
1
+ import { OnDestroy, Renderer2, ViewContainerRef } from "@angular/core";
2
+ import { ComponentType } from "@angular/cdk/portal";
3
+ import { IGenericModalConfig } from "./igeneric-modal-config.interface";
4
+ import { Observable } from "rxjs";
5
+ import { GenericModalRef } from "../classes/generic-modal-ref";
6
+ import { GenericModalComponent } from "../components/generic-modal";
7
+ export interface IGenericModalService extends OnDestroy {
8
+ viewContainer?: ViewContainerRef;
9
+ register: (viewContainer: ViewContainerRef, renderer: Renderer2) => void;
10
+ open: (component: ComponentType<any>, config?: IGenericModalConfig<any>) => GenericModalRef<any, any, any>;
11
+ close: (self: {
12
+ constructor: Function;
13
+ }, fromCloseFunction: boolean | undefined) => void;
14
+ closeAll: () => void;
15
+ get: (self: {
16
+ constructor: Function;
17
+ }) => GenericModalRef<any, any, any> | GenericModalComponent<any, any, any> | undefined;
18
+ getSubscribe(self: {
19
+ constructor: Function;
20
+ }): Observable<GenericModalRef<any, any, any> | GenericModalComponent<any, any, any> | undefined>;
21
+ modalsCount: () => number;
22
+ }
@@ -0,0 +1,28 @@
1
+ import { ModalPoistion } from "../types/modal.types";
2
+ import { IGenericSwipeableModalConfig } from "./igeneric-swipeable-modal-config";
3
+ /**
4
+ * IGenericModalStyleConfig
5
+ * @param {center' | 'left' | 'right'} position (optional) The position of the modal (can be center, left, or right), will default to center
6
+ * @param {boolean} handleMobile (optional) Whether the modal should open in a mobile configuration when going to a certain screen size
7
+ * @param {boolean} animate (optional) Whether the modal should have animations or not, will default to true
8
+ * @param {boolean} hasBackdrop (optional) Whether the modal should have a backdrop or not, will default to true
9
+ * @param {number} closeDelay (optional) The delay in milliseconds before the modal closes, will default to GENERIC_MODAL_DEFAULT_ANIM_DURATION (175)
10
+ * @param {IGenericSwipeableModalConfig} mobileConfig (optional) The configuration for the swipeable modal, will default to an empty object
11
+ * @param {boolean} contentWrapper (optional) Whether the content should be wrapped in a default-styled div or not, will default to true
12
+ * @param {string} wrapperClasses (optional) The classes to apply to the wrapper of the modal
13
+ * @param {string} wrapperStyles (optional) The styles to apply to the wrapper of the modal
14
+ * @param {boolean} overrideFullHeight (optional) Whether the modal should override the full height of the modal or not, will default to false
15
+ */
16
+ export interface IGenericModalStyleConfig {
17
+ position?: ModalPoistion;
18
+ handleMobile?: boolean;
19
+ animate?: boolean;
20
+ hasBackdrop?: boolean;
21
+ closeDelay?: number;
22
+ showCloseButton?: boolean;
23
+ mobileConfig?: IGenericSwipeableModalConfig;
24
+ contentWrapper?: boolean;
25
+ wrapperClasses?: string;
26
+ wrapperStyles?: string;
27
+ overrideFullHeight?: boolean;
28
+ }
@@ -0,0 +1,18 @@
1
+ import { InputSignal, OutputEmitterRef, QueryList } from "@angular/core";
2
+ import { GenericModalConfig } from "../classes/generic-modal-config";
3
+ import { ModalSwipeable } from "../components/views/swipeable/modal-swipeable";
4
+ import { ModalCloseMode } from "../types/modal.types";
5
+ export interface IGenericModalView<D = unknown> {
6
+ config: InputSignal<GenericModalConfig<D> | undefined>;
7
+ isOpen: InputSignal<boolean>;
8
+ isAnimated: InputSignal<boolean>;
9
+ isSwipeableModalActive: InputSignal<boolean>;
10
+ animationDuration: InputSignal<number>;
11
+ hasDefaultContentWrapperClass: InputSignal<boolean>;
12
+ hasBanner: InputSignal<boolean>;
13
+ close: OutputEmitterRef<ModalCloseMode | undefined>;
14
+ swipeableComponents: QueryList<ModalSwipeable>;
15
+ get modalClasses(): {
16
+ [key: string]: boolean;
17
+ };
18
+ }
@@ -0,0 +1,5 @@
1
+ export interface IGenericSwipeableModalConfig {
2
+ upSwipeLimit?: number;
3
+ downSwipeLimit?: number;
4
+ customHeight?: number;
5
+ }
@@ -0,0 +1,40 @@
1
+ import { Injector, ViewContainerRef, Renderer2 } from "@angular/core";
2
+ import { Observable } from "rxjs";
3
+ import { GenericModal } from "../classes/generic-modal";
4
+ import { GenericModalRef } from "../classes/generic-modal-ref";
5
+ import { GenericModalComponent } from "../components/generic-modal";
6
+ import { IGenericModalConfig } from "../interfaces/igeneric-modal-config.interface";
7
+ import { IGenericModalService } from "../interfaces/igeneric-modal-service.interface";
8
+ import { ComponentType } from "@angular/cdk/portal";
9
+ import * as i0 from "@angular/core";
10
+ export declare class GenericModalService implements IGenericModalService {
11
+ private router;
12
+ protected injector: Injector;
13
+ private modals;
14
+ private modalsSubject;
15
+ viewContainer?: ViewContainerRef;
16
+ renderer?: Renderer2;
17
+ private unsubscribe$;
18
+ constructor();
19
+ ngOnDestroy(): void;
20
+ private createSubscriptions;
21
+ register(viewContainer: ViewContainerRef, renderer: Renderer2): void;
22
+ open<D, R, C extends GenericModal<D, R> = GenericModal<D, R>>(component: ComponentType<C>, config?: IGenericModalConfig<D>): GenericModalRef<D, R, C>;
23
+ close(self: {
24
+ constructor: Function;
25
+ }, fromCloseFunction?: boolean | undefined): void;
26
+ closeAll(onNavigate?: boolean): void;
27
+ get<D, R, C extends GenericModal<D, R> = GenericModal<D, R>>(self: {
28
+ constructor: Function;
29
+ }): GenericModalRef<D, R, C> | GenericModalComponent<D, R, C> | undefined;
30
+ getSubscribe<D, R, C extends GenericModal<D, R> = GenericModal<D, R>>(self: {
31
+ constructor: Function;
32
+ }): Observable<GenericModalRef<D, R, C> | GenericModalComponent<D, R, C> | undefined>;
33
+ modalsCount(): number;
34
+ find(self: {
35
+ constructor: Function;
36
+ }): boolean;
37
+ modalRequestedTypeCheck(modal: GenericModalRef | GenericModalComponent | undefined): boolean;
38
+ static ɵfac: i0.ɵɵFactoryDeclaration<GenericModalService, never>;
39
+ static ɵprov: i0.ɵɵInjectableDeclaration<GenericModalService>;
40
+ }
@@ -0,0 +1,2 @@
1
+ import { InjectionToken } from "@angular/core";
2
+ export declare const GENERIC_MODAL_DATA: InjectionToken<any>;
@@ -0,0 +1,2 @@
1
+ export type ModalCloseMode = "cancel" | "confirm";
2
+ export type ModalPoistion = "center" | "right" | "left";
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@filip.mazev/modal",
3
+ "version": "0.0.1",
4
+ "peerDependencies": {
5
+ "@angular/common": "^21.1.1",
6
+ "@angular/core": "^21.1.1",
7
+ "@filip.mazev/common-parts": "^0.0.1"
8
+ },
9
+ "dependencies": {
10
+ "tslib": "^2.3.0"
11
+ },
12
+ "sideEffects": false,
13
+ "module": "fesm2022/filip.mazev-modal.mjs",
14
+ "typings": "index.d.ts",
15
+ "exports": {
16
+ "./package.json": {
17
+ "default": "./package.json"
18
+ },
19
+ ".": {
20
+ "types": "./index.d.ts",
21
+ "default": "./fesm2022/filip.mazev-modal.mjs"
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,30 @@
1
+ export * from './lib/components/generic-modal';
2
+ export * from './lib/components/views/swipeable/modal-swipeable';
3
+ export * from './lib/components/views/side/modal-side';
4
+ export * from './lib/components/views/centered/modal-centered';
5
+ export * from './lib/components/views/backdrop/modal-backdrop';
6
+ export * from './lib/components/views/banner/modal-banner';
7
+ export * from './lib/services/generic-modal.service';
8
+ export * from './lib/classes/generic-modal';
9
+ export * from './lib/classes/generic-modal-config';
10
+ export * from './lib/classes/generic-modal-ref';
11
+ export * from './lib/classes/generic-modal-style.config';
12
+ export * from './lib/interfaces/igeneric-close-result.interface';
13
+ export * from './lib/interfaces/igeneric-confirm-close.interface';
14
+ export * from './lib/interfaces/igeneric-confirm-modal-data.interface';
15
+ export * from './lib/interfaces/igeneric-modal-component.interface';
16
+ export * from './lib/interfaces/igeneric-modal-config.interface';
17
+ export * from './lib/interfaces/igeneric-modal-ref.interface';
18
+ export * from './lib/interfaces/igeneric-modal-service.interface';
19
+ export * from './lib/interfaces/igeneric-modal-style-config.interface';
20
+ export * from './lib/interfaces/igeneric-modal-view.interface';
21
+ export * from './lib/interfaces/igeneric-swipeable-modal-config';
22
+ export * from './lib/constants/generic-modal-animation.constants';
23
+ export * from './lib/constants/generic-modal-common.constants';
24
+ export * from './lib/constants/generic-modal-swipe.constants';
25
+ export * from './lib/constants/generic-modal-text.constants';
26
+ export * from './lib/enums/generic-modal-errors.enum';
27
+ export * from './lib/enums/generic-modal-warnings.enum';
28
+ export * from './lib/enums/generic-modal-state.enum';
29
+ export * from './lib/tokens/generic-modal-data.token';
30
+ export * from './lib/types/modal.types';
@@ -0,0 +1,5 @@
1
+ :root {
2
+ --modal_bg: #f0f0f0;
3
+ --text_primary: #2d2d2d;
4
+ --swipe_line_color: #cccccc;
5
+ }