@almoamendev/ngx-md3 0.0.16 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almoamendev/ngx-md3",
3
- "version": "0.0.16",
3
+ "version": "0.1.0",
4
4
  "description": "MD3-style Angular components & style library",
5
5
  "author": "Murtadha (Hussain) Almoamen",
6
6
  "license": "MIT",
@@ -1,9 +1,10 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ViewContainerRef, Injector, ElementRef, AfterViewInit, OnDestroy, OnInit, Renderer2, Signal, InputSignal, AfterContentInit, Type, ComponentRef, InjectionToken, TemplateRef } from '@angular/core';
2
+ import { ViewContainerRef, Injector, ElementRef, AfterViewInit, OnDestroy, OnInit, Renderer2, Signal, InputSignal, Type, ComponentRef, InjectionToken, AfterContentInit, TemplateRef } from '@angular/core';
3
3
  import { FlexibleConnectedPositionStrategyOrigin, ConnectedPosition, OverlayRef } from '@angular/cdk/overlay';
4
4
  import * as i1 from '@angular/cdk/scrolling';
5
5
  import { AbstractControl } from '@angular/forms';
6
6
  import * as i1$1 from '@angular/router';
7
+ import { CdkDialogContainer, DialogRef as DialogRef$1 } from '@angular/cdk/dialog';
7
8
  import { Observable } from 'rxjs';
8
9
  import { CdkPortalOutlet } from '@angular/cdk/portal';
9
10
 
@@ -35,6 +36,13 @@ type SliderSize = 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
35
36
 
36
37
  type DialogRole = 'dialog' | 'alertdialog';
37
38
 
39
+ /**
40
+ * What happens to a dialog that is already open when a new dialog opens.
41
+ * - close: the open dialogs are closed before the new one opens.
42
+ * - hide: the dialog on top is hidden and shown again once the new one closes.
43
+ */
44
+ type PreviousDialog = 'close' | 'hide';
45
+
38
46
  type ChipType = 'assist' | 'filter' | 'input' | 'suggestion';
39
47
 
40
48
  type ChipStyle = 'default' | 'surface' | 'elevated';
@@ -55,6 +63,11 @@ interface DialogConfig<D = unknown> {
55
63
  */
56
64
  bindDataToInputs?: boolean;
57
65
  disableCloseEvents?: boolean;
66
+ /**
67
+ * What happens to a dialog that is already open when this dialog opens.
68
+ * A hidden dialog keeps its state and is shown again once this dialog closes.
69
+ */
70
+ previousDialog?: PreviousDialog;
58
71
  role?: DialogRole;
59
72
  ariaLabel?: string;
60
73
  ariaLabelledBy?: string;
@@ -934,15 +947,23 @@ declare class SupportingText {
934
947
  static ɵdir: _angular_core.ɵɵDirectiveDeclaration<SupportingText, "[md3-supporting-text]", never, {}, {}, never, never, true, never>;
935
948
  }
936
949
 
937
- declare class Dialog implements AfterContentInit {
938
- private readonly portalOutlet;
950
+ /**
951
+ * Material 3 dialog shell. It extends the CDK dialog container, so focus
952
+ * trapping, focus restoration and the ARIA attributes are handled by the CDK
953
+ * while this component only owns the MD3 surface and its animation.
954
+ */
955
+ declare class Dialog extends CdkDialogContainer {
939
956
  isActive: _angular_core.WritableSignal<boolean>;
940
957
  protected readonly config: DialogConfig<unknown>;
941
- protected get role(): string;
942
- ngAfterContentInit(): void;
943
958
  /**
944
- * The service creates this wrapper first, then calls this method to mount
945
- * the user supplied component into the dialog container.
959
+ * Started by DialogService, either right after the dialog is created or
960
+ * once the dialog it replaces has finished animating out. The animation
961
+ * runs on the next frame so the surface has a real from/to state.
962
+ */
963
+ startEnterAnimation(): void;
964
+ /**
965
+ * @deprecated The CDK dialog service attaches the content. Kept for
966
+ * backwards compatibility and will be removed in a future release.
946
967
  */
947
968
  attachContent<T>(component: Type<T>, injector: Injector): ComponentRef<T>;
948
969
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<Dialog, never>;
@@ -953,36 +974,98 @@ declare const DIALOG_DATA: InjectionToken<unknown>;
953
974
  declare const DIALOG_CONFIG: InjectionToken<DialogConfig<unknown>>;
954
975
  declare const DIALOG_COMPONENT: InjectionToken<Type<unknown>>;
955
976
  declare class DialogRef<T = unknown, R = unknown> {
956
- private readonly overlayRef;
957
- private readonly previouslyFocusedElement;
977
+ private readonly cdkRef;
958
978
  private readonly closed;
959
- private isClosed;
979
+ private readonly closing;
980
+ private closePromise;
981
+ private closeStarted;
982
+ private closeSettled;
983
+ private hidden;
960
984
  dialogInstance?: Dialog;
961
985
  /**
962
986
  * Filled by DialogService after the user component is attached. Keeping the
963
987
  * instance here lets callers imperatively update inputs when that is useful.
964
988
  */
965
989
  componentInstance?: T;
966
- constructor(overlayRef: OverlayRef, previouslyFocusedElement: HTMLElement | null);
967
- close(result?: R): void;
968
- private startCloseAnimation;
990
+ /** Overlay hosting the dialog, useful to reach the panel and the scrim. */
991
+ get overlayRef(): OverlayRef;
992
+ /** Whether the dialog started closing. Such a dialog cannot be hidden or shown anymore. */
993
+ get isClosing(): boolean;
994
+ /** Whether the dialog is currently hidden behind another dialog. */
995
+ get isHidden(): boolean;
996
+ constructor(cdkRef: DialogRef$1<R, T>, disableCloseEvents: boolean);
997
+ /** Closes the dialog. The promise resolves once the exit animation is done. */
998
+ close(result?: R): Promise<void>;
999
+ /**
1000
+ * Hides the dialog with the closing animation while keeping it alive, so
1001
+ * its content, form state and subscriptions survive until show() is called.
1002
+ * The promise resolves once the dialog is out of sight.
1003
+ */
1004
+ hide(): Promise<void>;
1005
+ /**
1006
+ * Brings a hidden dialog back with the opening animation. Focus moves back
1007
+ * into the dialog even when it was never hidden, which is what makes it
1008
+ * usable again once the dialog above it closes.
1009
+ */
1010
+ show(): void;
1011
+ /** Emits when the dialog starts closing, before the exit animation runs. */
1012
+ beforeClosed(): Observable<void>;
969
1013
  afterClosed(): Observable<R | undefined>;
1014
+ private connectCloseEvents;
1015
+ private toggleHiddenState;
1016
+ private startClosing;
1017
+ private startCloseAnimation;
1018
+ /** Resolves when the surface finished animating, with a timeout as a safety net. */
1019
+ private waitForSurfaceAnimation;
1020
+ /** Emits the result once the CDK reference is closed. Focus is restored by the container. */
1021
+ private settle;
970
1022
  }
971
1023
 
972
1024
  declare class DialogService {
1025
+ private readonly cdkDialog;
973
1026
  private readonly overlay;
974
1027
  private readonly injector;
975
1028
  private readonly document;
1029
+ /** Open dialogs, from the first one opened to the one currently on top. */
1030
+ private readonly refs;
1031
+ /**
1032
+ * Page scrolling is blocked here instead of per overlay, so stacked dialogs
1033
+ * cannot unblock the page while another dialog is still open.
1034
+ */
1035
+ private readonly scrollBlock;
1036
+ /** Element that was focused before the first dialog of the stack opened. */
1037
+ private rootTrigger;
1038
+ get openDialogs(): readonly DialogRef<any, any>[];
976
1039
  open<T, D = unknown, R = unknown>(component: Type<T>, config?: DialogConfig<D>): DialogRef<T, R>;
1040
+ /** Closes every open dialog, including the hidden ones. */
1041
+ closeAll(): Promise<void>;
977
1042
  private mergeConfig;
978
- private createOverlay;
1043
+ /**
1044
+ * Hides or closes the dialog that is on screen. Its scrim stays up until
1045
+ * the dialog taking over is ready for it, so the page behind never
1046
+ * brightens between the two dialogs.
1047
+ */
1048
+ private dismissPrevious;
979
1049
  private startOpenAnimation;
980
- private createInjector;
1050
+ /** Opening animation for a dialog that took the place of another one. */
1051
+ private startReplacingAnimation;
1052
+ /** Opening animation for a dialog coming back from behind a closing one. */
1053
+ private startRestoringAnimation;
1054
+ /**
1055
+ * Moves both scrims to their new value in a single frame, without a
1056
+ * transition on either side, so the dim behind the dialogs never changes.
1057
+ */
1058
+ private beginScrimHandover;
1059
+ /** Gives the scrims their transitions back once the handover is painted. */
1060
+ private endScrimHandover;
981
1061
  private bindDataToInputs;
982
- private connectCloseEvents;
983
- private focusDialog;
984
- private getFocusedElement;
985
1062
  private canBindDataToInputs;
1063
+ /** Last dialog of the stack that is not closing yet. */
1064
+ private topRef;
1065
+ private restorePreviousDialog;
1066
+ private removeRef;
1067
+ private updateScrollBlock;
1068
+ private getFocusedElement;
986
1069
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<DialogService, never>;
987
1070
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<DialogService>;
988
1071
  }
@@ -1295,4 +1378,4 @@ declare class SnackbarService {
1295
1378
  }
1296
1379
 
1297
1380
  export { AppBar, AppBarLogo, Avatar, Badge, Button, ButtonGroup, Card, Checkbox, ChipAvatar, Chips, CircularProgressIndicator, DIALOG_COMPONENT, DIALOG_CONFIG, DIALOG_DATA, Dialog, DialogActions, DialogBody, DialogHeader, DialogRef, DialogService, Divider, FloatingActionButton, Grid, GridItem, IconButton, IconElement, InputElement, LayoutService, LinearProgressIndicator, List, ListItem, ListItemPrimaryAction, ListLeading, ListSlot, LoadingIndicator, MENU_COMPONENT, MENU_CONFIG, MENU_DATA, MaterialIcon, Menu, MenuGroup, MenuItem, MenuRef, MenuService, NavigationBar, NavigationGroup, NavigationItem, NavigationRail, RadioButton, SIDE_SHEET_COMPONENT, SIDE_SHEET_CONFIG, SIDE_SHEET_DATA, SNACKBAR_ACTION_LABEL, SNACKBAR_CONFIG, SNACKBAR_MESSAGE, Scaffold, ScaffoldBar, ScaffoldPane, ScaffoldRail, SheetsService, SideSheetActions, SideSheetBody, SideSheetHeader, SideSheetRef, Slider, Snackbar, SnackbarRef, SnackbarService, SplitButton, StateComponent, SupportingText, Switch, TextField, TypeBody, TypeDisplay, TypeHeadline, TypeLabel, TypeTitle };
1298
- export type { AppBarScrollingStyle, AppBarType, ButtonGroupSelection, ButtonGroupType, ButtonSize, ButtonType, CardType, ChipStyle, ChipType, DialogConfig, DialogRole, FabSize, FabType, IconButtonType, IconButtonWidth, ListLeadingSize, ListLeadingType, Md3NavigationMode, MenuConfig, MenuPositionOrigin, MenuPositionX, MenuPositionY, MenuScrollStrategy, SideSheetConfig, SideSheetContainer, SideSheetSide, SideSheetType, SliderSize, SnackbarConfig, SnackbarDismiss, SnackbarDismissReason, SnackbarPoliteness, SplitButtonType, TextColor, TextSize };
1381
+ export type { AppBarScrollingStyle, AppBarType, ButtonGroupSelection, ButtonGroupType, ButtonSize, ButtonType, CardType, ChipStyle, ChipType, DialogConfig, DialogRole, FabSize, FabType, IconButtonType, IconButtonWidth, ListLeadingSize, ListLeadingType, Md3NavigationMode, MenuConfig, MenuPositionOrigin, MenuPositionX, MenuPositionY, MenuScrollStrategy, PreviousDialog, SideSheetConfig, SideSheetContainer, SideSheetSide, SideSheetType, SliderSize, SnackbarConfig, SnackbarDismiss, SnackbarDismissReason, SnackbarPoliteness, SplitButtonType, TextColor, TextSize };