@almoamendev/ngx-md3 0.1.0 → 0.2.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.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "MD3-style Angular components & style library",
5
5
  "author": "Murtadha (Hussain) Almoamen",
6
6
  "license": "MIT",
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ViewContainerRef, Injector, ElementRef, AfterViewInit, OnDestroy, OnInit, Renderer2, Signal, InputSignal, Type, ComponentRef, InjectionToken, AfterContentInit, TemplateRef } from '@angular/core';
2
+ import { ViewContainerRef, Injector, ElementRef, AfterViewInit, OnDestroy, OnInit, Renderer2, Signal, InputSignal, InjectionToken, Type, AfterContentInit, ComponentRef, 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';
@@ -36,13 +36,6 @@ type SliderSize = 'x-small' | 'small' | 'medium' | 'large' | 'x-large';
36
36
 
37
37
  type DialogRole = 'dialog' | 'alertdialog';
38
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
-
46
39
  type ChipType = 'assist' | 'filter' | 'input' | 'suggestion';
47
40
 
48
41
  type ChipStyle = 'default' | 'surface' | 'elevated';
@@ -51,6 +44,12 @@ type ListLeadingType = 'icon' | 'avatar' | 'media' | 'selection-input';
51
44
 
52
45
  type ListLeadingSize = 'image' | 'small-video' | 'large-video';
53
46
 
47
+ /**
48
+ * What happens to a dialog that is already open when a new dialog opens.
49
+ * - close: the open dialogs are closed before the new one opens.
50
+ * - hide: the dialog on top is hidden and shown again once the new one closes.
51
+ */
52
+ type PreviousDialog = 'close' | 'hide';
54
53
  interface DialogConfig<D = unknown> {
55
54
  /**
56
55
  * Optional data passed to the component opened inside the dialog.
@@ -81,6 +80,27 @@ interface DialogConfig<D = unknown> {
81
80
  viewContainerRef?: ViewContainerRef;
82
81
  injector?: Injector;
83
82
  }
83
+ /**
84
+ * What DialogRef needs from the shell hosting a dialog. Implemented by both the
85
+ * regular dialog and the full screen dialog, so the reference can drive either.
86
+ */
87
+ interface DialogContainer {
88
+ /** Element that plays the enter and exit transition. */
89
+ readonly surfaceElement: HTMLElement | null;
90
+ /** Starts the enter animation. Delayed when the dialog replaces another one. */
91
+ startEnterAnimation(): void;
92
+ /** Shows or hides the surface, which is what drives both transitions. */
93
+ setActive(value: boolean): void;
94
+ /** Moves focus back inside the dialog when it is not there already. */
95
+ recaptureFocus(): void;
96
+ }
97
+
98
+ /**
99
+ * Configuration of a full screen dialog. It is the dialog configuration without
100
+ * `previousDialog`: a full screen dialog always replaces the one that is open,
101
+ * because only one of them can be open at a time.
102
+ */
103
+ type FullScreenDialogConfig<D = unknown> = Omit<DialogConfig<D>, 'previousDialog'>;
84
104
 
85
105
  type MenuPositionX = 'start' | 'end' | 'before' | 'after' | 'center';
86
106
  type MenuPositionY = 'above' | 'below' | 'center';
@@ -952,20 +972,19 @@ declare class SupportingText {
952
972
  * trapping, focus restoration and the ARIA attributes are handled by the CDK
953
973
  * while this component only owns the MD3 surface and its animation.
954
974
  */
955
- declare class Dialog extends CdkDialogContainer {
975
+ declare class Dialog extends CdkDialogContainer implements DialogContainer {
976
+ private readonly surface;
956
977
  isActive: _angular_core.WritableSignal<boolean>;
957
978
  protected readonly config: DialogConfig<unknown>;
979
+ get surfaceElement(): HTMLElement | null;
958
980
  /**
959
981
  * 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.
982
+ * once the dialog it replaces has had its head start. The animation runs on
983
+ * the next frame so the surface has a real from/to state.
962
984
  */
963
985
  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.
967
- */
968
- attachContent<T>(component: Type<T>, injector: Injector): ComponentRef<T>;
986
+ setActive(value: boolean): void;
987
+ recaptureFocus(): void;
969
988
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<Dialog, never>;
970
989
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<Dialog, "md3-dialog", never, {}, {}, never, never, true, never>;
971
990
  }
@@ -975,13 +994,16 @@ declare const DIALOG_CONFIG: InjectionToken<DialogConfig<unknown>>;
975
994
  declare const DIALOG_COMPONENT: InjectionToken<Type<unknown>>;
976
995
  declare class DialogRef<T = unknown, R = unknown> {
977
996
  private readonly cdkRef;
997
+ /** Whether this reference belongs to a full screen dialog. */
998
+ readonly isFullScreen: boolean;
978
999
  private readonly closed;
979
1000
  private readonly closing;
980
1001
  private closePromise;
981
1002
  private closeStarted;
982
1003
  private closeSettled;
983
1004
  private hidden;
984
- dialogInstance?: Dialog;
1005
+ /** Shell hosting the dialog: the regular dialog or the full screen one. */
1006
+ dialogInstance?: DialogContainer;
985
1007
  /**
986
1008
  * Filled by DialogService after the user component is attached. Keeping the
987
1009
  * instance here lets callers imperatively update inputs when that is useful.
@@ -993,7 +1015,9 @@ declare class DialogRef<T = unknown, R = unknown> {
993
1015
  get isClosing(): boolean;
994
1016
  /** Whether the dialog is currently hidden behind another dialog. */
995
1017
  get isHidden(): boolean;
996
- constructor(cdkRef: DialogRef$1<R, T>, disableCloseEvents: boolean);
1018
+ constructor(cdkRef: DialogRef$1<R, T>, disableCloseEvents: boolean,
1019
+ /** Whether this reference belongs to a full screen dialog. */
1020
+ isFullScreen?: boolean);
997
1021
  /** Closes the dialog. The promise resolves once the exit animation is done. */
998
1022
  close(result?: R): Promise<void>;
999
1023
  /**
@@ -1036,9 +1060,21 @@ declare class DialogService {
1036
1060
  /** Element that was focused before the first dialog of the stack opened. */
1037
1061
  private rootTrigger;
1038
1062
  get openDialogs(): readonly DialogRef<any, any>[];
1063
+ /** The full screen dialog that is open, if there is one. */
1064
+ get fullScreenDialog(): DialogRef<any, any> | undefined;
1039
1065
  open<T, D = unknown, R = unknown>(component: Type<T>, config?: DialogConfig<D>): DialogRef<T, R>;
1040
- /** Closes every open dialog, including the hidden ones. */
1066
+ /**
1067
+ * Opens a dialog that covers the whole screen. Only one can be open at a
1068
+ * time, so it replaces whatever is open, and while it is up the side sheet
1069
+ * outlets belong to it: side sheets open inside the dialog, not behind it.
1070
+ */
1071
+ openFullScreen<T, D = unknown, R = unknown>(component: Type<T>, config?: FullScreenDialogConfig<D>): DialogRef<T, R>;
1072
+ /** Wires a freshly created dialog into the stack and starts its animation. */
1073
+ private registerDialog;
1074
+ /** Closes every open dialog, including the hidden and the full screen ones. */
1041
1075
  closeAll(): Promise<void>;
1076
+ /** Closes the regular dialogs and leaves a full screen dialog alone. */
1077
+ private closeRegularDialogs;
1042
1078
  private mergeConfig;
1043
1079
  /**
1044
1080
  * Hides or closes the dialog that is on screen. Its scrim stays up until
@@ -1062,6 +1098,11 @@ declare class DialogService {
1062
1098
  private canBindDataToInputs;
1063
1099
  /** Last dialog of the stack that is not closing yet. */
1064
1100
  private topRef;
1101
+ /**
1102
+ * Same, without the full screen dialog: it hosts the dialogs opened on top
1103
+ * of it, so it is never the one that gets hidden or closed to make room.
1104
+ */
1105
+ private topRegularRef;
1065
1106
  private restorePreviousDialog;
1066
1107
  private removeRef;
1067
1108
  private updateScrollBlock;
@@ -1085,6 +1126,42 @@ declare class DialogActions {
1085
1126
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<DialogActions, "md3-dialog-actions", never, {}, {}, never, ["*"], true, never>;
1086
1127
  }
1087
1128
 
1129
+ /**
1130
+ * Material 3 full screen dialog shell. It covers the viewport and lays its
1131
+ * content out like the scaffold does, with a main pane and a side sheet outlet
1132
+ * on each side, so side sheets opened while it is up land inside the dialog
1133
+ * instead of behind it.
1134
+ */
1135
+ declare class FullScreenDialog extends CdkDialogContainer implements DialogContainer, AfterViewInit {
1136
+ private readonly surface;
1137
+ private readonly startOutlet;
1138
+ private readonly endOutlet;
1139
+ private readonly sheets;
1140
+ isActive: _angular_core.WritableSignal<boolean>;
1141
+ protected readonly config: DialogConfig<unknown>;
1142
+ get surfaceElement(): HTMLElement | null;
1143
+ ngAfterViewInit(): void;
1144
+ ngOnDestroy(): void;
1145
+ startEnterAnimation(): void;
1146
+ setActive(value: boolean): void;
1147
+ recaptureFocus(): void;
1148
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FullScreenDialog, never>;
1149
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FullScreenDialog, "md3-fullscreen-dialog", never, {}, {}, never, never, true, never>;
1150
+ }
1151
+
1152
+ /**
1153
+ * Header of a full screen dialog: a leading icon button to leave the dialog,
1154
+ * the headline, and a trailing action. It sticks to the top of the dialog while
1155
+ * the content scrolls underneath.
1156
+ */
1157
+ declare class FullScreenDialogHeader implements ButtonContext {
1158
+ title: _angular_core.InputSignal<string>;
1159
+ buttonContextSize: Signal<ButtonSize>;
1160
+ buttonContextWidth: Signal<IconButtonWidth>;
1161
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<FullScreenDialogHeader, never>;
1162
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<FullScreenDialogHeader, "md3-fullscreen-dialog-header", never, { "title": { "alias": "title"; "required": false; "isSignal": true; }; }, {}, never, ["[md3-icon-button][md3-header-leading]", "[md3-header-trailing]"], true, never>;
1163
+ }
1164
+
1088
1165
  declare class Menu implements AfterContentInit {
1089
1166
  private el;
1090
1167
  private readonly portalOutlet;
@@ -1246,11 +1323,19 @@ declare class SideSheetRef<T = unknown, R = unknown> {
1246
1323
 
1247
1324
  declare class SheetsService {
1248
1325
  private readonly injector;
1326
+ /**
1327
+ * Outlets registered per side, from the page scaffold up to whatever took
1328
+ * them over last. Sheets always open in the outlet on top, so a full screen
1329
+ * dialog can host them while it is up and hand them back when it closes.
1330
+ */
1249
1331
  private readonly states;
1250
1332
  registerSideSheetOutlet(side: SideSheetSide, outlet: CdkPortalOutlet): void;
1251
1333
  unregisterSideSheetOutlet(side: SideSheetSide, outlet: CdkPortalOutlet): void;
1252
1334
  openSideSheet<T = unknown, D = unknown, R = unknown>(component: Type<T>, config?: SideSheetConfig<D>): SideSheetRef<T, R>;
1253
1335
  closeSideSheet<R = unknown>(side?: SideSheetSide, result?: R): void;
1336
+ /** Outlet that sheets currently open in: the last one that registered. */
1337
+ private activeState;
1338
+ private getOutletStack;
1254
1339
  private mergeConfig;
1255
1340
  private createInjector;
1256
1341
  private bindDataToInputs;
@@ -1377,5 +1462,5 @@ declare class SnackbarService {
1377
1462
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<SnackbarService>;
1378
1463
  }
1379
1464
 
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 };
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 };
1465
+ 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, FullScreenDialog, FullScreenDialogHeader, 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 };
1466
+ export type { AppBarScrollingStyle, AppBarType, ButtonGroupSelection, ButtonGroupType, ButtonSize, ButtonType, CardType, ChipStyle, ChipType, DialogConfig, DialogContainer, DialogRole, FabSize, FabType, FullScreenDialogConfig, IconButtonType, IconButtonWidth, ListLeadingSize, ListLeadingType, Md3NavigationMode, MenuConfig, MenuPositionOrigin, MenuPositionX, MenuPositionY, MenuScrollStrategy, PreviousDialog, SideSheetConfig, SideSheetContainer, SideSheetSide, SideSheetType, SliderSize, SnackbarConfig, SnackbarDismiss, SnackbarDismissReason, SnackbarPoliteness, SplitButtonType, TextColor, TextSize };