mtrl 0.2.5 → 0.2.7
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/index.ts +18 -0
- package/package.json +1 -1
- package/src/components/badge/_styles.scss +123 -115
- package/src/components/badge/api.ts +57 -59
- package/src/components/badge/badge.ts +16 -2
- package/src/components/badge/config.ts +65 -11
- package/src/components/badge/constants.ts +22 -12
- package/src/components/badge/features.ts +44 -40
- package/src/components/badge/types.ts +42 -30
- package/src/components/bottom-app-bar/_styles.scss +103 -0
- package/src/components/bottom-app-bar/bottom-app-bar.ts +196 -0
- package/src/components/bottom-app-bar/config.ts +73 -0
- package/src/components/bottom-app-bar/index.ts +11 -0
- package/src/components/bottom-app-bar/types.ts +108 -0
- package/src/components/button/_styles.scss +0 -66
- package/src/components/button/api.ts +5 -0
- package/src/components/button/button.ts +0 -2
- package/src/components/button/config.ts +5 -0
- package/src/components/button/constants.ts +0 -6
- package/src/components/button/index.ts +2 -2
- package/src/components/button/types.ts +7 -7
- package/src/components/card/_styles.scss +67 -25
- package/src/components/card/api.ts +54 -3
- package/src/components/card/card.ts +25 -6
- package/src/components/card/config.ts +189 -22
- package/src/components/card/constants.ts +20 -19
- package/src/components/card/content.ts +299 -2
- package/src/components/card/features.ts +158 -4
- package/src/components/card/index.ts +31 -9
- package/src/components/card/types.ts +166 -15
- package/src/components/checkbox/_styles.scss +0 -2
- package/src/components/chip/chip.ts +1 -9
- package/src/components/chip/constants.ts +0 -10
- package/src/components/chip/index.ts +1 -1
- package/src/components/chip/types.ts +1 -4
- package/src/components/datepicker/_styles.scss +358 -0
- package/src/components/datepicker/api.ts +272 -0
- package/src/components/datepicker/config.ts +144 -0
- package/src/components/datepicker/constants.ts +98 -0
- package/src/components/datepicker/datepicker.ts +346 -0
- package/src/components/datepicker/index.ts +9 -0
- package/src/components/datepicker/render.ts +452 -0
- package/src/components/datepicker/types.ts +268 -0
- package/src/components/datepicker/utils.ts +290 -0
- package/src/components/dialog/_styles.scss +174 -128
- package/src/components/dialog/api.ts +48 -13
- package/src/components/dialog/config.ts +9 -5
- package/src/components/dialog/dialog.ts +6 -3
- package/src/components/dialog/features.ts +290 -130
- package/src/components/dialog/types.ts +7 -4
- package/src/components/divider/_styles.scss +57 -0
- package/src/components/divider/config.ts +81 -0
- package/src/components/divider/divider.ts +37 -0
- package/src/components/divider/features.ts +207 -0
- package/src/components/divider/index.ts +5 -0
- package/src/components/divider/types.ts +55 -0
- package/src/components/extended-fab/_styles.scss +267 -0
- package/src/components/extended-fab/api.ts +141 -0
- package/src/components/extended-fab/config.ts +108 -0
- package/src/components/extended-fab/constants.ts +36 -0
- package/src/components/extended-fab/extended-fab.ts +125 -0
- package/src/components/extended-fab/index.ts +4 -0
- package/src/components/extended-fab/types.ts +287 -0
- package/src/components/fab/_styles.scss +225 -0
- package/src/components/fab/api.ts +97 -0
- package/src/components/fab/config.ts +94 -0
- package/src/components/fab/constants.ts +41 -0
- package/src/components/fab/fab.ts +67 -0
- package/src/components/fab/index.ts +4 -0
- package/src/components/fab/types.ts +234 -0
- package/src/components/navigation/_styles.scss +1 -0
- package/src/components/navigation/api.ts +78 -50
- package/src/components/navigation/features/items.ts +280 -0
- package/src/components/navigation/nav-item.ts +72 -23
- package/src/components/navigation/navigation.ts +54 -2
- package/src/components/navigation/types.ts +210 -188
- package/src/components/progress/_styles.scss +0 -65
- package/src/components/progress/config.ts +1 -2
- package/src/components/progress/constants.ts +0 -14
- package/src/components/progress/index.ts +1 -1
- package/src/components/progress/progress.ts +1 -4
- package/src/components/progress/types.ts +1 -4
- package/src/components/radios/_styles.scss +0 -45
- package/src/components/radios/api.ts +85 -60
- package/src/components/radios/config.ts +1 -2
- package/src/components/radios/constants.ts +0 -9
- package/src/components/radios/index.ts +1 -1
- package/src/components/radios/radio.ts +34 -11
- package/src/components/radios/radios.ts +2 -1
- package/src/components/radios/types.ts +1 -7
- package/src/components/search/_styles.scss +306 -0
- package/src/components/search/api.ts +203 -0
- package/src/components/search/config.ts +87 -0
- package/src/components/search/constants.ts +21 -0
- package/src/components/search/features/index.ts +4 -0
- package/src/components/search/features/search.ts +718 -0
- package/src/components/search/features/states.ts +165 -0
- package/src/components/search/features/structure.ts +198 -0
- package/src/components/search/index.ts +10 -0
- package/src/components/search/search.ts +52 -0
- package/src/components/search/types.ts +163 -0
- package/src/components/segmented-button/_styles.scss +117 -0
- package/src/components/segmented-button/config.ts +67 -0
- package/src/components/segmented-button/constants.ts +42 -0
- package/src/components/segmented-button/index.ts +4 -0
- package/src/components/segmented-button/segment.ts +155 -0
- package/src/components/segmented-button/segmented-button.ts +250 -0
- package/src/components/segmented-button/types.ts +219 -0
- package/src/components/slider/_styles.scss +221 -168
- package/src/components/slider/accessibility.md +59 -0
- package/src/components/slider/api.ts +41 -120
- package/src/components/slider/config.ts +51 -49
- package/src/components/slider/features/handlers.ts +495 -0
- package/src/components/slider/features/index.ts +1 -2
- package/src/components/slider/features/slider.ts +66 -84
- package/src/components/slider/features/states.ts +195 -0
- package/src/components/slider/features/structure.ts +141 -184
- package/src/components/slider/features/ui.ts +150 -201
- package/src/components/slider/index.ts +2 -11
- package/src/components/slider/slider.ts +9 -12
- package/src/components/slider/types.ts +39 -24
- package/src/components/switch/_styles.scss +0 -2
- package/src/components/tabs/_styles.scss +346 -154
- package/src/components/tabs/api.ts +178 -400
- package/src/components/tabs/config.ts +46 -52
- package/src/components/tabs/constants.ts +85 -8
- package/src/components/tabs/features.ts +403 -0
- package/src/components/tabs/index.ts +60 -3
- package/src/components/tabs/indicator.ts +285 -0
- package/src/components/tabs/responsive.ts +144 -0
- package/src/components/tabs/scroll-indicators.ts +149 -0
- package/src/components/tabs/state.ts +186 -0
- package/src/components/tabs/tab-api.ts +258 -0
- package/src/components/tabs/tab.ts +255 -0
- package/src/components/tabs/tabs.ts +50 -31
- package/src/components/tabs/types.ts +332 -128
- package/src/components/tabs/utils.ts +107 -0
- package/src/components/textfield/_styles.scss +0 -98
- package/src/components/textfield/config.ts +2 -3
- package/src/components/textfield/constants.ts +0 -14
- package/src/components/textfield/index.ts +2 -2
- package/src/components/textfield/textfield.ts +0 -2
- package/src/components/textfield/types.ts +1 -4
- package/src/components/timepicker/README.md +277 -0
- package/src/components/timepicker/_styles.scss +451 -0
- package/src/components/timepicker/api.ts +632 -0
- package/src/components/timepicker/clockdial.ts +482 -0
- package/src/components/timepicker/config.ts +130 -0
- package/src/components/timepicker/constants.ts +138 -0
- package/src/components/timepicker/index.ts +8 -0
- package/src/components/timepicker/render.ts +613 -0
- package/src/components/timepicker/timepicker.ts +117 -0
- package/src/components/timepicker/types.ts +336 -0
- package/src/components/timepicker/utils.ts +241 -0
- package/src/components/top-app-bar/_styles.scss +225 -0
- package/src/components/top-app-bar/config.ts +83 -0
- package/src/components/top-app-bar/index.ts +11 -0
- package/src/components/top-app-bar/top-app-bar.ts +316 -0
- package/src/components/top-app-bar/types.ts +140 -0
- package/src/core/build/_ripple.scss +6 -6
- package/src/core/build/ripple.ts +72 -95
- package/src/core/compose/component.ts +1 -1
- package/src/core/compose/features/badge.ts +79 -0
- package/src/core/compose/features/icon.ts +3 -1
- package/src/core/compose/features/index.ts +3 -1
- package/src/core/compose/features/ripple.ts +4 -1
- package/src/core/compose/features/textlabel.ts +26 -2
- package/src/core/dom/create.ts +5 -0
- package/src/index.ts +9 -0
- package/src/styles/abstract/_theme.scss +115 -3
- package/src/styles/themes/_autumn.scss +21 -0
- package/src/styles/themes/_base-theme.scss +61 -0
- package/src/styles/themes/_baseline.scss +58 -0
- package/src/styles/themes/_bluekhaki.scss +125 -0
- package/src/styles/themes/_brownbeige.scss +125 -0
- package/src/styles/themes/_browngreen.scss +125 -0
- package/src/styles/themes/_forest.scss +6 -0
- package/src/styles/themes/_greenbeige.scss +125 -0
- package/src/styles/themes/_material.scss +125 -0
- package/src/styles/themes/_ocean.scss +6 -0
- package/src/styles/themes/_sageivory.scss +125 -0
- package/src/styles/themes/_spring.scss +6 -0
- package/src/styles/themes/_summer.scss +5 -0
- package/src/styles/themes/_sunset.scss +5 -0
- package/src/styles/themes/_tealcaramel.scss +125 -0
- package/src/styles/themes/_winter.scss +6 -0
- package/src/components/card/actions.ts +0 -48
- package/src/components/card/header.ts +0 -88
- package/src/components/card/media.ts +0 -52
- package/src/components/navigation/features/items.js +0 -192
- package/src/components/slider/features/appearance.ts +0 -94
- package/src/components/slider/features/disabled.ts +0 -43
- package/src/components/slider/features/events.ts +0 -164
- package/src/components/slider/features/interactions.ts +0 -261
- package/src/components/slider/features/keyboard.ts +0 -112
- package/src/core/collection/adapters/mongodb.js +0 -232
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
// src/components/navigation/nav-item.ts
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
// Simple interface for NavItemConfig if not imported
|
|
4
|
+
interface NavItemConfig {
|
|
5
|
+
id: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
label?: string;
|
|
8
|
+
badge?: string;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
active?: boolean;
|
|
11
|
+
expanded?: boolean;
|
|
12
|
+
items?: NavItemConfig[];
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
3
15
|
|
|
4
16
|
/**
|
|
5
17
|
* Creates an expand/collapse icon element
|
|
@@ -31,7 +43,9 @@ export const createNestedContainer = (
|
|
|
31
43
|
): HTMLElement => {
|
|
32
44
|
const container = document.createElement('div');
|
|
33
45
|
container.className = `${prefix}-nav-nested-container`;
|
|
34
|
-
|
|
46
|
+
|
|
47
|
+
// Use appropriate role for nested menu
|
|
48
|
+
container.setAttribute('role', 'menu');
|
|
35
49
|
container.hidden = true;
|
|
36
50
|
|
|
37
51
|
items.forEach(itemConfig => {
|
|
@@ -56,18 +70,45 @@ export const createNavItem = (
|
|
|
56
70
|
const itemContainer = document.createElement('div');
|
|
57
71
|
itemContainer.className = `${prefix}-nav-item-container`;
|
|
58
72
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
73
|
+
// Determine if parent container uses tabs or menu role pattern
|
|
74
|
+
const isMenuContext = container.getAttribute('role') === 'menu';
|
|
75
|
+
const isTabContext = container.getAttribute('role') === 'tablist';
|
|
76
|
+
const isDrawerVariant = container.closest(`.${prefix}-nav--drawer, .${prefix}-nav--drawer-modal, .${prefix}-nav--drawer-standard`) !== null;
|
|
77
|
+
|
|
78
|
+
// Create the item element
|
|
79
|
+
const itemElement = document.createElement('button');
|
|
80
|
+
itemElement.className = `${prefix}-nav-item`;
|
|
81
|
+
itemElement.type = 'button'; // Ensure it's a button type for proper behavior
|
|
82
|
+
|
|
83
|
+
// Set appropriate role based on context and items
|
|
84
|
+
if (config.items?.length) {
|
|
85
|
+
if (isDrawerVariant) {
|
|
86
|
+
// For expandable drawer items with nested items
|
|
87
|
+
itemElement.setAttribute('role', 'button');
|
|
88
|
+
itemElement.setAttribute('aria-expanded', config.expanded ? 'true' : 'false');
|
|
89
|
+
itemElement.setAttribute('aria-haspopup', 'menu');
|
|
90
|
+
} else {
|
|
91
|
+
// For non-drawer variants with nested items
|
|
92
|
+
itemElement.setAttribute('role', 'button');
|
|
93
|
+
}
|
|
94
|
+
} else if (isMenuContext) {
|
|
95
|
+
// For menu items
|
|
96
|
+
itemElement.setAttribute('role', 'menuitem');
|
|
97
|
+
} else if (isTabContext) {
|
|
98
|
+
// For tab items
|
|
99
|
+
itemElement.setAttribute('role', 'tab');
|
|
100
|
+
itemElement.setAttribute('aria-selected', config.active ? 'true' : 'false');
|
|
101
|
+
itemElement.setAttribute('tabindex', config.active ? '0' : '-1');
|
|
102
|
+
}
|
|
103
|
+
// For plain navigation buttons, we don't need to set the role since buttons have inherent semantics
|
|
63
104
|
|
|
64
105
|
if (config.id) {
|
|
65
|
-
|
|
106
|
+
itemElement.dataset.id = config.id;
|
|
66
107
|
}
|
|
67
108
|
|
|
68
109
|
if (config.disabled) {
|
|
69
|
-
|
|
70
|
-
|
|
110
|
+
itemElement.disabled = true;
|
|
111
|
+
itemElement.setAttribute('aria-disabled', 'true');
|
|
71
112
|
}
|
|
72
113
|
|
|
73
114
|
// Add icon if provided
|
|
@@ -75,7 +116,7 @@ export const createNavItem = (
|
|
|
75
116
|
const icon = document.createElement('span');
|
|
76
117
|
icon.className = `${prefix}-nav-item-icon`;
|
|
77
118
|
icon.innerHTML = config.icon;
|
|
78
|
-
|
|
119
|
+
itemElement.appendChild(icon);
|
|
79
120
|
}
|
|
80
121
|
|
|
81
122
|
// Add label if provided
|
|
@@ -83,8 +124,8 @@ export const createNavItem = (
|
|
|
83
124
|
const label = document.createElement('span');
|
|
84
125
|
label.className = `${prefix}-nav-item-label`;
|
|
85
126
|
label.textContent = config.label;
|
|
86
|
-
|
|
87
|
-
|
|
127
|
+
itemElement.appendChild(label);
|
|
128
|
+
itemElement.setAttribute('aria-label', config.label);
|
|
88
129
|
}
|
|
89
130
|
|
|
90
131
|
// Add badge if provided
|
|
@@ -92,29 +133,37 @@ export const createNavItem = (
|
|
|
92
133
|
const badge = document.createElement('span');
|
|
93
134
|
badge.className = `${prefix}-nav-item-badge`;
|
|
94
135
|
badge.textContent = config.badge;
|
|
136
|
+
// Use appropriate aria labeling
|
|
95
137
|
badge.setAttribute('aria-label', `${config.badge} notifications`);
|
|
96
|
-
|
|
138
|
+
itemElement.appendChild(badge);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Mark active state with appropriate semantics
|
|
142
|
+
if (config.active && !config.items?.length) {
|
|
143
|
+
itemElement.classList.add(`${prefix}-nav-item--active`);
|
|
144
|
+
|
|
145
|
+
// Use aria-current for standard navigation
|
|
146
|
+
if (!isTabContext) {
|
|
147
|
+
itemElement.setAttribute('aria-current', 'page');
|
|
148
|
+
}
|
|
97
149
|
}
|
|
98
150
|
|
|
99
|
-
itemContainer.appendChild(
|
|
151
|
+
itemContainer.appendChild(itemElement);
|
|
100
152
|
|
|
101
153
|
// Handle nested items - only for drawer variant
|
|
102
|
-
if (config.items?.length &&
|
|
154
|
+
if (config.items?.length && isDrawerVariant) {
|
|
103
155
|
const expandIcon = createExpandIcon(prefix);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
item.setAttribute('aria-expanded', config.expanded ? 'true' : 'false');
|
|
107
|
-
item.setAttribute('aria-haspopup', 'true');
|
|
156
|
+
itemElement.appendChild(expandIcon);
|
|
108
157
|
|
|
109
158
|
const nestedContainer = createNestedContainer(config.items, prefix, createNavItem);
|
|
110
159
|
nestedContainer.hidden = !config.expanded;
|
|
111
160
|
itemContainer.appendChild(nestedContainer);
|
|
112
161
|
|
|
113
162
|
// Handle expand/collapse
|
|
114
|
-
|
|
163
|
+
itemElement.addEventListener('click', (event) => {
|
|
115
164
|
event.stopPropagation();
|
|
116
|
-
const isExpanded =
|
|
117
|
-
|
|
165
|
+
const isExpanded = itemElement.getAttribute('aria-expanded') === 'true';
|
|
166
|
+
itemElement.setAttribute('aria-expanded', (!isExpanded).toString());
|
|
118
167
|
nestedContainer.hidden = isExpanded;
|
|
119
168
|
|
|
120
169
|
// Toggle expand icon rotation
|
|
@@ -125,7 +174,7 @@ export const createNavItem = (
|
|
|
125
174
|
}
|
|
126
175
|
|
|
127
176
|
container.appendChild(itemContainer);
|
|
128
|
-
return
|
|
177
|
+
return itemElement;
|
|
129
178
|
};
|
|
130
179
|
|
|
131
180
|
/**
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
withDisabled,
|
|
7
7
|
withLifecycle,
|
|
8
8
|
withVariant,
|
|
9
|
-
withPosition
|
|
9
|
+
withPosition
|
|
10
10
|
} from '../../core/compose/features';
|
|
11
11
|
import { withAPI } from './api';
|
|
12
12
|
import { withNavItems } from './features/items';
|
|
@@ -16,6 +16,48 @@ import {
|
|
|
16
16
|
getElementConfig,
|
|
17
17
|
getApiConfig
|
|
18
18
|
} from './config';
|
|
19
|
+
import { NAV_VARIANTS } from './constants';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Sets up proper ARIA roles based on navigation variant
|
|
23
|
+
* @param {NavigationComponent} nav - Navigation component
|
|
24
|
+
* @param {NavigationConfig} config - Navigation configuration
|
|
25
|
+
*/
|
|
26
|
+
const setupAccessibility = (nav: NavigationComponent, config: NavigationConfig): void => {
|
|
27
|
+
const { element } = nav;
|
|
28
|
+
const variant = config.variant || 'rail';
|
|
29
|
+
const prefix = config.prefix || 'mtrl';
|
|
30
|
+
|
|
31
|
+
// Set appropriate aria-label
|
|
32
|
+
element.setAttribute('aria-label', config.ariaLabel || 'Main Navigation');
|
|
33
|
+
|
|
34
|
+
// For bar navigation (bottom or top nav)
|
|
35
|
+
if (variant === NAV_VARIANTS.BAR) {
|
|
36
|
+
// If bar navigation is acting as tabs
|
|
37
|
+
const hasNestedItems = config.items?.some(item => item.items?.length) || false;
|
|
38
|
+
|
|
39
|
+
if (!hasNestedItems) {
|
|
40
|
+
element.setAttribute('role', 'tablist');
|
|
41
|
+
element.setAttribute('aria-orientation', 'horizontal');
|
|
42
|
+
} else {
|
|
43
|
+
element.setAttribute('role', 'menubar');
|
|
44
|
+
element.setAttribute('aria-orientation', 'horizontal');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// For rail and drawer navigation
|
|
48
|
+
else {
|
|
49
|
+
// Use standard navigation landmark
|
|
50
|
+
element.setAttribute('role', 'navigation');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Set hidden state for modal drawers if needed
|
|
54
|
+
if ((variant === NAV_VARIANTS.DRAWER_MODAL ||
|
|
55
|
+
variant === 'modal' ||
|
|
56
|
+
(variant === NAV_VARIANTS.DRAWER && config.behavior === 'dismissible')) &&
|
|
57
|
+
!config.expanded) {
|
|
58
|
+
element.classList.add(`${prefix}-nav--hidden`);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
19
61
|
|
|
20
62
|
/**
|
|
21
63
|
* Creates a new Navigation component
|
|
@@ -40,7 +82,17 @@ const createNavigation = (config: NavigationConfig = {}): NavigationComponent =>
|
|
|
40
82
|
comp => withAPI(getApiConfig(comp))(comp)
|
|
41
83
|
)(baseConfig);
|
|
42
84
|
|
|
43
|
-
|
|
85
|
+
const nav = navigation as NavigationComponent;
|
|
86
|
+
|
|
87
|
+
// Set up proper ARIA roles and relationships
|
|
88
|
+
setupAccessibility(nav, baseConfig);
|
|
89
|
+
|
|
90
|
+
// Implement any initialization logic
|
|
91
|
+
if (baseConfig.disabled) {
|
|
92
|
+
nav.disable();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return nav;
|
|
44
96
|
} catch (error) {
|
|
45
97
|
console.error('Navigation creation error:', error instanceof Error ? error.message : String(error));
|
|
46
98
|
throw new Error(`Failed to create navigation: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -1,212 +1,234 @@
|
|
|
1
|
-
// src/components/
|
|
2
|
-
import {
|
|
3
|
-
NAV_VARIANTS,
|
|
4
|
-
NAV_POSITIONS,
|
|
5
|
-
NAV_BEHAVIORS
|
|
6
|
-
} from './constants';
|
|
1
|
+
// src/components/button/types.ts
|
|
2
|
+
import { BUTTON_VARIANTS } from './constants';
|
|
7
3
|
|
|
8
4
|
/**
|
|
9
|
-
*
|
|
5
|
+
* Configuration interface for the Button component
|
|
6
|
+
* @category Components
|
|
10
7
|
*/
|
|
11
|
-
export interface
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
badge?: string;
|
|
23
|
-
|
|
24
|
-
/** Whether the item is disabled */
|
|
8
|
+
export interface ButtonConfig {
|
|
9
|
+
/**
|
|
10
|
+
* Button variant that determines visual styling
|
|
11
|
+
* @default 'filled'
|
|
12
|
+
*/
|
|
13
|
+
variant?: keyof typeof BUTTON_VARIANTS | string;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Whether the button is initially disabled
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
25
19
|
disabled?: boolean;
|
|
26
20
|
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/** Group title text */
|
|
51
|
-
title: string;
|
|
52
|
-
|
|
53
|
-
/** Whether the group is expanded */
|
|
54
|
-
expanded?: boolean;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Stored item data
|
|
59
|
-
*/
|
|
60
|
-
export interface NavItemData {
|
|
61
|
-
/** DOM element for the item */
|
|
62
|
-
element: HTMLElement;
|
|
63
|
-
|
|
64
|
-
/** Item configuration */
|
|
65
|
-
config: NavItemConfig;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Navigation change event data
|
|
70
|
-
*/
|
|
71
|
-
export interface NavChangeEvent {
|
|
72
|
-
/** ID of the active item */
|
|
73
|
-
id: string;
|
|
74
|
-
|
|
75
|
-
/** Item data */
|
|
76
|
-
item: NavItemData;
|
|
77
|
-
|
|
78
|
-
/** Previously active item */
|
|
79
|
-
previousItem: NavItemData | null;
|
|
21
|
+
/**
|
|
22
|
+
* Initial button text content
|
|
23
|
+
* @example 'Submit'
|
|
24
|
+
*/
|
|
25
|
+
text?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Initial button icon HTML content
|
|
29
|
+
* @example '<svg>...</svg>'
|
|
30
|
+
*/
|
|
31
|
+
icon?: string;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Icon size in pixels or other CSS units
|
|
35
|
+
* @example '18px'
|
|
36
|
+
*/
|
|
37
|
+
iconSize?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Additional CSS classes to add to the button
|
|
41
|
+
* @example 'form-submit header-action'
|
|
42
|
+
*/
|
|
43
|
+
class?: string;
|
|
80
44
|
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Button value attribute
|
|
47
|
+
*/
|
|
48
|
+
value?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Button type attribute
|
|
52
|
+
* @default 'button'
|
|
53
|
+
*/
|
|
54
|
+
type?: 'button' | 'submit' | 'reset';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Whether to enable ripple effect
|
|
58
|
+
* @default true
|
|
59
|
+
*/
|
|
60
|
+
ripple?: boolean;
|
|
84
61
|
|
|
85
|
-
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
variant?: keyof typeof NAV_VARIANTS | string;
|
|
91
|
-
|
|
92
|
-
/** Navigation position */
|
|
93
|
-
position?: keyof typeof NAV_POSITIONS | string;
|
|
94
|
-
|
|
95
|
-
/** Navigation behavior */
|
|
96
|
-
behavior?: keyof typeof NAV_BEHAVIORS | string;
|
|
97
|
-
|
|
98
|
-
/** Initial navigation items */
|
|
99
|
-
items?: NavItemConfig[];
|
|
100
|
-
|
|
101
|
-
/** Navigation groups */
|
|
102
|
-
groups?: NavGroupConfig[];
|
|
103
|
-
|
|
104
|
-
/** Whether the navigation is disabled */
|
|
105
|
-
disabled?: boolean;
|
|
106
|
-
|
|
107
|
-
/** Whether drawer is initially expanded */
|
|
108
|
-
expanded?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Component prefix for class names
|
|
64
|
+
* @default 'mtrl'
|
|
65
|
+
*/
|
|
66
|
+
prefix?: string;
|
|
109
67
|
|
|
110
|
-
/**
|
|
111
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Component name used in class generation
|
|
70
|
+
*/
|
|
71
|
+
componentName?: string;
|
|
112
72
|
|
|
113
|
-
/**
|
|
114
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Ripple effect configuration
|
|
75
|
+
*/
|
|
76
|
+
rippleConfig?: {
|
|
77
|
+
/** Duration of the ripple animation in milliseconds */
|
|
78
|
+
duration?: number;
|
|
79
|
+
/** Timing function for the ripple animation */
|
|
80
|
+
timing?: string;
|
|
81
|
+
/** Opacity values for ripple start and end [start, end] */
|
|
82
|
+
opacity?: [string, string];
|
|
83
|
+
};
|
|
115
84
|
|
|
116
|
-
/**
|
|
85
|
+
/**
|
|
86
|
+
* Accessible name for the button (aria-label)
|
|
87
|
+
* Required for icon-only buttons without text
|
|
88
|
+
*/
|
|
117
89
|
ariaLabel?: string;
|
|
118
90
|
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
/** Component name */
|
|
126
|
-
componentName?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Descriptive name for the button
|
|
93
|
+
* Used to derive an accessible name for icon-only buttons
|
|
94
|
+
*/
|
|
95
|
+
name?: string;
|
|
127
96
|
}
|
|
128
97
|
|
|
129
98
|
/**
|
|
130
|
-
*
|
|
99
|
+
* Button component interface
|
|
100
|
+
* @category Components
|
|
131
101
|
*/
|
|
132
|
-
export interface
|
|
133
|
-
/** The
|
|
134
|
-
element:
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
/** Removes a navigation item by ID */
|
|
143
|
-
removeItem: (id: string) => NavigationComponent;
|
|
144
|
-
|
|
145
|
-
/** Retrieves a navigation item by ID */
|
|
146
|
-
getItem: (id: string) => NavItemData | undefined;
|
|
147
|
-
|
|
148
|
-
/** Retrieves all navigation items */
|
|
149
|
-
getAllItems: () => NavItemData[];
|
|
150
|
-
|
|
151
|
-
/** Gets the currently active item */
|
|
152
|
-
getActive: () => NavItemData | null;
|
|
153
|
-
|
|
154
|
-
/** Gets the path to an item (parent IDs) */
|
|
155
|
-
getItemPath: (id: string) => string[];
|
|
156
|
-
|
|
157
|
-
/** Sets an item as active by ID */
|
|
158
|
-
setActive: (id: string) => NavigationComponent;
|
|
159
|
-
|
|
160
|
-
/** Adds event listener */
|
|
161
|
-
on: (event: string, handler: Function) => NavigationComponent;
|
|
162
|
-
|
|
163
|
-
/** Removes event listener */
|
|
164
|
-
off: (event: string, handler: Function) => NavigationComponent;
|
|
165
|
-
|
|
166
|
-
/** Enables the navigation */
|
|
167
|
-
enable: () => NavigationComponent;
|
|
102
|
+
export interface ButtonComponent {
|
|
103
|
+
/** The button's DOM element */
|
|
104
|
+
element: HTMLButtonElement;
|
|
105
|
+
|
|
106
|
+
/** API for managing button text */
|
|
107
|
+
text: {
|
|
108
|
+
setText: (content: string) => any;
|
|
109
|
+
getText: () => string;
|
|
110
|
+
getElement: () => HTMLElement | null;
|
|
111
|
+
};
|
|
168
112
|
|
|
169
|
-
/**
|
|
170
|
-
|
|
113
|
+
/** API for managing button icons */
|
|
114
|
+
icon: {
|
|
115
|
+
setIcon: (html: string) => any;
|
|
116
|
+
getIcon: () => string;
|
|
117
|
+
getElement: () => HTMLElement | null;
|
|
118
|
+
};
|
|
171
119
|
|
|
172
|
-
/**
|
|
173
|
-
destroy: () => void;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
/**
|
|
177
|
-
* API options interface
|
|
178
|
-
*/
|
|
179
|
-
export interface ApiOptions {
|
|
120
|
+
/** API for managing disabled state */
|
|
180
121
|
disabled: {
|
|
181
|
-
|
|
182
|
-
|
|
122
|
+
/** Enables the button */
|
|
123
|
+
enable: () => void;
|
|
124
|
+
/** Disables the button */
|
|
125
|
+
disable: () => void;
|
|
126
|
+
/** Checks if the button is disabled */
|
|
127
|
+
isDisabled: () => boolean;
|
|
183
128
|
};
|
|
129
|
+
|
|
130
|
+
/** API for managing component lifecycle */
|
|
184
131
|
lifecycle: {
|
|
132
|
+
/** Destroys the component and cleans up resources */
|
|
185
133
|
destroy: () => void;
|
|
186
134
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Gets a class name with the component's prefix
|
|
138
|
+
* @param name - Base class name
|
|
139
|
+
* @returns Prefixed class name
|
|
140
|
+
*/
|
|
141
|
+
getClass: (name: string) => string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Gets the button's value attribute
|
|
145
|
+
* @returns Button value
|
|
146
|
+
*/
|
|
147
|
+
getValue: () => string;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Sets the button's value attribute
|
|
151
|
+
* @param value - New value
|
|
152
|
+
* @returns The button component for chaining
|
|
153
|
+
*/
|
|
154
|
+
setValue: (value: string) => ButtonComponent;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Enables the button (removes disabled attribute)
|
|
158
|
+
* @returns The button component for chaining
|
|
159
|
+
*/
|
|
160
|
+
enable: () => ButtonComponent;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Disables the button (adds disabled attribute)
|
|
164
|
+
* @returns The button component for chaining
|
|
165
|
+
*/
|
|
166
|
+
disable: () => ButtonComponent;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Sets the button's text content
|
|
170
|
+
* @param content - Text content
|
|
171
|
+
* @returns The button component for chaining
|
|
172
|
+
*/
|
|
173
|
+
setText: (content: string) => ButtonComponent;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Gets the button's text content
|
|
177
|
+
* @returns Button text content
|
|
178
|
+
*/
|
|
179
|
+
getText: () => string;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Sets the button's icon
|
|
183
|
+
* @param icon - Icon HTML content
|
|
184
|
+
* @returns The button component for chaining
|
|
185
|
+
*/
|
|
186
|
+
setIcon: (icon: string) => ButtonComponent;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Gets the button's icon HTML content
|
|
190
|
+
* @returns Icon HTML
|
|
191
|
+
*/
|
|
192
|
+
getIcon: () => string;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Sets the accessible name (aria-label) for the button
|
|
196
|
+
* @param label - Accessible name
|
|
197
|
+
* @returns The button component for chaining
|
|
198
|
+
*/
|
|
199
|
+
setAriaLabel: (label: string) => ButtonComponent;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Destroys the button component and cleans up resources
|
|
203
|
+
*/
|
|
204
|
+
destroy: () => void;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Updates the button's circular style based on content
|
|
208
|
+
* Internal method used when changing content
|
|
209
|
+
*/
|
|
210
|
+
updateCircularStyle: () => void;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Adds an event listener to the button
|
|
214
|
+
* @param event - Event name ('click', 'focus', etc.)
|
|
215
|
+
* @param handler - Event handler function
|
|
216
|
+
* @returns The button component for chaining
|
|
217
|
+
*/
|
|
218
|
+
on: (event: string, handler: Function) => ButtonComponent;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Removes an event listener from the button
|
|
222
|
+
* @param event - Event name
|
|
223
|
+
* @param handler - Event handler function
|
|
224
|
+
* @returns The button component for chaining
|
|
225
|
+
*/
|
|
226
|
+
off: (event: string, handler: Function) => ButtonComponent;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Adds CSS classes to the button element
|
|
230
|
+
* @param classes - One or more class names to add
|
|
231
|
+
* @returns The button component for chaining
|
|
232
|
+
*/
|
|
233
|
+
addClass: (...classes: string[]) => ButtonComponent;
|
|
212
234
|
}
|