mtrl 0.2.6 → 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.
Files changed (147) hide show
  1. package/index.ts +18 -0
  2. package/package.json +1 -1
  3. package/src/components/badge/_styles.scss +117 -109
  4. package/src/components/badge/api.ts +57 -59
  5. package/src/components/badge/badge.ts +16 -2
  6. package/src/components/badge/config.ts +65 -11
  7. package/src/components/badge/constants.ts +22 -12
  8. package/src/components/badge/features.ts +44 -40
  9. package/src/components/badge/types.ts +42 -30
  10. package/src/components/bottom-app-bar/_styles.scss +103 -0
  11. package/src/components/bottom-app-bar/bottom-app-bar.ts +196 -0
  12. package/src/components/bottom-app-bar/config.ts +73 -0
  13. package/src/components/bottom-app-bar/index.ts +11 -0
  14. package/src/components/bottom-app-bar/types.ts +108 -0
  15. package/src/components/button/_styles.scss +0 -10
  16. package/src/components/button/api.ts +5 -0
  17. package/src/components/button/config.ts +5 -0
  18. package/src/components/button/types.ts +6 -0
  19. package/src/components/card/card.ts +13 -25
  20. package/src/components/card/config.ts +67 -22
  21. package/src/components/card/features.ts +3 -0
  22. package/src/components/card/types.ts +28 -0
  23. package/src/components/checkbox/_styles.scss +0 -2
  24. package/src/components/datepicker/_styles.scss +358 -0
  25. package/src/components/datepicker/api.ts +272 -0
  26. package/src/components/datepicker/config.ts +144 -0
  27. package/src/components/datepicker/constants.ts +98 -0
  28. package/src/components/datepicker/datepicker.ts +346 -0
  29. package/src/components/datepicker/index.ts +9 -0
  30. package/src/components/datepicker/render.ts +452 -0
  31. package/src/components/datepicker/types.ts +268 -0
  32. package/src/components/datepicker/utils.ts +290 -0
  33. package/src/components/dialog/_styles.scss +174 -128
  34. package/src/components/dialog/api.ts +48 -13
  35. package/src/components/dialog/config.ts +9 -5
  36. package/src/components/dialog/dialog.ts +6 -3
  37. package/src/components/dialog/features.ts +290 -130
  38. package/src/components/dialog/types.ts +7 -4
  39. package/src/components/divider/_styles.scss +57 -0
  40. package/src/components/divider/config.ts +81 -0
  41. package/src/components/divider/divider.ts +37 -0
  42. package/src/components/divider/features.ts +207 -0
  43. package/src/components/divider/index.ts +5 -0
  44. package/src/components/divider/types.ts +55 -0
  45. package/src/components/extended-fab/_styles.scss +267 -0
  46. package/src/components/extended-fab/api.ts +141 -0
  47. package/src/components/extended-fab/config.ts +108 -0
  48. package/src/components/extended-fab/constants.ts +36 -0
  49. package/src/components/extended-fab/extended-fab.ts +125 -0
  50. package/src/components/extended-fab/index.ts +4 -0
  51. package/src/components/extended-fab/types.ts +287 -0
  52. package/src/components/fab/_styles.scss +225 -0
  53. package/src/components/fab/api.ts +97 -0
  54. package/src/components/fab/config.ts +94 -0
  55. package/src/components/fab/constants.ts +41 -0
  56. package/src/components/fab/fab.ts +67 -0
  57. package/src/components/fab/index.ts +4 -0
  58. package/src/components/fab/types.ts +234 -0
  59. package/src/components/navigation/_styles.scss +1 -0
  60. package/src/components/navigation/api.ts +78 -50
  61. package/src/components/navigation/features/items.ts +280 -0
  62. package/src/components/navigation/nav-item.ts +72 -23
  63. package/src/components/navigation/navigation.ts +54 -2
  64. package/src/components/navigation/types.ts +210 -188
  65. package/src/components/search/_styles.scss +306 -0
  66. package/src/components/search/api.ts +203 -0
  67. package/src/components/search/config.ts +87 -0
  68. package/src/components/search/constants.ts +21 -0
  69. package/src/components/search/features/index.ts +4 -0
  70. package/src/components/search/features/search.ts +718 -0
  71. package/src/components/search/features/states.ts +165 -0
  72. package/src/components/search/features/structure.ts +198 -0
  73. package/src/components/search/index.ts +10 -0
  74. package/src/components/search/search.ts +52 -0
  75. package/src/components/search/types.ts +163 -0
  76. package/src/components/segmented-button/_styles.scss +117 -0
  77. package/src/components/segmented-button/config.ts +67 -0
  78. package/src/components/segmented-button/constants.ts +42 -0
  79. package/src/components/segmented-button/index.ts +4 -0
  80. package/src/components/segmented-button/segment.ts +155 -0
  81. package/src/components/segmented-button/segmented-button.ts +250 -0
  82. package/src/components/segmented-button/types.ts +219 -0
  83. package/src/components/slider/_styles.scss +83 -24
  84. package/src/components/slider/accessibility.md +5 -5
  85. package/src/components/slider/api.ts +41 -120
  86. package/src/components/slider/config.ts +51 -47
  87. package/src/components/slider/features/handlers.ts +495 -0
  88. package/src/components/slider/features/index.ts +1 -2
  89. package/src/components/slider/features/slider.ts +66 -84
  90. package/src/components/slider/features/states.ts +195 -0
  91. package/src/components/slider/features/structure.ts +136 -206
  92. package/src/components/slider/features/ui.ts +145 -206
  93. package/src/components/slider/index.ts +2 -11
  94. package/src/components/slider/slider.ts +9 -12
  95. package/src/components/slider/types.ts +39 -24
  96. package/src/components/switch/_styles.scss +0 -2
  97. package/src/components/tabs/_styles.scss +94 -32
  98. package/src/components/tabs/features.ts +4 -2
  99. package/src/components/tabs/indicator.ts +73 -13
  100. package/src/components/tabs/types.ts +10 -2
  101. package/src/components/timepicker/README.md +277 -0
  102. package/src/components/timepicker/_styles.scss +451 -0
  103. package/src/components/timepicker/api.ts +632 -0
  104. package/src/components/timepicker/clockdial.ts +482 -0
  105. package/src/components/timepicker/config.ts +130 -0
  106. package/src/components/timepicker/constants.ts +138 -0
  107. package/src/components/timepicker/index.ts +8 -0
  108. package/src/components/timepicker/render.ts +613 -0
  109. package/src/components/timepicker/timepicker.ts +117 -0
  110. package/src/components/timepicker/types.ts +336 -0
  111. package/src/components/timepicker/utils.ts +241 -0
  112. package/src/components/top-app-bar/_styles.scss +225 -0
  113. package/src/components/top-app-bar/config.ts +83 -0
  114. package/src/components/top-app-bar/index.ts +11 -0
  115. package/src/components/top-app-bar/top-app-bar.ts +316 -0
  116. package/src/components/top-app-bar/types.ts +140 -0
  117. package/src/core/build/_ripple.scss +6 -6
  118. package/src/core/build/ripple.ts +72 -95
  119. package/src/core/compose/features/icon.ts +3 -1
  120. package/src/core/compose/features/ripple.ts +4 -1
  121. package/src/core/compose/features/textlabel.ts +26 -2
  122. package/src/core/dom/create.ts +5 -0
  123. package/src/index.ts +9 -0
  124. package/src/styles/abstract/_theme.scss +9 -1
  125. package/src/styles/themes/_autumn.scss +21 -0
  126. package/src/styles/themes/_base-theme.scss +61 -0
  127. package/src/styles/themes/_baseline.scss +58 -0
  128. package/src/styles/themes/_bluekhaki.scss +125 -0
  129. package/src/styles/themes/_brownbeige.scss +125 -0
  130. package/src/styles/themes/_browngreen.scss +125 -0
  131. package/src/styles/themes/_forest.scss +6 -0
  132. package/src/styles/themes/_greenbeige.scss +125 -0
  133. package/src/styles/themes/_material.scss +125 -0
  134. package/src/styles/themes/_ocean.scss +6 -0
  135. package/src/styles/themes/_sageivory.scss +125 -0
  136. package/src/styles/themes/_spring.scss +6 -0
  137. package/src/styles/themes/_summer.scss +5 -0
  138. package/src/styles/themes/_sunset.scss +5 -0
  139. package/src/styles/themes/_tealcaramel.scss +125 -0
  140. package/src/styles/themes/_winter.scss +6 -0
  141. package/src/components/navigation/features/items.js +0 -192
  142. package/src/components/slider/features/appearance.ts +0 -94
  143. package/src/components/slider/features/disabled.ts +0 -68
  144. package/src/components/slider/features/events.ts +0 -164
  145. package/src/components/slider/features/interactions.ts +0 -396
  146. package/src/components/slider/features/keyboard.ts +0 -233
  147. package/src/core/collection/adapters/mongodb.js +0 -232
@@ -1,5 +1,17 @@
1
1
  // src/components/navigation/nav-item.ts
2
- import { NavItemConfig } from './types';
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
- container.setAttribute('role', 'group');
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
- const item = document.createElement('button');
60
- item.className = `${prefix}-nav-item`;
61
- item.setAttribute('role', config.items?.length ? 'button' : 'menuitem');
62
- item.setAttribute('aria-selected', 'false');
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
- item.dataset.id = config.id;
106
+ itemElement.dataset.id = config.id;
66
107
  }
67
108
 
68
109
  if (config.disabled) {
69
- item.disabled = true;
70
- item.setAttribute('aria-disabled', 'true');
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
- item.appendChild(icon);
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
- item.appendChild(label);
87
- item.setAttribute('aria-label', config.label);
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
- item.appendChild(badge);
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(item);
151
+ itemContainer.appendChild(itemElement);
100
152
 
101
153
  // Handle nested items - only for drawer variant
102
- if (config.items?.length && container.closest('.mtrl-nav--drawer, .mtrl-nav--drawer-modal, .mtrl-nav--drawer-standard')) {
154
+ if (config.items?.length && isDrawerVariant) {
103
155
  const expandIcon = createExpandIcon(prefix);
104
- item.appendChild(expandIcon);
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
- item.addEventListener('click', (event) => {
163
+ itemElement.addEventListener('click', (event) => {
115
164
  event.stopPropagation();
116
- const isExpanded = item.getAttribute('aria-expanded') === 'true';
117
- item.setAttribute('aria-expanded', (!isExpanded).toString());
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 item;
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 // Import core position feature
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
- return navigation as NavigationComponent;
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/navigation/types.ts
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
- * Navigation item configuration
5
+ * Configuration interface for the Button component
6
+ * @category Components
10
7
  */
11
- export interface NavItemConfig {
12
- /** Unique identifier for the item */
13
- id: string;
14
-
15
- /** HTML content for the icon */
16
- icon: string;
17
-
18
- /** Text label for the item */
19
- label: string;
20
-
21
- /** Optional badge text (notifications, etc.) */
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
- /** Whether the item is active */
28
- active?: boolean;
29
-
30
- /** Optional subtitle (for drawer variant) */
31
- subtitle?: string;
32
-
33
- /** ID of the group this item belongs to */
34
- groupId?: string;
35
-
36
- /** Nested navigation items */
37
- items?: NavItemConfig[];
38
-
39
- /** Whether nested items are expanded */
40
- expanded?: boolean;
41
- }
42
-
43
- /**
44
- * Navigation group configuration
45
- */
46
- export interface NavGroupConfig {
47
- /** Unique identifier for the group */
48
- id: string;
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
- /** Path of parent item IDs */
82
- path: string[];
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
- * Configuration interface for the Navigation component
87
- */
88
- export interface NavigationConfig {
89
- /** Navigation variant */
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
- /** Whether to show labels */
111
- showLabels?: boolean;
68
+ /**
69
+ * Component name used in class generation
70
+ */
71
+ componentName?: string;
112
72
 
113
- /** Whether backdrop scrim is enabled */
114
- scrimEnabled?: boolean;
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
- /** ARIA label for accessibility */
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
- /** Additional CSS classes */
120
- class?: string;
121
-
122
- /** Prefix for class names */
123
- prefix?: string;
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
- * Navigation component interface
99
+ * Button component interface
100
+ * @category Components
131
101
  */
132
- export interface NavigationComponent {
133
- /** The root element of the navigation */
134
- element: HTMLElement;
135
-
136
- /** Map of all navigation items */
137
- items: Map<string, NavItemData>;
138
-
139
- /** Adds a new navigation item */
140
- addItem: (itemConfig: NavItemConfig) => NavigationComponent;
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
- /** Disables the navigation */
170
- disable: () => NavigationComponent;
113
+ /** API for managing button icons */
114
+ icon: {
115
+ setIcon: (html: string) => any;
116
+ getIcon: () => string;
117
+ getElement: () => HTMLElement | null;
118
+ };
171
119
 
172
- /** Destroys the navigation component and cleans up resources */
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
- enable: () => any;
182
- disable: () => any;
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
- * Base component interface
191
- */
192
- export interface BaseComponent {
193
- element: HTMLElement;
194
- emit?: (event: string, data: any) => void;
195
- on?: (event: string, handler: Function) => any;
196
- off?: (event: string, handler: Function) => any;
197
- addItem?: (itemConfig: NavItemConfig) => any;
198
- removeItem?: (id: string) => any;
199
- getItem?: (id: string) => NavItemData | undefined;
200
- getAllItems?: () => NavItemData[];
201
- getActive?: () => NavItemData | null;
202
- getItemPath?: (id: string) => string[];
203
- setActive?: (id: string) => any;
204
- disabled?: {
205
- enable: () => any;
206
- disable: () => any;
207
- };
208
- lifecycle?: {
209
- destroy: () => void;
210
- };
211
- [key: string]: any;
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
  }