mtrl 0.2.7 → 0.2.8

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 (164) hide show
  1. package/demo/build.ts +349 -0
  2. package/demo/index.html +110 -0
  3. package/demo/main.js +448 -0
  4. package/demo/styles.css +239 -0
  5. package/package.json +14 -3
  6. package/server.ts +86 -0
  7. package/src/components/badge/api.ts +23 -14
  8. package/src/components/badge/badge.ts +2 -2
  9. package/src/components/badge/config.ts +10 -11
  10. package/src/components/badge/features.ts +15 -10
  11. package/src/components/badge/index.ts +27 -2
  12. package/src/components/badge/types.ts +28 -8
  13. package/src/components/bottom-app-bar/bottom-app-bar.ts +2 -44
  14. package/src/components/bottom-app-bar/config.ts +1 -45
  15. package/src/components/bottom-app-bar/index.ts +7 -1
  16. package/src/components/bottom-app-bar/types.ts +7 -1
  17. package/src/components/button/button.ts +0 -1
  18. package/src/components/button/config.ts +1 -2
  19. package/src/components/button/index.ts +10 -2
  20. package/src/components/button/types.ts +14 -2
  21. package/src/components/card/config.ts +17 -9
  22. package/src/components/card/content.ts +8 -10
  23. package/src/components/card/features.ts +4 -6
  24. package/src/components/card/index.ts +29 -2
  25. package/src/components/card/types.ts +6 -23
  26. package/src/components/checkbox/config.ts +3 -4
  27. package/src/components/checkbox/index.ts +1 -2
  28. package/src/components/checkbox/types.ts +12 -3
  29. package/src/components/chip/api.ts +170 -221
  30. package/src/components/chip/chip.ts +34 -302
  31. package/src/components/chip/config.ts +1 -2
  32. package/src/components/chip/index.ts +10 -2
  33. package/src/components/chip/types.ts +224 -35
  34. package/src/components/datepicker/api.ts +18 -25
  35. package/src/components/datepicker/config.ts +9 -12
  36. package/src/components/datepicker/datepicker.ts +7 -12
  37. package/src/components/datepicker/index.ts +10 -7
  38. package/src/components/datepicker/render.ts +16 -18
  39. package/src/components/datepicker/types.ts +164 -35
  40. package/src/components/datepicker/utils.ts +1 -2
  41. package/src/components/dialog/api.ts +7 -8
  42. package/src/components/dialog/config.ts +3 -4
  43. package/src/components/dialog/features.ts +56 -22
  44. package/src/components/dialog/index.ts +38 -8
  45. package/src/components/dialog/types.ts +33 -10
  46. package/src/components/divider/index.ts +5 -1
  47. package/src/components/extended-fab/config.ts +6 -2
  48. package/src/components/extended-fab/index.ts +7 -2
  49. package/src/components/extended-fab/types.ts +21 -4
  50. package/src/components/fab/config.ts +3 -4
  51. package/src/components/fab/fab.ts +1 -1
  52. package/src/components/fab/index.ts +7 -2
  53. package/src/components/fab/types.ts +21 -4
  54. package/src/components/list/config.ts +4 -5
  55. package/src/components/list/features.ts +6 -7
  56. package/src/components/list/index.ts +7 -9
  57. package/src/components/list/list-item.ts +12 -13
  58. package/src/components/list/types.ts +50 -5
  59. package/src/components/list/utils.ts +30 -3
  60. package/src/components/menu/features/items-manager.ts +9 -9
  61. package/src/components/menu/features/positioning.ts +7 -7
  62. package/src/components/menu/features/visibility.ts +7 -7
  63. package/src/components/menu/index.ts +7 -9
  64. package/src/components/menu/menu-item.ts +6 -6
  65. package/src/components/menu/menu.ts +22 -0
  66. package/src/components/menu/types.ts +29 -10
  67. package/src/components/menu/utils.ts +67 -0
  68. package/src/components/navigation/config.ts +22 -10
  69. package/src/components/navigation/features/items.ts +31 -27
  70. package/src/components/navigation/index.ts +0 -6
  71. package/src/components/navigation/nav-item.ts +12 -24
  72. package/src/components/navigation/navigation.ts +4 -6
  73. package/src/components/navigation/types.ts +228 -203
  74. package/src/components/progress/api.ts +2 -3
  75. package/src/components/progress/config.ts +2 -3
  76. package/src/components/progress/index.ts +0 -1
  77. package/src/components/progress/progress.ts +1 -2
  78. package/src/components/progress/types.ts +186 -33
  79. package/src/components/radios/config.ts +1 -1
  80. package/src/components/radios/index.ts +0 -1
  81. package/src/components/radios/types.ts +0 -7
  82. package/src/components/search/config.ts +1 -2
  83. package/src/components/search/features/search.ts +14 -15
  84. package/src/components/search/features/states.ts +5 -1
  85. package/src/components/search/features/structure.ts +3 -4
  86. package/src/components/search/index.ts +0 -3
  87. package/src/components/search/types.ts +18 -6
  88. package/src/components/segmented-button/config.ts +20 -7
  89. package/src/components/segmented-button/segment.ts +6 -7
  90. package/src/components/segmented-button/segmented-button.ts +4 -5
  91. package/src/components/segmented-button/types.ts +37 -2
  92. package/src/components/slider/types.ts +34 -8
  93. package/src/components/snackbar/config.ts +2 -3
  94. package/src/components/snackbar/constants.ts +0 -32
  95. package/src/components/snackbar/index.ts +0 -1
  96. package/src/components/snackbar/position.ts +9 -1
  97. package/src/components/snackbar/types.ts +122 -46
  98. package/src/components/switch/config.ts +2 -3
  99. package/src/components/switch/index.ts +0 -1
  100. package/src/components/switch/types.ts +3 -2
  101. package/src/components/tabs/config.ts +3 -4
  102. package/src/components/tabs/index.ts +0 -15
  103. package/src/components/tabs/tab-api.ts +12 -4
  104. package/src/components/tabs/tab.ts +18 -6
  105. package/src/components/tabs/types.ts +13 -3
  106. package/src/components/textfield/config.ts +2 -3
  107. package/src/components/textfield/index.ts +0 -1
  108. package/src/components/textfield/types.ts +17 -3
  109. package/src/components/timepicker/api.ts +1 -1
  110. package/src/components/timepicker/clockdial.ts +1 -1
  111. package/src/components/timepicker/config.ts +102 -4
  112. package/src/components/timepicker/index.ts +1 -6
  113. package/src/components/timepicker/render.ts +1 -1
  114. package/src/components/timepicker/timepicker.ts +1 -1
  115. package/src/components/tooltip/api.ts +1 -1
  116. package/src/components/tooltip/config.ts +27 -6
  117. package/src/components/tooltip/index.ts +0 -1
  118. package/src/components/tooltip/types.ts +13 -3
  119. package/src/core/compose/features/textlabel.ts +0 -3
  120. package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +1 -1
  121. package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +70 -67
  122. package/src/styles/main.scss +98 -49
  123. package/src/components/badge/constants.ts +0 -40
  124. package/src/components/button/constants.ts +0 -11
  125. package/src/components/card/constants.ts +0 -84
  126. package/src/components/datepicker/constants.ts +0 -98
  127. package/src/components/dialog/constants.ts +0 -32
  128. package/src/components/extended-fab/constants.ts +0 -36
  129. package/src/components/fab/constants.ts +0 -41
  130. package/src/components/menu/constants.ts +0 -154
  131. package/src/components/navigation/constants.ts +0 -200
  132. package/src/components/progress/constants.ts +0 -29
  133. package/src/components/search/constants.ts +0 -21
  134. package/src/components/segmented-button/constants.ts +0 -42
  135. package/src/components/switch/constants.ts +0 -80
  136. package/src/components/tabs/constants.ts +0 -89
  137. package/src/components/timepicker/constants.ts +0 -138
  138. /package/src/{components/badge/_styles.scss → styles/components/_badge.scss} +0 -0
  139. /package/src/{components/bottom-app-bar/_styles.scss → styles/components/_bottom-app-bar.scss} +0 -0
  140. /package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -0
  141. /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
  142. /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
  143. /package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -0
  144. /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
  145. /package/src/{components/datepicker/_styles.scss → styles/components/_datepicker.scss} +0 -0
  146. /package/src/{components/dialog/_styles.scss → styles/components/_dialog.scss} +0 -0
  147. /package/src/{components/divider/_styles.scss → styles/components/_divider.scss} +0 -0
  148. /package/src/{components/extended-fab/_styles.scss → styles/components/_extended-fab.scss} +0 -0
  149. /package/src/{components/fab/_styles.scss → styles/components/_fab.scss} +0 -0
  150. /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
  151. /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
  152. /package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +0 -0
  153. /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
  154. /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
  155. /package/src/{components/search/_styles.scss → styles/components/_search.scss} +0 -0
  156. /package/src/{components/segmented-button/_styles.scss → styles/components/_segmented-button.scss} +0 -0
  157. /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
  158. /package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +0 -0
  159. /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
  160. /package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -0
  161. /package/src/{components/timepicker/_styles.scss → styles/components/_timepicker.scss} +0 -0
  162. /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
  163. /package/src/{components/top-app-bar/_styles.scss → styles/components/_top-app-bar.scss} +0 -0
  164. /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
@@ -1,17 +1,5 @@
1
1
  // src/components/navigation/nav-item.ts
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
- }
2
+ import { NavItemConfig, NavClass } from './types';
15
3
 
16
4
  /**
17
5
  * Creates an expand/collapse icon element
@@ -20,7 +8,7 @@ interface NavItemConfig {
20
8
  */
21
9
  export const createExpandIcon = (prefix: string): HTMLElement => {
22
10
  const icon = document.createElement('span');
23
- icon.className = `${prefix}-nav-expand-icon`;
11
+ icon.className = `${prefix}-${NavClass.EXPAND_ICON}`;
24
12
  icon.innerHTML = `
25
13
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor">
26
14
  <polyline points="9 18 15 12 9 6"></polyline>
@@ -42,7 +30,7 @@ export const createNestedContainer = (
42
30
  createItem: (config: NavItemConfig, container: HTMLElement, prefix: string) => HTMLElement
43
31
  ): HTMLElement => {
44
32
  const container = document.createElement('div');
45
- container.className = `${prefix}-nav-nested-container`;
33
+ container.className = `${prefix}-${NavClass.NESTED_CONTAINER}`;
46
34
 
47
35
  // Use appropriate role for nested menu
48
36
  container.setAttribute('role', 'menu');
@@ -68,7 +56,7 @@ export const createNavItem = (
68
56
  prefix: string
69
57
  ): HTMLElement => {
70
58
  const itemContainer = document.createElement('div');
71
- itemContainer.className = `${prefix}-nav-item-container`;
59
+ itemContainer.className = `${prefix}-${NavClass.ITEM_CONTAINER}`;
72
60
 
73
61
  // Determine if parent container uses tabs or menu role pattern
74
62
  const isMenuContext = container.getAttribute('role') === 'menu';
@@ -77,7 +65,7 @@ export const createNavItem = (
77
65
 
78
66
  // Create the item element
79
67
  const itemElement = document.createElement('button');
80
- itemElement.className = `${prefix}-nav-item`;
68
+ itemElement.className = `${prefix}-${NavClass.ITEM}`;
81
69
  itemElement.type = 'button'; // Ensure it's a button type for proper behavior
82
70
 
83
71
  // Set appropriate role based on context and items
@@ -114,7 +102,7 @@ export const createNavItem = (
114
102
  // Add icon if provided
115
103
  if (config.icon) {
116
104
  const icon = document.createElement('span');
117
- icon.className = `${prefix}-nav-item-icon`;
105
+ icon.className = `${prefix}-${NavClass.ICON}`;
118
106
  icon.innerHTML = config.icon;
119
107
  itemElement.appendChild(icon);
120
108
  }
@@ -122,7 +110,7 @@ export const createNavItem = (
122
110
  // Add label if provided
123
111
  if (config.label) {
124
112
  const label = document.createElement('span');
125
- label.className = `${prefix}-nav-item-label`;
113
+ label.className = `${prefix}-${NavClass.LABEL}`;
126
114
  label.textContent = config.label;
127
115
  itemElement.appendChild(label);
128
116
  itemElement.setAttribute('aria-label', config.label);
@@ -131,7 +119,7 @@ export const createNavItem = (
131
119
  // Add badge if provided
132
120
  if (config.badge) {
133
121
  const badge = document.createElement('span');
134
- badge.className = `${prefix}-nav-item-badge`;
122
+ badge.className = `${prefix}-${NavClass.BADGE}`;
135
123
  badge.textContent = config.badge;
136
124
  // Use appropriate aria labeling
137
125
  badge.setAttribute('aria-label', `${config.badge} notifications`);
@@ -140,7 +128,7 @@ export const createNavItem = (
140
128
 
141
129
  // Mark active state with appropriate semantics
142
130
  if (config.active && !config.items?.length) {
143
- itemElement.classList.add(`${prefix}-nav-item--active`);
131
+ itemElement.classList.add(`${prefix}-${NavClass.ITEM}--active`);
144
132
 
145
133
  // Use aria-current for standard navigation
146
134
  if (!isTabContext) {
@@ -184,13 +172,13 @@ export const createNavItem = (
184
172
  * @returns {Array<HTMLElement>} Array of all nested items
185
173
  */
186
174
  export const getAllNestedItems = (item: HTMLElement, prefix: string): HTMLElement[] => {
187
- const container = item.closest(`.${prefix}-nav-item-container`);
175
+ const container = item.closest(`.${prefix}-${NavClass.ITEM_CONTAINER}`);
188
176
  if (!container) return [];
189
177
 
190
- const nestedContainer = container.querySelector(`.${prefix}-nav-nested-container`);
178
+ const nestedContainer = container.querySelector(`.${prefix}-${NavClass.NESTED_CONTAINER}`);
191
179
  if (!nestedContainer) return [];
192
180
 
193
- const items = Array.from(nestedContainer.querySelectorAll(`.${prefix}-nav-item`)) as HTMLElement[];
181
+ const items = Array.from(nestedContainer.querySelectorAll(`.${prefix}-${NavClass.ITEM}`)) as HTMLElement[];
194
182
  return items.reduce((acc: HTMLElement[], nestedItem: HTMLElement) => {
195
183
  return [...acc, nestedItem, ...getAllNestedItems(nestedItem, prefix)];
196
184
  }, []);
@@ -10,13 +10,12 @@ import {
10
10
  } from '../../core/compose/features';
11
11
  import { withAPI } from './api';
12
12
  import { withNavItems } from './features/items';
13
- import { NavigationConfig, NavigationComponent } from './types';
13
+ import { NavigationConfig, NavigationComponent, NavVariant } from './types';
14
14
  import {
15
15
  createBaseConfig,
16
16
  getElementConfig,
17
17
  getApiConfig
18
18
  } from './config';
19
- import { NAV_VARIANTS } from './constants';
20
19
 
21
20
  /**
22
21
  * Sets up proper ARIA roles based on navigation variant
@@ -32,7 +31,7 @@ const setupAccessibility = (nav: NavigationComponent, config: NavigationConfig):
32
31
  element.setAttribute('aria-label', config.ariaLabel || 'Main Navigation');
33
32
 
34
33
  // For bar navigation (bottom or top nav)
35
- if (variant === NAV_VARIANTS.BAR) {
34
+ if (variant === 'bar') {
36
35
  // If bar navigation is acting as tabs
37
36
  const hasNestedItems = config.items?.some(item => item.items?.length) || false;
38
37
 
@@ -51,9 +50,8 @@ const setupAccessibility = (nav: NavigationComponent, config: NavigationConfig):
51
50
  }
52
51
 
53
52
  // 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')) &&
53
+ if ((variant === 'modal' ||
54
+ (variant === 'drawer' && config.behavior === 'dismissible')) &&
57
55
  !config.expanded) {
58
56
  element.classList.add(`${prefix}-nav--hidden`);
59
57
  }
@@ -1,234 +1,259 @@
1
- // src/components/button/types.ts
2
- import { BUTTON_VARIANTS } from './constants';
1
+ // src/components/navigation/types.ts
3
2
 
4
3
  /**
5
- * Configuration interface for the Button component
4
+ * Navigation variants following Material Design 3
6
5
  * @category Components
7
6
  */
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
- */
7
+ export type NavVariant = 'rail' | 'drawer' | 'bar' | 'modal' | 'standard';
8
+
9
+ /**
10
+ * Navigation positions
11
+ * @category Components
12
+ */
13
+ export type NavPosition = 'left' | 'right' | 'top' | 'bottom';
14
+
15
+ /**
16
+ * Navigation behaviors
17
+ * @category Components
18
+ */
19
+ export type NavBehavior = 'fixed' | 'dismissible' | 'modal';
20
+
21
+ /**
22
+ * Navigation item state
23
+ * @category Components
24
+ */
25
+ export type NavItemState = 'active' | 'disabled' | 'expanded' | 'collapsed' | 'hovered' | 'focused' | 'pressed';
26
+
27
+ /**
28
+ * Navigation element class names
29
+ * Used internally to maintain consistent class names
30
+ * @internal
31
+ */
32
+ export const NavClass = {
33
+ ITEM: 'nav-item',
34
+ ITEM_CONTAINER: 'nav-item-container',
35
+ ICON: 'nav-item-icon',
36
+ LABEL: 'nav-item-label',
37
+ BADGE: 'nav-item-badge',
38
+ DIVIDER: 'nav-divider',
39
+ SCRIM: 'nav-scrim',
40
+ GROUP: 'nav-group',
41
+ GROUP_TITLE: 'nav-group-title',
42
+ SUBTITLE: 'nav-subtitle',
43
+ NESTED_CONTAINER: 'nav-nested-container',
44
+ NESTED_ITEM: 'nav-nested-item',
45
+ EXPAND_ICON: 'nav-expand-icon'
46
+ } as const;
47
+
48
+ /**
49
+ * Navigation item configuration
50
+ */
51
+ export interface NavItemConfig {
52
+ /** Unique identifier for the item */
53
+ id: string;
54
+
55
+ /** Icon HTML content */
56
+ icon?: string;
57
+
58
+ /** Text label */
59
+ label?: string;
60
+
61
+ /** Badge text */
62
+ badge?: string;
63
+
64
+ /** Whether the item is disabled */
19
65
  disabled?: boolean;
20
66
 
21
- /**
22
- * Initial button text content
23
- * @example 'Submit'
24
- */
25
- text?: string;
67
+ /** Whether the item is active */
68
+ active?: boolean;
26
69
 
27
- /**
28
- * Initial button icon HTML content
29
- * @example '<svg>...</svg>'
30
- */
31
- icon?: string;
70
+ /** Whether nested items are expanded */
71
+ expanded?: boolean;
32
72
 
33
- /**
34
- * Icon size in pixels or other CSS units
35
- * @example '18px'
36
- */
37
- iconSize?: string;
73
+ /** Subtitle text (for drawer items) */
74
+ subtitle?: string;
38
75
 
39
- /**
40
- * Additional CSS classes to add to the button
41
- * @example 'form-submit header-action'
42
- */
43
- class?: string;
76
+ /** Group ID this item belongs to */
77
+ groupId?: string;
78
+
79
+ /** Nested navigation items */
80
+ items?: NavItemConfig[];
81
+ }
82
+
83
+ /**
84
+ * Navigation group configuration
85
+ */
86
+ export interface NavGroupConfig {
87
+ /** Unique identifier for the group */
88
+ id: string;
44
89
 
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;
90
+ /** Group title text */
91
+ title: string;
92
+
93
+ /** Whether the group is expanded */
94
+ expanded?: boolean;
95
+ }
61
96
 
62
- /**
63
- * Component prefix for class names
64
- * @default 'mtrl'
65
- */
97
+ /**
98
+ * Navigation item data
99
+ */
100
+ export interface NavItemData {
101
+ /** The item's DOM element */
102
+ element: HTMLElement;
103
+
104
+ /** Item configuration */
105
+ config: NavItemConfig;
106
+ }
107
+
108
+ /**
109
+ * Navigation change event data
110
+ */
111
+ export interface NavChangeEvent {
112
+ /** ID of the selected item */
113
+ id: string;
114
+
115
+ /** Selected item data */
116
+ item: NavItemData;
117
+
118
+ /** Previously selected item data */
119
+ previousItem?: NavItemData | null;
120
+
121
+ /** Path of parent item IDs */
122
+ path: string[];
123
+ }
124
+
125
+ /**
126
+ * Configuration interface for the Navigation component
127
+ */
128
+ export interface NavigationConfig {
129
+ /** Navigation variant */
130
+ variant?: NavVariant | string;
131
+
132
+ /** Navigation position */
133
+ position?: NavPosition | string;
134
+
135
+ /** Navigation behavior */
136
+ behavior?: NavBehavior | string;
137
+
138
+ /** Navigation items */
139
+ items?: NavItemConfig[];
140
+
141
+ /** Navigation groups */
142
+ groups?: NavGroupConfig[];
143
+
144
+ /** Whether the navigation is disabled */
145
+ disabled?: boolean;
146
+
147
+ /** Whether the navigation is expanded (for drawer) */
148
+ expanded?: boolean;
149
+
150
+ /** Whether to show item labels */
151
+ showLabels?: boolean;
152
+
153
+ /** Whether to enable background scrim (for modal drawer) */
154
+ scrimEnabled?: boolean;
155
+
156
+ /** Additional CSS classes */
157
+ class?: string;
158
+
159
+ /** Accessibility label */
160
+ ariaLabel?: string;
161
+
162
+ /** Component prefix for class names */
66
163
  prefix?: string;
67
164
 
68
- /**
69
- * Component name used in class generation
70
- */
165
+ /** Component name */
71
166
  componentName?: string;
167
+ }
168
+
169
+ /**
170
+ * Navigation component interface
171
+ */
172
+ export interface NavigationComponent {
173
+ /** The navigation's DOM element */
174
+ element: HTMLElement;
72
175
 
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
- };
176
+ /** Map of navigation items */
177
+ items: Map<string, NavItemData>;
84
178
 
85
- /**
86
- * Accessible name for the button (aria-label)
87
- * Required for icon-only buttons without text
88
- */
89
- ariaLabel?: string;
179
+ /** Adds a navigation item */
180
+ addItem: (config: NavItemConfig) => NavigationComponent;
181
+
182
+ /** Removes a navigation item */
183
+ removeItem: (id: string) => NavigationComponent;
184
+
185
+ /** Gets a navigation item by ID */
186
+ getItem: (id: string) => NavItemData | undefined;
187
+
188
+ /** Gets all navigation items */
189
+ getAllItems: () => NavItemData[];
190
+
191
+ /** Gets the active navigation item */
192
+ getActive: () => NavItemData | null;
193
+
194
+ /** Gets the path to an item (parent IDs) */
195
+ getItemPath: (id: string) => string[];
90
196
 
91
- /**
92
- * Descriptive name for the button
93
- * Used to derive an accessible name for icon-only buttons
94
- */
95
- name?: string;
197
+ /** Sets the active navigation item */
198
+ setActive: (id: string) => NavigationComponent;
199
+
200
+ /** Enables the navigation */
201
+ enable: () => NavigationComponent;
202
+
203
+ /** Disables the navigation */
204
+ disable: () => NavigationComponent;
205
+
206
+ /** Expands the navigation (for drawer) */
207
+ expand: () => NavigationComponent;
208
+
209
+ /** Collapses the navigation (for drawer) */
210
+ collapse: () => NavigationComponent;
211
+
212
+ /** Checks if the navigation is expanded */
213
+ isExpanded: () => boolean;
214
+
215
+ /** Toggles the navigation expansion state */
216
+ toggle: () => NavigationComponent;
217
+
218
+ /** Adds an event listener */
219
+ on: (event: string, handler: Function) => NavigationComponent;
220
+
221
+ /** Removes an event listener */
222
+ off: (event: string, handler: Function) => NavigationComponent;
223
+
224
+ /** Destroys the navigation component */
225
+ destroy: () => void;
96
226
  }
97
227
 
98
228
  /**
99
- * Button component interface
100
- * @category Components
229
+ * Base component interface
101
230
  */
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;
231
+ export interface BaseComponent {
232
+ element: HTMLElement;
233
+ prefix?: string;
234
+ items?: Map<string, NavItemData>;
235
+ emit?: (event: string, data: any) => void;
236
+ on?: (event: string, handler: Function) => any;
237
+ off?: (event: string, handler: Function) => any;
238
+ lifecycle?: {
239
+ destroy: () => void;
111
240
  };
112
-
113
- /** API for managing button icons */
114
- icon: {
115
- setIcon: (html: string) => any;
116
- getIcon: () => string;
117
- getElement: () => HTMLElement | null;
241
+ disabled?: {
242
+ enable: () => any;
243
+ disable: () => any;
118
244
  };
119
-
120
- /** API for managing disabled state */
245
+ [key: string]: any;
246
+ }
247
+
248
+ /**
249
+ * API options interface
250
+ */
251
+ export interface ApiOptions {
121
252
  disabled: {
122
- /** Enables the button */
123
253
  enable: () => void;
124
- /** Disables the button */
125
254
  disable: () => void;
126
- /** Checks if the button is disabled */
127
- isDisabled: () => boolean;
128
255
  };
129
-
130
- /** API for managing component lifecycle */
131
256
  lifecycle: {
132
- /** Destroys the component and cleans up resources */
133
257
  destroy: () => void;
134
258
  };
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;
234
259
  }
@@ -1,7 +1,6 @@
1
1
  // src/components/progress/api.ts
2
2
 
3
3
  import { ProgressComponent } from './types';
4
- import { PROGRESS_EVENTS } from './constants';
5
4
 
6
5
  interface ApiOptions {
7
6
  value: {
@@ -80,7 +79,7 @@ export const withAPI = (options: ApiOptions) =>
80
79
  component.labelElement.textContent = formatter(value, options.value.getMax());
81
80
  }
82
81
 
83
- component.emit(PROGRESS_EVENTS.VALUE_CHANGE, { value });
82
+ component.emit('valueChange', { value });
84
83
  return this;
85
84
  },
86
85
 
@@ -163,7 +162,7 @@ export const withAPI = (options: ApiOptions) =>
163
162
  }
164
163
 
165
164
  if (wasIndeterminate !== indeterminate) {
166
- component.emit(PROGRESS_EVENTS.STATE_CHANGE, { indeterminate });
165
+ component.emit('stateChange', { indeterminate });
167
166
  }
168
167
 
169
168
  return this;
@@ -5,13 +5,12 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { ProgressConfig } from './types';
8
- import { PROGRESS_VARIANTS } from './constants';
9
8
 
10
9
  /**
11
10
  * Default configuration for the Progress component
12
11
  */
13
12
  export const defaultConfig: ProgressConfig = {
14
- variant: PROGRESS_VARIANTS.LINEAR,
13
+ variant: 'linear',
15
14
  value: 0,
16
15
  max: 100,
17
16
  buffer: 0,
@@ -52,7 +51,7 @@ export const getElementConfig = (config: ProgressConfig) => {
52
51
  attrs['aria-disabled'] = 'true';
53
52
  }
54
53
 
55
- const isCircular = config.variant === PROGRESS_VARIANTS.CIRCULAR;
54
+ const isCircular = config.variant === 'circular';
56
55
 
57
56
  return createElementConfig(config, {
58
57
  tag: 'div',
@@ -1,5 +1,4 @@
1
1
  // src/components/progress/index.ts
2
2
 
3
3
  export { default } from './progress';
4
- export { PROGRESS_VARIANTS, PROGRESS_EVENTS } from './constants';
5
4
  export { ProgressConfig, ProgressComponent } from './types';
@@ -11,7 +11,6 @@ import {
11
11
  } from '../../core/compose/features';
12
12
  import { withAPI } from './api';
13
13
  import { ProgressConfig, ProgressComponent } from './types';
14
- import { PROGRESS_VARIANTS, PROGRESS_EVENTS } from './constants';
15
14
  import { createBaseConfig, getElementConfig, getApiConfig } from './config';
16
15
 
17
16
  // Helper functions
@@ -104,7 +103,7 @@ const createProgress = (config: ProgressConfig = {}): ProgressComponent => {
104
103
  // Add DOM structure based on variant
105
104
  (component) => {
106
105
  const baseClass = component.getClass('progress');
107
- const isCircular = baseConfig.variant === PROGRESS_VARIANTS.CIRCULAR;
106
+ const isCircular = baseConfig.variant === 'circular';
108
107
 
109
108
  if (isCircular) {
110
109
  const { track, indicator, svg } = createCircularProgressDOM(baseClass);