mtrl 0.8.0-next.21 → 0.8.0-next.24

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 (43) hide show
  1. package/dist/components/bottom-sheet/api.d.ts +43 -0
  2. package/dist/components/bottom-sheet/bottom-sheet.d.ts +24 -0
  3. package/dist/components/bottom-sheet/config.d.ts +34 -0
  4. package/dist/components/bottom-sheet/constants.d.ts +65 -0
  5. package/dist/components/bottom-sheet/features/drag.d.ts +32 -0
  6. package/dist/components/bottom-sheet/features/index.d.ts +3 -0
  7. package/dist/components/bottom-sheet/features/state.d.ts +31 -0
  8. package/dist/components/bottom-sheet/features/structure.d.ts +26 -0
  9. package/dist/components/bottom-sheet/index.d.ts +2 -0
  10. package/dist/components/bottom-sheet/types.d.ts +116 -0
  11. package/dist/components/dialog/types.d.ts +1 -1
  12. package/dist/components/drawer/types.d.ts +1 -1
  13. package/dist/components/index.d.ts +6 -0
  14. package/dist/components/menu/features/registry.d.ts +37 -0
  15. package/dist/components/menu/index.d.ts +1 -1
  16. package/dist/components/menu/types.d.ts +31 -9
  17. package/dist/components/progress/types.d.ts +2 -2
  18. package/dist/components/sheet/sheet.d.ts +12 -0
  19. package/dist/components/sheet/types.d.ts +8 -0
  20. package/dist/components/side-sheet/api.d.ts +33 -0
  21. package/dist/components/side-sheet/config.d.ts +34 -0
  22. package/dist/components/side-sheet/constants.d.ts +60 -0
  23. package/dist/components/side-sheet/features/index.d.ts +2 -0
  24. package/dist/components/side-sheet/features/state.d.ts +28 -0
  25. package/dist/components/side-sheet/features/structure.d.ts +21 -0
  26. package/dist/components/side-sheet/index.d.ts +2 -0
  27. package/dist/components/side-sheet/side-sheet.d.ts +24 -0
  28. package/dist/components/side-sheet/types.d.ts +102 -0
  29. package/dist/index.cjs +13 -13
  30. package/dist/index.cjs.map +26 -12
  31. package/dist/index.js +13 -13
  32. package/dist/index.js.map +26 -12
  33. package/dist/package.json +1 -1
  34. package/dist/styles.css +2 -2
  35. package/package.json +1 -2
  36. package/src/styles/abstract/_variables.scss +13 -1
  37. package/src/styles/components/_bottom-sheet.scss +167 -0
  38. package/src/styles/components/_button.scss +9 -3
  39. package/src/styles/components/_card.scss +78 -19
  40. package/src/styles/components/_menu.scss +89 -3
  41. package/src/styles/components/_segmented-button.scss +28 -70
  42. package/src/styles/components/_side-sheet.scss +175 -0
  43. package/src/styles/main.scss +2 -0
@@ -0,0 +1,43 @@
1
+ import { BottomSheetComponent, BottomSheetEventHandlers, BottomSheetState } from "./types";
2
+ interface ApiOptions {
3
+ state: {
4
+ open: () => void;
5
+ close: () => void;
6
+ expand: () => void;
7
+ collapse: () => void;
8
+ isOpen: () => boolean;
9
+ getState: () => BottomSheetState;
10
+ release: () => void;
11
+ };
12
+ structure: {
13
+ setContent: (content: string | HTMLElement) => void;
14
+ setTitle: (title: string) => void;
15
+ };
16
+ drag: {
17
+ release: () => void;
18
+ };
19
+ lifecycle: {
20
+ destroy: () => void;
21
+ };
22
+ }
23
+ interface BaseComponent {
24
+ element: HTMLElement;
25
+ getClass: (name: string) => string;
26
+ on: (event: string, handler: (...args: never[]) => void) => unknown;
27
+ off: (event: string, handler: (...args: never[]) => void) => unknown;
28
+ }
29
+ /**
30
+ * The public surface. Every method here is backed by a feature above it; none
31
+ * is declared and left unwired.
32
+ */
33
+ export declare const withAPI: ({ state, structure, drag, lifecycle }: ApiOptions) => <C extends BaseComponent>(component: C) => BottomSheetComponent;
34
+ /**
35
+ * Registers the handlers given at creation.
36
+ *
37
+ * Several components in this library declare an `on` option and never read it,
38
+ * so handlers passed at creation are silently dropped. This one reads it.
39
+ */
40
+ export declare const applyEventHandlers: (component: {
41
+ on: (event: string, handler: (...args: never[]) => void) => unknown;
42
+ }, handlers?: BottomSheetEventHandlers) => void;
43
+ export {};
@@ -0,0 +1,24 @@
1
+ import { BottomSheetConfig, BottomSheetComponent } from "./types";
2
+ /**
3
+ * Creates a bottom sheet: a surface anchored to the bottom edge holding
4
+ * content secondary to the page.
5
+ *
6
+ * A modal sheet covers the page with a scrim and takes focus, for a task that
7
+ * must finish first. A standard sheet leaves the page usable alongside it.
8
+ *
9
+ * @param {BottomSheetConfig} config - Bottom sheet configuration
10
+ * @returns {BottomSheetComponent} Bottom sheet instance
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const sheet = createBottomSheet({
15
+ * title: 'Share',
16
+ * content: '<p>Choose where to send it.</p>',
17
+ * on: { close: () => console.info('closed') }
18
+ * });
19
+ *
20
+ * sheet.open();
21
+ * ```
22
+ */
23
+ declare const createBottomSheet: (config?: BottomSheetConfig) => BottomSheetComponent;
24
+ export default createBottomSheet;
@@ -0,0 +1,34 @@
1
+ import { BottomSheetConfig } from "./types";
2
+ /**
3
+ * What the component applies when the caller says nothing.
4
+ */
5
+ export declare const defaultConfig: Partial<BottomSheetConfig>;
6
+ /**
7
+ * Merges the caller's configuration over the defaults.
8
+ */
9
+ export declare const createBaseConfig: (config?: BottomSheetConfig) => BottomSheetConfig;
10
+ /**
11
+ * The root element: a fixed layer holding the scrim and the sheet itself.
12
+ */
13
+ export declare const getElementConfig: (config: BottomSheetConfig) => {
14
+ tag: string;
15
+ componentName: string;
16
+ attributes: Record<string, any>;
17
+ className: string[];
18
+ rawClass: string | string[];
19
+ id: string;
20
+ name: string;
21
+ title: string;
22
+ tabIndex: number;
23
+ style: string | Partial<CSSStyleDeclaration>;
24
+ data: Record<string, string>;
25
+ role: string;
26
+ ariaLabel: string;
27
+ ariaDescribedBy: string;
28
+ ariaLabelledBy: string;
29
+ ariaHidden: boolean;
30
+ html: string;
31
+ text: string;
32
+ forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
33
+ interactive: boolean;
34
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Bottom sheet variants.
3
+ *
4
+ * A standard sheet sits alongside the page and leaves it usable. A modal sheet
5
+ * puts a scrim over the page and takes focus, so it is the one to reach for
6
+ * when the sheet's task must finish before anything else continues.
7
+ */
8
+ export declare const BOTTOM_SHEET_VARIANTS: {
9
+ readonly STANDARD: "standard";
10
+ readonly MODAL: "modal";
11
+ };
12
+ /**
13
+ * How far the sheet is open.
14
+ *
15
+ * `partial` shows the peek height, enough to say what the sheet holds without
16
+ * covering the page. `expanded` shows as much as the content needs.
17
+ */
18
+ export declare const BOTTOM_SHEET_STATES: {
19
+ readonly HIDDEN: "hidden";
20
+ readonly PARTIAL: "partial";
21
+ readonly EXPANDED: "expanded";
22
+ };
23
+ /**
24
+ * Defaults, from Compose BottomSheetDefaults and SheetBottomTokens.
25
+ */
26
+ export declare const BOTTOM_SHEET_DEFAULTS: {
27
+ readonly VARIANT: "modal";
28
+ /** BottomSheetDefaults.SheetPeekHeight */
29
+ readonly PEEK_HEIGHT: 56;
30
+ /** BottomSheetDefaults.SheetMaxWidth; wider viewports centre the sheet */
31
+ readonly MAX_WIDTH: 640;
32
+ /** A drag handle is part of the anatomy, so it is on unless asked otherwise */
33
+ readonly DRAG_HANDLE: true;
34
+ readonly CLOSE_ON_SCRIM_CLICK: true;
35
+ readonly CLOSE_ON_ESCAPE: true;
36
+ /**
37
+ * BottomSheetDefaults.PositionalThreshold: how far the sheet must be dragged
38
+ * before it settles at the next anchor rather than springing back.
39
+ */
40
+ readonly POSITIONAL_THRESHOLD: 56;
41
+ /** BottomSheetDefaults.VelocityThreshold, in dp per second */
42
+ readonly VELOCITY_THRESHOLD: 125;
43
+ };
44
+ /**
45
+ * Class names, without the prefix. `getClass` adds it.
46
+ */
47
+ export declare const BOTTOM_SHEET_CLASSES: {
48
+ readonly ROOT: "bottom-sheet";
49
+ readonly SCRIM: "bottom-sheet-scrim";
50
+ readonly CONTAINER: "bottom-sheet-container";
51
+ readonly HANDLE: "bottom-sheet-handle";
52
+ readonly HEADER: "bottom-sheet-header";
53
+ readonly TITLE: "bottom-sheet-title";
54
+ readonly CONTENT: "bottom-sheet-content";
55
+ };
56
+ /**
57
+ * Events the sheet emits.
58
+ */
59
+ export declare const BOTTOM_SHEET_EVENTS: {
60
+ readonly OPEN: "open";
61
+ readonly CLOSE: "close";
62
+ readonly STATE_CHANGE: "stateChange";
63
+ readonly DRAG_START: "dragStart";
64
+ readonly DRAG_END: "dragEnd";
65
+ };
@@ -0,0 +1,32 @@
1
+ import { BottomSheetConfig, BottomSheetState } from "../types";
2
+ interface DragComponent {
3
+ getClass: (name: string) => string;
4
+ emit: (event: string, data?: unknown) => unknown;
5
+ structure: {
6
+ container: HTMLElement;
7
+ handle: HTMLElement | null;
8
+ };
9
+ state: {
10
+ getState: () => BottomSheetState;
11
+ setState: (next: BottomSheetState) => void;
12
+ close: () => void;
13
+ };
14
+ }
15
+ /**
16
+ * Dragging the sheet between its heights.
17
+ *
18
+ * Where the sheet settles follows Compose's rule: a drag past the positional
19
+ * threshold moves to the next anchor, and a flick past the velocity threshold
20
+ * does the same however short it was, so a quick flick works without having to
21
+ * cover the distance.
22
+ */
23
+ export declare const withDrag: (config: BottomSheetConfig) => <C extends DragComponent>(component: C) => (C & {
24
+ drag: {
25
+ release: () => void;
26
+ };
27
+ }) | (C & {
28
+ drag: {
29
+ release: () => void;
30
+ };
31
+ });
32
+ export {};
@@ -0,0 +1,3 @@
1
+ export { withStructure } from "./structure";
2
+ export { withState } from "./state";
3
+ export { withDrag } from "./drag";
@@ -0,0 +1,31 @@
1
+ import { BottomSheetConfig, BottomSheetState } from "../types";
2
+ interface StateComponent {
3
+ element: HTMLElement;
4
+ getClass: (name: string) => string;
5
+ emit: (event: string, data?: unknown) => unknown;
6
+ structure: {
7
+ scrim: HTMLElement | null;
8
+ container: HTMLElement;
9
+ };
10
+ }
11
+ /**
12
+ * Opening, closing and the two open heights.
13
+ *
14
+ * Events go through `component.emit`, which is what the composed events
15
+ * enhancer provides. Reaching for `component.events.emit` throws, because that
16
+ * shape comes from a different enhancer the barrel exports under another name.
17
+ */
18
+ export declare const withState: (config: BottomSheetConfig) => <C extends StateComponent>(component: C) => C & {
19
+ state: {
20
+ open: (to?: BottomSheetState) => void;
21
+ close: () => void;
22
+ expand: () => void;
23
+ collapse: () => void;
24
+ isOpen: () => boolean;
25
+ getState: () => BottomSheetState;
26
+ setState: (next: BottomSheetState) => void;
27
+ /** Releases the listeners this feature put on the document */
28
+ release: () => void;
29
+ };
30
+ };
31
+ export {};
@@ -0,0 +1,26 @@
1
+ import { BottomSheetConfig } from "../types";
2
+ /**
3
+ * Builds the parts of the sheet and puts the whole thing on the page.
4
+ *
5
+ * The root element is a fixed layer that holds the scrim and the sheet
6
+ * container, so both are children of something that exists. An earlier sheet
7
+ * in this library inserted its scrim through `element.parentNode` at
8
+ * construction, when the element had no parent yet, and so never had a scrim
9
+ * at all.
10
+ */
11
+ export declare const withStructure: (config: BottomSheetConfig) => <C extends {
12
+ element: HTMLElement;
13
+ getClass: (n: string) => string;
14
+ }>(component: C) => C & {
15
+ structure: {
16
+ scrim: HTMLElement;
17
+ container: HTMLDivElement;
18
+ handle: HTMLElement;
19
+ title: HTMLElement;
20
+ content: HTMLDivElement;
21
+ /** Replaces the body */
22
+ setContent(next: string | HTMLElement): void;
23
+ /** Replaces the headline, adding one if the sheet had none */
24
+ setTitle(next: string): void;
25
+ };
26
+ };
@@ -0,0 +1,2 @@
1
+ export { default as createBottomSheet, default } from "./bottom-sheet";
2
+ export type { BottomSheetConfig, BottomSheetComponent, BottomSheetVariant, BottomSheetState, BottomSheetStateEvent, BottomSheetEventHandlers, } from "./types";
@@ -0,0 +1,116 @@
1
+ import { BOTTOM_SHEET_VARIANTS, BOTTOM_SHEET_STATES } from "./constants";
2
+ /** Standard or modal */
3
+ export type BottomSheetVariant = (typeof BOTTOM_SHEET_VARIANTS)[keyof typeof BOTTOM_SHEET_VARIANTS];
4
+ /** How far the sheet is open */
5
+ export type BottomSheetState = (typeof BOTTOM_SHEET_STATES)[keyof typeof BOTTOM_SHEET_STATES];
6
+ /** What a state change reports */
7
+ export interface BottomSheetStateEvent {
8
+ /** The state the sheet has moved to */
9
+ state: BottomSheetState;
10
+ /** The state it came from */
11
+ previous: BottomSheetState;
12
+ }
13
+ /** Handlers accepted at creation, one per event name */
14
+ export interface BottomSheetEventHandlers {
15
+ open?: () => void;
16
+ close?: () => void;
17
+ stateChange?: (event: BottomSheetStateEvent) => void;
18
+ dragStart?: () => void;
19
+ dragEnd?: (event: BottomSheetStateEvent) => void;
20
+ }
21
+ /**
22
+ * Configuration for the bottom sheet.
23
+ *
24
+ * @category Components
25
+ */
26
+ export interface BottomSheetConfig {
27
+ /**
28
+ * Standard sheets leave the page usable; modal sheets cover it with a scrim
29
+ * and take focus.
30
+ * @default 'modal'
31
+ */
32
+ variant?: BottomSheetVariant;
33
+ /**
34
+ * Headline shown above the content. Also names the sheet for assistive
35
+ * technology, through `aria-labelledby`.
36
+ */
37
+ title?: string;
38
+ /** Body of the sheet, as markup or an element */
39
+ content?: string | HTMLElement;
40
+ /**
41
+ * The 32x4dp bar at the top edge, which says the sheet can be dragged.
42
+ * Turning it off also turns off dragging, since nothing would indicate it.
43
+ * @default true
44
+ */
45
+ dragHandle?: boolean;
46
+ /**
47
+ * Height of the partially expanded state, in pixels.
48
+ * @default 56
49
+ */
50
+ peekHeight?: number;
51
+ /**
52
+ * The sheet stops growing at this width and centres itself, so it does not
53
+ * stretch across a desktop window.
54
+ * @default 640
55
+ */
56
+ maxWidth?: number;
57
+ /**
58
+ * State to start in. `hidden` builds the sheet without showing it.
59
+ * @default 'hidden'
60
+ */
61
+ initialState?: BottomSheetState;
62
+ /**
63
+ * Whether a click on the scrim closes a modal sheet. Standard sheets have no
64
+ * scrim, so this does nothing for them.
65
+ * @default true
66
+ */
67
+ closeOnScrimClick?: boolean;
68
+ /**
69
+ * Whether Escape closes a modal sheet.
70
+ * @default true
71
+ */
72
+ closeOnEscape?: boolean;
73
+ /** Where to mount the sheet. Defaults to `document.body` */
74
+ container?: HTMLElement;
75
+ /** Handlers registered at creation, equivalent to calling `on` for each */
76
+ on?: BottomSheetEventHandlers;
77
+ /** Extra classes for the root element */
78
+ class?: string;
79
+ /** @internal */
80
+ prefix?: string;
81
+ /** @internal */
82
+ componentName?: string;
83
+ }
84
+ /**
85
+ * A bottom sheet instance.
86
+ *
87
+ * @category Components
88
+ */
89
+ export interface BottomSheetComponent {
90
+ /** The root element, which holds the scrim and the container */
91
+ element: HTMLElement;
92
+ /** Opens the sheet, partially expanded */
93
+ open: () => BottomSheetComponent;
94
+ /** Closes the sheet */
95
+ close: () => BottomSheetComponent;
96
+ /** Opens the sheet to its full height */
97
+ expand: () => BottomSheetComponent;
98
+ /** Returns the sheet to the peek height */
99
+ collapse: () => BottomSheetComponent;
100
+ /** Whether the sheet is showing at all */
101
+ isOpen: () => boolean;
102
+ /** How far the sheet is open */
103
+ getState: () => BottomSheetState;
104
+ /** Replaces the body of the sheet */
105
+ setContent: (content: string | HTMLElement) => BottomSheetComponent;
106
+ /** Replaces the headline */
107
+ setTitle: (title: string) => BottomSheetComponent;
108
+ /** Adds an event listener */
109
+ on: <T extends keyof BottomSheetEventHandlers>(event: T, handler: NonNullable<BottomSheetEventHandlers[T]>) => BottomSheetComponent;
110
+ /** Removes an event listener */
111
+ off: <T extends keyof BottomSheetEventHandlers>(event: T, handler: NonNullable<BottomSheetEventHandlers[T]>) => BottomSheetComponent;
112
+ /** Removes the sheet from the page and releases its listeners */
113
+ destroy: () => void;
114
+ /** Prefixes a class name, for styling hooks */
115
+ getClass: (name: string) => string;
116
+ }
@@ -165,7 +165,7 @@ export interface DialogConfig {
165
165
  zIndex?: number;
166
166
  /**
167
167
  * Duration of open/close animations in milliseconds
168
- * @default 300
168
+ * @default 150
169
169
  */
170
170
  animationDuration?: number;
171
171
  /**
@@ -92,7 +92,7 @@ export interface DrawerConfig extends BaseComponentConfig {
92
92
  items?: DrawerItemConfig[];
93
93
  /**
94
94
  * Drawer width as a CSS value
95
- * @default '360px'
95
+ * @default 360
96
96
  */
97
97
  width?: string | number;
98
98
  /**
@@ -9,6 +9,8 @@
9
9
  */
10
10
  export { default as createBadge } from "./badge";
11
11
  export { default as createBottomAppBar } from "./bottom-app-bar";
12
+ export { default as createBottomSheet } from "./bottom-sheet";
13
+ export { default as createSideSheet } from "./side-sheet";
12
14
  export { default as createButton } from "./button";
13
15
  export { default as createButtonGroup } from "./button-group";
14
16
  export { default as createCard } from "./card";
@@ -34,6 +36,7 @@ export { default as createSearch } from "./search";
34
36
  export { default as createSelect } from "./select";
35
37
  export { default as createSegmentedButton } from "./segmented-button";
36
38
  export { createSegment } from "./segmented-button/segment";
39
+ /** @deprecated Since 0.8.0. Use createBottomSheet or createSideSheet. */
37
40
  export { default as createSheet } from "./sheet";
38
41
  export { default as createSlider } from "./slider";
39
42
  export { default as createSnackbar } from "./snackbar";
@@ -48,6 +51,8 @@ export { default as createTooltip } from "./tooltip";
48
51
  export { createCardContent, createCardHeader, createCardActions, createCardMedia, } from "./card/content";
49
52
  export type { BadgeConfig, BadgeComponent } from "./badge/types";
50
53
  export type { BottomAppBarConfig, BottomAppBar } from "./bottom-app-bar/types";
54
+ export type { BottomSheetConfig, BottomSheetComponent, BottomSheetVariant, BottomSheetState, BottomSheetStateEvent, BottomSheetEventHandlers, } from "./bottom-sheet/types";
55
+ export type { SideSheetConfig, SideSheetComponent, SideSheetVariant, SideSheetPosition, SideSheetEventHandlers, } from "./side-sheet/types";
51
56
  export type { ButtonConfig, ButtonComponent, ButtonVariant, } from "./button/types";
52
57
  export type { ButtonGroupConfig, ButtonGroupComponent, ButtonGroupItemConfig, ButtonGroupEvent, ButtonGroupEventType, ButtonGroupVariant, ButtonGroupOrientation, ButtonGroupDensity, } from "./button-group/types";
53
58
  export type { CardSchema } from "./card/types";
@@ -71,6 +76,7 @@ export type { RadiosConfig, RadiosComponent, RadioOptionConfig, } from "./radios
71
76
  export type { SearchConfig, SearchComponent } from "./search/types";
72
77
  export type { SelectConfig, SelectComponent, SelectOption, SelectEvent, SelectChangeEvent, } from "./select/types";
73
78
  export type { SegmentedButtonConfig, SegmentedButtonComponent, } from "./segmented-button/types";
79
+ /** @deprecated Since 0.8.0. Use the BottomSheet or SideSheet types. */
74
80
  export type { SheetConfig, SheetComponent } from "./sheet/types";
75
81
  export type { SliderConfig, SliderComponent, SliderEvent, } from "./slider/types";
76
82
  export type { SnackbarConfig, SnackbarComponent } from "./snackbar/types";
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Keeps track of which menu is open, so that opening one closes the last.
3
+ *
4
+ * A menu button's menu is dismissed once the interaction moves outside it, so
5
+ * two menus should never be open together: the screen reader would be told
6
+ * there are two, since both openers carry aria-expanded="true".
7
+ *
8
+ * Menus used to rely on the document click listener each open menu installs to
9
+ * notice a click elsewhere and close. That never fired for another menu's
10
+ * opener, because the opener stops the click from propagating, so menus piled
11
+ * up. Announcing the open here does not depend on how the menu was opened,
12
+ * which the click path could never cover: a menu opened by keyboard or by code
13
+ * closes the previous one just the same.
14
+ *
15
+ * Only root menus take part. Submenus belong to their parent, which closes them.
16
+ */
17
+ /** What the registry needs of a menu: a way to close it */
18
+ export interface RegisteredMenu {
19
+ close: (event?: Event) => void;
20
+ }
21
+ /**
22
+ * Announces that a menu has opened, closing whichever was open before.
23
+ *
24
+ * @param menu - The menu that is opening
25
+ * @param event - The event that opened it, passed to the menu being closed
26
+ */
27
+ export declare const menuOpened: (menu: RegisteredMenu, event?: Event) => void;
28
+ /**
29
+ * Announces that a menu has closed. Closing a menu that is not the open one is
30
+ * a no-op, which is what makes the call safe from any close path, including
31
+ * destroy.
32
+ *
33
+ * @param menu - The menu that is closing
34
+ */
35
+ export declare const menuClosed: (menu: RegisteredMenu) => void;
36
+ /** The menu that is currently open, if any. Exported for tests */
37
+ export declare const currentlyOpenMenu: () => RegisteredMenu | null;
@@ -8,7 +8,7 @@
8
8
  * @category Components
9
9
  */
10
10
  export { default } from './menu';
11
- export type { MenuConfig, MenuComponent, MenuItem, MenuDivider, MenuContent, MenuEvent, MenuSelectEvent, MenuPosition } from './types';
11
+ export type { MenuConfig, MenuComponent, MenuItem, MenuDivider, MenuGap, MenuContent, MenuEvent, MenuSelectEvent, MenuPosition } from './types';
12
12
  /**
13
13
  * Constants for menu position values - use these instead of string literals
14
14
  * for better code completion and type safety.
@@ -103,11 +103,33 @@ export interface MenuDivider {
103
103
  id?: string;
104
104
  }
105
105
  /**
106
- * Combined type for menu content items (regular items or dividers)
106
+ * Menu item type for a gap between groups.
107
+ *
108
+ * The M3 expressive vertical menu separates groups two ways: a divider line,
109
+ * or a gap. A gap splits the menu into separate surfaces, each with its own
110
+ * rounded container, rather than drawing a line across one surface
111
+ * (m3.material.io/components/menus, vertical menus).
112
+ *
113
+ * A standard menu is a single surface, so a gap there is simply space.
114
+ *
115
+ * @category Components
116
+ */
117
+ export interface MenuGap {
118
+ /**
119
+ * Type must be 'gap' to differentiate from regular menu items
120
+ */
121
+ type: "gap";
122
+ /**
123
+ * Optional ID for the gap (for accessibility)
124
+ */
125
+ id?: string;
126
+ }
127
+ /**
128
+ * Combined type for menu content items (regular items, dividers or gaps)
107
129
  *
108
130
  * @category Components
109
131
  */
110
- export type MenuContent = MenuItem | MenuDivider;
132
+ export type MenuContent = MenuItem | MenuDivider | MenuGap;
111
133
  /**
112
134
  * Configuration interface for the Menu component
113
135
  *
@@ -129,15 +151,11 @@ export interface MenuConfig {
129
151
  * Array of menu items and dividers to display
130
152
  */
131
153
  items: MenuContent[];
132
- /**
133
- * Position of the menu relative to the opener
134
- * @default 'bottom-start'
135
- */
136
154
  /**
137
155
  * Menu variant. `'vertical'` is the M3 expressive menu: a rounded
138
156
  * container holding items that sit apart and change shape as they are
139
- * hovered, focused, pressed or selected. Defaults to `'baseline'`, the
140
- * original M3 menu.
157
+ * hovered, focused, pressed or selected.
158
+ * @default 'baseline'
141
159
  */
142
160
  variant?: MenuVariant;
143
161
  /**
@@ -145,6 +163,10 @@ export interface MenuConfig {
145
163
  * and more prominent, so it should be used sparingly.
146
164
  */
147
165
  color?: MenuColor;
166
+ /**
167
+ * Position of the menu relative to the opener
168
+ * @default 'bottom-start'
169
+ */
148
170
  position?: MenuPosition;
149
171
  /**
150
172
  * Whether the menu should close when an item is clicked
@@ -183,7 +205,7 @@ export interface MenuConfig {
183
205
  maxHeight?: string;
184
206
  /**
185
207
  * Optional offset from the opener (in pixels)
186
- * @default 8
208
+ * @default 0
187
209
  */
188
210
  offset?: number;
189
211
  /**
@@ -55,7 +55,7 @@ export interface ProgressConfig {
55
55
  /**
56
56
  * Thickness of the progress track and indicator
57
57
  * Can be a named preset ('thin', 'default', 'thick') or a specific number in pixels
58
- * @default 'default'
58
+ * @default 'thin'
59
59
  */
60
60
  thickness?: ProgressThickness;
61
61
  /**
@@ -109,7 +109,7 @@ export interface ProgressConfig {
109
109
  /**
110
110
  * Size of the circular progress indicator in dp (only for circular variant)
111
111
  * Clamped between 24 and 240
112
- * @default 50
112
+ * @default 40 (48 when wavy)
113
113
  */
114
114
  size?: number;
115
115
  }
@@ -1,6 +1,18 @@
1
1
  import { SheetConfig } from "./types";
2
2
  /**
3
3
  * Creates a new Sheet component
4
+ *
5
+ * @deprecated Since 0.8.0. Use {@link createBottomSheet} for a sheet anchored
6
+ * to the bottom edge, or {@link createSideSheet} for one docked to a vertical
7
+ * edge. Those follow the M3 bottom sheet and side sheet specifications, which
8
+ * this component predates and does not match.
9
+ *
10
+ * This component is also broken: `open()`, `close()` and the drag gestures
11
+ * call `component.events.emit(...)`, but it composes the event feature that
12
+ * provides `emit` directly and no `events` object, so every one of them
13
+ * throws. Its scrim is never inserted into the page either. It is kept only so
14
+ * that existing imports keep resolving, and it will be removed.
15
+ *
4
16
  * @param {SheetConfig} config - Sheet configuration object
5
17
  * @returns {SheetComponent} Sheet component instance
6
18
  */
@@ -24,6 +24,10 @@ export declare const SHEET_EVENTS: {
24
24
  readonly DRAG_START: "dragstart";
25
25
  readonly DRAG_END: "dragend";
26
26
  };
27
+ /**
28
+ * @deprecated Since 0.8.0. Use BottomSheetConfig or SideSheetConfig.
29
+ * The sheet component this belongs to does not open: see createSheet.
30
+ */
27
31
  /**
28
32
  * Configuration interface for the Sheet component
29
33
  * @category Components
@@ -146,6 +150,10 @@ export interface TitleAPI {
146
150
  */
147
151
  getElement: () => HTMLElement | null;
148
152
  }
153
+ /**
154
+ * @deprecated Since 0.8.0. Use BottomSheetComponent or SideSheetComponent.
155
+ * The sheet component this belongs to does not open: see createSheet.
156
+ */
149
157
  /**
150
158
  * Sheet component interface
151
159
  * @category Components
@@ -0,0 +1,33 @@
1
+ import { SideSheetComponent, SideSheetEventHandlers } from "./types";
2
+ interface ApiOptions {
3
+ state: {
4
+ open: () => void;
5
+ close: () => void;
6
+ toggle: () => void;
7
+ isOpen: () => boolean;
8
+ release: () => void;
9
+ };
10
+ structure: {
11
+ setContent: (content: string | HTMLElement) => void;
12
+ setTitle: (title: string) => void;
13
+ };
14
+ lifecycle: {
15
+ destroy: () => void;
16
+ };
17
+ }
18
+ interface BaseComponent {
19
+ element: HTMLElement;
20
+ getClass: (name: string) => string;
21
+ on: (event: string, handler: (...args: never[]) => void) => unknown;
22
+ off: (event: string, handler: (...args: never[]) => void) => unknown;
23
+ }
24
+ /**
25
+ * The public surface. Every method is backed by a feature; none is declared
26
+ * and left unwired.
27
+ */
28
+ export declare const withAPI: ({ state, structure, lifecycle }: ApiOptions) => <C extends BaseComponent>(component: C) => SideSheetComponent;
29
+ /** Registers the handlers given at creation */
30
+ export declare const applyEventHandlers: (component: {
31
+ on: (event: string, handler: (...args: never[]) => void) => unknown;
32
+ }, handlers?: SideSheetEventHandlers) => void;
33
+ export {};