@keenmate/pure-admin-core 2.9.0-rc03 → 2.9.0-rc05
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/README.md +55 -13
- package/dist/css/main.css +554 -7
- package/package.json +3 -1
- package/snippets/buttons.html +51 -0
- package/snippets/cards.html +132 -47
- package/snippets/comparison.html +26 -22
- package/snippets/manifest.json +180 -115
- package/snippets/range-group.html +125 -0
- package/snippets/splitter.html +44 -38
- package/snippets/statistics.html +31 -0
- package/src/js/btn-split-auto-absorb.js +327 -0
- package/src/js/command-palette.js +472 -0
- package/src/js/file-selector.js +1275 -0
- package/src/js/internal/logging.js +121 -0
- package/src/js/logic-tree-renderer.js +303 -0
- package/src/js/modal-dialogs.js +460 -0
- package/src/js/overflow.js +371 -0
- package/src/js/pa-stat-fit.js +184 -0
- package/src/js/range-group.js +663 -0
- package/src/js/search-autocomplete-v2.js +907 -0
- package/src/js/search-autocomplete.js +434 -0
- package/src/js/settings-panel.js +245 -0
- package/src/js/split-button.js +141 -0
- package/src/js/splitter.js +1323 -0
- package/src/js/toast-service.js +302 -0
- package/src/js/tooltips-popovers.js +275 -0
- package/src/js/virtual-scroll.js +143 -0
- package/src/js/virtual-textbox.js +803 -0
- package/src/scss/_core.scss +7 -0
- package/src/scss/core-components/_buttons.scss +44 -0
- package/src/scss/core-components/_cards.scss +95 -6
- package/src/scss/core-components/_overflow.scss +50 -0
- package/src/scss/core-components/_range-group.scss +474 -0
- package/src/scss/core-components/_statistics.scss +163 -0
- package/src/scss/variables/_components.scss +41 -2
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure Admin Virtual Scroll
|
|
3
|
+
*
|
|
4
|
+
* A general-purpose virtual scrolling utility that keeps DOM size constant
|
|
5
|
+
* by rendering only visible items. Works with tables, lists, timelines, etc.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const vs = new VirtualScroll({
|
|
9
|
+
* container: document.getElementById('my-container'),
|
|
10
|
+
* itemHeight: 50,
|
|
11
|
+
* totalItems: 10000,
|
|
12
|
+
* renderItem: (index) => {
|
|
13
|
+
* const div = document.createElement('div');
|
|
14
|
+
* div.textContent = `Item ${index}`;
|
|
15
|
+
* return div;
|
|
16
|
+
* }
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
class VirtualScroll {
|
|
20
|
+
constructor(options) {
|
|
21
|
+
// Required options
|
|
22
|
+
this.container = options.container;
|
|
23
|
+
this.itemHeight = options.itemHeight || 50;
|
|
24
|
+
this.totalItems = options.totalItems || 0;
|
|
25
|
+
this.renderItem = options.renderItem;
|
|
26
|
+
|
|
27
|
+
// Optional options
|
|
28
|
+
this.bufferSize = options.bufferSize || 5; // Extra items to render above/below viewport
|
|
29
|
+
this.onScroll = options.onScroll || null;
|
|
30
|
+
|
|
31
|
+
// Internal state
|
|
32
|
+
this.scrollTop = 0;
|
|
33
|
+
this.viewportHeight = 0;
|
|
34
|
+
this.visibleStart = 0;
|
|
35
|
+
this.visibleEnd = 0;
|
|
36
|
+
|
|
37
|
+
// Create internal structure
|
|
38
|
+
this.init();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
init() {
|
|
42
|
+
// Clear container
|
|
43
|
+
this.container.innerHTML = '';
|
|
44
|
+
|
|
45
|
+
// Create wrapper for positioning
|
|
46
|
+
this.wrapper = document.createElement('div');
|
|
47
|
+
this.wrapper.style.position = 'relative';
|
|
48
|
+
this.wrapper.style.height = `${this.totalItems * this.itemHeight}px`;
|
|
49
|
+
|
|
50
|
+
// Create viewport for visible items
|
|
51
|
+
this.viewport = document.createElement('div');
|
|
52
|
+
this.viewport.style.position = 'absolute';
|
|
53
|
+
this.viewport.style.top = '0';
|
|
54
|
+
this.viewport.style.left = '0';
|
|
55
|
+
this.viewport.style.right = '0';
|
|
56
|
+
|
|
57
|
+
this.wrapper.appendChild(this.viewport);
|
|
58
|
+
this.container.appendChild(this.wrapper);
|
|
59
|
+
|
|
60
|
+
// Set container styles if not set
|
|
61
|
+
if (!this.container.style.overflowY) {
|
|
62
|
+
this.container.style.overflowY = 'auto';
|
|
63
|
+
}
|
|
64
|
+
if (!this.container.style.position || this.container.style.position === 'static') {
|
|
65
|
+
this.container.style.position = 'relative';
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Bind scroll handler
|
|
69
|
+
this.container.addEventListener('scroll', this.handleScroll.bind(this));
|
|
70
|
+
|
|
71
|
+
// Initial render
|
|
72
|
+
this.viewportHeight = this.container.clientHeight;
|
|
73
|
+
this.render();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
handleScroll() {
|
|
77
|
+
this.scrollTop = this.container.scrollTop;
|
|
78
|
+
this.render();
|
|
79
|
+
|
|
80
|
+
if (this.onScroll) {
|
|
81
|
+
this.onScroll(this.scrollTop);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
render() {
|
|
86
|
+
// Calculate visible range
|
|
87
|
+
const startIndex = Math.floor(this.scrollTop / this.itemHeight);
|
|
88
|
+
const endIndex = Math.ceil((this.scrollTop + this.viewportHeight) / this.itemHeight);
|
|
89
|
+
|
|
90
|
+
// Add buffer
|
|
91
|
+
this.visibleStart = Math.max(0, startIndex - this.bufferSize);
|
|
92
|
+
this.visibleEnd = Math.min(this.totalItems, endIndex + this.bufferSize);
|
|
93
|
+
|
|
94
|
+
// Clear viewport
|
|
95
|
+
this.viewport.innerHTML = '';
|
|
96
|
+
|
|
97
|
+
// Render visible items
|
|
98
|
+
for (let i = this.visibleStart; i < this.visibleEnd; i++) {
|
|
99
|
+
const item = this.renderItem(i);
|
|
100
|
+
|
|
101
|
+
// Set item position
|
|
102
|
+
if (item) {
|
|
103
|
+
item.style.position = 'absolute';
|
|
104
|
+
item.style.top = `${i * this.itemHeight}px`;
|
|
105
|
+
item.style.left = '0';
|
|
106
|
+
item.style.right = '0';
|
|
107
|
+
|
|
108
|
+
this.viewport.appendChild(item);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Update total items and re-render
|
|
114
|
+
setTotalItems(count) {
|
|
115
|
+
this.totalItems = count;
|
|
116
|
+
this.wrapper.style.height = `${this.totalItems * this.itemHeight}px`;
|
|
117
|
+
this.render();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Scroll to specific item
|
|
121
|
+
scrollToItem(index) {
|
|
122
|
+
this.container.scrollTop = index * this.itemHeight;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Get current visible range
|
|
126
|
+
getVisibleRange() {
|
|
127
|
+
return {
|
|
128
|
+
start: this.visibleStart,
|
|
129
|
+
end: this.visibleEnd
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Destroy and cleanup
|
|
134
|
+
destroy() {
|
|
135
|
+
this.container.removeEventListener('scroll', this.handleScroll.bind(this));
|
|
136
|
+
this.container.innerHTML = '';
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Export for use
|
|
141
|
+
if (typeof module !== 'undefined' && module.exports) {
|
|
142
|
+
module.exports = VirtualScroll;
|
|
143
|
+
}
|