mtrl 0.6.3 → 0.7.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/dist/components/drawer/api.d.ts +54 -0
- package/dist/components/drawer/config.d.ts +106 -0
- package/dist/components/drawer/constants.d.ts +97 -0
- package/dist/components/drawer/drawer.d.ts +59 -0
- package/dist/components/drawer/features/headline.d.ts +17 -0
- package/dist/components/drawer/features/index.d.ts +3 -0
- package/dist/components/drawer/features/items.d.ts +18 -0
- package/dist/components/drawer/features/state.d.ts +18 -0
- package/dist/components/drawer/index.d.ts +6 -0
- package/dist/components/drawer/types.d.ts +233 -0
- package/dist/components/index.d.ts +2 -3
- package/dist/components/menu/constants.d.ts +2 -0
- package/dist/components/menu/features/opener.d.ts +1 -1
- package/dist/components/menu/types.d.ts +14 -0
- package/dist/components/progress/types.d.ts +8 -0
- package/dist/index.cjs +10 -20
- package/dist/index.cjs.map +20 -26
- package/dist/index.js +10 -20
- package/dist/index.js.map +20 -26
- package/dist/package.json +1 -1
- package/dist/styles.css +2 -2
- package/package.json +1 -4
- package/src/styles/components/_button-group.scss +1 -1
- package/src/styles/components/_button.scss +1 -1
- package/src/styles/components/_drawer.scss +611 -0
- package/src/styles/components/_extended-fab.scss +1 -1
- package/src/styles/components/_fab.scss +1 -1
- package/src/styles/components/_icon-button.scss +1 -1
- package/src/styles/components/_menu.scss +25 -0
- package/src/styles/components/_segmented-button.scss +1 -1
- package/src/styles/main.scss +1 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DrawerComponent, DrawerItemConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* API configuration options for drawer component
|
|
4
|
+
* @category Components
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
interface ApiOptions {
|
|
8
|
+
state: {
|
|
9
|
+
open: () => void;
|
|
10
|
+
close: () => void;
|
|
11
|
+
toggle: () => void;
|
|
12
|
+
isOpen: () => boolean;
|
|
13
|
+
};
|
|
14
|
+
items: {
|
|
15
|
+
setActive: (id: string) => void;
|
|
16
|
+
getActive: () => string | null;
|
|
17
|
+
setItems: (items: DrawerItemConfig[] | undefined) => void;
|
|
18
|
+
getItems: () => DrawerItemConfig[] | undefined;
|
|
19
|
+
setBadge: (id: string, badge: string) => void;
|
|
20
|
+
};
|
|
21
|
+
headline: {
|
|
22
|
+
setHeadline: (text: string) => void;
|
|
23
|
+
getHeadline: () => string;
|
|
24
|
+
};
|
|
25
|
+
lifecycle: {
|
|
26
|
+
destroy: () => void;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Component with required elements and methods for API enhancement
|
|
31
|
+
* @category Components
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
interface ComponentWithElements {
|
|
35
|
+
element: HTMLElement;
|
|
36
|
+
getClass: (name: string) => string;
|
|
37
|
+
on?: (event: string, handler: Function) => ComponentWithElements;
|
|
38
|
+
off?: (event: string, handler: Function) => ComponentWithElements;
|
|
39
|
+
addClass?: (...classes: string[]) => ComponentWithElements;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Enhances a drawer component with public API methods.
|
|
43
|
+
* This follows the higher-order function pattern to add public API methods
|
|
44
|
+
* to the component, making them available to the end user.
|
|
45
|
+
*
|
|
46
|
+
* All methods that modify the component return the component for chaining.
|
|
47
|
+
*
|
|
48
|
+
* @param {ApiOptions} options - API configuration options
|
|
49
|
+
* @returns {Function} Higher-order function that adds API methods to component
|
|
50
|
+
* @category Components
|
|
51
|
+
* @internal This is an internal utility for the Drawer component
|
|
52
|
+
*/
|
|
53
|
+
export declare const withAPI: ({ state, items, headline, lifecycle }: ApiOptions) => (component: ComponentWithElements) => DrawerComponent;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { DrawerConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Default configuration for the Drawer component.
|
|
4
|
+
* These values will be used when not explicitly specified by the user.
|
|
5
|
+
*
|
|
6
|
+
* @category Components
|
|
7
|
+
*/
|
|
8
|
+
export declare const defaultConfig: DrawerConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Creates the base configuration for the Drawer component by merging
|
|
11
|
+
* user-provided config with default values. Global configuration is
|
|
12
|
+
* automatically applied by createComponentConfig.
|
|
13
|
+
*
|
|
14
|
+
* @param {DrawerConfig} config - User provided configuration
|
|
15
|
+
* @returns {DrawerConfig} Complete configuration with defaults applied
|
|
16
|
+
* @category Components
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare const createBaseConfig: (config?: DrawerConfig) => DrawerConfig;
|
|
20
|
+
/**
|
|
21
|
+
* Generates element configuration for the Drawer component.
|
|
22
|
+
* This function creates the necessary attributes and configuration
|
|
23
|
+
* for the DOM element creation process.
|
|
24
|
+
*
|
|
25
|
+
* @param {DrawerConfig} config - Drawer configuration
|
|
26
|
+
* @returns {Object} Element configuration object for withElement
|
|
27
|
+
* @category Components
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
export declare const getElementConfig: (config: DrawerConfig) => {
|
|
31
|
+
tag: string;
|
|
32
|
+
componentName: string;
|
|
33
|
+
attributes: Record<string, any>;
|
|
34
|
+
className: string[];
|
|
35
|
+
rawClass: string | string[];
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
title: string;
|
|
39
|
+
tabIndex: number;
|
|
40
|
+
style: string | Partial<CSSStyleDeclaration>;
|
|
41
|
+
data: Record<string, string>;
|
|
42
|
+
role: string;
|
|
43
|
+
ariaLabel: string;
|
|
44
|
+
ariaDescribedBy: string;
|
|
45
|
+
ariaLabelledBy: string;
|
|
46
|
+
ariaHidden: boolean;
|
|
47
|
+
html: string;
|
|
48
|
+
text: string;
|
|
49
|
+
forwardEvents: Record<string, boolean | ((component: any, event: Event) => boolean)>;
|
|
50
|
+
interactive: boolean;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Creates API configuration for the Drawer component.
|
|
54
|
+
* This connects the core component features (state, items, headline)
|
|
55
|
+
* to the public API methods exposed to users.
|
|
56
|
+
*
|
|
57
|
+
* @param {Object} comp - Component with all features applied
|
|
58
|
+
* @returns {Object} API configuration object
|
|
59
|
+
* @category Components
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
export declare const getApiConfig: (comp: {
|
|
63
|
+
drawerState: {
|
|
64
|
+
open: () => void;
|
|
65
|
+
close: () => void;
|
|
66
|
+
toggle: () => void;
|
|
67
|
+
isOpen: () => boolean;
|
|
68
|
+
};
|
|
69
|
+
drawerItems: {
|
|
70
|
+
setActive: (id: string) => void;
|
|
71
|
+
getActive: () => string | null;
|
|
72
|
+
setItems: (items: DrawerConfig["items"]) => void;
|
|
73
|
+
getItems: () => DrawerConfig["items"];
|
|
74
|
+
setBadge: (id: string, badge: string) => void;
|
|
75
|
+
};
|
|
76
|
+
drawerHeadline: {
|
|
77
|
+
setHeadline: (text: string) => void;
|
|
78
|
+
getHeadline: () => string;
|
|
79
|
+
};
|
|
80
|
+
lifecycle: {
|
|
81
|
+
destroy: () => void;
|
|
82
|
+
};
|
|
83
|
+
_stateCleanup?: () => void;
|
|
84
|
+
}) => {
|
|
85
|
+
state: {
|
|
86
|
+
open: () => void;
|
|
87
|
+
close: () => void;
|
|
88
|
+
toggle: () => void;
|
|
89
|
+
isOpen: () => boolean;
|
|
90
|
+
};
|
|
91
|
+
items: {
|
|
92
|
+
setActive: (id: string) => void;
|
|
93
|
+
getActive: () => string;
|
|
94
|
+
setItems: (items: DrawerConfig["items"]) => void;
|
|
95
|
+
getItems: () => import("./types").DrawerItemConfig[];
|
|
96
|
+
setBadge: (id: string, badge: string) => void;
|
|
97
|
+
};
|
|
98
|
+
headline: {
|
|
99
|
+
setHeadline: (text: string) => void;
|
|
100
|
+
getHeadline: () => string;
|
|
101
|
+
};
|
|
102
|
+
lifecycle: {
|
|
103
|
+
destroy: () => void;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export default defaultConfig;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drawer variants matching MD3 navigation drawer specification
|
|
3
|
+
*/
|
|
4
|
+
export declare const DRAWER_VARIANTS: {
|
|
5
|
+
/** Standard drawer — inline, can be permanently visible or toggled */
|
|
6
|
+
readonly STANDARD: "standard";
|
|
7
|
+
/** Modal drawer — overlays content with scrim, for compact/medium screens */
|
|
8
|
+
readonly MODAL: "modal";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Drawer positions (anchor edge)
|
|
12
|
+
*/
|
|
13
|
+
export declare const DRAWER_POSITIONS: {
|
|
14
|
+
/** Start edge (left in LTR, right in RTL) — default per MD3 */
|
|
15
|
+
readonly START: "start";
|
|
16
|
+
/** End edge (right in LTR, left in RTL) */
|
|
17
|
+
readonly END: "end";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Drawer item types for the items configuration array
|
|
21
|
+
*/
|
|
22
|
+
export declare const DRAWER_ITEM_TYPES: {
|
|
23
|
+
/** Navigation destination item */
|
|
24
|
+
readonly ITEM: "item";
|
|
25
|
+
/** Visual separator between groups */
|
|
26
|
+
readonly DIVIDER: "divider";
|
|
27
|
+
/** Section label / subhead for grouping */
|
|
28
|
+
readonly SECTION: "section";
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Drawer events
|
|
32
|
+
*/
|
|
33
|
+
export declare const DRAWER_EVENTS: {
|
|
34
|
+
/** Fired when the drawer opens */
|
|
35
|
+
readonly OPEN: "open";
|
|
36
|
+
/** Fired when the drawer closes */
|
|
37
|
+
readonly CLOSE: "close";
|
|
38
|
+
/** Fired when a navigation item is selected */
|
|
39
|
+
readonly SELECT: "select";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* CSS classes used by the drawer component
|
|
43
|
+
*/
|
|
44
|
+
export declare const DRAWER_CLASSES: {
|
|
45
|
+
/** Root container */
|
|
46
|
+
readonly ROOT: "drawer";
|
|
47
|
+
/** Scrim overlay (modal variant only) */
|
|
48
|
+
readonly SCRIM: "drawer__scrim";
|
|
49
|
+
/** Inner sheet / panel */
|
|
50
|
+
readonly SHEET: "drawer__sheet";
|
|
51
|
+
/** Headline text */
|
|
52
|
+
readonly HEADLINE: "drawer__headline";
|
|
53
|
+
/** Scrollable items container */
|
|
54
|
+
readonly ITEMS: "drawer__items";
|
|
55
|
+
/** Single navigation item */
|
|
56
|
+
readonly ITEM: "drawer__item";
|
|
57
|
+
/** Item icon */
|
|
58
|
+
readonly ITEM_ICON: "drawer__item-icon";
|
|
59
|
+
/** Item label text */
|
|
60
|
+
readonly ITEM_LABEL: "drawer__item-label";
|
|
61
|
+
/** Item badge */
|
|
62
|
+
readonly ITEM_BADGE: "drawer__item-badge";
|
|
63
|
+
/** Active indicator shape */
|
|
64
|
+
readonly ACTIVE_INDICATOR: "drawer__active-indicator";
|
|
65
|
+
/** Dense/compact variant */
|
|
66
|
+
readonly DENSE: "drawer--dense";
|
|
67
|
+
/** Divider separator */
|
|
68
|
+
readonly DIVIDER: "drawer__divider";
|
|
69
|
+
/** Section label */
|
|
70
|
+
readonly SECTION_LABEL: "drawer__section-label";
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Default animation configuration
|
|
74
|
+
*/
|
|
75
|
+
export declare const DRAWER_ANIMATION: {
|
|
76
|
+
/** Animation duration in milliseconds */
|
|
77
|
+
readonly DURATION: 300;
|
|
78
|
+
/** Easing for opening */
|
|
79
|
+
readonly EASING_OPEN: "cubic-bezier(0.0, 0.0, 0.2, 1.0)";
|
|
80
|
+
/** Easing for closing */
|
|
81
|
+
readonly EASING_CLOSE: "cubic-bezier(0.3, 0.0, 1.0, 1.0)";
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Drawer default values
|
|
85
|
+
*/
|
|
86
|
+
export declare const DRAWER_DEFAULTS: {
|
|
87
|
+
/** Default variant */
|
|
88
|
+
readonly VARIANT: "standard";
|
|
89
|
+
/** Default position */
|
|
90
|
+
readonly POSITION: "start";
|
|
91
|
+
/** Whether drawer is open by default */
|
|
92
|
+
readonly OPEN: false;
|
|
93
|
+
/** Whether modal can be dismissed via scrim */
|
|
94
|
+
readonly DISMISSIBLE: true;
|
|
95
|
+
/** Default drawer width in pixels */
|
|
96
|
+
readonly WIDTH: 360;
|
|
97
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DrawerConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Drawer component with the specified configuration.
|
|
4
|
+
*
|
|
5
|
+
* The Drawer component implements Material Design 3 navigation drawer with
|
|
6
|
+
* support for standard (inline) and modal (overlay) variants. It provides
|
|
7
|
+
* navigation destinations with icons, labels, badges, dividers, and section
|
|
8
|
+
* labels following the MD3 specification.
|
|
9
|
+
*
|
|
10
|
+
* The Drawer component is created using a functional composition pattern,
|
|
11
|
+
* applying various features through the pipe function.
|
|
12
|
+
*
|
|
13
|
+
* @param {DrawerConfig} config - Configuration options for the drawer
|
|
14
|
+
* This can include variant, items, headline, position, open state,
|
|
15
|
+
* and other drawer properties. See {@link DrawerConfig} for available options.
|
|
16
|
+
*
|
|
17
|
+
* @returns {DrawerComponent} A fully configured drawer component instance with
|
|
18
|
+
* all requested features applied. The returned component has methods for
|
|
19
|
+
* state management, item selection, and lifecycle management.
|
|
20
|
+
*
|
|
21
|
+
* @throws {Error} Throws an error if drawer creation fails for any reason
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* // Create a standard navigation drawer
|
|
26
|
+
* const drawer = createDrawer({
|
|
27
|
+
* variant: 'standard',
|
|
28
|
+
* headline: 'Mail',
|
|
29
|
+
* open: true,
|
|
30
|
+
* items: [
|
|
31
|
+
* { id: 'inbox', label: 'Inbox', icon: '<svg>...</svg>', badge: '24', active: true },
|
|
32
|
+
* { id: 'outbox', label: 'Outbox', icon: '<svg>...</svg>' },
|
|
33
|
+
* { type: 'divider' },
|
|
34
|
+
* { type: 'section', label: 'Labels' },
|
|
35
|
+
* { id: 'family', label: 'Family', icon: '<svg>...</svg>' },
|
|
36
|
+
* ],
|
|
37
|
+
* onSelect: (event) => console.log('Selected:', event.id),
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* document.body.appendChild(drawer.element);
|
|
41
|
+
*
|
|
42
|
+
* // Create a modal drawer
|
|
43
|
+
* const modalDrawer = createDrawer({
|
|
44
|
+
* variant: 'modal',
|
|
45
|
+
* headline: 'Navigation',
|
|
46
|
+
* items: [
|
|
47
|
+
* { id: 'home', label: 'Home', icon: '<svg>...</svg>', active: true },
|
|
48
|
+
* { id: 'settings', label: 'Settings', icon: '<svg>...</svg>' },
|
|
49
|
+
* ],
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* document.body.appendChild(modalDrawer.element);
|
|
53
|
+
* modalDrawer.open();
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @category Components
|
|
57
|
+
*/
|
|
58
|
+
declare const createDrawer: (config?: DrawerConfig) => any;
|
|
59
|
+
export default createDrawer;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { DrawerConfig } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Component shape expected by withHeadline
|
|
4
|
+
*/
|
|
5
|
+
interface HeadlineBaseComponent {
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
getClass: (name: string) => string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Adds headline management to the drawer component
|
|
12
|
+
*
|
|
13
|
+
* @param config - Drawer configuration
|
|
14
|
+
* @returns Component enhancer function
|
|
15
|
+
*/
|
|
16
|
+
export declare const withHeadline: (config: DrawerConfig) => (component: HeadlineBaseComponent) => HeadlineBaseComponent;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DrawerConfig } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Component shape expected by withItems
|
|
4
|
+
*/
|
|
5
|
+
interface ItemsBaseComponent {
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
getClass: (name: string) => string;
|
|
8
|
+
emit: (event: string, data?: unknown) => void;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Adds item management functionality to the drawer component
|
|
13
|
+
*
|
|
14
|
+
* @param config - Drawer configuration
|
|
15
|
+
* @returns Component enhancer function
|
|
16
|
+
*/
|
|
17
|
+
export declare const withItems: (config: DrawerConfig) => (component: ItemsBaseComponent) => ItemsBaseComponent;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DrawerConfig } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Component shape expected by withState
|
|
4
|
+
*/
|
|
5
|
+
interface StateBaseComponent {
|
|
6
|
+
element: HTMLElement;
|
|
7
|
+
getClass: (name: string) => string;
|
|
8
|
+
emit: (event: string, data?: unknown) => void;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Adds open/close state management, scrim, and keyboard dismiss to the drawer
|
|
13
|
+
*
|
|
14
|
+
* @param config - Drawer configuration
|
|
15
|
+
* @returns Component enhancer function
|
|
16
|
+
*/
|
|
17
|
+
export declare const withState: (config: DrawerConfig) => (component: StateBaseComponent) => StateBaseComponent;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { BaseComponentConfig } from "../../core/config/component";
|
|
2
|
+
/**
|
|
3
|
+
* Drawer variant type — controls layout behavior
|
|
4
|
+
* @category Components
|
|
5
|
+
* @remarks
|
|
6
|
+
* - standard: Inline drawer, can be permanently visible or toggled. Best for expanded+ window sizes.
|
|
7
|
+
* - modal: Overlay drawer with scrim. Best for compact/medium window sizes.
|
|
8
|
+
*/
|
|
9
|
+
export type DrawerVariant = "standard" | "modal";
|
|
10
|
+
/**
|
|
11
|
+
* Drawer position — which edge the drawer anchors to
|
|
12
|
+
* @category Components
|
|
13
|
+
*/
|
|
14
|
+
export type DrawerPosition = "start" | "end";
|
|
15
|
+
/**
|
|
16
|
+
* Configuration for a navigation destination item
|
|
17
|
+
* @category Components
|
|
18
|
+
*/
|
|
19
|
+
export interface DrawerItemConfig {
|
|
20
|
+
/** Item type — defaults to 'item' if omitted */
|
|
21
|
+
type?: "item" | "divider" | "section";
|
|
22
|
+
/** Unique identifier for the item */
|
|
23
|
+
id?: string;
|
|
24
|
+
/** Destination label text */
|
|
25
|
+
label?: string;
|
|
26
|
+
/** Icon HTML content (placed before label) */
|
|
27
|
+
icon?: string;
|
|
28
|
+
/** Badge text (e.g. unread count) */
|
|
29
|
+
badge?: string;
|
|
30
|
+
/** Whether this item is initially active/selected */
|
|
31
|
+
active?: boolean;
|
|
32
|
+
/** Section label text (only when type is 'section') */
|
|
33
|
+
sectionLabel?: string;
|
|
34
|
+
/** Whether the item is disabled */
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Event detail emitted when a drawer item is selected
|
|
39
|
+
* @category Components
|
|
40
|
+
*/
|
|
41
|
+
export interface DrawerSelectEvent {
|
|
42
|
+
/** The selected item's id */
|
|
43
|
+
id: string;
|
|
44
|
+
/** The selected item's label */
|
|
45
|
+
label: string;
|
|
46
|
+
/** The selected item's index within navigation items (excludes dividers/sections) */
|
|
47
|
+
index: number;
|
|
48
|
+
/** The underlying DOM event */
|
|
49
|
+
originalEvent: Event;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Configuration interface for the Drawer component
|
|
53
|
+
* @category Components
|
|
54
|
+
*/
|
|
55
|
+
export interface DrawerConfig extends BaseComponentConfig {
|
|
56
|
+
/**
|
|
57
|
+
* Drawer variant that determines layout behavior
|
|
58
|
+
* @default 'standard'
|
|
59
|
+
*/
|
|
60
|
+
variant?: DrawerVariant | string;
|
|
61
|
+
/**
|
|
62
|
+
* Drawer anchor position
|
|
63
|
+
* @default 'start'
|
|
64
|
+
*/
|
|
65
|
+
position?: DrawerPosition | string;
|
|
66
|
+
/**
|
|
67
|
+
* Whether the drawer is initially open
|
|
68
|
+
* @default false
|
|
69
|
+
*/
|
|
70
|
+
open?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether the modal drawer can be dismissed by clicking the scrim
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
dismissible?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Optional headline text displayed at the top of the drawer
|
|
78
|
+
* @example 'Mail'
|
|
79
|
+
*/
|
|
80
|
+
headline?: string;
|
|
81
|
+
/**
|
|
82
|
+
* Navigation items configuration array.
|
|
83
|
+
* Supports destination items, dividers, and section labels.
|
|
84
|
+
* @example
|
|
85
|
+
* [
|
|
86
|
+
* { id: 'inbox', label: 'Inbox', icon: '<svg>...</svg>', badge: '24', active: true },
|
|
87
|
+
* { type: 'divider' },
|
|
88
|
+
* { type: 'section', label: 'Labels' },
|
|
89
|
+
* { id: 'family', label: 'Family', icon: '<svg>...</svg>' },
|
|
90
|
+
* ]
|
|
91
|
+
*/
|
|
92
|
+
items?: DrawerItemConfig[];
|
|
93
|
+
/**
|
|
94
|
+
* Drawer width as a CSS value
|
|
95
|
+
* @default '360px'
|
|
96
|
+
*/
|
|
97
|
+
width?: string | number;
|
|
98
|
+
/**
|
|
99
|
+
* When true, renders a compact drawer with smaller items and tighter spacing.
|
|
100
|
+
* Useful in dense UIs like admin panels where the standard 56px item height
|
|
101
|
+
* is too large.
|
|
102
|
+
* @default false
|
|
103
|
+
*/
|
|
104
|
+
dense?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Additional CSS classes to add to the drawer
|
|
107
|
+
*/
|
|
108
|
+
class?: string;
|
|
109
|
+
/**
|
|
110
|
+
* Component prefix for class names
|
|
111
|
+
* @default 'mtrl'
|
|
112
|
+
*/
|
|
113
|
+
prefix?: string;
|
|
114
|
+
/**
|
|
115
|
+
* Component name used in class generation
|
|
116
|
+
*/
|
|
117
|
+
componentName?: string;
|
|
118
|
+
/**
|
|
119
|
+
* Callback when a navigation item is selected
|
|
120
|
+
*/
|
|
121
|
+
onSelect?: (event: DrawerSelectEvent) => void;
|
|
122
|
+
/**
|
|
123
|
+
* Callback when the drawer opens
|
|
124
|
+
*/
|
|
125
|
+
onOpen?: () => void;
|
|
126
|
+
/**
|
|
127
|
+
* Callback when the drawer closes
|
|
128
|
+
*/
|
|
129
|
+
onClose?: () => void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Drawer component interface — public API
|
|
133
|
+
* @category Components
|
|
134
|
+
*/
|
|
135
|
+
export interface DrawerComponent {
|
|
136
|
+
/** The drawer's root DOM element */
|
|
137
|
+
element: HTMLElement;
|
|
138
|
+
/**
|
|
139
|
+
* Gets a class name with the component's prefix
|
|
140
|
+
* @param name - Base class name
|
|
141
|
+
* @returns Prefixed class name
|
|
142
|
+
*/
|
|
143
|
+
getClass: (name: string) => string;
|
|
144
|
+
/**
|
|
145
|
+
* Opens the drawer
|
|
146
|
+
* @returns The drawer component for chaining
|
|
147
|
+
*/
|
|
148
|
+
open: () => DrawerComponent;
|
|
149
|
+
/**
|
|
150
|
+
* Closes the drawer
|
|
151
|
+
* @returns The drawer component for chaining
|
|
152
|
+
*/
|
|
153
|
+
close: () => DrawerComponent;
|
|
154
|
+
/**
|
|
155
|
+
* Toggles the drawer open/closed state
|
|
156
|
+
* @returns The drawer component for chaining
|
|
157
|
+
*/
|
|
158
|
+
toggle: () => DrawerComponent;
|
|
159
|
+
/**
|
|
160
|
+
* Checks if the drawer is currently open
|
|
161
|
+
* @returns True if the drawer is open
|
|
162
|
+
*/
|
|
163
|
+
isOpen: () => boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Sets the active navigation item by id
|
|
166
|
+
* @param id - Item id to activate
|
|
167
|
+
* @returns The drawer component for chaining
|
|
168
|
+
*/
|
|
169
|
+
setActive: (id: string) => DrawerComponent;
|
|
170
|
+
/**
|
|
171
|
+
* Gets the currently active item id
|
|
172
|
+
* @returns Active item id or null
|
|
173
|
+
*/
|
|
174
|
+
getActive: () => string | null;
|
|
175
|
+
/**
|
|
176
|
+
* Sets the headline text
|
|
177
|
+
* @param text - Headline text
|
|
178
|
+
* @returns The drawer component for chaining
|
|
179
|
+
*/
|
|
180
|
+
setHeadline: (text: string) => DrawerComponent;
|
|
181
|
+
/**
|
|
182
|
+
* Gets the headline text
|
|
183
|
+
* @returns Headline text
|
|
184
|
+
*/
|
|
185
|
+
getHeadline: () => string;
|
|
186
|
+
/**
|
|
187
|
+
* Sets the navigation items
|
|
188
|
+
* @param items - Array of item configurations
|
|
189
|
+
* @returns The drawer component for chaining
|
|
190
|
+
*/
|
|
191
|
+
setItems: (items: DrawerItemConfig[]) => DrawerComponent;
|
|
192
|
+
/**
|
|
193
|
+
* Gets the current items configuration
|
|
194
|
+
* @returns Array of item configurations
|
|
195
|
+
*/
|
|
196
|
+
getItems: () => DrawerItemConfig[];
|
|
197
|
+
/**
|
|
198
|
+
* Sets a badge on a specific item
|
|
199
|
+
* @param id - Item id
|
|
200
|
+
* @param badge - Badge text or empty string to remove
|
|
201
|
+
* @returns The drawer component for chaining
|
|
202
|
+
*/
|
|
203
|
+
setBadge: (id: string, badge: string) => DrawerComponent;
|
|
204
|
+
/**
|
|
205
|
+
* Adds an event listener
|
|
206
|
+
* @param event - Event name ('select', 'open', 'close')
|
|
207
|
+
* @param handler - Event handler function
|
|
208
|
+
* @returns The drawer component for chaining
|
|
209
|
+
*/
|
|
210
|
+
on: (event: string, handler: Function) => DrawerComponent;
|
|
211
|
+
/**
|
|
212
|
+
* Removes an event listener
|
|
213
|
+
* @param event - Event name
|
|
214
|
+
* @param handler - Event handler function
|
|
215
|
+
* @returns The drawer component for chaining
|
|
216
|
+
*/
|
|
217
|
+
off: (event: string, handler: Function) => DrawerComponent;
|
|
218
|
+
/**
|
|
219
|
+
* Adds CSS classes to the drawer element
|
|
220
|
+
* @param classes - One or more class names to add
|
|
221
|
+
* @returns The drawer component for chaining
|
|
222
|
+
*/
|
|
223
|
+
addClass: (...classes: string[]) => DrawerComponent;
|
|
224
|
+
/**
|
|
225
|
+
* Destroys the drawer component and cleans up resources
|
|
226
|
+
*/
|
|
227
|
+
destroy: () => void;
|
|
228
|
+
/** API for managing component lifecycle */
|
|
229
|
+
lifecycle: {
|
|
230
|
+
/** Destroys the component and cleans up resources */
|
|
231
|
+
destroy: () => void;
|
|
232
|
+
};
|
|
233
|
+
}
|
|
@@ -18,13 +18,12 @@ export { createChip, createChips } from "./chips";
|
|
|
18
18
|
export { default as createDatePicker } from "./datepicker";
|
|
19
19
|
export { default as createDialog } from "./dialog";
|
|
20
20
|
export { createDivider } from "./divider";
|
|
21
|
+
export { default as createDrawer } from "./drawer";
|
|
21
22
|
export { default as createFab } from "./fab";
|
|
22
23
|
export { default as createExtendedFab } from "./extended-fab";
|
|
23
24
|
export { default as createIconButton } from "./icon-button";
|
|
24
25
|
export { default as createList } from "./list";
|
|
25
26
|
export { default as createMenu } from "./menu";
|
|
26
|
-
export { default as createNavigation } from "./navigation";
|
|
27
|
-
export { default as createNavigationSystem } from "./navigation/system";
|
|
28
27
|
export { default as createProgress } from "./progress";
|
|
29
28
|
export { default as createRadios } from "./radios";
|
|
30
29
|
export { default as createSearch } from "./search";
|
|
@@ -52,6 +51,7 @@ export type { CheckboxConfig, CheckboxComponent } from "./checkbox/types";
|
|
|
52
51
|
export type { ChipConfig, ChipComponent, ChipVariant, ChipsConfig, ChipsComponent, } from "./chips/types";
|
|
53
52
|
export type { DatePickerConfig, DatePickerComponent } from "./datepicker/types";
|
|
54
53
|
export type { DialogConfig, DialogComponent } from "./dialog/types";
|
|
54
|
+
export type { DrawerConfig, DrawerComponent, DrawerVariant, DrawerPosition, DrawerItemConfig, DrawerSelectEvent, } from "./drawer/types";
|
|
55
55
|
export type { DividerConfig } from "./divider/config";
|
|
56
56
|
export type { DividerComponent } from "./divider/types";
|
|
57
57
|
export type { FabConfig, FabComponent } from "./fab/types";
|
|
@@ -59,7 +59,6 @@ export type { ExtendedFabConfig, ExtendedFabComponent, } from "./extended-fab/ty
|
|
|
59
59
|
export type { IconButtonConfig, IconButtonComponent, } from "./icon-button/types";
|
|
60
60
|
export type { ListConfig, ListComponent, SelectEvent as ListSelectEvent, LoadEvent, } from "./list/types";
|
|
61
61
|
export type { MenuConfig, MenuComponent, MenuItem } from "./menu/types";
|
|
62
|
-
export type { NavigationConfig, NavigationComponent, NavItemConfig, } from "./navigation/types";
|
|
63
62
|
export type { ProgressConfig, ProgressComponent, ProgressShape, } from "./progress/types";
|
|
64
63
|
export type { RadiosConfig, RadiosComponent, RadioOptionConfig, } from "./radios/types";
|
|
65
64
|
export type { SearchConfig, SearchComponent } from "./search/types";
|
|
@@ -181,6 +181,20 @@ export interface MenuConfig {
|
|
|
181
181
|
* Use this when the menu needs to stay within a specific container (e.g., inside a dialog)
|
|
182
182
|
*/
|
|
183
183
|
container?: HTMLElement | null;
|
|
184
|
+
/**
|
|
185
|
+
* When true, the opener is used only for positioning.
|
|
186
|
+
* No click, blur, or keyboard handlers are attached to the opener element.
|
|
187
|
+
* The consumer is responsible for calling open() / close() manually.
|
|
188
|
+
* @default false
|
|
189
|
+
*/
|
|
190
|
+
manualOpen?: boolean;
|
|
191
|
+
/**
|
|
192
|
+
* When true, renders a compact menu with smaller items and tighter spacing.
|
|
193
|
+
* Useful in dense UIs like toolbars and action bars where the standard
|
|
194
|
+
* 48px item height is too large.
|
|
195
|
+
* @default false
|
|
196
|
+
*/
|
|
197
|
+
dense?: boolean;
|
|
184
198
|
/**
|
|
185
199
|
* Additional CSS classes to add to the menu
|
|
186
200
|
*/
|