mtrl 0.2.7 → 0.2.9

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 (190) hide show
  1. package/index.ts +2 -0
  2. package/package.json +14 -3
  3. package/src/components/badge/api.ts +23 -14
  4. package/src/components/badge/badge.ts +2 -2
  5. package/src/components/badge/config.ts +10 -11
  6. package/src/components/badge/features.ts +15 -10
  7. package/src/components/badge/index.ts +27 -2
  8. package/src/components/badge/types.ts +28 -8
  9. package/src/components/bottom-app-bar/bottom-app-bar.ts +2 -44
  10. package/src/components/bottom-app-bar/config.ts +1 -45
  11. package/src/components/bottom-app-bar/index.ts +7 -1
  12. package/src/components/bottom-app-bar/types.ts +7 -1
  13. package/src/components/button/button.ts +0 -1
  14. package/src/components/button/config.ts +1 -2
  15. package/src/components/button/index.ts +10 -2
  16. package/src/components/button/types.ts +14 -2
  17. package/src/components/card/config.ts +17 -9
  18. package/src/components/card/content.ts +8 -10
  19. package/src/components/card/features.ts +4 -6
  20. package/src/components/card/index.ts +29 -2
  21. package/src/components/card/types.ts +6 -23
  22. package/src/components/checkbox/config.ts +3 -4
  23. package/src/components/checkbox/index.ts +1 -2
  24. package/src/components/checkbox/types.ts +12 -3
  25. package/src/components/chip/api.ts +170 -221
  26. package/src/components/chip/chip.ts +34 -302
  27. package/src/components/chip/config.ts +1 -2
  28. package/src/components/chip/index.ts +10 -2
  29. package/src/components/chip/types.ts +224 -35
  30. package/src/components/datepicker/api.ts +18 -25
  31. package/src/components/datepicker/config.ts +9 -12
  32. package/src/components/datepicker/datepicker.ts +7 -12
  33. package/src/components/datepicker/index.ts +10 -7
  34. package/src/components/datepicker/render.ts +16 -18
  35. package/src/components/datepicker/types.ts +164 -35
  36. package/src/components/datepicker/utils.ts +1 -2
  37. package/src/components/dialog/api.ts +7 -8
  38. package/src/components/dialog/config.ts +3 -4
  39. package/src/components/dialog/features.ts +56 -22
  40. package/src/components/dialog/index.ts +38 -8
  41. package/src/components/dialog/types.ts +33 -10
  42. package/src/components/divider/index.ts +5 -1
  43. package/src/components/extended-fab/config.ts +6 -2
  44. package/src/components/extended-fab/index.ts +7 -2
  45. package/src/components/extended-fab/types.ts +21 -4
  46. package/src/components/fab/config.ts +3 -4
  47. package/src/components/fab/fab.ts +1 -1
  48. package/src/components/fab/index.ts +7 -2
  49. package/src/components/fab/types.ts +21 -4
  50. package/src/components/list/config.ts +4 -5
  51. package/src/components/list/features.ts +6 -7
  52. package/src/components/list/index.ts +7 -9
  53. package/src/components/list/list-item.ts +12 -13
  54. package/src/components/list/types.ts +50 -5
  55. package/src/components/list/utils.ts +30 -3
  56. package/src/components/menu/features/items-manager.ts +9 -9
  57. package/src/components/menu/features/positioning.ts +7 -7
  58. package/src/components/menu/features/visibility.ts +7 -7
  59. package/src/components/menu/index.ts +7 -9
  60. package/src/components/menu/menu-item.ts +6 -6
  61. package/src/components/menu/menu.ts +22 -0
  62. package/src/components/menu/types.ts +29 -10
  63. package/src/components/menu/utils.ts +67 -0
  64. package/src/components/navigation/api.ts +131 -96
  65. package/src/components/navigation/config.ts +22 -10
  66. package/src/components/navigation/features/controller.ts +273 -0
  67. package/src/components/navigation/features/items.ts +160 -87
  68. package/src/components/navigation/index.ts +0 -6
  69. package/src/components/navigation/nav-item.ts +12 -24
  70. package/src/components/navigation/navigation.ts +21 -8
  71. package/src/components/navigation/system-types.ts +124 -0
  72. package/src/components/navigation/system.ts +776 -0
  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/config.ts +20 -2
  93. package/src/components/slider/features/controller.ts +761 -0
  94. package/src/components/slider/features/handlers.ts +18 -15
  95. package/src/components/slider/features/index.ts +3 -2
  96. package/src/components/slider/features/range.ts +104 -0
  97. package/src/components/slider/slider.ts +34 -14
  98. package/src/components/slider/structure.ts +152 -0
  99. package/src/components/slider/types.ts +34 -8
  100. package/src/components/snackbar/config.ts +2 -3
  101. package/src/components/snackbar/constants.ts +0 -32
  102. package/src/components/snackbar/index.ts +0 -1
  103. package/src/components/snackbar/position.ts +9 -1
  104. package/src/components/snackbar/types.ts +122 -46
  105. package/src/components/switch/config.ts +2 -3
  106. package/src/components/switch/index.ts +0 -1
  107. package/src/components/switch/types.ts +3 -2
  108. package/src/components/tabs/config.ts +3 -4
  109. package/src/components/tabs/index.ts +0 -15
  110. package/src/components/tabs/tab-api.ts +12 -4
  111. package/src/components/tabs/tab.ts +18 -6
  112. package/src/components/tabs/types.ts +13 -3
  113. package/src/components/textfield/api.ts +53 -0
  114. package/src/components/textfield/config.ts +2 -3
  115. package/src/components/textfield/features.ts +322 -0
  116. package/src/components/textfield/index.ts +0 -1
  117. package/src/components/textfield/textfield.ts +8 -0
  118. package/src/components/textfield/types.ts +29 -6
  119. package/src/components/timepicker/api.ts +1 -1
  120. package/src/components/timepicker/clockdial.ts +2 -5
  121. package/src/components/timepicker/config.ts +102 -4
  122. package/src/components/timepicker/index.ts +1 -6
  123. package/src/components/timepicker/render.ts +1 -1
  124. package/src/components/timepicker/timepicker.ts +1 -1
  125. package/src/components/tooltip/api.ts +1 -1
  126. package/src/components/tooltip/config.ts +27 -6
  127. package/src/components/tooltip/index.ts +0 -1
  128. package/src/components/tooltip/types.ts +13 -3
  129. package/src/core/compose/features/textinput.ts +15 -2
  130. package/src/core/compose/features/textlabel.ts +0 -3
  131. package/src/core/composition/features/dom.ts +33 -0
  132. package/src/core/composition/features/icon.ts +131 -0
  133. package/src/core/composition/features/index.ts +11 -0
  134. package/src/core/composition/features/label.ts +156 -0
  135. package/src/core/composition/features/structure.ts +22 -0
  136. package/src/core/composition/index.ts +26 -0
  137. package/src/core/index.ts +1 -1
  138. package/src/core/structure.ts +288 -0
  139. package/src/index.ts +1 -0
  140. package/src/styles/components/_navigation-mobile.scss +244 -0
  141. package/src/styles/components/_navigation-system.scss +151 -0
  142. package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +1 -1
  143. package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +314 -72
  144. package/src/styles/main.scss +98 -49
  145. package/src/components/badge/constants.ts +0 -40
  146. package/src/components/button/constants.ts +0 -11
  147. package/src/components/card/constants.ts +0 -84
  148. package/src/components/datepicker/constants.ts +0 -98
  149. package/src/components/dialog/constants.ts +0 -32
  150. package/src/components/extended-fab/constants.ts +0 -36
  151. package/src/components/fab/constants.ts +0 -41
  152. package/src/components/menu/constants.ts +0 -154
  153. package/src/components/navigation/constants.ts +0 -200
  154. package/src/components/progress/constants.ts +0 -29
  155. package/src/components/search/constants.ts +0 -21
  156. package/src/components/segmented-button/constants.ts +0 -42
  157. package/src/components/slider/features/slider.ts +0 -318
  158. package/src/components/slider/features/structure.ts +0 -181
  159. package/src/components/slider/features/ui.ts +0 -388
  160. package/src/components/switch/constants.ts +0 -80
  161. package/src/components/tabs/constants.ts +0 -89
  162. package/src/components/textfield/constants.ts +0 -100
  163. package/src/components/timepicker/constants.ts +0 -138
  164. /package/src/{components/badge/_styles.scss → styles/components/_badge.scss} +0 -0
  165. /package/src/{components/bottom-app-bar/_styles.scss → styles/components/_bottom-app-bar.scss} +0 -0
  166. /package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -0
  167. /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
  168. /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
  169. /package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -0
  170. /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
  171. /package/src/{components/datepicker/_styles.scss → styles/components/_datepicker.scss} +0 -0
  172. /package/src/{components/dialog/_styles.scss → styles/components/_dialog.scss} +0 -0
  173. /package/src/{components/divider/_styles.scss → styles/components/_divider.scss} +0 -0
  174. /package/src/{components/extended-fab/_styles.scss → styles/components/_extended-fab.scss} +0 -0
  175. /package/src/{components/fab/_styles.scss → styles/components/_fab.scss} +0 -0
  176. /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
  177. /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
  178. /package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +0 -0
  179. /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
  180. /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
  181. /package/src/{components/search/_styles.scss → styles/components/_search.scss} +0 -0
  182. /package/src/{components/segmented-button/_styles.scss → styles/components/_segmented-button.scss} +0 -0
  183. /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
  184. /package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +0 -0
  185. /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
  186. /package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -0
  187. /package/src/{components/timepicker/_styles.scss → styles/components/_timepicker.scss} +0 -0
  188. /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
  189. /package/src/{components/top-app-bar/_styles.scss → styles/components/_top-app-bar.scss} +0 -0
  190. /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
@@ -1,102 +1,255 @@
1
1
  // src/components/progress/types.ts
2
- import { PROGRESS_VARIANTS } from './constants';
2
+
3
+ /**
4
+ * Progress variant types
5
+ * @category Components
6
+ */
7
+ export type ProgressVariant = 'linear' | 'circular';
8
+
9
+ /**
10
+ * Progress component event types
11
+ * @category Components
12
+ */
13
+ export type ProgressEvent = 'change' | 'complete';
14
+
15
+ // /**
16
+ // * Progress variants object for internal reference
17
+ // * @internal
18
+ // */
19
+ // export const PROGRESS_VARIANTS: Record<string, ProgressVariant> = {
20
+ // LINEAR: 'linear',
21
+ // CIRCULAR: 'circular'
22
+ // };
23
+
24
+ // /**
25
+ // * Progress events object for internal reference
26
+ // * @internal
27
+ // */
28
+ // export const PROGRESS_EVENTS: Record<string, ProgressEvent> = {
29
+ // CHANGE: 'change',
30
+ // COMPLETE: 'complete'
31
+ // };
3
32
 
4
33
  /**
5
34
  * Configuration interface for the Progress component
35
+ * @category Components
6
36
  */
7
37
  export interface ProgressConfig {
8
- /** Progress variant (linear, circular) */
9
- variant?: keyof typeof PROGRESS_VARIANTS | string;
10
-
11
- /** Initial progress value (0-100) */
38
+ /**
39
+ * Progress variant that determines visual style
40
+ * @default 'linear'
41
+ */
42
+ variant?: ProgressVariant | string;
43
+
44
+ /**
45
+ * Initial progress value (0-100)
46
+ * @default 0
47
+ */
12
48
  value?: number;
13
49
 
14
- /** Whether the progress indicator is initially disabled */
50
+ /**
51
+ * Whether the progress indicator is initially disabled
52
+ * @default false
53
+ */
15
54
  disabled?: boolean;
16
55
 
17
- /** Maximum value (defaults to 100) */
56
+ /**
57
+ * Maximum value
58
+ * @default 100
59
+ */
18
60
  max?: number;
19
61
 
20
- /** Custom buffer value for linear progress */
62
+ /**
63
+ * Buffer value for linear progress with buffer (like video loading)
64
+ * @default 0
65
+ */
21
66
  buffer?: number;
22
67
 
23
- /** Additional CSS classes */
68
+ /**
69
+ * Additional CSS classes to add to the progress component
70
+ * @example 'page-loader main-progress'
71
+ */
24
72
  class?: string;
25
73
 
26
- /** Whether to show text label with percentage */
74
+ /**
75
+ * Whether to show text label with percentage
76
+ * @default false
77
+ */
27
78
  showLabel?: boolean;
28
79
 
29
- /** Whether progress is indeterminate */
80
+ /**
81
+ * Whether progress is indeterminate (shows animation without specific value)
82
+ * @default false
83
+ */
30
84
  indeterminate?: boolean;
31
85
 
32
- /** Custom label format function */
86
+ /**
87
+ * Custom label formatter function
88
+ * @example (value, max) => `${Math.round((value/max) * 100)}%`
89
+ */
33
90
  labelFormatter?: (value: number, max: number) => string;
91
+
92
+ /**
93
+ * Component prefix for class names
94
+ * @default 'mtrl'
95
+ */
96
+ prefix?: string;
97
+
98
+ /**
99
+ * Component name used in class generation
100
+ * @default 'progress'
101
+ */
102
+ componentName?: string;
34
103
  }
35
104
 
36
105
  /**
37
106
  * Progress component interface
107
+ * @category Components
38
108
  */
39
109
  export interface ProgressComponent {
40
- /** The component's root element */
110
+ /** The component's root DOM element */
41
111
  element: HTMLElement;
42
112
 
43
- /** The track element */
113
+ /** The track element (background) */
44
114
  trackElement: HTMLElement;
45
115
 
46
- /** The indicator element */
116
+ /** The indicator element (filled part) */
47
117
  indicatorElement: HTMLElement;
48
118
 
49
- /** The buffer element (for linear variant) */
119
+ /** The buffer element for linear variant (pre-loaded state) */
50
120
  bufferElement?: HTMLElement;
51
121
 
52
- /** The label element (if enabled) */
122
+ /** The label element if showLabel is enabled */
53
123
  labelElement?: HTMLElement;
54
124
 
55
- /** Sets the current progress value */
125
+ /**
126
+ * Gets a class name with the component's prefix
127
+ * @param name - Base class name
128
+ * @returns Prefixed class name
129
+ */
130
+ getClass: (name: string) => string;
131
+
132
+ /**
133
+ * Sets the current progress value
134
+ * @param value - Progress value (between 0 and max)
135
+ * @returns The progress component for chaining
136
+ */
56
137
  setValue: (value: number) => ProgressComponent;
57
138
 
58
- /** Gets the current progress value */
139
+ /**
140
+ * Gets the current progress value
141
+ * @returns Current progress value
142
+ */
59
143
  getValue: () => number;
60
144
 
61
- /** Sets the buffer value (for linear variant) */
145
+ /**
146
+ * Sets the buffer value (for linear variant with buffer indicators)
147
+ * @param value - Buffer value (between 0 and max)
148
+ * @returns The progress component for chaining
149
+ */
62
150
  setBuffer: (value: number) => ProgressComponent;
63
151
 
64
- /** Gets the current buffer value */
152
+ /**
153
+ * Gets the current buffer value
154
+ * @returns Current buffer value
155
+ */
65
156
  getBuffer: () => number;
66
157
 
67
- /** Enables the progress component */
158
+ /**
159
+ * Enables the progress component
160
+ * @returns The progress component for chaining
161
+ */
68
162
  enable: () => ProgressComponent;
69
163
 
70
- /** Disables the progress component */
164
+ /**
165
+ * Disables the progress component
166
+ * @returns The progress component for chaining
167
+ */
71
168
  disable: () => ProgressComponent;
72
169
 
73
- /** Checks if the component is disabled */
170
+ /**
171
+ * Checks if the component is disabled
172
+ * @returns Whether the component is disabled
173
+ */
74
174
  isDisabled: () => boolean;
75
175
 
76
- /** Shows the label */
176
+ /**
177
+ * Shows the label element
178
+ * @returns The progress component for chaining
179
+ */
77
180
  showLabel: () => ProgressComponent;
78
181
 
79
- /** Hides the label */
182
+ /**
183
+ * Hides the label element
184
+ * @returns The progress component for chaining
185
+ */
80
186
  hideLabel: () => ProgressComponent;
81
187
 
82
- /** Sets a custom formatter for the label */
188
+ /**
189
+ * Sets a custom formatter for the label
190
+ * @param formatter - Function that formats the label text
191
+ * @returns The progress component for chaining
192
+ */
83
193
  setLabelFormatter: (formatter: (value: number, max: number) => string) => ProgressComponent;
84
194
 
85
- /** Sets the indeterminate state */
195
+ /**
196
+ * Sets the indeterminate state
197
+ * @param indeterminate - Whether progress is indeterminate
198
+ * @returns The progress component for chaining
199
+ */
86
200
  setIndeterminate: (indeterminate: boolean) => ProgressComponent;
87
201
 
88
- /** Checks if the component is indeterminate */
202
+ /**
203
+ * Checks if the component is in indeterminate state
204
+ * @returns Whether the component is indeterminate
205
+ */
89
206
  isIndeterminate: () => boolean;
90
207
 
91
- /** Adds event listener */
208
+ /**
209
+ * Adds an event listener to the progress
210
+ * @param event - Event name ('change', 'complete')
211
+ * @param handler - Event handler function
212
+ * @returns The progress component for chaining
213
+ */
92
214
  on: (event: string, handler: Function) => ProgressComponent;
93
215
 
94
- /** Removes event listener */
216
+ /**
217
+ * Removes an event listener from the progress
218
+ * @param event - Event name
219
+ * @param handler - Event handler function
220
+ * @returns The progress component for chaining
221
+ */
95
222
  off: (event: string, handler: Function) => ProgressComponent;
96
223
 
97
- /** Destroys the component and cleans up resources */
224
+ /**
225
+ * Destroys the progress component and cleans up resources
226
+ */
98
227
  destroy: () => void;
99
228
 
100
- /** Add CSS classes */
229
+ /**
230
+ * Adds CSS classes to the progress element
231
+ * @param classes - One or more class names to add
232
+ * @returns The progress component for chaining
233
+ */
101
234
  addClass: (...classes: string[]) => ProgressComponent;
235
+
236
+ /**
237
+ * API for managing disabled state
238
+ */
239
+ disabled: {
240
+ /** Enables the progress */
241
+ enable: () => void;
242
+ /** Disables the progress */
243
+ disable: () => void;
244
+ /** Checks if the progress is disabled */
245
+ isDisabled: () => boolean;
246
+ };
247
+
248
+ /**
249
+ * API for managing component lifecycle
250
+ */
251
+ lifecycle: {
252
+ /** Destroys the component and cleans up resources */
253
+ destroy: () => void;
254
+ };
102
255
  }
@@ -12,7 +12,7 @@ import { RADIO_DIRECTIONS } from './constants';
12
12
  */
13
13
  export const defaultConfig: RadiosConfig = {
14
14
  name: '',
15
- direction: RADIO_DIRECTIONS.VERTICAL,
15
+ direction: 'vertical',
16
16
  disabled: false,
17
17
  ripple: true,
18
18
  options: []
@@ -1,4 +1,3 @@
1
1
  // src/components/radios/index.ts
2
2
  export { default } from './radios';
3
- export { RADIO_STATES, RADIO_DIRECTIONS } from './constants';
4
3
  export { RadiosConfig, RadiosComponent, RadioOptionConfig } from './types';
@@ -1,5 +1,4 @@
1
1
  // src/components/radios/types.ts
2
- import { RADIO_DIRECTIONS } from './constants';
3
2
 
4
3
  /**
5
4
  * Configuration for a radio option in the Radios component
@@ -58,12 +57,6 @@ export interface RadiosConfig {
58
57
  */
59
58
  disabled?: boolean;
60
59
 
61
- /**
62
- * Group layout direction
63
- * @default 'vertical'
64
- */
65
- direction?: keyof typeof RADIO_DIRECTIONS | string;
66
-
67
60
  /**
68
61
  * Whether to enable ripple effect
69
62
  * @default true
@@ -4,13 +4,12 @@ import {
4
4
  createElementConfig
5
5
  } from '../../core/config/component-config';
6
6
  import { SearchConfig } from './types';
7
- import { SEARCH_VARIANTS } from './constants';
8
7
 
9
8
  /**
10
9
  * Default configuration for the Search component
11
10
  */
12
11
  export const defaultConfig: SearchConfig = {
13
- variant: SEARCH_VARIANTS.BAR,
12
+ variant: 'bar',
14
13
  disabled: false,
15
14
  placeholder: 'Search',
16
15
  value: '',
@@ -1,5 +1,4 @@
1
1
  // src/components/search/features/search.ts
2
- import { SEARCH_EVENTS, SEARCH_VARIANTS } from '../constants';
3
2
  import { SearchConfig } from '../types';
4
3
 
5
4
  /**
@@ -39,7 +38,7 @@ export const withSearch = (config: SearchConfig) => component => {
39
38
  placeholder: config.placeholder || 'Search',
40
39
  suggestions: config.suggestions || [],
41
40
  isFocused: false,
42
- isExpanded: config.variant === SEARCH_VARIANTS.VIEW,
41
+ isExpanded: config.variant === 'view',
43
42
  component
44
43
  };
45
44
 
@@ -95,7 +94,7 @@ export const withSearch = (config: SearchConfig) => component => {
95
94
 
96
95
  // Trigger input event
97
96
  if (triggerEvent) {
98
- eventHelpers.triggerEvent(SEARCH_EVENTS.INPUT);
97
+ eventHelpers.triggerEvent('input');
99
98
  }
100
99
  };
101
100
 
@@ -104,7 +103,7 @@ export const withSearch = (config: SearchConfig) => component => {
104
103
  */
105
104
  const submitSearch = () => {
106
105
  if (state.value) {
107
- eventHelpers.triggerEvent(SEARCH_EVENTS.SUBMIT);
106
+ eventHelpers.triggerEvent('submit');
108
107
 
109
108
  // Hide suggestions if in bar mode
110
109
  if (!state.isExpanded) {
@@ -124,7 +123,7 @@ export const withSearch = (config: SearchConfig) => component => {
124
123
  }
125
124
 
126
125
  if (triggerEvent) {
127
- eventHelpers.triggerEvent(SEARCH_EVENTS.CLEAR);
126
+ eventHelpers.triggerEvent('clear');
128
127
  }
129
128
  };
130
129
 
@@ -308,11 +307,11 @@ export const withSearch = (config: SearchConfig) => component => {
308
307
  component.element.classList.add(`${component.getClass('search')}--focused`);
309
308
 
310
309
  // Expand search bar to view if in bar mode
311
- if (!state.isExpanded && config.variant === SEARCH_VARIANTS.BAR) {
310
+ if (!state.isExpanded && config.variant === 'bar') {
312
311
  expandToView();
313
312
  }
314
313
 
315
- eventHelpers.triggerEvent(SEARCH_EVENTS.FOCUS, e);
314
+ eventHelpers.triggerEvent('focus', e);
316
315
  });
317
316
 
318
317
  // Blur event
@@ -331,13 +330,13 @@ export const withSearch = (config: SearchConfig) => component => {
331
330
  hideSuggestions();
332
331
 
333
332
  // Collapse to bar mode if in expanded state and originally a bar
334
- if (state.isExpanded && config.variant === SEARCH_VARIANTS.BAR) {
333
+ if (state.isExpanded && config.variant === 'bar') {
335
334
  collapseToBar();
336
335
  }
337
336
  }
338
337
  }, 200);
339
338
 
340
- eventHelpers.triggerEvent(SEARCH_EVENTS.BLUR, e);
339
+ eventHelpers.triggerEvent('blur', e);
341
340
  });
342
341
 
343
342
  // Enter key for submit
@@ -351,7 +350,7 @@ export const withSearch = (config: SearchConfig) => component => {
351
350
  // Clear if there's a value, otherwise collapse
352
351
  if (state.value) {
353
352
  clearSearch();
354
- } else if (state.isExpanded && config.variant === SEARCH_VARIANTS.BAR) {
353
+ } else if (state.isExpanded && config.variant === 'bar') {
355
354
  collapseToBar();
356
355
  }
357
356
  }
@@ -373,7 +372,7 @@ export const withSearch = (config: SearchConfig) => component => {
373
372
  expandToView();
374
373
  }
375
374
 
376
- eventHelpers.triggerEvent(SEARCH_EVENTS.ICON_CLICK, e);
375
+ eventHelpers.triggerEvent('iconClick', e);
377
376
  });
378
377
 
379
378
  // Keyboard access
@@ -413,7 +412,7 @@ export const withSearch = (config: SearchConfig) => component => {
413
412
  // If disabled, do nothing
414
413
  if (component.disabled?.isDisabled()) return;
415
414
 
416
- eventHelpers.triggerEvent(SEARCH_EVENTS.ICON_CLICK, e);
415
+ eventHelpers.triggerEvent('iconClick', e);
417
416
  });
418
417
 
419
418
  // Keyboard access
@@ -433,7 +432,7 @@ export const withSearch = (config: SearchConfig) => component => {
433
432
  // If disabled, do nothing
434
433
  if (component.disabled?.isDisabled()) return;
435
434
 
436
- eventHelpers.triggerEvent(SEARCH_EVENTS.ICON_CLICK, e);
435
+ eventHelpers.triggerEvent('iconClick', e);
437
436
  });
438
437
 
439
438
  // Keyboard access
@@ -451,7 +450,7 @@ export const withSearch = (config: SearchConfig) => component => {
451
450
  hideSuggestions();
452
451
 
453
452
  // Collapse to bar mode if in expanded state and originally a bar
454
- if (state.isExpanded && config.variant === SEARCH_VARIANTS.BAR) {
453
+ if (state.isExpanded && config.variant === 'bar') {
455
454
  collapseToBar();
456
455
  }
457
456
  }
@@ -471,7 +470,7 @@ export const withSearch = (config: SearchConfig) => component => {
471
470
  hideSuggestions();
472
471
 
473
472
  // Collapse to bar mode if in expanded state and originally a bar
474
- if (state.isExpanded && config.variant === SEARCH_VARIANTS.BAR) {
473
+ if (state.isExpanded && config.variant === 'bar') {
475
474
  collapseToBar();
476
475
  }
477
476
  }
@@ -1,7 +1,11 @@
1
1
  // src/components/search/features/states.ts
2
- import { SEARCH_VARIANTS } from '../constants';
3
2
  import { SearchConfig } from '../types';
4
3
 
4
+ const SEARCH_VARIANTS = {
5
+ BAR: 'bar',
6
+ VIEW: 'view'
7
+ }
8
+
5
9
  /**
6
10
  * Add state management features to search component
7
11
  *
@@ -1,5 +1,4 @@
1
1
  // src/components/search/features/structure.ts
2
- import { SEARCH_VARIANTS } from '../constants';
3
2
  import { SearchConfig } from '../types';
4
3
  import { createElement } from '../../../core/dom/create';
5
4
 
@@ -11,8 +10,8 @@ import { createElement } from '../../../core/dom/create';
11
10
  export const withStructure = (config: SearchConfig) => component => {
12
11
  // Get initial config values
13
12
  const isDisabled = config.disabled === true;
14
- const variant = config.variant || SEARCH_VARIANTS.BAR;
15
- const isViewMode = variant === SEARCH_VARIANTS.VIEW;
13
+ const variant = config.variant || 'bar';
14
+ const isViewMode = variant === 'view';
16
15
  const placeholder = config.placeholder || 'Search';
17
16
  const value = config.value || '';
18
17
 
@@ -179,7 +178,7 @@ function applyStyleClasses(component, config, isViewMode, isDisabled) {
179
178
  const baseClass = component.getClass('search');
180
179
 
181
180
  // Apply variant class
182
- component.element.classList.add(`${baseClass}--${config.variant || SEARCH_VARIANTS.BAR}`);
181
+ component.element.classList.add(`${baseClass}--${config.variant || 'bar'}`);
183
182
 
184
183
  // Apply disabled class if needed
185
184
  if (isDisabled) {
@@ -3,8 +3,5 @@
3
3
  // Export main component creator
4
4
  export { default } from './search';
5
5
 
6
- // Export constants
7
- export { SEARCH_VARIANTS, SEARCH_EVENTS } from './constants';
8
-
9
6
  // Export types for TypeScript users
10
7
  export type { SearchConfig, SearchComponent, SearchEvent } from './types';
@@ -1,12 +1,22 @@
1
1
  // src/components/search/types.ts
2
- import { SEARCH_VARIANTS, SEARCH_EVENTS } from './constants';
2
+
3
+ /**
4
+ * Navigation variants for the search component
5
+ */
6
+ export type NavVariant = 'rail' | 'drawer' | 'bar' | 'modal' | 'standard';
7
+
8
+ /**
9
+ * Valid event types for search component
10
+ */
11
+ export type SearchEventType = 'focus' | 'blur' | 'input' | 'submit' | 'clear' | 'iconClick';
3
12
 
4
13
  /**
5
14
  * Configuration options for the search component
15
+ * @interface SearchConfig
6
16
  */
7
17
  export interface SearchConfig {
8
- /** The variant of the search component (bar or view) */
9
- variant?: keyof typeof SEARCH_VARIANTS | typeof SEARCH_VARIANTS[keyof typeof SEARCH_VARIANTS];
18
+ /** The variant of the search component (rail, drawer, bar, modal, or standard) */
19
+ variant?: NavVariant | string;
10
20
 
11
21
  /** Whether the search component is disabled */
12
22
  disabled?: boolean;
@@ -61,12 +71,13 @@ export interface SearchConfig {
61
71
 
62
72
  /** Event handlers for search events */
63
73
  on?: {
64
- [key in keyof typeof SEARCH_EVENTS | typeof SEARCH_EVENTS[keyof typeof SEARCH_EVENTS]]?: (event: SearchEvent) => void;
74
+ [key in SearchEventType]?: (event: SearchEvent) => void;
65
75
  };
66
76
  }
67
77
 
68
78
  /**
69
79
  * Search event data
80
+ * @interface SearchEvent
70
81
  */
71
82
  export interface SearchEvent {
72
83
  /** The search component that triggered the event */
@@ -87,6 +98,7 @@ export interface SearchEvent {
87
98
 
88
99
  /**
89
100
  * Search component public API interface
101
+ * @interface SearchComponent
90
102
  */
91
103
  export interface SearchComponent {
92
104
  /** The root element of the search component */
@@ -153,10 +165,10 @@ export interface SearchComponent {
153
165
  isDisabled: () => boolean;
154
166
 
155
167
  /** Adds event listener */
156
- on: (event: keyof typeof SEARCH_EVENTS | typeof SEARCH_EVENTS[keyof typeof SEARCH_EVENTS], handler: (event: SearchEvent) => void) => SearchComponent;
168
+ on: (event: SearchEventType, handler: (event: SearchEvent) => void) => SearchComponent;
157
169
 
158
170
  /** Removes event listener */
159
- off: (event: keyof typeof SEARCH_EVENTS | typeof SEARCH_EVENTS[keyof typeof SEARCH_EVENTS], handler: (event: SearchEvent) => void) => SearchComponent;
171
+ off: (event: SearchEventType, handler: (event: SearchEvent) => void) => SearchComponent;
160
172
 
161
173
  /** Destroys the search component and cleans up resources */
162
174
  destroy: () => void;
@@ -1,7 +1,20 @@
1
1
  // src/components/segmented-button/config.ts
2
2
  import { createComponentConfig } from '../../core/config/component-config';
3
3
  import { SegmentedButtonConfig, SelectionMode } from './types';
4
- import { DEFAULT_CONFIG, CLASSES } from './constants';
4
+
5
+ export const DEFAULT_CHECKMARK_ICON = `
6
+ <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
7
+ <polyline points="20 6 9 17 4 12"></polyline>
8
+ </svg>`;
9
+
10
+ /**
11
+ * Default configuration values for segmented buttons
12
+ * @internal
13
+ */
14
+ export const DEFAULT_CONFIG = {
15
+ mode: SelectionMode.SINGLE,
16
+ ripple: true
17
+ };
5
18
 
6
19
  /**
7
20
  * Creates the base configuration for Segmented Button component
@@ -10,7 +23,7 @@ import { DEFAULT_CONFIG, CLASSES } from './constants';
10
23
  * @internal
11
24
  */
12
25
  export const createBaseConfig = (config: SegmentedButtonConfig = {}): SegmentedButtonConfig =>
13
- createComponentConfig(DEFAULT_CONFIG, config, CLASSES.CONTAINER) as SegmentedButtonConfig;
26
+ createComponentConfig(DEFAULT_CONFIG, config, 'segmented-button') as SegmentedButtonConfig;
14
27
 
15
28
  /**
16
29
  * Generates element configuration for the Segmented Button container
@@ -20,7 +33,7 @@ export const createBaseConfig = (config: SegmentedButtonConfig = {}): SegmentedB
20
33
  */
21
34
  export const getContainerConfig = (config: SegmentedButtonConfig) => ({
22
35
  tag: 'div',
23
- componentName: CLASSES.CONTAINER,
36
+ componentName: 'segmented-button',
24
37
  attrs: {
25
38
  role: 'group',
26
39
  'aria-label': 'Segmented button',
@@ -28,7 +41,7 @@ export const getContainerConfig = (config: SegmentedButtonConfig) => ({
28
41
  },
29
42
  className: [
30
43
  config.class,
31
- config.disabled ? `${config.prefix}-${CLASSES.CONTAINER}--disabled` : null
44
+ config.disabled ? `${config.prefix}-segmented-button--disabled` : null
32
45
  ],
33
46
  interactive: true
34
47
  });
@@ -54,9 +67,9 @@ export const getSegmentConfig = (segment, prefix, groupDisabled = false) => {
54
67
  value: segment.value
55
68
  },
56
69
  className: [
57
- `${prefix}-${CLASSES.SEGMENT}`,
58
- segment.selected ? `${prefix}-${CLASSES.SEGMENT}--${CLASSES.SELECTED}` : null,
59
- isDisabled ? `${prefix}-${CLASSES.SEGMENT}--${CLASSES.DISABLED}` : null,
70
+ `${prefix}-segment`,
71
+ segment.selected ? `${prefix}-segment--selected` : null,
72
+ isDisabled ? `${prefix}-segment--disabled` : null,
60
73
  segment.class
61
74
  ],
62
75
  forwardEvents: {