@aquera/nile-elements 1.2.6-beta-1.0 → 1.2.6-beta-1.1
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/demo/index.html +29 -50
- package/dist/index.js +30 -32
- package/dist/nile-select/nile-select.cjs.js +1 -1
- package/dist/nile-select/nile-select.cjs.js.map +1 -1
- package/dist/nile-select/nile-select.esm.js +5 -5
- package/dist/nile-select/virtual-scroll-helper.cjs.js +1 -1
- package/dist/nile-select/virtual-scroll-helper.cjs.js.map +1 -1
- package/dist/nile-select/virtual-scroll-helper.esm.js +0 -2
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js +2 -2
- package/dist/nile-virtual-select/nile-virtual-select.cjs.js.map +1 -1
- package/dist/nile-virtual-select/nile-virtual-select.esm.js +13 -13
- package/dist/src/nile-select/nile-select.d.ts +0 -12
- package/dist/src/nile-select/nile-select.js +0 -83
- package/dist/src/nile-select/nile-select.js.map +1 -1
- package/dist/src/nile-select/virtual-scroll-helper.js +0 -2
- package/dist/src/nile-select/virtual-scroll-helper.js.map +1 -1
- package/dist/src/nile-virtual-select/nile-virtual-select.d.ts +0 -12
- package/dist/src/nile-virtual-select/nile-virtual-select.js +54 -93
- package/dist/src/nile-virtual-select/nile-virtual-select.js.map +1 -1
- package/dist/src/version.js +1 -1
- package/dist/src/version.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/nile-select/nile-select.ts +0 -104
- package/src/nile-select/virtual-scroll-helper.ts +0 -2
- package/src/nile-virtual-select/nile-virtual-select.ts +58 -119
- package/vscode-html-custom-data.json +2 -22
|
@@ -115,7 +115,6 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
115
115
|
this.searchValue = '';
|
|
116
116
|
/** Enable search functionality */
|
|
117
117
|
this.searchEnabled = false;
|
|
118
|
-
this.enableVisibilityEffect = false;
|
|
119
118
|
/** Search input placeholder */
|
|
120
119
|
this.internalSearchPlaceHolder = 'Search...';
|
|
121
120
|
/** Disable local search filtering */
|
|
@@ -187,24 +186,8 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
187
186
|
*/
|
|
188
187
|
this.maxOptionsVisible = 3;
|
|
189
188
|
this.oldMaxOptionsVisible = 1;
|
|
190
|
-
this.enableTabClose = false;
|
|
191
189
|
this.showListbox = false;
|
|
192
190
|
this.wasShowSelectedCheckedOnClose = false;
|
|
193
|
-
/** All active IntersectionObservers for visibility detection */
|
|
194
|
-
this.anchorVisibilityObservers = [];
|
|
195
|
-
/** Handles tab visibility (page hidden / tab switched) */
|
|
196
|
-
this.handleDocumentVisibilityChange = () => {
|
|
197
|
-
if (!this.enableTabClose)
|
|
198
|
-
return;
|
|
199
|
-
if (document.visibilityState === 'hidden' && this.open) {
|
|
200
|
-
this.hide();
|
|
201
|
-
this.emit('nile-visibility-change', {
|
|
202
|
-
visible: false,
|
|
203
|
-
reason: 'document-hidden',
|
|
204
|
-
name: this.name,
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
191
|
this.handleDocumentMouseDown = (event) => {
|
|
209
192
|
if (!this.open)
|
|
210
193
|
return;
|
|
@@ -352,63 +335,6 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
352
335
|
this.hasFocus = false;
|
|
353
336
|
this.emit('nile-blur');
|
|
354
337
|
}
|
|
355
|
-
/** Utility: find ALL scrollable ancestors (not just the nearest) */
|
|
356
|
-
getScrollableAncestors(element) {
|
|
357
|
-
const scrollables = [];
|
|
358
|
-
let parent = element.parentElement;
|
|
359
|
-
while (parent) {
|
|
360
|
-
const style = getComputedStyle(parent);
|
|
361
|
-
const canScroll = /(auto|scroll)/.test(style.overflow + style.overflowY + style.overflowX);
|
|
362
|
-
if (canScroll) {
|
|
363
|
-
scrollables.push(parent);
|
|
364
|
-
}
|
|
365
|
-
parent = parent.parentElement;
|
|
366
|
-
}
|
|
367
|
-
return scrollables;
|
|
368
|
-
}
|
|
369
|
-
/** Sets up visibility tracking for all relevant contexts */
|
|
370
|
-
setupAnchorVisibilityObserver() {
|
|
371
|
-
if (!this.enableVisibilityEffect)
|
|
372
|
-
return;
|
|
373
|
-
this.cleanupAnchorVisibilityObserver();
|
|
374
|
-
const combobox = this.combobox;
|
|
375
|
-
if (!combobox)
|
|
376
|
-
return;
|
|
377
|
-
// Get all scrollable ancestors and viewport
|
|
378
|
-
const scrollContainers = [...this.getScrollableAncestors(this), null];
|
|
379
|
-
scrollContainers.forEach((rootContainer) => {
|
|
380
|
-
const observer = new IntersectionObserver((entries) => {
|
|
381
|
-
for (const entry of entries) {
|
|
382
|
-
if (!entry.isIntersecting && this.open) {
|
|
383
|
-
this.hide();
|
|
384
|
-
this.emit('nile-visibility-change', {
|
|
385
|
-
visible: false,
|
|
386
|
-
reason: 'anchor-out-of-view',
|
|
387
|
-
name: this.name,
|
|
388
|
-
root: rootContainer,
|
|
389
|
-
});
|
|
390
|
-
return; // stop further triggers
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}, {
|
|
394
|
-
root: rootContainer,
|
|
395
|
-
threshold: 0.1, // 10% visible = visible
|
|
396
|
-
});
|
|
397
|
-
observer.observe(combobox);
|
|
398
|
-
this.anchorVisibilityObservers.push(observer);
|
|
399
|
-
});
|
|
400
|
-
// Attach tab visibility listener only if property enabled
|
|
401
|
-
if (this.enableTabClose) {
|
|
402
|
-
document.addEventListener('visibilitychange', this.handleDocumentVisibilityChange);
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
/** Cleans up all visibility observers and listeners */
|
|
406
|
-
cleanupAnchorVisibilityObserver() {
|
|
407
|
-
this.anchorVisibilityObservers.forEach((o) => o.disconnect());
|
|
408
|
-
this.anchorVisibilityObservers = [];
|
|
409
|
-
// Always remove listener to avoid stale callbacks
|
|
410
|
-
document.removeEventListener('visibilitychange', this.handleDocumentVisibilityChange);
|
|
411
|
-
}
|
|
412
338
|
handleDocumentFocusIn(event) {
|
|
413
339
|
if (!this.open)
|
|
414
340
|
return;
|
|
@@ -648,6 +574,9 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
648
574
|
}
|
|
649
575
|
handleSearchChange(e) {
|
|
650
576
|
this.searchValue = e.detail.value;
|
|
577
|
+
if (this.portal) {
|
|
578
|
+
this.portalManager.updatePortalAppendPosition();
|
|
579
|
+
}
|
|
651
580
|
this.emit('nile-search', {
|
|
652
581
|
query: this.searchValue,
|
|
653
582
|
name: this.name
|
|
@@ -709,6 +638,19 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
709
638
|
}
|
|
710
639
|
filterVirtualOptions(searchValue) {
|
|
711
640
|
const result = VirtualSelectSearchManager.filterVirtualOptions(searchValue, this.originalOptionItems, this.data, this.getDisplayText.bind(this), this.renderItemConfig?.getSearchText);
|
|
641
|
+
if (this.portal) {
|
|
642
|
+
this.portalManager.updatePortalAppendPosition();
|
|
643
|
+
this.updateComplete.then(() => {
|
|
644
|
+
requestAnimationFrame(() => {
|
|
645
|
+
requestAnimationFrame(() => {
|
|
646
|
+
this.resetScrollPosition();
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
this.resetScrollPosition();
|
|
653
|
+
}
|
|
712
654
|
this.data = result.filteredItems;
|
|
713
655
|
this.showNoResults = result.showNoResults;
|
|
714
656
|
this.showSelected = false;
|
|
@@ -810,15 +752,11 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
810
752
|
this.data = [...this.originalOptionItems];
|
|
811
753
|
this.wasShowSelectedCheckedOnClose = false;
|
|
812
754
|
}
|
|
813
|
-
if (this.enableVisibilityEffect) {
|
|
814
|
-
this.setupAnchorVisibilityObserver();
|
|
815
|
-
}
|
|
816
755
|
this.filterVirtualOptions("");
|
|
817
756
|
this.resetScrollPosition();
|
|
818
757
|
this.emit('nile-after-show', { value: this.value, name: this.name });
|
|
819
758
|
}
|
|
820
759
|
async handleClose() {
|
|
821
|
-
this.cleanupAnchorVisibilityObserver();
|
|
822
760
|
this.emit('nile-hide', { value: this.value, name: this.name });
|
|
823
761
|
this.removeOpenListeners();
|
|
824
762
|
this.wasShowSelectedCheckedOnClose = this.showSelected;
|
|
@@ -1298,19 +1236,48 @@ let NileVirtualSelect = class NileVirtualSelect extends NileElement {
|
|
|
1298
1236
|
this.maxOptionsVisible = lastindex;
|
|
1299
1237
|
}, 1);
|
|
1300
1238
|
}
|
|
1301
|
-
resetScrollPosition() {
|
|
1302
|
-
this.updateComplete
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1239
|
+
async resetScrollPosition() {
|
|
1240
|
+
await this.updateComplete;
|
|
1241
|
+
requestAnimationFrame(() => {
|
|
1242
|
+
requestAnimationFrame(() => {
|
|
1243
|
+
let listbox = null;
|
|
1244
|
+
// Select listbox (portal vs non-portal)
|
|
1245
|
+
if (this.portal && this.portalManager.portalContainerElement) {
|
|
1246
|
+
listbox = this.portalManager.portalContainerElement.querySelector('#listbox');
|
|
1308
1247
|
}
|
|
1309
|
-
|
|
1248
|
+
else {
|
|
1249
|
+
listbox = this.shadowRoot?.querySelector('#listbox');
|
|
1250
|
+
}
|
|
1251
|
+
if (!listbox || !listbox.isConnected)
|
|
1252
|
+
return;
|
|
1253
|
+
// Always reset scroll position
|
|
1254
|
+
listbox.scrollTop = 0;
|
|
1255
|
+
// When very few items, collapse overflow completely
|
|
1256
|
+
const virtualized = listbox.querySelector('.virtualized');
|
|
1257
|
+
if (virtualized && virtualized.isConnected) {
|
|
1258
|
+
const fewItems = this.data.length <= 5;
|
|
1259
|
+
if (fewItems) {
|
|
1260
|
+
// 👇 Prevent *any* scrolling and let height shrink
|
|
1261
|
+
virtualized.style.overflowY = 'hidden';
|
|
1262
|
+
virtualized.style.maxHeight = 'none';
|
|
1263
|
+
listbox.style.overflowY = 'hidden';
|
|
1264
|
+
listbox.style.maxHeight = 'fit-content';
|
|
1265
|
+
}
|
|
1266
|
+
else {
|
|
1267
|
+
// 👇 Re-enable scrolling when many items
|
|
1268
|
+
virtualized.style.overflowY = 'auto';
|
|
1269
|
+
virtualized.style.maxHeight = '';
|
|
1270
|
+
listbox.style.overflowY = 'auto';
|
|
1271
|
+
listbox.style.maxHeight = '';
|
|
1272
|
+
}
|
|
1273
|
+
virtualized.scrollTop = 0;
|
|
1274
|
+
}
|
|
1275
|
+
// lit-virtualizer (if used)
|
|
1276
|
+
const virtualizer = listbox.querySelector('lit-virtualizer');
|
|
1310
1277
|
if (virtualizer && virtualizer.isConnected) {
|
|
1311
1278
|
virtualizer.scrollTop = 0;
|
|
1312
1279
|
}
|
|
1313
|
-
}
|
|
1280
|
+
});
|
|
1314
1281
|
});
|
|
1315
1282
|
}
|
|
1316
1283
|
};
|
|
@@ -1377,9 +1344,6 @@ __decorate([
|
|
|
1377
1344
|
__decorate([
|
|
1378
1345
|
property({ type: Boolean, reflect: true })
|
|
1379
1346
|
], NileVirtualSelect.prototype, "searchEnabled", void 0);
|
|
1380
|
-
__decorate([
|
|
1381
|
-
property({ type: Boolean, reflect: true, attribute: true })
|
|
1382
|
-
], NileVirtualSelect.prototype, "enableVisibilityEffect", void 0);
|
|
1383
1347
|
__decorate([
|
|
1384
1348
|
property({ attribute: 'internal-search-placeholder' })
|
|
1385
1349
|
], NileVirtualSelect.prototype, "internalSearchPlaceHolder", void 0);
|
|
@@ -1467,9 +1431,6 @@ __decorate([
|
|
|
1467
1431
|
__decorate([
|
|
1468
1432
|
state()
|
|
1469
1433
|
], NileVirtualSelect.prototype, "oldMaxOptionsVisible", void 0);
|
|
1470
|
-
__decorate([
|
|
1471
|
-
property({ type: Boolean, reflect: true, attribute: true })
|
|
1472
|
-
], NileVirtualSelect.prototype, "enableTabClose", void 0);
|
|
1473
1434
|
__decorate([
|
|
1474
1435
|
state()
|
|
1475
1436
|
], NileVirtualSelect.prototype, "showListbox", void 0);
|