mtrl 0.3.1 → 0.3.3

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 (162) hide show
  1. package/.env +15 -0
  2. package/CONTRIBUTING.md +62 -23
  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/navigation/nav-item.ts +13 -2
  83. package/src/components/sheet/config.ts +1 -2
  84. package/src/components/sheet/features/gestures.ts +1 -1
  85. package/src/components/sheet/features/position.ts +1 -2
  86. package/src/components/sheet/features/state.ts +1 -1
  87. package/src/components/sheet/index.ts +10 -2
  88. package/src/components/sheet/sheet.ts +1 -2
  89. package/src/components/sheet/types.ts +29 -1
  90. package/src/components/slider/api.ts +1 -1
  91. package/src/components/slider/config.ts +1 -1
  92. package/src/components/slider/features/controller.ts +1 -1
  93. package/src/components/slider/features/handlers.ts +1 -1
  94. package/src/components/slider/features/states.ts +1 -1
  95. package/src/components/slider/index.ts +12 -5
  96. package/src/components/slider/schema.ts +1 -1
  97. package/src/components/slider/types.ts +31 -0
  98. package/src/components/tabs/tab-api.ts +1 -1
  99. package/src/components/tabs/types.ts +1 -1
  100. package/src/components/tooltip/api.ts +6 -2
  101. package/src/components/tooltip/config.ts +9 -28
  102. package/src/components/tooltip/index.ts +10 -1
  103. package/src/components/tooltip/types.ts +38 -3
  104. package/src/core/dom/create.ts +57 -51
  105. package/src/index.ts +129 -31
  106. package/src/styles/abstract/_mixins.scss +23 -9
  107. package/src/styles/abstract/_variables.scss +14 -4
  108. package/src/styles/components/_card.scss +1 -1
  109. package/src/styles/components/_chip.scss +323 -113
  110. package/src/styles/components/_tabs.scss +1 -1
  111. package/src/styles/themes/_autumn.scss +3 -0
  112. package/CLAUDE.md +0 -33
  113. package/src/components/checkbox/constants.ts +0 -37
  114. package/src/components/chip/chip-set.ts +0 -225
  115. package/src/components/chip/chip.ts +0 -118
  116. package/src/components/chip/constants.ts +0 -28
  117. package/src/components/chip/index.ts +0 -12
  118. package/src/components/list/constants.ts +0 -116
  119. package/src/components/sheet/constants.ts +0 -20
  120. package/src/components/slider/constants.ts +0 -32
  121. package/src/components/tooltip/constants.ts +0 -27
  122. package/test/components/badge.test.ts +0 -545
  123. package/test/components/bottom-app-bar.test.ts +0 -303
  124. package/test/components/button.test.ts +0 -233
  125. package/test/components/card.test.ts +0 -560
  126. package/test/components/carousel.test.ts +0 -951
  127. package/test/components/checkbox.test.ts +0 -462
  128. package/test/components/chip.test.ts +0 -692
  129. package/test/components/datepicker.test.ts +0 -1124
  130. package/test/components/dialog.test.ts +0 -990
  131. package/test/components/divider.test.ts +0 -412
  132. package/test/components/extended-fab.test.ts +0 -672
  133. package/test/components/fab.test.ts +0 -561
  134. package/test/components/list.test.ts +0 -365
  135. package/test/components/menu.test.ts +0 -718
  136. package/test/components/navigation.test.ts +0 -186
  137. package/test/components/progress.test.ts +0 -567
  138. package/test/components/radios.test.ts +0 -699
  139. package/test/components/search.test.ts +0 -1135
  140. package/test/components/segmented-button.test.ts +0 -732
  141. package/test/components/sheet.test.ts +0 -641
  142. package/test/components/slider.test.ts +0 -1220
  143. package/test/components/snackbar.test.ts +0 -461
  144. package/test/components/switch.test.ts +0 -452
  145. package/test/components/tabs.test.ts +0 -1369
  146. package/test/components/textfield.test.ts +0 -400
  147. package/test/components/timepicker.test.ts +0 -592
  148. package/test/components/tooltip.test.ts +0 -630
  149. package/test/components/top-app-bar.test.ts +0 -566
  150. package/test/core/dom.attributes.test.ts +0 -148
  151. package/test/core/dom.classes.test.ts +0 -152
  152. package/test/core/dom.events.test.ts +0 -243
  153. package/test/core/emitter.test.ts +0 -141
  154. package/test/core/ripple.test.ts +0 -99
  155. package/test/core/state.store.test.ts +0 -189
  156. package/test/core/utils.normalize.test.ts +0 -61
  157. package/test/core/utils.object.test.ts +0 -120
  158. package/test/setup.js +0 -371
  159. package/test/setup.ts +0 -451
  160. package/tsconfig.json +0 -22
  161. package/typedoc.json +0 -28
  162. package/typedoc.simple.json +0 -14
package/test/setup.js DELETED
@@ -1,371 +0,0 @@
1
- // test/setup.js
2
- // Setup global DOM environment for testing
3
-
4
- /**
5
- * Mock Element implementation for testing
6
- */
7
- class MockElement {
8
- constructor (tagName) {
9
- this.tagName = tagName.toUpperCase()
10
- this.className = ''
11
- this.style = {}
12
- this.attributes = {}
13
- this.children = []
14
- this.childNodes = []
15
- this.__eventListeners = {}
16
- this.innerHTML = ''
17
- this.textContent = ''
18
- this.dataset = {}
19
- this.parentNode = null
20
-
21
- // Explicitly add __handlers for the tests that expect it
22
- this.__handlers = {}
23
- }
24
-
25
- appendChild (child) {
26
- this.children.push(child)
27
- this.childNodes.push(child)
28
- child.parentNode = this
29
- return child
30
- }
31
-
32
- insertBefore (newChild, referenceChild) {
33
- const index = referenceChild ? this.children.indexOf(referenceChild) : 0
34
- if (index === -1) {
35
- this.children.push(newChild)
36
- } else {
37
- this.children.splice(index, 0, newChild)
38
- }
39
- this.childNodes = [...this.children]
40
- newChild.parentNode = this
41
- return newChild
42
- }
43
-
44
- removeChild (child) {
45
- const index = this.children.indexOf(child)
46
- if (index !== -1) {
47
- this.children.splice(index, 1)
48
- this.childNodes = [...this.children]
49
- child.parentNode = null
50
- }
51
- return child
52
- }
53
-
54
- getAttribute (name) {
55
- return this.attributes[name] || null
56
- }
57
-
58
- setAttribute (name, value) {
59
- this.attributes[name] = value
60
- if (name === 'class') this.className = value
61
- }
62
-
63
- removeAttribute (name) {
64
- delete this.attributes[name]
65
- if (name === 'class') this.className = ''
66
- }
67
-
68
- hasAttribute (name) {
69
- return name in this.attributes
70
- }
71
-
72
- querySelector (selector) {
73
- // Basic selector implementation for testing
74
- if (selector.startsWith('.')) {
75
- // Class selector
76
- const className = selector.substring(1)
77
- return this.getElementsByClassName(className)[0] || null
78
- } else if (selector.includes(',')) {
79
- // Multiple selectors (comma-separated)
80
- const subSelectors = selector.split(',').map(s => s.trim())
81
- for (const subSelector of subSelectors) {
82
- const match = this.querySelector(subSelector)
83
- if (match) return match
84
- }
85
- return null
86
- }
87
- // Default
88
- return null
89
- }
90
-
91
- querySelectorAll (selector) {
92
- if (selector.startsWith('.')) {
93
- return this.getElementsByClassName(selector.substring(1))
94
- }
95
- return []
96
- }
97
-
98
- getElementsByClassName (className) {
99
- const results = []
100
- if (this.className && this.className.split(' ').includes(className)) {
101
- results.push(this)
102
- }
103
- this.children.forEach(child => {
104
- if (child.getElementsByClassName) {
105
- results.push(...child.getElementsByClassName(className))
106
- }
107
- })
108
- return results
109
- }
110
-
111
- addEventListener (type, listener) {
112
- // Support dual storage for different test expectations
113
- if (!this.__eventListeners[type]) {
114
- this.__eventListeners[type] = []
115
- }
116
- this.__eventListeners[type].push(listener)
117
-
118
- // Also store in __handlers for tests that expect it
119
- if (!this.__handlers[type]) {
120
- this.__handlers[type] = []
121
- }
122
- this.__handlers[type].push(listener)
123
- }
124
-
125
- removeEventListener (type, listener) {
126
- if (this.__eventListeners[type]) {
127
- this.__eventListeners[type] = this.__eventListeners[type]
128
- .filter(l => l !== listener)
129
- }
130
-
131
- if (this.__handlers && this.__handlers[type]) {
132
- this.__handlers[type] = this.__handlers[type]
133
- .filter(l => l !== listener)
134
- }
135
- }
136
-
137
- dispatchEvent (event) {
138
- event.target = this
139
- if (this.__eventListeners[event.type]) {
140
- this.__eventListeners[event.type].forEach(listener => {
141
- listener(event)
142
- })
143
- }
144
- return !event.defaultPrevented
145
- }
146
-
147
- get classList () {
148
- const classNames = this.className ? this.className.split(' ').filter(Boolean) : []
149
- return {
150
- add: (...classes) => {
151
- classes.forEach(c => {
152
- if (!classNames.includes(c)) {
153
- classNames.push(c)
154
- }
155
- })
156
- this.className = classNames.join(' ')
157
- },
158
- remove: (...classes) => {
159
- classes.forEach(c => {
160
- const index = classNames.indexOf(c)
161
- if (index !== -1) {
162
- classNames.splice(index, 1)
163
- }
164
- })
165
- this.className = classNames.join(' ')
166
- },
167
- toggle: (c) => {
168
- const index = classNames.indexOf(c)
169
- if (index !== -1) {
170
- classNames.splice(index, 1)
171
- this.className = classNames.join(' ')
172
- return false
173
- } else {
174
- classNames.push(c)
175
- this.className = classNames.join(' ')
176
- return true
177
- }
178
- },
179
- contains: (c) => classNames.includes(c),
180
- toString: () => this.className || ''
181
- }
182
- }
183
-
184
- getBoundingClientRect () {
185
- return {
186
- width: 100,
187
- height: 50,
188
- top: 0,
189
- left: 0,
190
- right: 100,
191
- bottom: 50
192
- }
193
- }
194
-
195
- remove () {
196
- if (this.parentNode) {
197
- this.parentNode.removeChild(this)
198
- }
199
- }
200
-
201
- // Support closest for navigation tests
202
- closest (selector) {
203
- // Always return an element with minimal functionality for navigation tests to work
204
- // In real tests this would need to be more sophisticated
205
- const mockClosest = new MockElement('div')
206
- mockClosest.className = selector.replace(/^\./, '')
207
-
208
- // For navigation tests, ensure the element can be queried
209
- mockClosest.querySelector = (childSelector) => {
210
- const mockChild = new MockElement('div')
211
- mockChild.className = childSelector.replace(/^\./, '')
212
-
213
- // Further support nested querying
214
- mockChild.querySelector = (grandchildSelector) => {
215
- const mockGrandchild = new MockElement('div')
216
- mockGrandchild.className = grandchildSelector.replace(/^\./, '')
217
- mockGrandchild.dataset = { id: 'mock-id' }
218
- return mockGrandchild
219
- }
220
-
221
- return mockChild
222
- }
223
-
224
- return mockClosest
225
- }
226
-
227
- // Simple matches implementation
228
- matches (selector) {
229
- if (selector.startsWith('.')) {
230
- return this.classList.contains(selector.substring(1))
231
- }
232
- return false
233
- }
234
- }
235
-
236
- // Create document fragment element
237
- class MockDocumentFragment extends MockElement {
238
- constructor () {
239
- super('#document-fragment')
240
- }
241
-
242
- hasChildNodes () {
243
- return this.childNodes.length > 0
244
- }
245
- }
246
-
247
- // Set up global document object for tests
248
- global.document = {
249
- createElement: (tag) => new MockElement(tag),
250
- createDocumentFragment: () => new MockDocumentFragment(),
251
- body: new MockElement('body'),
252
- __eventListeners: {},
253
- addEventListener: function (type, listener) {
254
- if (!this.__eventListeners[type]) {
255
- this.__eventListeners[type] = []
256
- }
257
- this.__eventListeners[type].push(listener)
258
- },
259
- removeEventListener: function (type, listener) {
260
- if (this.__eventListeners[type]) {
261
- this.__eventListeners[type] = this.__eventListeners[type]
262
- .filter(l => l !== listener)
263
- }
264
- },
265
- dispatchEvent: function (event) {
266
- if (this.__eventListeners[event.type]) {
267
- this.__eventListeners[event.type].forEach(listener => {
268
- listener(event)
269
- })
270
- }
271
- return !event.defaultPrevented
272
- },
273
- querySelector: (selector) => null,
274
- querySelectorAll: (selector) => []
275
- }
276
-
277
- // Set up global window object
278
- global.window = {
279
- getComputedStyle: () => ({
280
- position: 'static',
281
- getPropertyValue: () => ''
282
- }),
283
- addEventListener: () => {},
284
- removeEventListener: () => {},
285
- dispatchEvent: () => {},
286
- innerWidth: 1024,
287
- innerHeight: 768,
288
- history: {
289
- pushState: () => {}
290
- },
291
- location: {
292
- pathname: '/'
293
- },
294
- navigator: {
295
- userAgent: 'test'
296
- },
297
- performance: {
298
- now: () => Date.now()
299
- },
300
- localStorage: {
301
- getItem: () => null,
302
- setItem: () => {},
303
- removeItem: () => {}
304
- }
305
- }
306
-
307
- // Event constructor
308
- global.Event = class Event {
309
- constructor (type, options = {}) {
310
- this.type = type
311
- this.bubbles = options.bubbles || false
312
- this.cancelable = options.cancelable || false
313
- this.defaultPrevented = false
314
- this.target = null
315
- this.currentTarget = null
316
- this.stopPropagation = () => {}
317
- this.stopImmediatePropagation = () => {}
318
-
319
- // Support for offsetX/Y for ripple tests
320
- this.offsetX = options.offsetX || 0
321
- this.offsetY = options.offsetY || 0
322
- }
323
-
324
- preventDefault () {
325
- if (this.cancelable) {
326
- this.defaultPrevented = true
327
- }
328
- }
329
- }
330
-
331
- // CustomEvent constructor
332
- global.CustomEvent = class CustomEvent extends global.Event {
333
- constructor (type, options = {}) {
334
- super(type, options)
335
- this.detail = options.detail || {}
336
- }
337
- }
338
-
339
- // AbortController
340
- global.AbortController = class AbortController {
341
- constructor () {
342
- this.signal = { aborted: false }
343
- }
344
-
345
- abort () {
346
- this.signal.aborted = true
347
- }
348
- }
349
-
350
- // Set up Element constructor
351
- global.Element = MockElement
352
-
353
- // Console mocking (preventing test output pollution)
354
- const originalConsole = { ...console }
355
- global.console = {
356
- ...console,
357
- log: (...args) => {
358
- if (process.env.DEBUG) {
359
- originalConsole.log(...args)
360
- }
361
- },
362
- warn: (...args) => {
363
- if (process.env.DEBUG) {
364
- originalConsole.warn(...args)
365
- }
366
- },
367
- error: (...args) => {
368
- // Always log errors
369
- originalConsole.error(...args)
370
- }
371
- }