mtrl 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/index.ts +2 -0
  2. package/package.json +14 -3
  3. package/src/components/badge/api.ts +23 -14
  4. package/src/components/badge/badge.ts +2 -2
  5. package/src/components/badge/config.ts +10 -11
  6. package/src/components/badge/features.ts +15 -10
  7. package/src/components/badge/index.ts +27 -2
  8. package/src/components/badge/types.ts +28 -8
  9. package/src/components/bottom-app-bar/bottom-app-bar.ts +2 -44
  10. package/src/components/bottom-app-bar/config.ts +1 -45
  11. package/src/components/bottom-app-bar/index.ts +7 -1
  12. package/src/components/bottom-app-bar/types.ts +7 -1
  13. package/src/components/button/button.ts +0 -1
  14. package/src/components/button/config.ts +1 -2
  15. package/src/components/button/index.ts +10 -2
  16. package/src/components/button/types.ts +14 -2
  17. package/src/components/card/config.ts +17 -9
  18. package/src/components/card/content.ts +8 -10
  19. package/src/components/card/features.ts +4 -6
  20. package/src/components/card/index.ts +29 -2
  21. package/src/components/card/types.ts +6 -23
  22. package/src/components/checkbox/config.ts +3 -4
  23. package/src/components/checkbox/index.ts +1 -2
  24. package/src/components/checkbox/types.ts +12 -3
  25. package/src/components/chip/api.ts +170 -221
  26. package/src/components/chip/chip.ts +34 -302
  27. package/src/components/chip/config.ts +1 -2
  28. package/src/components/chip/index.ts +10 -2
  29. package/src/components/chip/types.ts +224 -35
  30. package/src/components/datepicker/api.ts +18 -25
  31. package/src/components/datepicker/config.ts +9 -12
  32. package/src/components/datepicker/datepicker.ts +7 -12
  33. package/src/components/datepicker/index.ts +10 -7
  34. package/src/components/datepicker/render.ts +16 -18
  35. package/src/components/datepicker/types.ts +164 -35
  36. package/src/components/datepicker/utils.ts +1 -2
  37. package/src/components/dialog/api.ts +7 -8
  38. package/src/components/dialog/config.ts +3 -4
  39. package/src/components/dialog/features.ts +56 -22
  40. package/src/components/dialog/index.ts +38 -8
  41. package/src/components/dialog/types.ts +33 -10
  42. package/src/components/divider/index.ts +5 -1
  43. package/src/components/extended-fab/config.ts +6 -2
  44. package/src/components/extended-fab/index.ts +7 -2
  45. package/src/components/extended-fab/types.ts +21 -4
  46. package/src/components/fab/config.ts +3 -4
  47. package/src/components/fab/fab.ts +1 -1
  48. package/src/components/fab/index.ts +7 -2
  49. package/src/components/fab/types.ts +21 -4
  50. package/src/components/list/config.ts +4 -5
  51. package/src/components/list/features.ts +6 -7
  52. package/src/components/list/index.ts +7 -9
  53. package/src/components/list/list-item.ts +12 -13
  54. package/src/components/list/types.ts +50 -5
  55. package/src/components/list/utils.ts +30 -3
  56. package/src/components/menu/features/items-manager.ts +9 -9
  57. package/src/components/menu/features/positioning.ts +7 -7
  58. package/src/components/menu/features/visibility.ts +7 -7
  59. package/src/components/menu/index.ts +7 -9
  60. package/src/components/menu/menu-item.ts +6 -6
  61. package/src/components/menu/menu.ts +22 -0
  62. package/src/components/menu/types.ts +29 -10
  63. package/src/components/menu/utils.ts +67 -0
  64. package/src/components/navigation/api.ts +131 -96
  65. package/src/components/navigation/config.ts +22 -10
  66. package/src/components/navigation/features/controller.ts +273 -0
  67. package/src/components/navigation/features/items.ts +160 -87
  68. package/src/components/navigation/index.ts +0 -6
  69. package/src/components/navigation/nav-item.ts +12 -24
  70. package/src/components/navigation/navigation.ts +21 -8
  71. package/src/components/navigation/system-types.ts +124 -0
  72. package/src/components/navigation/system.ts +776 -0
  73. package/src/components/navigation/types.ts +228 -203
  74. package/src/components/progress/api.ts +2 -3
  75. package/src/components/progress/config.ts +2 -3
  76. package/src/components/progress/index.ts +0 -1
  77. package/src/components/progress/progress.ts +1 -2
  78. package/src/components/progress/types.ts +186 -33
  79. package/src/components/radios/config.ts +1 -1
  80. package/src/components/radios/index.ts +0 -1
  81. package/src/components/radios/types.ts +0 -7
  82. package/src/components/search/config.ts +1 -2
  83. package/src/components/search/features/search.ts +14 -15
  84. package/src/components/search/features/states.ts +5 -1
  85. package/src/components/search/features/structure.ts +3 -4
  86. package/src/components/search/index.ts +0 -3
  87. package/src/components/search/types.ts +18 -6
  88. package/src/components/segmented-button/config.ts +20 -7
  89. package/src/components/segmented-button/segment.ts +6 -7
  90. package/src/components/segmented-button/segmented-button.ts +4 -5
  91. package/src/components/segmented-button/types.ts +37 -2
  92. package/src/components/slider/config.ts +20 -2
  93. package/src/components/slider/features/controller.ts +761 -0
  94. package/src/components/slider/features/handlers.ts +18 -15
  95. package/src/components/slider/features/index.ts +3 -2
  96. package/src/components/slider/features/range.ts +104 -0
  97. package/src/components/slider/slider.ts +34 -14
  98. package/src/components/slider/structure.ts +152 -0
  99. package/src/components/slider/types.ts +34 -8
  100. package/src/components/snackbar/config.ts +2 -3
  101. package/src/components/snackbar/constants.ts +0 -32
  102. package/src/components/snackbar/index.ts +0 -1
  103. package/src/components/snackbar/position.ts +9 -1
  104. package/src/components/snackbar/types.ts +122 -46
  105. package/src/components/switch/config.ts +2 -3
  106. package/src/components/switch/index.ts +0 -1
  107. package/src/components/switch/types.ts +3 -2
  108. package/src/components/tabs/config.ts +3 -4
  109. package/src/components/tabs/index.ts +0 -15
  110. package/src/components/tabs/tab-api.ts +12 -4
  111. package/src/components/tabs/tab.ts +18 -6
  112. package/src/components/tabs/types.ts +13 -3
  113. package/src/components/textfield/api.ts +53 -0
  114. package/src/components/textfield/config.ts +2 -3
  115. package/src/components/textfield/features.ts +322 -0
  116. package/src/components/textfield/index.ts +0 -1
  117. package/src/components/textfield/textfield.ts +8 -0
  118. package/src/components/textfield/types.ts +29 -6
  119. package/src/components/timepicker/api.ts +1 -1
  120. package/src/components/timepicker/clockdial.ts +2 -5
  121. package/src/components/timepicker/config.ts +102 -4
  122. package/src/components/timepicker/index.ts +1 -6
  123. package/src/components/timepicker/render.ts +1 -1
  124. package/src/components/timepicker/timepicker.ts +1 -1
  125. package/src/components/tooltip/api.ts +1 -1
  126. package/src/components/tooltip/config.ts +27 -6
  127. package/src/components/tooltip/index.ts +0 -1
  128. package/src/components/tooltip/types.ts +13 -3
  129. package/src/core/compose/features/textinput.ts +15 -2
  130. package/src/core/compose/features/textlabel.ts +0 -3
  131. package/src/core/composition/features/dom.ts +33 -0
  132. package/src/core/composition/features/icon.ts +131 -0
  133. package/src/core/composition/features/index.ts +11 -0
  134. package/src/core/composition/features/label.ts +156 -0
  135. package/src/core/composition/features/structure.ts +22 -0
  136. package/src/core/composition/index.ts +26 -0
  137. package/src/core/index.ts +1 -1
  138. package/src/core/structure.ts +288 -0
  139. package/src/index.ts +1 -0
  140. package/src/styles/components/_navigation-mobile.scss +244 -0
  141. package/src/styles/components/_navigation-system.scss +151 -0
  142. package/src/{components/tabs/_styles.scss → styles/components/_tabs.scss} +1 -1
  143. package/src/{components/textfield/_styles.scss → styles/components/_textfield.scss} +314 -72
  144. package/src/styles/main.scss +98 -49
  145. package/src/components/badge/constants.ts +0 -40
  146. package/src/components/button/constants.ts +0 -11
  147. package/src/components/card/constants.ts +0 -84
  148. package/src/components/datepicker/constants.ts +0 -98
  149. package/src/components/dialog/constants.ts +0 -32
  150. package/src/components/extended-fab/constants.ts +0 -36
  151. package/src/components/fab/constants.ts +0 -41
  152. package/src/components/menu/constants.ts +0 -154
  153. package/src/components/navigation/constants.ts +0 -200
  154. package/src/components/progress/constants.ts +0 -29
  155. package/src/components/search/constants.ts +0 -21
  156. package/src/components/segmented-button/constants.ts +0 -42
  157. package/src/components/slider/features/slider.ts +0 -318
  158. package/src/components/slider/features/structure.ts +0 -181
  159. package/src/components/slider/features/ui.ts +0 -388
  160. package/src/components/switch/constants.ts +0 -80
  161. package/src/components/tabs/constants.ts +0 -89
  162. package/src/components/textfield/constants.ts +0 -100
  163. package/src/components/timepicker/constants.ts +0 -138
  164. /package/src/{components/badge/_styles.scss → styles/components/_badge.scss} +0 -0
  165. /package/src/{components/bottom-app-bar/_styles.scss → styles/components/_bottom-app-bar.scss} +0 -0
  166. /package/src/{components/button/_styles.scss → styles/components/_button.scss} +0 -0
  167. /package/src/{components/card/_styles.scss → styles/components/_card.scss} +0 -0
  168. /package/src/{components/carousel/_styles.scss → styles/components/_carousel.scss} +0 -0
  169. /package/src/{components/checkbox/_styles.scss → styles/components/_checkbox.scss} +0 -0
  170. /package/src/{components/chip/_styles.scss → styles/components/_chip.scss} +0 -0
  171. /package/src/{components/datepicker/_styles.scss → styles/components/_datepicker.scss} +0 -0
  172. /package/src/{components/dialog/_styles.scss → styles/components/_dialog.scss} +0 -0
  173. /package/src/{components/divider/_styles.scss → styles/components/_divider.scss} +0 -0
  174. /package/src/{components/extended-fab/_styles.scss → styles/components/_extended-fab.scss} +0 -0
  175. /package/src/{components/fab/_styles.scss → styles/components/_fab.scss} +0 -0
  176. /package/src/{components/list/_styles.scss → styles/components/_list.scss} +0 -0
  177. /package/src/{components/menu/_styles.scss → styles/components/_menu.scss} +0 -0
  178. /package/src/{components/navigation/_styles.scss → styles/components/_navigation.scss} +0 -0
  179. /package/src/{components/progress/_styles.scss → styles/components/_progress.scss} +0 -0
  180. /package/src/{components/radios/_styles.scss → styles/components/_radios.scss} +0 -0
  181. /package/src/{components/search/_styles.scss → styles/components/_search.scss} +0 -0
  182. /package/src/{components/segmented-button/_styles.scss → styles/components/_segmented-button.scss} +0 -0
  183. /package/src/{components/sheet/_styles.scss → styles/components/_sheet.scss} +0 -0
  184. /package/src/{components/slider/_styles.scss → styles/components/_slider.scss} +0 -0
  185. /package/src/{components/snackbar/_styles.scss → styles/components/_snackbar.scss} +0 -0
  186. /package/src/{components/switch/_styles.scss → styles/components/_switch.scss} +0 -0
  187. /package/src/{components/timepicker/_styles.scss → styles/components/_timepicker.scss} +0 -0
  188. /package/src/{components/tooltip/_styles.scss → styles/components/_tooltip.scss} +0 -0
  189. /package/src/{components/top-app-bar/_styles.scss → styles/components/_top-app-bar.scss} +0 -0
  190. /package/src/styles/utilities/{_color.scss → _colors.scss} +0 -0
@@ -1,58 +1,134 @@
1
- // src/components/snackbar/constants.ts
1
+ // src/components/snackbar/types.ts
2
2
 
3
3
  /**
4
- * Snackbar visual variants
4
+ * Available snackbar variants
5
5
  */
6
- export const SNACKBAR_VARIANTS = {
7
- BASIC: 'basic',
8
- ACTION: 'action' // With action button
9
- } as const;
6
+ export type SnackbarVariant = 'basic' | 'action';
10
7
 
11
8
  /**
12
- * Snackbar display positions
9
+ * Available snackbar positions
13
10
  */
14
- export const SNACKBAR_POSITIONS = {
15
- CENTER: 'center',
16
- START: 'start',
17
- END: 'end'
18
- } as const;
11
+ export type SnackbarPosition = 'center' | 'start' | 'end';
19
12
 
20
13
  /**
21
- * Validation schema for snackbar configuration
14
+ * Snackbar visibility states
22
15
  */
23
- export const SNACKBAR_SCHEMA = {
24
- variant: {
25
- type: 'string',
26
- enum: Object.values(SNACKBAR_VARIANTS),
27
- required: false
28
- },
29
- position: {
30
- type: 'string',
31
- enum: Object.values(SNACKBAR_POSITIONS),
32
- required: false
33
- },
34
- message: {
35
- type: 'string',
36
- required: true
37
- },
38
- action: {
39
- type: 'string',
40
- required: false
41
- },
42
- duration: {
43
- type: 'number',
44
- required: false
45
- },
46
- class: {
47
- type: 'string',
48
- required: false
49
- }
50
- } as const;
16
+ export type SnackbarState = 'visible' | 'hidden';
51
17
 
52
18
  /**
53
- * Snackbar state classes
19
+ * Available snackbar event types
54
20
  */
55
- export const SNACKBAR_STATES = {
56
- VISIBLE: 'visible',
57
- HIDDEN: 'hidden'
58
- } as const;
21
+ export type SnackbarEventType = 'open' | 'close' | 'action';
22
+
23
+ /**
24
+ * Snackbar event data
25
+ * @interface SnackbarEvent
26
+ */
27
+ export interface SnackbarEvent {
28
+ /** The snackbar component that triggered the event */
29
+ snackbar: SnackbarComponent;
30
+
31
+ /** Original DOM event if available */
32
+ originalEvent: Event | null;
33
+
34
+ /** Function to prevent default behavior */
35
+ preventDefault: () => void;
36
+
37
+ /** Whether default behavior was prevented */
38
+ defaultPrevented: boolean;
39
+ }
40
+
41
+ /**
42
+ * Configuration options for the snackbar component
43
+ * @interface SnackbarConfig
44
+ */
45
+ export interface SnackbarConfig {
46
+ /** Visual variant of the snackbar */
47
+ variant?: SnackbarVariant;
48
+
49
+ /** Position of the snackbar on screen */
50
+ position?: SnackbarPosition;
51
+
52
+ /** Text message to display */
53
+ message: string;
54
+
55
+ /** Action button text (for 'action' variant) */
56
+ action?: string;
57
+
58
+ /** Duration in milliseconds to show the snackbar (0 for indefinite) */
59
+ duration?: number;
60
+
61
+ /** Action button callback function */
62
+ onAction?: (event: SnackbarEvent) => void;
63
+
64
+ /** Callback function when the snackbar opens */
65
+ onOpen?: (event: SnackbarEvent) => void;
66
+
67
+ /** Callback function when the snackbar closes */
68
+ onClose?: (event: SnackbarEvent) => void;
69
+
70
+ /** Additional CSS classes */
71
+ class?: string;
72
+
73
+ /** Component prefix for CSS classes */
74
+ prefix?: string;
75
+
76
+ /** Component name for CSS classes */
77
+ componentName?: string;
78
+
79
+ /** Event handlers for snackbar events */
80
+ on?: {
81
+ [key in SnackbarEventType]?: (event: SnackbarEvent) => void;
82
+ };
83
+ }
84
+
85
+ /**
86
+ * Snackbar component public API interface
87
+ * @interface SnackbarComponent
88
+ */
89
+ export interface SnackbarComponent {
90
+ /** The root element of the snackbar */
91
+ element: HTMLElement;
92
+
93
+ /** Current state of the snackbar */
94
+ state: SnackbarState;
95
+
96
+ /** Displays the snackbar */
97
+ show: () => SnackbarComponent;
98
+
99
+ /** Hides the snackbar */
100
+ hide: () => SnackbarComponent;
101
+
102
+ /** Sets the message text */
103
+ setMessage: (message: string) => SnackbarComponent;
104
+
105
+ /** Gets the message text */
106
+ getMessage: () => string;
107
+
108
+ /** Sets the action button text */
109
+ setAction: (text: string) => SnackbarComponent;
110
+
111
+ /** Gets the action button text */
112
+ getAction: () => string;
113
+
114
+ /** Sets the display duration */
115
+ setDuration: (duration: number) => SnackbarComponent;
116
+
117
+ /** Gets the display duration */
118
+ getDuration: () => number;
119
+
120
+ /** Sets the snackbar position */
121
+ setPosition: (position: SnackbarPosition) => SnackbarComponent;
122
+
123
+ /** Gets the snackbar position */
124
+ getPosition: () => SnackbarPosition;
125
+
126
+ /** Adds event listener */
127
+ on: (event: SnackbarEventType, handler: (event: SnackbarEvent) => void) => SnackbarComponent;
128
+
129
+ /** Removes event listener */
130
+ off: (event: SnackbarEventType, handler: (event: SnackbarEvent) => void) => SnackbarComponent;
131
+
132
+ /** Destroys the snackbar component and cleans up resources */
133
+ destroy: () => void;
134
+ }
@@ -5,13 +5,12 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { SwitchConfig, BaseComponent, ApiOptions } from './types';
8
- import { SWITCH_LABEL_POSITION } from './constants';
9
8
 
10
9
  /**
11
10
  * Default configuration for the Switch component
12
11
  */
13
12
  export const defaultConfig: SwitchConfig = {
14
- labelPosition: SWITCH_LABEL_POSITION.END
13
+ labelPosition: 'end'
15
14
  };
16
15
 
17
16
  /**
@@ -42,7 +41,7 @@ export const getElementConfig = (config: SwitchConfig) =>
42
41
  export const withLabelPosition = (config: SwitchConfig) => (component: BaseComponent): BaseComponent => {
43
42
  if (!config.label) return component;
44
43
 
45
- const position = config.labelPosition || SWITCH_LABEL_POSITION.END;
44
+ const position = config.labelPosition || 'end';
46
45
  const positionClass = `${config.prefix}-switch--label-${position}`;
47
46
 
48
47
  component.element.classList.add(positionClass);
@@ -1,4 +1,3 @@
1
1
  // src/components/switch/index.ts
2
2
  export { default } from './switch'
3
- export { SWITCH_LABEL_POSITION } from './constants'
4
3
  export { SwitchConfig, SwitchComponent } from './types'
@@ -1,5 +1,6 @@
1
1
  // src/components/switch/types.ts
2
- import { SWITCH_LABEL_POSITION } from './constants';
2
+
3
+ export type SwitchPosition = 'center' | 'start' | 'end';
3
4
 
4
5
  /**
5
6
  * Configuration interface for the Switch component
@@ -24,7 +25,7 @@ export interface SwitchConfig {
24
25
  label?: string;
25
26
 
26
27
  /** Label position (start/end) */
27
- labelPosition?: keyof typeof SWITCH_LABEL_POSITION | string;
28
+ labelPosition?: SwitchPosition | string;
28
29
 
29
30
  /** Additional CSS classes */
30
31
  class?: string;
@@ -6,13 +6,12 @@ import {
6
6
  } from '../../core/config/component-config';
7
7
  import { withElement } from '../../core/compose/component';
8
8
  import { TabConfig } from './types';
9
- import { TABS_VARIANTS, TAB_STATES } from './constants';
10
9
 
11
10
  /**
12
11
  * Default configuration for a Tab
13
12
  */
14
13
  export const defaultTabConfig: TabConfig = {
15
- state: TAB_STATES.INACTIVE,
14
+ state: 'inactive',
16
15
  componentName: 'tab',
17
16
  ripple: true
18
17
  };
@@ -21,7 +20,7 @@ export const defaultTabConfig: TabConfig = {
21
20
  * Default configuration for the Tabs component
22
21
  */
23
22
  export const defaultTabsConfig = {
24
- variant: TABS_VARIANTS.PRIMARY,
23
+ variant: 'primary',
25
24
  scrollable: true,
26
25
  showDivider: true,
27
26
  componentName: 'tabs'
@@ -48,7 +47,7 @@ export const getTabsElementConfig = (config) => {
48
47
  },
49
48
  className: [
50
49
  `${config.prefix}-tabs`,
51
- `${config.prefix}-tabs--${config.variant || TABS_VARIANTS.PRIMARY}`,
50
+ `${config.prefix}-tabs--${config.variant || 'primary'}`,
52
51
  config.class
53
52
  ]
54
53
  };
@@ -7,21 +7,6 @@ import { createTabsState } from './state';
7
7
  import { createTabIndicator } from './indicator';
8
8
  import { updateTabPanels, setupKeyboardNavigation } from './utils';
9
9
 
10
- export {
11
- // Main component creators
12
- createTabs,
13
- createTab,
14
-
15
- // Constants
16
- TABS_VARIANTS,
17
- TAB_STATES,
18
- TAB_LAYOUT,
19
- TAB_INTERACTION_STATES,
20
- TAB_ANIMATION,
21
- TAB_A11Y,
22
- TAB_COLORS
23
- } from './constants';
24
-
25
10
  export {
26
11
  // Types
27
12
  TabsConfig,
@@ -1,9 +1,17 @@
1
1
  // src/components/tabs/tab-api.ts
2
2
  import { TabComponent } from './types';
3
- import { TAB_STATES, TAB_LAYOUT } from './constants';
4
3
  import { BadgeComponent } from '../badge/types';
5
4
  import createBadge from '../badge';
6
5
 
6
+ const TAB_LAYOUT = {
7
+ /** Icon-only tab layout */
8
+ ICON_ONLY: 'icon-only',
9
+ /** Text-only tab layout */
10
+ TEXT_ONLY: 'text-only',
11
+ /** Icon and text layout */
12
+ ICON_AND_TEXT: 'icon-and-text'
13
+ }
14
+
7
15
  /**
8
16
  * API options for a Tab component
9
17
  */
@@ -82,7 +90,7 @@ export const withTabAPI = ({ disabled, lifecycle, button }: ApiOptions) =>
82
90
  * Activates the tab
83
91
  */
84
92
  activate() {
85
- component.element.classList.add(`${component.getClass('tab')}--${TAB_STATES.ACTIVE}`);
93
+ component.element.classList.add(`${component.getClass('tab')}--active`);
86
94
  component.element.setAttribute('aria-selected', 'true');
87
95
  return this;
88
96
  },
@@ -91,7 +99,7 @@ export const withTabAPI = ({ disabled, lifecycle, button }: ApiOptions) =>
91
99
  * Deactivates the tab
92
100
  */
93
101
  deactivate() {
94
- component.element.classList.remove(`${component.getClass('tab')}--${TAB_STATES.ACTIVE}`);
102
+ component.element.classList.remove(`${component.getClass('tab')}--active`);
95
103
  component.element.setAttribute('aria-selected', 'false');
96
104
  return this;
97
105
  },
@@ -100,7 +108,7 @@ export const withTabAPI = ({ disabled, lifecycle, button }: ApiOptions) =>
100
108
  * Checks if the tab is active
101
109
  */
102
110
  isActive() {
103
- return component.element.classList.contains(`${component.getClass('tab')}--${TAB_STATES.ACTIVE}`);
111
+ return component.element.classList.contains(`${component.getClass('tab')}--active`);
104
112
  },
105
113
 
106
114
  /**
@@ -8,6 +8,18 @@ import { createTabConfig } from './config';
8
8
  import createButton from '../button';
9
9
  import createBadge from '../badge';
10
10
 
11
+ /**
12
+ * Tab layout types
13
+ */
14
+ export const TAB_LAYOUT = {
15
+ /** Icon-only tab layout */
16
+ ICON_ONLY: 'icon-only',
17
+ /** Text-only tab layout */
18
+ TEXT_ONLY: 'text-only',
19
+ /** Icon and text layout */
20
+ ICON_AND_TEXT: 'icon-and-text'
21
+ };
22
+
11
23
  /**
12
24
  * Creates a new Tab component following MD3 guidelines
13
25
  * @param {TabConfig} config - Tab configuration object
@@ -49,7 +61,7 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
49
61
  // Set up tab accessibility attributes
50
62
  baseComponent.element.setAttribute('role', 'tab');
51
63
  baseComponent.element.setAttribute('aria-selected',
52
- baseConfig.state === TAB_STATES.ACTIVE ? 'true' : 'false');
64
+ baseConfig.state === 'active' ? 'true' : 'false');
53
65
 
54
66
  // For better accessibility
55
67
  if (baseConfig.value) {
@@ -58,8 +70,8 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
58
70
  }
59
71
 
60
72
  // Add active state if specified in config
61
- if (baseConfig.state === TAB_STATES.ACTIVE) {
62
- baseComponent.element.classList.add(`${baseComponent.getClass('tab')}--${TAB_STATES.ACTIVE}`);
73
+ if (baseConfig.state === 'active') {
74
+ baseComponent.element.classList.add(`${baseComponent.getClass('tab')}--active`);
63
75
  }
64
76
 
65
77
  // Forward button events to our component
@@ -95,7 +107,7 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
95
107
  },
96
108
 
97
109
  activate() {
98
- this.element.classList.add(`${this.getClass('tab')}--${TAB_STATES.ACTIVE}`);
110
+ this.element.classList.add(`${this.getClass('tab')}--active`);
99
111
  this.element.setAttribute('aria-selected', 'true');
100
112
 
101
113
  // Dispatch event for screen readers
@@ -109,13 +121,13 @@ export const createTab = (config: TabConfig = {}): TabComponent => {
109
121
  },
110
122
 
111
123
  deactivate() {
112
- this.element.classList.remove(`${this.getClass('tab')}--${TAB_STATES.ACTIVE}`);
124
+ this.element.classList.remove(`${this.getClass('tab')}--active`);
113
125
  this.element.setAttribute('aria-selected', 'false');
114
126
  return this;
115
127
  },
116
128
 
117
129
  isActive() {
118
- return this.element.classList.contains(`${this.getClass('tab')}--${TAB_STATES.ACTIVE}`);
130
+ return this.element.classList.contains(`${this.getClass('tab')}--active`);
119
131
  },
120
132
 
121
133
  enable() {
@@ -1,8 +1,18 @@
1
1
  // src/components/tabs/types.ts
2
- import { TABS_VARIANTS, TAB_STATES, TAB_LAYOUT } from './constants';
3
2
  import { BadgeComponent } from '../badge/types';
4
3
  import { TabIndicator } from './indicator';
5
4
 
5
+ /**
6
+ * Available tabs variants
7
+ */
8
+ export type TabsVariant = 'primary' | 'secondary';
9
+
10
+ /**
11
+ * Available tabs states
12
+ */
13
+
14
+ export type TabStates = 'active' | 'inactive' | 'disabled';
15
+
6
16
  /**
7
17
  * Configuration for the tab indicator
8
18
  * @category Components
@@ -55,7 +65,7 @@ export interface TabConfig {
55
65
  * Tab state that determines if it's the active destination
56
66
  * @default 'inactive'
57
67
  */
58
- state?: keyof typeof TAB_STATES | string;
68
+ state?: TabStates | string;
59
69
 
60
70
  /**
61
71
  * Whether the tab is initially disabled
@@ -154,7 +164,7 @@ export interface TabsConfig {
154
164
  * Tabs variant (primary or secondary)
155
165
  * @default 'primary'
156
166
  */
157
- variant?: keyof typeof TABS_VARIANTS | string;
167
+ variant?: TabsVariant | string;
158
168
 
159
169
  /**
160
170
  * Initial tabs to create
@@ -1,6 +1,11 @@
1
1
  // src/components/textfield/api.ts
2
2
  import { BaseComponent, TextfieldComponent, ApiOptions } from './types';
3
3
 
4
+ /**
5
+ * Enhances textfield component with API methods
6
+ * @param {ApiOptions} options - API configuration
7
+ * @returns {Function} Higher-order function that adds API methods to component
8
+ */
4
9
  /**
5
10
  * Enhances textfield component with API methods
6
11
  * @param {ApiOptions} options - API configuration
@@ -43,6 +48,54 @@ export const withAPI = ({ disabled, lifecycle }: ApiOptions) =>
43
48
  getLabel(): string {
44
49
  return component.label?.getText() || '';
45
50
  },
51
+
52
+ // Leading icon management (if present)
53
+ leadingIcon: component.leadingIcon || null,
54
+ setLeadingIcon(html: string): TextfieldComponent {
55
+ if (component.setLeadingIcon) {
56
+ component.setLeadingIcon(html);
57
+ }
58
+ return this;
59
+ },
60
+
61
+ removeLeadingIcon(): TextfieldComponent {
62
+ if (component.removeLeadingIcon) {
63
+ component.removeLeadingIcon();
64
+ }
65
+ return this;
66
+ },
67
+
68
+ // Trailing icon management (if present)
69
+ trailingIcon: component.trailingIcon || null,
70
+ setTrailingIcon(html: string): TextfieldComponent {
71
+ if (component.setTrailingIcon) {
72
+ component.setTrailingIcon(html);
73
+ }
74
+ return this;
75
+ },
76
+
77
+ removeTrailingIcon(): TextfieldComponent {
78
+ if (component.removeTrailingIcon) {
79
+ component.removeTrailingIcon();
80
+ }
81
+ return this;
82
+ },
83
+
84
+ // Supporting text management (if present)
85
+ supportingTextElement: component.supportingTextElement || null,
86
+ setSupportingText(text: string, isError?: boolean): TextfieldComponent {
87
+ if (component.setSupportingText) {
88
+ component.setSupportingText(text, isError);
89
+ }
90
+ return this;
91
+ },
92
+
93
+ removeSupportingText(): TextfieldComponent {
94
+ if (component.removeSupportingText) {
95
+ component.removeSupportingText();
96
+ }
97
+ return this;
98
+ },
46
99
 
47
100
  // Event handling
48
101
  on(event: string, handler: Function): TextfieldComponent {
@@ -5,14 +5,13 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { TextfieldConfig, BaseComponent, ApiOptions } from './types';
8
- import { TEXTFIELD_VARIANTS, TEXTFIELD_TYPES } from './constants';
9
8
 
10
9
  /**
11
10
  * Default configuration for the Textfield component
12
11
  */
13
12
  export const defaultConfig: TextfieldConfig = {
14
- type: TEXTFIELD_TYPES.TEXT,
15
- variant: TEXTFIELD_VARIANTS.FILLED
13
+ type: 'text',
14
+ variant: 'filled'
16
15
  };
17
16
 
18
17
  /**