mtrl 0.3.0 → 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 (140) 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 -69
  9. package/package.json +10 -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/navigation/index.ts +4 -1
  83. package/src/components/navigation/types.ts +33 -0
  84. package/src/components/sheet/config.ts +1 -2
  85. package/src/components/sheet/features/gestures.ts +1 -1
  86. package/src/components/sheet/features/position.ts +1 -2
  87. package/src/components/sheet/features/state.ts +1 -1
  88. package/src/components/sheet/index.ts +10 -2
  89. package/src/components/sheet/sheet.ts +1 -2
  90. package/src/components/sheet/types.ts +29 -1
  91. package/src/components/slider/api.ts +1 -1
  92. package/src/components/slider/config.ts +1 -1
  93. package/src/components/slider/features/controller.ts +1 -1
  94. package/src/components/slider/features/handlers.ts +1 -1
  95. package/src/components/slider/features/states.ts +1 -1
  96. package/src/components/slider/index.ts +12 -5
  97. package/src/components/slider/schema.ts +1 -1
  98. package/src/components/slider/types.ts +31 -0
  99. package/src/components/snackbar/index.ts +7 -1
  100. package/src/components/snackbar/types.ts +25 -0
  101. package/src/components/switch/index.ts +5 -1
  102. package/src/components/switch/types.ts +13 -0
  103. package/src/components/tabs/tab-api.ts +1 -1
  104. package/src/components/tabs/types.ts +1 -1
  105. package/src/components/textfield/index.ts +7 -1
  106. package/src/components/textfield/types.ts +36 -0
  107. package/src/components/tooltip/api.ts +6 -2
  108. package/src/components/tooltip/config.ts +9 -28
  109. package/src/components/tooltip/index.ts +10 -1
  110. package/src/components/tooltip/types.ts +38 -3
  111. package/src/index.ts +129 -31
  112. package/src/styles/abstract/_mixins.scss +23 -9
  113. package/src/styles/abstract/_variables.scss +14 -4
  114. package/src/styles/components/_card.scss +1 -1
  115. package/src/styles/components/_chip.scss +323 -113
  116. package/src/styles/components/_tabs.scss +1 -1
  117. package/src/components/checkbox/constants.ts +0 -37
  118. package/src/components/chip/chip-set.ts +0 -225
  119. package/src/components/chip/chip.ts +0 -118
  120. package/src/components/chip/constants.ts +0 -28
  121. package/src/components/chip/index.ts +0 -12
  122. package/src/components/list/constants.ts +0 -116
  123. package/src/components/sheet/constants.ts +0 -20
  124. package/src/components/slider/constants.ts +0 -32
  125. package/src/components/snackbar/constants.ts +0 -26
  126. package/src/components/tooltip/constants.ts +0 -27
  127. package/test/components/button.test.js +0 -170
  128. package/test/components/checkbox.test.js +0 -238
  129. package/test/components/list.test.js +0 -105
  130. package/test/components/menu.test.js +0 -385
  131. package/test/components/navigation.test.js +0 -227
  132. package/test/components/snackbar.test.js +0 -234
  133. package/test/components/switch.test.js +0 -186
  134. package/test/components/textfield.test.js +0 -314
  135. package/test/core/emitter.test.js +0 -141
  136. package/test/core/ripple.test.js +0 -66
  137. package/test/setup.js +0 -371
  138. package/tsconfig.json +0 -22
  139. package/typedoc.json +0 -28
  140. package/typedoc.simple.json +0 -14
@@ -20,11 +20,13 @@ interface SwipeableConfig {
20
20
  }
21
21
 
22
22
  /**
23
- * Higher-order function to add loading state to a card
23
+ * Higher-order function to add loading state to a card.
24
+ * Adds a loading overlay with spinner and proper ARIA attributes
25
+ * for accessibility during asynchronous operations.
24
26
  *
25
27
  * @param {LoadingConfig} config - Loading state configuration
26
28
  * @returns {Function} Card component enhancer
27
- *
29
+ * @category Components
28
30
  * @example
29
31
  * ```typescript
30
32
  * // Create a card with loading state
@@ -35,6 +37,9 @@ interface SwipeableConfig {
35
37
  *
36
38
  * // Toggle loading state
37
39
  * setTimeout(() => card.loading.setLoading(false), 2000);
40
+ *
41
+ * // Check loading state
42
+ * console.log(card.loading.isLoading()); // false after timeout
38
43
  * ```
39
44
  */
40
45
  export const withLoading = (config: LoadingConfig = {}) => (component: BaseComponent): BaseComponent & { loading: LoadingFeature } => {
@@ -90,14 +95,18 @@ export const withLoading = (config: LoadingConfig = {}) => (component: BaseCompo
90
95
  };
91
96
 
92
97
  /**
93
- * Higher-order function to add elevation to a card based on its variant
98
+ * Higher-order function to add elevation to a card based on its variant.
94
99
  *
95
100
  * Sets the initial elevation CSS variable according to Material Design 3 guidelines:
96
101
  * - Elevated variant: 1dp elevation
97
102
  * - Filled and outlined variants: 0dp elevation
98
103
  *
104
+ * These elevation values affect shadows and surface appearance of the card
105
+ * to create appropriate visual hierarchy.
106
+ *
99
107
  * @param {BaseComponent} component - Card component
100
108
  * @returns {BaseComponent} Card component with elevation applied
109
+ * @category Components
101
110
  * @example
102
111
  * ```typescript
103
112
  * // Apply elevation in the composition chain
@@ -122,11 +131,13 @@ export const withElevation = (component: BaseComponent): BaseComponent => {
122
131
  };
123
132
 
124
133
  /**
125
- * Higher-order function to add expandable behavior to a card
134
+ * Higher-order function to add expandable behavior to a card.
135
+ * Creates a collapsible section with proper accessibility attributes and
136
+ * toggle controls. Supports keyboard interaction and screen readers.
126
137
  *
127
138
  * @param {ExpandableConfig} config - Expandable configuration
128
139
  * @returns {Function} Card component enhancer
129
- *
140
+ * @category Components
130
141
  * @example
131
142
  * ```typescript
132
143
  * // Create a card with expandable content
@@ -143,6 +154,11 @@ export const withElevation = (component: BaseComponent): BaseComponent => {
143
154
  *
144
155
  * // Later toggle the expanded state
145
156
  * card.expandable.toggleExpanded();
157
+ *
158
+ * // Or check current state
159
+ * if (card.expandable.isExpanded()) {
160
+ * console.log('Card is expanded');
161
+ * }
146
162
  * ```
147
163
  */
148
164
  export const withExpandable = (config: ExpandableConfig = {}) => (component: BaseComponent): BaseComponent & { expandable: ExpandableFeature } => {
@@ -249,22 +265,33 @@ export const withExpandable = (config: ExpandableConfig = {}) => (component: Bas
249
265
  };
250
266
 
251
267
  /**
252
- * Higher-order function to add swipeable behavior to a card
268
+ * Higher-order function to add swipeable behavior to a card.
269
+ * Implements touch-based swipe gestures with customizable threshold and callbacks.
270
+ * Includes keyboard accessibility support and visual feedback during swipe.
253
271
  *
254
- * @param {SwipeableConfig} config - Swipeable configuration
272
+ * @param {SwipeableConfig} config - Swipeable configuration
255
273
  * @returns {Function} Card component enhancer
256
- *
274
+ * @category Components
257
275
  * @example
258
276
  * ```typescript
259
- * // Create a swipeable card
277
+ * // Create a swipeable card with custom actions
260
278
  * const card = pipe(
261
279
  * createCard,
262
280
  * withSwipeable({
263
- * threshold: 100,
264
- * onSwipeLeft: (card) => console.log('Swiped left'),
265
- * onSwipeRight: (card) => console.log('Swiped right')
281
+ * threshold: 100, // Swipe sensitivity in pixels
282
+ * onSwipeLeft: (card) => {
283
+ * console.log('Swiped left');
284
+ * // For example: Delete or archive action
285
+ * },
286
+ * onSwipeRight: (card) => {
287
+ * console.log('Swiped right');
288
+ * // For example: Save or favorite action
289
+ * }
266
290
  * })
267
291
  * )({ variant: 'elevated' });
292
+ *
293
+ * // Reset card position programmatically
294
+ * card.swipeable.reset();
268
295
  * ```
269
296
  */
270
297
  export const withSwipeable = (config: SwipeableConfig = {}) => (component: BaseComponent): BaseComponent & { swipeable: SwipeableFeature } => {
@@ -2,16 +2,90 @@
2
2
  import defaultCreateCard from './card';
3
3
 
4
4
  /**
5
- * Card Component Module
5
+ * @module Card
6
6
  *
7
- * This module exports the Card components and related utilities following
8
- * Material Design 3 specifications.
7
+ * Card component following Material Design 3 guidelines.
8
+ * Cards are surfaces that display content and actions about a single topic.
9
+ * They should be easy to scan for relevant and actionable information.
10
+ *
11
+ * The main export is the {@link default | createCard} factory function that creates
12
+ * a {@link CardComponent} instance with the provided configuration.
13
+ *
14
+ * Features:
15
+ * - Multiple variants: elevated, filled, and outlined
16
+ * - Support for header, content, media, and actions sections
17
+ * - Interactive behavior with elevation changes on hover
18
+ * - Draggable capability
19
+ * - Expandable content support
20
+ * - Loading state indication
21
+ * - Swipe gestures with custom actions
22
+ *
23
+ * The API includes methods for:
24
+ * - {@link CardComponent.addContent | Adding content}
25
+ * - {@link CardComponent.setHeader | Setting header}
26
+ * - {@link CardComponent.addMedia | Adding media}
27
+ * - {@link CardComponent.setActions | Setting actions}
28
+ * - {@link CardComponent.makeDraggable | Making cards draggable}
29
+ * - {@link CardComponent.focus | Managing focus}
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * // Create a basic card
34
+ * const card = createCard({
35
+ * variant: 'elevated',
36
+ * header: {
37
+ * title: 'Card Title',
38
+ * subtitle: 'Secondary text'
39
+ * },
40
+ * content: {
41
+ * text: 'Card content goes here.'
42
+ * },
43
+ * buttons: [
44
+ * { text: 'Action', variant: 'text' }
45
+ * ]
46
+ * });
47
+ *
48
+ * // Modify card programmatically using API methods
49
+ * const image = document.createElement('div');
50
+ * image.className = 'mtrl-card-media';
51
+ * image.style.backgroundImage = 'url(path/to/image.jpg)';
52
+ *
53
+ * card.addMedia(image, 'top')
54
+ * .makeDraggable((event) => {
55
+ * console.log('Card drag started');
56
+ * });
57
+ * ```
58
+ *
59
+ * @category Components
9
60
  */
10
61
 
11
- // Add default export
12
- export default defaultCreateCard;
62
+ /**
63
+ * Factory function to create a new Card component.
64
+ * @see CardComponent for the full API reference
65
+ */
66
+ export { default } from './card';
13
67
 
14
- // Export components from content file where they are now merged
68
+ /**
69
+ * Card component types and interfaces
70
+ *
71
+ * These types define the structure and behavior of the Card component.
72
+ */
73
+ export {
74
+ CardVariant,
75
+ CardElevationLevel,
76
+ CardSchema,
77
+ CardHeaderConfig,
78
+ CardContentConfig,
79
+ CardActionsConfig,
80
+ CardMediaConfig,
81
+ CardAriaAttributes,
82
+ CardComponent,
83
+ LoadingFeature,
84
+ ExpandableFeature,
85
+ SwipeableFeature
86
+ } from './types';
87
+
88
+ // Export card content helper functions
15
89
  export {
16
90
  createCardContent,
17
91
  createCardHeader,
@@ -19,7 +93,10 @@ export {
19
93
  createCardMedia
20
94
  } from './content';
21
95
 
22
- // Other exports
96
+ // Export API methods
97
+ export { withAPI } from './api';
98
+
99
+ // Export feature enhancers
23
100
  export {
24
101
  withLoading,
25
102
  withExpandable,
@@ -27,18 +104,6 @@ export {
27
104
  withElevation
28
105
  } from './features';
29
106
 
30
- export {
31
- CardVariant,
32
- CardElevationLevel,
33
- CardSchema,
34
- CardHeaderConfig,
35
- CardContentConfig,
36
- CardActionsConfig,
37
- CardMediaConfig,
38
- CardAriaAttributes,
39
- CardComponent
40
- } from './types';
41
-
42
107
  // Export card constants for backward compatibility
43
108
  export const CARD_VARIANTS = {
44
109
  ELEVATED: 'elevated',
@@ -1,33 +1,65 @@
1
1
  // src/components/card/types.ts
2
2
 
3
3
  /**
4
- * Card variant types
4
+ * Card variant types following Material Design 3 guidelines.
5
+ * - elevated: Card with shadow elevation (default)
6
+ * - filled: Card with filled background color and no elevation
7
+ * - outlined: Card with outline border and no elevation
8
+ *
9
+ * @category Components
5
10
  */
6
11
  export type CardVariant = 'elevated' | 'filled' | 'outlined';
7
12
 
8
13
  /**
9
- * Card elevation levels
14
+ * Card elevation levels in Material Design 3.
15
+ * Specifies the shadow height in density-independent pixels (dp).
16
+ * These values match the CARD_ELEVATION_LEVELS constants.
17
+ *
18
+ * @category Components
10
19
  */
11
20
  export type CardElevationLevel = 0 | 1 | 2 | 4;
12
21
 
13
22
  /**
14
- * Button configuration interface for buttons shorthand
23
+ * Button configuration interface for buttons shorthand.
24
+ * Used in the card's `buttons` configuration property for simple button creation.
25
+ *
15
26
  * @interface ButtonConfig
27
+ * @category Components
16
28
  */
17
29
  export interface ButtonConfig {
18
- /** Button text */
30
+ /** Button text content */
19
31
  text?: string;
20
- /** Button variant */
32
+ /** Button variant (text, outlined, filled, etc.) */
21
33
  variant?: string;
22
- /** Button icon */
34
+ /** Button icon HTML content */
23
35
  icon?: string;
24
- /** Additional button properties */
36
+ /** Additional button properties passed to button component */
25
37
  [key: string]: any;
26
38
  }
27
39
 
28
40
  /**
29
- * Card configuration interface
41
+ * Card configuration interface defining all possible card options.
42
+ * This is the primary configuration interface for creating card components.
43
+ *
30
44
  * @interface CardSchema
45
+ * @category Components
46
+ * @example
47
+ * ```typescript
48
+ * const cardConfig: CardSchema = {
49
+ * variant: 'elevated',
50
+ * interactive: true,
51
+ * header: {
52
+ * title: 'Card Title',
53
+ * subtitle: 'Secondary text'
54
+ * },
55
+ * content: {
56
+ * text: 'Card content text'
57
+ * },
58
+ * buttons: [
59
+ * { text: 'Action', variant: 'text' }
60
+ * ]
61
+ * };
62
+ * ```
31
63
  */
32
64
  export interface CardSchema {
33
65
  /** Card variant type (elevated, filled, outlined) */
@@ -74,8 +106,11 @@ export interface CardSchema {
74
106
  }
75
107
 
76
108
  /**
77
- * ARIA attributes for card accessibility
109
+ * ARIA attributes for card accessibility.
110
+ * These attributes enhance the card's accessibility for assistive technologies.
111
+ *
78
112
  * @interface CardAriaAttributes
113
+ * @category Components
79
114
  */
80
115
  export interface CardAriaAttributes {
81
116
  /** ARIA label */
@@ -91,8 +126,11 @@ export interface CardAriaAttributes {
91
126
  }
92
127
 
93
128
  /**
94
- * Card header configuration
129
+ * Card header configuration.
130
+ * Options for configuring the card's header section with title, subtitle, and actions.
131
+ *
95
132
  * @interface CardHeaderConfig
133
+ * @category Components
96
134
  */
97
135
  export interface CardHeaderConfig {
98
136
  /** Header title text */
@@ -108,8 +146,11 @@ export interface CardHeaderConfig {
108
146
  }
109
147
 
110
148
  /**
111
- * Card content configuration
149
+ * Card content configuration.
150
+ * Options for configuring the card's main content area.
151
+ *
112
152
  * @interface CardContentConfig
153
+ * @category Components
113
154
  */
114
155
  export interface CardContentConfig {
115
156
  /** Text content */
@@ -125,8 +166,11 @@ export interface CardContentConfig {
125
166
  }
126
167
 
127
168
  /**
128
- * Card actions configuration
169
+ * Card actions configuration.
170
+ * Options for configuring the card's action buttons area at the bottom.
171
+ *
129
172
  * @interface CardActionsConfig
173
+ * @category Components
130
174
  */
131
175
  export interface CardActionsConfig {
132
176
  /** Action elements */
@@ -142,8 +186,11 @@ export interface CardActionsConfig {
142
186
  }
143
187
 
144
188
  /**
145
- * Card media configuration
189
+ * Card media configuration.
190
+ * Options for configuring the card's media section (images or other media content).
191
+ *
146
192
  * @interface CardMediaConfig
193
+ * @category Components
147
194
  */
148
195
  export interface CardMediaConfig {
149
196
  /** Image source URL */
@@ -167,8 +214,11 @@ export interface CardMediaConfig {
167
214
  }
168
215
 
169
216
  /**
170
- * Base component interface
217
+ * Base component interface.
218
+ * Core interface that all components extend with basic functionality.
219
+ *
171
220
  * @interface BaseComponent
221
+ * @category Components
172
222
  */
173
223
  export interface BaseComponent {
174
224
  /** The DOM element */
@@ -194,8 +244,11 @@ export interface BaseComponent {
194
244
  }
195
245
 
196
246
  /**
197
- * Touch state interface for touch interactions
247
+ * Touch state interface for touch interactions.
248
+ * Used to track touch events for interactive components.
249
+ *
198
250
  * @interface TouchState
251
+ * @category Components
199
252
  */
200
253
  export interface TouchState {
201
254
  /** Timestamp when touch started */
@@ -209,8 +262,11 @@ export interface TouchState {
209
262
  }
210
263
 
211
264
  /**
212
- * Component lifecycle interface
265
+ * Component lifecycle interface.
266
+ * Defines the lifecycle hooks for component creation, updates, and destruction.
267
+ *
213
268
  * @interface ComponentLifecycle
269
+ * @category Components
214
270
  */
215
271
  export interface ComponentLifecycle {
216
272
  /** Called when component is mounted to DOM */
@@ -222,9 +278,13 @@ export interface ComponentLifecycle {
222
278
  }
223
279
 
224
280
  /**
225
- * Card component configuration
281
+ * Card component configuration.
282
+ * Internal configuration object that extends the user-provided schema
283
+ * with additional required properties.
284
+ *
226
285
  * @interface CardComponentConfig
227
286
  * @extends CardSchema
287
+ * @category Components
228
288
  */
229
289
  export interface CardComponentConfig extends CardSchema {
230
290
  /** Component name */
@@ -234,24 +294,141 @@ export interface CardComponentConfig extends CardSchema {
234
294
  }
235
295
 
236
296
  /**
237
- * Card component interface with methods
297
+ * Card component interface with methods.
298
+ * This is the public API of the card component that users interact with.
299
+ *
238
300
  * @interface CardComponent
239
301
  * @extends BaseComponent
302
+ * @category Components
240
303
  */
241
304
  export interface CardComponent extends BaseComponent {
242
- /** Add content to the card */
305
+ /**
306
+ * Adds content to the card.
307
+ * This method appends content to the card component.
308
+ *
309
+ * @param contentElement - The content element to add
310
+ * @returns The card instance for chaining
311
+ * @example
312
+ * ```typescript
313
+ * const content = document.createElement('div');
314
+ * content.className = 'mtrl-card-content';
315
+ * content.textContent = 'Card content goes here';
316
+ * card.addContent(content);
317
+ * ```
318
+ */
243
319
  addContent: (contentElement: HTMLElement) => CardComponent;
244
- /** Set the card header */
320
+
321
+ /**
322
+ * Sets the card header.
323
+ * Places the header element in the card. When media elements exist,
324
+ * the header is placed after the last media element to ensure proper
325
+ * visual hierarchy following Material Design guidelines.
326
+ *
327
+ * @param headerElement - The header element to add
328
+ * @returns The card instance for chaining
329
+ * @example
330
+ * ```typescript
331
+ * // Add a header after media
332
+ * card.setHeader(headerElement);
333
+ * ```
334
+ */
245
335
  setHeader: (headerElement: HTMLElement) => CardComponent;
246
- /** Add media to the card */
336
+
337
+ /**
338
+ * Adds media to the card.
339
+ * Places media elements at the specified position in the card.
340
+ *
341
+ * @param mediaElement - The media element to add
342
+ * @param position - Position to place media ('top', 'bottom')
343
+ * @returns The card instance for chaining
344
+ * @example
345
+ * ```typescript
346
+ * // Creating media element
347
+ * const media = document.createElement('div');
348
+ * media.className = 'mtrl-card-media';
349
+ *
350
+ * // Adding at the top (default)
351
+ * card.addMedia(media);
352
+ *
353
+ * // Or adding at the bottom
354
+ * card.addMedia(media, 'bottom');
355
+ * ```
356
+ */
247
357
  addMedia: (mediaElement: HTMLElement, position?: 'top' | 'bottom') => CardComponent;
248
- /** Set the card actions */
358
+
359
+ /**
360
+ * Sets the card actions section.
361
+ * Replaces any existing actions with the provided actions element.
362
+ * Actions typically contain buttons or other interactive controls,
363
+ * and are placed at the bottom of the card.
364
+ *
365
+ * @param actionsElement - The actions element to add
366
+ * @returns The card instance for chaining
367
+ * @example
368
+ * ```typescript
369
+ * // Create actions container
370
+ * const actions = document.createElement('div');
371
+ * actions.className = 'mtrl-card-actions';
372
+ *
373
+ * // Add buttons to actions
374
+ * const button = document.createElement('button');
375
+ * button.textContent = 'Action';
376
+ * actions.appendChild(button);
377
+ *
378
+ * // Set actions on card
379
+ * card.setActions(actions);
380
+ * ```
381
+ */
249
382
  setActions: (actionsElement: HTMLElement) => CardComponent;
250
- /** Make the card draggable */
383
+
384
+ /**
385
+ * Makes the card draggable.
386
+ * Sets up native HTML5 drag and drop functionality and adds appropriate
387
+ * accessibility attributes. Automatically updates ARIA attributes during drag.
388
+ *
389
+ * @param dragStartCallback - Callback for drag start event
390
+ * @returns The card instance for chaining
391
+ * @example
392
+ * ```typescript
393
+ * // Basic draggable card
394
+ * card.makeDraggable();
395
+ *
396
+ * // With custom drag start handler
397
+ * card.makeDraggable((event) => {
398
+ * // Set custom data or perform other actions on drag start
399
+ * event.dataTransfer.setData('text/plain', 'Card data');
400
+ * });
401
+ * ```
402
+ */
251
403
  makeDraggable: (dragStartCallback?: (event: DragEvent) => void) => CardComponent;
252
- /** Set focus to the card */
404
+
405
+ /**
406
+ * Sets focus to the card.
407
+ * Useful for programmatic focus management, especially in keyboard navigation
408
+ * scenarios or after dynamic content changes.
409
+ *
410
+ * @returns The card instance for chaining
411
+ * @example
412
+ * ```typescript
413
+ * // Focus the card
414
+ * card.focus();
415
+ *
416
+ * // Can be chained with other methods
417
+ * card.setHeader(headerElement).focus();
418
+ * ```
419
+ */
253
420
  focus: () => CardComponent;
254
- /** Destroy the card and clean up resources */
421
+
422
+ /**
423
+ * Destroys the card component and removes event listeners.
424
+ * Call this method when the card is no longer needed to prevent memory leaks.
425
+ *
426
+ * @example
427
+ * ```typescript
428
+ * // Clean up resources when done with the card
429
+ * card.destroy();
430
+ * ```
431
+ */
255
432
  destroy: () => void;
256
433
 
257
434
  /** Optional loading feature */
@@ -263,8 +440,11 @@ export interface CardComponent extends BaseComponent {
263
440
  }
264
441
 
265
442
  /**
266
- * Loading feature interface
443
+ * Loading feature interface.
444
+ * Provides methods to control loading state on the card.
445
+ *
267
446
  * @interface LoadingFeature
447
+ * @category Components
268
448
  */
269
449
  export interface LoadingFeature {
270
450
  /** Check if loading state is active */
@@ -274,8 +454,11 @@ export interface LoadingFeature {
274
454
  }
275
455
 
276
456
  /**
277
- * Expandable feature interface
457
+ * Expandable feature interface.
458
+ * Provides methods to control the expanded/collapsed state of a card.
459
+ *
278
460
  * @interface ExpandableFeature
461
+ * @category Components
279
462
  */
280
463
  export interface ExpandableFeature {
281
464
  /** Check if expanded state is active */
@@ -287,8 +470,11 @@ export interface ExpandableFeature {
287
470
  }
288
471
 
289
472
  /**
290
- * Swipeable feature interface
473
+ * Swipeable feature interface.
474
+ * Provides methods to control the swipe behavior of a card.
475
+ *
291
476
  * @interface SwipeableFeature
477
+ * @category Components
292
478
  */
293
479
  export interface SwipeableFeature {
294
480
  /** Reset swipe position */
@@ -296,8 +482,11 @@ export interface SwipeableFeature {
296
482
  }
297
483
 
298
484
  /**
299
- * API options interface
485
+ * API options interface.
486
+ * Configuration object for the card's API methods.
487
+ *
300
488
  * @interface ApiOptions
489
+ * @category Components
301
490
  */
302
491
  export interface ApiOptions {
303
492
  /** Lifecycle methods */