mtrl 0.8.0 → 0.9.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/badge/config.d.ts +2 -2
- package/dist/components/bottom-sheet/bottom-sheet.js +1 -1
- package/dist/components/bottom-sheet/config.d.ts +2 -2
- package/dist/components/bottom-sheet/features/drag.d.ts +2 -2
- package/dist/components/bottom-sheet/features/drag.js +1 -1
- package/dist/components/button/api.d.ts +3 -3
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/config.d.ts +2 -2
- package/dist/components/button/features/progress.d.ts +17 -5
- package/dist/components/button-group/config.d.ts +20 -0
- package/dist/components/card/api.d.ts +10 -1
- package/dist/components/card/api.js +6 -1
- package/dist/components/card/card.js +1 -1
- package/dist/components/card/config.d.ts +15 -9
- package/dist/components/card/features.d.ts +2 -1
- package/dist/components/card/types.d.ts +5 -4
- package/dist/components/carousel/config.d.ts +2 -2
- package/dist/components/checkbox/config.d.ts +2 -2
- package/dist/components/checkbox/types.d.ts +15 -16
- package/dist/components/chips/api.d.ts +6 -6
- package/dist/components/chips/chip/api.d.ts +2 -2
- package/dist/components/chips/chip/config.d.ts +6 -7
- package/dist/components/chips/config.d.ts +2 -2
- package/dist/components/chips/features/dom.js +0 -1
- package/dist/components/chips/types.d.ts +12 -1
- package/dist/components/datepicker/api.d.ts +5 -2
- package/dist/components/datepicker/config.d.ts +16 -13
- package/dist/components/datepicker/datepicker.js +10 -4
- package/dist/components/datepicker/render.d.ts +14 -6
- package/dist/components/datepicker/render.js +1 -1
- package/dist/components/datepicker/types.d.ts +51 -3
- package/dist/components/dialog/api.d.ts +1 -1
- package/dist/components/dialog/config.d.ts +3 -4
- package/dist/components/dialog/config.js +1 -1
- package/dist/components/dialog/features.js +1 -1
- package/dist/components/dialog/types.d.ts +1 -1
- package/dist/components/divider/features.js +2 -0
- package/dist/components/drawer/api.d.ts +3 -3
- package/dist/components/drawer/config.d.ts +2 -2
- package/dist/components/drawer/drawer.d.ts +1 -1
- package/dist/components/drawer/features/headline.d.ts +12 -2
- package/dist/components/drawer/features/items.d.ts +17 -3
- package/dist/components/drawer/features/state.d.ts +14 -2
- package/dist/components/extended-fab/api.d.ts +12 -4
- package/dist/components/extended-fab/api.js +12 -0
- package/dist/components/extended-fab/config.d.ts +10 -10
- package/dist/components/extended-fab/types.d.ts +4 -2
- package/dist/components/fab/api.d.ts +9 -2
- package/dist/components/fab/api.js +12 -0
- package/dist/components/fab/config.d.ts +8 -8
- package/dist/components/fab/types.d.ts +2 -1
- package/dist/components/icon-button/config.d.ts +2 -2
- package/dist/components/icon-button/features/toggle.d.ts +1 -5
- package/dist/components/icon-button/types.d.ts +6 -0
- package/dist/components/list/api.d.ts +18 -18
- package/dist/components/list/config.d.ts +6 -3
- package/dist/components/list/config.js +6 -7
- package/dist/components/list/features/renderer.js +2 -2
- package/dist/components/list/list.d.ts +20 -1
- package/dist/components/list/types.d.ts +32 -32
- package/dist/components/loading-indicator/config.d.ts +2 -2
- package/dist/components/loading-indicator/types.d.ts +3 -1
- package/dist/components/menu/api.d.ts +6 -5
- package/dist/components/menu/config.d.ts +2 -2
- package/dist/components/menu/features/keyboard.d.ts +19 -9
- package/dist/components/menu/types.d.ts +25 -9
- package/dist/components/navigation/config.d.ts +2 -2
- package/dist/components/navigation/features/controller.d.ts +1 -3
- package/dist/components/navigation/features/items.d.ts +1 -2
- package/dist/components/navigation/system/core.d.ts +6 -6
- package/dist/components/navigation/system/events.d.ts +3 -3
- package/dist/components/navigation/system/mobile.d.ts +6 -6
- package/dist/components/navigation/system/state.d.ts +3 -3
- package/dist/components/navigation/system/types.d.ts +43 -11
- package/dist/components/navigation/types.d.ts +15 -6
- package/dist/components/progress/api.js +0 -1
- package/dist/components/progress/config.d.ts +2 -2
- package/dist/components/progress/features/canvas.d.ts +14 -5
- package/dist/components/progress/features/state.d.ts +1 -2
- package/dist/components/progress/types.d.ts +1 -1
- package/dist/components/radios/config.d.ts +2 -2
- package/dist/components/search/api.js +4 -4
- package/dist/components/search/config.d.ts +2 -2
- package/dist/components/search/features/suggestions.d.ts +1 -3
- package/dist/components/search/features/suggestions.js +5 -5
- package/dist/components/search/search.js +1 -1
- package/dist/components/segmented-button/config.d.ts +1 -5
- package/dist/components/segmented-button/config.js +1 -1
- package/dist/components/select/api.d.ts +2 -2
- package/dist/components/select/features.d.ts +2 -2
- package/dist/components/select/features.js +2 -1
- package/dist/components/select/types.d.ts +38 -21
- package/dist/components/side-sheet/config.d.ts +2 -2
- package/dist/components/slider/api.d.ts +6 -6
- package/dist/components/slider/config.d.ts +2 -2
- package/dist/components/slider/types.d.ts +2 -2
- package/dist/components/snackbar/config.d.ts +2 -2
- package/dist/components/snackbar/features.d.ts +3 -3
- package/dist/components/snackbar/position.d.ts +1 -1
- package/dist/components/snackbar/types.d.ts +5 -6
- package/dist/components/split-button/api.js +1 -3
- package/dist/components/split-button/config.d.ts +2 -2
- package/dist/components/split-button/features/buttons.d.ts +3 -2
- package/dist/components/split-button/features/menu.d.ts +3 -2
- package/dist/components/split-button/types.d.ts +13 -2
- package/dist/components/switch/config.d.ts +2 -2
- package/dist/components/switch/types.d.ts +0 -1
- package/dist/components/tabs/api.d.ts +8 -5
- package/dist/components/tabs/config.d.ts +9 -1
- package/dist/components/tabs/features.d.ts +7 -11
- package/dist/components/tabs/features.js +2 -1
- package/dist/components/tabs/indicator.js +4 -2
- package/dist/components/tabs/responsive.js +2 -1
- package/dist/components/tabs/tab-api.d.ts +11 -5
- package/dist/components/tabs/tab-api.js +1 -1
- package/dist/components/tabs/tab.js +9 -1
- package/dist/components/tabs/types.d.ts +9 -2
- package/dist/components/tabs/utils.d.ts +14 -3
- package/dist/components/textfield/api.d.ts +1 -1
- package/dist/components/textfield/config.d.ts +2 -2
- package/dist/components/textfield/features/error.d.ts +1 -2
- package/dist/components/textfield/features/leading-icon.d.ts +1 -2
- package/dist/components/textfield/features/prefix-text.d.ts +1 -2
- package/dist/components/textfield/features/suffix-text.d.ts +1 -2
- package/dist/components/textfield/features/supporting-text.d.ts +1 -2
- package/dist/components/textfield/features/trailing-icon.d.ts +1 -2
- package/dist/components/textfield/types.d.ts +0 -2
- package/dist/components/timepicker/api.d.ts +5 -4
- package/dist/components/timepicker/config.d.ts +14 -11
- package/dist/components/tooltip/config.d.ts +2 -2
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/core/compose/base.d.ts +2 -2
- package/dist/core/compose/base.js +1 -1
- package/dist/core/compose/component.d.ts +13 -4
- package/dist/core/compose/component.js +1 -1
- package/dist/core/compose/features/badge.d.ts +3 -4
- package/dist/core/compose/features/badge.js +1 -1
- package/dist/core/compose/features/checkable.d.ts +3 -4
- package/dist/core/compose/features/debounce.d.ts +2 -3
- package/dist/core/compose/features/disabled.d.ts +1 -2
- package/dist/core/compose/features/events.d.ts +4 -3
- package/dist/core/compose/features/icon.d.ts +1 -5
- package/dist/core/compose/features/input.d.ts +2 -3
- package/dist/core/compose/features/lifecycle.d.ts +2 -2
- package/dist/core/compose/features/lifecycle.js +3 -3
- package/dist/core/compose/features/position.d.ts +1 -2
- package/dist/core/compose/features/ripple.d.ts +1 -2
- package/dist/core/compose/features/size.d.ts +1 -2
- package/dist/core/compose/features/style.d.ts +1 -2
- package/dist/core/compose/features/text.d.ts +1 -5
- package/dist/core/compose/features/textinput.d.ts +2 -3
- package/dist/core/compose/features/textlabel.d.ts +1 -2
- package/dist/core/compose/features/throttle.d.ts +1 -2
- package/dist/core/compose/features/track.d.ts +0 -1
- package/dist/core/compose/features/variant.d.ts +1 -2
- package/dist/core/compose/index.d.ts +1 -1
- package/dist/core/compose/pipe.d.ts +43 -3
- package/dist/core/compose/pipe.js +6 -2
- package/dist/core/compose/utils/type-guards.d.ts +4 -4
- package/dist/core/compose/utils/type-guards.js +1 -1
- package/dist/core/config/component.d.ts +12 -9
- package/dist/core/config/global.d.ts +12 -8
- package/dist/core/config.d.ts +1 -1
- package/dist/core/dom/attributes.d.ts +6 -6
- package/dist/core/dom/attributes.js +3 -2
- package/dist/core/dom/create.d.ts +27 -10
- package/dist/core/dom/create.js +0 -24
- package/dist/core/dom/utils.d.ts +1 -1
- package/dist/core/state/emitter.d.ts +2 -2
- package/dist/core/state/events.d.ts +3 -3
- package/dist/core/state/lifecycle.d.ts +0 -1
- package/dist/core/state/store.d.ts +3 -3
- package/dist/core/utils/object.d.ts +2 -2
- package/dist/core/utils/performance.d.ts +3 -3
- package/dist/core/utils/validate.d.ts +6 -6
- package/dist/core/utils/validate.js +13 -12
- package/dist/index.cjs +12 -12
- package/dist/package.json +1 -1
- package/dist/styles/badge.css +2 -2
- package/dist/styles/base.css +2 -2
- package/dist/styles/bottom-app-bar.css +2 -2
- package/dist/styles/bottom-sheet.css +2 -2
- package/dist/styles/button-group.css +2 -2
- package/dist/styles/button.css +2 -2
- package/dist/styles/card.css +2 -2
- package/dist/styles/carousel.css +2 -2
- package/dist/styles/checkbox.css +2 -2
- package/dist/styles/chips.css +2 -2
- package/dist/styles/dialog.css +2 -2
- package/dist/styles/divider.css +2 -2
- package/dist/styles/drawer.css +2 -2
- package/dist/styles/extended-fab.css +2 -2
- package/dist/styles/fab.css +2 -2
- package/dist/styles/icon-button.css +2 -2
- package/dist/styles/list.css +2 -2
- package/dist/styles/loading-indicator.css +2 -2
- package/dist/styles/menu.css +2 -2
- package/dist/styles/navigation-rail.css +2 -2
- package/dist/styles/navigation.css +2 -2
- package/dist/styles/progress.css +2 -2
- package/dist/styles/radios.css +2 -2
- package/dist/styles/search.css +2 -2
- package/dist/styles/segmented-button.css +2 -2
- package/dist/styles/select.css +2 -2
- package/dist/styles/side-sheet.css +2 -2
- package/dist/styles/slider.css +2 -2
- package/dist/styles/snackbar.css +2 -2
- package/dist/styles/split-button.css +2 -2
- package/dist/styles/switch.css +2 -2
- package/dist/styles/tabs.css +2 -2
- package/dist/styles/textfield.css +2 -2
- package/dist/styles/timepicker.css +2 -2
- package/dist/styles/tooltip.css +2 -0
- package/dist/styles/tooltip.d.ts +1 -0
- package/dist/styles/tooltip.js +2 -0
- package/dist/styles/top-app-bar.css +2 -2
- package/dist/styles/utilities.css +2 -2
- package/dist/styles.css +2 -2
- package/dist/themes/autumn.css +1 -1
- package/dist/themes/baseline.css +1 -1
- package/dist/themes/brownbeige.css +1 -1
- package/dist/themes/browngreen.css +1 -1
- package/dist/themes/desert.css +1 -1
- package/dist/themes/forest.css +1 -1
- package/dist/themes/highcontrast.css +1 -1
- package/dist/themes/legacy.css +1 -1
- package/dist/themes/material.css +1 -1
- package/dist/themes/ocean.css +1 -1
- package/dist/themes/sageivory.css +1 -1
- package/dist/themes/spring.css +1 -1
- package/dist/themes/summer.css +1 -1
- package/dist/themes/sunset.css +1 -1
- package/dist/themes/tealcaramel.css +1 -1
- package/dist/themes/winter.css +1 -1
- package/package.json +2 -2
- package/src/styles/abstract/_mixins.scss +5 -1
- package/src/styles/components/_checkbox.scss +27 -7
- package/src/styles/components/_chips.scss +13 -13
- package/src/styles/components/_datepicker.scss +5 -5
- package/src/styles/components/_dialog.scss +2 -2
- package/src/styles/components/_radios.scss +30 -30
- package/src/styles/components/_switch.scss +36 -26
- package/src/styles/components/_tabs.scss +59 -58
- package/src/styles/components/_timepicker.scss +3 -3
- package/src/styles/main.scss +1 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FabConfig } from "./types.js";
|
|
1
|
+
import { FabConfig, FabComponent } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Default configuration for the FAB component
|
|
4
4
|
*
|
|
@@ -38,7 +38,7 @@ export declare const createBaseConfig: (config?: FabConfig) => FabConfig;
|
|
|
38
38
|
export declare const getElementConfig: (config: FabConfig) => {
|
|
39
39
|
tag: string;
|
|
40
40
|
componentName: string;
|
|
41
|
-
attributes: Record<string,
|
|
41
|
+
attributes: Record<string, unknown>;
|
|
42
42
|
className: string[];
|
|
43
43
|
rawClass: string | string[];
|
|
44
44
|
id: string;
|
|
@@ -54,7 +54,7 @@ export declare const getElementConfig: (config: FabConfig) => {
|
|
|
54
54
|
ariaHidden: boolean;
|
|
55
55
|
html: string;
|
|
56
56
|
text: string;
|
|
57
|
-
forwardEvents: Record<string,
|
|
57
|
+
forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
|
|
58
58
|
interactive: boolean;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
@@ -69,14 +69,14 @@ export declare const getElementConfig: (config: FabConfig) => {
|
|
|
69
69
|
* @category Components
|
|
70
70
|
* @internal
|
|
71
71
|
*/
|
|
72
|
-
export declare const getApiConfig: (comp:
|
|
72
|
+
export declare const getApiConfig: (comp: Pick<FabComponent, "disabled" | "lifecycle" | "getClass">) => {
|
|
73
73
|
disabled: {
|
|
74
|
-
enable: () =>
|
|
75
|
-
disable: () =>
|
|
74
|
+
enable: () => void;
|
|
75
|
+
disable: () => void;
|
|
76
76
|
};
|
|
77
77
|
lifecycle: {
|
|
78
|
-
destroy: () =>
|
|
78
|
+
destroy: () => void;
|
|
79
79
|
};
|
|
80
|
-
className:
|
|
80
|
+
className: string;
|
|
81
81
|
};
|
|
82
82
|
export default defaultConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { IconManager } from "../../core/compose/features/icon.js";
|
|
1
2
|
/**
|
|
2
3
|
* FAB variants following Material Design 3 guidelines
|
|
3
4
|
*
|
|
@@ -338,7 +339,7 @@ export interface FabComponent {
|
|
|
338
339
|
*/
|
|
339
340
|
icon: {
|
|
340
341
|
/** Sets the icon HTML content */
|
|
341
|
-
setIcon: (html: string) =>
|
|
342
|
+
setIcon: (html: string) => IconManager;
|
|
342
343
|
/** Gets the current icon HTML content */
|
|
343
344
|
getIcon: () => string;
|
|
344
345
|
/** Gets the icon DOM element */
|
|
@@ -38,7 +38,7 @@ export declare const createBaseConfig: (config?: IconButtonConfig) => IconButton
|
|
|
38
38
|
export declare const getElementConfig: (config: IconButtonConfig) => {
|
|
39
39
|
tag: string;
|
|
40
40
|
componentName: string;
|
|
41
|
-
attributes: Record<string,
|
|
41
|
+
attributes: Record<string, unknown>;
|
|
42
42
|
className: string[];
|
|
43
43
|
rawClass: string | string[];
|
|
44
44
|
id: string;
|
|
@@ -54,7 +54,7 @@ export declare const getElementConfig: (config: IconButtonConfig) => {
|
|
|
54
54
|
ariaHidden: boolean;
|
|
55
55
|
html: string;
|
|
56
56
|
text: string;
|
|
57
|
-
forwardEvents: Record<string,
|
|
57
|
+
forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
|
|
58
58
|
interactive: boolean;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
@@ -33,10 +33,6 @@ export interface ToggleConfig {
|
|
|
33
33
|
* Component name for class generation
|
|
34
34
|
*/
|
|
35
35
|
componentName?: string;
|
|
36
|
-
/**
|
|
37
|
-
* Additional configuration options
|
|
38
|
-
*/
|
|
39
|
-
[key: string]: unknown;
|
|
40
36
|
}
|
|
41
37
|
/**
|
|
42
38
|
* Toggle state manager interface
|
|
@@ -132,5 +128,5 @@ interface ComponentWithIcon extends ElementComponent {
|
|
|
132
128
|
* )(config);
|
|
133
129
|
* ```
|
|
134
130
|
*/
|
|
135
|
-
export declare const withToggle: <T extends ToggleConfig>(config: T) => <C extends ComponentWithIcon>(component: C) => C & ToggleComponent;
|
|
131
|
+
export declare const withToggle: <T extends ToggleConfig & object>(config: T) => <C extends ComponentWithIcon>(component: C) => C & ToggleComponent;
|
|
136
132
|
export {};
|
|
@@ -81,6 +81,12 @@ export interface IconButtonConfig extends BaseComponentConfig {
|
|
|
81
81
|
* @default false
|
|
82
82
|
*/
|
|
83
83
|
selected?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Whether a click flips the selected state of a toggle button. Set to
|
|
86
|
+
* false when a container (button group) owns the selection.
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
toggleOnClick?: boolean;
|
|
84
90
|
/**
|
|
85
91
|
* Additional CSS classes to add to the IconButton
|
|
86
92
|
*/
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* API configuration options for List component
|
|
3
3
|
*/
|
|
4
|
-
interface ApiOptions {
|
|
4
|
+
interface ApiOptions<T = unknown> {
|
|
5
5
|
list: {
|
|
6
6
|
refresh: () => void;
|
|
7
|
-
getItems: () =>
|
|
8
|
-
getAllItems: () =>
|
|
9
|
-
getVisibleItems: () =>
|
|
7
|
+
getItems: () => T[];
|
|
8
|
+
getAllItems: () => T[];
|
|
9
|
+
getVisibleItems: () => T[];
|
|
10
10
|
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => void;
|
|
11
11
|
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => void;
|
|
12
12
|
isLoading: () => boolean;
|
|
13
13
|
hasNextPage: () => boolean;
|
|
14
14
|
};
|
|
15
15
|
selection: {
|
|
16
|
-
getSelectedItems: () =>
|
|
16
|
+
getSelectedItems: () => T[];
|
|
17
17
|
getSelectedItemIds: () => string[];
|
|
18
18
|
isItemSelected: (itemId: string | number) => boolean;
|
|
19
|
-
selectItem: (itemId: string | number) =>
|
|
20
|
-
deselectItem: (itemId: string | number) =>
|
|
21
|
-
clearSelection: () =>
|
|
22
|
-
setSelection: (itemIds: (string | number)[]) =>
|
|
19
|
+
selectItem: (itemId: string | number) => unknown;
|
|
20
|
+
deselectItem: (itemId: string | number) => unknown;
|
|
21
|
+
clearSelection: () => unknown;
|
|
22
|
+
setSelection: (itemIds: (string | number)[]) => unknown;
|
|
23
23
|
};
|
|
24
24
|
events: {
|
|
25
|
-
on: (event: string, handler: Function) =>
|
|
26
|
-
off: (event: string, handler: Function) =>
|
|
25
|
+
on: (event: string, handler: Function) => unknown;
|
|
26
|
+
off: (event: string, handler: Function) => unknown;
|
|
27
27
|
};
|
|
28
28
|
lifecycle: {
|
|
29
29
|
destroy: () => void;
|
|
@@ -35,17 +35,17 @@ interface ApiOptions {
|
|
|
35
35
|
/**
|
|
36
36
|
* Component with required elements and methods for API enhancement
|
|
37
37
|
*/
|
|
38
|
-
interface ComponentWithElements {
|
|
38
|
+
export interface ComponentWithElements {
|
|
39
39
|
element: HTMLElement;
|
|
40
|
-
on?: (event: string, handler: Function) =>
|
|
41
|
-
off?: (event: string, handler: Function) =>
|
|
40
|
+
on?: (event: string, handler: Function) => unknown;
|
|
41
|
+
off?: (event: string, handler: Function) => unknown;
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Enhances a List component with API methods
|
|
45
45
|
* @param {ApiOptions} options - API configuration options
|
|
46
46
|
* @returns {Function} Higher-order function that adds API methods to component
|
|
47
47
|
*/
|
|
48
|
-
export declare const withAPI: ({ list, selection, events, lifecycle, config }: ApiOptions) => (component: ComponentWithElements) => {
|
|
48
|
+
export declare const withAPI: <T = unknown>({ list, selection, events, lifecycle, config }: ApiOptions<T>) => (component: ComponentWithElements) => {
|
|
49
49
|
element: HTMLElement;
|
|
50
50
|
/**
|
|
51
51
|
* Refreshes the list display
|
|
@@ -56,12 +56,12 @@ export declare const withAPI: ({ list, selection, events, lifecycle, config }: A
|
|
|
56
56
|
* Gets all items in the list
|
|
57
57
|
* @returns {Array} All items
|
|
58
58
|
*/
|
|
59
|
-
getAllItems: () =>
|
|
59
|
+
getAllItems: () => T[];
|
|
60
60
|
/**
|
|
61
61
|
* Gets all visible items (same as getAllItems for rendered lists)
|
|
62
62
|
* @returns {Array} Visible items
|
|
63
63
|
*/
|
|
64
|
-
getVisibleItems: () =>
|
|
64
|
+
getVisibleItems: () => T[];
|
|
65
65
|
/**
|
|
66
66
|
* Scrolls to a specific item by ID
|
|
67
67
|
* @param {string|number} itemId - Item ID to scroll to
|
|
@@ -92,7 +92,7 @@ export declare const withAPI: ({ list, selection, events, lifecycle, config }: A
|
|
|
92
92
|
* Gets the currently selected items
|
|
93
93
|
* @returns {Array} Selected items
|
|
94
94
|
*/
|
|
95
|
-
getSelectedItems: () =>
|
|
95
|
+
getSelectedItems: () => T[];
|
|
96
96
|
/**
|
|
97
97
|
* Gets the IDs of currently selected items
|
|
98
98
|
* @returns {Array} Selected item IDs
|
|
@@ -8,7 +8,10 @@ export declare const defaultConfig: Partial<ListConfig>;
|
|
|
8
8
|
* @param {ListConfig} config - User provided configuration
|
|
9
9
|
* @returns {Object} Complete configuration with defaults applied
|
|
10
10
|
*/
|
|
11
|
-
export declare const createBaseConfig: (config?: Partial<ListConfig>) =>
|
|
11
|
+
export declare const createBaseConfig: (config?: Partial<ListConfig>) => Partial<ListConfig<unknown>> & {
|
|
12
|
+
componentName: string;
|
|
13
|
+
prefix: string;
|
|
14
|
+
};
|
|
12
15
|
/**
|
|
13
16
|
* Generates element configuration for the List component
|
|
14
17
|
* @param {Object} config - List configuration
|
|
@@ -17,7 +20,7 @@ export declare const createBaseConfig: (config?: Partial<ListConfig>) => import(
|
|
|
17
20
|
export declare const getElementConfig: (config: any) => {
|
|
18
21
|
tag: string;
|
|
19
22
|
componentName: string;
|
|
20
|
-
attributes: Record<string,
|
|
23
|
+
attributes: Record<string, unknown>;
|
|
21
24
|
className: string[];
|
|
22
25
|
rawClass: string | string[];
|
|
23
26
|
id: string;
|
|
@@ -33,7 +36,7 @@ export declare const getElementConfig: (config: any) => {
|
|
|
33
36
|
ariaHidden: boolean;
|
|
34
37
|
html: string;
|
|
35
38
|
text: string;
|
|
36
|
-
forwardEvents: Record<string,
|
|
39
|
+
forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
|
|
37
40
|
interactive: boolean;
|
|
38
41
|
};
|
|
39
42
|
/**
|
|
@@ -16,13 +16,12 @@ export const createBaseConfig = (config = {}) => {
|
|
|
16
16
|
config.renderItem = (item) => {
|
|
17
17
|
const element = document.createElement("div");
|
|
18
18
|
element.className = "mtrl-list-item";
|
|
19
|
-
element.textContent =
|
|
20
|
-
item.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
String(item);
|
|
19
|
+
element.textContent = String(item.text ||
|
|
20
|
+
item.title ||
|
|
21
|
+
item.headline ||
|
|
22
|
+
item.name ||
|
|
23
|
+
item.id ||
|
|
24
|
+
String(item));
|
|
26
25
|
return element;
|
|
27
26
|
};
|
|
28
27
|
}
|
|
@@ -10,7 +10,7 @@ export const withRenderer = (config) => component => {
|
|
|
10
10
|
listContainer.className = 'mtrl-list-content';
|
|
11
11
|
listContainer.setAttribute('role', 'list');
|
|
12
12
|
component.element.appendChild(listContainer);
|
|
13
|
-
function renderDefaultItem(item
|
|
13
|
+
function renderDefaultItem(item) {
|
|
14
14
|
const element = document.createElement('div');
|
|
15
15
|
element.className = LIST_CLASSES.ITEM;
|
|
16
16
|
element.setAttribute('role', 'listitem');
|
|
@@ -35,7 +35,7 @@ export const withRenderer = (config) => component => {
|
|
|
35
35
|
return;
|
|
36
36
|
const element = userRenderItem
|
|
37
37
|
? userRenderItem(item, index)
|
|
38
|
-
: renderDefaultItem(item
|
|
38
|
+
: renderDefaultItem(item);
|
|
39
39
|
if (!element)
|
|
40
40
|
return;
|
|
41
41
|
if (!element.classList.contains(LIST_CLASSES.ITEM)) {
|
|
@@ -8,5 +8,24 @@
|
|
|
8
8
|
* @param {Object} config - Configuration options for the list
|
|
9
9
|
* @returns {Object} List component instance
|
|
10
10
|
*/
|
|
11
|
-
declare const createList: (config?: {}) =>
|
|
11
|
+
declare const createList: (config?: {}) => {
|
|
12
|
+
element: HTMLElement;
|
|
13
|
+
refresh: () => Promise<import("./api.js").ComponentWithElements>;
|
|
14
|
+
getAllItems: () => unknown[];
|
|
15
|
+
getVisibleItems: () => unknown[];
|
|
16
|
+
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => import("./api.js").ComponentWithElements;
|
|
17
|
+
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => Promise<import("./api.js").ComponentWithElements>;
|
|
18
|
+
isLoading: () => boolean;
|
|
19
|
+
hasNextPage: () => boolean;
|
|
20
|
+
getSelectedItems: () => unknown[];
|
|
21
|
+
getSelectedItemIds: () => string[];
|
|
22
|
+
isItemSelected: (itemId: string | number) => boolean;
|
|
23
|
+
selectItem: (itemId: string | number) => import("./api.js").ComponentWithElements;
|
|
24
|
+
deselectItem: (itemId: string | number) => import("./api.js").ComponentWithElements;
|
|
25
|
+
clearSelection: () => import("./api.js").ComponentWithElements;
|
|
26
|
+
setSelection: (itemIds: (string | number)[]) => import("./api.js").ComponentWithElements;
|
|
27
|
+
on: (event: any, handler: any) => import("./api.js").ComponentWithElements;
|
|
28
|
+
off: (event: any, handler: any) => import("./api.js").ComponentWithElements;
|
|
29
|
+
destroy: () => void;
|
|
30
|
+
};
|
|
12
31
|
export default createList;
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
* Configuration for the List component
|
|
3
3
|
* @interface ListConfig
|
|
4
4
|
*/
|
|
5
|
-
export interface ListConfig {
|
|
5
|
+
export interface ListConfig<T = unknown> {
|
|
6
6
|
/**
|
|
7
7
|
* Static array of items to display
|
|
8
8
|
* @required
|
|
9
9
|
*/
|
|
10
|
-
items:
|
|
10
|
+
items: T[];
|
|
11
11
|
/**
|
|
12
12
|
* Function to render an item
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {T} item - Item to render
|
|
14
14
|
* @param {number} index - Item index in the list
|
|
15
15
|
* @returns {HTMLElement} Rendered DOM element
|
|
16
16
|
*/
|
|
17
|
-
renderItem?: (item:
|
|
17
|
+
renderItem?: (item: T, index: number) => HTMLElement;
|
|
18
18
|
/**
|
|
19
19
|
* Whether to track item selection
|
|
20
20
|
* When true, clicked items will receive a selected class
|
|
@@ -59,11 +59,11 @@ export interface ListConfig {
|
|
|
59
59
|
* Selection event data
|
|
60
60
|
* @interface SelectEvent
|
|
61
61
|
*/
|
|
62
|
-
export interface SelectEvent {
|
|
62
|
+
export interface SelectEvent<T = unknown> {
|
|
63
63
|
/**
|
|
64
64
|
* Selected item data
|
|
65
65
|
*/
|
|
66
|
-
item:
|
|
66
|
+
item: T;
|
|
67
67
|
/**
|
|
68
68
|
* DOM element for the selected item
|
|
69
69
|
*/
|
|
@@ -75,7 +75,7 @@ export interface SelectEvent {
|
|
|
75
75
|
/**
|
|
76
76
|
* Component instance
|
|
77
77
|
*/
|
|
78
|
-
component: ListComponent
|
|
78
|
+
component: ListComponent<T>;
|
|
79
79
|
/**
|
|
80
80
|
* Prevent default behavior
|
|
81
81
|
*/
|
|
@@ -89,11 +89,11 @@ export interface SelectEvent {
|
|
|
89
89
|
* Load event data
|
|
90
90
|
* @interface LoadEvent
|
|
91
91
|
*/
|
|
92
|
-
export interface LoadEvent {
|
|
92
|
+
export interface LoadEvent<T = unknown> {
|
|
93
93
|
/**
|
|
94
94
|
* Loaded items
|
|
95
95
|
*/
|
|
96
|
-
items:
|
|
96
|
+
items: T[];
|
|
97
97
|
/**
|
|
98
98
|
* Whether the list is currently loading
|
|
99
99
|
*/
|
|
@@ -109,7 +109,7 @@ export interface LoadEvent {
|
|
|
109
109
|
/**
|
|
110
110
|
* Component instance
|
|
111
111
|
*/
|
|
112
|
-
component: ListComponent
|
|
112
|
+
component: ListComponent<T>;
|
|
113
113
|
/**
|
|
114
114
|
* Prevent default behavior
|
|
115
115
|
*/
|
|
@@ -123,26 +123,26 @@ export interface LoadEvent {
|
|
|
123
123
|
* List component interface
|
|
124
124
|
* @interface ListComponent
|
|
125
125
|
*/
|
|
126
|
-
export interface ListComponent {
|
|
126
|
+
export interface ListComponent<T = unknown> {
|
|
127
127
|
/**
|
|
128
128
|
* Component's root DOM element
|
|
129
129
|
*/
|
|
130
130
|
element: HTMLElement;
|
|
131
131
|
/**
|
|
132
132
|
* Refreshes the list display
|
|
133
|
-
* @returns {Promise<ListComponent
|
|
133
|
+
* @returns {Promise<ListComponent<T>>} Promise that resolves with component
|
|
134
134
|
*/
|
|
135
|
-
refresh: () => Promise<ListComponent
|
|
135
|
+
refresh: () => Promise<ListComponent<T>>;
|
|
136
136
|
/**
|
|
137
137
|
* Gets all items in the list
|
|
138
|
-
* @returns {
|
|
138
|
+
* @returns {T[]} All items
|
|
139
139
|
*/
|
|
140
|
-
getAllItems: () =>
|
|
140
|
+
getAllItems: () => T[];
|
|
141
141
|
/**
|
|
142
142
|
* Gets all visible items (same as getAllItems for rendered lists)
|
|
143
|
-
* @returns {
|
|
143
|
+
* @returns {T[]} Visible items
|
|
144
144
|
*/
|
|
145
|
-
getVisibleItems: () =>
|
|
145
|
+
getVisibleItems: () => T[];
|
|
146
146
|
/**
|
|
147
147
|
* Scrolls to a specific item by ID
|
|
148
148
|
* @param {string | number} itemId - Item ID to scroll to
|
|
@@ -150,15 +150,15 @@ export interface ListComponent {
|
|
|
150
150
|
* @param {boolean} animate - Whether to animate the scroll
|
|
151
151
|
* @returns {ListComponent} Component instance for chaining
|
|
152
152
|
*/
|
|
153
|
-
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => ListComponent
|
|
153
|
+
scrollToItem: (itemId: string | number, position?: "start" | "center" | "end", animate?: boolean) => ListComponent<T>;
|
|
154
154
|
/**
|
|
155
155
|
* Scroll to a specific index in the list
|
|
156
156
|
* @param {number} index - Index to scroll to (0-based)
|
|
157
157
|
* @param {string} position - Position ('start', 'center', 'end')
|
|
158
158
|
* @param {boolean} animate - Whether to animate the scroll
|
|
159
|
-
* @returns {Promise<ListComponent
|
|
159
|
+
* @returns {Promise<ListComponent<T>>} Promise that resolves when scroll is complete
|
|
160
160
|
*/
|
|
161
|
-
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => Promise<ListComponent
|
|
161
|
+
scrollToIndex: (index: number, position?: "start" | "center" | "end", animate?: boolean) => Promise<ListComponent<T>>;
|
|
162
162
|
/**
|
|
163
163
|
* Checks if the list is currently loading (always false for rendered lists)
|
|
164
164
|
* @returns {boolean} Always false
|
|
@@ -171,9 +171,9 @@ export interface ListComponent {
|
|
|
171
171
|
hasNextPage: () => boolean;
|
|
172
172
|
/**
|
|
173
173
|
* Gets the currently selected items
|
|
174
|
-
* @returns {
|
|
174
|
+
* @returns {T[]} Selected items
|
|
175
175
|
*/
|
|
176
|
-
getSelectedItems: () =>
|
|
176
|
+
getSelectedItems: () => T[];
|
|
177
177
|
/**
|
|
178
178
|
* Gets the IDs of currently selected items
|
|
179
179
|
* @returns {string[]} Selected item IDs
|
|
@@ -190,38 +190,38 @@ export interface ListComponent {
|
|
|
190
190
|
* @param {string | number} itemId - Item ID to select
|
|
191
191
|
* @returns {ListComponent} Component instance for chaining
|
|
192
192
|
*/
|
|
193
|
-
selectItem: (itemId: string | number) => ListComponent
|
|
193
|
+
selectItem: (itemId: string | number) => ListComponent<T>;
|
|
194
194
|
/**
|
|
195
195
|
* Deselects an item
|
|
196
196
|
* @param {string | number} itemId - Item ID to deselect
|
|
197
197
|
* @returns {ListComponent} Component instance for chaining
|
|
198
198
|
*/
|
|
199
|
-
deselectItem: (itemId: string | number) => ListComponent
|
|
199
|
+
deselectItem: (itemId: string | number) => ListComponent<T>;
|
|
200
200
|
/**
|
|
201
201
|
* Clears all selections
|
|
202
202
|
* @returns {ListComponent} Component instance for chaining
|
|
203
203
|
*/
|
|
204
|
-
clearSelection: () => ListComponent
|
|
204
|
+
clearSelection: () => ListComponent<T>;
|
|
205
205
|
/**
|
|
206
206
|
* Sets the selection to the specified item IDs
|
|
207
207
|
* @param {(string | number)[]} itemIds - Item IDs to select
|
|
208
208
|
* @returns {ListComponent} Component instance for chaining
|
|
209
209
|
*/
|
|
210
|
-
setSelection: (itemIds: (string | number)[]) => ListComponent
|
|
210
|
+
setSelection: (itemIds: (string | number)[]) => ListComponent<T>;
|
|
211
211
|
/**
|
|
212
212
|
* Adds an event listener to the list
|
|
213
213
|
* @param {string} event - Event name
|
|
214
214
|
* @param {Function} handler - Event handler
|
|
215
215
|
* @returns {ListComponent} Component instance for chaining
|
|
216
216
|
*/
|
|
217
|
-
on: <
|
|
217
|
+
on: <K extends keyof ListEvents<T>>(event: K, handler: ListEvents<T>[K]) => ListComponent<T>;
|
|
218
218
|
/**
|
|
219
219
|
* Removes an event listener from the list
|
|
220
220
|
* @param {string} event - Event name
|
|
221
221
|
* @param {Function} handler - Event handler
|
|
222
222
|
* @returns {ListComponent} Component instance for chaining
|
|
223
223
|
*/
|
|
224
|
-
off: <
|
|
224
|
+
off: <K extends keyof ListEvents<T>>(event: K, handler: ListEvents<T>[K]) => ListComponent<T>;
|
|
225
225
|
/**
|
|
226
226
|
* Destroys the component and cleans up resources
|
|
227
227
|
*/
|
|
@@ -231,11 +231,11 @@ export interface ListComponent {
|
|
|
231
231
|
* Event handlers for List
|
|
232
232
|
* @interface ListEvents
|
|
233
233
|
*/
|
|
234
|
-
export interface ListEvents {
|
|
235
|
-
select: (event: SelectEvent) => void;
|
|
236
|
-
load: (event: LoadEvent) => void;
|
|
234
|
+
export interface ListEvents<T = unknown> {
|
|
235
|
+
select: (event: SelectEvent<T>) => void;
|
|
236
|
+
load: (event: LoadEvent<T>) => void;
|
|
237
237
|
scroll: (event: {
|
|
238
238
|
originalEvent: Event;
|
|
239
|
-
component: ListComponent
|
|
239
|
+
component: ListComponent<T>;
|
|
240
240
|
}) => void;
|
|
241
241
|
}
|
|
@@ -22,7 +22,7 @@ export declare const clampValue: (value: number | null | undefined) => number |
|
|
|
22
22
|
export declare const getElementConfig: (config: LoadingIndicatorConfig) => {
|
|
23
23
|
tag: string;
|
|
24
24
|
componentName: string;
|
|
25
|
-
attributes: Record<string,
|
|
25
|
+
attributes: Record<string, unknown>;
|
|
26
26
|
className: string[];
|
|
27
27
|
rawClass: string | string[];
|
|
28
28
|
id: string;
|
|
@@ -38,7 +38,7 @@ export declare const getElementConfig: (config: LoadingIndicatorConfig) => {
|
|
|
38
38
|
ariaHidden: boolean;
|
|
39
39
|
html: string;
|
|
40
40
|
text: string;
|
|
41
|
-
forwardEvents: Record<string,
|
|
41
|
+
forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
|
|
42
42
|
interactive: boolean;
|
|
43
43
|
};
|
|
44
44
|
export default defaultConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Renderer } from "./features/renderer.js";
|
|
1
2
|
/**
|
|
2
3
|
* Configuration options for the loading indicator
|
|
3
4
|
* @interface LoadingIndicatorConfig
|
|
@@ -61,5 +62,6 @@ export interface BaseComponent {
|
|
|
61
62
|
lifecycle?: {
|
|
62
63
|
destroy?: () => void;
|
|
63
64
|
};
|
|
64
|
-
|
|
65
|
+
canvas?: HTMLCanvasElement;
|
|
66
|
+
renderer?: Renderer;
|
|
65
67
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { MenuComponent, MenuContent, MenuPosition
|
|
1
|
+
import { MenuComponent, MenuContent, MenuPosition } from "./types.js";
|
|
2
|
+
import type { EventCallback } from "../../core/state/emitter.js";
|
|
2
3
|
/**
|
|
3
4
|
* API configuration options for menu component
|
|
4
5
|
* @category Components
|
|
@@ -26,8 +27,8 @@ interface ApiOptions {
|
|
|
26
27
|
closeAllSubmenus: () => void;
|
|
27
28
|
};
|
|
28
29
|
events?: {
|
|
29
|
-
on:
|
|
30
|
-
off:
|
|
30
|
+
on: (event: string, handler: EventCallback) => void;
|
|
31
|
+
off: (event: string, handler: EventCallback) => void;
|
|
31
32
|
};
|
|
32
33
|
lifecycle: {
|
|
33
34
|
destroy: () => void;
|
|
@@ -40,8 +41,8 @@ interface ApiOptions {
|
|
|
40
41
|
*/
|
|
41
42
|
interface ComponentWithElements {
|
|
42
43
|
element: HTMLElement;
|
|
43
|
-
on?:
|
|
44
|
-
off?:
|
|
44
|
+
on?: (event: string, handler: EventCallback) => unknown;
|
|
45
|
+
off?: (event: string, handler: EventCallback) => unknown;
|
|
45
46
|
emit?: (event: string, data: unknown) => void;
|
|
46
47
|
}
|
|
47
48
|
/**
|
|
@@ -29,7 +29,7 @@ export declare const createBaseConfig: (config: MenuConfig) => MenuConfig;
|
|
|
29
29
|
export declare const getElementConfig: (config: MenuConfig) => {
|
|
30
30
|
tag: string;
|
|
31
31
|
componentName: string;
|
|
32
|
-
attributes: Record<string,
|
|
32
|
+
attributes: Record<string, unknown>;
|
|
33
33
|
className: string[];
|
|
34
34
|
rawClass: string | string[];
|
|
35
35
|
id: string;
|
|
@@ -45,7 +45,7 @@ export declare const getElementConfig: (config: MenuConfig) => {
|
|
|
45
45
|
ariaHidden: boolean;
|
|
46
46
|
html: string;
|
|
47
47
|
text: string;
|
|
48
|
-
forwardEvents: Record<string,
|
|
48
|
+
forwardEvents: Record<string, import("../../core/dom/create.js").EventCondition>;
|
|
49
49
|
interactive: boolean;
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import { MenuItem } from "../types.js";
|
|
1
|
+
import { MenuItem, MenuContent } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Menu state the keyboard handlers read
|
|
4
|
+
*/
|
|
5
|
+
interface KeyboardMenuState {
|
|
6
|
+
items: MenuContent[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Menu actions the keyboard handlers call
|
|
10
|
+
*/
|
|
11
|
+
interface KeyboardActions {
|
|
12
|
+
closeMenu: (event: Event, restoreFocus?: boolean) => void;
|
|
13
|
+
closeSubmenu: (level: number) => void;
|
|
14
|
+
findItemById: (id: string) => MenuItem | null;
|
|
15
|
+
handleSubmenuClick: (item: MenuItem, index: number, itemElement: HTMLElement) => void;
|
|
16
|
+
handleNestedSubmenuClick: (item: MenuItem, index: number, itemElement: HTMLElement) => void;
|
|
17
|
+
}
|
|
2
18
|
/**
|
|
3
19
|
* Keyboard navigation handler for menus
|
|
4
20
|
* Manages focus management and keyboard interactions for accessibility
|
|
@@ -7,14 +23,8 @@ export declare const createKeyboardNavigation: (component: any) => {
|
|
|
7
23
|
destroy: () => void;
|
|
8
24
|
removeKeyboardHandlers: (element: HTMLElement) => void;
|
|
9
25
|
handleInitialFocus: (menuElement: HTMLElement, interactionType: "keyboard" | "mouse") => void;
|
|
10
|
-
handleMenuKeydown: (e: KeyboardEvent, state:
|
|
11
|
-
|
|
12
|
-
closeSubmenu: (level: number) => void;
|
|
13
|
-
findItemById: (id: string) => MenuItem | null;
|
|
14
|
-
handleSubmenuClick: (item: MenuItem, index: number, itemElement: HTMLElement) => void;
|
|
15
|
-
handleNestedSubmenuClick: (item: MenuItem, index: number, itemElement: HTMLElement) => void;
|
|
16
|
-
}) => void;
|
|
17
|
-
setupKeyboardHandlers: (menuElement: HTMLElement, state: any, actions: any) => void;
|
|
26
|
+
handleMenuKeydown: (e: KeyboardEvent, state: KeyboardMenuState, actions: KeyboardActions) => void;
|
|
27
|
+
setupKeyboardHandlers: (menuElement: HTMLElement, state: KeyboardMenuState, actions: KeyboardActions) => void;
|
|
18
28
|
isTabNavigationActive: () => boolean;
|
|
19
29
|
getFocusableElements: () => HTMLElement[];
|
|
20
30
|
resetTypeahead: () => void;
|