mtrl 0.3.1 → 0.3.2

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 (159) hide show
  1. package/.env +15 -0
  2. package/CONTRIBUTING.md +8 -8
  3. package/DOCS.md +3 -3
  4. package/README.md +43 -20
  5. package/TESTING.md +128 -18
  6. package/dist/index.js +14865 -0
  7. package/git-user-stats.js +545 -0
  8. package/index.ts +9 -67
  9. package/package.json +8 -3
  10. package/src/components/badge/api.ts +15 -1
  11. package/src/components/badge/badge.ts +43 -4
  12. package/src/components/badge/config.ts +40 -8
  13. package/src/components/badge/index.ts +64 -3
  14. package/src/components/badge/types.ts +175 -33
  15. package/src/components/button/api.ts +63 -1
  16. package/src/components/button/button.ts +39 -3
  17. package/src/components/button/config.ts +21 -4
  18. package/src/components/button/index.ts +26 -1
  19. package/src/components/button/types.ts +7 -1
  20. package/src/components/card/api.ts +78 -9
  21. package/src/components/card/card.ts +58 -3
  22. package/src/components/card/config.ts +41 -11
  23. package/src/components/card/features.ts +39 -12
  24. package/src/components/card/index.ts +84 -19
  25. package/src/components/card/types.ts +218 -29
  26. package/src/components/carousel/carousel.ts +92 -28
  27. package/src/components/carousel/constants.ts +107 -21
  28. package/src/components/carousel/index.ts +31 -13
  29. package/src/components/checkbox/checkbox.ts +83 -16
  30. package/src/components/checkbox/index.ts +43 -1
  31. package/src/components/checkbox/types.ts +219 -32
  32. package/src/components/chips/api.ts +194 -0
  33. package/src/components/{chip → chips/chip}/api.ts +42 -2
  34. package/src/components/chips/chip/chip.ts +131 -0
  35. package/src/components/{chip → chips/chip}/config.ts +3 -3
  36. package/src/components/chips/chip/index.ts +3 -0
  37. package/src/components/chips/chips.md +481 -0
  38. package/src/components/chips/chips.ts +75 -0
  39. package/src/components/chips/config.ts +109 -0
  40. package/src/components/chips/constants.ts +61 -0
  41. package/src/components/chips/features/chip-items.ts +33 -0
  42. package/src/components/chips/features/container.ts +77 -0
  43. package/src/components/chips/features/controller.ts +448 -0
  44. package/src/components/chips/features/index.ts +5 -0
  45. package/src/components/chips/features/label.ts +108 -0
  46. package/src/components/chips/index.ts +11 -0
  47. package/src/components/chips/schema.ts +61 -0
  48. package/src/components/{chip → chips}/types.ts +203 -92
  49. package/src/components/dialog/dialog.ts +99 -16
  50. package/src/components/dialog/index.ts +97 -1
  51. package/src/components/dialog/types.ts +375 -69
  52. package/src/components/divider/config.ts +90 -6
  53. package/src/components/divider/divider.ts +32 -2
  54. package/src/components/divider/features.ts +26 -0
  55. package/src/components/divider/index.ts +30 -0
  56. package/src/components/divider/types.ts +86 -9
  57. package/src/components/extended-fab/api.ts +53 -1
  58. package/src/components/extended-fab/config.ts +29 -1
  59. package/src/components/extended-fab/extended-fab.ts +28 -0
  60. package/src/components/extended-fab/index.ts +36 -0
  61. package/src/components/extended-fab/types.ts +458 -13
  62. package/src/components/fab/api.ts +42 -2
  63. package/src/components/fab/config.ts +29 -1
  64. package/src/components/fab/fab.ts +16 -2
  65. package/src/components/fab/index.ts +35 -0
  66. package/src/components/fab/types.ts +374 -10
  67. package/src/components/list/api.ts +12 -2
  68. package/src/components/list/config.ts +21 -0
  69. package/src/components/list/features.ts +6 -0
  70. package/src/components/list/index.ts +56 -1
  71. package/src/components/list/list-item.ts +46 -2
  72. package/src/components/list/list.ts +73 -2
  73. package/src/components/list/types.ts +172 -0
  74. package/src/components/list/utils.ts +26 -2
  75. package/src/components/menu/api.ts +217 -20
  76. package/src/components/menu/config.ts +27 -0
  77. package/src/components/menu/features/visibility.ts +55 -6
  78. package/src/components/menu/index.ts +64 -0
  79. package/src/components/menu/menu-item.ts +46 -3
  80. package/src/components/menu/menu.ts +77 -1
  81. package/src/components/menu/types.ts +404 -39
  82. package/src/components/sheet/config.ts +1 -2
  83. package/src/components/sheet/features/gestures.ts +1 -1
  84. package/src/components/sheet/features/position.ts +1 -2
  85. package/src/components/sheet/features/state.ts +1 -1
  86. package/src/components/sheet/index.ts +10 -2
  87. package/src/components/sheet/sheet.ts +1 -2
  88. package/src/components/sheet/types.ts +29 -1
  89. package/src/components/slider/api.ts +1 -1
  90. package/src/components/slider/config.ts +1 -1
  91. package/src/components/slider/features/controller.ts +1 -1
  92. package/src/components/slider/features/handlers.ts +1 -1
  93. package/src/components/slider/features/states.ts +1 -1
  94. package/src/components/slider/index.ts +12 -5
  95. package/src/components/slider/schema.ts +1 -1
  96. package/src/components/slider/types.ts +31 -0
  97. package/src/components/tabs/tab-api.ts +1 -1
  98. package/src/components/tabs/types.ts +1 -1
  99. package/src/components/tooltip/api.ts +6 -2
  100. package/src/components/tooltip/config.ts +9 -28
  101. package/src/components/tooltip/index.ts +10 -1
  102. package/src/components/tooltip/types.ts +38 -3
  103. package/src/index.ts +129 -31
  104. package/src/styles/abstract/_mixins.scss +23 -9
  105. package/src/styles/abstract/_variables.scss +14 -4
  106. package/src/styles/components/_card.scss +1 -1
  107. package/src/styles/components/_chip.scss +323 -113
  108. package/src/styles/components/_tabs.scss +1 -1
  109. package/CLAUDE.md +0 -33
  110. package/src/components/checkbox/constants.ts +0 -37
  111. package/src/components/chip/chip-set.ts +0 -225
  112. package/src/components/chip/chip.ts +0 -118
  113. package/src/components/chip/constants.ts +0 -28
  114. package/src/components/chip/index.ts +0 -12
  115. package/src/components/list/constants.ts +0 -116
  116. package/src/components/sheet/constants.ts +0 -20
  117. package/src/components/slider/constants.ts +0 -32
  118. package/src/components/tooltip/constants.ts +0 -27
  119. package/test/components/badge.test.ts +0 -545
  120. package/test/components/bottom-app-bar.test.ts +0 -303
  121. package/test/components/button.test.ts +0 -233
  122. package/test/components/card.test.ts +0 -560
  123. package/test/components/carousel.test.ts +0 -951
  124. package/test/components/checkbox.test.ts +0 -462
  125. package/test/components/chip.test.ts +0 -692
  126. package/test/components/datepicker.test.ts +0 -1124
  127. package/test/components/dialog.test.ts +0 -990
  128. package/test/components/divider.test.ts +0 -412
  129. package/test/components/extended-fab.test.ts +0 -672
  130. package/test/components/fab.test.ts +0 -561
  131. package/test/components/list.test.ts +0 -365
  132. package/test/components/menu.test.ts +0 -718
  133. package/test/components/navigation.test.ts +0 -186
  134. package/test/components/progress.test.ts +0 -567
  135. package/test/components/radios.test.ts +0 -699
  136. package/test/components/search.test.ts +0 -1135
  137. package/test/components/segmented-button.test.ts +0 -732
  138. package/test/components/sheet.test.ts +0 -641
  139. package/test/components/slider.test.ts +0 -1220
  140. package/test/components/snackbar.test.ts +0 -461
  141. package/test/components/switch.test.ts +0 -452
  142. package/test/components/tabs.test.ts +0 -1369
  143. package/test/components/textfield.test.ts +0 -400
  144. package/test/components/timepicker.test.ts +0 -592
  145. package/test/components/tooltip.test.ts +0 -630
  146. package/test/components/top-app-bar.test.ts +0 -566
  147. package/test/core/dom.attributes.test.ts +0 -148
  148. package/test/core/dom.classes.test.ts +0 -152
  149. package/test/core/dom.events.test.ts +0 -243
  150. package/test/core/emitter.test.ts +0 -141
  151. package/test/core/ripple.test.ts +0 -99
  152. package/test/core/state.store.test.ts +0 -189
  153. package/test/core/utils.normalize.test.ts +0 -61
  154. package/test/core/utils.object.test.ts +0 -120
  155. package/test/setup.js +0 -371
  156. package/test/setup.ts +0 -451
  157. package/tsconfig.json +0 -22
  158. package/typedoc.json +0 -28
  159. package/typedoc.simple.json +0 -14
@@ -1,196 +1,561 @@
1
1
  // src/components/menu/types.ts
2
2
 
3
3
  /**
4
- * Menu alignment options
4
+ * Menu horizontal alignment options
5
+ *
6
+ * Determines how the menu is horizontally aligned relative to its anchor element.
7
+ *
5
8
  * @category Components
9
+ * @example
10
+ * ```typescript
11
+ * // Position menu with right alignment
12
+ * menu.position(buttonElement, { align: 'right' });
13
+ * ```
6
14
  */
7
15
  export type MenuAlign = 'left' | 'right' | 'center';
8
16
 
9
17
  /**
10
18
  * Menu vertical alignment options
19
+ *
20
+ * Determines how the menu is vertically positioned relative to its anchor element.
21
+ *
11
22
  * @category Components
23
+ * @example
24
+ * ```typescript
25
+ * // Position menu above the anchor element
26
+ * menu.position(buttonElement, { vAlign: 'top' });
27
+ * ```
12
28
  */
13
29
  export type MenuVerticalAlign = 'top' | 'bottom' | 'middle';
14
30
 
15
31
  /**
16
32
  * Menu item types
33
+ *
34
+ * Defines the different types of items that can be added to a menu.
35
+ * - 'item': Standard selectable menu item (default)
36
+ * - 'divider': Horizontal line separating groups of menu items
37
+ *
17
38
  * @category Components
39
+ * @example
40
+ * ```typescript
41
+ * // Adding a divider between menu items
42
+ * menu.addItem({ type: 'divider' });
43
+ * ```
18
44
  */
19
45
  export type MenuItemType = 'item' | 'divider';
20
46
 
21
47
  /**
22
48
  * Menu events
49
+ *
50
+ * Events that can be subscribed to for the Menu component.
51
+ * - 'select': Fired when a menu item is selected
52
+ * - 'open': Fired when the menu is shown
53
+ * - 'close': Fired when the menu is hidden
54
+ * - 'submenuOpen': Fired when a submenu is opened
55
+ * - 'submenuClose': Fired when a submenu is closed
56
+ *
23
57
  * @category Components
58
+ * @example
59
+ * ```typescript
60
+ * // Listen for menu open events
61
+ * menu.on('open', () => {
62
+ * console.log('Menu opened');
63
+ * });
64
+ *
65
+ * // Listen for item selection
66
+ * menu.on('select', (event) => {
67
+ * console.log(`Selected item: ${event.name}`);
68
+ * });
69
+ * ```
24
70
  */
25
71
  export type MenuEvent = 'select' | 'open' | 'close' | 'submenuOpen' | 'submenuClose';
26
72
 
27
73
  /**
28
74
  * Menu item configuration
75
+ *
76
+ * Configuration object for individual menu items.
77
+ *
78
+ * @category Components
79
+ * @example
80
+ * ```typescript
81
+ * // Basic menu item
82
+ * const basicItem: MenuItemConfig = {
83
+ * name: 'edit',
84
+ * text: 'Edit Document'
85
+ * };
86
+ *
87
+ * // Disabled menu item
88
+ * const disabledItem: MenuItemConfig = {
89
+ * name: 'print',
90
+ * text: 'Print',
91
+ * disabled: true
92
+ * };
93
+ *
94
+ * // Menu item with a submenu
95
+ * const itemWithSubmenu: MenuItemConfig = {
96
+ * name: 'share',
97
+ * text: 'Share',
98
+ * items: [
99
+ * { name: 'email', text: 'Email' },
100
+ * { name: 'link', text: 'Copy Link' }
101
+ * ]
102
+ * };
103
+ *
104
+ * // Divider item
105
+ * const divider: MenuItemConfig = { type: 'divider' };
106
+ * ```
29
107
  */
30
108
  export interface MenuItemConfig {
31
- /** Unique identifier for the item */
109
+ /**
110
+ * Unique identifier for the item
111
+ * Used for identifying the item when handling selection events
112
+ */
32
113
  name: string;
33
114
 
34
- /** Text content for the item */
115
+ /**
116
+ * Text content displayed for the item
117
+ * This is the visible label shown in the menu
118
+ */
35
119
  text: string;
36
120
 
37
- /** Type of menu item */
121
+ /**
122
+ * Type of menu item
123
+ * Defaults to 'item' if not specified
124
+ */
38
125
  type?: MenuItemType | string;
39
126
 
40
- /** Whether the item is disabled */
127
+ /**
128
+ * Whether the item is disabled
129
+ * Disabled items can't be selected and appear visually muted
130
+ */
41
131
  disabled?: boolean;
42
132
 
43
- /** Additional CSS classes */
133
+ /**
134
+ * Additional CSS classes to apply to the item
135
+ * Useful for custom styling or visual indicators
136
+ */
44
137
  class?: string;
45
138
 
46
- /** Submenu items */
139
+ /**
140
+ * Submenu items
141
+ * Creates a nested menu that appears when this item is hovered
142
+ */
47
143
  items?: MenuItemConfig[];
48
144
  }
49
145
 
50
146
  /**
51
- * Position configuration
147
+ * Menu position configuration
148
+ *
149
+ * Configures how a menu is positioned relative to an anchor element.
150
+ * This allows for precise control over menu placement in the UI.
151
+ *
152
+ * @category Components
153
+ * @example
154
+ * ```typescript
155
+ * // Position menu at the bottom-right of the anchor with additional offset
156
+ * menu.position(buttonElement, {
157
+ * align: 'right',
158
+ * vAlign: 'bottom',
159
+ * offsetX: 5,
160
+ * offsetY: 10
161
+ * });
162
+ *
163
+ * // Center align menu below the anchor
164
+ * menu.position(buttonElement, {
165
+ * align: 'center',
166
+ * vAlign: 'bottom'
167
+ * });
168
+ * ```
52
169
  */
53
170
  export interface MenuPositionConfig {
54
- /** Horizontal alignment */
171
+ /**
172
+ * Horizontal alignment
173
+ * Controls how the menu aligns horizontally with the anchor element
174
+ * @default 'left'
175
+ */
55
176
  align?: MenuAlign | string;
56
177
 
57
- /** Vertical alignment */
178
+ /**
179
+ * Vertical alignment
180
+ * Controls how the menu aligns vertically with the anchor element
181
+ * @default 'bottom'
182
+ */
58
183
  vAlign?: MenuVerticalAlign | string;
59
184
 
60
- /** Horizontal offset in pixels */
185
+ /**
186
+ * Horizontal offset in pixels
187
+ * Additional horizontal offset from the aligned position
188
+ * Positive values move the menu to the right
189
+ * @default 0
190
+ */
61
191
  offsetX?: number;
62
192
 
63
- /** Vertical offset in pixels */
193
+ /**
194
+ * Vertical offset in pixels
195
+ * Additional vertical offset from the aligned position
196
+ * Positive values move the menu downward
197
+ * @default 0
198
+ */
64
199
  offsetY?: number;
65
200
  }
66
201
 
67
202
  /**
68
- * Position result
203
+ * Menu position result
204
+ *
205
+ * Contains the calculated position values for a menu.
206
+ * Used internally by the positioning system.
207
+ *
208
+ * @category Components
209
+ * @internal
69
210
  */
70
211
  export interface MenuPosition {
71
- /** Left position in pixels */
212
+ /**
213
+ * Left position in pixels
214
+ * Absolute position from the left edge of the viewport
215
+ */
72
216
  left: number;
73
217
 
74
- /** Top position in pixels */
218
+ /**
219
+ * Top position in pixels
220
+ * Absolute position from the top edge of the viewport
221
+ */
75
222
  top: number;
76
223
  }
77
224
 
78
225
  /**
79
- * Stored item data
226
+ * Menu item internal data structure
227
+ *
228
+ * Used internally to track menu item DOM elements and their configurations.
229
+ * This helps with item management and event handling.
230
+ *
231
+ * @category Components
232
+ * @internal
80
233
  */
81
234
  export interface MenuItemData {
82
- /** DOM element for the item */
235
+ /**
236
+ * DOM element for the item
237
+ * Reference to the rendered menu item element
238
+ */
83
239
  element: HTMLElement;
84
240
 
85
- /** Item configuration */
241
+ /**
242
+ * Item configuration
243
+ * The configuration that was used to create this item
244
+ */
86
245
  config: MenuItemConfig;
87
246
  }
88
247
 
89
248
  /**
90
249
  * Menu selection event data
250
+ *
251
+ * Contains information about a selected menu item.
252
+ * This is passed to event handlers when an item is selected.
253
+ *
254
+ * @category Components
255
+ * @example
256
+ * ```typescript
257
+ * menu.on('select', (event: MenuSelectEvent) => {
258
+ * console.log(`Selected: ${event.name}`);
259
+ * console.log(`Text: ${event.text}`);
260
+ *
261
+ * // For submenu items, path contains the hierarchy
262
+ * if (event.path) {
263
+ * console.log(`From submenu path: ${event.path.join(' > ')}`);
264
+ * }
265
+ * });
266
+ * ```
91
267
  */
92
268
  export interface MenuSelectEvent {
93
- /** Name of the selected item */
269
+ /**
270
+ * Name of the selected item
271
+ * Matches the name property from MenuItemConfig
272
+ */
94
273
  name: string;
95
274
 
96
- /** Text content of the selected item */
275
+ /**
276
+ * Text content of the selected item
277
+ * The visible text that was displayed in the menu
278
+ */
97
279
  text: string;
98
280
 
99
- /** Path of parent item names (for submenus) */
281
+ /**
282
+ * Path of parent item names (for submenus)
283
+ * For nested menu selections, contains the names of all parent items
284
+ * from top level to the selected item
285
+ */
100
286
  path?: string[];
101
287
  }
102
288
 
103
289
  /**
104
290
  * Configuration interface for the Menu component
291
+ *
292
+ * Provides options for creating and configuring a Menu component.
293
+ *
294
+ * @category Components
295
+ * @example
296
+ * ```typescript
297
+ * // Create a basic menu with initial items
298
+ * const menu = createMenu({
299
+ * items: [
300
+ * { name: 'copy', text: 'Copy' },
301
+ * { name: 'paste', text: 'Paste' },
302
+ * { type: 'divider' },
303
+ * { name: 'delete', text: 'Delete' }
304
+ * ],
305
+ * stayOpenOnSelect: false,
306
+ * class: 'custom-menu'
307
+ * });
308
+ *
309
+ * // Create a submenu
310
+ * const submenu = createMenu({
311
+ * items: [
312
+ * { name: 'option1', text: 'Option 1' },
313
+ * { name: 'option2', text: 'Option 2' }
314
+ * ],
315
+ * parentItem: parentElement
316
+ * });
317
+ * ```
105
318
  */
106
319
  export interface MenuConfig {
107
- /** Initial menu items */
320
+ /**
321
+ * Initial menu items
322
+ * Array of item configurations to populate the menu with
323
+ */
108
324
  items?: MenuItemConfig[];
109
325
 
110
- /** Additional CSS classes */
326
+ /**
327
+ * Additional CSS classes
328
+ * Custom classes to apply to the menu container element
329
+ */
111
330
  class?: string;
112
331
 
113
- /** Whether to keep menu open after selection */
332
+ /**
333
+ * Whether to keep menu open after selection
334
+ * When true, selecting an item will not automatically close the menu
335
+ * @default false
336
+ */
114
337
  stayOpenOnSelect?: boolean;
115
338
 
116
- /** Orgin element that opens the menu */
339
+ /**
340
+ * Origin element that opens the menu
341
+ * Element used to trigger the menu appearance (like a button)
342
+ */
117
343
  origin?: HTMLElement | { element: HTMLElement };
118
344
 
119
- /** Parent item element (for submenus) */
345
+ /**
346
+ * Parent item element (for submenus)
347
+ * For submenus, references the parent menu item this menu belongs to
348
+ */
120
349
  parentItem?: HTMLElement;
121
350
 
122
- /** Prefix for class names */
351
+ /**
352
+ * Prefix for class names
353
+ * Custom prefix for all CSS class names generated by the component
354
+ * @default 'mtrl'
355
+ */
123
356
  prefix?: string;
124
357
 
125
- /** Component name */
358
+ /**
359
+ * Component name
360
+ * Name identifier used in CSS classes and debugging
361
+ * @default 'menu'
362
+ */
126
363
  componentName?: string;
127
364
  }
128
365
 
129
366
  /**
130
367
  * Menu component interface
368
+ *
369
+ * Represents a Material Design 3 menu component that provides a temporary
370
+ * surface containing choices that users can interact with.
371
+ *
372
+ * The menu supports positioning, item management, keyboard navigation,
373
+ * and event handling for user interactions.
374
+ *
375
+ * This interface is implemented by the object returned from the {@link ../menu!default | createMenu} function.
376
+ *
377
+ * @category Components
378
+ * @example
379
+ * ```typescript
380
+ * // Create a menu with items
381
+ * const menu = createMenu({
382
+ * items: [
383
+ * { name: 'edit', text: 'Edit' },
384
+ * { name: 'duplicate', text: 'Duplicate' },
385
+ * { type: 'divider' },
386
+ * { name: 'delete', text: 'Delete' }
387
+ * ]
388
+ * });
389
+ *
390
+ * // Position and show the menu
391
+ * const button = document.getElementById('menuButton');
392
+ * button.addEventListener('click', () => {
393
+ * menu.position(button).show();
394
+ * });
395
+ *
396
+ * // Handle selection
397
+ * menu.on('select', (event) => {
398
+ * console.log(`Selected: ${event.name}`);
399
+ * if (event.name === 'delete') {
400
+ * // Handle delete action
401
+ * }
402
+ * });
403
+ * ```
404
+ *
405
+ * @see {@link ../menu!default | createMenu} for creating menu instances
131
406
  */
132
407
  export interface MenuComponent {
133
- /** The root element of the menu */
408
+ /**
409
+ * The root element of the menu
410
+ * Access to the underlying DOM element for direct manipulation if needed
411
+ */
134
412
  element: HTMLElement;
135
413
 
136
- /** Shows the menu */
414
+ /**
415
+ * Shows the menu
416
+ * Makes the menu visible in the DOM
417
+ * @returns The menu component for method chaining
418
+ */
137
419
  show: () => MenuComponent;
138
420
 
139
- /** Hides the menu */
421
+ /**
422
+ * Hides the menu
423
+ * Makes the menu invisible in the DOM
424
+ * @returns The menu component for method chaining
425
+ */
140
426
  hide: () => MenuComponent;
141
427
 
142
- /** Checks if the menu is visible */
428
+ /**
429
+ * Checks if the menu is visible
430
+ * @returns True if the menu is currently visible
431
+ */
143
432
  isVisible: () => boolean;
144
433
 
145
- /** Positions the menu relative to a target */
434
+ /**
435
+ * Positions the menu relative to a target
436
+ * Places the menu in relation to a target element with customizable alignment
437
+ * @param target - The element to position the menu against
438
+ * @param options - Configuration for how to align the menu
439
+ * @returns The menu component for method chaining
440
+ */
146
441
  position: (target: HTMLElement, options?: MenuPositionConfig) => MenuComponent;
147
442
 
148
- /** Adds a menu item */
443
+ /**
444
+ * Adds a menu item
445
+ * Dynamically adds a new item to the menu
446
+ * @param config - Configuration for the new menu item
447
+ * @returns The menu component for method chaining
448
+ */
149
449
  addItem: (config: MenuItemConfig) => MenuComponent;
150
450
 
151
- /** Removes a menu item by name */
451
+ /**
452
+ * Removes a menu item by name
453
+ * Dynamically removes an item from the menu
454
+ * @param name - Name identifier of the item to remove
455
+ * @returns The menu component for method chaining
456
+ */
152
457
  removeItem: (name: string) => MenuComponent;
153
458
 
154
- /** Gets all menu items */
459
+ /**
460
+ * Gets all menu items
461
+ * @returns A Map of all items in the menu, indexed by item name
462
+ */
155
463
  getItems: () => Map<string, MenuItemData>;
156
464
 
157
- /** Adds event listener */
465
+ /**
466
+ * Adds event listener
467
+ * Subscribes to menu events like 'select', 'open', etc.
468
+ * @param event - The event name to listen for
469
+ * @param handler - Callback function to execute when the event occurs
470
+ * @returns The menu component for method chaining
471
+ */
158
472
  on: (event: string, handler: Function) => MenuComponent;
159
473
 
160
- /** Removes event listener */
474
+ /**
475
+ * Removes event listener
476
+ * Unsubscribes from menu events
477
+ * @param event - The event name to stop listening for
478
+ * @param handler - The handler function to remove
479
+ * @returns The menu component for method chaining
480
+ */
161
481
  off: (event: string, handler: Function) => MenuComponent;
162
482
 
163
- /** Destroys the menu component and cleans up resources */
483
+ /**
484
+ * Destroys the menu component and cleans up resources
485
+ * Removes event listeners and DOM elements to prevent memory leaks
486
+ * @returns The menu component for method chaining
487
+ */
164
488
  destroy: () => MenuComponent;
165
489
  }
166
490
 
167
491
  /**
168
492
  * Base component interface
493
+ *
494
+ * Internal interface representing the base structure for menu components
495
+ * before the public API is applied.
496
+ *
497
+ * @internal
498
+ * @category Components
169
499
  */
170
500
  export interface BaseComponent {
501
+ /** The root DOM element */
171
502
  element: HTMLElement;
503
+
504
+ /** Method to emit events */
172
505
  emit?: (event: string, data: any) => void;
506
+
507
+ /** Method to subscribe to events */
173
508
  on?: (event: string, handler: Function) => any;
509
+
510
+ /** Method to unsubscribe from events */
174
511
  off?: (event: string, handler: Function) => any;
512
+
513
+ /** Method to show the component */
175
514
  show?: () => any;
515
+
516
+ /** Method to hide the component */
176
517
  hide?: () => any;
518
+
519
+ /** Method to check visibility */
177
520
  isVisible?: () => boolean;
521
+
522
+ /** Method to position relative to target */
178
523
  position?: (target: HTMLElement, options?: MenuPositionConfig) => any;
524
+
525
+ /** Method to add an item */
179
526
  addItem?: (config: MenuItemConfig) => any;
527
+
528
+ /** Method to remove an item */
180
529
  removeItem?: (name: string) => any;
530
+
531
+ /** Method to get all items */
181
532
  getItems?: () => Map<string, MenuItemData>;
533
+
534
+ /** Method to close submenus */
182
535
  closeSubmenus?: () => any;
536
+
537
+ /** Method to refresh hover handlers */
183
538
  refreshHoverHandlers?: () => any;
539
+
540
+ /** Lifecycle methods container */
184
541
  lifecycle?: {
185
542
  destroy: () => void;
186
543
  };
544
+
545
+ /** Allow for additional properties */
187
546
  [key: string]: any;
188
547
  }
189
548
 
190
549
  /**
191
550
  * API options interface
551
+ *
552
+ * Internal interface used when applying the API to a component.
553
+ *
554
+ * @internal
555
+ * @category Components
192
556
  */
193
557
  export interface ApiOptions {
558
+ /** Lifecycle methods to include */
194
559
  lifecycle: {
195
560
  destroy: () => void;
196
561
  };
@@ -4,8 +4,7 @@ import {
4
4
  createElementConfig,
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
- import { SheetConfig } from './types';
8
- import { SHEET_VARIANTS, SHEET_POSITIONS } from './constants';
7
+ import { SheetConfig, SHEET_VARIANTS, SHEET_POSITIONS } from './types';
9
8
 
10
9
  /**
11
10
  * Default configuration for the Sheet component
@@ -1,5 +1,5 @@
1
1
  // src/components/sheet/features/gestures.ts
2
- import { SHEET_EVENTS, SHEET_POSITIONS } from '../constants';
2
+ import { SHEET_EVENTS, SHEET_POSITIONS } from '../types';
3
3
 
4
4
  /**
5
5
  * Adds gesture support to a component
@@ -1,6 +1,5 @@
1
1
  // src/components/sheet/features/position.ts
2
- import { SheetConfig } from '../types';
3
- import { SHEET_POSITIONS } from '../constants';
2
+ import { SheetConfig, SHEET_POSITIONS } from '../types';
4
3
 
5
4
  /**
6
5
  * Adds position functionality to a component
@@ -1,5 +1,5 @@
1
1
  // src/components/sheet/features/state.ts
2
- import { SHEET_EVENTS } from '../constants';
2
+ import { SHEET_EVENTS } from '../types';
3
3
 
4
4
  /**
5
5
  * Adds state management functionality to a component
@@ -1,4 +1,12 @@
1
1
  // src/components/sheet/index.ts
2
2
  export { default } from './sheet';
3
- export { SHEET_VARIANTS, SHEET_POSITIONS, SHEET_EVENTS } from './constants';
4
- export { SheetConfig, SheetComponent } from './types';
3
+ export {
4
+ // Constants
5
+ SHEET_VARIANTS,
6
+ SHEET_POSITIONS,
7
+ SHEET_EVENTS,
8
+
9
+ // Types
10
+ SheetConfig,
11
+ SheetComponent
12
+ } from './types';
@@ -17,8 +17,7 @@ import {
17
17
  withGestures
18
18
  } from './features';
19
19
  import { withAPI } from './api';
20
- import { SheetConfig } from './types';
21
- import { SHEET_VARIANTS, SHEET_POSITIONS } from './constants';
20
+ import { SheetConfig, SHEET_VARIANTS, SHEET_POSITIONS } from './types';
22
21
  import { createBaseConfig, getElementConfig, getApiConfig } from './config';
23
22
 
24
23
  /**
@@ -1,5 +1,33 @@
1
1
  // src/components/sheet/types.ts
2
- import { SHEET_VARIANTS, SHEET_POSITIONS } from './constants';
2
+
3
+ /**
4
+ * Sheet variants
5
+ */
6
+ export const SHEET_VARIANTS = {
7
+ STANDARD: 'standard',
8
+ MODAL: 'modal',
9
+ EXPANDED: 'expanded'
10
+ } as const;
11
+
12
+ /**
13
+ * Sheet positions
14
+ */
15
+ export const SHEET_POSITIONS = {
16
+ BOTTOM: 'bottom',
17
+ TOP: 'top',
18
+ LEFT: 'left',
19
+ RIGHT: 'right'
20
+ } as const;
21
+
22
+ /**
23
+ * Sheet events
24
+ */
25
+ export const SHEET_EVENTS = {
26
+ OPEN: 'open',
27
+ CLOSE: 'close',
28
+ DRAG_START: 'dragstart',
29
+ DRAG_END: 'dragend'
30
+ } as const;
3
31
 
4
32
  /**
5
33
  * Configuration interface for the Sheet component
@@ -1,6 +1,6 @@
1
1
  // src/components/slider/api.ts
2
2
  import { SliderComponent, SliderEvent } from './types';
3
- import { SLIDER_COLORS, SLIDER_SIZES, SLIDER_EVENTS } from './constants';
3
+ import { SLIDER_COLORS, SLIDER_SIZES, SLIDER_EVENTS } from './types';
4
4
 
5
5
  /**
6
6
  * API options interface - structured by feature area