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,4 +1,4 @@
1
- // src/components/chip/chip.js
1
+ // src/components/chip/chip.ts
2
2
  import { PREFIX } from '../../core/config'
3
3
  import { pipe } from '../../core/compose'
4
4
  import { createBase, withElement } from '../../core/compose/component'
@@ -12,82 +12,29 @@ import {
12
12
  withLifecycle
13
13
  } from '../../core/compose/features'
14
14
  import { withAPI } from './api'
15
- import { CHIP_VARIANTS } from './constants'
15
+ import { ChipConfig, ChipComponent } from './types'
16
+ import { createBaseConfig, getElementConfig, getApiConfig } from './config'
16
17
 
17
18
  /**
18
19
  * Creates a new Chip component
19
- * @param {Object} config - Chip configuration
20
- * @param {string} [config.variant='filled'] - Chip variant
21
- * @param {boolean} [config.selected=false] - Whether the chip is initially selected
22
- * @param {boolean} [config.disabled=false] - Whether the chip is initially disabled
23
- * @param {string} [config.text] - Chip text content
24
- * @param {string} [config.leadingIcon] - Leading icon HTML content
25
- * @param {string} [config.trailingIcon] - Trailing icon HTML content
26
- * @param {string} [config.class] - Additional CSS classes
27
- * @param {string} [config.value] - Chip value
28
- * @param {boolean} [config.ripple=true] - Whether to enable ripple effect
29
- * @param {Function} [config.onTrailingIconClick] - Callback when trailing icon is clicked
30
- * @param {Function} [config.onSelect] - Callback when chip is selected
31
- * @param {Function} [config.onChange] - Callback when chip selection changes
32
- * @returns {Object} Chip component instance
20
+ * @param {ChipConfig} config - Chip configuration
21
+ * @returns {ChipComponent} Chip component instance
33
22
  */
34
- const createChip = (config = {}) => {
35
- const baseConfig = {
36
- ...config,
37
- variant: config.variant || CHIP_VARIANTS.FILLED,
38
- componentName: 'chip',
39
- prefix: PREFIX,
40
- ripple: config.ripple !== false
41
- }
23
+ const createChip = (config: ChipConfig = {}): ChipComponent => {
24
+ const baseConfig = createBaseConfig(config)
42
25
 
43
26
  try {
44
27
  // Create base component with core features
45
28
  const chip = pipe(
46
29
  createBase,
47
30
  withEvents(),
48
- withElement({
49
- tag: 'div',
50
- componentName: 'chip',
51
- attrs: {
52
- role: 'button',
53
- tabindex: '0',
54
- 'aria-disabled': config.disabled ? 'true' : 'false',
55
- 'aria-selected': config.selected ? 'true' : 'false',
56
- 'data-value': config.value || ''
57
- },
58
- className: config.class,
59
- forwardEvents: {
60
- click: (component) => component.element.getAttribute('aria-disabled') !== 'true',
61
- focus: true,
62
- blur: true
63
- }
64
- }),
31
+ withElement(getElementConfig(baseConfig)),
32
+ withVariant(baseConfig),
33
+ withDisabled(baseConfig),
34
+ withRipple(baseConfig),
65
35
  withLifecycle()
66
36
  )(baseConfig)
67
37
 
68
- // Track selected state
69
- let isSelectedState = !!config.selected;
70
-
71
- // Manually add the variant class
72
- if (config.variant) {
73
- chip.element.classList.add(`${chip.getClass('chip')}--${config.variant}`)
74
- }
75
-
76
- // Add ripple if enabled
77
- if (config.ripple) {
78
- withRipple(baseConfig)(chip)
79
- }
80
-
81
- // Add disabled state if needed
82
- if (config.disabled) {
83
- withDisabled(baseConfig)(chip)
84
- }
85
-
86
- // Add selected class if needed
87
- if (config.selected) {
88
- chip.element.classList.add(`${chip.getClass('chip')}--selected`)
89
- }
90
-
91
38
  // Create a container for the chip content to ensure proper ordering
92
39
  const contentContainer = document.createElement('div')
93
40
  contentContainer.className = `${chip.getClass('chip')}-content`
@@ -98,10 +45,10 @@ const createChip = (config = {}) => {
98
45
  chip.element.appendChild(contentContainer)
99
46
 
100
47
  // Add leading icon if provided
101
- if (config.leadingIcon) {
48
+ if (config.leadingIcon || config.icon) {
102
49
  const leadingIconElement = document.createElement('span')
103
50
  leadingIconElement.className = `${chip.getClass('chip')}-leading-icon`
104
- leadingIconElement.innerHTML = config.leadingIcon
51
+ leadingIconElement.innerHTML = config.leadingIcon || config.icon || ''
105
52
  contentContainer.appendChild(leadingIconElement)
106
53
  }
107
54
 
@@ -123,264 +70,49 @@ const createChip = (config = {}) => {
123
70
  if (config.onTrailingIconClick) {
124
71
  trailingIconElement.addEventListener('click', (e) => {
125
72
  e.stopPropagation() // Prevent chip click event
126
- config.onTrailingIconClick(enhancedChip)
73
+ config.onTrailingIconClick(chip as unknown as ChipComponent)
127
74
  })
128
75
  }
129
76
 
130
77
  contentContainer.appendChild(trailingIconElement)
131
78
  }
79
+
80
+ // Add selected class if needed
81
+ if (config.selected) {
82
+ chip.element.classList.add(`${chip.getClass('chip')}--selected`)
83
+ chip.element.setAttribute('aria-selected', 'true')
84
+ }
132
85
 
133
- // Create enhanced component with API
134
- const enhancedChip = {
135
- ...chip,
136
-
137
- /**
138
- * Checks if the chip is disabled
139
- * @returns {boolean} True if the chip is disabled
140
- */
141
- isDisabled() {
142
- return chip.element.getAttribute('aria-disabled') === 'true';
143
- },
144
-
145
- /**
146
- * Checks if the chip is selected
147
- * @returns {boolean} True if the chip is selected
148
- */
149
- isSelected() {
150
- return isSelectedState;
151
- },
152
-
153
- /**
154
- * Sets the chip's selected state
155
- * @param {boolean} selected - Whether the chip should be selected
156
- * @returns {Object} The chip instance for chaining
157
- */
158
- setSelected(selected) {
159
- isSelectedState = !!selected;
160
-
161
- if (selected) {
162
- chip.element.classList.add(`${chip.getClass('chip')}--selected`);
163
- chip.element.setAttribute('aria-selected', 'true');
164
- } else {
165
- chip.element.classList.remove(`${chip.getClass('chip')}--selected`);
166
- chip.element.setAttribute('aria-selected', 'false');
167
- }
168
-
169
- return this;
170
- },
171
-
172
- /**
173
- * Toggles the chip's selected state
174
- * @returns {Object} The chip instance for chaining
175
- */
176
- toggleSelected() {
177
- return this.setSelected(!isSelectedState);
178
- },
179
-
180
- /**
181
- * Gets the chip's value
182
- * @returns {string} The chip's value
183
- */
184
- getValue() {
185
- return chip.element.getAttribute('data-value');
186
- },
187
-
188
- /**
189
- * Sets the chip's value
190
- * @param {string} value - Value to set
191
- * @returns {Object} The chip instance for chaining
192
- */
193
- setValue(value) {
194
- chip.element.setAttribute('data-value', value);
195
- return this;
196
- },
197
-
198
- /**
199
- * Enables the chip
200
- * @returns {Object} The chip instance for chaining
201
- */
202
- enable() {
203
- chip.element.classList.remove(`${chip.getClass('chip')}--disabled`);
204
- chip.element.setAttribute('aria-disabled', 'false');
205
- chip.element.setAttribute('tabindex', '0');
206
- return this;
207
- },
208
-
209
- /**
210
- * Disables the chip
211
- * @returns {Object} The chip instance for chaining
212
- */
213
- disable() {
214
- chip.element.classList.add(`${chip.getClass('chip')}--disabled`);
215
- chip.element.setAttribute('aria-disabled', 'true');
216
- chip.element.setAttribute('tabindex', '-1');
217
- return this;
218
- },
219
-
220
- /**
221
- * Sets the chip's text content
222
- * @param {string} content - Text content
223
- * @returns {Object} The chip instance for chaining
224
- */
225
- setText(content) {
226
- const textElement = chip.element.querySelector(`.${chip.getClass('chip')}-text`);
227
-
228
- if (textElement) {
229
- textElement.textContent = content;
230
- } else if (content) {
231
- const newTextElement = document.createElement('span');
232
- newTextElement.className = `${chip.getClass('chip')}-text`;
233
- newTextElement.textContent = content;
234
- contentContainer.appendChild(newTextElement);
235
- }
236
-
237
- return this;
238
- },
239
-
240
- /**
241
- * Gets the chip's text content
242
- * @returns {string} The chip's text content
243
- */
244
- getText() {
245
- const textElement = chip.element.querySelector(`.${chip.getClass('chip')}-text`);
246
- return textElement ? textElement.textContent : '';
247
- },
248
-
249
- /**
250
- * Sets the chip's icon
251
- * @param {string} icon - Icon HTML content
252
- * @returns {Object} The chip instance for chaining
253
- */
254
- setIcon(icon) {
255
- return this.setLeadingIcon(icon);
256
- },
257
-
258
- /**
259
- * Gets the chip's icon
260
- * @returns {string} The chip's icon HTML
261
- */
262
- getIcon() {
263
- const iconElement = chip.element.querySelector(`.${chip.getClass('chip')}-leading-icon`);
264
- return iconElement ? iconElement.innerHTML : '';
265
- },
266
-
267
- /**
268
- * Sets the chip's leading icon
269
- * @param {string} icon - Icon HTML content
270
- * @returns {Object} The chip instance for chaining
271
- */
272
- setLeadingIcon(icon) {
273
- const leadingIconSelector = `.${chip.getClass('chip')}-leading-icon`;
274
- let leadingIconElement = chip.element.querySelector(leadingIconSelector);
275
-
276
- if (!leadingIconElement && icon) {
277
- leadingIconElement = document.createElement('span');
278
- leadingIconElement.className = `${chip.getClass('chip')}-leading-icon`;
279
-
280
- // Insert at the beginning of the content container
281
- contentContainer.insertBefore(leadingIconElement, contentContainer.firstChild);
282
- }
283
-
284
- if (leadingIconElement) {
285
- leadingIconElement.innerHTML = icon || '';
286
-
287
- // Remove the element if icon is empty
288
- if (!icon && leadingIconElement.parentNode) {
289
- leadingIconElement.parentNode.removeChild(leadingIconElement);
290
- }
291
- }
292
-
293
- return this;
294
- },
295
-
296
- /**
297
- * Sets the chip's trailing icon
298
- * @param {string} icon - Icon HTML content
299
- * @param {Function} [onClick] - Click handler for the trailing icon
300
- * @returns {Object} The chip instance for chaining
301
- */
302
- setTrailingIcon(icon, onClick) {
303
- const trailingIconSelector = `.${chip.getClass('chip')}-trailing-icon`;
304
- let trailingIconElement = chip.element.querySelector(trailingIconSelector);
305
-
306
- if (!trailingIconElement && icon) {
307
- trailingIconElement = document.createElement('span');
308
- trailingIconElement.className = `${chip.getClass('chip')}-trailing-icon`;
309
-
310
- // Add at the end of the content container
311
- contentContainer.appendChild(trailingIconElement);
312
-
313
- // Add click handler if provided
314
- if (onClick) {
315
- trailingIconElement.addEventListener('click', (e) => {
316
- e.stopPropagation(); // Prevent chip click event
317
- onClick(this);
318
- });
319
- }
320
- }
321
-
322
- if (trailingIconElement) {
323
- trailingIconElement.innerHTML = icon || '';
324
-
325
- // Remove the element if icon is empty
326
- if (!icon && trailingIconElement.parentNode) {
327
- trailingIconElement.parentNode.removeChild(trailingIconElement);
328
- }
329
- }
330
-
331
- return this;
332
- },
333
-
334
- /**
335
- * Destroys the chip component and cleans up resources
336
- */
337
- destroy() {
338
- chip.lifecycle && chip.lifecycle.destroy && chip.lifecycle.destroy();
339
- chip.element.remove();
340
- },
341
-
342
- // Forward event methods from the original chip
343
- on: chip.on,
344
- off: chip.off,
345
-
346
- /**
347
- * Add CSS classes to the chip element
348
- * @param {...string} classes - CSS classes to add
349
- * @returns {Object} The chip instance for chaining
350
- */
351
- addClass(...classes) {
352
- chip.element.classList.add(...classes);
353
- return this;
354
- }
355
- };
86
+ // Add API methods to the component
87
+ const enhancedChip = withAPI(getApiConfig(chip))(chip)
356
88
 
357
89
  // Add click handler for selection toggle
358
- if (config.variant === CHIP_VARIANTS.FILTER ||
359
- config.variant === CHIP_VARIANTS.ASSIST ||
90
+ if (config.variant === 'filter' ||
91
+ config.variant === 'assist' ||
360
92
  config.selectable) {
361
93
 
362
94
  chip.element.addEventListener('click', () => {
363
- if (enhancedChip.isDisabled()) return;
95
+ if (enhancedChip.isDisabled()) return
364
96
 
365
- enhancedChip.toggleSelected();
97
+ enhancedChip.toggleSelected()
366
98
 
367
99
  // Call onChange callback if provided
368
100
  if (config.onChange) {
369
- config.onChange(enhancedChip);
101
+ config.onChange(enhancedChip as unknown as ChipComponent)
370
102
  }
371
103
 
372
104
  // Call onSelect callback if provided
373
105
  if (config.onSelect) {
374
- config.onSelect(enhancedChip);
106
+ config.onSelect(enhancedChip as unknown as ChipComponent)
375
107
  }
376
- });
108
+ })
377
109
  }
378
110
 
379
- return enhancedChip;
111
+ return enhancedChip as unknown as ChipComponent
380
112
  } catch (error) {
381
- console.error('Chip creation error:', error);
382
- throw new Error(`Failed to create chip: ${error.message}`);
113
+ console.error('Chip creation error:', error)
114
+ throw new Error(`Failed to create chip: ${(error as Error).message}`)
383
115
  }
384
- };
116
+ }
385
117
 
386
- export default createChip;
118
+ export default createChip
@@ -5,13 +5,12 @@ import {
5
5
  BaseComponentConfig
6
6
  } from '../../core/config/component-config';
7
7
  import { ChipConfig, BaseComponent } from './types';
8
- import { CHIP_VARIANTS } from './constants';
9
8
 
10
9
  /**
11
10
  * Default configuration for the Chip component
12
11
  */
13
12
  export const defaultConfig: ChipConfig = {
14
- variant: CHIP_VARIANTS.FILLED,
13
+ variant: 'filled',
15
14
  ripple: true
16
15
  };
17
16
 
@@ -1,4 +1,12 @@
1
- // src/components/chip/index.js
1
+ // src/components/chip/index.ts
2
2
  export { default } from './chip'
3
3
  export { default as createChipSet } from './chip-set'
4
- export { CHIP_VARIANTS } from './constants'
4
+ export type {
5
+ ChipConfig,
6
+ ChipComponent,
7
+ ChipVariant
8
+ } from './types'
9
+ export type {
10
+ ChipSetConfig,
11
+ ChipSetComponent
12
+ } from './chip-set'