mtrl-addons 0.1.2 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (117) hide show
  1. package/AI.md +28 -230
  2. package/CLAUDE.md +882 -0
  3. package/build.js +253 -24
  4. package/package.json +14 -4
  5. package/scripts/debug/vlist-selection.ts +121 -0
  6. package/src/components/index.ts +5 -41
  7. package/src/components/{list → vlist}/config.ts +66 -95
  8. package/src/components/vlist/constants.ts +23 -0
  9. package/src/components/vlist/features/api.ts +626 -0
  10. package/src/components/vlist/features/index.ts +10 -0
  11. package/src/components/vlist/features/selection.ts +436 -0
  12. package/src/components/vlist/features/viewport.ts +59 -0
  13. package/src/components/vlist/index.ts +17 -0
  14. package/src/components/{list → vlist}/types.ts +242 -32
  15. package/src/components/vlist/vlist.ts +92 -0
  16. package/src/core/compose/features/gestures/index.ts +227 -0
  17. package/src/core/compose/features/gestures/longpress.ts +383 -0
  18. package/src/core/compose/features/gestures/pan.ts +424 -0
  19. package/src/core/compose/features/gestures/pinch.ts +475 -0
  20. package/src/core/compose/features/gestures/rotate.ts +485 -0
  21. package/src/core/compose/features/gestures/swipe.ts +492 -0
  22. package/src/core/compose/features/gestures/tap.ts +334 -0
  23. package/src/core/compose/features/index.ts +2 -38
  24. package/src/core/compose/index.ts +13 -29
  25. package/src/core/gestures/index.ts +31 -0
  26. package/src/core/gestures/longpress.ts +68 -0
  27. package/src/core/gestures/manager.ts +418 -0
  28. package/src/core/gestures/pan.ts +48 -0
  29. package/src/core/gestures/pinch.ts +58 -0
  30. package/src/core/gestures/rotate.ts +58 -0
  31. package/src/core/gestures/swipe.ts +66 -0
  32. package/src/core/gestures/tap.ts +45 -0
  33. package/src/core/gestures/types.ts +387 -0
  34. package/src/core/gestures/utils.ts +128 -0
  35. package/src/core/index.ts +27 -151
  36. package/src/core/layout/schema.ts +153 -72
  37. package/src/core/layout/types.ts +5 -2
  38. package/src/core/viewport/constants.ts +145 -0
  39. package/src/core/viewport/features/base.ts +73 -0
  40. package/src/core/viewport/features/collection.ts +1182 -0
  41. package/src/core/viewport/features/events.ts +130 -0
  42. package/src/core/viewport/features/index.ts +20 -0
  43. package/src/core/{list-manager/features/viewport → viewport/features}/item-size.ts +31 -34
  44. package/src/core/{list-manager/features/viewport → viewport/features}/loading.ts +4 -4
  45. package/src/core/viewport/features/momentum.ts +269 -0
  46. package/src/core/viewport/features/placeholders.ts +335 -0
  47. package/src/core/viewport/features/rendering.ts +962 -0
  48. package/src/core/viewport/features/scrollbar.ts +434 -0
  49. package/src/core/viewport/features/scrolling.ts +634 -0
  50. package/src/core/viewport/features/utils.ts +94 -0
  51. package/src/core/viewport/features/virtual.ts +525 -0
  52. package/src/core/viewport/index.ts +31 -0
  53. package/src/core/viewport/types.ts +133 -0
  54. package/src/core/viewport/utils/speed-tracker.ts +79 -0
  55. package/src/core/viewport/viewport.ts +265 -0
  56. package/src/index.ts +0 -7
  57. package/src/styles/components/_vlist.scss +352 -0
  58. package/src/styles/index.scss +1 -1
  59. package/test/components/vlist-selection.test.ts +240 -0
  60. package/test/components/vlist.test.ts +63 -0
  61. package/test/core/collection/adapter.test.ts +161 -0
  62. package/bun.lock +0 -792
  63. package/src/components/list/api.ts +0 -314
  64. package/src/components/list/constants.ts +0 -56
  65. package/src/components/list/features/api.ts +0 -428
  66. package/src/components/list/features/index.ts +0 -31
  67. package/src/components/list/features/list-manager.ts +0 -502
  68. package/src/components/list/index.ts +0 -39
  69. package/src/components/list/list.ts +0 -234
  70. package/src/core/collection/base-collection.ts +0 -100
  71. package/src/core/collection/collection-composer.ts +0 -178
  72. package/src/core/collection/collection.ts +0 -745
  73. package/src/core/collection/constants.ts +0 -172
  74. package/src/core/collection/events.ts +0 -428
  75. package/src/core/collection/features/api/loading.ts +0 -279
  76. package/src/core/collection/features/operations/data-operations.ts +0 -147
  77. package/src/core/collection/index.ts +0 -104
  78. package/src/core/collection/state.ts +0 -497
  79. package/src/core/collection/types.ts +0 -404
  80. package/src/core/compose/features/collection.ts +0 -119
  81. package/src/core/compose/features/selection.ts +0 -213
  82. package/src/core/compose/features/styling.ts +0 -108
  83. package/src/core/list-manager/api.ts +0 -599
  84. package/src/core/list-manager/config.ts +0 -593
  85. package/src/core/list-manager/constants.ts +0 -268
  86. package/src/core/list-manager/features/api.ts +0 -58
  87. package/src/core/list-manager/features/collection/collection.ts +0 -705
  88. package/src/core/list-manager/features/collection/index.ts +0 -17
  89. package/src/core/list-manager/features/viewport/constants.ts +0 -42
  90. package/src/core/list-manager/features/viewport/index.ts +0 -16
  91. package/src/core/list-manager/features/viewport/placeholders.ts +0 -281
  92. package/src/core/list-manager/features/viewport/rendering.ts +0 -575
  93. package/src/core/list-manager/features/viewport/scrollbar.ts +0 -495
  94. package/src/core/list-manager/features/viewport/scrolling.ts +0 -795
  95. package/src/core/list-manager/features/viewport/template.ts +0 -220
  96. package/src/core/list-manager/features/viewport/viewport.ts +0 -654
  97. package/src/core/list-manager/features/viewport/virtual.ts +0 -309
  98. package/src/core/list-manager/index.ts +0 -279
  99. package/src/core/list-manager/list-manager.ts +0 -206
  100. package/src/core/list-manager/types.ts +0 -439
  101. package/src/core/list-manager/utils/calculations.ts +0 -290
  102. package/src/core/list-manager/utils/range-calculator.ts +0 -349
  103. package/src/core/list-manager/utils/speed-tracker.ts +0 -273
  104. package/src/styles/components/_list.scss +0 -244
  105. package/src/types/mtrl.d.ts +0 -6
  106. package/test/components/list.test.ts +0 -256
  107. package/test/core/collection/failed-ranges.test.ts +0 -270
  108. package/test/core/compose/features.test.ts +0 -183
  109. package/test/core/list-manager/features/collection.test.ts +0 -704
  110. package/test/core/list-manager/features/viewport.test.ts +0 -698
  111. package/test/core/list-manager/list-manager.test.ts +0 -593
  112. package/test/core/list-manager/utils/calculations.test.ts +0 -433
  113. package/test/core/list-manager/utils/range-calculator.test.ts +0 -569
  114. package/test/core/list-manager/utils/speed-tracker.test.ts +0 -530
  115. package/tsconfig.build.json +0 -23
  116. /package/src/components/{list → vlist}/features.ts +0 -0
  117. /package/src/core/{compose → viewport}/features/performance.ts +0 -0
package/AI.md CHANGED
@@ -1,241 +1,39 @@
1
- # MTRL-ADDONS - AI Assistant Guide
1
+ # AI Assistant Guide
2
2
 
3
- This document provides specific guidance for AI assistants working with the mtrl-addons package - the advanced features extension library for the mtrl ecosystem.
3
+ ## 👋 Hello AI Assistant!
4
4
 
5
- ## 🎯 Package Purpose
5
+ This project uses **CLAUDE.md** as the primary development guide and documentation for AI assistants.
6
6
 
7
- mtrl-addons extends the main mtrl library with advanced features and performance-optimized components:
7
+ ### If you are Claude:
8
+ → **See [CLAUDE.md](./CLAUDE.md)** for complete development guidelines
8
9
 
9
- - **List Manager**: Virtual scrolling with intelligent data loading
10
- - **Collection System**: Advanced data management with caching and state
11
- - **Layout Schema**: Declarative UI composition system
12
- - **Performance Utilities**: Optimized calculations and range management
10
+ ### If you are another AI assistant:
11
+ **See [CLAUDE.md](./CLAUDE.md)** for complete development guidelines
13
12
 
14
- ## 🏗️ Architecture
15
-
16
- ### Core Systems
17
-
18
- ```
19
- src/
20
- ├── components/ # Extended components
21
- │ └── list/ # Advanced list component
22
- ├── core/ # Advanced core features
23
- │ ├── collection/ # Collection management system
24
- │ ├── list-manager/ # Virtual scrolling engine
25
- │ └── layout/ # Layout schema system
26
- └── styles/ # Extended component styles
27
- ```
28
-
29
- ### Key Features
30
-
31
- 1. **List Manager** (`src/core/list-manager/`)
32
- - Virtual scrolling with viewport management
33
- - Item size calculation and caching
34
- - Custom scrollbar implementation
35
- - Collection integration for data loading
36
-
37
- 2. **Collection System** (`src/core/collection/`)
38
- - Data loading and caching strategies
39
- - State management for large datasets
40
- - Event-driven architecture
41
-
42
- 3. **Layout Schema** (`src/core/layout/`)
43
- - Declarative UI composition
44
- - JSX-like syntax for component creation
45
- - Array-based schema system
46
-
47
- ## 🛠️ Development Guidelines
48
-
49
- ### Dependencies
50
- - **Depends on mtrl main** - Import from `mtrl` package
51
- - **Zero additional dependencies** - Maintain the zero-dependency philosophy
52
- - **TypeScript first** - All features in TypeScript
53
-
54
- ### Component Enhancement Pattern
55
- ```typescript
56
- // Use functional composition to enhance components
57
- import { pipe } from 'mtrl/core/compose';
58
- import { createList } from 'mtrl/components/list';
59
-
60
- const enhancedList = pipe(
61
- createList(config),
62
- withCollection(collectionConfig),
63
- withListManager(listManagerConfig),
64
- withViewport(viewportConfig)
65
- );
66
- ```
67
-
68
- ### Performance Focus
69
- - **Virtual scrolling** - Handle massive datasets efficiently
70
- - **Memory optimization** - Minimize DOM elements and memory usage
71
- - **Intelligent loading** - Load data on-demand based on viewport
72
- - **Caching strategies** - Cache measured sizes and loaded data
73
-
74
- ## 📋 List Manager System
75
-
76
- ### Core Components
77
- - **Viewport**: Virtual scrolling and item positioning
78
- - **Collection**: Data loading and state management
79
- - **Item Size Manager**: Dynamic size calculation and caching
80
- - **Scrolling Manager**: Custom scrollbar and scroll handling
81
-
82
- ### Usage Pattern
83
- ```typescript
84
- import { createListManager } from 'mtrl-addons/core/list-manager';
85
-
86
- const listManager = createListManager({
87
- collection: {
88
- loadData: async (range) => fetchItems(range),
89
- totalItems: 100000,
90
- cacheSize: 1000
91
- },
92
- viewport: {
93
- orientation: 'vertical',
94
- estimatedItemSize: 60,
95
- overscan: 5
96
- }
97
- });
98
- ```
99
-
100
- ### Event System
101
- - **Data Loading**: `range:loaded`, `items:set`, `total:changed`
102
- - **Viewport Changes**: `viewport:changed`, `range:rendered`
103
- - **Performance**: `estimated-size:changed`, `dimensions:changed`
104
-
105
- ## 🎨 Styling System
106
-
107
- ### SCSS Architecture
108
- - **Extends mtrl styles** - Build on core style system
109
- - **BEM naming** - `mtrl-addon-component__element--modifier`
110
- - **Performance CSS** - Optimize for virtual scrolling
111
-
112
- ### Virtual Scrolling Styles
113
- ```scss
114
- .mtrl-list-manager {
115
- &__viewport {
116
- overflow: hidden;
117
- position: relative;
118
- }
119
-
120
- &__items {
121
- position: absolute;
122
- top: 0;
123
- left: 0;
124
- }
125
-
126
- &__scrollbar {
127
- // Custom scrollbar styles
128
- }
129
- }
130
- ```
131
-
132
- ## 🧪 Testing Strategy
133
-
134
- ### Test Focus Areas
135
- - **Performance testing** - Measure virtual scrolling performance
136
- - **Data loading** - Test collection loading strategies
137
- - **Memory usage** - Monitor DOM element creation/destruction
138
- - **Viewport calculations** - Test range calculations and positioning
139
-
140
- ### Test Structure
141
- ```typescript
142
- // test/core/list-manager/list-manager.test.ts
143
- describe('ListManager', () => {
144
- it('should handle large datasets efficiently', () => {
145
- // Performance test
146
- });
147
-
148
- it('should load data on demand', () => {
149
- // Data loading test
150
- });
151
- });
152
- ```
153
-
154
- ### Mock Strategies
155
- - **Mock data sources** - Simulate large datasets
156
- - **Mock viewport** - Test different container sizes
157
- - **Mock collection** - Test data loading patterns
158
-
159
- ## 🚀 Common Development Tasks
160
-
161
- ### Adding New List Manager Features
162
- 1. **Create feature module** in `src/core/list-manager/features/`
163
- 2. **Follow enhancement pattern** - Use functional composition
164
- 3. **Add event handling** - Integrate with event system
165
- 4. **Test performance** - Ensure no performance regression
166
-
167
- ### Extending Collection System
168
- 1. **Add to collection features** in `src/core/collection/features/`
169
- 2. **Maintain cache efficiency** - Don't break caching strategies
170
- 3. **Handle edge cases** - Empty datasets, loading failures
171
- 4. **Test data integrity** - Ensure data consistency
172
-
173
- ### Performance Optimization
174
- 1. **Profile virtual scrolling** - Use browser dev tools
175
- 2. **Minimize DOM operations** - Batch updates when possible
176
- 3. **Optimize calculations** - Cache expensive computations
177
- 4. **Monitor memory usage** - Prevent memory leaks
178
-
179
- ## 📊 Performance Benchmarks
180
-
181
- ### Target Metrics
182
- - **Initial render**: < 100ms for 1000+ items
183
- - **Scroll performance**: 60 FPS during scrolling
184
- - **Memory usage**: < 50MB for 100k items
185
- - **Data loading**: < 200ms for range requests
186
-
187
- ### Monitoring Tools
188
- - **Performance tests** in `test/benchmarks/`
189
- - **Memory profiling** with browser dev tools
190
- - **Scroll performance** measurement utilities
191
-
192
- ## 🔧 Integration with mtrl-app
193
-
194
- ### Showcases
195
- - **Create showcases** in `mtrl-app/client/content/components/`
196
- - **Use layout schema** - Demonstrate declarative UI
197
- - **Performance demos** - Show large dataset handling
198
- - **Real-world examples** - Practical use cases
199
-
200
- ### Documentation
201
- - **API documentation** in `mtrl-app/docs/`
202
- - **Performance guides** - Optimization strategies
203
- - **Integration examples** - How to use with mtrl core
204
-
205
- ## 🐛 Common Issues & Solutions
206
-
207
- ### Performance Issues
208
- - **Too many DOM elements** - Increase virtual scrolling efficiency
209
- - **Memory leaks** - Check event listener cleanup
210
- - **Slow scrolling** - Optimize item positioning calculations
211
-
212
- ### Data Loading Issues
213
- - **Loading loops** - Check range calculation logic
214
- - **Missing data** - Verify collection loading strategies
215
- - **Inconsistent state** - Review event handling order
216
-
217
- ### Integration Issues
218
- - **Component composition** - Ensure proper enhancement order
219
- - **Event conflicts** - Check event listener priorities
220
- - **Style conflicts** - Verify CSS specificity
221
-
222
- ## 📚 Key Files Reference
13
+ ---
223
14
 
224
- ### Core Systems
225
- - `src/core/list-manager/list-manager.ts` - Main list manager
226
- - `src/core/collection/collection.ts` - Collection management
227
- - `src/core/layout/schema.ts` - Layout schema system
15
+ ## Quick Links
228
16
 
229
- ### Features
230
- - `src/core/list-manager/features/viewport/` - Virtual scrolling
231
- - `src/core/collection/features/` - Collection features
232
- - `src/core/compose/features/` - Composition utilities
17
+ - **[CLAUDE.md](./CLAUDE.md)** - Complete development guide
18
+ - Project overview and architecture
19
+ - VList component with virtual scrolling
20
+ - Viewport system for virtual positioning
21
+ - Layout schema for declarative UI (JSX-like)
22
+ - Gesture system for touch interactions
23
+ - Development philosophy and standards
24
+ - TypeScript and SCSS guidelines
25
+ - Testing strategy and performance benchmarks
26
+ - Integration with mtrl core
27
+ - Git commit/push rules
233
28
 
234
- ### Tests
235
- - `test/core/list-manager/` - List manager tests
236
- - `test/benchmarks/` - Performance benchmarks
237
- - `test/components/` - Component integration tests
29
+ - **[mtrl](../mtrl/CLAUDE.md)** - Core Material Design 3 library
30
+ - **[mtrl-app](../mtrl-app/.cursorrules)** - Documentation and showcase
238
31
 
239
32
  ---
240
33
 
241
- This guide focuses specifically on mtrl-addons development. For core mtrl development, see `mtrl/CLAUDE.md`. For showcase and documentation, see `mtrl-app/CLAUDE.md`.
34
+ **Package:** mtrl-addons - Extended Components for mtrl
35
+ **Philosophy:** "Less is more" - Zero dependencies (mtrl peer only)
36
+ **Key Features:** VList (virtual list), Viewport system, Layout schema, Gesture handling
37
+ **Documentation:** Everything you need is in CLAUDE.md
38
+
39
+ Enjoy building with mtrl-addons! 🚀