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,4 +1,4 @@
1
- // src/components/chip/types.ts
1
+ // src/components/chips/types.ts
2
2
 
3
3
  /**
4
4
  * Chip variant types
@@ -6,6 +6,25 @@
6
6
  */
7
7
  export type ChipVariant = 'filled' | 'outlined' | 'elevated' | 'assist' | 'filter' | 'input' | 'suggestion';
8
8
 
9
+ /**
10
+ * Available chip event types
11
+ */
12
+ export const CHIP_EVENTS = {
13
+ CHANGE: 'change',
14
+ SELECT: 'select',
15
+ DESELECT: 'deselect',
16
+ REMOVE: 'remove'
17
+ } as const;
18
+
19
+ /**
20
+ * Available chips event types
21
+ */
22
+ export const CHIPS_EVENTS = {
23
+ CHANGE: 'change',
24
+ ADD: 'add',
25
+ REMOVE: 'remove'
26
+ } as const;
27
+
9
28
  /**
10
29
  * Configuration interface for the Chip component
11
30
  * @category Components
@@ -111,58 +130,85 @@ export interface ChipConfig {
111
130
 
112
131
  /**
113
132
  * Function called when the chip selection changes
133
+ * @param {boolean} selected - Whether the chip is selected
134
+ * @param {ChipComponent} chip - The chip component
114
135
  */
115
- onChange?: (chip: ChipComponent) => void;
136
+ onChange?: (selected: boolean, chip: ChipComponent) => void;
116
137
  }
117
138
 
118
139
  /**
119
- * Icon API interface for managing chip icons
140
+ * Configuration interface for the Chips component
120
141
  * @category Components
121
142
  */
122
- export interface IconAPI {
123
- /**
124
- * Sets the icon HTML content
125
- * @param html - HTML string for the icon
126
- * @returns The icon API for chaining
143
+ export interface ChipsConfig {
144
+ /**
145
+ * Array of chip configurations to initialize
146
+ * @default []
127
147
  */
128
- setIcon: (html: string) => IconAPI;
148
+ chips?: ChipConfig[];
129
149
 
130
- /**
131
- * Gets the current icon HTML content
132
- * @returns HTML string for the icon
150
+ /**
151
+ * Whether the chip set is horizontally scrollable
152
+ * @default false
133
153
  */
134
- getIcon: () => string;
154
+ scrollable?: boolean;
155
+
156
+ /**
157
+ * Whether the chip set is vertically stacked
158
+ * @default false
159
+ */
160
+ vertical?: boolean;
161
+
162
+ /**
163
+ * Additional CSS classes
164
+ */
165
+ class?: string;
166
+
167
+ /**
168
+ * CSS selector for filtering behavior
169
+ */
170
+ selector?: string | null;
171
+
172
+ /**
173
+ * Whether multiple chips can be selected simultaneously
174
+ * @default false
175
+ */
176
+ multiSelect?: boolean;
177
+
178
+ /**
179
+ * Callback function when chip selection changes
180
+ */
181
+ onChange?: (selectedValues: (string | null)[], changedValue: string | null) => void;
135
182
 
136
183
  /**
137
- * Gets the icon DOM element
138
- * @returns The icon element or null if not present
184
+ * Component prefix for class names
185
+ * @default 'mtrl'
139
186
  */
140
- getElement: () => HTMLElement | null;
141
- }
142
-
143
- /**
144
- * Text API interface for managing chip text
145
- * @category Components
146
- */
147
- export interface TextAPI {
187
+ prefix?: string;
188
+
148
189
  /**
149
- * Sets the text content
150
- * @param content - Text content
151
- * @returns The text API for chaining
190
+ * Label text for the chips container
152
191
  */
153
- setText: (content: string) => TextAPI;
192
+ label?: string;
154
193
 
155
194
  /**
156
- * Gets the current text content
157
- * @returns Chip text content
195
+ * Position of the label (start or end)
196
+ * @default 'start'
158
197
  */
159
- getText: () => string;
198
+ labelPosition?: 'start' | 'end';
199
+
200
+ /**
201
+ * Schema definition for the component structure
202
+ * @internal
203
+ */
204
+ schema?: any;
160
205
 
161
206
  /**
162
- * Gets the text DOM element
163
- * @returns The text element or null if not present
207
+ * Event handlers for component events
164
208
  */
165
- getElement: () => HTMLElement | null;
209
+ on?: {
210
+ [key: string]: Function;
211
+ };
166
212
  }
167
213
 
168
214
  /**
@@ -173,35 +219,6 @@ export interface ChipComponent {
173
219
  /** The chip's DOM element */
174
220
  element: HTMLElement;
175
221
 
176
- /** API for managing chip text */
177
- text: TextAPI;
178
-
179
- /** API for managing chip icons */
180
- icon: IconAPI;
181
-
182
- /** API for managing disabled state */
183
- disabled: {
184
- /** Enables the chip */
185
- enable: () => void;
186
- /** Disables the chip */
187
- disable: () => void;
188
- /** Checks if the chip is disabled */
189
- isDisabled: () => boolean;
190
- };
191
-
192
- /** API for managing component lifecycle */
193
- lifecycle: {
194
- /** Destroys the component and cleans up resources */
195
- destroy: () => void;
196
- };
197
-
198
- /**
199
- * Gets a class name with the component's prefix
200
- * @param name - Base class name
201
- * @returns Prefixed class name
202
- */
203
- getClass: (name: string) => string;
204
-
205
222
  /**
206
223
  * Gets the chip's value attribute
207
224
  * @returns Chip value
@@ -323,36 +340,130 @@ export interface ChipComponent {
323
340
  }
324
341
 
325
342
  /**
326
- * API options interface
327
- * @internal
328
- */
329
- export interface ApiOptions {
330
- disabled: {
331
- enable: () => void;
332
- disable: () => void;
333
- };
334
- lifecycle: {
335
- destroy: () => void;
336
- };
337
- }
338
-
339
- /**
340
- * Base component interface
341
- * @internal
343
+ * Chips component interface
344
+ * @category Components
342
345
  */
343
- export interface BaseComponent {
346
+ export interface ChipsComponent {
347
+ /** The chips container's DOM element */
344
348
  element: HTMLElement;
345
- getClass: (name?: string) => string;
346
- config: any;
347
- text?: TextAPI;
348
- icon?: IconAPI;
349
- disabled?: {
350
- enable: () => void;
351
- disable: () => void;
352
- isDisabled: () => boolean;
353
- };
354
- lifecycle?: {
355
- destroy: () => void;
356
- };
357
- [key: string]: any;
349
+
350
+ /**
351
+ * Adds a new chip to the chips container
352
+ * @param chipConfig - Configuration for the chip
353
+ * @returns The chips instance for chaining
354
+ */
355
+ addChip: (chipConfig: ChipConfig) => ChipsComponent;
356
+
357
+ /**
358
+ * Removes a chip from the chips container
359
+ * @param chipOrIndex - Chip instance or index to remove
360
+ * @returns The chips instance for chaining
361
+ */
362
+ removeChip: (chipOrIndex: ChipComponent | number) => ChipsComponent;
363
+
364
+ /**
365
+ * Gets all chip instances in the set
366
+ * @returns Array of chip instances
367
+ */
368
+ getChips: () => ChipComponent[];
369
+
370
+ /**
371
+ * Gets currently selected chips
372
+ * @returns Array of selected chip instances
373
+ */
374
+ getSelectedChips: () => ChipComponent[];
375
+
376
+ /**
377
+ * Gets the values of selected chips
378
+ * @returns Array of selected chip values
379
+ */
380
+ getSelectedValues: () => (string | null)[];
381
+
382
+ /**
383
+ * Selects chips by their values
384
+ * @param values - Value or array of values to select
385
+ * @param triggerEvent - Whether to trigger change event (default: true)
386
+ * @returns The chips instance for chaining
387
+ */
388
+ selectByValue: (values: string | string[], triggerEvent?: boolean) => ChipsComponent;
389
+
390
+ /**
391
+ * Clears all selections
392
+ * @returns The chips instance for chaining
393
+ */
394
+ clearSelection: () => ChipsComponent;
395
+
396
+ /**
397
+ * Sets the scrollable state of the chips container
398
+ * @param isScrollable - Whether the chips container should be scrollable
399
+ * @returns The chips instance for chaining
400
+ */
401
+ setScrollable: (isScrollable: boolean) => ChipsComponent;
402
+
403
+ /**
404
+ * Sets the vertical layout state
405
+ * @param isVertical - Whether the chips container should be vertically stacked
406
+ * @returns The chips instance for chaining
407
+ */
408
+ setVertical: (isVertical: boolean) => ChipsComponent;
409
+
410
+ /**
411
+ * Sets the label text
412
+ * @param text - Label text
413
+ * @returns The chips instance for chaining
414
+ */
415
+ setLabel: (text: string) => ChipsComponent;
416
+
417
+ /**
418
+ * Gets the label text
419
+ * @returns Label text
420
+ */
421
+ getLabel: () => string;
422
+
423
+ /**
424
+ * Sets the label position
425
+ * @param position - Label position ('start' or 'end')
426
+ * @returns The chips instance for chaining
427
+ */
428
+ setLabelPosition: (position: 'start' | 'end') => ChipsComponent;
429
+
430
+ /**
431
+ * Gets the label position
432
+ * @returns Label position
433
+ */
434
+ getLabelPosition: () => string;
435
+
436
+ /**
437
+ * Scrolls to a specific chip
438
+ * @param chipOrIndex - Chip instance or index to scroll to
439
+ * @returns The chips instance for chaining
440
+ */
441
+ scrollToChip: (chipOrIndex: ChipComponent | number) => ChipsComponent;
442
+
443
+ /**
444
+ * Enables keyboard navigation between chips in the set
445
+ * @returns The chips instance for chaining
446
+ */
447
+ enableKeyboardNavigation: () => ChipsComponent;
448
+
449
+ /**
450
+ * Destroys the chips container and all contained chips
451
+ */
452
+ destroy: () => void;
453
+
454
+ /**
455
+ * Adds an event listener to the chips container
456
+ * @param event - Event name ('change', etc.)
457
+ * @param handler - Event handler function
458
+ * @returns The chips instance for chaining
459
+ */
460
+ on: (event: string, handler: Function) => ChipsComponent;
461
+
462
+ /**
463
+ * Removes an event listener from the chips container
464
+ * @param event - Event name
465
+ * @param handler - Event handler function
466
+ * @returns The chips instance for chaining
467
+ */
468
+ off: (event: string, handler: Function) => ChipsComponent;
358
469
  }
@@ -1,4 +1,22 @@
1
1
  // src/components/dialog/dialog.ts
2
+ /**
3
+ * Dialog Component Implementation
4
+ *
5
+ * This module implements a Material Design 3 dialog component that can be
6
+ * used for alerts, confirmations, form submissions, and complex interactions.
7
+ *
8
+ * The implementation supports various features including:
9
+ * - Multiple size variants (small, medium, large, fullwidth, fullscreen)
10
+ * - Multiple animation styles
11
+ * - Custom buttons with configurable actions
12
+ * - Dividers for visual separation
13
+ * - Confirmation dialog patterns
14
+ * - Event handling for dialog lifecycle
15
+ *
16
+ * @module components/dialog
17
+ * @category Components
18
+ */
19
+
2
20
  import { pipe } from '../../core/compose';
3
21
  import { createBase, withElement } from '../../core/compose/component';
4
22
  import { withEvents, withLifecycle } from '../../core/compose/features';
@@ -16,28 +34,93 @@ import { DialogConfig, DialogComponent } from './types';
16
34
  import { createBaseConfig, getElementConfig, getApiConfig } from './config';
17
35
 
18
36
  /**
19
- * Creates a new Dialog component
20
- * @param {DialogConfig} config - Dialog configuration object
21
- * @returns {DialogComponent} Dialog component instance
37
+ * Creates a new Dialog component with the specified configuration.
38
+ *
39
+ * Dialogs are modal windows that appear in front of app content to
40
+ * provide critical information or ask for decisions. They inform
41
+ * users about specific tasks and may contain critical information,
42
+ * require decisions, or involve multiple tasks.
43
+ *
44
+ * @param {DialogConfig} config - Configuration options for the dialog
45
+ * @returns {DialogComponent} A fully configured dialog component instance
46
+ * @throws {Error} Throws an error if dialog creation fails
47
+ *
48
+ * @category Components
49
+ *
50
+ * @example
51
+ * // Create a basic dialog with title and content
52
+ * const infoDialog = createDialog({
53
+ * title: 'Information',
54
+ * content: 'Your changes have been saved.',
55
+ * size: 'small',
56
+ * buttons: [
57
+ * { text: 'OK', variant: 'text', closeDialog: true }
58
+ * ]
59
+ * });
60
+ *
61
+ * document.body.appendChild(infoDialog.element);
62
+ * infoDialog.open();
63
+ *
64
+ * @example
65
+ * // Create a form dialog with multiple buttons
66
+ * const formDialog = createDialog({
67
+ * title: 'Edit Profile',
68
+ * content: '<form id="profile-form">...</form>',
69
+ * size: 'medium',
70
+ * closeOnEscape: true,
71
+ * closeOnOverlayClick: false,
72
+ * buttons: [
73
+ * {
74
+ * text: 'Save',
75
+ * variant: 'filled',
76
+ * onClick: (event, dialog) => {
77
+ * const form = document.getElementById('profile-form');
78
+ * if(form.checkValidity()) {
79
+ * saveProfile(form);
80
+ * dialog.close();
81
+ * }
82
+ * }
83
+ * },
84
+ * { text: 'Cancel', variant: 'text', closeDialog: true }
85
+ * ]
86
+ * });
87
+ *
88
+ * @example
89
+ * // Create a confirmation dialog using the Promise-based API
90
+ * async function confirmAction() {
91
+ * const dialog = createDialog();
92
+ * const confirmed = await dialog.confirm({
93
+ * title: 'Confirm Action',
94
+ * message: 'Are you sure you want to proceed?',
95
+ * confirmText: 'Yes, proceed',
96
+ * cancelText: 'No, cancel'
97
+ * });
98
+ *
99
+ * if (confirmed) {
100
+ * // User clicked the confirm button
101
+ * performAction();
102
+ * }
103
+ * }
22
104
  */
23
105
  const createDialog = (config: DialogConfig = {}): DialogComponent => {
24
106
  const baseConfig = createBaseConfig(config);
25
107
 
26
108
  try {
27
- // Maintain original order but setup event-based communication
109
+ // Create the dialog through functional composition
110
+ // Each function in the pipe adds specific features to the component
28
111
  const dialog = pipe(
29
- createBase,
30
- withEvents(),
31
- withElement(getElementConfig(baseConfig)),
32
- withStructure(baseConfig), // Keep structure first to create overlay
33
- withVisibility(), // Then add visibility features
34
- withContent(),
35
- withButtons(),
36
- withSize(),
37
- withDivider(), // Simplified divider feature
38
- withConfirm(),
39
- withLifecycle(),
40
- comp => withAPI(getApiConfig(comp))(comp)
112
+ createBase, // Base component
113
+ withEvents(), // Event handling
114
+ withElement(getElementConfig(baseConfig)), // DOM element
115
+ withStructure(baseConfig), // Dialog structure (overlay, header, content, footer)
116
+ withVisibility(), // Open/close functionality
117
+ withContent(), // Content management
118
+ withButtons(), // Footer buttons
119
+ withSize(), // Size variants
120
+ withDivider(), // Header/content divider
121
+ withConfirm(), // Confirmation dialog helpers
122
+ withLifecycle(), // Lifecycle management
123
+ comp => withAPI(getApiConfig(comp))(comp) // Public API
41
124
  )(baseConfig);
42
125
 
43
126
  // Register event handlers from config
@@ -1,5 +1,22 @@
1
1
  // src/components/dialog/index.ts
2
+
3
+ /**
4
+ * Dialog Component Module
5
+ *
6
+ * A Material Design 3 dialog implementation with support for multiple sizes,
7
+ * animations, content types, and interactive features like confirmation.
8
+ *
9
+ * Dialogs inform users about critical information, require decisions,
10
+ * or involve multiple tasks.
11
+ *
12
+ * @module components/dialog
13
+ * @category Components
14
+ */
15
+
16
+ // Main factory function
2
17
  export { default } from './dialog';
18
+
19
+ // TypeScript types and interfaces
3
20
  export {
4
21
  DialogConfig,
5
22
  DialogComponent,
@@ -12,34 +29,113 @@ export {
12
29
  DialogEventType
13
30
  } from './types';
14
31
 
15
- // Export common dialog constants for convenience and backward compatibility
32
+ /**
33
+ * Dialog size constants
34
+ *
35
+ * These constants define the available dialog size variants,
36
+ * controlling the width and height of the dialog.
37
+ *
38
+ * @example
39
+ * import { createDialog, DIALOG_SIZES } from 'mtrl';
40
+ *
41
+ * const dialog = createDialog({
42
+ * title: 'Settings',
43
+ * size: DIALOG_SIZES.MEDIUM
44
+ * });
45
+ *
46
+ * @category Components
47
+ */
16
48
  export const DIALOG_SIZES = {
49
+ /** Small dialog (320px) for simple messages or choices */
17
50
  SMALL: 'small',
51
+ /** Medium dialog (560px) for standard forms or content (default) */
18
52
  MEDIUM: 'medium',
53
+ /** Large dialog (800px) for complex forms or rich content */
19
54
  LARGE: 'large',
55
+ /** Dialog that spans the full width of the viewport with margins */
20
56
  FULLWIDTH: 'fullwidth',
57
+ /** Dialog that takes up the entire viewport (similar to a new page) */
21
58
  FULLSCREEN: 'fullscreen'
22
59
  } as const;
23
60
 
61
+ /**
62
+ * Dialog animation constants
63
+ *
64
+ * These constants define the available dialog opening and closing animations.
65
+ *
66
+ * @example
67
+ * import { createDialog, DIALOG_ANIMATIONS } from 'mtrl';
68
+ *
69
+ * const dialog = createDialog({
70
+ * animation: DIALOG_ANIMATIONS.SCALE
71
+ * });
72
+ *
73
+ * @category Components
74
+ */
24
75
  export const DIALOG_ANIMATIONS = {
76
+ /** Scale up/down animation from center (default) */
25
77
  SCALE: 'scale',
78
+ /** Slide in from bottom, slide out to bottom */
26
79
  SLIDE_UP: 'slide-up',
80
+ /** Slide in from top, slide out to top */
27
81
  SLIDE_DOWN: 'slide-down',
82
+ /** Simple fade in/out animation */
28
83
  FADE: 'fade'
29
84
  } as const;
30
85
 
86
+ /**
87
+ * Dialog footer alignment constants
88
+ *
89
+ * These constants control how buttons in the footer are aligned.
90
+ *
91
+ * @example
92
+ * import { createDialog, DIALOG_FOOTER_ALIGNMENTS } from 'mtrl';
93
+ *
94
+ * const dialog = createDialog({
95
+ * footerAlignment: DIALOG_FOOTER_ALIGNMENTS.RIGHT
96
+ * });
97
+ *
98
+ * @category Components
99
+ */
31
100
  export const DIALOG_FOOTER_ALIGNMENTS = {
101
+ /** Align buttons to the right (default, follows Material Design guidelines) */
32
102
  RIGHT: 'right',
103
+ /** Align buttons to the left */
33
104
  LEFT: 'left',
105
+ /** Center buttons in footer */
34
106
  CENTER: 'center',
107
+ /** Space buttons evenly, with first button at left, last at right */
35
108
  SPACE_BETWEEN: 'space-between'
36
109
  } as const;
37
110
 
111
+ /**
112
+ * Dialog event constants
113
+ *
114
+ * These events can be used with the dialog's on() method to respond
115
+ * to changes in the dialog's state.
116
+ *
117
+ * @example
118
+ * import { createDialog, DIALOG_EVENTS } from 'mtrl';
119
+ *
120
+ * const dialog = createDialog();
121
+ *
122
+ * dialog.on(DIALOG_EVENTS.AFTER_OPEN, () => {
123
+ * console.log('Dialog was opened');
124
+ * });
125
+ *
126
+ * @category Components
127
+ */
38
128
  export const DIALOG_EVENTS = {
129
+ /** Fired when the dialog begins opening */
39
130
  OPEN: 'open',
131
+ /** Fired when the dialog begins closing */
40
132
  CLOSE: 'close',
133
+ /** Fired before the dialog starts opening (can be prevented) */
41
134
  BEFORE_OPEN: 'beforeopen',
135
+ /** Fired before the dialog starts closing (can be prevented) */
42
136
  BEFORE_CLOSE: 'beforeclose',
137
+ /** Fired after the dialog has fully opened (animation complete) */
43
138
  AFTER_OPEN: 'afteropen',
139
+ /** Fired after the dialog has fully closed (animation complete) */
44
140
  AFTER_CLOSE: 'afterclose'
45
141
  } as const;