mtrl-addons 0.2.2 → 0.2.4

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 (129) hide show
  1. package/{src/components/index.ts → dist/components/index.d.ts} +0 -2
  2. package/dist/components/vlist/config.d.ts +86 -0
  3. package/{src/components/vlist/constants.ts → dist/components/vlist/constants.d.ts} +10 -11
  4. package/dist/components/vlist/features/api.d.ts +7 -0
  5. package/{src/components/vlist/features/index.ts → dist/components/vlist/features/index.d.ts} +0 -2
  6. package/dist/components/vlist/features/selection.d.ts +6 -0
  7. package/dist/components/vlist/features/viewport.d.ts +9 -0
  8. package/dist/components/vlist/features.d.ts +31 -0
  9. package/{src/components/vlist/index.ts → dist/components/vlist/index.d.ts} +1 -10
  10. package/dist/components/vlist/types.d.ts +596 -0
  11. package/dist/components/vlist/vlist.d.ts +29 -0
  12. package/dist/core/compose/features/gestures/index.d.ts +86 -0
  13. package/dist/core/compose/features/gestures/longpress.d.ts +85 -0
  14. package/dist/core/compose/features/gestures/pan.d.ts +108 -0
  15. package/dist/core/compose/features/gestures/pinch.d.ts +111 -0
  16. package/dist/core/compose/features/gestures/rotate.d.ts +111 -0
  17. package/dist/core/compose/features/gestures/swipe.d.ts +149 -0
  18. package/dist/core/compose/features/gestures/tap.d.ts +79 -0
  19. package/{src/core/compose/features/index.ts → dist/core/compose/features/index.d.ts} +1 -2
  20. package/{src/core/compose/index.ts → dist/core/compose/index.d.ts} +2 -11
  21. package/{src/core/gestures/index.ts → dist/core/gestures/index.d.ts} +1 -20
  22. package/dist/core/gestures/longpress.d.ts +23 -0
  23. package/dist/core/gestures/manager.d.ts +14 -0
  24. package/dist/core/gestures/pan.d.ts +12 -0
  25. package/dist/core/gestures/pinch.d.ts +14 -0
  26. package/dist/core/gestures/rotate.d.ts +14 -0
  27. package/dist/core/gestures/swipe.d.ts +20 -0
  28. package/dist/core/gestures/tap.d.ts +12 -0
  29. package/dist/core/gestures/types.d.ts +320 -0
  30. package/dist/core/gestures/utils.d.ts +57 -0
  31. package/dist/core/index.d.ts +13 -0
  32. package/dist/core/layout/config.d.ts +33 -0
  33. package/dist/core/layout/index.d.ts +51 -0
  34. package/dist/core/layout/jsx.d.ts +65 -0
  35. package/dist/core/layout/schema.d.ts +112 -0
  36. package/dist/core/layout/types.d.ts +69 -0
  37. package/dist/core/viewport/constants.d.ts +105 -0
  38. package/dist/core/viewport/features/base.d.ts +14 -0
  39. package/dist/core/viewport/features/collection.d.ts +41 -0
  40. package/dist/core/viewport/features/events.d.ts +13 -0
  41. package/{src/core/viewport/features/index.ts → dist/core/viewport/features/index.d.ts} +0 -7
  42. package/dist/core/viewport/features/item-size.d.ts +30 -0
  43. package/dist/core/viewport/features/loading.d.ts +34 -0
  44. package/dist/core/viewport/features/momentum.d.ts +17 -0
  45. package/dist/core/viewport/features/performance.d.ts +53 -0
  46. package/dist/core/viewport/features/placeholders.d.ts +38 -0
  47. package/dist/core/viewport/features/rendering.d.ts +16 -0
  48. package/dist/core/viewport/features/scrollbar.d.ts +26 -0
  49. package/dist/core/viewport/features/scrolling.d.ts +16 -0
  50. package/dist/core/viewport/features/utils.d.ts +43 -0
  51. package/dist/core/viewport/features/virtual.d.ts +18 -0
  52. package/{src/core/viewport/index.ts → dist/core/viewport/index.d.ts} +1 -17
  53. package/dist/core/viewport/types.d.ts +96 -0
  54. package/dist/core/viewport/utils/speed-tracker.d.ts +22 -0
  55. package/dist/core/viewport/viewport.d.ts +11 -0
  56. package/{src/index.ts → dist/index.d.ts} +0 -4
  57. package/dist/index.js +5143 -0
  58. package/dist/index.mjs +5111 -0
  59. package/dist/styles.css +254 -0
  60. package/dist/styles.css.map +1 -0
  61. package/package.json +16 -2
  62. package/.cursorrules +0 -117
  63. package/AI.md +0 -39
  64. package/CLAUDE.md +0 -882
  65. package/build.js +0 -377
  66. package/index.ts +0 -7
  67. package/scripts/analyze-orphaned-functions.ts +0 -387
  68. package/scripts/debug/vlist-selection.ts +0 -121
  69. package/src/components/vlist/config.ts +0 -323
  70. package/src/components/vlist/features/api.ts +0 -626
  71. package/src/components/vlist/features/selection.ts +0 -436
  72. package/src/components/vlist/features/viewport.ts +0 -59
  73. package/src/components/vlist/features.ts +0 -112
  74. package/src/components/vlist/types.ts +0 -723
  75. package/src/components/vlist/vlist.ts +0 -92
  76. package/src/core/compose/features/gestures/index.ts +0 -227
  77. package/src/core/compose/features/gestures/longpress.ts +0 -383
  78. package/src/core/compose/features/gestures/pan.ts +0 -424
  79. package/src/core/compose/features/gestures/pinch.ts +0 -475
  80. package/src/core/compose/features/gestures/rotate.ts +0 -485
  81. package/src/core/compose/features/gestures/swipe.ts +0 -492
  82. package/src/core/compose/features/gestures/tap.ts +0 -334
  83. package/src/core/gestures/longpress.ts +0 -68
  84. package/src/core/gestures/manager.ts +0 -418
  85. package/src/core/gestures/pan.ts +0 -48
  86. package/src/core/gestures/pinch.ts +0 -58
  87. package/src/core/gestures/rotate.ts +0 -58
  88. package/src/core/gestures/swipe.ts +0 -66
  89. package/src/core/gestures/tap.ts +0 -45
  90. package/src/core/gestures/types.ts +0 -387
  91. package/src/core/gestures/utils.ts +0 -128
  92. package/src/core/index.ts +0 -43
  93. package/src/core/layout/config.ts +0 -102
  94. package/src/core/layout/index.ts +0 -168
  95. package/src/core/layout/jsx.ts +0 -174
  96. package/src/core/layout/schema.ts +0 -1044
  97. package/src/core/layout/types.ts +0 -95
  98. package/src/core/viewport/constants.ts +0 -145
  99. package/src/core/viewport/features/base.ts +0 -73
  100. package/src/core/viewport/features/collection.ts +0 -1182
  101. package/src/core/viewport/features/events.ts +0 -130
  102. package/src/core/viewport/features/item-size.ts +0 -271
  103. package/src/core/viewport/features/loading.ts +0 -263
  104. package/src/core/viewport/features/momentum.ts +0 -269
  105. package/src/core/viewport/features/performance.ts +0 -161
  106. package/src/core/viewport/features/placeholders.ts +0 -335
  107. package/src/core/viewport/features/rendering.ts +0 -962
  108. package/src/core/viewport/features/scrollbar.ts +0 -434
  109. package/src/core/viewport/features/scrolling.ts +0 -634
  110. package/src/core/viewport/features/utils.ts +0 -94
  111. package/src/core/viewport/features/virtual.ts +0 -525
  112. package/src/core/viewport/types.ts +0 -133
  113. package/src/core/viewport/utils/speed-tracker.ts +0 -79
  114. package/src/core/viewport/viewport.ts +0 -265
  115. package/test/benchmarks/layout/advanced.test.ts +0 -656
  116. package/test/benchmarks/layout/comparison.test.ts +0 -519
  117. package/test/benchmarks/layout/performance-comparison.test.ts +0 -274
  118. package/test/benchmarks/layout/real-components.test.ts +0 -733
  119. package/test/benchmarks/layout/simple.test.ts +0 -321
  120. package/test/benchmarks/layout/stress.test.ts +0 -990
  121. package/test/collection/basic.test.ts +0 -304
  122. package/test/components/vlist-selection.test.ts +0 -240
  123. package/test/components/vlist.test.ts +0 -63
  124. package/test/core/collection/adapter.test.ts +0 -161
  125. package/test/core/collection/collection.test.ts +0 -394
  126. package/test/core/layout/layout.test.ts +0 -201
  127. package/test/utils/dom-helpers.ts +0 -275
  128. package/test/utils/performance-helpers.ts +0 -392
  129. package/tsconfig.json +0 -20
@@ -1,733 +0,0 @@
1
- // test/integration/real-components.test.ts - Integration Tests with Real mtrl Components
2
- // @ts-nocheck
3
- import { describe, test, expect, beforeAll, afterAll } from "bun:test";
4
- import { JSDOM } from "jsdom";
5
-
6
- // Setup for DOM testing environment
7
- let dom: JSDOM;
8
- let window: Window;
9
- let document: Document;
10
- let originalGlobalDocument: any;
11
- let originalGlobalWindow: any;
12
-
13
- // High-resolution timer
14
- const hrTimer = (() => {
15
- const start = Date.now();
16
- return () => Date.now() - start;
17
- })();
18
-
19
- beforeAll(() => {
20
- // Create JSDOM instance
21
- dom = new JSDOM("<!DOCTYPE html><html><body></body></html>", {
22
- url: "http://localhost/",
23
- pretendToBeVisual: true,
24
- resources: "usable",
25
- });
26
-
27
- window = dom.window as any;
28
- document = window.document;
29
-
30
- // Store original globals
31
- originalGlobalDocument = global.document;
32
- originalGlobalWindow = global.window;
33
-
34
- // Set globals
35
- global.document = document;
36
- global.window = window as any;
37
- global.Element = (window as any).Element;
38
- global.HTMLElement = (window as any).HTMLElement;
39
- global.DocumentFragment = (window as any).DocumentFragment;
40
-
41
- // Fix performance.now conflict
42
- (global as any).performance = {
43
- now: hrTimer,
44
- mark: () => {},
45
- measure: () => {},
46
- getEntriesByType: () => [],
47
- clearMarks: () => {},
48
- clearMeasures: () => {},
49
- };
50
-
51
- // Add DOM APIs
52
- global.getComputedStyle = () => ({
53
- position: "static",
54
- getPropertyValue: () => "",
55
- });
56
- });
57
-
58
- afterAll(() => {
59
- // Restore globals
60
- global.document = originalGlobalDocument;
61
- global.window = originalGlobalWindow;
62
- window.close();
63
- });
64
-
65
- // Import after DOM setup
66
- import {
67
- createLayout,
68
- performance as addonsPerformance,
69
- } from "../../../src/core/layout";
70
-
71
- // Import real mtrl components
72
- import {
73
- createButton,
74
- createCard,
75
- createTextfield,
76
- createCheckbox,
77
- createSelect,
78
- createTabs,
79
- createList,
80
- } from "mtrl";
81
-
82
- describe("Real Component Integration Tests", () => {
83
- beforeAll(() => {
84
- // Clear all caches before tests
85
- addonsPerformance.clearAll();
86
- });
87
-
88
- describe("Real Component Performance", () => {
89
- test("layout system with real mtrl buttons", () => {
90
- const iterations = 1000;
91
-
92
- console.log(`\n🔘 Real Button Components (${iterations} layouts):`);
93
- console.log(` Testing mtrl-addons layout + real mtrl.createButton()`);
94
-
95
- const createButtonLayoutSchema = () => [
96
- "div",
97
- "button-container",
98
- {
99
- layout: { type: "row", gap: "1rem", wrap: true },
100
- class: "button-demo",
101
- },
102
- // Primary button
103
- [
104
- "div",
105
- "btn-1",
106
- {
107
- component: {
108
- creator: () =>
109
- createButton({
110
- type: "filled",
111
- label: "Primary Action",
112
- icon: "check",
113
- }),
114
- options: {},
115
- },
116
- },
117
- ],
118
- // Secondary button
119
- [
120
- "div",
121
- "btn-2",
122
- {
123
- component: {
124
- creator: () =>
125
- createButton({
126
- type: "outlined",
127
- label: "Secondary",
128
- disabled: false,
129
- }),
130
- options: {},
131
- },
132
- },
133
- ],
134
- // Text button
135
- [
136
- "div",
137
- "btn-3",
138
- {
139
- component: {
140
- creator: () =>
141
- createButton({
142
- type: "text",
143
- label: "Cancel",
144
- }),
145
- options: {},
146
- },
147
- },
148
- ],
149
- ];
150
-
151
- addonsPerformance.clearAll();
152
-
153
- const start = hrTimer();
154
- const layouts = [];
155
-
156
- for (let i = 0; i < iterations; i++) {
157
- layouts.push(createLayout(createButtonLayoutSchema()));
158
- }
159
- const createTime = hrTimer() - start;
160
-
161
- const destroyStart = hrTimer();
162
- layouts.forEach((layout) => layout.destroy());
163
- const destroyTime = hrTimer() - destroyStart;
164
-
165
- const totalTime = createTime + destroyTime;
166
- const avgTimePerLayout = totalTime / iterations;
167
- const totalComponents = iterations * 3;
168
-
169
- console.log(` Creation: ${createTime.toFixed(2)}ms`);
170
- console.log(` Cleanup: ${destroyTime.toFixed(2)}ms`);
171
- console.log(` Total: ${totalTime.toFixed(2)}ms`);
172
- console.log(` Per layout: ${avgTimePerLayout.toFixed(3)}ms`);
173
- console.log(
174
- ` Per button: ${(totalTime / totalComponents).toFixed(4)}ms`
175
- );
176
- console.log(
177
- ` Throughput: ${Math.round(
178
- iterations / (totalTime / 1000)
179
- ).toLocaleString()} layouts/sec`
180
- );
181
-
182
- expect(totalTime).toBeLessThan(10000); // Should complete within 10 seconds
183
- expect(avgTimePerLayout).toBeLessThan(10); // Should be under 10ms per layout
184
- });
185
-
186
- test("complex form with real mtrl components", () => {
187
- const iterations = 200;
188
-
189
- console.log(`\n📝 Real Form Components (${iterations} forms):`);
190
- console.log(` Testing complex forms with real mtrl components`);
191
-
192
- const createFormLayoutSchema = () => [
193
- "form",
194
- "registration-form",
195
- {
196
- layout: { type: "stack", gap: "1.5rem" },
197
- class: "registration-form",
198
- },
199
-
200
- // Form header
201
- [
202
- "div",
203
- "form-header",
204
- {
205
- layout: { type: "stack", gap: "0.5rem" },
206
- class: "form-header",
207
- },
208
- [
209
- "h2",
210
- "title",
211
- { textContent: "User Registration", class: "form-title" },
212
- ],
213
- [
214
- "p",
215
- "subtitle",
216
- {
217
- textContent: "Please fill in your details",
218
- class: "form-subtitle",
219
- },
220
- ],
221
- ],
222
-
223
- // Personal info section
224
- [
225
- "fieldset",
226
- "personal-info",
227
- {
228
- layout: { type: "grid", columns: 2, gap: "1rem" },
229
- class: "form-section",
230
- },
231
- [
232
- "legend",
233
- "personal-legend",
234
- { textContent: "Personal Information" },
235
- ],
236
-
237
- // First name field
238
- [
239
- "div",
240
- "first-name",
241
- {
242
- component: {
243
- creator: () =>
244
- createTextfield({
245
- label: "First Name",
246
- placeholder: "Enter your first name",
247
- required: true,
248
- }),
249
- options: {},
250
- },
251
- },
252
- ],
253
-
254
- // Last name field
255
- [
256
- "div",
257
- "last-name",
258
- {
259
- component: {
260
- creator: () =>
261
- createTextfield({
262
- label: "Last Name",
263
- placeholder: "Enter your last name",
264
- required: true,
265
- }),
266
- options: {},
267
- },
268
- },
269
- ],
270
-
271
- // Email field
272
- [
273
- "div",
274
- "email",
275
- {
276
- layoutItem: { span: 2 },
277
- component: {
278
- creator: () =>
279
- createTextfield({
280
- label: "Email",
281
- type: "email",
282
- placeholder: "user@example.com",
283
- required: true,
284
- }),
285
- options: {},
286
- },
287
- },
288
- ],
289
- ],
290
-
291
- // Preferences section
292
- [
293
- "fieldset",
294
- "preferences",
295
- {
296
- layout: { type: "stack", gap: "1rem" },
297
- class: "form-section",
298
- },
299
- ["legend", "preferences-legend", { textContent: "Preferences" }],
300
-
301
- // Country select
302
- [
303
- "div",
304
- "country",
305
- {
306
- component: {
307
- creator: () =>
308
- createSelect({
309
- label: "Country",
310
- options: [
311
- { value: "us", label: "United States" },
312
- { value: "ca", label: "Canada" },
313
- { value: "uk", label: "United Kingdom" },
314
- { value: "de", label: "Germany" },
315
- { value: "fr", label: "France" },
316
- ],
317
- }),
318
- options: {},
319
- },
320
- },
321
- ],
322
-
323
- // Additional text field
324
- [
325
- "div",
326
- "bio",
327
- {
328
- layoutItem: { span: 1 },
329
- component: {
330
- creator: () =>
331
- createTextfield({
332
- label: "Bio",
333
- placeholder: "Tell us about yourself",
334
- multiline: true,
335
- }),
336
- options: {},
337
- },
338
- },
339
- ],
340
-
341
- // Notifications checkbox
342
- [
343
- "div",
344
- "notifications",
345
- {
346
- component: {
347
- creator: () =>
348
- createCheckbox({
349
- label: "Receive email notifications",
350
- checked: true,
351
- }),
352
- options: {},
353
- },
354
- },
355
- ],
356
-
357
- // Newsletter checkbox
358
- [
359
- "div",
360
- "newsletter",
361
- {
362
- component: {
363
- creator: () =>
364
- createCheckbox({
365
- label: "Subscribe to newsletter",
366
- checked: false,
367
- }),
368
- options: {},
369
- },
370
- },
371
- ],
372
- ],
373
-
374
- // Form actions
375
- [
376
- "div",
377
- "form-actions",
378
- {
379
- layout: { type: "row", gap: "1rem", justify: "flex-end" },
380
- class: "form-actions",
381
- },
382
- [
383
- "div",
384
- "cancel-btn",
385
- {
386
- component: {
387
- creator: () =>
388
- createButton({
389
- type: "text",
390
- label: "Cancel",
391
- }),
392
- options: {},
393
- },
394
- },
395
- ],
396
- [
397
- "div",
398
- "submit-btn",
399
- {
400
- component: {
401
- creator: () =>
402
- createButton({
403
- type: "filled",
404
- label: "Register",
405
- icon: "person_add",
406
- }),
407
- options: {},
408
- },
409
- },
410
- ],
411
- ],
412
- ];
413
-
414
- addonsPerformance.clearAll();
415
-
416
- const start = hrTimer();
417
- const layouts = [];
418
-
419
- for (let i = 0; i < iterations; i++) {
420
- layouts.push(createLayout(createFormLayoutSchema()));
421
- }
422
- const createTime = hrTimer() - start;
423
-
424
- const destroyStart = hrTimer();
425
- layouts.forEach((layout) => layout.destroy());
426
- const destroyTime = hrTimer() - destroyStart;
427
-
428
- const totalTime = createTime + destroyTime;
429
- const avgTimePerForm = totalTime / iterations;
430
- const totalComponents = iterations * 10; // ~10 real components per form
431
-
432
- console.log(` Creation: ${createTime.toFixed(2)}ms`);
433
- console.log(` Cleanup: ${destroyTime.toFixed(2)}ms`);
434
- console.log(` Total: ${totalTime.toFixed(2)}ms`);
435
- console.log(` Per form: ${avgTimePerForm.toFixed(3)}ms`);
436
- console.log(
437
- ` Per component: ${(totalTime / totalComponents).toFixed(4)}ms`
438
- );
439
- console.log(
440
- ` Throughput: ${Math.round(
441
- iterations / (totalTime / 1000)
442
- ).toLocaleString()} forms/sec`
443
- );
444
-
445
- expect(totalTime).toBeLessThan(30000); // Should complete within 30 seconds
446
- expect(avgTimePerForm).toBeLessThan(150); // Should be under 150ms per form
447
- });
448
-
449
- test("dashboard with real mtrl cards and lists", () => {
450
- const iterations = 100;
451
-
452
- console.log(`\n📊 Real Dashboard Components (${iterations} dashboards):`);
453
- console.log(` Testing dashboard layouts with cards, lists, and tabs`);
454
-
455
- const createDashboardSchema = () => [
456
- "div",
457
- "dashboard",
458
- {
459
- layout: { type: "grid", columns: 12, gap: "1.5rem" },
460
- class: "dashboard-layout",
461
- },
462
-
463
- // Header
464
- [
465
- "header",
466
- "dashboard-header",
467
- {
468
- layoutItem: { span: 12 },
469
- layout: {
470
- type: "row",
471
- gap: "1rem",
472
- align: "center",
473
- justify: "space-between",
474
- },
475
- },
476
- [
477
- "h1",
478
- "dashboard-title",
479
- { textContent: "Dashboard", class: "dashboard-title" },
480
- ],
481
- [
482
- "div",
483
- "header-actions",
484
- {
485
- component: {
486
- creator: () =>
487
- createButton({
488
- type: "filled",
489
- label: "New Item",
490
- icon: "add",
491
- }),
492
- options: {},
493
- },
494
- },
495
- ],
496
- ],
497
-
498
- // Stats cards
499
- [
500
- "div",
501
- "stats-row",
502
- {
503
- layoutItem: { span: 12 },
504
- layout: { type: "grid", columns: 4, gap: "1rem" },
505
- },
506
- [
507
- "div",
508
- "stat-card-1",
509
- {
510
- component: {
511
- creator: () =>
512
- createCard({
513
- title: "Total Sales",
514
- content: "$24,567",
515
- variant: "elevated",
516
- }),
517
- options: {},
518
- },
519
- },
520
- ],
521
- [
522
- "div",
523
- "stat-card-2",
524
- {
525
- component: {
526
- creator: () =>
527
- createCard({
528
- title: "New Customers",
529
- content: "156",
530
- variant: "elevated",
531
- }),
532
- options: {},
533
- },
534
- },
535
- ],
536
- [
537
- "div",
538
- "stat-card-3",
539
- {
540
- component: {
541
- creator: () =>
542
- createCard({
543
- title: "Conversion Rate",
544
- content: "3.24%",
545
- variant: "elevated",
546
- }),
547
- options: {},
548
- },
549
- },
550
- ],
551
- [
552
- "div",
553
- "stat-card-4",
554
- {
555
- component: {
556
- creator: () =>
557
- createCard({
558
- title: "Active Users",
559
- content: "1,247",
560
- variant: "elevated",
561
- }),
562
- options: {},
563
- },
564
- },
565
- ],
566
- ],
567
-
568
- // Main content area
569
- [
570
- "div",
571
- "main-content",
572
- {
573
- layoutItem: { span: 8 },
574
- layout: { type: "stack", gap: "1.5rem" },
575
- },
576
- // Tabs for different views
577
- [
578
- "div",
579
- "content-tabs",
580
- {
581
- component: {
582
- creator: () =>
583
- createTabs({
584
- tabs: [
585
- { id: "overview", label: "Overview", active: true },
586
- { id: "analytics", label: "Analytics" },
587
- { id: "reports", label: "Reports" },
588
- ],
589
- }),
590
- options: {},
591
- },
592
- },
593
- ],
594
-
595
- // Data card
596
- [
597
- "div",
598
- "data-card",
599
- {
600
- component: {
601
- creator: () =>
602
- createCard({
603
- title: "Recent Activity",
604
- content: "Loading recent activities...",
605
- variant: "outlined",
606
- }),
607
- options: {},
608
- },
609
- },
610
- ],
611
- ],
612
-
613
- // Sidebar
614
- [
615
- "aside",
616
- "sidebar",
617
- {
618
- layoutItem: { span: 4 },
619
- layout: { type: "stack", gap: "1rem" },
620
- },
621
- // Quick actions list
622
- [
623
- "div",
624
- "quick-actions",
625
- {
626
- component: {
627
- creator: () =>
628
- createList({
629
- title: "Quick Actions",
630
- items: [
631
- {
632
- id: "1",
633
- text: "Create new project",
634
- icon: "add_circle",
635
- },
636
- { id: "2", text: "View reports", icon: "assessment" },
637
- { id: "3", text: "Manage users", icon: "people" },
638
- { id: "4", text: "Settings", icon: "settings" },
639
- ],
640
- }),
641
- options: {},
642
- },
643
- },
644
- ],
645
-
646
- // Notifications card
647
- [
648
- "div",
649
- "notifications",
650
- {
651
- component: {
652
- creator: () =>
653
- createCard({
654
- title: "Notifications",
655
- content: "You have 3 new notifications",
656
- variant: "filled",
657
- }),
658
- options: {},
659
- },
660
- },
661
- ],
662
- ],
663
- ];
664
-
665
- addonsPerformance.clearAll();
666
-
667
- const start = hrTimer();
668
- const layouts = [];
669
-
670
- for (let i = 0; i < iterations; i++) {
671
- layouts.push(createLayout(createDashboardSchema()));
672
- }
673
- const createTime = hrTimer() - start;
674
-
675
- const destroyStart = hrTimer();
676
- layouts.forEach((layout) => layout.destroy());
677
- const destroyTime = hrTimer() - destroyStart;
678
-
679
- const totalTime = createTime + destroyTime;
680
- const avgTimePerDashboard = totalTime / iterations;
681
- const totalComponents = iterations * 12; // ~12 real components per dashboard
682
-
683
- console.log(` Creation: ${createTime.toFixed(2)}ms`);
684
- console.log(` Cleanup: ${destroyTime.toFixed(2)}ms`);
685
- console.log(` Total: ${totalTime.toFixed(2)}ms`);
686
- console.log(` Per dashboard: ${avgTimePerDashboard.toFixed(3)}ms`);
687
- console.log(
688
- ` Per component: ${(totalTime / totalComponents).toFixed(4)}ms`
689
- );
690
- console.log(
691
- ` Throughput: ${Math.round(
692
- iterations / (totalTime / 1000)
693
- ).toLocaleString()} dashboards/sec`
694
- );
695
-
696
- expect(totalTime).toBeLessThan(60000); // Should complete within 1 minute
697
- expect(avgTimePerDashboard).toBeLessThan(600); // Should be under 600ms per dashboard
698
- });
699
- });
700
-
701
- describe("Integration Performance Summary", () => {
702
- test("real component performance summary", () => {
703
- console.log(`\n🎯 Real Component Integration Summary:`);
704
- console.log(`============================================`);
705
- console.log(`✅ Button layouts: Real mtrl.createButton() components`);
706
- console.log(`✅ Form layouts: Complex forms with multiple field types`);
707
- console.log(`✅ Dashboard layouts: Cards, lists, tabs, and navigation`);
708
-
709
- console.log(`\n📊 Expected Performance with Real Components:`);
710
- console.log(` • Simple button layout: ~5-15ms`);
711
- console.log(` • Complex form: ~50-150ms`);
712
- console.log(` • Full dashboard: ~200-600ms`);
713
-
714
- console.log(`\n💡 Real vs Mock Component Overhead:`);
715
- console.log(` • Mock components: ~0.02-0.05ms per component`);
716
- console.log(` • Real components: ~2-15ms per component`);
717
- console.log(` • Overhead factor: ~100-300x (expected)`);
718
-
719
- console.log(`\n🚀 Production Optimization:`);
720
- console.log(` • Component pooling: Reuse component instances`);
721
- console.log(` • Lazy loading: Create components on demand`);
722
- console.log(` • Batch operations: Group component creation`);
723
- console.log(` • Fragment optimization: Already implemented`);
724
-
725
- console.log(`\n🏆 CONCLUSION: mtrl-addons + real mtrl components`);
726
- console.log(
727
- ` perform excellently even with component creation overhead!`
728
- );
729
-
730
- expect(true).toBe(true); // This is a summary test
731
- });
732
- });
733
- });