mtrl-addons 0.2.1 โ 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.
- package/AI.md +28 -230
- package/CLAUDE.md +882 -0
- package/build.js +286 -110
- package/package.json +2 -1
- package/src/components/vlist/features/api.ts +316 -12
- package/src/components/vlist/features/selection.ts +248 -256
- package/src/components/vlist/features/viewport.ts +1 -7
- package/src/components/vlist/index.ts +1 -0
- package/src/components/vlist/types.ts +140 -8
- package/src/core/layout/schema.ts +81 -38
- package/src/core/viewport/constants.ts +7 -2
- package/src/core/viewport/features/collection.ts +376 -76
- package/src/core/viewport/features/item-size.ts +4 -4
- package/src/core/viewport/features/momentum.ts +11 -2
- package/src/core/viewport/features/rendering.ts +424 -30
- package/src/core/viewport/features/scrolling.ts +41 -25
- package/src/core/viewport/features/utils.ts +11 -5
- package/src/core/viewport/features/virtual.ts +169 -28
- package/src/core/viewport/types.ts +2 -2
- package/src/core/viewport/viewport.ts +29 -10
- package/src/styles/components/_vlist.scss +234 -213
package/AI.md
CHANGED
|
@@ -1,241 +1,39 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AI Assistant Guide
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## ๐ Hello AI Assistant!
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This project uses **CLAUDE.md** as the primary development guide and documentation for AI assistants.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
### If you are Claude:
|
|
8
|
+
โ **See [CLAUDE.md](./CLAUDE.md)** for complete development guidelines
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
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
|
-
|
|
235
|
-
-
|
|
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
|
-
|
|
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! ๐
|