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,32 +1,72 @@
1
1
  // src/components/fab/api.ts
2
2
  import { FabComponent } from './types';
3
3
 
4
+ /**
5
+ * API configuration options for the FAB component
6
+ *
7
+ * @category Components
8
+ * @internal
9
+ */
4
10
  interface ApiOptions {
11
+ /**
12
+ * Disabled state management API
13
+ */
5
14
  disabled: {
15
+ /** Enables the component */
6
16
  enable: () => void;
17
+ /** Disables the component */
7
18
  disable: () => void;
8
19
  };
20
+
21
+ /**
22
+ * Lifecycle management API
23
+ */
9
24
  lifecycle: {
25
+ /** Destroys the component */
10
26
  destroy: () => void;
11
27
  };
28
+
29
+ /**
30
+ * Base class name for the FAB
31
+ */
12
32
  className: string;
13
33
  }
14
34
 
35
+ /**
36
+ * Base component with element properties
37
+ *
38
+ * @category Components
39
+ * @internal
40
+ */
15
41
  interface ComponentWithElements {
42
+ /** The DOM element */
16
43
  element: HTMLElement;
44
+
45
+ /** Icon management */
17
46
  icon: {
47
+ /** Sets icon HTML content */
18
48
  setIcon: (html: string) => any;
49
+ /** Gets icon HTML content */
19
50
  getIcon: () => string;
51
+ /** Gets icon DOM element */
20
52
  getElement: () => HTMLElement | null;
21
53
  };
54
+
55
+ /** Gets a class name with component's prefix */
22
56
  getClass: (name: string) => string;
23
57
  }
24
58
 
25
59
  /**
26
- * Enhances a FAB component with API methods
60
+ * Enhances a FAB component with public API methods
61
+ *
62
+ * Higher-order function that adds the full public API to the FAB component,
63
+ * exposing methods for changing appearance, handling state, and managing position.
64
+ *
27
65
  * @param {ApiOptions} options - API configuration options
28
66
  * @returns {Function} Higher-order function that adds API methods to component
29
- * @internal This is an internal utility for the FAB component
67
+ *
68
+ * @category Components
69
+ * @internal
30
70
  */
31
71
  export const withAPI = ({ disabled, lifecycle, className }: ApiOptions) =>
32
72
  (component: ComponentWithElements): FabComponent => ({
@@ -8,6 +8,12 @@ import { FabConfig } from './types';
8
8
 
9
9
  /**
10
10
  * Default configuration for the FAB component
11
+ *
12
+ * Provides reasonable defaults for creating FABs
13
+ * according to Material Design 3 guidelines.
14
+ *
15
+ * @category Components
16
+ * @internal
11
17
  */
12
18
  export const defaultConfig: FabConfig = {
13
19
  variant: 'primary',
@@ -18,16 +24,31 @@ export const defaultConfig: FabConfig = {
18
24
 
19
25
  /**
20
26
  * Creates the base configuration for FAB component
27
+ *
28
+ * Merges user-provided configuration with default values and validates
29
+ * the configuration to ensure all required properties have values.
30
+ *
21
31
  * @param {FabConfig} config - User provided configuration
22
32
  * @returns {FabConfig} Complete configuration with defaults applied
33
+ *
34
+ * @category Components
35
+ * @internal
23
36
  */
24
37
  export const createBaseConfig = (config: FabConfig = {}): FabConfig =>
25
38
  createComponentConfig(defaultConfig, config, 'fab') as FabConfig;
26
39
 
27
40
  /**
28
41
  * Generates element configuration for the FAB component
42
+ *
43
+ * Transforms the user-friendly FabConfig into the internal format required
44
+ * by the withElement function. Creates all the appropriate CSS classes and attributes
45
+ * needed to properly render the FAB in the DOM.
46
+ *
29
47
  * @param {FabConfig} config - FAB configuration
30
48
  * @returns {Object} Element configuration object for withElement
49
+ *
50
+ * @category Components
51
+ * @internal
31
52
  */
32
53
  export const getElementConfig = (config: FabConfig) => {
33
54
  // Create the attributes object
@@ -76,8 +97,15 @@ export const getElementConfig = (config: FabConfig) => {
76
97
 
77
98
  /**
78
99
  * Creates API configuration for the FAB component
100
+ *
101
+ * Provides access to various component sub-features like disabled state
102
+ * and lifecycle management.
103
+ *
79
104
  * @param {Object} comp - Component with disabled and lifecycle features
80
- * @returns {Object} API configuration object
105
+ * @returns {Object} API configuration object for withAPI
106
+ *
107
+ * @category Components
108
+ * @internal
81
109
  */
82
110
  export const getApiConfig = (comp: any) => ({
83
111
  disabled: {
@@ -16,14 +16,23 @@ import { createBaseConfig, getElementConfig, getApiConfig } from './config';
16
16
  /**
17
17
  * Creates a new Floating Action Button (FAB) component
18
18
  *
19
+ * Floating Action Buttons (FABs) represent the primary action in an application.
20
+ * They're circular buttons that float above the UI, and typically contain an icon.
21
+ * FABs follow Material Design 3 guidelines with support for multiple variants,
22
+ * sizes, and positioning options.
23
+ *
19
24
  * @param {FabConfig} config - FAB configuration object
20
25
  * @returns {FabComponent} FAB component instance
21
26
  *
27
+ * @throws {Error} If the FAB cannot be created due to invalid configuration
28
+ *
29
+ * @category Components
30
+ *
22
31
  * @example
23
32
  * ```typescript
24
33
  * // Create a default FAB with a plus icon
25
34
  * const fab = createFab({
26
- * icon: '<svg>...</svg>',
35
+ * icon: '<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',
27
36
  * ariaLabel: 'Add new item'
28
37
  * });
29
38
  *
@@ -35,10 +44,15 @@ import { createBaseConfig, getElementConfig, getApiConfig } from './config';
35
44
  * position: 'bottom-right'
36
45
  * });
37
46
  *
38
- * // Add click handler
47
+ * // Add click handler and attach to DOM
39
48
  * fab.on('click', () => {
40
49
  * console.log('FAB clicked');
41
50
  * });
51
+ * document.body.appendChild(fab.element);
52
+ *
53
+ * // Later, update the FAB's appearance
54
+ * fab.setIcon('<span class="material-icons">edit</span>');
55
+ * fab.setPosition('bottom-left');
42
56
  * ```
43
57
  */
44
58
  const createFab = (config: FabConfig = {}): FabComponent => {
@@ -1,4 +1,39 @@
1
1
  // src/components/fab/index.ts
2
+
3
+ /**
4
+ * @module Fab
5
+ *
6
+ * Floating Action Button (FAB) component following Material Design 3 guidelines.
7
+ * FABs are circular buttons that represent the primary action in an application.
8
+ * They are prominently displayed, typically in a fixed position overlaid on the UI.
9
+ *
10
+ * Features:
11
+ * - Multiple variants (primary, secondary, tertiary, surface)
12
+ * - Three size options (small, default, large)
13
+ * - Configurable positioning
14
+ * - Icon support with customization
15
+ * - Ripple effect on interaction
16
+ * - Accessibility support
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * // Create a primary FAB with a plus icon
21
+ * const fab = createFab({
22
+ * icon: '<svg viewBox="0 0 24 24"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></svg>',
23
+ * position: 'bottom-right',
24
+ * ariaLabel: 'Add new item'
25
+ * });
26
+ *
27
+ * // Attach to DOM and add click handler
28
+ * container.appendChild(fab.element);
29
+ * fab.on('click', () => {
30
+ * console.log('FAB clicked');
31
+ * });
32
+ * ```
33
+ *
34
+ * @category Components
35
+ */
36
+
2
37
  export { default, default as createFab } from './fab';
3
38
  export {
4
39
  FabConfig,