@almoamendev/ngx-md3 0.4.0 → 0.5.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almoamendev/ngx-md3",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "MD3-style Angular components & style library",
5
5
  "author": "Murtadha (Hussain) Almoamen",
6
6
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ViewContainerRef, Injector, ElementRef, AfterViewInit, OnDestroy, OnInit, Renderer2, Signal, InputSignal, InjectionToken, Type, AfterContentInit, ComponentRef, TemplateRef } from '@angular/core';
2
+ import { ViewContainerRef, Injector, Signal, ElementRef, AfterViewInit, OnDestroy, OnInit, Renderer2, InputSignal, InjectionToken, Type, AfterContentInit, ComponentRef, TemplateRef } from '@angular/core';
3
3
  import { FlexibleConnectedPositionStrategyOrigin, ConnectedPosition, OverlayRef } from '@angular/cdk/overlay';
4
- import { Observable } from 'rxjs';
4
+ import { Observable, Subject } from 'rxjs';
5
5
  import * as i1 from '@angular/cdk/scrolling';
6
6
  import { AbstractControl } from '@angular/forms';
7
7
  import * as i1$1 from '@angular/router';
@@ -26,7 +26,7 @@ type SplitButtonType = 'elevated' | 'filled' | 'tonal' | 'outlined';
26
26
 
27
27
  type ButtonGroupType = 'standard' | 'connected';
28
28
 
29
- type ButtonGroupSelection = 'none' | 'single' | 'multiple';
29
+ type ButtonGroupSelection = 'none' | 'single' | 'multiple' | 'manual';
30
30
 
31
31
  type FabSize = 'small' | 'medium' | 'large';
32
32
 
@@ -226,33 +226,79 @@ interface SideSheetContainer {
226
226
  setHidden(value: boolean): void;
227
227
  }
228
228
 
229
+ /**
230
+ * How the sheet sits in the layout. A modal sheet floats above the page in an overlay with a
231
+ * scrim; a standard sheet docks into the scaffold, reserves its collapsed height and leaves the
232
+ * rest of the page usable.
233
+ */
234
+ type BottomSheetType = 'standard' | 'modal';
235
+ /** Which of a standard sheet's two heights it is resting at. */
236
+ type BottomSheetState = 'collapsed' | 'expanded';
229
237
  interface BottomSheetConfig<D = unknown> {
230
238
  data?: D;
231
239
  bindDataToInputs?: boolean;
240
+ /** @default 'modal' */
241
+ type?: BottomSheetType;
232
242
  /** Shows the MD3 drag handle centered above the sheet's content. */
233
243
  handle?: boolean;
234
- /** Lets the sheet be dragged down, and flung, to dismiss it. */
244
+ /**
245
+ * Lets the sheet be dragged, and flung. A modal sheet is dragged down to dismiss it; a
246
+ * standard sheet is dragged between its collapsed and expanded heights.
247
+ */
235
248
  gestures?: boolean;
249
+ /** Standard only. How much of the sheet shows when it is collapsed. */
250
+ collapsedHeight?: number | string;
251
+ /** Standard only. Height the sheet grows to when it is expanded. */
252
+ expandedHeight?: number | string;
253
+ /** Standard only. Which height the sheet opens at. */
254
+ initialState?: BottomSheetState;
255
+ /** Standard only. Whether dragging below the collapsed height closes the sheet. */
256
+ dismissible?: boolean;
257
+ /** Standard only. Accessible name for the region the sheet occupies. */
258
+ label?: string;
259
+ /** Standard only. Id of the element naming the sheet, when it already has a visible title. */
260
+ labelledBy?: string;
236
261
  scheme?: 'inherit' | 'dark' | 'light';
237
262
  direction?: null | 'ltr' | 'rtl';
238
263
  viewContainerRef?: ViewContainerRef;
239
264
  injector?: Injector;
240
265
  }
241
266
  /**
242
- * What BottomSheetRef needs from the shell hosting a bottom sheet, mirroring
243
- * DialogContainer: a bottom sheet is a CDK dialog container underneath, not a
244
- * side-sheet-style outlet.
267
+ * What BottomSheetRef needs from the surface hosting a sheet, whichever shell it was created
268
+ * in. The surface reports gestures rather than acting on them, because it is created before
269
+ * the reference exists and cannot reach it through DI.
245
270
  */
246
- interface BottomSheetContainer {
271
+ interface BottomSheetSurfaceHost {
247
272
  readonly surfaceElement: HTMLElement | null;
248
273
  /** Emits when a drag gesture asks for the sheet to be dismissed. */
249
274
  readonly dismissed: Observable<void>;
250
275
  /** Emits how far a drag has taken the sheet towards being dismissed, from 0 to 1. */
251
276
  readonly dragProgress: Observable<number>;
277
+ /** Emits the height a drag settled the sheet at. Standard sheets only. */
278
+ readonly stateChanges: Observable<BottomSheetState>;
252
279
  startEnterAnimation(): void;
253
280
  setActive(value: boolean): void;
281
+ }
282
+ /**
283
+ * The modal shell, which is a CDK dialog container underneath and so has focus handling the
284
+ * standard shell deliberately does without.
285
+ */
286
+ interface BottomSheetContainer extends BottomSheetSurfaceHost {
254
287
  recaptureFocus(): void;
255
288
  }
289
+ /**
290
+ * The docked shell, which owns the two heights a standard sheet moves between. Typed as an
291
+ * interface so BottomSheetRef can drive the shell without importing the component it lives in.
292
+ */
293
+ interface StandardBottomSheetHost extends BottomSheetSurfaceHost {
294
+ readonly state: Signal<BottomSheetState>;
295
+ expand(): void;
296
+ collapse(): void;
297
+ toggle(): void;
298
+ setCollapsedHeight(value: number | string): void;
299
+ setExpandedHeight(value: number | string): void;
300
+ setDismissible(value: boolean): void;
301
+ }
256
302
 
257
303
  type SnackbarPoliteness = 'polite' | 'assertive';
258
304
  interface SnackbarConfig<D = unknown> {
@@ -576,8 +622,10 @@ declare class LayoutService {
576
622
  declare class Scaffold implements AfterViewInit, OnDestroy {
577
623
  private startOutlet;
578
624
  private endOutlet;
625
+ private bottomOutlet;
579
626
  private panesContainer;
580
627
  private sheets;
628
+ private bottomSheets;
581
629
  private layout;
582
630
  ngAfterViewInit(): void;
583
631
  ngOnDestroy(): void;
@@ -702,7 +750,7 @@ declare class Button {
702
750
  effectiveSquared: _angular_core.Signal<boolean>;
703
751
  constructor(el: ElementRef);
704
752
  get element(): HTMLElement;
705
- enableSelection(): void;
753
+ enableSelection(): boolean;
706
754
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<Button, never>;
707
755
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<Button, "button[md3-button], a[md3-button]", never, { "buttonSize": { "alias": "button-size"; "required": false; "isSignal": true; }; "buttonType": { "alias": "button-type"; "required": false; "isSignal": true; }; "isSquared": { "alias": "button-squared"; "required": false; "isSignal": true; }; "isSelected": { "alias": "selected"; "required": false; "isSignal": true; }; }, { "isSelected": "selectedChange"; }, never, ["[md3-icon-element=leading]", "*", "[md3-icon-element=trailing]"], true, [{ directive: typeof StateComponent; inputs: {}; outputs: {}; }]>;
708
756
  }
@@ -736,7 +784,7 @@ declare class IconButton {
736
784
  effectiveSquared: _angular_core.Signal<boolean>;
737
785
  constructor(el: ElementRef);
738
786
  get element(): HTMLElement;
739
- enableSelection(): void;
787
+ enableSelection(): boolean;
740
788
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<IconButton, never>;
741
789
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<IconButton, "button[md3-icon-button], a[md3-icon-button]", never, { "buttonSize": { "alias": "button-size"; "required": false; "isSignal": true; }; "buttonType": { "alias": "button-type"; "required": false; "isSignal": true; }; "buttonWidth": { "alias": "button-width"; "required": false; "isSignal": true; }; "isSquared": { "alias": "button-squared"; "required": false; "isSignal": true; }; "isSelected": { "alias": "selected"; "required": false; "isSignal": true; }; }, { "isSelected": "selectedChange"; }, never, ["[md3-icon-element]", "*"], true, [{ directive: typeof StateComponent; inputs: {}; outputs: {}; }]>;
742
790
  }
@@ -775,6 +823,7 @@ declare class ButtonGroup implements ButtonContext {
775
823
  groupSelection: InputSignal<ButtonGroupSelection>;
776
824
  private buttons;
777
825
  private iconButtons;
826
+ private managedButtons;
778
827
  buttonContextSize: Signal<ButtonSize>;
779
828
  buttonContextSelection: Signal<ButtonGroupSelection>;
780
829
  constructor(el: ElementRef);
@@ -1874,58 +1923,128 @@ declare const BOTTOM_SHEET_DATA: InjectionToken<unknown>;
1874
1923
  declare const BOTTOM_SHEET_CONFIG: InjectionToken<BottomSheetConfig<unknown>>;
1875
1924
  declare const BOTTOM_SHEET_COMPONENT: InjectionToken<Type<unknown>>;
1876
1925
  /**
1877
- * A bottom sheet is a single modal overlay, not a stack like dialogs can be,
1878
- * so this is a smaller version of DialogRef: no hide/show, no full screen
1879
- * variant, closing is always the only way out.
1926
+ * What both kinds of bottom sheet have in common: closing once, animating out before the shell
1927
+ * goes away, and reporting the result. The two shells differ in what they are hosted by — a CDK
1928
+ * overlay or a scaffold outlet so each subclass owns its own exit and teardown.
1929
+ *
1930
+ * This class stays the DI token, so a component written for one kind of sheet can be opened as
1931
+ * the other without changing how it injects its reference.
1880
1932
  */
1881
- declare class BottomSheetRef<T = unknown, R = unknown> {
1882
- private readonly cdkRef;
1883
- private readonly closed;
1884
- private closeStarted;
1933
+ declare abstract class BottomSheetRef<T = unknown, R = unknown> {
1934
+ protected readonly closed: Subject<R | undefined>;
1935
+ protected closeStarted: boolean;
1885
1936
  private closeSettled;
1886
- /** Shell hosting the sheet. Filled by BottomSheetService once it is created. */
1887
- sheetInstance?: BottomSheetContainer;
1937
+ /** Surface hosting the sheet. Filled in by BottomSheetService once the shell is created. */
1938
+ sheetInstance?: BottomSheetSurfaceHost;
1888
1939
  /** Filled by BottomSheetService after the sheet component is attached. */
1889
1940
  componentInstance?: T;
1890
- /** Overlay hosting the sheet, useful to reach the panel and the scrim. */
1891
- get overlayRef(): OverlayRef;
1892
1941
  /** Whether the sheet started closing. */
1893
1942
  get isClosing(): boolean;
1894
- constructor(cdkRef: DialogRef$1<R, T>);
1943
+ /** Height the sheet is resting at. A modal sheet is only ever fully open. */
1944
+ get state(): Signal<BottomSheetState>;
1895
1945
  /** Closes the sheet. The promise resolves once the exit animation is done. */
1896
1946
  close(result?: R): Promise<void>;
1897
1947
  afterClosed(): Observable<R | undefined>;
1898
1948
  /**
1899
1949
  * Wires the shell to this reference. Called by BottomSheetService, since the shell is
1900
- * created by the CDK before this reference exists and cannot reach it through DI.
1950
+ * created before this reference exists and cannot reach it through DI.
1901
1951
  */
1902
- attachContainer(container: BottomSheetContainer): void;
1952
+ attachContainer(container: BottomSheetSurfaceHost): void;
1953
+ /** Moves a standard sheet to its expanded height. Modal sheets have only one height. */
1954
+ expand(): void;
1955
+ /** Moves a standard sheet back to its collapsed height. */
1956
+ collapse(): void;
1957
+ /** Switches a standard sheet between its two heights. */
1958
+ toggle(): void;
1959
+ setCollapsedHeight(height: number | string): void;
1960
+ setExpandedHeight(height: number | string): void;
1961
+ setDismissible(value: boolean): void;
1962
+ protected abstract startCloseAnimation(): Promise<void>;
1963
+ protected abstract finishClose(result?: R): void;
1964
+ /** Resolves when the surface finished animating, with a timeout as a safety net. */
1965
+ protected waitForSurfaceAnimation(fallback?: HTMLElement | null): Promise<void>;
1966
+ /** Emits the result once the sheet is gone. */
1967
+ protected settle(result?: R): void;
1968
+ }
1969
+ /**
1970
+ * A modal bottom sheet is a single overlay, not a stack like dialogs can be, so this is a
1971
+ * smaller version of DialogRef: no hide/show, no full screen variant, closing is always the
1972
+ * only way out.
1973
+ */
1974
+ declare class ModalBottomSheetRef<T = unknown, R = unknown> extends BottomSheetRef<T, R> {
1975
+ private readonly cdkRef;
1976
+ constructor(cdkRef: DialogRef$1<R, T>);
1977
+ /** Overlay hosting the sheet, useful to reach the panel and the scrim. */
1978
+ get overlayRef(): OverlayRef;
1979
+ attachContainer(container: BottomSheetSurfaceHost): void;
1980
+ protected startCloseAnimation(): Promise<void>;
1981
+ protected finishClose(result?: R): void;
1982
+ private connectCloseEvents;
1903
1983
  /** Fades the scrim along with the sheet being dragged, and hands it back to CSS on release. */
1904
1984
  private trackDragProgress;
1905
- private connectCloseEvents;
1906
- private startCloseAnimation;
1907
- /** Resolves when the surface finished animating, with a timeout as a safety net. */
1908
- private waitForSurfaceAnimation;
1909
- /** Emits the result once the CDK reference is closed. Focus is restored by the container. */
1910
- private settle;
1985
+ }
1986
+ /**
1987
+ * A standard bottom sheet lives in a scaffold outlet rather than an overlay, so there is no
1988
+ * scrim to fade and nothing to dispose but the component itself. In exchange it can be moved
1989
+ * between its two heights while it is open.
1990
+ */
1991
+ declare class StandardBottomSheetRef<T = unknown, R = unknown> extends BottomSheetRef<T, R> {
1992
+ private readonly onClosed;
1993
+ private sheetComponentRef?;
1994
+ private host?;
1995
+ constructor(onClosed: () => void);
1996
+ get state(): Signal<BottomSheetState>;
1997
+ /** Called by BottomSheetService once the shell has been created in the outlet. */
1998
+ attachSheet(componentRef: ComponentRef<unknown>, host: StandardBottomSheetHost): void;
1999
+ expand(): void;
2000
+ collapse(): void;
2001
+ toggle(): void;
2002
+ setCollapsedHeight(height: number | string): void;
2003
+ setExpandedHeight(height: number | string): void;
2004
+ setDismissible(value: boolean): void;
2005
+ /**
2006
+ * Tears the sheet down without an exit animation, for when the outlet holding it is going
2007
+ * away and there is nothing left to animate in.
2008
+ */
2009
+ dispose(result?: R): void;
2010
+ protected startCloseAnimation(): Promise<void>;
2011
+ protected finishClose(result?: R): void;
1911
2012
  }
1912
2013
 
1913
2014
  /**
1914
- * Opens bottom sheets as CDK dialogs anchored to the bottom of the viewport.
1915
- * A bottom sheet is always a modal overlay, the same way a regular dialog is
1916
- * always an overlay, so this mirrors DialogService rather than the side sheet
1917
- * outlet model: there is no docked variant and nothing to register from the
1918
- * scaffold.
2015
+ * Opens bottom sheets, in either of the two ways MD3 describes them.
2016
+ *
2017
+ * A modal sheet is a CDK dialog anchored to the bottom of the viewport, the same way a regular
2018
+ * dialog is always an overlay, so that path mirrors DialogService. A standard sheet is docked
2019
+ * into the scaffold instead, following the side sheet outlet model: it floats over the content
2020
+ * without a scrim, leaves the rest of the page usable, and needs an outlet to open into.
2021
+ *
2022
+ * One of each may be open at a time, and they replace only their own kind.
1919
2023
  */
1920
2024
  declare class BottomSheetService {
1921
2025
  private readonly cdkDialog;
1922
2026
  private readonly overlay;
1923
2027
  private readonly injector;
1924
- /** Only one bottom sheet is ever open at a time. */
1925
- private ref?;
2028
+ /**
2029
+ * Outlets registered from the page scaffold up to whatever took them over last. Standard
2030
+ * sheets always open in the outlet on top.
2031
+ */
2032
+ private readonly outlets;
2033
+ private modalRef?;
2034
+ private standardRef?;
2035
+ /** Registers the outlet standard bottom sheets open into. Called by Scaffold. */
2036
+ registerBottomSheetOutlet(outlet: CdkPortalOutlet): void;
2037
+ unregisterBottomSheetOutlet(outlet: CdkPortalOutlet): void;
1926
2038
  open<T, D = unknown, R = unknown>(component: Type<T>, config?: BottomSheetConfig<D>): BottomSheetRef<T, R>;
1927
- /** Closes the bottom sheet that is open, if there is one. */
2039
+ /**
2040
+ * Closes the bottom sheet that is open. A modal sheet goes first when both kinds are up,
2041
+ * since it is the one covering the page.
2042
+ */
1928
2043
  close<R = unknown>(result?: R): void;
2044
+ private openModal;
2045
+ private openStandard;
2046
+ private activeOutlet;
2047
+ private createInjector;
1929
2048
  private startOpenAnimation;
1930
2049
  private mergeConfig;
1931
2050
  private bindDataToInputs;
@@ -2029,5 +2148,5 @@ declare class SnackbarService {
2029
2148
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<SnackbarService>;
2030
2149
  }
2031
2150
 
2032
- export { AppBar, AppBarLogo, Avatar, BOTTOM_SHEET_COMPONENT, BOTTOM_SHEET_CONFIG, BOTTOM_SHEET_DATA, Badge, BottomSheetRef, BottomSheetService, Button, ButtonGroup, CAROUSEL_STRATEGIES, Card, Carousel, CarouselItem, 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, buildGeometry, clampIndex, indexForScrollOffset, multiBrowseStrategy, parseCarouselAspectRatio, resolveItemGeometry, resolveState, scrollOffsetForIndex, sizeBandFor };
2033
- export type { AppBarScrollingStyle, AppBarType, BottomSheetConfig, BottomSheetContainer, ButtonGroupSelection, ButtonGroupType, ButtonSize, ButtonType, CardType, CarouselAlignment, CarouselArrangement, CarouselGeometry, CarouselItemGeometry, CarouselItemSize, CarouselKeyline, CarouselKeylineState, CarouselLayout, CarouselOrientation, CarouselStrategy, CarouselStrategyContext, 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 };
2151
+ export { AppBar, AppBarLogo, Avatar, BOTTOM_SHEET_COMPONENT, BOTTOM_SHEET_CONFIG, BOTTOM_SHEET_DATA, Badge, BottomSheetRef, BottomSheetService, Button, ButtonGroup, CAROUSEL_STRATEGIES, Card, Carousel, CarouselItem, 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, ModalBottomSheetRef, 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, StandardBottomSheetRef, StateComponent, SupportingText, Switch, TextField, TypeBody, TypeDisplay, TypeHeadline, TypeLabel, TypeTitle, buildGeometry, clampIndex, indexForScrollOffset, multiBrowseStrategy, parseCarouselAspectRatio, resolveItemGeometry, resolveState, scrollOffsetForIndex, sizeBandFor };
2152
+ export type { AppBarScrollingStyle, AppBarType, BottomSheetConfig, BottomSheetContainer, BottomSheetState, BottomSheetSurfaceHost, BottomSheetType, ButtonGroupSelection, ButtonGroupType, ButtonSize, ButtonType, CardType, CarouselAlignment, CarouselArrangement, CarouselGeometry, CarouselItemGeometry, CarouselItemSize, CarouselKeyline, CarouselKeylineState, CarouselLayout, CarouselOrientation, CarouselStrategy, CarouselStrategyContext, 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, StandardBottomSheetHost, TextColor, TextSize };